* [RFA] dwarf2read - empty file name table
@ 2007-04-19 14:23 Jerome Guitton
2007-04-19 15:06 ` Daniel Jacobowitz
0 siblings, 1 reply; 4+ messages in thread
From: Jerome Guitton @ 2007-04-19 14:23 UTC (permalink / raw)
To: gdb-patches
I am using a third-party library which makes GDB crash; it has the
following entry in its .debug_line:
[...]
Dump of debug contents of section .debug_line:
Length: 35
DWARF Version: 2
Prologue Length: 19
Minimum Instruction Length: 4
Initial value of 'is_stmt': 1
Line Base: -1
Line Range: 4
Opcode Base: 13
(Pointer size: 4)
Opcodes:
Opcode 1 has 0 args
Opcode 2 has 1 args
Opcode 3 has 1 args
Opcode 4 has 1 args
Opcode 5 has 1 args
Opcode 6 has 0 args
Opcode 7 has 0 args
Opcode 8 has 0 args
Opcode 9 has 1 args
Opcode 10 has 0 args
Opcode 11 has 0 args
Opcode 12 has 1 args
The Directory Table is empty.
The File Name Table is empty.
Line Number Statements:
Extended opcode 2: set Address to 0x10000
Extended opcode 1: End of Sequence
[...]
Note that the file name table is empty and that no file name is
specified in the line number statements. Not sure what is the use of
such an entry, but it does not seem invalid to me. Anyway, this makes
GDB crash in dwarf2read.c (trying to read into a num file name table
at End of Sequence). The followwing patch should fix this problem.
Ok to apply?
Thanks in advance,
Jerome
2007-04-19 Jerome Guitton <guitton@adacore.com>
* dwarf2read.c (dwarf_decode_lines): Do not dereference file_names
if NULL.
Index: dwarf2read.c
===================================================================
--- dwarf2read.c (revision 6081)
+++ dwarf2read.c (revision 6082)
@@ -6996,7 +6996,8 @@
{
case DW_LNE_end_sequence:
end_sequence = 1;
- lh->file_names[file - 1].included_p = 1;
+ if (lh->file_names_size)
+ lh->file_names[file - 1].included_p = 1;
if (!decode_for_pst_p)
record_line (current_subfile, 0, address);
break;
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFA] dwarf2read - empty file name table
2007-04-19 14:23 [RFA] dwarf2read - empty file name table Jerome Guitton
@ 2007-04-19 15:06 ` Daniel Jacobowitz
2007-04-19 19:39 ` Jerome Guitton
0 siblings, 1 reply; 4+ messages in thread
From: Daniel Jacobowitz @ 2007-04-19 15:06 UTC (permalink / raw)
To: Jerome Guitton; +Cc: gdb-patches
On Thu, Apr 19, 2007 at 04:16:47PM +0200, Jerome Guitton wrote:
>
> I am using a third-party library which makes GDB crash; it has the
> following entry in its .debug_line:
I've seen ARM's compiler produce this construct. In fact, I had a
patch sitting in my behind schedule backlog for this very issue...
Could you see if this works for you? There's a number of other places
with the same problem.
--
Daniel Jacobowitz
CodeSourcery
2007-04-19 Paul Brook <paul@codesourcery.com>
Daniel Jacobowitz <dan@codesourcery.com>
* dwarf2read.c (dwarf2_debug_line_missing_file_complaint): New
function.
(dwarf_decode_lines): Check for line info without a file.
--- gdb/dwarf2read.c 2007-04-12 10:52:32.000000000 -0400
+++ gdb/dwarf2read.c 2007-04-19 10:18:51.000000000 -0400
@@ -688,6 +688,13 @@ dwarf2_statement_list_fits_in_line_numbe
}
static void
+dwarf2_debug_line_missing_file_complaint (void)
+{
+ complaint (&symfile_complaints,
+ _(".debug_line section has line data without a file"));
+}
+
+static void
dwarf2_complex_location_expr_complaint (void)
{
complaint (&symfile_complaints, _("location expression too complex"));
@@ -6711,19 +6942,24 @@ dwarf_decode_lines (struct line_header *
address += (adj_opcode / lh->line_range)
* lh->minimum_instruction_length;
line += lh->line_base + (adj_opcode % lh->line_range);
- lh->file_names[file - 1].included_p = 1;
- if (!decode_for_pst_p)
- {
- if (last_subfile != current_subfile)
- {
- if (last_subfile)
- record_line (last_subfile, 0, address);
- last_subfile = current_subfile;
+ if (lh->num_file_names < file)
+ dwarf2_debug_line_missing_file_complaint ();
+ else
+ {
+ lh->file_names[file - 1].included_p = 1;
+ if (!decode_for_pst_p)
+ {
+ if (last_subfile != current_subfile)
+ {
+ if (last_subfile)
+ record_line (last_subfile, 0, address);
+ last_subfile = current_subfile;
+ }
+ /* Append row to matrix using current values. */
+ record_line (current_subfile, line,
+ check_cu_functions (address, cu));
}
- /* Append row to matrix using current values. */
- record_line (current_subfile, line,
- check_cu_functions (address, cu));
- }
+ }
basic_block = 1;
}
else switch (op_code)
@@ -6737,9 +6973,15 @@ dwarf_decode_lines (struct line_header *
{
case DW_LNE_end_sequence:
end_sequence = 1;
- lh->file_names[file - 1].included_p = 1;
- if (!decode_for_pst_p)
- record_line (current_subfile, 0, address);
+
+ if (lh->num_file_names < file)
+ dwarf2_debug_line_missing_file_complaint ();
+ else
+ {
+ lh->file_names[file - 1].included_p = 1;
+ if (!decode_for_pst_p)
+ record_line (current_subfile, 0, address);
+ }
break;
case DW_LNE_set_address:
address = read_address (abfd, line_ptr, cu, &bytes_read);
@@ -6772,17 +7014,22 @@ dwarf_decode_lines (struct line_header *
}
break;
case DW_LNS_copy:
- lh->file_names[file - 1].included_p = 1;
- if (!decode_for_pst_p)
+ if (lh->num_file_names < file)
+ dwarf2_debug_line_missing_file_complaint ();
+ else
{
- if (last_subfile != current_subfile)
- {
- if (last_subfile)
- record_line (last_subfile, 0, address);
- last_subfile = current_subfile;
- }
- record_line (current_subfile, line,
- check_cu_functions (address, cu));
+ lh->file_names[file - 1].included_p = 1;
+ if (!decode_for_pst_p)
+ {
+ if (last_subfile != current_subfile)
+ {
+ if (last_subfile)
+ record_line (last_subfile, 0, address);
+ last_subfile = current_subfile;
+ }
+ record_line (current_subfile, line,
+ check_cu_functions (address, cu));
+ }
}
basic_block = 0;
break;
@@ -6805,15 +7052,19 @@ dwarf_decode_lines (struct line_header *
file = read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
line_ptr += bytes_read;
- fe = &lh->file_names[file - 1];
- if (fe->dir_index)
- dir = lh->include_dirs[fe->dir_index - 1];
-
- if (!decode_for_pst_p)
- {
- last_subfile = current_subfile;
- dwarf2_start_subfile (fe->name, dir, comp_dir);
- }
+ if (lh->num_file_names < file)
+ dwarf2_debug_line_missing_file_complaint ();
+ else
+ {
+ fe = &lh->file_names[file - 1];
+ if (fe->dir_index)
+ dir = lh->include_dirs[fe->dir_index - 1];
+ if (!decode_for_pst_p)
+ {
+ last_subfile = current_subfile;
+ dwarf2_start_subfile (fe->name, dir, comp_dir);
+ }
+ }
}
break;
case DW_LNS_set_column:
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFA] dwarf2read - empty file name table
2007-04-19 15:06 ` Daniel Jacobowitz
@ 2007-04-19 19:39 ` Jerome Guitton
2007-05-14 17:15 ` Daniel Jacobowitz
0 siblings, 1 reply; 4+ messages in thread
From: Jerome Guitton @ 2007-04-19 19:39 UTC (permalink / raw)
To: gdb-patches
> I've seen ARM's compiler produce this construct. In fact, I had a
> patch sitting in my behind schedule backlog for this very issue...
>
> Could you see if this works for you? There's a number of other places
> with the same problem.
I confirm that it works for me, thanks! Do you plan to check it in?
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFA] dwarf2read - empty file name table
2007-04-19 19:39 ` Jerome Guitton
@ 2007-05-14 17:15 ` Daniel Jacobowitz
0 siblings, 0 replies; 4+ messages in thread
From: Daniel Jacobowitz @ 2007-05-14 17:15 UTC (permalink / raw)
To: Jerome Guitton; +Cc: gdb-patches
On Thu, Apr 19, 2007 at 05:06:14PM +0200, Jerome Guitton wrote:
>
> > I've seen ARM's compiler produce this construct. In fact, I had a
> > patch sitting in my behind schedule backlog for this very issue...
> >
> > Could you see if this works for you? There's a number of other places
> > with the same problem.
>
> I confirm that it works for me, thanks! Do you plan to check it in?
I have now, after a smoke test on x86_64-linux with gcc.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2007-05-14 17:15 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-04-19 14:23 [RFA] dwarf2read - empty file name table Jerome Guitton
2007-04-19 15:06 ` Daniel Jacobowitz
2007-04-19 19:39 ` Jerome Guitton
2007-05-14 17:15 ` Daniel Jacobowitz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox