remove long long printf crash
[deliverable/binutils-gdb.git] / gdb / buildsym.c
index be8f787b47119a416f550fbef393be2ec3633c8c..b104f16e928acf01cf4e3c4968c1b57b5f66a010 100644 (file)
@@ -55,6 +55,10 @@ static struct pending_block *pending_blocks = NULL;
 
 static struct pending *free_pendings;
 
+/* Non-zero if symtab has line number info.  This prevents an otherwise empty
+   symtab from being tossed.  */
+
+static int have_line_numbers;
 \f
 static int
 compare_line_numbers PARAMS ((const void *, const void *));
@@ -95,6 +99,10 @@ add_symbol_to_list (symbol, listhead)
      struct pending **listhead;
 {
   register struct pending *link;
+
+  /* If this is an alias for another symbol, don't add it.  */
+  if (symbol->ginfo.name && symbol->ginfo.name[0] == '#')
+    return;
       
   /* We keep PENDINGSIZE symbols in each link of the list.
      If we don't have a link with room in it, add a new link.  */
@@ -566,6 +574,10 @@ start_subfile (name, dirname)
       subfile->language = subfile->next->language;
     }
 
+  /* Initialize the debug format string to NULL.  We may supply it
+     later via a call to record_debugformat. */
+  subfile->debugformat = NULL;
+
   /* cfront output is a C program, so in most ways it looks like a C
      program.  But to demangle we need to set the language to C++.  We
      can distinguish cfront code by the fact that it has #line
@@ -705,6 +717,7 @@ record_line (subfile, line, pc)
        xmalloc (sizeof (struct linetable)
          + subfile->line_vector_length * sizeof (struct linetable_entry));
       subfile->line_vector->nitems = 0;
+      have_line_numbers = 1;
     }
 
   if (subfile->line_vector->nitems + 1 >= subfile->line_vector_length)
@@ -761,6 +774,7 @@ start_symtab (name, dirname, start_addr)
   file_symbols = NULL;
   global_symbols = NULL;
   within_function = 0;
+  have_line_numbers = 0;
 
   /* Context stack is initially empty.  Allocate first one with room for
      10 levels; reuse it forever afterward.  */
@@ -835,8 +849,7 @@ end_symtab (end_addr, objfile, section)
      OBJF_REORDERED is true, then sort the pending blocks.  */
   if ((objfile->flags & OBJF_REORDERED) && pending_blocks)
     {
-      /* FIXME!  Remove this horrid bubble sort and use qsort!!!
-        It'd be a whole lot easier if they weren't in a linked list!!! */
+      /* FIXME!  Remove this horrid bubble sort and use merge sort!!! */
       int swapped;
       do
        {
@@ -878,7 +891,8 @@ end_symtab (end_addr, objfile, section)
 
   if (pending_blocks == NULL
       && file_symbols == NULL
-      && global_symbols == NULL)
+      && global_symbols == NULL
+      && have_line_numbers == 0)
     {
       /* Ignore symtabs that have no functions with real debugging info */
       blockvector = NULL;
@@ -969,6 +983,14 @@ end_symtab (end_addr, objfile, section)
             language it is from things we found in the symbols. */
          symtab->language = subfile->language;
 
+         /* Save the debug format string (if any) in the symtab */
+         if (subfile -> debugformat != NULL)
+           {
+             symtab->debugformat = obsavestring (subfile->debugformat,
+                                                 strlen (subfile->debugformat),
+                                                 &objfile -> symbol_obstack);
+           }
+
          /* All symtabs for the main file and the subfiles share a
             blockvector, so we need to clear primary for everything but
             the main file.  */
@@ -987,6 +1009,10 @@ end_symtab (end_addr, objfile, section)
        {
          free ((PTR) subfile->line_vector);
        }
+      if (subfile->debugformat != NULL)
+       {
+         free ((PTR) subfile->debugformat);
+       }
 
       nextsub = subfile->next;
       free ((PTR)subfile);
@@ -1066,6 +1092,14 @@ hashname (name)
   return (total % HASHSIZE);
 }
 
+\f
+void
+record_debugformat (format)
+     char *format;
+{
+  current_subfile -> debugformat = savestring (format, strlen (format));
+}
+
 \f
 /* Initialize anything that needs initializing when starting to read
    a fresh piece of a symbol file, e.g. reading in the stuff corresponding
This page took 0.024876 seconds and 4 git commands to generate.