* config/mn10300-eval.exp: New file to support MN10300 eval board.
[deliverable/binutils-gdb.git] / gdb / dstread.c
index 64b68c6a78929b3d037cc91e119e808b0608c99e..f0d2a980623ff321e982cfa7449dab3ba60032b3 100644 (file)
@@ -16,7 +16,7 @@ GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
-Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 \f
 #include "defs.h"
 #include "symtab.h"
@@ -26,9 +26,9 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #include "symfile.h"
 #include "objfiles.h"
 #include "buildsym.h"
-#include <obstack.h>
+#include "obstack.h"
 
-#include <string.h>
+#include "gdb_string.h"
 
 #include "dst.h"
 
@@ -51,11 +51,6 @@ static int prev_line_number;
 
 static int line_vector_length;
 
-struct pending_block *pending_blocks;
-
-static struct blockvector *
-make_blockvector PARAMS ((struct objfile *));
-
 static int
 init_dst_sections PARAMS ((int));
 
@@ -77,9 +72,6 @@ dst_symfile_read PARAMS ((struct objfile *, struct section_offsets *, int));
 static void
 dst_symfile_finish PARAMS ((struct objfile *));
 
-static void
-record_minimal_symbol PARAMS ((char *, CORE_ADDR, enum minimal_symbol_type));
-
 static void
 dst_end_symtab PARAMS ((struct objfile *));
 
@@ -92,42 +84,6 @@ dst_start_symtab PARAMS ((void));
 static void
 dst_record_line PARAMS ((int, CORE_ADDR));
 
-static struct blockvector *
-make_blockvector (objfile)
-     struct objfile *objfile;
-{
-  register struct pending_block *next, *next1;
-  register struct blockvector *blockvector;
-  register int i;
-
-  /* Count the length of the list of blocks.  */
-
-  for (next = pending_blocks, i = 0; next; next = next->next, i++);
-
-  blockvector = (struct blockvector *)
-                 obstack_alloc (&objfile->symbol_obstack, sizeof (struct blockvector) + (i - 1) * sizeof (struct block *));
-
-  /* Copy the blocks into the blockvector.
-     This is done in reverse order, which happens to put
-     the blocks into the proper order (ascending starting address).
-   */
-
-  BLOCKVECTOR_NBLOCKS (blockvector) = i;
-  for (next = pending_blocks; next; next = next->next)
-    BLOCKVECTOR_BLOCK (blockvector, --i) = next->block;
-
-  /* Now free the links of the list, and empty the list.  */
-
-  for (next = pending_blocks; next; next = next1)
-    {
-      next1 = next->next;
-      free ((PTR)next);
-    }
-  pending_blocks = 0;
-
-  return blockvector;
-}
-
 /* Manage the vector of line numbers.  */
 /* FIXME: Use record_line instead.  */
 
@@ -221,6 +177,8 @@ dst_end_symtab (objfile)
   symtab->free_ptr = 0;
   symtab->filename = last_source_file;
   symtab->dirname = NULL;
+  symtab->debugformat = obsavestring ("Apollo DST", 10,
+                                     &objfile -> symbol_obstack);
   lv = line_vector;
   lv->nitems = line_vector_index;
   symtab->linetable = (struct linetable *)
@@ -235,17 +193,6 @@ dst_end_symtab (objfile)
   last_source_file = NULL;
 }
 \f
-static void
-record_minimal_symbol (name, address, type)
-     char *name;
-     CORE_ADDR address;
-     enum minimal_symbol_type type;
-{
-  prim_record_minimal_symbol (savestring (name, strlen (name)),
-                            address,
-                            type);
-}
-\f
 /* dst_symfile_init ()
    is the dst-specific initialization routine for reading symbols.
 
@@ -330,7 +277,7 @@ dst_symfile_read (objfile, section_offsets, mainline)
   symfile_bfd = abfd;                  /* Kludge for swap routines */
 
 /* WARNING WILL ROBINSON!  ACCESSING BFD-PRIVATE DATA HERE!  FIXME!  */
-   desc = fileno ((FILE *)(abfd->iostream));   /* File descriptor */
+   desc = fileno ((GDB_FILE *)(abfd->iostream));       /* File descriptor */
 
   /* Read the line number table, all at once.  */
   bfd_map_over_sections (abfd, find_dst_sections, (PTR)NULL);
@@ -349,7 +296,13 @@ dst_symfile_read (objfile, section_offsets, mainline)
 
   /* Sort symbols alphabetically within each block.  */
 
-  sort_all_symtab_syms ();
+  {
+    struct symtab *s;
+    for (s = objfile -> symtabs; s != NULL; s = s -> next)
+      {
+       sort_symtab_syms (s);
+      }
+  }
 
   /* Install any minimal symbols that have been collected as the current
      minimal symbols for this objfile. */
