From 18d3655890d3e978b22106dc95e7b5c8b1a3a5c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9ophile=20Bastian?= Date: Thu, 5 Apr 2018 19:18:06 +0200 Subject: [PATCH] Adapt test files --- test/Makefile | 2 +- test/dump_my_stack.cpp | 15 +++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/test/Makefile b/test/Makefile index 290edf9..c0132a7 100644 --- a/test/Makefile +++ b/test/Makefile @@ -1,5 +1,5 @@ CXX=g++ -CXXFLAGS=-Wall -Wextra -O1 -g --std=c++14 +CXXFLAGS=-Wall -Wextra -O0 -g --std=c++14 CXXLIBS=-ldwarfpp -ldwarf -lelf -lc++fileno -ldwarfinterpret CXXDIRS=-I../include -L../lib diff --git a/test/dump_my_stack.cpp b/test/dump_my_stack.cpp index 2415613..7635f74 100644 --- a/test/dump_my_stack.cpp +++ b/test/dump_my_stack.cpp @@ -8,11 +8,19 @@ volatile int optim_stopper = 0; void dump_my_stack() { DwarfInterpret& dw = DwarfInterpret::acquire(); - uintptr_t pc = dw.get_current_pc(); + DwarfInterpret::UnwindContext unw_context = + DwarfInterpret::get_current_unwind_context(); + MemoryMap mmap; + while(true) { - printf(">> PC = %p <<\n", pc); + printf(">> PC = %lX ", unw_context.rip); + MemoryMap::MapEntry cur_map_entry = + mmap[mmap.id_of_address(unw_context.rip)]; + uintptr_t inelf_pc = unw_context.rip + - cur_map_entry.mem_region.begin + cur_map_entry.offset; + printf("(in ELF: %lX) <<\n", inelf_pc); fflush(stdout); - pc = dw.get_return_address(pc); + unw_context = dw.unwind_context(unw_context); } } @@ -20,7 +28,6 @@ void fill_my_stack(int stack_depth) { if(stack_depth == 0) dump_my_stack(); - optim_stopper++; fill_my_stack(stack_depth - 1); }