* gas/arm/abs12.d: Update expected disassembly.
[deliverable/binutils-gdb.git] / gdb / symtab.c
index 4f19d13368589d4cf513442f1c3850f90f5c290a..db84f4fc7191893bdd3873f34ca2f044b1543d85 100644 (file)
@@ -651,7 +651,7 @@ symbol_natural_name (const struct general_symbol_info *gsymbol)
 /* Return the demangled name for a symbol based on the language for
    that symbol.  If no demangled name exists, return NULL. */
 char *
-symbol_demangled_name (struct general_symbol_info *gsymbol)
+symbol_demangled_name (const struct general_symbol_info *gsymbol)
 {
   switch (gsymbol->language) 
     {
@@ -1081,7 +1081,8 @@ fixup_section (struct general_symbol_info *ginfo,
          int idx = s->the_bfd_section->index;
          CORE_ADDR offset = ANOFFSET (objfile->section_offsets, idx);
 
-         if (s->addr - offset <= addr && addr < s->endaddr - offset)
+         if (obj_section_addr (s) - offset <= addr
+             && addr < obj_section_endaddr (s) - offset)
            {
              ginfo->bfd_section = s->the_bfd_section;
              ginfo->section = idx;
@@ -1116,7 +1117,6 @@ fixup_symbol_section (struct symbol *sym, struct objfile *objfile)
     {
     case LOC_STATIC:
     case LOC_LABEL:
-    case LOC_INDIRECT:
       addr = SYMBOL_VALUE_ADDRESS (sym);
       break;
     case LOC_BLOCK:
@@ -1151,7 +1151,6 @@ fixup_psymbol_section (struct partial_symbol *psym, struct objfile *objfile)
     {
     case LOC_STATIC:
     case LOC_LABEL:
-    case LOC_INDIRECT:
     case LOC_BLOCK:
       addr = SYMBOL_VALUE_ADDRESS (psym);
       break;
@@ -1169,8 +1168,6 @@ fixup_psymbol_section (struct partial_symbol *psym, struct objfile *objfile)
 /* Find the definition for a specified symbol name NAME
    in domain DOMAIN, visible from lexical block BLOCK.
    Returns the struct symbol pointer, or zero if no symbol is found.
-   If SYMTAB is non-NULL, store the symbol table in which the
-   symbol was found there, or NULL if not found.
    C++: if IS_A_FIELD_OF_THIS is nonzero on entry, check to see if
    NAME is a field of the current implied argument `this'.  If so set
    *IS_A_FIELD_OF_THIS to 1, otherwise set it to zero. 
@@ -1399,8 +1396,8 @@ lookup_objfile_from_block (const struct block *block)
   return NULL;
 }
 
-/* Look up a symbol in a block; if found, locate its symtab, fixup the
-   symbol, and set block_found appropriately.  */
+/* Look up a symbol in a block; if found, fixup the symbol, and set
+   block_found appropriately.  */
 
 struct symbol *
 lookup_symbol_aux_block (const char *name, const char *linkage_name,
@@ -1959,13 +1956,7 @@ lookup_block_symbol (const struct block *block, const char *name,
                  ? strcmp (SYMBOL_LINKAGE_NAME (sym), linkage_name) == 0 : 1))
            {
              sym_found = sym;
-             if (SYMBOL_CLASS (sym) != LOC_ARG &&
-                 SYMBOL_CLASS (sym) != LOC_LOCAL_ARG &&
-                 SYMBOL_CLASS (sym) != LOC_REF_ARG &&
-                 SYMBOL_CLASS (sym) != LOC_REGPARM &&
-                 SYMBOL_CLASS (sym) != LOC_REGPARM_ADDR &&
-                 SYMBOL_CLASS (sym) != LOC_BASEREG_ARG &&
-                 SYMBOL_CLASS (sym) != LOC_COMPUTED_ARG)
+             if (!SYMBOL_IS_ARGUMENT (sym))
                {
                  break;
                }
@@ -2627,6 +2618,21 @@ find_function_start_sal (struct symbol *sym, int funfirstline)
       /* Recalculate the line number (might not be N+1).  */
       sal = find_pc_sect_line (pc, SYMBOL_BFD_SECTION (sym), 0);
     }
+
+  /* On targets with executable formats that don't have a concept of
+     constructors (ELF with .init has, PE doesn't), gcc emits a call
+     to `__main' in `main' between the prologue and before user
+     code.  */
+  if (funfirstline
+      && gdbarch_skip_main_prologue_p (current_gdbarch)
+      && SYMBOL_LINKAGE_NAME (sym)
+      && strcmp (SYMBOL_LINKAGE_NAME (sym), "main") == 0)
+    {
+      pc = gdbarch_skip_main_prologue (current_gdbarch, pc);
+      /* Recalculate the line number (might not be N+1).  */
+      sal = find_pc_sect_line (pc, SYMBOL_BFD_SECTION (sym), 0);
+    }
+
   sal.pc = pc;
 
   return sal;
@@ -4320,7 +4326,7 @@ main_name (void)
 /* Handle ``executable_changed'' events for the symtab module.  */
 
 static void
-symtab_observer_executable_changed (void *unused)
+symtab_observer_executable_changed (void)
 {
   /* NAME_OF_MAIN may no longer be the same, so reset it for now.  */
   set_main_name (NULL);
@@ -4451,8 +4457,8 @@ expand_line_sal (struct symtab_and_line sal)
      blocks -- for each PC found above we see if there are other PCs
      that are in the same block.  If yes, the other PCs are filtered out.  */  
 
-  filter = xmalloc (ret.nelts * sizeof (int));
-  blocks = xmalloc (ret.nelts * sizeof (struct block *));
+  filter = alloca (ret.nelts * sizeof (int));
+  blocks = alloca (ret.nelts * sizeof (struct block *));
   for (i = 0; i < ret.nelts; ++i)
     {
       filter[i] = 1;
This page took 0.025401 seconds and 4 git commands to generate.