profile.h (89ec08eebf8c37adf22419feb9fcf64e50f04091) | profile.h (590ccf8c744af5629becdbadd2f57d73b33866e9) |
---|---|
1/*- 2 * Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University. 3 * All rights reserved. 4 * 5 * Author: Chris G. Demetriou 6 * 7 * Permission to use, copy, modify and distribute this software and 8 * its documentation is hereby granted, provided that both the copyright --- 18 unchanged lines hidden (view full) --- 27 * from: NetBSD: profile.h,v 1.9 1997/04/06 08:47:37 cgd Exp 28 * from: FreeBSD: src/sys/alpha/include/profile.h,v 1.4 1999/12/29 29 * $FreeBSD$ 30 */ 31 32#ifndef _MACHINE_PROFILE_H_ 33#define _MACHINE_PROFILE_H_ 34 | 1/*- 2 * Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University. 3 * All rights reserved. 4 * 5 * Author: Chris G. Demetriou 6 * 7 * Permission to use, copy, modify and distribute this software and 8 * its documentation is hereby granted, provided that both the copyright --- 18 unchanged lines hidden (view full) --- 27 * from: NetBSD: profile.h,v 1.9 1997/04/06 08:47:37 cgd Exp 28 * from: FreeBSD: src/sys/alpha/include/profile.h,v 1.4 1999/12/29 29 * $FreeBSD$ 30 */ 31 32#ifndef _MACHINE_PROFILE_H_ 33#define _MACHINE_PROFILE_H_ 34 |
35#define _MCOUNT_DECL void mcount | 35#define _MCOUNT_DECL void __mcount |
36 37#define FUNCTION_ALIGNMENT 16 38 39typedef u_int fptrdiff_t; 40 | 36 37#define FUNCTION_ALIGNMENT 16 38 39typedef u_int fptrdiff_t; 40 |
41/* 42 * The mcount trampoline macro, expanded in libc/gmon/mcount.c 43 * 44 * For PowerPC SVR4 ABI profiling, the compiler will insert 45 * a data declaration and code sequence at the start of a routine of the form 46 * 47 * .function_mc: .data 48 * .align 2 49 * .long 0 50 * .text 51 * 52 * function: mflr %r0 53 * addis %r11,%r0, .function_mc@ha 54 * stw %r0,4(%r1) 55 * addi %r0,%r11, .function_mc@l 56 * bl _mcount 57 * 58 * The link register is saved in the LR save word in the caller's 59 * stack frame, r0 is set up to point to the allocated longword, 60 * and control is transferred to _mcount. 61 * 62 * On return from _mcount, the routine should function as it would 63 * with no profiling so _mcount must restore register state to that upon 64 * entry. Any routine called by the _mcount trampoline will save 65 * callee-save registers, so _mcount must make sure it saves volatile 66 * registers that may have state after it returns i.e. parameter registers. 67 * 68 * The FreeBSD libc mcount routine ignores the r0 longword pointer, but 69 * instead requires as parameters the current PC and called PC. The current 70 * PC is obtained from the link register, as a result of "bl _mcount" in 71 * the stub, while the caller's PC is obtained from the LR save word. 72 * 73 * On return from libc mcount, the return is done indirectly with the 74 * ctr register rather than the link register, to allow the link register 75 * to be restored to what it was on entry to the profiled routine. 76 */ 77 78#ifdef PIC 79#define _PLT "@plt" 80#else 81#define _PLT 82#endif 83 |
|
41#define MCOUNT \ | 84#define MCOUNT \ |
42void \ 43_mcount() \ 44{ \ 45} | 85__asm(" .globl _mcount \n" \ 86" .type _mcount,@function \n" \ 87"_mcount: \n" \ 88" stwu %r1,-64(%r1) /* alloca for reg save space */ \n" \ 89" stw %r3,16(%r1) /* save parameter registers, */ \n" \ 90" stw %r4,20(%r1) /* r3-10 */ \n" \ 91" stw %r5,24(%r1) \n" \ 92" stw %r6,28(%r1) \n" \ 93" stw %r7,32(%r1) \n" \ 94" stw %r8,36(%r1) \n" \ 95" stw %r9,40(%r1) \n" \ 96" stw %r10,44(%r1) \n" \ 97" \n" \ 98" mflr %r4 /* link register is 'selfpc' */ \n" \ 99" stw %r4,48(%r1) /* save since bl will scrub */ \n" \ 100" lwz %r3,68(%r1) /* get 'frompc' from LR-save */ \n" \ 101" bl __mcount" _PLT " /* __mcount(frompc, selfpc)*/ \n" \ 102" lwz %r3,68(%r1) \n" \ 103" mtlr %r3 /* restore caller's lr */ \n" \ 104" lwz %r4,48(%r1) \n" \ 105" mtctr %r4 /* set up ctr for call back */ \n" \ 106" /* note that blr is not used!*/ \n" \ 107" lwz %r3,16(%r1) /* restore r3-10 parameters */ \n" \ 108" lwz %r4,20(%r1) \n" \ 109" lwz %r5,24(%r1) \n" \ 110" lwz %r6,28(%r1) \n" \ 111" lwz %r7,32(%r1) \n" \ 112" lwz %r8,36(%r1) \n" \ 113" lwz %r9,40(%r1) \n" \ 114" lwz %r10,44(%r1) \n" \ 115" addi %r1,%r1,64 /* blow away alloca save area */ \n" \ 116" bctr /* return with indirect call */ \n" \ 117"_mcount_end: \n" \ 118" .size _mcount,_mcount_end-_mcount"); |
46 | 119 |
120 |
|
47#ifdef _KERNEL | 121#ifdef _KERNEL |
48#define MCOUNT_ENTER(s) 49#define MCOUNT_EXIT(s) 50#define MCOUNT_DECL(s) | 122#define MCOUNT_ENTER(s) s = intr_disable(); 123#define MCOUNT_EXIT(s) intr_restore(s); 124#define MCOUNT_DECL(s) register_t s |
51 52void bintr(void); 53void btrap(void); 54void eintr(void); 55void user(void); 56 57#define MCOUNT_FROMPC_USER(pc) \ 58 ((pc < (uintfptr_t)VM_MAXUSER_ADDRESS) ? (uintfptr_t)user : pc) --- 14 unchanged lines hidden --- | 125 126void bintr(void); 127void btrap(void); 128void eintr(void); 129void user(void); 130 131#define MCOUNT_FROMPC_USER(pc) \ 132 ((pc < (uintfptr_t)VM_MAXUSER_ADDRESS) ? (uintfptr_t)user : pc) --- 14 unchanged lines hidden --- |