From b8f6a2302cfd16b2bc97f102baa9a8085905901c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9ophile=20Bastian?= Date: Fri, 27 Apr 2018 17:32:49 +0200 Subject: [PATCH] Fix stack walk display --- tests/Makefile | 2 +- tests/stack_walked.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/Makefile b/tests/Makefile index a21dd07..c409edc 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -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 diff --git a/tests/stack_walked.cpp b/tests/stack_walked.cpp index 1b03903..3c0c73f 100644 --- a/tests/stack_walked.cpp +++ b/tests/stack_walked.cpp @@ -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,