Discussion:
[Bug breakpoints/23327] New: cannot stop in captured_main when built with gcc 8.1.1
tromey at sourceware dot org
2018-06-21 18:59:15 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=23327

Bug ID: 23327
Summary: cannot stop in captured_main when built with gcc 8.1.1
Product: gdb
Version: HEAD
Status: NEW
Severity: normal
Priority: P2
Component: breakpoints
Assignee: unassigned at sourceware dot org
Reporter: tromey at sourceware dot org
Target Milestone: ---

I'm using x86-64 Fedora 28.
I built gdb with the system gcc using the default options, -g -O2.

Then I try to debug gdb itself and stop in captured_main.
However, the breakpoint is never hit. This shows up as a failure
in one of the gdb.gdb self-tests.


The function is inlined but is described in the DWARF:

<1><4219f9d>: Abbrev Number: 161 (DW_TAG_subprogram)
<4219f9f> DW_AT_name : (indirect string, offset:
0x4d7b65): captured_main
<4219fa3> DW_AT_decl_file : 1
<4219fa4> DW_AT_decl_line : 1143
<4219fa6> DW_AT_decl_column : 1
<4219fa7> DW_AT_inline : 1 (inlined)
<4219fa8> DW_AT_sibling : <0x4219fea>

Setting the breakpoint claims to work:

(top-gdb) b captured_main
Breakpoint 3 at 0x42400b: file ../../binutils-gdb/gdb/main.c, line 359.


However "info b" shows something else:

3 breakpoint keep y 0x000000000042400b in
gdb_main(captured_main_args*) at ../../binutils-gdb/gdb/main.c:359


"info func" doesn't know about the inline function:

(top-gdb) info func captured_main
All functions matching regular expression "captured_main":

File ../../binutils-gdb/gdb/main.c:
int gdb_main(captured_main_args*);
--
You are receiving this mail because:
You are on the CC list for the bug.
tromey at sourceware dot org
2018-06-21 19:07:28 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=23327

--- Comment #1 from Tom Tromey <tromey at sourceware dot org> ---
See also https://sourceware.org/ml/gdb-patches/2018-06/msg00480.html
--
You are receiving this mail because:
You are on the CC list for the bug.
tromey at sourceware dot org
2018-06-21 20:46:02 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=23327

--- Comment #2 from Tom Tromey <tromey at sourceware dot org> ---
I made this change to inline-break.c:

diff --git a/gdb/testsuite/gdb.opt/inline-break.c
b/gdb/testsuite/gdb.opt/inline-break.c
index f64a81af939..41683357a26 100644
--- a/gdb/testsuite/gdb.opt/inline-break.c
+++ b/gdb/testsuite/gdb.opt/inline-break.c
@@ -202,11 +202,11 @@ func_inline_caller (int x)
/* An extern not-inline function that calls a static inlined
function. */

-int
-func_extern_caller (int x)
-{
- return func_inline_caller (x);
-}
+// int
+// func_extern_caller (int x)
+// {
+// return func_inline_caller (x);
+// }

/* Entry point. */

@@ -237,7 +237,7 @@ main (int argc, char *argv[])

x = not_inline_func3 (-21);

- func_extern_caller (1);
+ func_inline_caller (1);

return x;
}




Now gdb can't "break func_inline_caller".

The DIE looks like:

<1><2d7>: Abbrev Number: 12 (DW_TAG_subprogram)
<2d8> DW_AT_name : (indirect string, offset: 0x172):
func_inline_caller
<2dc> DW_AT_decl_file : 1
<2dd> DW_AT_decl_line : 197
<2de> DW_AT_decl_column : 1
<2df> DW_AT_prototyped : 1
<2df> DW_AT_type : <0x2b8>
<2e3> DW_AT_inline : 3 (declared as inline and inlined)
<2e4> DW_AT_sibling : <0x2f3>


What happens is that read_func_scope takes this early return:

/* Ignore functions with missing or invalid low and high pc attributes. */
if (dwarf2_get_pc_bounds (die, &lowpc, &highpc, cu, NULL)
<= PC_BOUNDS_INVALID)
{
attr = dwarf2_attr (die, DW_AT_external, cu);
if (!attr || !DW_UNSND (attr))
complaint (_("cannot get low and high bounds "
"for subprogram DIE at %s"),
sect_offset_str (die->sect_off));
return;
}

so no symbol is made for this function.
--
You are receiving this mail because:
You are on the CC list for the bug.
tromey at sourceware dot org
2018-06-21 20:58:47 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=23327

--- Comment #3 from Tom Tromey <tromey at sourceware dot org> ---
Maybe this is just a gcc bug because some other inlined functions
are referenced via DW_AT_abstract_origin, but this one is not.
--
You are receiving this mail because:
You are on the CC list for the bug.
Loading...