+++ /dev/null
-/*
- * Copyright (c) 1983, 1993, 2001
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-#include "gprof.h"
-#include "search_list.h"
-#include "source.h"
-#include "symtab.h"
-#include "cg_arcs.h"
-#include "corefile.h"
-#include "hist.h"
-
- /*
- * opcode of the `callf' instruction
- */
-#define CALLF 0xfe
-
- /*
- * register for pc relative addressing
- */
-#define PC 0xf
-
-enum tahoe_opermodes
- {
- literal, indexed, reg, regdef, autodec, autoinc, autoincdef,
- bytedisp, bytedispdef, worddisp, worddispdef, longdisp, longdispdef,
- immediate, absolute, byterel, bytereldef, wordrel, wordreldef,
- longrel, longreldef
- };
-typedef enum tahoe_opermodes tahoe_operandenum;
-
-/*
- * A symbol to be the child of indirect callf:
- */
-static Sym indirectchild;
-
-static tahoe_operandenum tahoe_operandmode (unsigned char *);
-static char *tahoe_operandname (tahoe_operandenum);
-static long tahoe_operandlength (unsigned char *);
-static bfd_signed_vma tahoe_offset (unsigned char *);
-void tahoe_find_call (Sym *, bfd_vma, bfd_vma);
-
-static tahoe_operandenum
-tahoe_operandmode (unsigned char *modep)
-{
- long usesreg = *modep & 0xf;
-
- switch ((*modep >> 4) & 0xf)
- {
- case 0:
- case 1:
- case 2:
- case 3:
- return literal;
- case 4:
- return indexed;
- case 5:
- return reg;
- case 6:
- return regdef;
- case 7:
- return autodec;
- case 8:
- return usesreg != 0xe ? autoinc : immediate;
- case 9:
- return usesreg != PC ? autoincdef : absolute;
- case 10:
- return usesreg != PC ? bytedisp : byterel;
- case 11:
- return usesreg != PC ? bytedispdef : bytereldef;
- case 12:
- return usesreg != PC ? worddisp : wordrel;
- case 13:
- return usesreg != PC ? worddispdef : wordreldef;
- case 14:
- return usesreg != PC ? longdisp : longrel;
- case 15:
- return usesreg != PC ? longdispdef : longreldef;
- }
- /* NOTREACHED */
- abort ();
-}
-
-static char *
-tahoe_operandname (tahoe_operandenum mode)
-{
-
- switch (mode)
- {
- case literal:
- return "literal";
- case indexed:
- return "indexed";
- case reg:
- return "register";
- case regdef:
- return "register deferred";
- case autodec:
- return "autodecrement";
- case autoinc:
- return "autoincrement";
- case autoincdef:
- return "autoincrement deferred";
- case bytedisp:
- return "byte displacement";
- case bytedispdef:
- return "byte displacement deferred";
- case byterel:
- return "byte relative";
- case bytereldef:
- return "byte relative deferred";
- case worddisp:
- return "word displacement";
- case worddispdef:
- return "word displacement deferred";
- case wordrel:
- return "word relative";
- case wordreldef:
- return "word relative deferred";
- case immediate:
- return "immediate";
- case absolute:
- return "absolute";
- case longdisp:
- return "long displacement";
- case longdispdef:
- return "long displacement deferred";
- case longrel:
- return "long relative";
- case longreldef:
- return "long relative deferred";
- }
- /* NOTREACHED */
- abort ();
-}
-
-static long
-tahoe_operandlength (unsigned char *modep
-)
-{
-
- switch (tahoe_operandmode (modep))
- {
- case literal:
- case reg:
- case regdef:
- case autodec:
- case autoinc:
- case autoincdef:
- return 1;
- case bytedisp:
- case bytedispdef:
- case byterel:
- case bytereldef:
- return 2;
- case worddisp:
- case worddispdef:
- case wordrel:
- case wordreldef:
- return 3;
- case immediate:
- case absolute:
- case longdisp:
- case longdispdef:
- case longrel:
- case longreldef:
- return 5;
- case indexed:
- return 1 + tahoe_operandlength (modep + 1);
- }
- /* NOTREACHED */
- abort ();
-}
-
-static bfd_signed_vma
-tahoe_offset (unsigned char *modep)
-{
- tahoe_operandenum mode = tahoe_operandmode (modep);
-
- ++modep; /* skip over the mode */
- switch (mode)
- {
- default:
- fprintf (stderr, "[reladdr] not relative address\n");
- return 0;
- case byterel:
- return 1 + bfd_get_signed_8 (core_bfd, modep);
- case wordrel:
- return 2 + bfd_get_signed_16 (core_bfd, modep);
- case longrel:
- return 4 + bfd_get_signed_32 (core_bfd, modep);
- }
-}
-
-void
-tahoe_find_call (Sym *parent, bfd_vma p_lowpc, bfd_vma p_highpc)
-{
- unsigned char *instructp;
- long length;
- Sym *child;
- tahoe_operandenum mode;
- tahoe_operandenum firstmode;
- bfd_vma pc, destpc;
- static bfd_boolean inited = FALSE;
-
- if (!inited)
- {
- inited = TRUE;
- sym_init (&indirectchild);
- indirectchild.cg.prop.fract = 1.0;
- indirectchild.cg.cyc.head = &indirectchild;
- }
-
- DBG (CALLDEBUG, printf ("[findcall] %s: 0x%lx to 0x%lx\n",
- parent->name, (unsigned long) p_lowpc,
- (unsigned long) p_highpc));
- for (pc = p_lowpc; pc < p_highpc; pc += length)
- {
- length = 1;
- 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) pc));
- firstmode = tahoe_operandmode (instructp + length);
- switch (firstmode)
- {
- case literal:
- case immediate:
- break;
- default:
- goto botched;
- }
- length += tahoe_operandlength (instructp + length);
- mode = tahoe_operandmode (instructp + length);
- DBG (CALLDEBUG,
- printf ("\tfirst operand is %s", tahoe_operandname (firstmode));
- printf ("\tsecond operand is %s\n", tahoe_operandname (mode));
- );
- switch (mode)
- {
- case regdef:
- case bytedispdef:
- case worddispdef:
- case longdispdef:
- case bytereldef:
- case wordreldef:
- case longreldef:
- /*
- * indirect call: call through pointer
- * either *d(r) as a parameter or local
- * (r) as a return value
- * *f as a global pointer
- * [are there others that we miss?,
- * e.g. arrays of pointers to functions???]
- */
- arc_add (parent, &indirectchild, (unsigned long) 0);
- length += tahoe_operandlength (instructp + length);
- continue;
- case byterel:
- case wordrel:
- case longrel:
- /*
- * regular pc relative addressing
- * check that this is the address of
- * a function.
- */
- destpc = pc + tahoe_offset (instructp + length);
- if (hist_check_address (destpc))
- {
- child = sym_lookup (&symtab, destpc);
- if (child)
- {
- DBG (CALLDEBUG,
- printf ("[findcall]\tdestpc 0x%lx",
- (unsigned long) destpc);
- printf (" child->name %s", child->name);
- printf (" child->addr 0x%lx\n",
- (unsigned long) child->addr);
- );
- if (child->addr == destpc)
- {
- /*
- * a hit
- */
- arc_add (parent, child, (unsigned long) 0);
- length += tahoe_operandlength (instructp + length);
- continue;
- }
- }
- goto botched;
- }
- /*
- * else:
- * it looked like a callf,
- * but it wasn't to anywhere.
- */
- goto botched;
- default:
- botched:
- /*
- * something funny going on.
- */
- DBG (CALLDEBUG, printf ("[findcall]\tbut it's a botch\n"));
- length = 1;
- continue;
- }
- }
- }
-}
+++ /dev/null
-/*
- * Ported by the State University of New York at Buffalo by the Distributed
- * Computer Systems Lab, Department of Computer Science, 1991.
- */
-/* Copyright (C) 2012-2018 Free Software Foundation, Inc.
-
- This file is part of GDB and BINUTILS.
-
- GDB and BINUTILS are free software; you can redistribute them and/or
- modify them under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 3, or (at
- your option) any later version.
-
- GDB and BINUTILS are distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with GDB or BINUTILS; see the file COPYING3. If not, write
- to the Free Software Foundation, 51 Franklin Street - Fifth Floor,
- Boston, MA 02110-1301, USA. */
-
-
-#ifndef tahoe_opcodeT
-#define tahoe_opcodeT int
-#endif /* no tahoe_opcodeT */
-
-struct vot_wot /* tahoe opcode table: wot to do with this */
- /* particular opcode */
-{
- char * args; /* how to compile said opcode */
- tahoe_opcodeT code; /* op-code (may be > 8 bits!) */
-};
-
-struct vot /* tahoe opcode text */
-{
- char * name; /* opcode name: lowercase string [key] */
- struct vot_wot detail; /* rest of opcode table [datum] */
-};
-
-#define vot_how args
-#define vot_code code
-#define vot_detail detail
-#define vot_name name
-
-static struct vot
-votstrs[] =
-{
-{ "halt", {"", 0x00 } },
-{ "sinf", {"", 0x05 } },
-{ "ldf", {"rl", 0x06 } },
-{ "ldd", {"rq", 0x07 } },
-{ "addb2", {"rbmb", 0x08 } },
-{ "movb", {"rbwb", 0x09 } },
-{ "addw2", {"rwmw", 0x0a } },
-{ "movw", {"rwww", 0x0b } },
-{ "addl2", {"rlml", 0x0c } },
-{ "movl", {"rlwl", 0x0d } },
-{ "bbs", {"rlvlbw", 0x0e } },
-{ "nop", {"", 0x10 } },
-{ "brb", {"bb", 0x11 } },
-{ "brw", {"bw", 0x13 } },
-{ "cosf", {"", 0x15 } },
-{ "lnf", {"rl", 0x16 } },
-{ "lnd", {"rq", 0x17 } },
-{ "addb3", {"rbrbwb", 0x18 } },
-{ "cmpb", {"rbwb", 0x19 } },
-{ "addw3", {"rwrwww", 0x1a } },
-{ "cmpw", {"rwww", 0x1b } },
-{ "addl3", {"rlrlwl", 0x1c } },
-{ "cmpl", {"rlwl", 0x1d } },
-{ "bbc", {"rlvlbw", 0x1e } },
-{ "rei", {"", 0x20 } },
-{ "bneq", {"bb", 0x21 } },
-{ "bnequ", {"bb", 0x21 } },
-{ "cvtwl", {"rwwl", 0x23 } },
-{ "stf", {"wl", 0x26 } },
-{ "std", {"wq", 0x27 } },
-{ "subb2", {"rbmb", 0x28 } },
-{ "mcomb", {"rbwb", 0x29 } },
-{ "subw2", {"rwmw", 0x2a } },
-{ "mcomw", {"rwww", 0x2b } },
-{ "subl2", {"rlml", 0x2c } },
-{ "mcoml", {"rlwl", 0x2d } },
-{ "emul", {"rlrlrlwq", 0x2e } },
-{ "aoblss", {"rlmlbw", 0x2f } },
-{ "bpt", {"", 0x30 } },
-{ "beql", {"bb", 0x31 } },
-{ "beqlu", {"bb", 0x31 } },
-{ "cvtwb", {"rwwb", 0x33 } },
-{ "logf", {"", 0x35 } },
-{ "cmpf", {"rl", 0x36 } },
-{ "cmpd", {"rq", 0x37 } },
-{ "subb3", {"rbrbwb", 0x38 } },
-{ "bitb", {"rbrb", 0x39 } },
-{ "subw3", {"rwrwww", 0x3a } },
-{ "bitw", {"rwrw", 0x3b } },
-{ "subl3", {"rlrlwl", 0x3c } },
-{ "bitl", {"rlrl", 0x3d } },
-{ "ediv", {"rlrqwlwl", 0x3e } },
-{ "aobleq", {"rlmlbw", 0x3f } },
-{ "ret", {"", 0x40 } },
-{ "bgtr", {"bb", 0x41 } },
-{ "sqrtf", {"", 0x45 } },
-{ "cmpf2", {"rl", 0x46 } },
-{ "cmpd2", {"rqrq", 0x47 } },
-{ "shll", {"rbrlwl", 0x48 } },
-{ "clrb", {"wb", 0x49 } },
-{ "shlq", {"rbrqwq", 0x4a } },
-{ "clrw", {"ww", 0x4b } },
-{ "mull2", {"rlml", 0x4c } },
-{ "clrl", {"wl", 0x4d } },
-{ "shal", {"rbrlwl", 0x4e } },
-{ "bleq", {"bb", 0x51 } },
-{ "expf", {"", 0x55 } },
-{ "tstf", {"", 0x56 } },
-{ "tstd", {"", 0x57 } },
-{ "shrl", {"rbrlwl", 0x58 } },
-{ "tstb", {"rb", 0x59 } },
-{ "shrq", {"rbrqwq", 0x5a } },
-{ "tstw", {"rw", 0x5b } },
-{ "mull3", {"rlrlwl", 0x5c } },
-{ "tstl", {"rl", 0x5d } },
-{ "shar", {"rbrlwl", 0x5e } },
-{ "bbssi", {"rlmlbw", 0x5f } },
-{ "ldpctx", {"", 0x60 } },
-{ "pushd", {"", 0x67 } },
-{ "incb", {"mb", 0x69 } },
-{ "incw", {"mw", 0x6b } },
-{ "divl2", {"rlml", 0x6c } },
-{ "incl", {"ml", 0x6d } },
-{ "cvtlb", {"rlwb", 0x6f } },
-{ "svpctx", {"", 0x70 } },
-{ "jmp", {"ab", 0x71 } },
-{ "cvlf", {"rl", 0x76 } },
-{ "cvld", {"rl", 0x77 } },
-{ "decb", {"mb", 0x79 } },
-{ "decw", {"mw", 0x7b } },
-{ "divl3", {"rlrlwl", 0x7c } },
-{ "decl", {"ml", 0x7d } },
-{ "cvtlw", {"rlww", 0x7f } },
-{ "bgeq", {"bb", 0x81 } },
-{ "movs2", {"abab", 0x82 } },
-{ "cvfl", {"wl", 0x86 } },
-{ "cvdl", {"wl", 0x87 } },
-{ "orb2", {"rbmb", 0x88 } },
-{ "cvtbl", {"rbwl", 0x89 } },
-{ "orw2", {"rwmw", 0x8a } },
-{ "bispsw", {"rw", 0x8b } },
-{ "orl2", {"rlml", 0x8c } },
-{ "adwc", {"rlml", 0x8d } },
-{ "adda", {"rlml", 0x8e } },
-{ "blss", {"bb", 0x91 } },
-{ "cmps2", {"abab", 0x92 } },
-{ "ldfd", {"rl", 0x97 } },
-{ "orb3", {"rbrbwb", 0x98 } },
-{ "cvtbw", {"rbww", 0x99 } },
-{ "orw3", {"rwrwww", 0x9a } },
-{ "bicpsw", {"rw", 0x9b } },
-{ "orl3", {"rlrlwl", 0x9c } },
-{ "sbwc", {"rlml", 0x9d } },
-{ "suba", {"rlml", 0x9e } },
-{ "bgtru", {"bb", 0xa1 } },
-{ "cvdf", {"", 0xa6 } },
-{ "andb2", {"rbmb", 0xa8 } },
-{ "movzbl", {"rbwl", 0xa9 } },
-{ "andw2", {"rwmw", 0xaa } },
-{ "loadr", {"rwal", 0xab } },
-{ "andl2", {"rlml", 0xac } },
-{ "mtpr", {"rlrl", 0xad } },
-{ "ffs", {"rlwl", 0xae } },
-{ "blequ", {"bb", 0xb1 } },
-{ "negf", {"", 0xb6 } },
-{ "negd", {"", 0xb7 } },
-{ "andb3", {"rbrbwb", 0xb8 } },
-{ "movzbw", {"rbww", 0xb9 } },
-{ "andw3", {"rwrwww", 0xba } },
-{ "storer", {"rwal", 0xbb } },
-{ "andl3", {"rlrlwl", 0xbc } },
-{ "mfpr", {"rlwl", 0xbd } },
-{ "ffc", {"rlwl", 0xbe } },
-{ "calls", {"rbab", 0xbf } },
-{ "prober", {"rbabrl", 0xc0 } },
-{ "bvc", {"bb", 0xc1 } },
-{ "movs3", {"ababrw", 0xc2 } },
-{ "movzwl", {"rwwl", 0xc3 } },
-{ "addf", {"rl", 0xc6 } },
-{ "addd", {"rq", 0xc7 } },
-{ "xorb2", {"rbmb", 0xc8 } },
-{ "movob", {"rbwb", 0xc9 } },
-{ "xorw2", {"rwmw", 0xca } },
-{ "movow", {"rwww", 0xcb } },
-{ "xorl2", {"rlml", 0xcc } },
-{ "movpsl", {"wl", 0xcd } },
-{ "kcall", {"rw", 0xcf } },
-{ "probew", {"rbabrl", 0xd0 } },
-{ "bvs", {"bb", 0xd1 } },
-{ "cmps3", {"ababrw", 0xd2 } },
-{ "subf", {"rq", 0xd6 } },
-{ "subd", {"rq", 0xd7 } },
-{ "xorb3", {"rbrbwb", 0xd8 } },
-{ "pushb", {"rb", 0xd9 } },
-{ "xorw3", {"rwrwww", 0xda } },
-{ "pushw", {"rw", 0xdb } },
-{ "xorl3", {"rlrlwl", 0xdc } },
-{ "pushl", {"rl", 0xdd } },
-{ "insque", {"abab", 0xe0 } },
-{ "bcs", {"bb", 0xe1 } },
-{ "bgequ", {"bb", 0xe1 } },
-{ "mulf", {"rq", 0xe6 } },
-{ "muld", {"rq", 0xe7 } },
-{ "mnegb", {"rbwb", 0xe8 } },
-{ "movab", {"abwl", 0xe9 } },
-{ "mnegw", {"rwww", 0xea } },
-{ "movaw", {"awwl", 0xeb } },
-{ "mnegl", {"rlwl", 0xec } },
-{ "moval", {"alwl", 0xed } },
-{ "remque", {"ab", 0xf0 } },
-{ "bcc", {"bb", 0xf1 } },
-{ "blssu", {"bb", 0xf1 } },
-{ "divf", {"rq", 0xf6 } },
-{ "divd", {"rq", 0xf7 } },
-{ "movblk", {"alalrw", 0xf8 } },
-{ "pushab", {"ab", 0xf9 } },
-{ "pushaw", {"aw", 0xfb } },
-{ "casel", {"rlrlrl", 0xfc } },
-{ "pushal", {"al", 0xfd } },
-{ "callf", {"rbab", 0xfe } },
-{ "" , "" } /* empty is end sentinel */
-
-};