X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=gprof%2Fsymtab.c;h=df3dbdc1aecbb3cb6b2a5b45f22731c2498f0371;hb=e2201c2a578f2b22fc04cc95507c643ac908c952;hp=6b5a093d067fcdbcd977aabda991a1c5fb6fbe11;hpb=0eee5820aa0f68b2283b40f5a3fb09aefcfb1575;p=deliverable%2Fbinutils-gdb.git diff --git a/gprof/symtab.c b/gprof/symtab.c index 6b5a093d06..df3dbdc1ae 100644 --- a/gprof/symtab.c +++ b/gprof/symtab.c @@ -1,12 +1,12 @@ /* symtab.c - Copyright 2000, 2001 Free Software Foundation, Inc. + Copyright (C) 1999-2020 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, @@ -16,13 +16,17 @@ 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., 59 Temple Place - Suite 330, Boston, MA - 02111-1307, USA. */ + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA + 02110-1301, USA. */ #include "gprof.h" +#include "search_list.h" +#include "source.h" +#include "symtab.h" #include "cg_arcs.h" #include "corefile.h" -#include "symtab.h" + +static int cmp_addr (const PTR, const PTR); Sym_Table symtab; @@ -30,7 +34,7 @@ Sym_Table symtab; /* Initialize a symbol (so it's empty). */ void -DEFUN (sym_init, (sym), Sym * sym) +sym_init (Sym *sym) { memset (sym, 0, sizeof (*sym)); @@ -54,10 +58,10 @@ DEFUN (sym_init, (sym), Sym * sym) the global symbol survives. */ static int -DEFUN (cmp_addr, (lp, rp), const PTR lp AND const PTR rp) +cmp_addr (const PTR lp, const PTR rp) { - Sym *left = (Sym *) lp; - Sym *right = (Sym *) rp; + const Sym *left = (const Sym *) lp; + const Sym *right = (const Sym *) rp; if (left->addr > right->addr) return 1; @@ -72,7 +76,7 @@ DEFUN (cmp_addr, (lp, rp), const PTR lp AND const PTR rp) void -DEFUN (symtab_finalize, (tab), Sym_Table * tab) +symtab_finalize (Sym_Table *tab) { Sym *src, *dst; bfd_vma prev_addr; @@ -85,7 +89,7 @@ DEFUN (symtab_finalize, (tab), Sym_Table * tab) /* Remove duplicate entries to speed-up later processing and set end_addr if its not set yet. */ - prev_addr = tab->base[0].addr + 1; + prev_addr = tab->base[0].addr - 1; for (src = dst = tab->base; src < tab->limit; ++src) { @@ -103,7 +107,7 @@ DEFUN (symtab_finalize, (tab), Sym_Table * tab) && ((src->is_func && !dst[-1].is_func) || ((src->is_func == dst[-1].is_func) && ((src->name[0] != '_' && dst[-1].name[0] == '_') - || (src->name[0] + || (src->name[0] == '_' && dst[-1].name[0] == '_' && src->name[1] != '_' && dst[-1].name[1] == '_')))))) { @@ -144,7 +148,8 @@ DEFUN (symtab_finalize, (tab), Sym_Table * tab) } if (tab->len > 0 && dst[-1].end_addr == 0) - dst[-1].end_addr = core_text_sect->vma + core_text_sect->_raw_size - 1; + dst[-1].end_addr + = core_text_sect->vma + bfd_section_size (core_text_sect) - 1; DBG (AOUTDEBUG | IDDEBUG, printf ("[symtab_finalize]: removed %d duplicate entries\n", @@ -159,8 +164,9 @@ DEFUN (symtab_finalize, (tab), Sym_Table * tab) for (j = 0; j < tab->len; ++j) { printf ("[symtab_finalize] 0x%lx-0x%lx\t%s\n", - (long) tab->base[j].addr, (long) tab->base[j].end_addr, - tab->base[j].name); + (unsigned long) tab->base[j].addr, + (unsigned long) tab->base[j].end_addr, + tab->base[j].name); } ); } @@ -169,16 +175,16 @@ DEFUN (symtab_finalize, (tab), Sym_Table * tab) #ifdef DEBUG Sym * -DEFUN (dbg_sym_lookup, (symtab, address), Sym_Table * symtab AND bfd_vma address) +dbg_sym_lookup (Sym_Table *sym_tab, bfd_vma address) { - long low, mid, high; + unsigned long low, mid, high; Sym *sym; fprintf (stderr, "[dbg_sym_lookup] address 0x%lx\n", (unsigned long) address); - sym = symtab->base; - for (low = 0, high = symtab->len - 1; low != high;) + sym = sym_tab->base; + for (low = 0, high = sym_tab->len - 1; low != high;) { mid = (high + low) >> 1; @@ -208,7 +214,7 @@ DEFUN (dbg_sym_lookup, (symtab, address), Sym_Table * symtab AND bfd_vma address /* Look up an address in the symbol-table that is sorted by address. If address does not hit any symbol, 0 is returned. */ Sym * -DEFUN (sym_lookup, (symtab, address), Sym_Table * symtab AND bfd_vma address) +sym_lookup (Sym_Table *sym_tab, bfd_vma address) { long low, high; long mid = -1; @@ -217,11 +223,11 @@ DEFUN (sym_lookup, (symtab, address), Sym_Table * symtab AND bfd_vma address) int probes = 0; #endif /* DEBUG */ - if (!symtab->len) + if (!sym_tab->len) return 0; - sym = symtab->base; - for (low = 0, high = symtab->len - 1; low != high;) + sym = sym_tab->base; + for (low = 0, high = sym_tab->len - 1; low != high;) { DBG (LOOKUPDEBUG, ++probes); mid = (high + low) / 2; @@ -238,7 +244,7 @@ DEFUN (sym_lookup, (symtab, address), Sym_Table * symtab AND bfd_vma address) { DBG (LOOKUPDEBUG, printf ("[sym_lookup] %d probes (symtab->len=%u)\n", - probes, symtab->len - 1)); + probes, sym_tab->len - 1)); return &sym[mid]; } } @@ -259,7 +265,7 @@ DEFUN (sym_lookup, (symtab, address), Sym_Table * symtab AND bfd_vma address) else { DBG (LOOKUPDEBUG, printf ("[sym_lookup] %d (%u) probes, fall off\n", - probes, symtab->len - 1)); + probes, sym_tab->len - 1)); return &sym[mid + 1]; } }