Skip to content

Commit 397f8c2

Browse files
apanginr1viollet
authored andcommitted
#819: Extend AArch64 stack walking fix to cstack=dwarf
1 parent 8bd6d4c commit 397f8c2

File tree

7 files changed

+9
-8
lines changed

7 files changed

+9
-8
lines changed

ddprof-lib/src/main/cpp/stackFrame.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class StackFrame {
7575
uintptr_t &sp, uintptr_t &fp);
7676
bool unwindCompiled(NMethod *nm, uintptr_t &pc, uintptr_t &sp, uintptr_t &fp);
7777

78-
void adjustCompiled(NMethod *nm, const void *pc, uintptr_t &sp);
78+
void adjustSP(const void *entry, const void *pc, uintptr_t &sp);
7979

8080
bool skipFaultInstruction();
8181

ddprof-lib/src/main/cpp/stackFrame_aarch64.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,8 @@ bool StackFrame::unwindCompiled(NMethod *nm, uintptr_t &pc, uintptr_t &sp,
136136
return true;
137137
}
138138

139-
void StackFrame::adjustCompiled(NMethod *nm, const void *pc, uintptr_t &sp) {
139+
void StackFrame::adjustSP(const void *entry, const void *pc, uintptr_t &sp) {
140140
instruction_t *ip = (instruction_t *)pc;
141-
instruction_t *entry = (instruction_t *)nm->entry();
142141
if (ip > entry && (ip[-1] == 0xa9bf27ff ||
143142
(ip[-1] == 0xd63f0100 && ip[-2] == 0xa9bf27ff))) {
144143
// When calling a leaf native from Java, JVM puts a dummy frame link onto

ddprof-lib/src/main/cpp/stackFrame_arm.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ bool StackFrame::unwindCompiled(NMethod *nm, uintptr_t &pc, uintptr_t &sp,
108108
return true;
109109
}
110110

111-
void StackFrame::adjustCompiled(NMethod *nm, const void *pc, uintptr_t &sp) {
111+
void StackFrame::adjustSP(const void *entry, const void *pc, uintptr_t &sp) {
112112
// Not needed
113113
}
114114

ddprof-lib/src/main/cpp/stackFrame_i386.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ bool StackFrame::unwindCompiled(NMethod *nm, uintptr_t &pc, uintptr_t &sp,
115115
return false;
116116
}
117117

118-
void StackFrame::adjustCompiled(NMethod *nm, const void *pc, uintptr_t &sp) {
118+
void StackFrame::adjustSP(const void *entry, const void *pc, uintptr_t &sp) {
119119
// Not needed
120120
}
121121

ddprof-lib/src/main/cpp/stackFrame_ppc64.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ bool StackFrame::unwindCompiled(NMethod *nm, uintptr_t &pc, uintptr_t &sp,
143143
return true;
144144
}
145145

146-
void StackFrame::adjustCompiled(NMethod *nm, const void *pc, uintptr_t &sp) {
146+
void StackFrame::adjustSP(const void *entry, const void *pc, uintptr_t &sp) {
147147
// Not needed
148148
}
149149

ddprof-lib/src/main/cpp/stackFrame_x64.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ bool StackFrame::unwindCompiled(NMethod *nm, uintptr_t &pc, uintptr_t &sp,
141141
return false;
142142
}
143143

144-
void StackFrame::adjustCompiled(NMethod *nm, const void *pc, uintptr_t &sp) {
144+
void StackFrame::adjustSP(const void *entry, const void *pc, uintptr_t &sp) {
145145
// Not needed
146146
}
147147

ddprof-lib/src/main/cpp/stackWalker.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,8 @@ int StackWalker::walkDwarf(void *ucontext, const void **callchain,
155155
break;
156156
}
157157
if (CodeHeap::contains(pc)) {
158+
const void* page_start = (const void*)((uintptr_t)pc & ~0xfffUL);
159+
frame.adjustSP(page_start, pc, sp);
158160
java_ctx->set(pc, sp, fp);
159161
break;
160162
}
@@ -302,7 +304,7 @@ int StackWalker::walkVM(void *ucontext, ASGCT_CallFrame *frames, int max_depth,
302304

303305
// Handle situations when sp is temporarily changed in the compiled
304306
// code
305-
frame.adjustCompiled(nm, pc, sp);
307+
frame.adjustSP(nm->entry(), pc, sp);
306308

307309
sp += nm->frameSize() * sizeof(void *);
308310
fp = ((uintptr_t *)sp)[-FRAME_PC_SLOT - 1];

0 commit comments

Comments
 (0)