Fix stack walk display

This commit is contained in:
Théophile Bastian 2018-04-27 17:32:49 +02:00
parent 4595bb48fb
commit b8f6a2302c
2 changed files with 4 additions and 4 deletions

View file

@ -1,5 +1,5 @@
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
$(CXX) $(CXXFLAGS) -o $@ $^ -L../stack_walker -ldl -lstack_walker

View file

@ -7,12 +7,12 @@ void fill_my_stack1(volatile int&);
void fill_my_stack2(volatile int&);
void stack_filled() {
int frame_id = 1;
int frame_id = 0;
walk_stack([&frame_id](const unwind_context_t& ctx) {
Dl_info func_info;
int dl_rc = dladdr((void*) ctx.rip, &func_info);
printf("#%d - %s - RIP=%lx, RBP=%lx, RSP=%lx\n",
frame_id,
printf("#%d - %s — %%rip = 0x%lx, %%rbp = 0x%lx, %%rsp = 0x%lx\n",
++frame_id,
(dl_rc != 0) ? func_info.dli_sname : "[Unknown func]",
ctx.rip,
ctx.rbp,