Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
move parts of the kernel to the right subdir
[simgrid.git] / src / mc / mc_member.cpp
index c69ef51..8ce5366 100644 (file)
@@ -4,11 +4,9 @@
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
-#include <xbt/misc.h>
-
-#include "mc_object_info.h"
-#include "mc_private.h"
-#include "mc/Type.hpp"
+#include "src/mc/mc_private.h"
+#include "src/mc/Type.hpp"
+#include "src/mc/mc_dwarf.hpp"
 
 namespace simgrid {
 namespace dwarf {
@@ -18,7 +16,7 @@ namespace dwarf {
  * @param object   Process address of the struct/class
  * @param type     Type of the struct/class
  * @param member   Member description
- * @param snapshot Snapshot (or NULL)
+ * @param snapshot Snapshot (or nullptr)
  * @return Process address of the given member of the 'object' struct/class
  */
 void *resolve_member(
@@ -29,22 +27,16 @@ void *resolve_member(
   if (!member->has_offset_location())
     return ((char *) base) + member->offset();
 
-  s_mc_expression_state_t state;
-  memset(&state, 0, sizeof(s_mc_expression_state_t));
-  state.frame_base = NULL;
-  state.cursor = NULL;
+  ExpressionContext state;
+  state.frame_base = nullptr;
+  state.cursor = nullptr;
   state.address_space = address_space;
-  state.stack_size = 1;
-  state.stack[0] = (uintptr_t) base;
   state.process_index = process_index;
 
-  if (simgrid::mc::execute(
-      member->location_expression, &state))
-    xbt_die("Error evaluating DWARF expression");
-  if (state.stack_size == 0)
-    xbt_die("No value on the stack");
-  else
-    return (void *) state.stack[state.stack_size - 1];
+  ExpressionStack stack;
+  stack.push((ExpressionStack::value_type) base);
+  simgrid::dwarf::execute(member->location_expression, state, stack);
+  return (void*) stack.top();
 }
 
 }