This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFA] Clean up GAS line symbols for debugging assembly source



This change affects the debug info emitted by GAS with -gstabs or
 -gdwarf2, for source-level debugging of assembly language files.

The intent of these line symbols is that there be one line symbol
per source line, permitting GDB to step over macros and such in a
single operation.  Currently GAS is emitting one line symbol per
instruction, rather than one per source line.  GDB is coping with
this, but imperfectly and with much effort (and largely accidentally).

This change eliminates sequences of consecutive line symbols with
the same source file and line number (collapsing them down to one).
It still needs to be done for ecoff, and perhaps for dwarf1, but
I'll do those as time permits (or someone else can).

2001-11-16  Michael Snyder  <msnyder@redhat.com>

	* stabs.c (stabs_generate_asm_lineno): Remember file and line number
	from one call to the next, and eliminate consecutive duplicates
	(thereby emitting only one line symbol per source line).
	* dwarf2dbg.c (dwarf2_gen_line_info): Ditto.	

Index: stabs.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gas/stabs.c,v
retrieving revision 1.35
diff -c -3 -p -r1.35 stabs.c
*** stabs.c	2001/08/11 18:27:01	1.35
--- stabs.c	2001/11/17 01:39:50
*************** stabs_generate_asm_lineno ()
*** 580,590 ****
    unsigned int lineno;
    char *buf;
    char sym[30];
  
-   /* Let the world know that we are in the middle of generating a
-      piece of stabs line debugging information.  */
-   outputting_stabs_line_debug = 1;
- 
    /* Rather than try to do this in some efficient fashion, we just
       generate a string and then parse it again.  That lets us use the
       existing stabs hook, which expect to see a string, rather than
--- 580,589 ----
    unsigned int lineno;
    char *buf;
    char sym[30];
+   /* Remember the last file/line and avoid duplicates. */
+   static unsigned int prev_lineno = -1;
+   static char *prev_file = NULL;
  
    /* Rather than try to do this in some efficient fashion, we just
       generate a string and then parse it again.  That lets us use the
       existing stabs hook, which expect to see a string, rather than
*************** stabs_generate_asm_lineno ()
*** 593,598 ****
--- 592,625 ----
    hold = input_line_pointer;
  
    as_where (&file, &lineno);
+ 
+   /* Don't emit sequences of stabs for the same line. */
+   if (prev_file == NULL)
+     {
+       /* First time thru. */
+       prev_file = xstrdup (file);
+       prev_lineno = lineno;
+     }
+   else if (lineno == prev_lineno
+ 	   && strcmp (file, prev_file) == 0)
+     {
+       /* Same file/line as last time. */
+       return;
+     }
+   else
+     {
+       /* Remember file/line for next time. */
+       prev_lineno = lineno;
+       if (strcmp (file, prev_file) != 0)
+ 	{
+ 	  free (prev_file);
+ 	  prev_file = xstrdup (file);
+ 	}
+     }
+ 
+   /* Let the world know that we are in the middle of generating a
+      piece of stabs line debugging information.  */
+   outputting_stabs_line_debug = 1;
  
    generate_asm_file (N_SOL, file);
  
Index: dwarf2dbg.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gas/dwarf2dbg.c,v
retrieving revision 1.24
diff -c -3 -p -r1.24 dwarf2dbg.c
*** dwarf2dbg.c	2001/09/27 10:00:53	1.24
--- dwarf2dbg.c	2001/11/17 01:39:50
*************** dwarf2_gen_line_info (ofs, loc)
*** 230,239 ****
--- 230,248 ----
  {
    struct line_subseg *ss;
    struct line_entry *e;
+   static unsigned int line = -1;
+   static unsigned int filenum = -1;
  
    /* Early out for as-yet incomplete location information.  */
    if (loc->filenum == 0 || loc->line == 0)
      return;
+ 
+   /* Don't emit sequences of line symbols for the same line. */
+   if (line == loc->line && filenum == loc->filenum)
+     return;
+ 
+   line = loc->line;
+   filenum = loc->filenum;
  
    e = (struct line_entry *) xmalloc (sizeof (*e));
    e->next = NULL;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]