This is the mail archive of the gdb-patches@sourceware.cygnus.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]

Re: RFA: tolerate code motion


On Apr 28,  2:28pm, Michael Snyder wrote:

> Also in break.exp, in the same optimized test, there is a test
> that expects "break main" to land at a specific line.  But, 
> due to -O2 optimization, there may be code movement, and the
> breakpoint may occur on the second or subsequent line.
> This should not be regarded as a gdb failure.
> 
> 
> 2000-04-28  Michael Snyder  <msnyder@seadog.cygnus.com>
> 
>         * gdb.base/break.exp: When compiled with -O2 optimization, 
>         gdb may not stop at the first line of main, due to code motion.
[...]
> +     -re "Starting program.*Breakpoint \[0-9\]+,.*main .*argc.*argv.* at .*$srcfile:.*$gdb_prompt $"\
> + 	                    { pass "run until function breakpoint, optimized file (code motion)" }

I think this is a good idea, but I need an even more relaxed test
for IA-64.

Here's what I'm seeing...

[kev@mesquite testsuite]$ ../gdb gdb.base/breako2
[...]
This GDB was configured as "ia64-unknown-linux"...
(gdb) b main
Breakpoint 1 at 0x40000000000009c0: file stdlib.h, line 310.

That looks totally wrong, right?

But it turns out that it's correct.  (Unless someone convinces me
otherwise.) Line 310 of stdlib.h happens to be part of an inline
atoi() function.  So what the compiler has done at optimization level
-O2 is move part of the call setup for atoi() to the first instruction
after the prologue.

Here's what happens when I run it...

(gdb) r
Starting program: /home/kev/devo-ia64/bld/gdb/testsuite/gdb.base/breako2 

Breakpoint 1, main (argc=1, argv=0x9ffffffffffffa78, envp=0x1) at stdlib.h:310
310     {
(gdb) x/i $pc
0x40000000000009c0 <main+32>:   [MII]       addl r16=-2097072,r1
(gdb) x/9i main
0x40000000000009a0 <main>:      [MII]       alloc r38=ar.pfs,11,7,0
0x40000000000009a1 <main+1>:                mov r36=r12
0x40000000000009a2 <main+2>:                sxt4 r34=r32
0x40000000000009b0 <main+16>:   [MII]       mov r35=12345
0x40000000000009b1 <main+17>:               mov r37=b0;;
0x40000000000009b2 <main+18>:               adds r12=-16,r12
0x40000000000009c0 <main+32>:   [MII]       addl r16=-2097072,r1
0x40000000000009c1 <main+33>:               mov r41=10
0x40000000000009c2 <main+34>:               mov r42=0

In order to relax your test so that it'll work for this case, we need to
remove the part about $srcfile.  I.e, change the regular expression line to

    -re "Starting program.*Breakpoint \[0-9\]+,.*main .*argc.*argv.* at.*$gdb_prompt $"\

(Untested, but I think it'll work.)

Kevin

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