Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Move MC malloc introspection code in simgrid::mc
authorGabriel Corona <gabriel.corona@loria.fr>
Tue, 15 Mar 2016 12:02:11 +0000 (13:02 +0100)
committerGabriel Corona <gabriel.corona@loria.fr>
Tue, 15 Mar 2016 12:02:11 +0000 (13:02 +0100)
include/xbt/mmalloc.h
src/mc/malloc.hpp [new file with mode: 0644]
src/mc/mc_compare.cpp
src/mc/mc_diff.cpp
src/mc/mc_snapshot.h
tools/cmake/DefinePackages.cmake

index 116a6c3..af93032 100644 (file)
@@ -60,13 +60,6 @@ XBT_PUBLIC( xbt_mheap_t ) mmalloc_get_default_md(void);
 xbt_mheap_t mmalloc_set_current_heap(xbt_mheap_t new_heap);
 xbt_mheap_t mmalloc_get_current_heap(void);
 
 xbt_mheap_t mmalloc_set_current_heap(xbt_mheap_t new_heap);
 xbt_mheap_t mmalloc_get_current_heap(void);
 
-int mmalloc_compare_heap(mc_snapshot_t snapshot1, mc_snapshot_t snapshot2);
-int mmalloc_linear_compare_heap(xbt_mheap_t heap1, xbt_mheap_t heap2);
-int init_heap_information(xbt_mheap_t heap1, xbt_mheap_t heap2, xbt_dynar_t to_ignore1, xbt_dynar_t to_ignore2);
-int compare_heap_area(int process_index, const void *area1, const void* area2, mc_snapshot_t snapshot1,
-                      mc_snapshot_t snapshot2, xbt_dynar_t previous, mc_type_t type, int pointer_level);
-void reset_heap_information(void);
-
 size_t mmalloc_get_bytes_used(xbt_mheap_t);
 ssize_t mmalloc_get_busy_size(xbt_mheap_t, void *ptr);
 
 size_t mmalloc_get_bytes_used(xbt_mheap_t);
 ssize_t mmalloc_get_busy_size(xbt_mheap_t, void *ptr);
 
diff --git a/src/mc/malloc.hpp b/src/mc/malloc.hpp
new file mode 100644 (file)
index 0000000..82acd86
--- /dev/null
@@ -0,0 +1,38 @@
+/* Copyright (c) 2010-2016. The SimGrid Team.
+ * All rights reserved.                                                     */
+
+/* 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. */
+
+/* Copyright (C) 1991, 1992 Free Software Foundation, Inc.
+   This file was then part of the GNU C Library. */
+
+#ifndef SIMGRID_MC_MALLOC_HPP
+#define SIMGRID_MC_MALLOC_HPP
+
+#include <vector>
+
+#include <xbt/dynar.h>
+#include <xbt/mmalloc.h>
+
+#include "src/mc/mc_forward.hpp"
+#include "src/mc/Process.hpp"
+
+namespace simgrid {
+namespace mc {
+
+XBT_PRIVATE int mmalloc_compare_heap(Snapshot* snapshot1, Snapshot* snapshot2);
+XBT_PRIVATE int mmalloc_linear_compare_heap(xbt_mheap_t heap1, xbt_mheap_t heap2);
+XBT_PRIVATE int init_heap_information(xbt_mheap_t heap1, xbt_mheap_t heap2,
+                          std::vector<simgrid::mc::IgnoredHeapRegion>* i1,
+                          std::vector<simgrid::mc::IgnoredHeapRegion>* i2);
+XBT_PRIVATE int compare_heap_area(
+  int process_index, const void *area1, const void* area2,
+  Snapshot* snapshot1, Snapshot* snapshot2,
+  xbt_dynar_t previous, Type* type, int pointer_level);
+XBT_PRIVATE void reset_heap_information(void);
+
+}
+}
+
+#endif
index 8aaaefb..33371e4 100644 (file)
@@ -18,7 +18,7 @@
 #include "src/mc/mc_private.h"
 #include "src/mc/mc_smx.h"
 #include "src/mc/mc_dwarf.hpp"
 #include "src/mc/mc_private.h"
 #include "src/mc/mc_smx.h"
 #include "src/mc/mc_dwarf.hpp"
