* sparc-nat.c: Include "inf-ptrace.h".
[binutils-gdb.git] / gdb / dbxread.c
index e33a7e43c5b4991b13d25282ed35c9788b5808d6..32db167c375e7ad955576bf605d5fc4fc17da4c2 100644 (file)
@@ -37,7 +37,7 @@
 #include "defs.h"
 #include "gdb_string.h"
 
-#if defined(USG) || defined(__CYGNUSCLIB__)
+#if defined(__CYGNUSCLIB__)
 #include <sys/types.h>
 #include <fcntl.h>
 #endif
@@ -54,7 +54,6 @@
 #include "stabsread.h"
 #include "gdb-stabs.h"
 #include "demangle.h"
-#include "language.h"          /* Needed for local_hex_string */
 #include "complaints.h"
 #include "cp-abi.h"
 #include "gdb_assert.h"
@@ -625,7 +624,7 @@ dbx_symfile_init (struct objfile *objfile)
 
   /* Allocate struct to keep track of the symfile */
   objfile->sym_stab_info = (struct dbx_symfile_info *)
-    xmmalloc (objfile->md, sizeof (struct dbx_symfile_info));
+    xmalloc (sizeof (struct dbx_symfile_info));
   memset (objfile->sym_stab_info, 0, sizeof (struct dbx_symfile_info));
 
   DBX_TEXT_SECTION (objfile) = bfd_get_section_by_name (sym_bfd, ".text");
@@ -748,7 +747,7 @@ dbx_symfile_finish (struct objfile *objfile)
            }
          xfree (hfiles);
        }
-      xmfree (objfile->md, objfile->sym_stab_info);
+      xfree (objfile->sym_stab_info);
     }
   free_header_files ();
 }
@@ -892,7 +891,7 @@ init_bincl_list (int number, struct objfile *objfile)
 {
   bincls_allocated = number;
   next_bincl = bincl_list = (struct header_file_location *)
-    xmmalloc (objfile->md, bincls_allocated * sizeof (struct header_file_location));
+    xmalloc (bincls_allocated * sizeof (struct header_file_location));
 }
 
 /* Add a bincl to the list.  */
@@ -905,8 +904,8 @@ add_bincl_to_list (struct partial_symtab *pst, char *name, int instance)
       int offset = next_bincl - bincl_list;
       bincls_allocated *= 2;
       bincl_list = (struct header_file_location *)
-       xmrealloc (pst->objfile->md, (char *) bincl_list,
-                  bincls_allocated * sizeof (struct header_file_location));
+       xrealloc ((char *) bincl_list,
+                 bincls_allocated * sizeof (struct header_file_location));
       next_bincl = bincl_list + offset;
     }
   next_bincl->pst = pst;
@@ -937,7 +936,7 @@ find_corresponding_bincl_psymtab (char *name, int instance)
 static void
 free_bincl_list (struct objfile *objfile)
 {
-  xmfree (objfile->md, bincl_list);
+  xfree (bincl_list);
   bincls_allocated = 0;
 }
 
@@ -1457,6 +1456,7 @@ read_dbx_symtab (struct objfile *objfile)
            static int prev_so_symnum = -10;
            static int first_so_symnum;
            char *p;
+           static char *dirname_nso;
            int prev_textlow_not_set;
 
            valu = nlist.n_value + ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
@@ -1514,18 +1514,27 @@ read_dbx_symtab (struct objfile *objfile)
 
            p = strrchr (namestring, '/');
            if (p && *(p + 1) == '\000')
-             continue;         /* Simply ignore directory name SOs */
+             {
+               /* Save the directory name SOs locally, then save it into
+                  the psymtab when it's created below. */
+               dirname_nso = namestring;
+               continue;               
+             }
 
            /* Some other compilers (C++ ones in particular) emit useless
               SOs for non-existant .c files.  We ignore all subsequent SOs that
               immediately follow the first.  */
 
            if (!pst)
+             {
              pst = start_psymtab (objfile,
                                   namestring, valu,
                                   first_so_symnum * symbol_size,
                                   objfile->global_psymbols.next,
                                   objfile->static_psymbols.next);
+               pst->dirname = dirname_nso;
+               dirname_nso = NULL;
+             }
            continue;
          }
 
@@ -2087,7 +2096,7 @@ read_dbx_symtab (struct objfile *objfile)
          default:
          /* If we haven't found it yet, ignore it.  It's probably some
             new type we don't know about yet.  */
-         unknown_symtype_complaint (local_hex_string (nlist.n_type));
+         unknown_symtype_complaint (hex_string (nlist.n_type));
          continue;
        }
     }
