Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] C++ location lists and expressions
[simgrid.git] / src / mc / mc_object_info.cpp
index 67e4d35..5222260 100644 (file)
 namespace simgrid {
 namespace mc {
 
+// Free functions
+
+static void mc_variable_free_voidp(void *t)
+{
+  delete *(simgrid::mc::Variable**)t;
+}
+
+static void mc_frame_free_voipd(void** p)
+{
+  delete *(mc_frame_t**)p;
+  *p = nullptr;
+}
+
 // Type
 
 Type::Type()
 {
   this->type = 0;
   this->id = 0;
-  this->name = std::string();
   this->byte_size = 0;
   this->element_count = 0;
-  this->members = nullptr;
   this->is_pointer_type = 0;
-  this->location = {0, 0, 0, 0};
-  this->offset = 0;
   this->subtype = nullptr;
   this->full_type = nullptr;
 }
 
-Type::~Type()
+// Type
+
+Variable::Variable()
 {
-  xbt_dynar_free(&this->members);
-  mc_dwarf_expression_clear(&this->location);
+  this->dwarf_offset = 0;
+  this->global = 0;
+  this->type = nullptr;
+  this->address = nullptr;
+  this->start_scope = 0;
+  this->object_info = nullptr;
+}
+
+// Frame
+
+Frame::Frame()
+{
+  this->tag = 0;
+  this->low_pc = nullptr;
+  this->high_pc = nullptr;
+  this->variables = xbt_dynar_new(
+    sizeof(mc_variable_t), mc_variable_free_voidp);
+  this->id = 0;
+  this->scopes = xbt_dynar_new(
+    sizeof(mc_frame_t), (void_f_pvoid_t) mc_frame_free_voipd);
+  this->abstract_origin_id = 0;
+  this->object_info = nullptr;
+}
+
+Frame::~Frame()
+{
+  xbt_dynar_free(&(this->variables));
+  xbt_dynar_free(&(this->scopes));
 }
 
 // ObjectInformations
 
-dw_frame_t ObjectInformation::find_function(const void *ip) const
+mc_frame_t ObjectInformation::find_function(const void *ip) const
 {
   xbt_dynar_t dynar = this->functions_index;
   mc_function_index_item_t base =
@@ -59,15 +96,13 @@ dw_frame_t ObjectInformation::find_function(const void *ip) const
   return nullptr;
 }
 
-dw_variable_t ObjectInformation::find_variable(const char* name) const
+mc_variable_t ObjectInformation::find_variable(const char* name) const
 {
   unsigned int cursor = 0;
-  dw_variable_t variable;
-  xbt_dynar_foreach(this->global_variables, cursor, variable){
-    if(!strcmp(name, variable->name))
+  mc_variable_t variable;
+  xbt_dynar_foreach(this->global_variables, cursor, variable)
+    if(variable->name == name)
       return variable;
-  }
-
   return nullptr;
 }