1*54775Storek /* 2*54775Storek * Copyright (c) 1992 Regents of the University of California. 3*54775Storek * All rights reserved. 4*54775Storek * 5*54775Storek * This software was developed by the Computer Systems Engineering group 6*54775Storek * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and 7*54775Storek * contributed to Berkeley. 8*54775Storek * 9*54775Storek * %sccs.include.redist.c% 10*54775Storek */ 11*54775Storek 12*54775Storek #ifndef lint 13*54775Storek static char sccsid[] = "@(#)sparc.c 5.1 (Berkeley) 07/07/92"; 14*54775Storek #endif /* not lint */ 15*54775Storek 16*54775Storek #include "gprof.h" 17*54775Storek 18*54775Storek /* 19*54775Storek * a namelist entry to be the child of indirect calls 20*54775Storek */ 21*54775Storek nltype indirectchild = { 22*54775Storek "(*)" , /* the name */ 23*54775Storek (unsigned long) 0 , /* the pc entry point */ 24*54775Storek (unsigned long) 0 , /* entry point aligned to histogram */ 25*54775Storek (double) 0.0 , /* ticks in this routine */ 26*54775Storek (double) 0.0 , /* cumulative ticks in children */ 27*54775Storek (long) 0 , /* how many times called */ 28*54775Storek (long) 0 , /* times called by live arcs */ 29*54775Storek (long) 0 , /* how many calls to self */ 30*54775Storek (double) 1.0 , /* propagation fraction */ 31*54775Storek (double) 0.0 , /* self propagation time */ 32*54775Storek (double) 0.0 , /* child propagation time */ 33*54775Storek (short) 0 , /* print flag */ 34*54775Storek (short) 0 , /* flags */ 35*54775Storek (int) 0 , /* index in the graph list */ 36*54775Storek (int) 0 , /* graph call chain top-sort order */ 37*54775Storek (int) 0 , /* internal number of cycle on */ 38*54775Storek (int) 0 , /* number of live parent arcs */ 39*54775Storek (struct nl *) &indirectchild , /* pointer to head of cycle */ 40*54775Storek (struct nl *) 0 , /* pointer to next member of cycle */ 41*54775Storek (arctype *) 0 , /* list of caller arcs */ 42*54775Storek (arctype *) 0 /* list of callee arcs */ 43*54775Storek }; 44*54775Storek 45*54775Storek findcall(parentp, p_lowpc, p_highpc) 46*54775Storek nltype *parentp; 47*54775Storek unsigned long p_lowpc; 48*54775Storek unsigned long p_highpc; 49*54775Storek { 50*54775Storek register u_long pc; 51*54775Storek nltype *childp; 52*54775Storek unsigned long destpc; 53*54775Storek register long op; 54*54775Storek register int off; 55*54775Storek 56*54775Storek if (textspace == 0) 57*54775Storek return; 58*54775Storek if (p_lowpc < s_lowpc) 59*54775Storek p_lowpc = s_lowpc; 60*54775Storek if (p_highpc > s_highpc) 61*54775Storek p_highpc = s_highpc; 62*54775Storek 63*54775Storek for (pc = p_lowpc; pc < p_highpc; pc += 4) { 64*54775Storek off = pc - s_lowpc; 65*54775Storek op = *(u_long *)&textspace[off]; 66*54775Storek if ((op & 0xc0000000) == 0x40000000) { 67*54775Storek /* 68*54775Storek * a pc relative call insn -- check that this 69*54775Storek * is the address of a function. 70*54775Storek */ 71*54775Storek off = (op & 0x3fffffff) << 2; 72*54775Storek destpc = pc + off; 73*54775Storek if (destpc >= s_lowpc && destpc <= s_highpc) { 74*54775Storek childp = nllookup(destpc); 75*54775Storek if (childp != 0 && childp->value == destpc) 76*54775Storek addarc(parentp, childp, 0L); 77*54775Storek } 78*54775Storek } else if ((op & 0xfff80000) == 0x9fc00000) 79*54775Storek /* 80*54775Storek * A jmpl with rd = 15 (%o7) -- an indirect call. 81*54775Storek */ 82*54775Storek addarc(parentp, &indirectchild, 0L); 83*54775Storek } 84*54775Storek } 85