summaryrefslogtreecommitdiff
path: root/gprof/tahoe.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@bigpond.net.au>2002-01-31 12:56:08 +0000
committerAlan Modra <amodra@bigpond.net.au>2002-01-31 12:56:08 +0000
commit0b60af563a0c85486bf82d3ec30c460a8e333a26 (patch)
treee82c76e12c54593f3d872ec3f266c4aec4adf9dc /gprof/tahoe.c
parenta81f09ba7107fcbc046409ecb840af929b0dd1a4 (diff)
downloadbinutils-redhat-0b60af563a0c85486bf82d3ec30c460a8e333a26.tar.gz
* 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.c53
1 files changed, 21 insertions, 32 deletions
diff --git a/gprof/tahoe.c b/gprof/tahoe.c
index 214309ac34..1e627c8669 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);