This is the mail archive of the gdb-testers@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]

[binutils-gdb] out of line functions nested inside inline functions.


*** TEST RESULTS FOR COMMIT 0fa7fe506c242b459c4c05d331e7c7d66fb52390 ***

Author: Joel Brobecker <brobecker@adacore.com>
Branch: master
Commit: 0fa7fe506c242b459c4c05d331e7c7d66fb52390

out of line functions nested inside inline functions.
This patch improves the handling of out-of-line functions nested
inside functions that have been inlined.

Consider for instance a situation where function Foo_O224_021
has a function Child1 declared in it, which itself has a function
Child2 nested inside Child1. After compiling the program with
optimization on, Child1 gets inlined, but not Child2.

After inserting a breakpoint on Child2, and running the program
until reaching that breakpoint, we get the following backtrace:

    % gdb foo_o224_021
    (gdb) break foo_o224_021.child1.child2
    (gdb) run
    [...]
    Breakpoint 1, foo_o224_021 () at foo_o224_021.adb:28
    28          Child1;
    (gdb) bt
    #0  0x0000000000402400 in foo_o224_021 () at foo_o224_021.adb:28
    #1  0x00000000004027a4 in foo_o224_021.child1 () at foo_o224_021.adb:23
    #2  0x00000000004027a4 in foo_o224_021 () at foo_o224_021.adb:28

GDB reports the wrong function name for frame #0. We also get the same
kind of error in the "Breakpoint 1, foo_o224_021 () [...]" message.
In both cases, the function name should be foo_o224_021.child1.child2,
and the parameters should be "s=...".

What happens is that the inlined frame handling does not handle well
the case where an inlined function is calling an out-of-line function
which was declared inside the inlined function's scope.

In particular, looking first at the inlined-frame sniffer when applying
to frame #0:

        /* Calculate DEPTH, the number of inlined functions at this
           location.  */
        depth = 0;
        cur_block = frame_block;
        while (BLOCK_SUPERBLOCK (cur_block))
          {
            if (block_inlined_p (cur_block))
              depth++;
            cur_block = BLOCK_SUPERBLOCK (cur_block);
          }

What happens is that cur_block starts as the block associated
to child2, which is not inlined. We shoud be stopping here, but
instead, we keep walking the superblock chain, which takes us
all the way to Foo_O224_021's block, via Child2's block. And
since Child1 was inlined, we end up with a depth count of 1,
wrongly making GDB think that frame #0 is an inlined frame.

Same kind of issue inside skip_inline_frames.

The fix is to stop checking for inlined frames as soon as we see
a block corresponding to a function which is not inlined.  This is
the behavior we now obtain:

    (gdb) run
    [...]
    Breakpoint 1, foo_o224_021.child1.child2 (s=...) at foo_o224_021.adb:9
    9               function Child2 (S : String) return Boolean is
    (gdb) bt
    #0  0x0000000000402400 in foo_o224_021.child1.child2 (s=...)
        at foo_o224_021.adb:9
    #1  0x00000000004027a4 in foo_o224_021.child1 () at foo_o224_021.adb:23
    #2  0x00000000004027a4 in foo_o224_021 () at foo_o224_021.adb:28

gdb/ChangeLog:

        * inline-frame.c (inline_frame_sniffer, skip_inline_frames):
        Stop counting inlined frames as soon as an out-of-line function
        is found.

gdb/testsuite/ChangeLog:

        * gdb.ada/out_of_line_in_inlined.exp: Add run and "bt" tests.


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