From 2e43b2f67e50679deaceaa445c1ad48ecacd2f47 Mon Sep 17 00:00:00 2001 From: mquinson Date: Tue, 19 May 2009 12:08:48 +0000 Subject: [PATCH] Display the status of simulated processes when receiving SIGINT in simulation mode git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@6300 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- ChangeLog | 2 ++ src/gras/gras.c | 43 +++++++++++++++++++++++-------------------- src/gras/rl_stubs.c | 7 +++++-- 3 files changed, 30 insertions(+), 22 deletions(-) diff --git a/ChangeLog b/ChangeLog index 36e16cf4a6..f1ba131696 100644 --- a/ChangeLog +++ b/ChangeLog @@ -18,6 +18,8 @@ SimGrid (3.4-svn) unstable; urgency=high - added two regression tests about this in datadesc_usage * Be more verbose when propagating local exceptions This helps debugging. + * Display the status of simulated processes when receiving SIGINT in + simulation mode MSG: * Allow to control the simulation from a trace file. diff --git a/src/gras/gras.c b/src/gras/gras.c index cdd6ead232..a49174a30f 100644 --- a/src/gras/gras.c +++ b/src/gras/gras.c @@ -36,7 +36,10 @@ static void gras_sigusr_handler(int sig) { static void gras_sigint_handler(int sig) { static double lastone = 0; if (lastone == 0 || xbt_os_time() - lastone > 5) { - xbt_backtrace_display_current(); + if (gras_if_RL()) + xbt_backtrace_display_current(); + else + SIMIX_display_process_status(); fprintf(stderr, "\nBacktrace displayed because Ctrl-C was pressed. Press again (within 5 sec) to abort the process.\n"); lastone = xbt_os_time(); @@ -73,9 +76,9 @@ void gras_init(int *argc,char **argv) { xbt_getpid = gras_os_getpid; /* First initialize the XBT */ xbt_init(argc,argv); - - /* module registrations: - * - declare process specific data we need (without creating them) + + /* module registrations: + * - declare process specific data we need (without creating them) */ if (gras_running_process == 0) { /* Connect our log channels: that must be done manually under windows */ @@ -86,31 +89,31 @@ void gras_init(int *argc,char **argv) { XBT_LOG_CONNECT(gras_ddt_exchange, gras_ddt); XBT_LOG_CONNECT(gras_ddt_lexer, gras_ddt_parse); XBT_LOG_CONNECT(gras_ddt_parse, gras_ddt); - + XBT_LOG_CONNECT(gras_modules, gras); - + XBT_LOG_CONNECT(gras_msg, gras); XBT_LOG_CONNECT(gras_msg_read, gras_msg); XBT_LOG_CONNECT(gras_msg_rpc, gras_msg); - + XBT_LOG_CONNECT(gras_timer, gras); - + XBT_LOG_CONNECT(gras_trp, gras); XBT_LOG_CONNECT(gras_trp_meas, gras_trp); - + XBT_LOG_CONNECT(gras_virtu, gras); XBT_LOG_CONNECT(gras_virtu_emul, gras_virtu); XBT_LOG_CONNECT(gras_virtu_process, gras_virtu); - + gras_trp_register(); gras_msg_register(); } - + /* * Initialize the process specific stuff */ gras_process_init(); /* calls procdata_init, which creates process specific data for each module */ - + /* * Initialize the global stuff if it's not the first process created */ @@ -124,12 +127,12 @@ void gras_init(int *argc,char **argv) { signal(SIGUSR1,gras_sigusr_handler); # endif signal(SIGINT,gras_sigint_handler); -#endif +#endif } - + /* and then init amok */ amok_init(); - + /* And finally, launch the listener thread */ pd = gras_procdata_get(); msg_pd = gras_libdata_by_name("gras_msg"); @@ -158,15 +161,15 @@ const char *hexa_str(unsigned char *data, int size, int downside) { static char*buff=NULL; static int buffsize=0; int i,pos=0; - int begin,increment; - + int begin,increment; + if (buffsize<5*(size+1)) { if (buff) free(buff); buffsize=5*(size+1); buff=xbt_malloc(buffsize); } - + if (downside) { begin=size-1; @@ -175,7 +178,7 @@ const char *hexa_str(unsigned char *data, int size, int downside) { begin=0; increment=1; } - + for (i=begin; 0<=i && i126) sprintf(buff+pos,"."); @@ -191,7 +194,7 @@ const char *hexa_str(unsigned char *data, int size, int downside) { } sprintf(buff+pos,")"); while (buff[++pos]); - buff[pos]='\0'; + buff[pos]='\0'; return buff; } void hexa_print(const char*name, unsigned char *data, int size) { diff --git a/src/gras/rl_stubs.c b/src/gras/rl_stubs.c index 6123585100..16ef4d92ba 100644 --- a/src/gras/rl_stubs.c +++ b/src/gras/rl_stubs.c @@ -10,6 +10,7 @@ #include "xbt_modinter.h" #include "xbt/sysdep.h" +#include "simix/simix.h" XBT_LOG_EXTERNAL_CATEGORY(xbt); XBT_LOG_EXTERNAL_CATEGORY(xbt_sync_rl); @@ -20,7 +21,9 @@ XBT_LOG_EXTERNAL_CATEGORY(gras_trp_tcp); void xbt_context_mod_init(void) { XBT_LOG_CONNECT(xbt_sync_rl, xbt); XBT_LOG_CONNECT(gras_trp_file, gras_trp); - XBT_LOG_CONNECT(gras_trp_tcp, gras_trp); + XBT_LOG_CONNECT(gras_trp_tcp, gras_trp); } - + void xbt_context_mod_exit(void) {} + +void SIMIX_display_process_status(void) {} -- 2.20.1