@@ -707,10 +660,10 @@ get_dst_entry(buffer, ret_entry)
     }
     if (size == -1)
     {
-       fprintf(stderr, "Warning: unexpected DST entry type (%d) found\nLast valid entry was of type: %d\n",
+       fprintf_unfiltered(gdb_stderr, "Warning: unexpected DST entry type (%d) found\nLast valid entry was of type: %d\n",
                (int) entry->rec_type,
                last_type);
-       fprintf(stderr, "Last unknown_3 value: %d\n", lu3);
+       fprintf_unfiltered(gdb_stderr, "Last unknown_3 value: %d\n", lu3);
        size = 0;
     }
     else
@@ -805,8 +758,8 @@ create_new_symbol(objfile, name)
        struct symbol *sym = (struct symbol *)
               obstack_alloc (&objfile->symbol_obstack, sizeof (struct symbol));
        memset (sym, 0, sizeof (struct symbol));
-       SYMBOL_NAME (sym) = obstack_copy0 (&objfile->symbol_obstack,
-                                               name, strlen (name));
+       SYMBOL_NAME (sym) = obsavestring (name, strlen (name),
+                                         &objfile->symbol_obstack);
        SYMBOL_VALUE (sym) = 0;
        SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
 
@@ -1115,7 +1068,7 @@ decode_dst_locstring(locstr, sym)
        {
                if (count++ == 100)
                {
-                       fprintf(stderr, "Error reading locstring\n");
+                       fprintf_unfiltered(gdb_stderr, "Error reading locstring\n");
                        break;
                }
                entry = (dst_loc_entry_t *) locstr;
@@ -1436,7 +1389,6 @@ process_dst_block(objfile, entry)
        dst_rec_ptr_t child_entry, symbol_entry;
        struct block *child_block;
        int     total_symbols = 0;
-       struct pending_block *pblock;
        char    fake_name[20];
        static  long    fake_seq = 0;
        struct symbol_list *symlist, *nextsym;
@@ -1469,7 +1421,7 @@ process_dst_block(objfile, entry)
        case dst_block_function:
        case dst_block_subroutine:
        case dst_block_program:
-               record_minimal_symbol(name, address, mst_text);
+               prim_record_minimal_symbol(name, address, mst_text, objfile);
                function = process_dst_function(
                        objfile,
                        symbol_entry,
@@ -1519,11 +1471,6 @@ process_dst_block(objfile, entry)
        else
                BLOCK_FUNCTION (block) = 0;
 
-       pblock = (struct pending_block *)
-                       xmalloc (sizeof (struct pending_block));
-       pblock->block = block;
-       pblock->next = pending_blocks;
-       pending_blocks = pblock;
        if (DST_block(entry).child_block_off)
        {
                child_entry = (dst_rec_ptr_t) DST_OFFSET(entry,
@@ -1553,6 +1500,7 @@ process_dst_block(objfile, entry)
                                child_entry = NULL;
                }
        }
+       record_pending_block (objfile, block, NULL);
        return block;
 }
 
@@ -1565,7 +1513,6 @@ read_dst_symtab (objfile)
        dst_rec_ptr_t entry, file_table, root_block;
        char    *source_file;
        struct  block *block, *global_block;
-       struct  pending_block *pblock;
        int     symnum;
        struct symbol_list *nextsym;
        int     module_num = 0;
@@ -1590,11 +1537,6 @@ read_dst_symtab (objfile)
                                        DST_comp_unit(entry).data_size);
                        dst_start_symtab();
 
-                       pblock = (struct pending_block *)
-                               xmalloc (sizeof (struct pending_block));
-                       pblock->next = NULL;
-                       pending_blocks = pblock;
-       
                        block = process_dst_block(objfile, root_block);
 
                        global_block = (struct block *)
@@ -1620,7 +1562,7 @@ read_dst_symtab (objfile)
                        BLOCK_END(global_block) = BLOCK_END(block);
                        BLOCK_SUPERBLOCK(global_block) = 0;
                        BLOCK_SUPERBLOCK(block) = global_block;
-                       pblock->block = global_block;
+                       record_pending_block (objfile, global_block, NULL);
 
                        complete_symtab(source_file,
                                        BLOCK_START(block), 
@@ -1630,8 +1572,8 @@ read_dst_symtab (objfile)
                }
        }
        if (module_num)
-               record_minimal_symbol("<end_of_program>",
-                               BLOCK_END(block), mst_text);
+               prim_record_minimal_symbol("<end_of_program>",
+                               BLOCK_END(block), mst_text, objfile);
        /* One more faked symbol to make sure nothing can ever run off the
         * end of the symbol table. This one represents the end of the
         * text space. It used to be (CORE_ADDR) -1 (effectively the highest
@@ -1640,9 +1582,9 @@ read_dst_symtab (objfile)
         * but no functions are ever mapped to an address higher than
         * 40000000
         */
-       record_minimal_symbol("<end_of_text>",
+       prim_record_minimal_symbol("<end_of_text>",
                                (CORE_ADDR) 0x40000000,
-                               mst_text);
+                               mst_text, objfile);
        while (struct_list)
        {
                element = struct_list;
@@ -1696,6 +1638,7 @@ dst_symfile_offsets (objfile, addr)
      struct objfile *objfile;
      CORE_ADDR addr;
 {
+  objfile->num_sections = 1;
   return &dst_symfile_faker;
 }
 
@@ -1703,8 +1646,10 @@ dst_symfile_offsets (objfile, addr)
 
 static struct sym_fns dst_sym_fns =
 {
-  "apollo",            /* sym_name: name or name prefix of BFD target type */
-  6,                   /* sym_namelen: number of significant sym_name chars */
+  /* FIXME: Can this be integrated with coffread.c?  If not, should it be
+     a separate flavour like ecoff?  */
+  (enum bfd_flavour)-2,
+
   dst_new_init,                /* sym_new_init: init anything gbl to entire symtab */
   dst_symfile_init,    /* sym_init: read initial info, setup for sym_read() */
   dst_symfile_read,    /* sym_read: read a symbol file into symtab */
This page took 0.031041 seconds and 4 git commands to generate.