Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Remove old code (mc_location_t)
[simgrid.git] / src / mc / mc_dwarf_expression.c
index 54f0d22..7aadf06 100644 (file)
@@ -43,6 +43,31 @@ int mc_dwarf_execute_expression(
         break;
       }
 
+    // Push the CFA (Call Frame Addresse):
+    case DW_OP_call_frame_cfa:
+    {
+      unw_word_t res;
+
+      int register_id =
+#if defined(UNW_TARGET_X86_64)
+          UNW_X86_64_CFA
+#elif defined(UNW_TARGET_X86)
+          UNW_X86_CFA
+#else
+          -1;
+#endif
+        ;
+      if(register_id<0)
+        xbt_die("Support for CFA not implemented for this achitecture.");
+
+      if(!state->cursor)
+        return MC_EXPRESSION_E_MISSING_STACK_CONTEXT;
+
+      unw_get_reg(state->cursor, register_id, &res);
+      error = mc_dwarf_push_value(state, res + op->number);
+      break;
+    }
+
     // Frame base:
 
     case DW_OP_fbreg:
@@ -254,6 +279,15 @@ Dwarf_Off mc_dwarf_resolve_locations(mc_location_list_t locations, unw_cursor_t*
   xbt_die("Could not resolve location");
 }
 
+/** \brief Find the frame base of a given frame
+ *
+ *  \param frame
+ *  \param unw_cursor
+ */
+void* mc_find_frame_base(dw_frame_t frame, unw_cursor_t* unw_cursor) {
+  return (void*) mc_dwarf_resolve_locations(&frame->frame_base, unw_cursor, NULL);
+}
+
 static
 void mc_dwarf_expression_clear(mc_expression_t expression) {
   free(expression->ops);
@@ -319,8 +353,10 @@ void mc_dwarf_location_list_init(mc_location_list_t list, mc_object_info_t info,
 
     void* base = info->flags & MC_OBJECT_INFO_EXECUTABLE ? 0 : MC_object_base_address(info);
     mc_dwarf_expression_init(expression, len, ops);
-    expression->lowpc = (char*) base + start;
-    expression->highpc = (char*) base + end;
+
+    // If start == 0, this is not a location list:
+    expression->lowpc = start == 0 ? NULL : (char*) base + start;
+    expression->highpc = start == 0 ? NULL : (char*) base + end;
   }
 
 }