dwarfinterpret/test/dump_my_stack.cpp

41 lines
865 B
C++

#include <cstdio>
#include <DwarfInterpret.hpp>
using namespace std;
volatile int optim_stopper = 0;
void dump_my_stack() {
DwarfInterpret& dw = DwarfInterpret::acquire();
uintptr_t pc = dw.get_current_pc();
while(true) {
printf(">> PC = %p <<\n", pc);
fflush(stdout);
pc = dw.get_return_address(pc);
}
}
void fill_my_stack(int stack_depth) {
if(stack_depth == 0)
dump_my_stack();
optim_stopper++;
fill_my_stack(stack_depth - 1);
}
int main(int argc, char** argv) {
MemoryMap mmap;
cout << "Dumping memory map… (" << mmap.size() << " entries)" << endl;
for(const auto& entry: mmap) {
entry.dump(cout);
}
cout << "End memory map" << endl;
int stack_depth = 5;
if(argc >= 2)
stack_depth = atoi(argv[1]);
fill_my_stack(stack_depth);
return 0;
}