From: Christian Heinrich Date: Tue, 28 Apr 2015 20:03:47 +0000 (+0200) Subject: Fixed exception tests X-Git-Tag: v3_12~732^2~31 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/e2003d622b6b961020a60265f2b03b427afaeb4b?hp=34a90997543e96d03c7a370fadabbd20abf0f37c;ds=sidebyside Fixed exception tests - 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. --- diff --git a/examples/msg/exception/exception.tesh b/examples/msg/exception/exception.tesh index 0c76151b2d..ab67769b07 100644 --- a/examples/msg/exception/exception.tesh +++ b/examples/msg/exception/exception.tesh @@ -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) diff --git a/src/simgrid/sg_config.c b/src/simgrid/sg_config.c index 2a387677ad..763192e633 100644 --- a/src/simgrid/sg_config.c +++ b/src/simgrid/sg_config.c @@ -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); diff --git a/src/xbt/ex.c b/src/xbt/ex.c index a543fb8fce..1e48d4c838 100644 --- a/src/xbt/ex.c +++ b/src/xbt/ex.c @@ -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