MCPcopy Create free account
hub / github.com/async-profiler/async-profiler / walkFP

Method walkFP

src/stackWalker.cpp:65–112  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

63
64
65int StackWalker::walkFP(void* ucontext, const void** callchain, int max_depth) {
66 const void* pc;
67 uintptr_t fp;
68 uintptr_t sp;
69 uintptr_t bottom = (uintptr_t)&sp + MAX_WALK_SIZE;
70
71 StackFrame frame(ucontext);
72 if (ucontext == NULL) {
73 pc = callerPC();
74 fp = (uintptr_t)callerFP();
75 sp = (uintptr_t)callerSP();
76 } else {
77 pc = (const void*)frame.pc();
78 fp = frame.fp();
79 sp = frame.sp();
80 }
81
82 int depth = 0;
83
84 // Walk until the bottom of the stack or until the first Java frame
85 while (depth < max_depth) {
86 if (CodeHeap::contains(pc) && !(depth == 0 && frame.unwindAtomicStub(pc))) {
87 break;
88 }
89
90 callchain[depth++] = pc;
91
92 // Check if the next frame is below on the current stack
93 if (fp < sp || fp >= sp + MAX_FRAME_SIZE || fp >= bottom) {
94 break;
95 }
96
97 // Frame pointer must be word aligned
98 if (!aligned(fp)) {
99 break;
100 }
101
102 pc = stripPointer(SafeAccess::load((void**)fp + FRAME_PC_SLOT));
103 if (inDeadZone(pc)) {
104 break;
105 }
106
107 sp = fp + (FRAME_PC_SLOT + 1) * sizeof(void*);
108 fp = *(uintptr_t*)fp;
109 }
110
111 return depth;
112}
113
114int StackWalker::walkDwarf(void* ucontext, const void** callchain, int max_depth) {
115 const void* pc;

Callers

nothing calls this directly

Calls 4

alignedFunction · 0.85
stripPointerFunction · 0.85
inDeadZoneFunction · 0.85
unwindAtomicStubMethod · 0.45

Tested by

no test coverage detected