2013-02-01 Andreas Tobler <andreast@fgznet.ch>
[deliverable/binutils-gdb.git] / gdb / symtab.c
index 68d654db2c97f955e63262572bc9fa576b31b803..a471fc3bf24ba32c3f017c565f6a6c8e32be688e 100644 (file)
@@ -285,7 +285,6 @@ iterate_over_symtabs (const char *name,
                                       void *data),
                      void *data)
 {
-  struct symtab *s = NULL;
   struct objfile *objfile;
   char *real_path = NULL;
   char *full_path = NULL;
@@ -526,7 +525,7 @@ symbol_set_language (struct general_symbol_info *gsymbol,
 /* Objects of this type are stored in the demangled name hash table.  */
 struct demangled_name_entry
 {
-  char *mangled;
+  const char *mangled;
   char demangled[1];
 };
 
@@ -758,7 +757,7 @@ symbol_set_names (struct general_symbol_info *gsymbol,
       linkage_name_copy = linkage_name;
     }
 
-  entry.mangled = (char *) lookup_name;
+  entry.mangled = lookup_name;
   slot = ((struct demangled_name_entry **)
          htab_find_slot (objfile->demangled_names_hash,
                          &entry, INSERT));
@@ -789,10 +788,12 @@ symbol_set_names (struct general_symbol_info *gsymbol,
                                 offsetof (struct demangled_name_entry,
                                           demangled)
                                 + demangled_len + 1);
-         (*slot)->mangled = (char *) lookup_name;
+         (*slot)->mangled = lookup_name;
        }
       else
        {
+         char *mangled_ptr;
+
          /* If we must copy the mangled name, put it directly after
             the demangled name so we can have a single
             allocation.  */
@@ -800,8 +801,9 @@ symbol_set_names (struct general_symbol_info *gsymbol,
                                 offsetof (struct demangled_name_entry,
                                           demangled)
                                 + lookup_len + demangled_len + 2);
-         (*slot)->mangled = &((*slot)->demangled[demangled_len + 1]);
-         strcpy ((*slot)->mangled, lookup_name);
+         mangled_ptr = &((*slot)->demangled[demangled_len + 1]);
+         strcpy (mangled_ptr, lookup_name);
+         (*slot)->mangled = mangled_ptr;
        }
 
       if (demangled_name != NULL)
@@ -2100,12 +2102,9 @@ find_pc_sect_symtab (CORE_ADDR pc, struct obj_section *section)
   struct symtab *s = NULL;
   struct symtab *best_s = NULL;
   struct objfile *objfile;
-  struct program_space *pspace;
   CORE_ADDR distance = 0;
   struct minimal_symbol *msymbol;
 
-  pspace = current_program_space;
-
   /* If we know that this is not a text address, return failure.  This is
      necessary because we loop based on the block's high and low code
      addresses, which do not include the data ranges, and because
@@ -2258,7 +2257,6 @@ find_pc_sect_line (CORE_ADDR pc, struct obj_section *section, int notcurrent)
      we will use a line one less than this,
      with a range from the start of that file to the first line's pc.  */
   struct linetable_entry *alt = NULL;
-  struct symtab *alt_symtab = 0;
 
   /* Info on best line seen in this file.  */
 
@@ -2403,10 +2401,7 @@ find_pc_sect_line (CORE_ADDR pc, struct obj_section *section, int notcurrent)
       /* Is this file's first line closer than the first lines of other files?
          If so, record this file, and its first line, as best alternate.  */
       if (item->pc > pc && (!alt || item->pc < alt->pc))
-       {
-         alt = item;
-         alt_symtab = s;
-       }
+       alt = item;
 
       for (i = 0; i < len; i++, item++)
        {
@@ -2597,8 +2592,7 @@ VEC (CORE_ADDR) *
 find_pcs_for_symtab_line (struct symtab *symtab, int line,
                          struct linetable_entry **best_item)
 {
-  int start = 0, ix;
-  struct symbol *previous_function = NULL;
+  int start = 0;
   VEC (CORE_ADDR) *result = NULL;
 
   /* First, collect all the PCs that are at this line.  */
@@ -4038,8 +4032,6 @@ completion_list_add_name (const char *symname,
                          const char *sym_text, int sym_text_len,
                          const char *text, const char *word)
 {
-  int newsize;
-
   /* Clip symbols that cannot match.  */
   if (!compare_symbol_name (symname, sym_text, sym_text_len))
     return;
@@ -4902,6 +4894,10 @@ skip_prologue_using_sal (struct gdbarch *gdbarch, CORE_ADDR func_addr)
             line mark the prologue -> body transition.  */
          if (sal.line >= prologue_sal.line)
            break;
+         /* Likewise if we are in a different symtab altogether
+            (e.g. within a file included via #include).  */
+         if (sal.symtab != prologue_sal.symtab)
+           break;
 
          /* The line number is smaller.  Check that it's from the
             same function, not something inlined.  If it's inlined,
This page took 0.026382 seconds and 4 git commands to generate.