/* corefile.c
- Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005
+ Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008
Free Software Foundation, Inc.
This file is part of GNU Binutils.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
+ the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
02110-1301, USA. */
\f
-#include "libiberty.h"
#include "gprof.h"
+#include "libiberty.h"
#include "search_list.h"
#include "source.h"
#include "symtab.h"
#include "hist.h"
#include "corefile.h"
+#include "safe-ctype.h"
bfd *core_bfd;
static int core_num_syms;
for (name = sym->name; *name; ++name)
{
- if (*name == '.' || *name == '$')
- return 0;
+ if (*name == '$')
+ return 0;
+
+ /* Do not discard nested subprograms (those
+ which end with .NNN, where N are digits). */
+ if (*name == '.')
+ for (name++; *name; name++)
+ if (! ISDIGIT (*name))
+ return 0;
}
/* On systems where the C compiler adds an underscore to all
else
{
DBG (AOUTDEBUG, printf ("[get_src_info] no info for 0x%lx (%s:%d,%s)\n",
- (long) addr, fname ? fname : "<unknown>", l,
+ (unsigned long) addr,
+ fname ? fname : "<unknown>", l,
func_name ? func_name : "<unknown>"));
return FALSE;
}
done (1);
}
- /* The "+ 2" is for the sentinels. */
- symtab.base = (Sym *) xmalloc ((symtab.len + 2) * sizeof (Sym));
+ symtab.base = (Sym *) xmalloc (symtab.len * sizeof (Sym));
/* Pass 2 - create symbols. */
symtab.limit = symtab.base;
}
}
- symtab.limit->is_func = TRUE;
+ symtab.limit->is_func = (core_syms[i]->flags & BSF_FUNCTION) != 0;
symtab.limit->is_bb_head = TRUE;
if (class == 't')
else
max_vma = MAX (symtab.limit->addr, max_vma);
- /* If we see "main" without an initial '_', we assume names
- are *not* prefixed by '_'. */
- if (symtab.limit->name[0] == 'm' && discard_underscores
- && strcmp (symtab.limit->name, "main") == 0)
- discard_underscores = 0;
-
DBG (AOUTDEBUG, printf ("[core_create_function_syms] %ld %s 0x%lx\n",
(long) (symtab.limit - symtab.base),
symtab.limit->name,
++symtab.limit;
}
- /* Create sentinels. */
- sym_init (symtab.limit);
- symtab.limit->name = "<locore>";
- symtab.limit->addr = 0;
- symtab.limit->end_addr = min_vma - 1;
- ++symtab.limit;
-
- sym_init (symtab.limit);
- symtab.limit->name = "<hicore>";
- symtab.limit->addr = max_vma + 1;
- symtab.limit->end_addr = ~(bfd_vma) 0;
- ++symtab.limit;
-
symtab.len = symtab.limit - symtab.base;
symtab_finalize (&symtab);
}
char *prev_name, *prev_filename;
unsigned int prev_name_len, prev_filename_len;
bfd_vma vma, min_vma = ~(bfd_vma) 0, max_vma = 0;
- Sym *prev, dummy, *sentinel, *sym;
+ Sym *prev, dummy, *sym;
const char *filename;
int prev_line_num;
Sym_Table ltab;
else
{
sym = sym_lookup(&symtab, ltab.limit->addr);
- ltab.limit->is_static = sym->is_static;
+ if (sym)
+ ltab.limit->is_static = sym->is_static;
}
prev = ltab.limit;
- /* If we see "main" without an initial '_', we assume names
- are *not* prefixed by '_'. */
- if (ltab.limit->name[0] == 'm' && discard_underscores
- && strcmp (ltab.limit->name, "main") == 0)
- discard_underscores = 0;
-
DBG (AOUTDEBUG, printf ("[core_create_line_syms] %lu %s 0x%lx\n",
(unsigned long) (ltab.limit - ltab.base),
ltab.limit->name,
++ltab.limit;
}
- /* Update sentinels. */
- sentinel = sym_lookup (&symtab, (bfd_vma) 0);
-
- if (sentinel
- && strcmp (sentinel->name, "<locore>") == 0
- && min_vma <= sentinel->end_addr)
- sentinel->end_addr = min_vma - 1;
-
- sentinel = sym_lookup (&symtab, ~(bfd_vma) 0);
-
- if (sentinel
- && strcmp (sentinel->name, "<hicore>") == 0
- && max_vma >= sentinel->addr)
- sentinel->addr = max_vma + 1;
-
/* Copy in function symbols. */
memcpy (ltab.limit, symtab.base, symtab.len * sizeof (Sym));
ltab.limit += symtab.len;