* complaints.c: New file, code moved from utils.c.
[deliverable/binutils-gdb.git] / gdb / dbxread.c
index b97e50c30602676448a19a5713f1bbbb3a9d6b29..a8595973cd805c9bfeb64e76e7244076343f9ac5 100644 (file)
@@ -41,7 +41,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #define L_INCR 1
 #endif
 
-#ifdef hp9000s800
+#ifdef GDB_TARGET_IS_HPPA
 /* We don't want to use HP-UX's nlists. */
 #define _NLIST_INCLUDED
 #endif
@@ -59,7 +59,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #include "target.h"
 #include "gdbcore.h"           /* for bfd stuff */
 #include "libbfd.h"            /* FIXME Secret internal BFD stuff (bfd_read) */
-#ifdef hp9000s800
+#ifdef GDB_TARGET_IS_HPPA
 #include "libhppa.h"
 #include "syms.h"
 #else
@@ -71,6 +71,8 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #include "stabsread.h"
 #include "gdb-stabs.h"
 #include "demangle.h"
+#include "language.h"          /* Needed inside partial-stab.h */
+#include "complaints.h"
 
 #include "aout/aout64.h"
 #include "aout/stab_gnu.h"     /* We always use GNU stabs, not native, now */
@@ -348,7 +350,7 @@ add_old_header_file (name, instance)
        add_this_object_header_file (i);
        return;
       }
-  complain (&repeated_header_complaint, (char *)symnum);
+  complain (&repeated_header_complaint, symnum);
   complain (&repeated_header_name_complaint, name);
 }
 
@@ -464,7 +466,7 @@ dbx_symfile_read (objfile, section_offsets, mainline)
   if (mainline || objfile->global_psymbols.size == 0 || objfile->static_psymbols.size == 0)
     init_psymbol_list (objfile);
 
-#ifdef hp9000s800
+#ifdef GDB_TARGET_IS_HPPA
   symbol_size = obj_dbx_symbol_entry_size (sym_bfd);
 #else
   symbol_size = DBX_SYMBOL_SIZE (objfile);
@@ -537,7 +539,7 @@ dbx_symfile_init (objfile)
     xmmalloc (objfile -> md, sizeof (struct dbx_symfile_info));
 
   /* FIXME POKING INSIDE BFD DATA STRUCTURES */
-#ifdef hp9000s800
+#ifdef GDB_TARGET_IS_HPPA
 #define STRING_TABLE_OFFSET  (sym_bfd->origin + obj_dbx_str_filepos (sym_bfd))
 #define SYMBOL_TABLE_OFFSET  (sym_bfd->origin + obj_dbx_sym_filepos (sym_bfd))
 #define HP_STRING_TABLE_OFFSET  (sym_bfd->origin + obj_hp_str_filepos (sym_bfd))
@@ -553,7 +555,7 @@ dbx_symfile_init (objfile)
   if (!DBX_TEXT_SECT (objfile))
     error ("Can't find .text section in symbol file");
 
-#ifdef hp9000s800
+#ifdef GDB_TARGET_IS_HPPA
   HP_SYMCOUNT (objfile) = obj_hp_sym_count (sym_bfd);
   DBX_SYMCOUNT (objfile) = obj_dbx_sym_count (sym_bfd);
 #else
@@ -574,7 +576,7 @@ dbx_symfile_init (objfile)
      however at least check to see if the size is zero or some negative
      value. */
 
-#ifdef hp9000s800
+#ifdef GDB_TARGET_IS_HPPA
   DBX_STRINGTAB_SIZE (objfile) = obj_dbx_stringtab_size (sym_bfd);
   HP_STRINGTAB_SIZE (objfile) = obj_hp_stringtab_size (sym_bfd);
 #else
@@ -596,7 +598,7 @@ dbx_symfile_init (objfile)
   DBX_STRINGTAB (objfile) =
     (char *) obstack_alloc (&objfile -> psymbol_obstack,
                            DBX_STRINGTAB_SIZE (objfile));
-#ifdef hp9000s800
+#ifdef GDB_TARGET_IS_HPPA
   if (HP_STRINGTAB_SIZE (objfile) <= 0)
     error ("ridiculous string table size (%d bytes).",
           HP_STRINGTAB_SIZE (objfile));
@@ -615,7 +617,7 @@ dbx_symfile_init (objfile)
                  sym_bfd);
   if (val != DBX_STRINGTAB_SIZE (objfile))
     perror_with_name (name);
