This is the mail archive of the binutils@sourceware.cygnus.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]

PATCH fix for bug in GAS stabs file info


* gas/stabs.c (generate_asm_file): Escape backslashes found in file
path, so that stabs info generated by GAS is equivalent to that
generated by GCC.  If not escaped, the pathname will be incorrectly
encoded.


Index: stabs.c
===================================================================
RCS file: /cvs/binutils/binutils/gas/stabs.c,v
retrieving revision 1.3
diff -d -c -p -r1.3 stabs.c
*** stabs.c	1999/07/11 20:19:59	1.3
--- stabs.c	2000/02/01 14:59:03
*************** generate_asm_file (type, file)
*** 498,504 ****
    static char *last_file;
    static int label_count;
    char *hold;
!   char buf[100];
    char sym[30];
  
    /* Rather than try to do this in some efficient fashion, we just
--- 498,504 ----
    static char *last_file;
    static int label_count;
    char *hold;
!   char *buf = xmalloc (strlen(file) + 100);
    char sym[30];
  
    /* Rather than try to do this in some efficient fashion, we just
*************** generate_asm_file (type, file)
*** 511,520 ****
    if (last_file == NULL
        || strcmp (last_file, file) != 0)
      {
        sprintf (sym, "%sF%d", FAKE_LABEL_NAME, label_count);
        ++label_count;
  
!       sprintf (buf, "\"%s\",%d,0,0,%s\n", file, type, sym);
        input_line_pointer = buf;
        s_stab ('s');
        colon (sym);
--- 511,538 ----
    if (last_file == NULL
        || strcmp (last_file, file) != 0)
      {
+       char *tmp = file;
+       char *endp = file + strlen(file);
+       char *bufp = buf;
+ 
        sprintf (sym, "%sF%d", FAKE_LABEL_NAME, label_count);
        ++label_count;
  
!       *bufp++ = '"';
!       while (tmp < endp)
!         {
!           char *bslash = strchr (tmp, '\\');
!           int len = (bslash ? (bslash - tmp + 1) : strlen(tmp));
!           /* double all backslashes, since demand_copy_C_string (used by
!              s_stab to extract the part in quotes) will try to replace them as
!              escape sequences.  backslash may appear in a filespec. */
!           strncpy (bufp, tmp, len);
!           tmp += len;
!           bufp += len;
!           if (bslash != NULL)
!             *bufp++ = '\\';
!         } 
!       sprintf (bufp, "\",%d,0,0,%s\n", type, sym);
        input_line_pointer = buf;
        s_stab ('s');
        colon (sym);
*************** generate_asm_file (type, file)
*** 525,530 ****
--- 543,549 ----
      }
  
    input_line_pointer = hold;
+   free (buf);
  }
  
  /* Generate stabs debugging information for the current line.  This is

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