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

[RFA/i386] pb reading insns if breakpoints still inserted (take 2)


Hello,

This is the second attempt at fixing a problem that was documented in:

        http://www.sourceware.org/ml/gdb-patches/2006-04/msg00345.html

A consensus seemed to have emerged while we discussed the patch I
submitted for it in:

        http://www.sourceware.org/ml/gdb-patches/2006-04/msg00367.html

Summary of the problem: When we do next/step operations, we end up
parsing the top frame function prologue and creating a frame_info with
it. Unfortunately, at that point, the breakpoints are still inserted and
that causes the prologue analyzer to misinterpret the function prologue
and consequently breaks unwinding a bit.

I'm just only realizing that I didn't produce a new testcase for it,
so I will do that and send it tonight. Just to refresh our memory,
here is how to reproduce:

        #include <stdio.h>
        
        void
        hello (void)
        {
          printf ("Hello world.\n");
        }
        
        int
        main (void)
        {
          hello ();
        
          return 0;
        }

Compile this code on i386 using STABS. Using dwarf won't show the issue
because GDB doesn't need to do prologue analysis when the frame info is
available.

Then follow the guide:

        (gdb) b *hello
        Breakpoint 1 at 0x401050: file foo.c, line 5.
        (gdb) run
        Starting program: /[...]/foo.exe 
        
        Breakpoint 1, hello () at foo.c:5
        5       {
        (gdb) stepi
        0x00401051      5       {
        (gdb) bt
        #0  0x00401051 in hello () at foo.c:5
        #1  0x00401093 in main () at foo.c:12
        (gdb) stepi
        0x00401053 in hello () at foo.c:5
        5       {

So we're at the third instruction of the function. Here is the backtrace
we get when I request it:

        (gdb) bt
        #0  0x00401053 in hello () at foo.c:5
        #1  0x0022ee88 in ?? ()
        #2  0x00401093 in main () at foo.c:12

We get an extra frame between hello() and main().

2006-07-26  Joel Brobecker  <brobecker@adacore.com>

        * i386-tdep.c (i386_follow_jump): Use read_memory_nobpt to read
        instructions.
        (i386_analyze_struct_return): Likewise.
        (i386_skip_probe): Likewise.
        (i386_match_insn): Likewise.
        (i386_analyze_frame_setup): Likewise.
        (i386_analyze_register_saves): Likewise.
        (i386_skip_prologue): Likewise.

This patch requires that the patch submitted at the address below
be applied first (it undeprecates read_memory_nobpt):

        http://www.sourceware.org/ml/gdb-patches/2006-07/msg00397.html

Tested on x86-linux with stabs as the debugging info format.
No regression.

OK to apply?

Thanks,
-- 
Joel

Attachment: stepi.diff
Description: Text document


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