-#ifdef hp9000s800
+#ifdef GDB_TARGET_IS_HPPA
   val = bfd_seek (sym_bfd, HP_STRING_TABLE_OFFSET, L_SET);
   if (val < 0)
     perror_with_name (name);
@@ -624,7 +626,7 @@ dbx_symfile_init (objfile)
   if (val != HP_STRINGTAB_SIZE (objfile))
     perror_with_name (name);
 #endif
-#ifdef hp9000s800
+#ifdef GDB_TARGET_IS_HPPA
   HP_SYMTAB_OFFSET (objfile) = HP_SYMBOL_TABLE_OFFSET;
 #endif
 }
@@ -680,7 +682,7 @@ fill_symbuf (sym_bfd)
   symbuf_end = nbytes / symbol_size;
   symbuf_idx = 0;
 }
-#ifdef hp9000s800
+#ifdef GDB_TARGET_IS_HPPA
 /* same as above for the HP symbol table */
 
 static struct symbol_dictionary_record hp_symbuf[4096];
@@ -746,7 +748,7 @@ init_psymbol_list (objfile)
   /* Current best guess is that there are approximately a twentieth
      of the total symbols (in a debugging file) are global or static
      oriented symbols */
-#ifdef hp9000s800
+#ifdef GDB_TARGET_IS_HPPA
   objfile -> global_psymbols.size = (DBX_SYMCOUNT (objfile) + 
                                     HP_SYMCOUNT (objfile)) / 10;
   objfile -> static_psymbols.size = (DBX_SYMCOUNT (objfile) +
@@ -846,7 +848,7 @@ read_dbx_symtab (section_offsets, objfile, text_addr, text_size)
   CORE_ADDR last_o_file_start = 0;
   struct cleanup *old_chain;
   bfd *abfd;
-#ifdef hp9000s800
+#ifdef GDB_TARGET_IS_HPPA
   /* HP stuff */
   struct symbol_dictionary_record *hp_bufp;
   int hp_symnum;
@@ -875,7 +877,7 @@ read_dbx_symtab (section_offsets, objfile, text_addr, text_size)
   file_string_table_offset = 0;
   next_file_string_table_offset = 0;
 
-#ifdef hp9000s800
+#ifdef GDB_TARGET_IS_HPPA
   stringtab_global = HP_STRINGTAB (objfile);
 #else
   stringtab_global = DBX_STRINGTAB (objfile);
@@ -914,12 +916,12 @@ read_dbx_symtab (section_offsets, objfile, text_addr, text_size)
   symbuf_end = symbuf_idx = 0;
   next_symbol_text_func = dbx_next_symbol_text;
 
-#ifdef hp9000s800
+#ifdef GDB_TARGET_IS_HPPA
   /* On pa machines, the global symbols are all in the regular HP-UX
      symbol table. Read them in first. */
 
   hp_symbuf_end = hp_symbuf_idx = 0;
-  bfd_seek (abfd, HP_SYMTAB_OFFSET (objfile), 0);
+  bfd_seek (abfd, HP_SYMTAB_OFFSET (objfile), L_SET);
 
   for (hp_symnum = 0; hp_symnum < HP_SYMCOUNT (objfile); hp_symnum++)
     {
@@ -980,7 +982,7 @@ read_dbx_symtab (section_offsets, objfile, text_addr, text_size)
                                 objfile);
         }
     }
-  bfd_seek (abfd, DBX_SYMTAB_OFFSET (objfile), 0);
+  bfd_seek (abfd, DBX_SYMTAB_OFFSET (objfile), L_SET);
 #endif
 
   for (symnum = 0; symnum < DBX_SYMCOUNT (objfile); symnum++)
@@ -1018,7 +1020,7 @@ read_dbx_symtab (section_offsets, objfile, text_addr, text_size)
 #define SET_NAMESTRING()\
   if (((unsigned)bufp->n_strx + file_string_table_offset) >=           \
       DBX_STRINGTAB_SIZE (objfile)) {                                  \
-    complain (&string_table_offset_complaint, (char *) symnum);                \
+    complain (&string_table_offset_complaint, symnum);                 \
     namestring = "foo";                                                        \
   } else                                                               \
     namestring = bufp->n_strx + file_string_table_offset +             \
