Bug 28147 - GDB fails to read the debug information for nested function/offload kernels.
Summary: GDB fails to read the debug information for nested function/offload kernels.
Status: NEW
Alias: None
Product: gdb
Classification: Unclassified
Component: gdb (show other bugs)
Version: HEAD
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-07-27 11:55 UTC by Hafiz Abid Qadeer
Modified: 2021-07-27 11:55 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Hafiz Abid Qadeer 2021-07-27 11:55:10 UTC
GDB fails to read the debug information for a function in some cases.
See the testcase below.

$ cat test.c
int main(int argc, char **argv)
{
  void foo (int input)
    {
      __builtin_printf ("input = %d", input);
    }
  foo (5);
  return 0;
}

$ gcc -g -flto -flto-partition=max test.c -o test

$ gdb test

(gdb) b 5
Breakpoint 1 at 0x762: file test.c, line 5.
(gdb) r
Starting program: test 

Breakpoint 1, foo.1915.lto_priv () at test.c:5
5	      __builtin_printf ("input = %d", input);
(gdb) info args
No symbol table info available.

Same program when compiled without -flto-partition=max correctly shows
the 'input' value.

The problems seems to be handling of debug information where a parent function
with no address range encloses a function with address range.

In this case, it looks something like this:
0x0000008d:   DW_TAG_subprogram
                DW_AT_abstract_origin	(0x00000000000000d6 "main")

0x00000092:     DW_TAG_subprogram
                  DW_AT_abstract_origin	(0x00000000000000fe "foo")
                  DW_AT_low_pc	(0x000000000000074f)
                  DW_AT_high_pc	(0x000000000000077a)
                  DW_AT_frame_base	(DW_OP_call_frame_cfa)
                  DW_AT_static_link	(DW_OP_fbreg -32, DW_OP_deref, DW_OP_deref)
                  DW_AT_GNU_all_tail_call_sites	(true)

For more detail discussion, please look at
https://gcc.gnu.org/pipermail/gcc-patches/2021-July/574242.html

The issue was first observed for debugging offload kernels. But Richard created
the above test case which simulates that behaviour.