Re: [patch] Fix for PR gdb/12573

Jan Kratochvil
2011-03-18T17:13:02Z

On Fri, 18 Mar 2011 18:01:50 +0100, Paul Pluzhnikov wrote:
> On Fri, Mar 18, 2011 at 9:29 AM, Tom Tromey <tromey@redhat.com> wrote:
> >>>>>> "Paul" == Paul Pluzhnikov <ppluzhnikov@google.com> writes:
> >
> > Paul> Attached patch fixes http://sourceware.org/bugzilla/show_bug.cgi?id=12573
> > Paul> by removing (I believe incorrect) assertion.
> >
> > See also:
> >
> > https://bugzilla.redhat.com/show_bug.cgi?id=612253
> >
> > And Jan's patch:
> >
> > http://sourceware.org/ml/gdb-patches/2010-07/msg00533.html
> >
> > I can't say I fully understand Jan's.
>
> The patch looks good to me (and I *think* I understand it).

I have to review it again but for example it would hide another bug but I do
not have a fix for it, it should be pretty straightforward if anyone would
like to write it:

https://bugzilla.redhat.com/show_bug.cgi?id=612253#c6

One of the problems is that GDB tries to skip prologue even for -O2 -g code.
There is no such reason as with -O2 -g the debug info is correct for each
instructions. With -O0 -g there are frame-related absolute addresses of
autovariables which is the reason GDB needs to skip the prologue to have valid
location of such -O0 -g autovariables.

-O2 -g code can be detected for a Compilation Unit if there is referenced any
location list from that CU (suggested by GCC hackers). In such case skipping
prologues should be disabled.

Compilation Unit @ offset 0x90398e:
<0><903999>: Abbrev Number: 1 (DW_TAG_compile_unit)
<90399f> DW_AT_name : ../../gcc/gcc/tree-into-ssa.c
<9039a3> DW_AT_comp_dir : /user/inria/fsf/160832/bld-2/gcc
<1><91073a>: Abbrev Number: 69 (DW_TAG_subprogram)
<91073b> DW_AT_name : add_new_name_mapping
<2><910751>: Abbrev Number: 75 (DW_TAG_formal_parameter)
<910752> DW_AT_name : new_tree
<910759> DW_AT_type : <0x903ea5>
<91075d> DW_AT_location : 0x59d960 (location list)
^^^^^^^^^^^^^^^

(gdb) break add_new_name_mapping
->
(gdb) p/x original_pc
$1 = 0x85be0bd

085be0b0 <add_new_name_mapping>:
85be0b0: 55 push %ebp
85be0b1: 89 e5 mov %esp,%ebp
85be0b3: 57 push %edi
85be0b4: 56 push %esi
85be0b5: 89 c6 mov %eax,%esi
85be0b7: 53 push %ebx
85be0b8: 89 d3 mov %edx,%ebx
85be0ba: 83 ec 4c sub $0x4c,%esp
85be0bd: 80 3d a0 8c ca 08 00 cmpb $0x0,0x8ca8ca0
^^^^^^^

There are other problems but this is the first step which should make the
problems at least no longer affecting this specific case.

Thanks,
Jan