Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fixed exception tests
authorChristian Heinrich <christian.heinrich@livando.com>
Tue, 28 Apr 2015 20:03:47 +0000 (22:03 +0200)
committerChristian Heinrich <christian.heinrich@livando.com>
Tue, 28 Apr 2015 20:06:27 +0000 (22:06 +0200)
- New configuration option "exception/cutpath" introduced. This makes
  it possible to remove the path to files in backtraces as used for exceptions.

- .tesh files adjusted to reflect this change.

examples/msg/exception/exception.tesh
src/simgrid/sg_config.c
src/xbt/ex.c

index 0c76151..ab67769 100644 (file)
@@ -3,7 +3,7 @@
 p Testing the remote exception raising feature
 
 ! output sort
-$ $SG_TEST_EXENV exception/exception ${srcdir:=.}/../platforms/platform.xml ${srcdir:=.}/exception/deployment_exception.xml  "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
+$ $SG_TEST_EXENV exception/exception ${srcdir:=.}/../platforms/platform.xml ${srcdir:=.}/exception/deployment_exception.xml  "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" "--cfg=exception/cutpath:1"
 > [  0.000000] (1:terrorist@Jacquelin) Let's create a victim.
 > [  0.000000] (2:victim@Jacquelin) Let's work.
 > [  0.000000] (1:terrorist@Jacquelin) Going to sleep for 1 second
@@ -19,14 +19,13 @@ $ $SG_TEST_EXENV exception/exception ${srcdir:=.}/../platforms/platform.xml ${sr
 > ** SimGrid: UNCAUGHT EXCEPTION received on exception/exception(2): category: action canceled; value: 0
 > ** Canceled
 > ** Thrown by () on process 0
+> [  0.000000] (0:@) Configuration change: Set 'exception/cutpath' to '1'
 > [  3.000000] (2:victim@Jacquelin) Canceled
-> 
-> **   In SIMIX_execution_finish() at /home/alegrand/Work/SimGrid/simgrid-git/src/simix/smx_host.c:557
-> **   In SIMIX_post_host_execute() at /home/alegrand/Work/SimGrid/simgrid-git/src/simix/smx_host.c:604
-> **   In SIMIX_simcall_exit() at /home/alegrand/Work/SimGrid/simgrid-git/src/simix/popping.c:39
-> **   In SIMIX_run() at /home/alegrand/Work/SimGrid/simgrid-git/src/simix/smx_global.c:410
-> **   In MSG_main() at /home/alegrand/Work/SimGrid/simgrid-git/src/msg/msg_global.c:129
-> **   In main() at /home/alegrand/Work/SimGrid/simgrid-git/examples/msg/exception/exception.c:156
+>
+> **   In SIMIX_execution_finish() at smx_host.c
+> **   In SIMIX_run() at smx_global.c
+> **   In MSG_main() at msg_global.c
+> **   In main() at exception.c
 > [  3.000000] (2:victim@Jacquelin) (end of the second exception) ----8<------------------------
 > [  3.000000] (2:victim@Jacquelin) Let's sleep for 10 seconds.
 > [  6.000000] (1:terrorist@Jacquelin) Send a third exception (cancellation)
index 2a38767..763192e 100644 (file)
@@ -956,6 +956,11 @@ void sg_config_init(int *argc, char **argv)
                      xbt_cfgelm_string, 0, 1, &_sg_cfg_cb__coll_reduce, NULL);
 #endif // HAVE_SMPI
 
+    xbt_cfg_register(&_sg_cfg_set, "exception/cutpath",
+                     "\"yes\" or \"no\". \"yes\" will cut all path information from call traces, used e.g. in exceptions.",
+                     xbt_cfgelm_boolean, 1, 1, NULL, NULL);
+    xbt_cfg_setdefault_boolean(_sg_cfg_set, "exception/cutpath", "no");
+
     xbt_cfg_register(&_sg_cfg_set, "clean_atexit",
                      "\"yes\" or \"no\". \"yes\" enables all the cleanups of SimGrid (XBT,SIMIX,MSG) to be registered with atexit. \"no\" may be useful if your code segfaults when calling the exit function.",
                      xbt_cfgelm_boolean, 1, 1, _sg_cfg_cb_clean_atexit, NULL);
index a543fb8..1e48d4c 100644 (file)
@@ -52,6 +52,8 @@
 #include "xbt_modinter.h"       /* backtrace initialization headers */
 
 #include "xbt/ex_interface.h"
+#include "simgrid/sg_config.h"  /* Configuration mechanism of SimGrid */
+
 
 #undef HAVE_BACKTRACE
 #if defined(HAVE_EXECINFO_H) && defined(HAVE_POPEN) && defined(ADDR2LINE)
@@ -155,8 +157,27 @@ void xbt_ex_display(xbt_ex_t * e)
     int i;
 
     fprintf(stderr, "\n");
-    for (i = 0; i < e->used; i++)
-      fprintf(stderr, "%s\n", e->bt_strings[i]);
+    for (i = 0; i < e->used; i++) {
+      if (sg_cfg_get_boolean("exception/cutpath")) {
+        char* p = e->bt_strings[i];
+        xbt_str_rtrim(p, ":0123456789");
+        char* filename = strrchr(p, '/')+1;
+        char* end_of_message  = strrchr(p, ' ');
+
+        int length = strlen(p)-strlen(end_of_message);
+        char* dest = malloc(length);
+
+        memcpy(dest, &p[0], length);
+        dest[length] = 0;
+
+        fprintf(stderr, "%s %s\n", dest, filename);
+
+        free(dest);
+      }
+      else {
+        fprintf(stderr, "%s\n", e->bt_strings[i]);
+      }
+    }
 
   } else
 #endif