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

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

1.3     ! tholo       1: /*     $OpenBSD: i386.c,v 1.2 1996/06/26 05:33:52 deraadt Exp $        */
1.1       deraadt     2: /*     $NetBSD: i386.c,v 1.5 1995/04/19 07:16:04 cgd Exp $     */
                      3:
                      4: #ifndef lint
1.3     ! tholo       5: static char rcsid[] = "$OpenBSD: i386.c,v 1.2 1996/06/26 05:33:52 deraadt Exp $";
1.1       deraadt     6: #endif /* not lint */
                      7:
                      8: #include "gprof.h"
                      9:
1.3     ! tholo      10: #define        iscall(pc)      ((*pc) == 0xE8)
        !            11:
1.1       deraadt    12: /*
                     13:  * gprof -c isn't currently supported...
                     14:  */
                     15: findcall( parentp , p_lowpc , p_highpc )
                     16:     nltype             *parentp;
                     17:     unsigned long      p_lowpc;
                     18:     unsigned long      p_highpc;
                     19: {
1.3     ! tholo      20:        unsigned char *pc;
        !            21:        long len;
        !            22:        nltype *childp;
        !            23:        unsigned long destpc;
        !            24:
        !            25:        if (textspace == 0)
        !            26:                return;
        !            27:        if (p_lowpc < s_lowpc)
        !            28:                p_lowpc = s_lowpc;
        !            29:        if (p_highpc > s_highpc)
        !            30:                p_highpc = s_highpc;
        !            31: #      ifdef DEBUG
        !            32:                if ( debug & CALLDEBUG ) {
        !            33:                        printf( "[findcall] %s: 0x%x to 0x%x\n" ,
        !            34:                                parentp -> name , p_lowpc , p_highpc );
        !            35:                }
        !            36: #      endif DEBUG
        !            37:        for (pc = textspace + p_lowpc - N_TXTADDR(xbuf) ; pc < textspace + p_highpc - N_TXTADDR(xbuf) ; pc += len) {
        !            38:                len = 1;
        !            39:                if (iscall(pc)) {
        !            40:                        destpc = *(unsigned long *)(pc + 1) + (pc - textspace + N_TXTADDR(xbuf)) + 5;
        !            41: #                      ifdef DEBUG
        !            42:                                if ( debug & CALLDEBUG ) {
        !            43:                                        printf( "[findcall]\t0x%x:calls" , pc - textspace );
        !            44:                                        printf( "\tdestpc 0x%x" , destpc );
        !            45:                                }
        !            46: #                      endif DEBUG
        !            47:                        if (destpc >= s_lowpc && destpc <= s_highpc) {
        !            48:                                childp = nllookup(destpc);
        !            49: #                              ifdef DEBUG
        !            50:                                        if ( debug & CALLDEBUG ) {
        !            51:                                                printf( " childp->name %s" , childp -> name );
        !            52:                                                printf( " childp->value 0x%x\n" ,
        !            53:                                                        childp -> value );
        !            54:                                        }
        !            55: #                              endif DEBUG
        !            56:                                if (childp != NULL && childp->value == destpc) {
        !            57:                                        addarc(parentp, childp, 0L);
        !            58:                                        len += 4;
        !            59:                                        continue;
        !            60:                                }
        !            61:                        }
        !            62: #                      ifdef DEBUG
        !            63:                                if ( debug & CALLDEBUG ) {
        !            64:                                        printf( "\tbut it's a botch\n" );
        !            65:                                }
        !            66: #                      endif DEBUG
        !            67:                }
        !            68:        }
1.1       deraadt    69: }