This is the mail archive of the gdb@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[testsuite & dwarf2] How to handle store.exp failure on AMD64?


Hi all,
on AMD64 I'm getting these failures:

Running /ttt/64/gdb-head/gdb/testsuite/gdb.base/store.exp ...
FAIL: gdb.base/store.exp: up print old r - charest
FAIL: gdb.base/store.exp: up print old r - short
FAIL: gdb.base/store.exp: up print old r - int
FAIL: gdb.base/store.exp: up print old r - long
FAIL: gdb.base/store.exp: up print old r - longest
FAIL: gdb.base/store.exp: up print old r - float
FAIL: gdb.base/store.exp: up print old r - double

Maybe these failures should be turned into "expected failures" or something alike [see below for other solutions]. Why?

This is an extracted testcase:
=============
int add_int (register int u, register int v)
{
  return u + v;
}

int wack_int (register int u, register int v)
{
  register int l = u, r = v;
  l = add_int (l, r);
  return l + r;
}

int main (void)
{
  return wack_int (-1, -2);
}
=============

Compile it and do the steps that store.exp does:
$ ./gdb store
GNU gdb 5.3.90_2003-08-07-cvs
[...]
This GDB was configured as "x86_64-unknown-linux-gnu"...
(gdb) break add_int
Breakpoint 1 at 0x40040c: file store.c, line 6.
(gdb) run
Starting program: /ttt/64/tst/store
Breakpoint 1, add_int (u=-1, v=-2) at store.c:6
6         return u + v;
(gdb) up
#1  0x0000000000400429 in wack_int (u=-1, v=-2) at store.c:13
13        l = add_int (l, r);
(gdb) print r
$1 = <value optimized out>
(gdb)

The testsuite expects that 'r' will have a value '-2' which is not the case here. The problem is, that 'r' lives in the register (%rbx) but .debug_frame doesn't contain information how to unwind it's previous value. When I manually added the appropriate rule (DW_CFA_same_value[rbx]) to the generated asm file store.s it worked, but GCC obviously doesn't put it there.
The testsuite also works if I undefine the 'register' keyword. Then the variables live in the memory and everything is fine.


What's the purpose of having the 'register' keyword in this testcase? When the code isn't optimized it doesn't matter where the value lives and if you optimize it then GCC itself decides if it should go to the register or not.

So I see these possible solutions for inhibiting AMD64 testcase failures:
1) undefine 'register' keyword when running the testsuite on AMD64, or
2) make these failures expected on AMD64, or
3) convince GCC to put 'DW_CFA_same_value' for all non-destroyed registers, or
4) let GDB pretend that all registers have the same value unless said otherwise later in the .debug_frame and convince GCC to put a note when their value is overwritten.


Opinions?

Michal Ludvig
--
* SuSE CR, s.r.o     * mludvig@suse.cz
* (+420) 296.545.373 * http://www.suse.cz


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]