-
+#include "src/mc/malloc.hpp"
 #include "src/mc/Frame.hpp"
 #include "src/mc/ObjectInformation.hpp"
 #include "src/mc/Variable.hpp"
 #include "src/mc/Frame.hpp"
 #include "src/mc/ObjectInformation.hpp"
 #include "src/mc/Variable.hpp"
@@ -170,7 +170,7 @@ static int compare_areas_with_type(ComparisonState& state,
              && addr_pointed2 < mc_snapshot_get_heap_end(snapshot2)))
           return 1;
         // The pointers are both in the heap:
              && addr_pointed2 < mc_snapshot_get_heap_end(snapshot2)))
           return 1;
         // The pointers are both in the heap:
-        return compare_heap_area(process_index, addr_pointed1, addr_pointed2, snapshot1,
+        return simgrid::mc::compare_heap_area(process_index, addr_pointed1, addr_pointed2, snapshot1,
                                  snapshot2, nullptr, type->subtype, pointer_level);
       }
 
                                  snapshot2, nullptr, type->subtype, pointer_level);
       }
 
@@ -427,7 +427,7 @@ int snapshot_compare(void *state1, void *state2)
     alloca(sizeof(struct mdesc)), sizeof(struct mdesc),
     remote(process->heap_address),
     simgrid::mc::ProcessIndexMissing, simgrid::mc::ReadOptions::lazy());
     alloca(sizeof(struct mdesc)), sizeof(struct mdesc),
     remote(process->heap_address),
     simgrid::mc::ProcessIndexMissing, simgrid::mc::ReadOptions::lazy());
-  res_init = init_heap_information(heap1, heap2, &s1->to_ignore, &s2->to_ignore);
+  res_init = simgrid::mc::init_heap_information(heap1, heap2, &s1->to_ignore, &s2->to_ignore);
   if (res_init == -1) {
 #ifdef MC_DEBUG
     XBT_DEBUG("(%d - %d) Different heap information", num1, num2);
   if (res_init == -1) {
 #ifdef MC_DEBUG
     XBT_DEBUG("(%d - %d) Different heap information", num1, num2);
@@ -472,7 +472,7 @@ int snapshot_compare(void *state1, void *state2)
                num2, cursor + 1);
 #endif
 
                num2, cursor + 1);
 #endif
 
-      reset_heap_information();
+      simgrid::mc::reset_heap_information();
 
       return 1;
 #endif
 
       return 1;
 #endif
@@ -522,7 +522,7 @@ int snapshot_compare(void *state1, void *state2)
   }
 
   /* Compare heap */
   }
 
   /* Compare heap */
-  if (mmalloc_compare_heap(s1, s2) > 0) {
+  if (simgrid::mc::mmalloc_compare_heap(s1, s2) > 0) {
 
 #ifdef MC_DEBUG
     XBT_DEBUG("(%d - %d) Different heap (mmalloc_compare)", num1, num2);
 
 #ifdef MC_DEBUG
     XBT_DEBUG("(%d - %d) Different heap (mmalloc_compare)", num1, num2);
@@ -537,7 +537,7 @@ int snapshot_compare(void *state1, void *state2)
 #endif
   }
 
 #endif
   }
 
-  reset_heap_information();
+  simgrid::mc::reset_heap_information();
 
 #ifdef MC_VERBOSE
   if (errors || hash_result)
 
 #ifdef MC_VERBOSE
   if (errors || hash_result)
index e877474..6e2bb9f 100644 (file)
@@ -11,6 +11,7 @@
 #include "mc/mc.h"
 #include "xbt/mmalloc.h"
 #include "mc/datatypes.h"
 #include "mc/mc.h"
 #include "xbt/mmalloc.h"
 #include "mc/datatypes.h"
