aboutsummaryrefslogtreecommitdiff
path: root/gprof/vax.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2002-01-31 12:56:08 +0000
committerAlan Modra <amodra@gmail.com>2002-01-31 12:56:08 +0000
commit6d9c411afd0301f0262ff63d6dc59dac38f58e63 (patch)
tree4c0dfabb0e6280f2d1eb6858297020cbb8ba0879 /gprof/vax.c
parentcaf8ca8e1c4fbebb2f611a3d33f2449fd8dea4f3 (diff)
downloadgdb-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/vax.c')
-rw-r--r--gprof/vax.c75
1 files changed, 35 insertions, 40 deletions
diff --git a/gprof/vax.c b/gprof/vax.c
index bce1e72..bbecff9 100644
--- a/gprof/vax.c
+++ b/gprof/vax.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 `calls' instruction
@@ -41,30 +43,34 @@ enum opermodes
};
typedef enum opermodes operandenum;
+#if 0
+/* Here to document only. We can't use this when cross compiling as
+ the bitfield layout might not be the same as native. */
struct modebyte
{
unsigned int regfield:4;
unsigned int modefield:4;
};
+#endif
/*
* A symbol to be the child of indirect calls:
*/
static Sym indirectchild;
-static operandenum vax_operandmode PARAMS ((struct modebyte *));
+static operandenum vax_operandmode PARAMS ((unsigned char *));
static char *vax_operandname PARAMS ((operandenum));
-static long vax_operandlength PARAMS ((struct modebyte *));
-static bfd_vma vax_reladdr PARAMS ((struct modebyte *));
+static long vax_operandlength PARAMS ((unsigned char *));
+static bfd_signed_vma vax_offset PARAMS ((unsigned char *));
void vax_find_call PARAMS ((Sym *, bfd_vma, bfd_vma));
static operandenum
vax_operandmode (modep)
- struct modebyte *modep;
+ unsigned char *modep;
{
- long usesreg = modep->regfield;
+ int usesreg = *modep & 0xf;
- switch (modep->modefield)
+ switch ((*modep >> 4) & 0xf)
{
case 0:
case 1:
@@ -156,7 +162,7 @@ vax_operandname (mode)
static long
vax_operandlength (modep)
- struct modebyte *modep;
+ unsigned char *modep;
{
switch (vax_operandmode (modep))
@@ -186,36 +192,30 @@ vax_operandlength (modep)
case longreldef:
return 5;
case indexed:
- return 1 + vax_operandlength ((struct modebyte *) ((char *) modep) + 1);
+ return 1 + vax_operandlength (modep + 1);
}
/* NOTREACHED */
abort ();
}
-static bfd_vma
-vax_reladdr (modep)
- struct modebyte *modep;
+static bfd_signed_vma
+vax_offset (modep)
+ unsigned char *modep;
{
operandenum mode = vax_operandmode (modep);
- char *cp;
- short *sp;
- long *lp;
- cp = (char *) 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:
- sp = (short *) cp;
- return (bfd_vma) (cp + sizeof *sp + *sp);
+ return 2 + bfd_get_signed_16 (core_bfd, modep);
case longrel:
- lp = (long *) cp;
- return (bfd_vma) (cp + sizeof *lp + *lp);
+ return 4 + bfd_get_signed_32 (core_bfd, modep);
}
}
@@ -231,7 +231,7 @@ vax_find_call (parent, p_lowpc, p_highpc)
Sym *child;
operandenum mode;
operandenum firstmode;
- bfd_vma destpc;
+ bfd_vma pc, destpc;
static bool inited = FALSE;
if (!inited)
@@ -257,22 +257,20 @@ vax_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 == CALLS)
+ instructp = ((unsigned char *) core_text_space
+ + pc - core_text_sect->vma);
+ if ((*instructp & 0xff) == CALLS)
{
/*
* maybe a calls, better check it out.
* skip the count of the number of arguments.
*/
DBG (CALLDEBUG,
- printf ("[findcall]\t0x%lx:calls",
- ((unsigned long)
- (instructp - (unsigned char *) core_text_space))));
- firstmode = vax_operandmode ((struct modebyte *) (instructp + length));
+ printf ("[findcall]\t0x%lx:calls", (unsigned long) pc));
+ firstmode = vax_operandmode (instructp + length);
switch (firstmode)
{
case literal:
@@ -281,8 +279,8 @@ vax_find_call (parent, p_lowpc, p_highpc)
default:
goto botched;
}
- length += vax_operandlength ((struct modebyte *) (instructp + length));
- mode = vax_operandmode ((struct modebyte *) (instructp + length));
+ length += vax_operandlength (instructp + length);
+ mode = vax_operandmode (instructp + length);
DBG (CALLDEBUG,
printf ("\tfirst operand is %s", vax_operandname (firstmode));
printf ("\tsecond operand is %s\n", vax_operandname (mode)));
@@ -304,8 +302,7 @@ vax_find_call (parent, p_lowpc, p_highpc)
* e.g. arrays of pointers to functions???]
*/
arc_add (parent, &indirectchild, (unsigned long) 0);
- length += vax_operandlength (
- (struct modebyte *) (instructp + length));
+ length += vax_operandlength (instructp + length);
continue;
case byterel:
case wordrel:
@@ -315,8 +312,7 @@ vax_find_call (parent, p_lowpc, p_highpc)
* check that this is the address of
* a function.
*/
- destpc = vax_reladdr ((struct modebyte *) (instructp + length))
- - (bfd_vma) core_text_space;
+ destpc = pc + vax_offset (instructp + length);
if (destpc >= s_lowpc && destpc <= s_highpc)
{
child = sym_lookup (&symtab, destpc);
@@ -333,8 +329,7 @@ vax_find_call (parent, p_lowpc, p_highpc)
* a hit
*/
arc_add (parent, child, (unsigned long) 0);
- length += vax_operandlength ((struct modebyte *)
- (instructp + length));
+ length += vax_operandlength (instructp + length);
continue;
}
goto botched;