* breakpoint.c, breakpoint.h (breakpoint_init_inferior): New function
[deliverable/binutils-gdb.git] / gdb / dbxread.c
index 6c93ef40b6c89e57af3df33969b6aa864fade152..9d1a423607f7f94899a702237a253363fd8ef19f 100644 (file)
@@ -594,7 +594,7 @@ dbx_symfile_init (objfile)
   unsigned char size_temp[DBX_STRINGTAB_SIZE_SIZE];
 
   /* Allocate struct to keep track of the symfile */
-  objfile->sym_private = (PTR)
+  objfile->sym_stab_info = (PTR)
     xmmalloc (objfile -> md, sizeof (struct dbx_symfile_info));
 
   /* FIXME POKING INSIDE BFD DATA STRUCTURES */
@@ -696,9 +696,9 @@ static void
 dbx_symfile_finish (objfile)
      struct objfile *objfile;
 {
-  if (objfile->sym_private != NULL)
+  if (objfile->sym_stab_info != NULL)
     {
-      mfree (objfile -> md, objfile->sym_private);
+      mfree (objfile -> md, objfile->sym_stab_info);
     }
   free_header_files ();
 }
@@ -1114,7 +1114,7 @@ end_psymtab (pst, include_list, num_includes, capping_symbol_offset,
 
     if (minsym) {
       pst->texthigh = SYMBOL_VALUE_ADDRESS (minsym) +
-       (int) MSYMBOL_INFO (minsym);
+       (long) MSYMBOL_INFO (minsym);
     } else {
       /* This file ends with a static function, and it's
         difficult to imagine how hard it would be to track down
@@ -1765,6 +1765,10 @@ process_one_symbol (type, desc, valu, name, section_offsets, objfile)
     case N_BCOMM:
       if (common_block)
        {
+         /* Note: this does not detect nesting if the previous N_BCOMM
+            was at the beginning of a scope (and thus common_block was
+            NULL).  Not necessarily worth worrying about unless we run
+            into a compiler which actually has this bug.  */
          static struct complaint msg = {
            "Invalid symbol data: common within common at symtab pos %d",
            0, 0};
@@ -1775,11 +1779,21 @@ process_one_symbol (type, desc, valu, name, section_offsets, objfile)
       break;
 
     case N_ECOMM:
+
       /* Symbols declared since the BCOMM are to have the common block
-        start address added in when we know it.  common_block points to
-        the first symbol after the BCOMM in the local_symbols list;
-        copy the list and hang it off the symbol for the common block name
-        for later fixup.  */
+        start address added in when we know it.  common_block and
+        common_block_i point to the first symbol after the BCOMM in
+        the local_symbols list; copy the list and hang it off the
+        symbol for the common block name for later fixup.  */
+
+      /* If there is a N_ECOMM unmatched by a N_BCOMM, we treat all
+        the local_symbols as part of the common block.  It might be
+        better to just ignore the N_ECOMM, but then we'd need to
+        distinguish between a N_BCOMM at the start of a scope, or no
+        N_BCOMM at all (currently they both have common_block NULL).
+        Not necessarily worth worrying about unless we run into a
+        compiler which actually has this bug.  */
+
       {
        int i;
        struct symbol *sym =
@@ -1870,7 +1884,8 @@ process_one_symbol (type, desc, valu, name, section_offsets, objfile)
     case N_NBBSS:
     case N_NBSTS:
     case N_NBLCS:
-      complain (&unknown_symtype_complaint, local_hex_string(type));
+      complain (&unknown_symtype_complaint,
+               local_hex_string((unsigned long) type));
       /* FALLTHROUGH */
 
     /* The following symbol types don't need the address field relocated,
@@ -1919,12 +1934,13 @@ process_one_symbol (type, desc, valu, name, section_offsets, objfile)
              /* On solaris up to 2.2, the N_FUN stab gets relocated.
                 On Solaris 2.3, ld no longer relocates stabs (which
                 is good), and the N_FUN's value is now always zero.
-                We only provide this correction for functions, not for
-                all N_FUN symbols, because that is easiest and all
-                readonly variables seem to go in the .rodata on Solaris.  */
+                The following code can't deal with this, because
+                last_pc_address depends on getting the address from a
+                N_SLINE or some such and in Solaris those are function
+                relative.  Best fix is probably to create a Ttext.text symbol
+                and handle this like Ddata.data and so on.  */
 
-             if (type == N_GSYM || type == N_STSYM
-                 || (type == N_FUN && valu == 0))
+             if (type == N_GSYM || type == N_STSYM)
                {
                  struct minimal_symbol *m;
                  int l = colon_pos - name;
@@ -1933,17 +1949,12 @@ process_one_symbol (type, desc, valu, name, section_offsets, objfile)
                  if (m && STREQN (SYMBOL_NAME (m), name, l))
                    /* last_pc_address was in this function */
                    valu = SYMBOL_VALUE (m);
+                 else if (m && STREQN (SYMBOL_NAME (m+1), name, l))
+                   /* last_pc_address was in last function */
+                   valu = SYMBOL_VALUE (m+1);
                  else
-                   {
-                     m = lookup_next_minimal_symbol (last_pc_address);
-                     if (m && STREQN (SYMBOL_NAME (m), name, l))
-                       /* last_pc_address was in last function */
-                       valu = SYMBOL_VALUE (m);
-                     else
-                       /* Not found.
-                          Use last_pc_address (for finish_block).  */
-                       valu = last_pc_address;
-                   }
+                   /* Not found - use last_pc_address (for finish_block) */
+                   valu = last_pc_address;
                }
 
              last_pc_address = valu;   /* Save for SunOS bug circumcision */
@@ -2036,13 +2047,96 @@ copy_pending (beg, endi, end)
        add_symbol_to_list (next->symbol[j], &new);
     }
 
-  /* Copy however much of END we need.  */
-  for (j = endi; j < end->nsyms; j++)
-    add_symbol_to_list (end->symbol[j], &new);
+  /* Copy however much of END we need.  If END is NULL, it means copy
+     all the local symbols (which we already did above).  */
+  if (end != NULL)
+    for (j = endi; j < end->nsyms; j++)
+      add_symbol_to_list (end->symbol[j], &new);
 
   return new;
 }
 \f
+/* FIXME: The only difference between this and elfstab_build_psymtabs is
+   the call to install_minimal_symbols for elf.  If the differences are
+   really that small, the code should be shared.  */
+
+/* Scan and build partial symbols for an coff symbol file.
+   The coff 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.
+
+   OBJFILE is the object file we are reading symbols from.
+   ADDR is the address relative to which the symbols are (e.g.
+   the base address of the text segment).
+   MAINLINE is true if we are reading the main symbol
+   table (as opposed to a shared lib or dynamically loaded file).
+   STABOFFSET and STABSIZE define the location in OBJFILE where the .stab
+   section exists.
+   STABSTROFFSET and STABSTRSIZE define the location in OBJFILE where the
+   .stabstr section exists.
+
+   This routine is mostly copied from dbx_symfile_init and dbx_symfile_read,
+   adjusted for coff details. */
+
+void
+coffstab_build_psymtabs (objfile, section_offsets, mainline, 
+                              staboffset, stabsize,
+                              stabstroffset, stabstrsize)
+      struct objfile *objfile;
+      struct section_offsets *section_offsets;
+      int mainline;
+      file_ptr staboffset;
+      unsigned int stabsize;
+      file_ptr stabstroffset;
+      unsigned int stabstrsize;
+{
+  int val;
+  bfd *sym_bfd = objfile->obfd;
+  char *name = bfd_get_filename (sym_bfd);
+  struct dbx_symfile_info *info;
+
+  /* There is already a dbx_symfile_info allocated by our caller.
+     It might even contain some info from the coff symtab to help us.  */
+  info = (struct dbx_symfile_info *) objfile->sym_stab_info;
+
+  DBX_TEXT_SECT (objfile) = bfd_get_section_by_name (sym_bfd, ".text");
+  if (!DBX_TEXT_SECT (objfile))
+    error ("Can't find .text section in symbol file");
+
+#define        COFF_STABS_SYMBOL_SIZE  12      /* XXX FIXME XXX */
+  DBX_SYMBOL_SIZE    (objfile) = COFF_STABS_SYMBOL_SIZE;
+  DBX_SYMCOUNT       (objfile) = stabsize / DBX_SYMBOL_SIZE (objfile);
+  DBX_STRINGTAB_SIZE (objfile) = stabstrsize;
+  DBX_SYMTAB_OFFSET  (objfile) = staboffset;
+  
+  if (stabstrsize > bfd_get_size (sym_bfd))
+    error ("ridiculous string table size: %d bytes", stabstrsize);
+  DBX_STRINGTAB (objfile) = (char *)
+    obstack_alloc (&objfile->psymbol_obstack, stabstrsize+1);
+
+  /* Now read in the string table in one big gulp.  */
+
+  val = bfd_seek (sym_bfd, stabstroffset, SEEK_SET);
+  if (val < 0)
+    perror_with_name (name);
+  val = bfd_read (DBX_STRINGTAB (objfile), stabstrsize, 1, sym_bfd);
+  if (val != stabstrsize)
+    perror_with_name (name);
+
+  stabsread_new_init ();
+  buildsym_new_init ();
+  free_header_files ();
+  init_header_files ();
+
+  processing_acc_compilation = 1;
+
+  /* In a coff file, we've already installed the minimal symbols that came
+     from the coff (non-stab) symbol table, so always act like an
+     incremental load here. */
+  dbx_symfile_read (objfile, section_offsets, 0);
+}
+\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.
@@ -2082,7 +2176,7 @@ elfstab_build_psymtabs (objfile, section_offsets, mainline,
 
   /* There is already a dbx_symfile_info allocated by our caller.
      It might even contain some info from the ELF symtab to help us.  */
-  info = (struct dbx_symfile_info *) objfile->sym_private;
+  info = (struct dbx_symfile_info *) objfile->sym_stab_info;
 
   DBX_TEXT_SECT (objfile) = bfd_get_section_by_name (sym_bfd, ".text");
   if (!DBX_TEXT_SECT (objfile))
This page took 0.025248 seconds and 4 git commands to generate.