[BACK]Return to mips64.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / gprof

Annotation of src/usr.bin/gprof/mips64.c, Revision 1.3

1.3     ! deraadt     1: /*     $OpenBSD: mips64.c,v 1.2 2006/03/25 19:06:36 espie Exp $        */
1.1       pefo        2: /*     $NetBSD: mips.c,v 1.4 1995/04/19 07:16:11 cgd Exp $     */
                      3:
                      4: /*
                      5:  * Copyright (c) 1992, 1993
                      6:  *     The Regents of the University of California.  All rights reserved.
                      7:  *
                      8:  * This software was developed by the Computer Systems Engineering group
                      9:  * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
                     10:  * contributed to Berkeley. Modified by Ralph Campbell for mips.
                     11:  *
                     12:  * Redistribution and use in source and binary forms, with or without
                     13:  * modification, are permitted provided that the following conditions
                     14:  * are met:
                     15:  * 1. Redistributions of source code must retain the above copyright
                     16:  *    notice, this list of conditions and the following disclaimer.
                     17:  * 2. Redistributions in binary form must reproduce the above copyright
                     18:  *    notice, this list of conditions and the following disclaimer in the
                     19:  *    documentation and/or other materials provided with the distribution.
                     20:  * 3. Neither the name of the University nor the names of its contributors
                     21:  *    may be used to endorse or promote products derived from this software
                     22:  *    without specific prior written permission.
                     23:  *
                     24:  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
                     25:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
                     26:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
                     27:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
                     28:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                     29:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
                     30:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     31:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                     32:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     33:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     34:  * SUCH DAMAGE.
                     35:  *
                     36:  * From: sparc.c 5.1 (Berkeley) 7/7/92
                     37:  */
                     38:
                     39: #include       "gprof.h"
                     40:
                     41:     /*
                     42:      * a namelist entry to be the child of indirect calls
                     43:      */
                     44: nltype indirectchild = {
                     45:        "(*)" ,                         /* the name */
                     46:        (unsigned long) 0 ,             /* the pc entry point */
                     47:        (unsigned long) 0 ,             /* entry point aligned to histogram */
                     48:        (double) 0.0 ,                  /* ticks in this routine */
                     49:        (double) 0.0 ,                  /* cumulative ticks in children */
                     50:        (long) 0 ,                      /* how many times called */
                     51:        (long) 0 ,                      /* times called by live arcs */
                     52:        (long) 0 ,                      /* how many calls to self */
                     53:        (double) 1.0 ,                  /* propagation fraction */
                     54:        (double) 0.0 ,                  /* self propagation time */
                     55:        (double) 0.0 ,                  /* child propagation time */
                     56:        (short) 0 ,                     /* print flag */
                     57:        (short) 0 ,                     /* flags */
                     58:        (int) 0 ,                       /* index in the graph list */
                     59:        (int) 0 ,                       /* graph call chain top-sort order */
                     60:        (int) 0 ,                       /* internal number of cycle on */
                     61:        (int) 0 ,                       /* number of live parent arcs */
                     62:        (struct nl *) &indirectchild ,  /* pointer to head of cycle */
                     63:        (struct nl *) 0 ,               /* pointer to next member of cycle */
                     64:        (arctype *) 0 ,                 /* list of caller arcs */
                     65:        (arctype *) 0                   /* list of callee arcs */
                     66: };
                     67:
                     68: void
1.2       espie      69: findcall(nltype *parentp, unsigned long p_lowpc, unsigned long p_highpc)
1.1       pefo       70: {
1.2       espie      71:        unsigned long pc;
1.1       pefo       72:        nltype *childp;
                     73:        unsigned long destpc;
                     74:        long op;
                     75:        int off;
                     76:
                     77:        if (textspace == 0)
                     78:                return;
                     79:        if (p_lowpc < s_lowpc)
                     80:                p_lowpc = s_lowpc;
                     81:        if (p_highpc > s_highpc)
                     82:                p_highpc = s_highpc;
                     83:
                     84:        for (pc = p_lowpc; pc < p_highpc; pc += 4) {
                     85:                off = pc - s_lowpc;
1.2       espie      86:                op = *(unsigned long *)&textspace[off];
1.1       pefo       87:                if ((op & 0xfc000000) == 0x0c000000) {
                     88:                        /*
                     89:                         * a jal insn -- check that this
                     90:                         * is the address of a function.
                     91:                         */
                     92:                        off = (op & 0x03ffffff) << 2;
                     93:                        destpc = (pc & 0xf0000000) | off;
                     94:                        if (destpc >= s_lowpc && destpc <= s_highpc) {
                     95:                                childp = nllookup(destpc);
                     96:                                if (childp != 0 && childp->value == destpc)
                     97:                                        addarc(parentp, childp, 0L);
                     98:                        }
                     99:                } else if ((op & 0xfc00f83f) == 0x0000f809)
                    100:                        /*
                    101:                         * A jalr -- an indirect call.
                    102:                         */
                    103:                        addarc(parentp, &indirectchild, 0L);
                    104:        }
                    105: }