diff options
Diffstat (limited to 'gprof/tahoe.c')
-rw-r--r-- | gprof/tahoe.c | 53 |
1 files changed, 21 insertions, 32 deletions
diff --git a/gprof/tahoe.c b/gprof/tahoe.c index 214309a..1e627c8 100644 --- a/gprof/tahoe.c +++ b/gprof/tahoe.c @@ -17,10 +17,12 @@ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #include "gprof.h" +#include "search_list.h" +#include "source.h" +#include "symtab.h" #include "cg_arcs.h" #include "corefile.h" #include "hist.h" -#include "symtab.h" /* * opcode of the `callf' instruction @@ -49,16 +51,16 @@ static Sym indirectchild; static tahoe_operandenum tahoe_operandmode PARAMS ((unsigned char *)); static char *tahoe_operandname PARAMS ((tahoe_operandenum)); static long tahoe_operandlength PARAMS ((unsigned char *)); -static bfd_vma tahoe_reladdr PARAMS ((char *)); +static bfd_signed_vma tahoe_offset PARAMS ((unsigned char *)); void tahoe_find_call PARAMS ((Sym *, bfd_vma, bfd_vma)); static tahoe_operandenum tahoe_operandmode (modep) unsigned char *modep; { - long usesreg = ((long) *modep) & 0xf; + long usesreg = *modep & 0xf; - switch (((long) *modep) >> 4) + switch ((*modep >> 4) & 0xf) { case 0: case 1: @@ -186,34 +188,24 @@ tahoe_operandlength (modep) abort (); } -static bfd_vma -tahoe_reladdr (modep) - char *modep; +static bfd_signed_vma +tahoe_offset (modep) + unsigned char *modep; { tahoe_operandenum mode = tahoe_operandmode (modep); - char *cp; - short *sp; - long *lp; - int i; - long value = 0; - cp = modep; - ++cp; /* skip over the mode */ + ++modep; /* skip over the mode */ switch (mode) { default: fprintf (stderr, "[reladdr] not relative address\n"); - return (bfd_vma) modep; + return 0; case byterel: - return (bfd_vma) (cp + sizeof *cp + *cp); + return 1 + bfd_get_signed_8 (core_bfd, modep); case wordrel: - for (i = 0; (size_t) i < sizeof *sp; i++) - value = (value << 8) + (cp[i] & 0xff); - return (bfd_vma) (cp + sizeof *sp + value); + return 2 + bfd_get_signed_16 (core_bfd, modep); case longrel: - for (i = 0; (size_t) i < sizeof *lp; i++) - value = (value << 8) + (cp[i] & 0xff); - return (bfd_vma) (cp + sizeof *lp + value); + return 4 + bfd_get_signed_32 (core_bfd, modep); } } @@ -228,7 +220,7 @@ tahoe_find_call (parent, p_lowpc, p_highpc) Sym *child; tahoe_operandenum mode; tahoe_operandenum firstmode; - bfd_vma destpc; + bfd_vma pc, destpc; static bool inited = FALSE; if (!inited) @@ -254,21 +246,19 @@ tahoe_find_call (parent, p_lowpc, p_highpc) DBG (CALLDEBUG, printf ("[findcall] %s: 0x%lx to 0x%lx\n", parent->name, (unsigned long) p_lowpc, (unsigned long) p_highpc)); - for (instructp = (unsigned char *) core_text_space + p_lowpc; - instructp < (unsigned char *) core_text_space + p_highpc; - instructp += length) + for (pc = p_lowpc; pc < p_highpc; pc += length) { length = 1; - if (*instructp == CALLF) + instructp = ((unsigned char *) core_text_space + + pc - core_text_sect->vma); + if ((*instructp & 0xff) == CALLF) { /* * maybe a callf, better check it out. * skip the count of the number of arguments. */ DBG (CALLDEBUG, printf ("[findcall]\t0x%lx:callf", - ((unsigned long) - (instructp - - (unsigned char *) core_text_space)))); + (unsigned long) pc)); firstmode = tahoe_operandmode (instructp + length); switch (firstmode) { @@ -312,8 +302,7 @@ tahoe_find_call (parent, p_lowpc, p_highpc) * check that this is the address of * a function. */ - destpc = tahoe_reladdr (instructp + length) - - (bfd_vma) core_text_space; + destpc = pc + tahoe_offset (instructp + length); if (destpc >= s_lowpc && destpc <= s_highpc) { child = sym_lookup (&symtab, destpc); |