[Bug gdb/26317] GDB crashes when trying to insert a breakpoint by line number
vries at gcc dot gnu.org
sourceware-bugzilla@sourceware.org
Mon Aug 3 07:25:26 GMT 2020
https://sourceware.org/bugzilla/show_bug.cgi?id=26317
--- Comment #7 from Tom de Vries <vries at gcc dot gnu.org> ---
(In reply to Tom Tromey from comment #4)
> find_function_start_sal is returning a sal that has a symbol
> but no symtab, which seems wrong.
FTR.
When find_function_start_sal is called we have backtrace:
...
(gdb) bt
#0 find_function_start_sal (sym=0x223ae40, funfirstline=true)
at src/gdb/symtab.c:3678
#1 0x000000000096f467 in select_source_symtab (s=0x0)
at src/gdb/source.c:308
#2 0x000000000096f285 in set_default_source_symtab_and_line ()
at src/gdb/source.c:248
#3 0x000000000074c570 in create_sals_line_offset (self=0x7fffffffcfb0,
ls=0x7fffffffd000)
at src/gdb/linespec.c:2102
#4 0x000000000074d468 in convert_linespec_to_sals (state=0x7fffffffcfb0,
ls=0x7fffffffd000)
at src/gdb/linespec.c:2338
#5 0x000000000074e146 in parse_linespec (parser=0x7fffffffcf80, arg=0x220f870
"27",
match_type=symbol_name_match_type::WILD)
...
and sym:
...
(gdb) p sym.m_name
$9 = 0x220eed1 "main"
...
That is, we're trying to set a breakpoint at line 27 in function bar1, but in
the process we're trying to find the function start for main.
I've compiled dw2-line-number-zero.c with -g, and got the same behaviour, so
that's not something specific to this dwarf assembly test-case.
Anyway, in find_pc_sect_line we're trying to find the sal for the address of
main, and iterate over compunit_filesymtabs to find the 'best' matching symtab
give the line number info, but no matching symtab is found because there's no
line info for main in the dwarf assembly test-case, so we hit this case:
...
if (!best_symtab)
{
/* If we didn't find any line number info, just return zeros.
We used to return alt->line - 1 here, but that could be
anywhere; if we don't have line number info for this PC,
don't make some up. */
val.pc = pc;
}
...
So, this problem can be worked around by adding that missing line number info:
...
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-line-number-zero.c
b/gdb/testsuite/gdb.dwarf2/dw2
-line-number-zero.c
index 15b37a6676..ac7e306aa3 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-line-number-zero.c
+++ b/gdb/testsuite/gdb.dwarf2/dw2-line-number-zero.c
@@ -57,6 +57,7 @@ main (void)
bar2 ();
+ asm ("main_label_2: .globl main_label_2");
return 0;
}
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-line-number-zero.exp
b/gdb/testsuite/gdb.dwarf2/d
w2-line-number-zero.exp
index 12011b5f9c..66566752f0 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-line-number-zero.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-line-number-zero.exp
@@ -102,6 +102,13 @@ Dwarf::assemble $asm_file {
{DW_LNE_set_address bar2_label_5}
{DW_LNE_end_sequence}
+
+ {DW_LNE_set_address main_label}
+ {line 54}
+ {DW_LNS_copy}
+
+ {DW_LNE_set_address main_label_2}
+ {DW_LNE_end_sequence}
}
}
}
...
--
You are receiving this mail because:
You are on the CC list for the bug.
More information about the Gdb-prs
mailing list