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

Annotation of src/usr.bin/gprof/sparc.c, Revision 1.1

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