#include #include #include #include // FIXME #include using namespace std; StackDump StackDump::snapshot(uintptr_t rsp) { StackDump stack; MemoryMap memory_map; const MemoryMap::MapEntry& stack_region = memory_map[memory_map.id_of_address(rsp)]; assert(stack_region.pathname == "[stack]"); size_t stack_size = stack_region.mem_region.end - rsp; stack.stack = std::shared_ptr(new cell_t[stack_size]); cerr << "memcpy'ing " << stack_size << " bytes" << endl; memcpy(stack.stack.get(), (void*)rsp, stack_size); // FIXME way too brutal stack.offset = rsp; return stack; } StackDump::StackDump() : stack(nullptr), offset(0) {} StackDump::StackDump(const StackDump& oth) { this->operator=(oth); } StackDump& StackDump::operator=(const StackDump& oth) { stack = oth.stack; offset = oth.offset; return *this; }