Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Add location field in struct/class-members
[simgrid.git] / src / mc / mc_checkpoint.c
index 765bfdd..e72bef3 100644 (file)
@@ -302,9 +302,6 @@ static xbt_dynar_t MC_unwind_stack_frames(void *stack_context) {
 
   unw_cursor_t c;
 
-  dw_frame_t test = MC_find_function_by_ip(&MC_unwind_stack_frames);
-  xbt_assert(test);
-
   int ret;
   for(ret = unw_init_local(&c, (unw_context_t *)stack_context); ret >= 0; ret = unw_step(&c)){
     mc_stack_frame_t stack_frame = xbt_new(s_mc_stack_frame_t, 1);
@@ -478,6 +475,22 @@ void* mc_translate_address(uintptr_t addr, mc_snapshot_t snapshot) {
   return (void*) addr;
 }
 
+uintptr_t mc_untranslate_address(void* addr, mc_snapshot_t snapshot) {
+  if(!snapshot) {
+    return (uintptr_t) addr;
+  }
+
+  for(size_t i=0; i!=NB_REGIONS; ++i) {
+    mc_mem_region_t region = snapshot->regions[i];
+    if(addr>=region->data && addr<=region->data+region->size) {
+      size_t offset = (size_t) ((char*) addr - (char*) region->data);
+      return (uintptr_t) (region->start_addr + offset);
+    }
+  }
+
+  return (uintptr_t) addr;
+}
+
 mc_snapshot_t SIMIX_pre_mc_snapshot(smx_simcall_t simcall){
   return MC_take_snapshot(1);
 }