This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
dwarf2 .debug_line directive changes
- To: binutils at sources dot redhat dot com
- Subject: dwarf2 .debug_line directive changes
- From: Richard Henderson <rth at redhat dot com>
- Date: Sat, 17 Mar 2001 10:28:40 -0800
In order to get proper debug output for DW_AT_decl_file in .debug_info
sections, gcc needs the assembler to respect the exact file numbers
given in the directives.
If you have an installed cvs gcc using a previous cvs binutils, you'll
need to fall back to something else (or bootstrap without debug info),
since until yesterday gcc would emit .file directives that this patch
will reject.
r~
* dwarf2dbg.c (user_filenum, user_filenum_allocated): Remove.
(dwarf2_directive_loc): Don't use them.
(dwarf2_directive_file): Reject duplicate file definitions.
(get_filenum): Zero allocated memory.
(out_file_list): Complain about missing file definitions.
Index: dwarf2dbg.c
===================================================================
RCS file: /cvs/src/src/gas/dwarf2dbg.c,v
retrieving revision 1.34
diff -c -p -d -r1.34 dwarf2dbg.c
*** dwarf2dbg.c 2001/03/08 23:24:22 1.34
--- dwarf2dbg.c 2001/03/17 18:20:38
*************** static struct file_entry *files;
*** 131,141 ****
static unsigned int files_in_use;
static unsigned int files_allocated;
- /* Correlate file numbers as given by the user in .file/.loc directives
- with the file numbers used in the output debug info. */
- static unsigned int *user_filenum;
- static unsigned int user_filenum_allocated;
-
/* True when we've seen a .loc directive recently. Used to avoid
doing work when there's nothing to do. */
static boolean loc_directive_seen;
--- 131,136 ----
*************** get_filenum (filename)
*** 305,313 ****
--- 300,312 ----
if (i >= files_allocated)
{
+ unsigned int old = files_allocated;
+
files_allocated = i + 32;
files = (struct file_entry *)
xrealloc (files, (i + 32) * sizeof (struct file_entry));
+
+ memset (files + old, 0, (i + 32 - old) * sizeof (struct file_entry));
}
files[i].filename = xstrdup (filename);
*************** dwarf2_directive_file (dummy)
*** 340,364 ****
filename = demand_copy_C_string (&filename_len);
demand_empty_rest_of_line ();
! if (num < 0)
{
! as_bad (_("File number less than zero"));
return;
}
! if (num >= (int) user_filenum_allocated)
{
! unsigned int old = user_filenum_allocated;
! user_filenum_allocated = num + 16;
! user_filenum = (unsigned int *)
! xrealloc (user_filenum, (num + 16) * sizeof (unsigned int));
/* Zero the new memory. */
! memset (user_filenum + old, 0, (num + 16 - old) * sizeof (unsigned int));
}
! user_filenum[num] = get_filenum (filename);
}
void
--- 339,371 ----
filename = demand_copy_C_string (&filename_len);
demand_empty_rest_of_line ();
! if (num < 1)
{
! as_bad (_("File number less than one"));
return;
}
! if (num < files_in_use && files[num].filename != 0)
{
! as_bad (_("File number %d already allocated"), num);
! return;
! }
! if (num >= (int) files_allocated)
! {
! unsigned int old = files_allocated;
+ files_allocated = num + 16;
+ files = (struct file_entry *)
+ xrealloc (files, (num + 16) * sizeof (struct file_entry));
+
/* Zero the new memory. */
! memset (files + old, 0, (num + 16 - old) * sizeof (struct file_entry));
}
! files[num].filename = filename;
! files[num].dir = 0;
! files_in_use = num + 1;
}
void
*************** dwarf2_directive_loc (dummy)
*** 374,392 ****
column = get_absolute_expression ();
demand_empty_rest_of_line ();
! if (filenum < 0)
{
! as_bad (_("File number less than zero"));
return;
}
! if (filenum >= (int) user_filenum_allocated
! || user_filenum[filenum] == 0)
{
as_bad (_("Unassigned file number %ld"), (long) filenum);
return;
}
! current.filenum = user_filenum[filenum];
current.line = line;
current.column = column;
current.flags = DWARF2_FLAG_BEGIN_STMT;
--- 381,398 ----
column = get_absolute_expression ();
demand_empty_rest_of_line ();
! if (filenum < 1)
{
! as_bad (_("File number less than one"));
return;
}
! if (filenum >= (int) files_in_use || files[filenum].filename == 0)
{
as_bad (_("Unassigned file number %ld"), (long) filenum);
return;
}
! current.filenum = filenum;
current.line = line;
current.column = column;
current.flags = DWARF2_FLAG_BEGIN_STMT;
*************** out_file_list ()
*** 921,926 ****
--- 927,938 ----
for (i = 1; i < files_in_use; ++i)
{
+ if (files[i].filename == NULL)
+ {
+ as_bad (_("Unassigned file number %u"), i);
+ continue;
+ }
+
size = strlen (files[i].filename) + 1;
cp = frag_more (size);
memcpy (cp, files[i].filename, size);