Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Handle DW_TAG_namespace (C++)
[simgrid.git] / src / mc / mc_dwarf.c
index c5e69dd..4927f81 100644 (file)
@@ -124,7 +124,8 @@ typedef enum mc_tag_class {
   mc_tag_type,
   mc_tag_subprogram,
   mc_tag_variable,
   mc_tag_type,
   mc_tag_subprogram,
   mc_tag_variable,
-  mc_tag_scope
+  mc_tag_scope,
+  mc_tag_namespace
 } mc_tag_class;
 
 static mc_tag_class MC_dwarg_tag_classify(int tag) {
 } mc_tag_class;
 
 static mc_tag_class MC_dwarg_tag_classify(int tag) {
@@ -166,6 +167,9 @@ static mc_tag_class MC_dwarg_tag_classify(int tag) {
     case DW_TAG_inlined_subroutine:
       return mc_tag_scope;
 
     case DW_TAG_inlined_subroutine:
       return mc_tag_scope;
 
+    case DW_TAG_namespace:
+      return mc_tag_namespace;
+
     default:
       return mc_tag_unkonwn;
 
     default:
       return mc_tag_unkonwn;
 
@@ -998,6 +1002,16 @@ static void MC_dwarf_handle_subprogram_die(mc_object_info_t info, Dwarf_Die* die
   MC_dwarf_handle_children(info, die, unit, frame, namespace);
 }
 
   MC_dwarf_handle_children(info, die, unit, frame, namespace);
 }
 
+static void mc_dwarf_handle_namespace_die(
+    mc_object_info_t info, Dwarf_Die* die, Dwarf_Die* unit, dw_frame_t frame, const char* namespace) {
+  const char* name = MC_dwarf_attr_string(die, DW_AT_name);
+  if(frame)
+    xbt_die("Unexpected namespace in a subprogram");
+  char* new_namespace = namespace == NULL ? xbt_strdup(name)
+    : bprintf("%s::%s", namespace, name);
+  MC_dwarf_handle_children(info, die, unit, frame, new_namespace);
+}
+
 static void MC_dwarf_handle_children(mc_object_info_t info, Dwarf_Die* die, Dwarf_Die* unit, dw_frame_t frame, const char* namespace) {
   Dwarf_Die child;
   int res;
 static void MC_dwarf_handle_children(mc_object_info_t info, Dwarf_Die* die, Dwarf_Die* unit, dw_frame_t frame, const char* namespace) {
   Dwarf_Die child;
   int res;
@@ -1031,6 +1045,9 @@ static void MC_dwarf_handle_die(mc_object_info_t info, Dwarf_Die* die, Dwarf_Die
       // TODO
       break;
 
       // TODO
       break;
 
+    case mc_tag_namespace:
+      mc_dwarf_handle_namespace_die(info, die, unit, frame, namespace);
+
     default:
       break;
 
     default:
       break;