@@ -2638,17 +2647,6 @@ process_one_symbol (int type, int desc, CORE_ADDR valu, char *name,
                    struct section_offsets *section_offsets,
                    struct objfile *objfile)
 {
-#ifdef SUN_FIXED_LBRAC_BUG
-  /* If SUN_FIXED_LBRAC_BUG is defined, then it tells us whether we need
-     to correct the address of N_LBRAC's.  If it is not defined, then
-     we never need to correct the addresses.  */
-
-  /* This records the last pc address we've seen.  We depend on there being
-     an SLINE or FUN or SO before the first LBRAC, since the variable does
-     not get reset in between reads of different symbol files.  */
-  static CORE_ADDR last_pc_address;
-#endif
-
   struct context_stack *new;
   /* This remembers the address of the start of a function.  It is used
      because in Solaris 2, N_LBRAC, N_RBRAC, and N_SLINE entries are
@@ -2756,14 +2754,6 @@ process_one_symbol (int type, int desc, CORE_ADDR valu, char *name,
           N_SO, the linker did not relocate them (sigh).  */
        valu += last_source_start_addr;
 
-#ifdef SUN_FIXED_LBRAC_BUG
-      if (!SUN_FIXED_LBRAC_BUG && valu < last_pc_address)
-       {
-         /* Patch current LBRAC pc value to match last handy pc value */
-         complaint (&symfile_complaints, "bad block start address patched");
-         valu = last_pc_address;
-       }
-#endif
       new = push_context (desc, valu);
       break;
 
@@ -2877,18 +2867,6 @@ process_one_symbol (int type, int desc, CORE_ADDR valu, char *name,
 
       n_opt_found = 0;
 
-#ifdef SUN_FIXED_LBRAC_BUG
-      last_pc_address = valu;  /* Save for SunOS bug circumcision */
-#endif
-
-#ifdef PCC_SOL_BROKEN
-      /* pcc bug, occasionally puts out SO for SOL.  */
-      if (context_stack_depth > 0)
-       {
-         start_subfile (name, NULL);
-         break;
-       }
-#endif
       if (last_source_file)
        {
          /* Check if previous symbol was also an N_SO (with some
@@ -2949,9 +2927,6 @@ process_one_symbol (int type, int desc, CORE_ADDR valu, char *name,
       /* Relocate for dynamic loading and for ELF acc fn-relative syms.  */
       valu += function_start_offset;
 
-#ifdef SUN_FIXED_LBRAC_BUG
-      last_pc_address = valu;  /* Save for SunOS bug circumcision */
-#endif
       /* If this is the first SLINE note in the function, record it at
         the start of the function instead of at the listed location.  */
       if (within_function && sline_found_in_function == 0)
@@ -3062,7 +3037,7 @@ process_one_symbol (int type, int desc, CORE_ADDR valu, char *name,
     case N_NBBSS:
     case N_NBSTS:
     case N_NBLCS:
-      unknown_symtype_complaint (local_hex_string (type));
+      unknown_symtype_complaint (hex_string (type));
       /* FALLTHROUGH */
 
       /* The following symbol types don't need the address field relocated,
@@ -3111,56 +3086,6 @@ process_one_symbol (int type, int desc, CORE_ADDR valu, char *name,
                }
 #endif
 
-#ifdef SUN_FIXED_LBRAC_BUG
-             /* The Sun acc compiler, under SunOS4, puts out
-                functions with N_GSYM or N_STSYM.  The problem is
-                that the address of the symbol is no good (for N_GSYM
-                it doesn't even attept an address; for N_STSYM it
-                puts out an address but then it gets relocated
-                relative to the data segment, not the text segment).
-                Currently we can't fix this up later as we do for
-                some types of symbol in scan_file_globals.
-                Fortunately we do have a way of finding the address -
-                we know that the value in last_pc_address is either
-                the one we want (if we're dealing with the first
-                function in an object file), or somewhere in the
-                previous function. This means that we can use the
-                minimal symbol table to get the address.  */
-
-             /* Starting with release 3.0, the Sun acc compiler,
-                under SunOS4, puts out functions with N_FUN and a value
-                of zero. This gets relocated to the start of the text
-                segment of the module, which is no good either.
-                Under SunOS4 we can deal with this as N_SLINE and N_SO
-                entries contain valid absolute addresses.
-                Release 3.0 acc also puts out N_OPT entries, which makes
-                it possible to discern acc from cc or gcc.  */
-
-             if (type == N_GSYM || type == N_STSYM
-                 || (type == N_FUN
-                     && n_opt_found && !block_address_function_relative))
-               {
-                 struct minimal_symbol *m;
-                 int l = colon_pos - name;
-
-                 m = lookup_minimal_symbol_by_pc (last_pc_address);
-                 if (m && strncmp (DEPRECATED_SYMBOL_NAME (m), name, l) == 0
-                     && DEPRECATED_SYMBOL_NAME (m)[l] == '\0')
-                   /* last_pc_address was in this function */
-                   valu = SYMBOL_VALUE (m);
-                 else if (m && DEPRECATED_SYMBOL_NAME (m + 1)
-                          && strncmp (DEPRECATED_SYMBOL_NAME (m + 1), name, l) == 0
-                          && DEPRECATED_SYMBOL_NAME (m + 1)[l] == '\0')
-                   /* last_pc_address was in last function */
-                   valu = SYMBOL_VALUE (m + 1);
-                 else
-                   /* Not found - use last_pc_address (for finish_block) */
-                   valu = last_pc_address;
-               }
-
-             last_pc_address = valu;   /* Save for SunOS bug circumcision */
-#endif
-
              if (block_address_function_relative)
                /* For Solaris 2.0 compilers, the block addresses and
                   N_SLINE's are relative to the start of the
@@ -3376,8 +3301,7 @@ coffstab_build_psymtabs (struct objfile *objfile, int mainline,
 }
 \f
 /* Scan and build partial symbols for an ELF symbol file.
-   This ELF file has already been processed to get its minimal symbols,
-   and any DWARF symbols that were in it.
+   This ELF file has already been processed to get its minimal symbols.
 
    This routine is the equivalent of dbx_symfile_init and dbx_symfile_read
    rolled into one.