@@ -1036,7 +1038,7 @@ read_dbx_symtab (section_offsets, objfile, text_addr, text_size)
     }
 
   /* If there's stuff to be cleaned up, clean it up.  */
-#ifndef hp9000s800
+#ifndef GDB_TARGET_IS_HPPA
   if (DBX_SYMCOUNT (objfile) > 0                       /* We have some syms */
 /*FIXME, does this have a bug at start address 0? */
       && last_o_file_start
@@ -1050,7 +1052,7 @@ read_dbx_symtab (section_offsets, objfile, text_addr, text_size)
 
   if (pst)
     {
-#ifdef hp9000s800
+#ifdef GDB_TARGET_IS_HPPA
       end_psymtab (pst, psymtab_include_list, includes_used,
                   symnum * symbol_size, dbsubc_addr,
                   dependency_list, dependencies_used);
@@ -1346,8 +1348,8 @@ dbx_psymtab_to_symtab_1 (pst)
       buildsym_init ();
       old_chain = make_cleanup (really_free_pendings, 0);
       file_string_table_offset = FILE_STRING_OFFSET (pst);
-#ifdef hp9000s800
-      symbol_size = obj_dbx_symbol_entry_size (sym_bfd);
+#ifdef GDB_TARGET_IS_HPPA
+      symbol_size = obj_dbx_symbol_entry_size (pst->objfile->obfd);
 #else
       symbol_size = SYMBOL_SIZE (pst);
 #endif
@@ -1442,7 +1444,7 @@ read_ofile_symtab (objfile, sym_offset, sym_size, text_offset, text_size,
   current_objfile = objfile;
   subfile_stack = NULL;
 
-#ifdef hp9000s800
+#ifdef GDB_TARGET_IS_HPPA
   stringtab_global = HP_STRINGTAB (objfile);
 #else
   stringtab_global = DBX_STRINGTAB (objfile);
@@ -1468,10 +1470,14 @@ read_ofile_symtab (objfile, sym_offset, sym_size, text_offset, text_size,
 
       SET_NAMESTRING ();
 
-      processing_gcc_compilation =
-       (bufp->n_type == N_TEXT
-        && (strcmp (namestring, GCC_COMPILED_FLAG_SYMBOL) == 0
-            || strcmp(namestring, GCC2_COMPILED_FLAG_SYMBOL) == 0));
+      processing_gcc_compilation = 0;
+      if (bufp->n_type == N_TEXT)
+       {
+         if (strcmp (namestring, GCC_COMPILED_FLAG_SYMBOL) == 0)
+           processing_gcc_compilation = 1;
+         else if (strcmp (namestring, GCC2_COMPILED_FLAG_SYMBOL) == 0)
+           processing_gcc_compilation = 2;
+       }
 
       /* Try to select a C++ demangling based on the compilation unit
         producer. */
@@ -1479,7 +1485,7 @@ read_ofile_symtab (objfile, sym_offset, sym_size, text_offset, text_size,
       if (processing_gcc_compilation)
        {
 #if 1    /* Works, but is experimental.  -fnf */
-         if (current_demangling_style == auto_demangling)
+         if (AUTO_DEMANGLING)
            {
              set_demangling_style (GNU_DEMANGLING_STYLE_STRING);
            }
@@ -1523,18 +1529,21 @@ read_ofile_symtab (objfile, sym_offset, sym_size, text_offset, text_size,
       }
       /* We skip checking for a new .o or -l file; that should never
          happen in this routine. */
-      else if (type == N_TEXT
-              && (strcmp (namestring, GCC_COMPILED_FLAG_SYMBOL) == 0
-                  || strcmp (namestring, GCC2_COMPILED_FLAG_SYMBOL) == 0))
+      else if (type == N_TEXT)
        {
          /* I don't think this code will ever be executed, because
             the GCC_COMPILED_FLAG_SYMBOL usually is right before
             the N_SO symbol which starts this source file.
             However, there is no reason not to accept
             the GCC_COMPILED_FLAG_SYMBOL anywhere.  */
-         processing_gcc_compilation = 1;
+
+         if (strcmp (namestring, GCC_COMPILED_FLAG_SYMBOL) == 0)
+           processing_gcc_compilation = 1;
+         else if (strcmp (namestring, GCC2_COMPILED_FLAG_SYMBOL) == 0)
+           processing_gcc_compilation = 2;
+
 #if 1    /* Works, but is experimental.  -fnf */
-         if (current_demangling_style == auto_demangling)
+         if (AUTO_DEMANGLING)
            {
              set_demangling_style (GNU_DEMANGLING_STYLE_STRING);
            }
@@ -1606,6 +1615,12 @@ process_one_symbol (type, desc, valu, name, section_offsets, objfile)
   static CORE_ADDR function_start_offset;
   char *colon_pos;
 
+#ifndef        BLOCK_ADDRESS_FUNCTION_RELATIVE
+  /* N_LBRAC, N_RBRAC and N_SLINE entries are not relative to the
+     function start address, so just use the text offset.  */
+  function_start_offset = ANOFFSET (section_offsets, SECT_OFF_TEXT);
+#endif
+
   /* Something is wrong if we see real data before
      seeing a source file name.  */
 
@@ -1663,9 +1678,6 @@ process_one_symbol (type, desc, valu, name, section_offsets, objfile)
         absolute, or relative to the N_SO, depending on
         BLOCK_ADDRESS_ABSOLUTE.  */
       function_start_offset = valu;    
-#else
-      /* Default on ordinary systems */
-      function_start_offset = ANOFFSET (section_offsets, SECT_OFF_TEXT);
 #endif
 
       within_function = 1;
@@ -1678,7 +1690,7 @@ process_one_symbol (type, desc, valu, name, section_offsets, objfile)
        }
       /* Stack must be empty now.  */
       if (context_stack_depth != 0)
-       complain (&lbrac_unmatched_complaint, (char *) symnum);
+       complain (&lbrac_unmatched_complaint, symnum);
 
       new = push_context (0, valu);
       new->name = define_symbol (valu, name, desc, type, objfile);
@@ -1700,7 +1712,7 @@ process_one_symbol (type, desc, valu, name, section_offsets, objfile)
 #ifndef SUN_FIXED_LBRAC_BUG
       if (valu < last_pc_address) {
        /* Patch current LBRAC pc value to match last handy pc value */
-       complain (&lbrac_complaint, 0);
+       complain (&lbrac_complaint);
        valu = last_pc_address;
       }
 #endif
@@ -1722,7 +1734,7 @@ process_one_symbol (type, desc, valu, name, section_offsets, objfile)
 
       new = pop_context();
       if (desc != new->depth)
-       complain (&lbrac_mismatch_complaint, (char *) symnum);
+       complain (&lbrac_mismatch_complaint, symnum);
 
       /* Some compilers put the variable decls inside of an
          LBRAC/RBRAC block.  This macro should be nonzero if this
@@ -1754,7 +1766,7 @@ process_one_symbol (type, desc, valu, name, section_offsets, objfile)
          /* FIXME Muzzle a compiler bug that makes end < start.  */
          if (new->start_addr > valu)
            {
-             complain(&lbrac_rbrac_complaint, 0);
+             complain (&lbrac_rbrac_complaint);
              new->start_addr = valu;
            }
          /* Make a block for the local symbols within.  */
@@ -1958,11 +1970,11 @@ process_one_symbol (type, desc, valu, name, section_offsets, objfile)
     case N_OPT:                        /* Solaris 2:  Compiler options */
       if (name)
        {
-         if (!strcmp (name, GCC2_COMPILED_FLAG_SYMBOL))
+         if (strcmp (name, GCC2_COMPILED_FLAG_SYMBOL) == 0)
            {
-             processing_gcc_compilation = 1;
+             processing_gcc_compilation = 2;
 #if 1        /* Works, but is experimental.  -fnf */
-             if (current_demangling_style == auto_demangling)
+             if (AUTO_DEMANGLING)
                {
                  set_demangling_style (GNU_DEMANGLING_STYLE_STRING);
                }
@@ -2045,16 +2057,16 @@ copy_pending (beg, begi, end)
    adjusted for elf details. */
 
 void
-DEFUN(elfstab_build_psymtabs, (objfile, section_offsets, mainline, 
+elfstab_build_psymtabs (objfile, section_offsets, mainline, 
                               staboffset, stabsize,
-                              stabstroffset, stabstrsize),
-      struct objfile *objfile AND
-      struct section_offsets *section_offsets AND
-      int mainline AND
-      unsigned int staboffset AND
-      unsigned int stabsize AND
-      unsigned int stabstroffset AND
-      unsigned int stabstrsize)
+                              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;
This page took 0.037663 seconds and 4 git commands to generate.