Fix stack walk display
This commit is contained in:
parent
4595bb48fb
commit
b8f6a2302c
2 changed files with 4 additions and 4 deletions
|
@ -1,5 +1,5 @@
|
||||||
CXX=g++
|
CXX=g++
|
||||||
CXXFLAGS=-Wall -Wextra -O2 -g -I../stack_walker -rdynamic
|
CXXFLAGS=-Wall -Wextra -O0 -g -I../stack_walker -rdynamic
|
||||||
|
|
||||||
stack_walked.bin: stack_walked.cpp
|
stack_walked.bin: stack_walked.cpp
|
||||||
$(CXX) $(CXXFLAGS) -o $@ $^ -L../stack_walker -ldl -lstack_walker
|
$(CXX) $(CXXFLAGS) -o $@ $^ -L../stack_walker -ldl -lstack_walker
|
||||||
|
|
|
@ -7,12 +7,12 @@ void fill_my_stack1(volatile int&);
|
||||||
void fill_my_stack2(volatile int&);
|
void fill_my_stack2(volatile int&);
|
||||||
|
|
||||||
void stack_filled() {
|
void stack_filled() {
|
||||||
int frame_id = 1;
|
int frame_id = 0;
|
||||||
walk_stack([&frame_id](const unwind_context_t& ctx) {
|
walk_stack([&frame_id](const unwind_context_t& ctx) {
|
||||||
Dl_info func_info;
|
Dl_info func_info;
|
||||||
int dl_rc = dladdr((void*) ctx.rip, &func_info);
|
int dl_rc = dladdr((void*) ctx.rip, &func_info);
|
||||||
printf("#%d - %s - RIP=%lx, RBP=%lx, RSP=%lx\n",
|
printf("#%d - %s — %%rip = 0x%lx, %%rbp = 0x%lx, %%rsp = 0x%lx\n",
|
||||||
frame_id,
|
++frame_id,
|
||||||
(dl_rc != 0) ? func_info.dli_sname : "[Unknown func]",
|
(dl_rc != 0) ? func_info.dli_sname : "[Unknown func]",
|
||||||
ctx.rip,
|
ctx.rip,
|
||||||
ctx.rbp,
|
ctx.rbp,
|
||||||
|
|
Loading…
Reference in a new issue