Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Infrastructure for statically defined tracepoints
authorGabriel Corona <gabriel.corona@loria.fr>
Fri, 7 Nov 2014 15:17:18 +0000 (16:17 +0100)
committerGabriel Corona <gabriel.corona@loria.fr>
Tue, 18 Nov 2014 15:03:38 +0000 (16:03 +0100)
3 modes are supported on compilation:

 * normal (no SDT);

 * SDT (systemtap statically defined tracepoint);

 * UST (lttng userspace static tracepoint, compatible with systemtap
   if LTTNG_UST_HAVE_SDT_INTEGRATION).

buildtools/Cmake/DefinePackages.cmake
buildtools/Cmake/Flags.cmake
buildtools/Cmake/MakeLib.cmake
buildtools/Cmake/Option.cmake
src/mc/mc_checkpoint.c
src/mc/mc_compare.cpp
src/probes.tp [new file with mode: 0644]
src/xbt/probes.h [new file with mode: 0644]

index 638ac0b..0774625 100644 (file)
@@ -23,6 +23,7 @@ set(EXTRA_DIST
   src/msg/msg_mailbox.h
   src/msg/msg_private.h
   src/portable.h
+  src/probes.tp
   src/simdag/dax.dtd
   src/simdag/dax_dtd.c
   src/simdag/dax_dtd.h
@@ -121,6 +122,7 @@ set(EXTRA_DIST
   src/xbt/mmalloc/mmprivate.h
   src/xbt/mmalloc/mmtrace.awk
   src/xbt/mmalloc/mrealloc.c
+  src/xbt/probes.h
   src/xbt/setset_private.h
   src/xbt/win32_ucontext.c
   tools/tesh/run_context.h
@@ -1242,6 +1244,23 @@ set(generated_src_files
   src/xbt/automaton/parserPromela.tab.hacc
   )
 
+if(enable_ust)
+  set(simgrid_sources ${CMAKE_CURRENT_BINARY_DIR}/src/simgrid_ust.c ${simgrid_sources})
+  ADD_CUSTOM_COMMAND(
+    OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/src/simgrid_ust.c
+    OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/src/simgrid_ust.h
+    COMMAND lttng-gen-tp -o simgrid_ust.c -o simgrid_ust.h ${CMAKE_CURRENT_SOURCE_DIR}/src/probes.tp
+    WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/src/
+    DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/src/probes.tp
+  )
+  ADD_CUSTOM_TARGET(simgrid_ust
+    DEPENDS
+      ${CMAKE_CURRENT_BINARY_DIR}/src/simgrid_ust.c
+      ${CMAKE_CURRENT_BINARY_DIR}/src/simgrid_ust.h
+    )
+  set(generated_src_files ${CMAKE_CURRENT_BINARY_DIR}/src/simgrid_ust.c ${generated_src_files})
+endif()
+
 foreach(file ${generated_src_files})
   set_source_files_properties(${file} PROPERTIES GENERATED true)
 endforeach(file ${generated_src_files})
index 6e50110..d45e7f9 100644 (file)
@@ -50,6 +50,14 @@ else()
   set(optCFLAGS "-O0 ")
 endif()
 
+if(enable_sdt)
+  add_definitions(-DUSE_SDT)
+endif()
+
+if(enable_ust)
+  add_definitions(-DUSE_UST)
+endif()
+
 if(enable_model-checking AND enable_compile_optimizations)
   # Forget it, do not optimize the code (because it confuses the MC):
   set(optCFLAGS "-O0 ")
index f73882a..9f15a91 100644 (file)
@@ -12,6 +12,10 @@ if(enable_lib_static)
   add_library(simgrid_static STATIC ${simgrid_sources})
 endif()
 
+if(enable_ust)
+  ADD_DEPENDENCIES(simgrid simgrid_ust)
+endif()
+
 if(enable_java)
   include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/MakeJava.cmake)
 endif()
@@ -124,6 +128,12 @@ if(HAVE_BACKTRACE_IN_LIBEXECINFO)
   SET(SIMGRID_DEP "${SIMGRID_DEP} -lexecinfo")
 endif(HAVE_BACKTRACE_IN_LIBEXECINFO)
 
+# Dependencies from USR
+###################################
+if(enable_ust)
+  set(SIMGRID_DEP "${SIMGRID_DEP} -llttng-ust")
+endif()
+
 # Compute the dependencies of SMPI
 ##################################
 if(enable_smpi AND APPLE)
index eb1aae1..27463ba 100644 (file)
@@ -27,6 +27,8 @@ option(enable_maintainer_mode "Whether flex and flexml files should be rebuilt."
 option(enable_tracing "Tracing simulations for visualization." on)
 option(enable_latency_bound_tracking "" off)
 option(enable_coverage "Enable coverage." off)
+option(enable_ust "Enable userspace statuic tracepoint (lttng-ust)." off)
+option(enable_sdt "Enable statically defined tracepoint (strace/systemtap)." off)
 mark_as_advanced(enable_coverage)
 option(enable_memcheck "Enable memcheck." off)
 option(enable_memcheck_xml "Enable memcheck with xml output." off)
index 3c3d166..b21f190 100644 (file)
@@ -629,6 +629,10 @@ static void MC_get_current_fd(mc_snapshot_t snapshot){
     if (strncmp(link, "pipe:", 5) == 0 || strncmp(link, "socket:", 7) == 0)
       continue;
 
+    // This is probably a shared memory used by lttng-ust:
+    if(strncmp("/dev/shm/ust-shm-tmp-", link, 21)==0)
+      continue;
+
     // Add an entry for this FD in the snapshot:
     fd_infos_t fd = xbt_new0(s_fd_infos_t, 1);
     fd->filename = strdup(link);
index 1f7814a..0958d2d 100644 (file)
@@ -18,6 +18,8 @@
 #include "xbt/mmalloc.h"
 #include "xbt/mmalloc/mmprivate.h"
 
+#include <xbt/probes.h>
+
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_compare, mc,
                                 "Logging specific to mc_compare");
 
@@ -280,6 +282,7 @@ static int compare_global_variables(mc_object_info_t object_info,
                                 (char *) current_var->address, snapshot2, r2,
                                 bvariable_type, 0);
     if (res == 1) {
+      XBT_TRACE3(mc, global_diff, -1, -1, current_var->name);
       XBT_VERB("Global variable %s (%p) is different between snapshots",
                current_var->name, (char *) current_var->address);
       return 1;
@@ -336,6 +339,7 @@ static int compare_local_variables(int process_index,
 
       if (res == 1) {
         // TODO, fix current_varX->subprogram->name to include name if DW_TAG_inlined_subprogram
+        XBT_TRACE3(mc, local_diff, -1, -1, current_var1->name);
         XBT_VERB
             ("Local variable %s (%p - %p) in frame %s  is different between snapshots",
              current_var1->name, current_var1->address, current_var2->address,
@@ -382,6 +386,7 @@ int snapshot_compare(void *state1, void *state2)
   if (_sg_mc_hash) {
     hash_result = (s1->hash != s2->hash);
     if (hash_result) {
+      XBT_TRACE2(mc, hash_diff, num1, num2);
       XBT_VERB("(%d - %d) Different hash : 0x%" PRIx64 "--0x%" PRIx64, num1,
                num2, s1->hash, s2->hash);
 #ifndef MC_DEBUG
@@ -396,8 +401,11 @@ int snapshot_compare(void *state1, void *state2)
   unsigned int cursor;
   int pid;
   xbt_dynar_foreach(s1->enabled_processes, cursor, pid){
-    if(!xbt_dynar_member(s2->enabled_processes, &pid))
+    if(!xbt_dynar_member(s2->enabled_processes, &pid)) {
+      //XBT_TRACE3(mc, state_diff, num1, num2, "Different enabled processes");
       XBT_VERB("(%d - %d) Different enabled processes", num1, num2);
+      // return 1; ??
+    }
   }
 
   unsigned long i = 0;
@@ -424,6 +432,7 @@ int snapshot_compare(void *state1, void *state2)
       XBT_VERB("(%d - %d) Different size used in stacks : %zu - %zu", num1,
                num2, size_used1, size_used2);
 #endif
+      XBT_TRACE3(mc, state_diff, num1, num2, "Different stack size");
 
       xbt_os_walltimer_stop(timer);
       xbt_os_timer_free(timer);
@@ -455,6 +464,7 @@ int snapshot_compare(void *state1, void *state2)
     errors++;
 #else
 #ifdef MC_VERBOSE
+    XBT_TRACE3(mc, state_diff, num1, num2, "Different heap information");
     XBT_VERB("(%d - %d) Different heap information", num1, num2);
 #endif
 
@@ -492,6 +502,7 @@ int snapshot_compare(void *state1, void *state2)
     else diff_local =
         compare_local_variables(stack1->process_index, s1, s2, stack1, stack2);
     if (diff_local > 0) {
+      XBT_TRACE3(mc, state_diff, num1, num2, "Different local variables");
 #ifdef MC_DEBUG
       if (is_diff == 0) {
         xbt_os_walltimer_stop(timer);
@@ -559,6 +570,7 @@ int snapshot_compare(void *state1, void *state2)
         compare_global_variables(object_infos[k], MC_NO_PROCESS_INDEX, s1->regions[k], s2->regions[k], s1, s2);
 
     if (is_diff != 0) {
+      XBT_TRACE3(mc, state_diff, num1, num2, "Different global variables");
 #ifdef MC_DEBUG
       xbt_os_walltimer_stop(timer);
       *times[k] = xbt_os_timer_elapsed(timer);
@@ -589,6 +601,7 @@ int snapshot_compare(void *state1, void *state2)
 
   /* Compare heap */
   if (mmalloc_compare_heap(s1, s2) > 0) {
+    XBT_TRACE3(mc, state_diff, num1, num2, "Different heap");
 
 #ifdef MC_DEBUG
     xbt_os_walltimer_stop(timer);
diff --git a/src/probes.tp b/src/probes.tp
new file mode 100644 (file)
index 0000000..6ccc0aa
--- /dev/null
@@ -0,0 +1,61 @@
+TRACEPOINT_EVENT(
+  mc,
+  state_diff,
+  TP_ARGS(
+    int, state1,
+    int, state2,
+    char*, message
+  ),
+  TP_FIELDS(
+    ctf_integer(int, state1, state1)
+    ctf_integer(int, state2, state2)
+    ctf_string(message, message)
+  )
+)
+TRACEPOINT_LOGLEVEL(mc, state_diff, TRACE_INFO)
+
+TRACEPOINT_EVENT(
+  mc,
+  hash_diff,
+  TP_ARGS(
+    int, state1,
+    int, state2
+  ),
+  TP_FIELDS(
+    ctf_integer(int, state1, state1)
+    ctf_integer(int, state2, state2)
+  )
+)
+TRACEPOINT_LOGLEVEL(mc, hash_diff, TRACE_INFO)
+
+TRACEPOINT_EVENT(
+  mc,
+  global_diff,
+  TP_ARGS(
+    int, state1,
+    int, state2,
+    char*, variable
+  ),
+  TP_FIELDS(
+    ctf_integer(int, state1, state1)
+    ctf_integer(int, state2, state2)
+    ctf_string(variable, variable)
+  )
+)
+TRACEPOINT_LOGLEVEL(mc, global_diff, TRACE_INFO)
+
+TRACEPOINT_EVENT(
+  mc,
+  local_diff,
+  TP_ARGS(
+    int, state1,
+    int, state2,
+    char*, variable
+  ),
+  TP_FIELDS(
+    ctf_integer(int, state1, state1)
+    ctf_integer(int, state2, state2)
+    ctf_string(variable, variable)
+  )
+)
+TRACEPOINT_LOGLEVEL(mc, local_diff, TRACE_INFO)
diff --git a/src/xbt/probes.h b/src/xbt/probes.h
new file mode 100644 (file)
index 0000000..187e4cd
--- /dev/null
@@ -0,0 +1,52 @@
+/* Copyright (c) 2014. 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. */
+
+#ifdef USE_UST
+#  include <lttng/tracepoint.h>
+#  include "simgrid_ust.h"
+#  define XBT_TRACE0 tracepoint
+#  define XBT_TRACE1 tracepoint
+#  define XBT_TRACE2 tracepoint
+#  define XBT_TRACE3 tracepoint
+#  define XBT_TRACE4 tracepoint
+#  define XBT_TRACE5 tracepoint
+#  define XBT_TRACE6 tracepoint
+#  define XBT_TRACE7 tracepoint
+#  define XBT_TRACE8 tracepoint
+#  define XBT_TRACE9 tracepoint
+#  define XBT_TRACE10 tracepoint
+#  define XBT_TRACE11 tracepoint
+#  define XBT_TRACE12 tracepoint
+#elif USE_SDT
+#  include <sys/sdt.h>
+#  define XBT_TRACE0  DTRACE_PROBE0
+#  define XBT_TRACE1  DTRACE_PROBE1
+#  define XBT_TRACE2  DTRACE_PROBE2
+#  define XBT_TRACE3  DTRACE_PROBE3
+#  define XBT_TRACE4  DTRACE_PROBE4
+#  define XBT_TRACE5  DTRACE_PROBE5
+#  define XBT_TRACE6  DTRACE_PROBE6
+#  define XBT_TRACE7  DTRACE_PROBE7
+#  define XBT_TRACE8  DTRACE_PROBE8
+#  define XBT_TRACE9  DTRACE_PROBE9
+#  define XBT_TRACE10  DTRACE_PROBE10
+#  define XBT_TRACE11  DTRACE_PROBE11
+#  define XBT_TRACE12  DTRACE_PROBE12
+#else
+#  define XBT_TRACE0(...)
+#  define XBT_TRACE1(...)
+#  define XBT_TRACE2(...)
+#  define XBT_TRACE3(...)
+#  define XBT_TRACE4(...)
+#  define XBT_TRACE5(...)
+#  define XBT_TRACE6(...)
+#  define XBT_TRACE7(...)
+#  define XBT_TRACE8(...)
+#  define XBT_TRACE9(...)
+#  define XBT_TRACE10(...)
+#  define XBT_TRACE11(...)
+#  define XBT_TRACE12(...)
+#endif