diff options
author | Alan Modra <amodra@gmail.com> | 2002-01-31 12:56:08 +0000 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2002-01-31 12:56:08 +0000 |
commit | 6d9c411afd0301f0262ff63d6dc59dac38f58e63 (patch) | |
tree | 4c0dfabb0e6280f2d1eb6858297020cbb8ba0879 /gprof/tahoe.c | |
parent | caf8ca8e1c4fbebb2f611a3d33f2449fd8dea4f3 (diff) | |
download | gdb-6d9c411afd0301f0262ff63d6dc59dac38f58e63.zip gdb-6d9c411afd0301f0262ff63d6dc59dac38f58e63.tar.gz gdb-6d9c411afd0301f0262ff63d6dc59dac38f58e63.tar.bz2 |
* alpha.c (alpha_Instruction): Don't use.
(alpha_find_call): Avoid use of bitfields and casts between
pointers and integers of different sizes. Avoid endian problems
when cross-compiling.
* vax.c (vax_find_call): Likewise.
(struct modebyte): Don't use.
(vax_operandmode): Pass in an unsigned char *.
(vax_operandlength): Likewise.
(vax_reladdr): Rename to vax_offset and return relative offset
rather than address.
* i386.c (i386_find_call): Avoid casts between pointers and
integers of different sizes.
* sparc.c (sparc_find_call): Likewise. Avoid endian problems.
* tahoe.c (tahoe_find_call): Likewise.
(tahoe_reladdr): Rename to tahoe_offset and return relative offset
rather than address.
* basic_blocks.h: Don't include headers here.
* call_graph.h: Likewise.
* cg_arcs.h: Likewise.
* cg_print.h: Likewise.
* corefile.h: Likewise.
* gmon_io.h: Likewise.
* gmon_out.h: Likewise.
* hertz.h: Likewise.
* hist.h: Likewise.
* source.h: Likewise.
* sym_ids.h: Likewise.
* symtab.h: Likewise.
* gprof.h: Don't include ansidecl.h, do include bfd.h.
(bool): Don't typedef.
* alpha.c: Adjust #include's for above header changes.
* basic_blocks.c: Likewise.
* call_graph.c: Likewise.
* cg_arcs.c: Likewise.
* cg_dfn.c: Likewise.
* cg_print.c: Likewise.
* corefile.c: Likewise.
* gmon_io.c: Likewise.
* gprof.c: Likewise.
* hertz.c: Likewise.
* hist.c: Likewise.
* i386.c: Likewise.
* mips.c: Likewise.
* sparc.c: Likewise.
* sym_ids.c: Likewise.
* symtab.c: Likewise.
* tahoe.c: Likewise.
* utils.c: Likewise.
* vax.c: Likewise.
* po/POTFILES.in: Regenerate.
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); |