Fix arm stack frame walking support:
- Adjust stack offset for Clang - Correctly fill registers for fake stack frame (soft PMC) MFC after: 1 week Sponsored by: Stormshield Differential Revision: https://reviews.freebsd.org/D7396
This commit is contained in:
parent
ead4920e1e
commit
74bd0be5e9
@ -70,7 +70,9 @@ union pmc_md_pmc {
|
||||
/* 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)
|
||||
|
||||
/*
|
||||
|
@ -42,6 +42,17 @@ __FBSDID("$FreeBSD$");
|
||||
#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 @@ pmc_save_kernel_callchain(uintptr_t *cc, int maxsamples,
|
||||
|
||||
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 @@ pmc_save_kernel_callchain(uintptr_t *cc, int maxsamples,
|
||||
*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 @@ pmc_save_user_callchain(uintptr_t *cc, int maxsamples,
|
||||
|
||||
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 @@ pmc_save_user_callchain(uintptr_t *cc, int maxsamples,
|
||||
|
||||
/* 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))
|
||||
|
Loading…
x
Reference in New Issue
Block a user