Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F142566697
D7396.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D7396.diff
View Options
Index: head/sys/arm/include/pmc_mdep.h
===================================================================
--- head/sys/arm/include/pmc_mdep.h
+++ head/sys/arm/include/pmc_mdep.h
@@ -70,7 +70,9 @@
/* Build a fake kernel trapframe from current instruction pointer. */
#define PMC_FAKE_TRAPFRAME(TF) \
do { \
+ (TF)->tf_spsr = PSR_SVC32_MODE; \
__asm __volatile("mov %0, pc" : "=r" ((TF)->tf_pc)); \
+ __asm __volatile("mov %0, r11" : "=r" ((TF)->tf_r11)); \
} while (0)
/*
Index: head/sys/dev/hwpmc/hwpmc_arm.c
===================================================================
--- head/sys/dev/hwpmc/hwpmc_arm.c
+++ head/sys/dev/hwpmc/hwpmc_arm.c
@@ -42,6 +42,17 @@
#include <vm/vm_param.h>
#include <vm/pmap.h>
+/* XXX: Userland code compiled with gcc will need an heuristic
+ * to be correctly detected.
+ */
+#ifdef __clang__
+#define PC_OFF 1
+#define FP_OFF 0
+#else
+#define PC_OFF -1
+#define FP_OFF -3
+#endif
+
struct pmc_mdep *
pmc_md_initialize()
{
@@ -100,7 +111,7 @@
for (count = 1; count < maxsamples; count++) {
/* Use saved lr as pc. */
- r = fp - sizeof(uintptr_t);
+ r = fp + PC_OFF * sizeof(uintptr_t);
if (!PMC_IN_KERNEL_STACK(r, stackstart, stackend))
break;
pc = *(uintptr_t *)r;
@@ -110,7 +121,7 @@
*cc++ = pc;
/* Switch to next frame up */
- r = fp - 3 * sizeof(uintptr_t);
+ r = fp + FP_OFF * sizeof(uintptr_t);
if (!PMC_IN_KERNEL_STACK(r, stackstart, stackend))
break;
fp = *(uintptr_t *)r;
@@ -147,7 +158,7 @@
for (count = 1; count < maxsamples; count++) {
/* Use saved lr as pc. */
- r = fp - sizeof(uintptr_t);
+ r = fp + PC_OFF * sizeof(uintptr_t);
if (copyin((void *)r, &pc, sizeof(pc)) != 0)
break;
if (!PMC_IN_USERSPACE(pc))
@@ -157,7 +168,7 @@
/* Switch to next frame up */
oldfp = fp;
- r = fp - 3 * sizeof(uintptr_t);
+ r = fp + FP_OFF * sizeof(uintptr_t);
if (copyin((void *)r, &fp, sizeof(fp)) != 0)
break;
if (fp < oldfp || !PMC_IN_USERSPACE(fp))
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Jan 22, 2:18 AM (11 h, 23 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
27826866
Default Alt Text
D7396.diff (1 KB)
Attached To
Mode
D7396: HWPMC: Fix clang stack frame parsing
Attached
Detach File
Event Timeline
Log In to Comment