2009-08-10 Paul Pluzhnikov <ppluzhnikov@google.com>
[deliverable/binutils-gdb.git] / gdb / dbxread.c
index 115bdef32cd061c2433fb490c98e86bb3ded717d..7cb016ddfed55dc1796cb644cc2b78340921dff1 100644 (file)
@@ -395,7 +395,7 @@ add_new_header_file (char *name, int instance)
 
   i = N_HEADER_FILES (current_objfile)++;
   hfile = HEADER_FILES (current_objfile) + i;
-  hfile->name = savestring (name, strlen (name));
+  hfile->name = xstrdup (name);
   hfile->instance = instance;
   hfile->length = 10;
   hfile->vector
@@ -1188,6 +1188,8 @@ read_dbx_symtab (struct objfile *objfile)
   struct internal_nlist nlist;
   CORE_ADDR text_addr;
   int text_size;
+  char *sym_name;
+  int sym_len;
 
   char *namestring;
   int nsl;
@@ -1382,6 +1384,7 @@ read_dbx_symtab (struct objfile *objfile)
                  pst = (struct partial_symtab *) 0;
                  includes_used = 0;
                  dependencies_used = 0;
+                 has_line_numbers = 0;
                }
              else
                past_first_source_file = 1;
@@ -1506,6 +1509,7 @@ read_dbx_symtab (struct objfile *objfile)
                    pst = (struct partial_symtab *) 0;
                    includes_used = 0;
                    dependencies_used = 0;
+                   has_line_numbers = 0;
                  }
              }
 
@@ -1681,6 +1685,30 @@ pos %d"),
          if (!p)
            continue;                   /* Not a debugging symbol.   */
 
+         sym_len = 0;
+         sym_name = NULL;      /* pacify "gcc -Werror" */
+         if (psymtab_language == language_cplus)
+           {
+             char *new_name, *name = xmalloc (p - namestring + 1);
+             memcpy (name, namestring, p - namestring);
+             name[p - namestring] = '\0';
+             new_name = cp_canonicalize_string (name);
+             if (new_name != NULL)
+               {
+                 sym_len = strlen (new_name);
+                 sym_name = obsavestring (new_name, sym_len,
+                                          &objfile->objfile_obstack);
+                 xfree (new_name);
+               }
+              xfree (name);
+           }
+
+         if (sym_len == 0)
+           {
+             sym_name = namestring;
+             sym_len = p - namestring;
+           }
+
          /* Main processing section for debugging symbols which
             the initial read through the symbol tables needs to worry
             about.  If we reach this point, the symbol which we are
@@ -1698,7 +1726,7 @@ pos %d"),
                namestring = gdbarch_static_transform_name (gdbarch,
                                                            namestring);
 
-             add_psymbol_to_list (namestring, p - namestring,
+             add_psymbol_to_list (sym_name, sym_len,
                                   VAR_DOMAIN, LOC_STATIC,
                                   &objfile->static_psymbols,
                                   0, nlist.n_value,
@@ -1710,7 +1738,7 @@ pos %d"),
                                         data_sect_index);
              /* The addresses in these entries are reported to be
                 wrong.  See the code that reads 'G's for symtabs. */
-             add_psymbol_to_list (namestring, p - namestring,
+             add_psymbol_to_list (sym_name, sym_len,
                                   VAR_DOMAIN, LOC_STATIC,
                                   &objfile->global_psymbols,
                                   0, nlist.n_value,
@@ -1728,7 +1756,7 @@ pos %d"),
                  || (p == namestring + 1
                      && namestring[0] != ' '))
                {
-                 add_psymbol_to_list (namestring, p - namestring,
+                 add_psymbol_to_list (sym_name, sym_len,
                                       STRUCT_DOMAIN, LOC_TYPEDEF,
                                       &objfile->static_psymbols,
                                       nlist.n_value, 0,
@@ -1736,7 +1764,7 @@ pos %d"),
                  if (p[2] == 't')
                    {
                      /* Also a typedef with the same name.  */
-                     add_psymbol_to_list (namestring, p - namestring,
+                     add_psymbol_to_list (sym_name, sym_len,
                                           VAR_DOMAIN, LOC_TYPEDEF,
                                           &objfile->static_psymbols,
                                           nlist.n_value, 0,
@@ -1749,7 +1777,7 @@ pos %d"),
            case 't':
              if (p != namestring)      /* a name is there, not just :T... */
                {
-                 add_psymbol_to_list (namestring, p - namestring,
+                 add_psymbol_to_list (sym_name, sym_len,
                                       VAR_DOMAIN, LOC_TYPEDEF,
                                       &objfile->static_psymbols,
                                       nlist.n_value, 0,
@@ -1829,7 +1857,7 @@ pos %d"),
 
            case 'c':
              /* Constant, e.g. from "const" in Pascal.  */
-             add_psymbol_to_list (namestring, p - namestring,
+             add_psymbol_to_list (sym_name, sym_len,
                                   VAR_DOMAIN, LOC_CONST,
                                   &objfile->static_psymbols, nlist.n_value,
                                   0, psymtab_language, objfile);
@@ -1893,7 +1921,7 @@ pos %d"),
                  pst->textlow = nlist.n_value;
                  textlow_not_set = 0;
                }
-             add_psymbol_to_list (namestring, p - namestring,
+             add_psymbol_to_list (sym_name, sym_len,
                                   VAR_DOMAIN, LOC_BLOCK,
                                   &objfile->static_psymbols,
                                   0, nlist.n_value,
@@ -1961,7 +1989,7 @@ pos %d"),
                  pst->textlow = nlist.n_value;
                  textlow_not_set = 0;
                }
-             add_psymbol_to_list (namestring, p - namestring,
+             add_psymbol_to_list (sym_name, sym_len,
                                   VAR_DOMAIN, LOC_BLOCK,
                                   &objfile->global_psymbols,
                                   0, nlist.n_value,
@@ -2082,6 +2110,7 @@ pos %d"),
              pst = (struct partial_symtab *) 0;
              includes_used = 0;
              dependencies_used = 0;
+             has_line_numbers = 0;
            }
          continue;
 
@@ -2765,7 +2794,11 @@ process_one_symbol (int type, int desc, CORE_ADDR valu, char *name,
             which may have an N_FUN stabs at the end of the function,
             but no N_SLINE stabs.  */
          if (sline_found_in_function)
-           record_line (current_subfile, 0, last_function_start + valu);
+           {
+             CORE_ADDR addr = last_function_start + valu;
+             record_line (current_subfile, 0,
+                          gdbarch_addr_bits_remove (gdbarch, addr));
+           }
 
          within_function = 0;
          new = pop_context ();
@@ -2981,14 +3014,15 @@ no enclosing block"));
 
       if (within_function && sline_found_in_function == 0)
        {
-         if (processing_gcc_compilation == 2)
-           record_line (current_subfile, desc, last_function_start);
-         else
-           record_line (current_subfile, desc, valu);
+         CORE_ADDR addr = processing_gcc_compilation == 2 ?
+                          last_function_start : valu;
+         record_line (current_subfile, desc,
+                      gdbarch_addr_bits_remove (gdbarch, addr));
          sline_found_in_function = 1;
        }
       else
-       record_line (current_subfile, desc, valu);
+       record_line (current_subfile, desc,
+                    gdbarch_addr_bits_remove (gdbarch, valu));
       break;
 
     case N_BCOMM:
This page took 0.029221 seconds and 4 git commands to generate.