X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/fe73287da00d0f46b2e2b7b9f95a35cdeda00417..e6ca184e99d50d0ee8fe405a83ee5277e2ecfce6:/src/mc/mc_unw.cpp diff --git a/src/mc/mc_unw.cpp b/src/mc/mc_unw.cpp index aa6eaea1fe..ab43771ab2 100644 --- a/src/mc/mc_unw.cpp +++ b/src/mc/mc_unw.cpp @@ -18,9 +18,11 @@ #include -#include "mc_object_info.h" -#include "mc_process.h" -#include "mc_unw.h" +#include "src/mc/Process.hpp" +#include "src/mc/mc_unw.h" +#include "src/mc/Frame.hpp" + +using simgrid::mc::remote; extern "C" { @@ -72,7 +74,7 @@ static int get_dyn_info_list_addr(unw_addr_space_t as, /** Read from the target address space memory (libunwind method) * - * Delegates to the `mc_process_t`. + * Delegates to the `simgrid::mc::Process*`. */ static int access_mem(unw_addr_space_t as, unw_word_t addr, unw_word_t *valp, @@ -81,9 +83,7 @@ static int access_mem(unw_addr_space_t as, mc_unw_context_t context = (mc_unw_context_t) arg; if (write) return - UNW_EREADONLYREG; - MC_address_space_read(context->address_space, - MC_ADDRESS_SPACE_READ_FLAGS_NONE, valp, (void*) addr, sizeof(unw_word_t), MC_PROCESS_INDEX_ANY); - // We don't handle failure gracefully. + context->address_space->read_bytes(valp, sizeof(unw_word_t), remote(addr)); return 0; } @@ -109,10 +109,10 @@ static void* get_reg(unw_context_t* context, unw_regnum_t regnum) case UNW_X86_64_R14: return &mcontext->gregs[REG_R14]; case UNW_X86_64_R15: return &mcontext->gregs[REG_R15]; case UNW_X86_64_RIP: return &mcontext->gregs[REG_RIP]; - default: return NULL; + default: return nullptr; } #else - return NULL; + return nullptr; #endif } @@ -164,12 +164,12 @@ static int get_proc_name(unw_addr_space_t as, void* arg) { mc_unw_context_t context = (mc_unw_context_t) arg; - dw_frame_t frame = MC_process_find_function(context->process, (void*) addr); + simgrid::mc::Frame* frame = context->process->find_function(remote(addr)); if (!frame) return - UNW_ENOINFO; - *offp = (unw_word_t) frame->low_pc - addr; + *offp = (unw_word_t) frame->range.begin() - addr; - strncpy(bufp, frame->name, buf_len); + strncpy(bufp, frame->name.c_str(), buf_len); if (bufp[buf_len - 1]) { bufp[buf_len - 1] = 0; return -UNW_ENOMEM; @@ -195,9 +195,9 @@ unw_accessors_t mc_unw_accessors = // ***** Context management int mc_unw_init_context( - mc_unw_context_t context, mc_process_t process, unw_context_t* c) + mc_unw_context_t context, simgrid::mc::Process* process, unw_context_t* c) { - context->address_space = (mc_address_space_t) process; + context->address_space = process; context->process = process; // Take a copy of the context for our own purpose: @@ -217,25 +217,12 @@ int mc_unw_init_context( return 0; } -int mc_unw_destroy_context(mc_unw_context_t context) -{ - context->address_space = NULL; - context->process = NULL; - return 0; -} - // ***** Cursor management int mc_unw_init_cursor(unw_cursor_t *cursor, mc_unw_context_t context) { if (!context->process || !context->address_space) return -UNW_EUNSPEC; - mc_address_space_t as = context->address_space; - - // Use local unwinding for current process: - if (MC_is_process(as) && MC_process_is_self((mc_process_t) as)) - return unw_init_local(cursor, &context->context); - return unw_init_remote(cursor, context->process->unw_addr_space, context); }