+#include "src/mc/malloc.hpp"
 #include "src/mc/mc_private.h"
 #include "src/mc/mc_snapshot.h"
 #include "src/mc/mc_dwarf.hpp"
 #include "src/mc/mc_private.h"
 #include "src/mc/mc_snapshot.h"
 #include "src/mc/mc_dwarf.hpp"
@@ -21,13 +22,9 @@ using simgrid::mc::remote;
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_diff, xbt,
                                 "Logging specific to mc_diff in mc");
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_diff, xbt,
                                 "Logging specific to mc_diff in mc");
 
-extern "C" {
-
 /*********************************** Heap comparison ***********************************/
 /***************************************************************************************/
 
 /*********************************** Heap comparison ***********************************/
 /***************************************************************************************/
 
-typedef char *type_name;
-
 struct XBT_PRIVATE s_mc_diff {
   s_xbt_mheap_t std_heap_copy;
   std::size_t heaplimit;
 struct XBT_PRIVATE s_mc_diff {
   s_xbt_mheap_t std_heap_copy;
   std::size_t heaplimit;
@@ -218,7 +215,8 @@ static int equal_fragments(struct s_mc_diff *state, int b1, int f1, int b2,
   return 0;
 }
 
   return 0;
 }
 
-}
+namespace simgrid {
+namespace mc {
 
 int init_heap_information(xbt_mheap_t heap1, xbt_mheap_t heap2,
                           std::vector<simgrid::mc::IgnoredHeapRegion>* i1,
 
 int init_heap_information(xbt_mheap_t heap1, xbt_mheap_t heap2,
                           std::vector<simgrid::mc::IgnoredHeapRegion>* i1,
@@ -275,16 +273,14 @@ int init_heap_information(xbt_mheap_t heap1, xbt_mheap_t heap2,
   memset(state->equals_to2, 0,
          state->heaplimit * MAX_FRAGMENT_PER_BLOCK * sizeof(s_heap_area_t));
   memset(state->types1, 0,
   memset(state->equals_to2, 0,
          state->heaplimit * MAX_FRAGMENT_PER_BLOCK * sizeof(s_heap_area_t));
   memset(state->types1, 0,
-         state->heaplimit * MAX_FRAGMENT_PER_BLOCK * sizeof(type_name *));
+         state->heaplimit * MAX_FRAGMENT_PER_BLOCK * sizeof(char**));
   memset(state->types2, 0,
   memset(state->types2, 0,
-         state->heaplimit * MAX_FRAGMENT_PER_BLOCK * sizeof(type_name *));
+         state->heaplimit * MAX_FRAGMENT_PER_BLOCK * sizeof(char**));
 
   return 0;
 
 }
 
 
   return 0;
 
 }
 
-extern "C" {
-
 void reset_heap_information()
 {
 
 void reset_heap_information()
 {
 
@@ -1589,3 +1585,4 @@ int mmalloc_linear_compare_heap(xbt_mheap_t heap1, xbt_mheap_t heap2)
 #endif
 
 }
 #endif
 
 }
+}
index c84a17b..e73b228 100644 (file)
@@ -275,8 +275,4 @@ void* MC_region_read_pointer(mc_mem_region_t region, const void* addr)
 
 SG_END_DECL()
 
 
 SG_END_DECL()
 
-XBT_PRIVATE int init_heap_information(xbt_mheap_t heap1, xbt_mheap_t heap2,
-                          std::vector<simgrid::mc::IgnoredHeapRegion>* i1,
-                          std::vector<simgrid::mc::IgnoredHeapRegion>* i2);
-
 #endif
 #endif
index e7f948c..79e7ee3 100644 (file)
@@ -597,6 +597,7 @@ set(MC_SRC
   src/mc/mc_mmalloc.h
   src/mc/mc_liveness.h
   src/mc/LocationList.hpp
   src/mc/mc_mmalloc.h
   src/mc/mc_liveness.h
   src/mc/LocationList.hpp
+  src/mc/malloc.hpp
   src/mc/LocationList.cpp
   src/mc/mc_liveness.cpp
   src/mc/mc_record.cpp
   src/mc/LocationList.cpp
   src/mc/mc_liveness.cpp
   src/mc/mc_record.cpp