Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Make s_mc_snapshot_stack::context not a pointer
[simgrid.git] / src / mc / mc_unw.cpp
index a141f09..c408e2a 100644 (file)
@@ -22,6 +22,8 @@
 #include "mc_process.h"
 #include "mc_unw.h"
 
 #include "mc_process.h"
 #include "mc_unw.h"
 
+using simgrid::mc::remote;
+
 extern "C" {
 
 // ***** Implementation
 extern "C" {
 
 // ***** Implementation
@@ -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_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;
 }
 
   return 0;
 }
 
@@ -164,7 +164,7 @@ static int get_proc_name(unw_addr_space_t as,
               void* arg)
 {
   mc_unw_context_t context = (mc_unw_context_t) arg;
               void* arg)
 {
   mc_unw_context_t context = (mc_unw_context_t) arg;
-  dw_frame_t frame = MC_process_find_function(context->process, (void*) addr);
+  dw_frame_t frame = context->process->find_function(remote(addr));
   if (!frame)
     return - UNW_ENOINFO;
   *offp = (unw_word_t) frame->low_pc - addr;
   if (!frame)
     return - UNW_ENOINFO;
   *offp = (unw_word_t) frame->low_pc - addr;
@@ -182,14 +182,14 @@ static int get_proc_name(unw_addr_space_t as,
 
 unw_accessors_t mc_unw_accessors =
   {
 
 unw_accessors_t mc_unw_accessors =
   {
-    .find_proc_info             = &find_proc_info,
-    .put_unwind_info            = &put_unwind_info,
-    .get_dyn_info_list_addr     = &get_dyn_info_list_addr,
-    .access_mem                 = &access_mem,
-    .access_reg                 = &access_reg,
-    .access_fpreg               = &access_fpreg,
-    .resume                     = &resume,
-    .get_proc_name              = &get_proc_name
+    &find_proc_info,
+    &put_unwind_info,
+    &get_dyn_info_list_addr,
+    &access_mem,
+    &access_reg,
+    &access_fpreg,
+    &resume,
+    &get_proc_name
   };
 
 // ***** Context management
   };
 
 // ***** Context management
@@ -197,7 +197,7 @@ unw_accessors_t mc_unw_accessors =
 int mc_unw_init_context(
   mc_unw_context_t context, mc_process_t process, unw_context_t* c)
 {
 int mc_unw_init_context(
   mc_unw_context_t context, mc_process_t 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:
   context->process = process;
 
   // Take a copy of the context for our own purpose:
@@ -217,13 +217,6 @@ int mc_unw_init_context(
   return 0;
 }
 
   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)
 // ***** Cursor management
 
 int mc_unw_init_cursor(unw_cursor_t *cursor, mc_unw_context_t context)
@@ -232,8 +225,8 @@ int mc_unw_init_cursor(unw_cursor_t *cursor, mc_unw_context_t context)
     return -UNW_EUNSPEC;
   mc_address_space_t as = 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))
+  mc_process_t process = dynamic_cast<mc_process_t>(as);
+  if (process && process->is_self())
     return unw_init_local(cursor, &context->context);
 
   return unw_init_remote(cursor, context->process->unw_addr_space, context);
     return unw_init_local(cursor, &context->context);
 
   return unw_init_remote(cursor, context->process->unw_addr_space, context);