summaryrefslogtreecommitdiffstats
path: root/sys/libkern
diff options
context:
space:
mode:
authormarcel <marcel@FreeBSD.org>2004-08-27 19:42:35 +0000
committermarcel <marcel@FreeBSD.org>2004-08-27 19:42:35 +0000
commit01fd13440d6b5d1349e7ce6b74fe9fcf29d1ff58 (patch)
treeb2e0d69a2a9be2870443aacf8a3cee8a31cfc5d2 /sys/libkern
parent9b969b5afb1e6125fee738dea17fef52f88a0c7b (diff)
downloadFreeBSD-src-01fd13440d6b5d1349e7ce6b74fe9fcf29d1ff58.zip
FreeBSD-src-01fd13440d6b5d1349e7ce6b74fe9fcf29d1ff58.tar.gz
Move the kernel-specific logic to adjust frompc from MI to MD. For
these two reasons: 1. On ia64 a function pointer does not hold the address of the first instruction of a functions implementation. It holds the address of a function descriptor. Hence the user(), btrap(), eintr() and bintr() prototypes are wrong for getting the actual code address. 2. The logic forces interrupt, trap and exception entry points to be layed-out contiguously. This can not be achieved on ia64 and is generally just bad programming. The MCOUNT_FROMPC_USER macro is used to set the frompc argument to some kernel address which represents any frompc that falls outside the kernel text range. The macro can expand to ~0U to bail out in that case. The MCOUNT_FROMPC_INTR macro is used to set the frompc argument to some kernel address to represent a call to a trap or interrupt handler. This to avoid that the trap or interrupt handler appear to be called from everywhere in the call graph. The macro can expand to ~0U to prevent adjusting frompc. Note that the argument is selfpc, not frompc. This commit defines the macros on all architectures equivalently to the original code in sys/libkern/mcount.c. People can take it from here... Compile-tested on: alpha, amd64, i386, ia64 and sparc64 Boot-tested on: i386
Diffstat (limited to 'sys/libkern')
-rw-r--r--sys/libkern/mcount.c54
1 files changed, 21 insertions, 33 deletions
diff --git a/sys/libkern/mcount.c b/sys/libkern/mcount.c
index 1a9f8ac..d967fe8 100644
--- a/sys/libkern/mcount.c
+++ b/sys/libkern/mcount.c
@@ -39,10 +39,6 @@ __FBSDID("$FreeBSD$");
#include <vm/vm.h>
#include <vm/vm_param.h>
#include <vm/pmap.h>
-void bintr(void);
-void btrap(void);
-void eintr(void);
-void user(void);
#endif
/*
@@ -61,16 +57,16 @@ void user(void);
* perform this optimization.
*/
_MCOUNT_DECL(frompc, selfpc) /* _mcount; may be static, inline, etc */
- register uintfptr_t frompc, selfpc;
+ uintfptr_t frompc, selfpc;
{
#ifdef GUPROF
int delta;
#endif
- register fptrdiff_t frompci;
- register u_short *frompcindex;
- register struct tostruct *top, *prevtop;
- register struct gmonparam *p;
- register long toindex;
+ fptrdiff_t frompci;
+ u_short *frompcindex;
+ struct tostruct *top, *prevtop;
+ struct gmonparam *p;
+ long toindex;
#ifdef _KERNEL
MCOUNT_DECL(s)
#endif
@@ -89,24 +85,20 @@ _MCOUNT_DECL(frompc, selfpc) /* _mcount; may be static, inline, etc */
#else
p->state = GMON_PROF_BUSY;
#endif
- frompci = frompc - p->lowpc;
#ifdef _KERNEL
/*
- * When we are called from an exception handler, frompci may be
- * for a user address. Convert such frompci's to the index of
- * user() to merge all user counts.
+ * When we are called from an exception handler, frompc may be
+ * a user address. Convert such frompc's to some representation
+ * in kernel address space.
*/
- if (frompci >= p->textsize) {
- if (frompci + p->lowpc
- >= (uintfptr_t)(VM_MAXUSER_ADDRESS))
- goto done;
- frompci = (uintfptr_t)user - p->lowpc;
- if (frompci >= p->textsize)
- goto done;
- }
+ frompc = MCOUNT_FROMPC_USER(frompc);
#endif
+ frompci = frompc - p->lowpc;
+ if (frompci >= p->textsize)
+ goto done;
+
#ifdef GUPROF
if (p->state == GMON_PROF_HIRES) {
/*
@@ -141,18 +133,14 @@ _MCOUNT_DECL(frompc, selfpc) /* _mcount; may be static, inline, etc */
/*
* When we are called from an exception handler, frompc is faked
* to be for where the exception occurred. We've just solidified
- * the count for there. Now convert frompci to the index of btrap()
- * for trap handlers and bintr() for interrupt handlers to make
- * exceptions appear in the call graph as calls from btrap() and
- * bintr() instead of calls from all over.
+ * the count for there. Now convert frompci to an index that
+ * represents the kind of exception so that interruptions appear
+ * in the call graph as calls from those index instead of calls
+ * from all over.
*/
- if ((uintfptr_t)selfpc >= (uintfptr_t)btrap
- && (uintfptr_t)selfpc < (uintfptr_t)eintr) {
- if ((uintfptr_t)selfpc >= (uintfptr_t)bintr)
- frompci = (uintfptr_t)bintr - p->lowpc;
- else
- frompci = (uintfptr_t)btrap - p->lowpc;
- }
+ frompc = MCOUNT_FROMPC_INTR(selfpc);
+ if ((frompc - p->lowpc) < p->textsize)
+ frompci = frompc - p->lowpc;
#endif
/*
OpenPOWER on IntegriCloud