From: mquinson Date: Mon, 18 May 2009 08:32:55 +0000 (+0000) Subject: Be more verbose when propagating local exceptions X-Git-Tag: SVN~1350 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/f2442b3b9a0742e33338ca189a6f662639548aa2 Be more verbose when propagating local exceptions git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@6287 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- diff --git a/ChangeLog b/ChangeLog index 3d62e0a84c..3ab6e6a509 100644 --- a/ChangeLog +++ b/ChangeLog @@ -13,6 +13,8 @@ SimGrid (3.4-svn) unstable; urgency=high version from 0 to 1 (if we have external users, we have to get clean on that point too ;) - added two regression tests about this in datadesc_usage + * Be more verbose when propagating local exceptions + This helps debugging. MSG: * Allow to control the simulation from a trace file. diff --git a/examples/gras/rpc/rpc.c b/examples/gras/rpc/rpc.c index f40a4cf5d7..b43db35c63 100644 --- a/examples/gras/rpc/rpc.c +++ b/examples/gras/rpc/rpc.c @@ -27,8 +27,8 @@ int server (int argc,char *argv[]); int forwarder (int argc,char *argv[]); int client (int argc,char *argv[]); -#define exception_raising() \ - THROW0(unknown_error,42,"Some error we will catch on client side") +#define exception_msg "Error for the client" +#define exception_raising() THROW0(unknown_error,42,exception_msg) static void exception_catching(void) { int gotit = 0,i; @@ -44,11 +44,10 @@ static void exception_catching(void) { if (!gotit) { THROW0(unknown_error,0,"Didn't got the remote exception!"); } - xbt_assert2(e.category == unknown_error, "Got wrong category: %d (instead of %d)", + xbt_assert2(e.category == unknown_error, "Got wrong category: %d (instead of %d)", e.category,unknown_error); xbt_assert1(e.value == 42, "Got wrong value: %d (!=42)", e.value); - xbt_assert1(!strncmp(e.msg,"Some error we will catch on client side", - strlen("Some error we will catch on client side")), + xbt_assert1(!strncmp(e.msg,exception_msg, strlen(exception_msg)), "Got wrong message: %s", e.msg); xbt_ex_free(e); } @@ -75,19 +74,19 @@ int client(int argc,char *argv[]) { /* 1. Init the GRAS's infrastructure */ gras_init(&argc, argv); - + /* 2. Get the server's address. The command line override defaults when specified */ if (argc == 5) { host=argv[1]; port=atoi(argv[2]); - } + } INFO2("Launch client (server on %s:%d)",host,port); exception_catching(); - + /* 3. Wait for the server & forwarder startup */ gras_os_sleep(2); - + /* 4. Create a socket to speak to the server */ TRY { exception_catching(); @@ -96,10 +95,10 @@ int client(int argc,char *argv[]) { } CATCH(e) { RETHROW0("Unable to connect to the server: %s"); } - INFO2("Connected to %s:%d.",host,port); + INFO2("Connected to %s:%d.",host,port); - /* 5. Register the messages. + /* 5. Register the messages. See, it doesn't have to be done completely at the beginning, but only before use */ exception_catching(); @@ -122,7 +121,7 @@ int client(int argc,char *argv[]) { /* 8. Keep the user informed of what's going on, again */ INFO4("The answer to PING(%d) on %s:%d is PONG(%d)", - ping, + ping, gras_socket_peer_name(toserver),gras_socket_peer_port(toserver), pong); @@ -131,13 +130,12 @@ int client(int argc,char *argv[]) { TRY { gras_msg_rpccall(toserver, 6000.0, "raise exception", NULL, NULL); } CATCH(e) { - gotit = 1; - xbt_assert2(e.category == unknown_error, - "Got wrong category: %d (instead of %d)", + gotit = 1; + xbt_assert2(e.category == unknown_error, + "Got wrong category: %d (instead of %d)", e.category,unknown_error); xbt_assert1(e.value == 42, "Got wrong value: %d (!=42)", e.value); - xbt_assert1(!strncmp(e.msg,"Some error we will catch on client side", - strlen("Some error we will catch on client side")), + xbt_assert1(!strncmp(e.msg,exception_msg,strlen(exception_msg)), "Got wrong message: %s", e.msg); INFO0("Got the expected exception when calling the exception raising RPC"); xbt_ex_free(e); @@ -151,7 +149,7 @@ int client(int argc,char *argv[]) { /* doxygen_ignore */ for (i=0; i<5; i++) { - + INFO1("Call the exception raising RPC (i=%d)",i); TRY { gras_msg_rpccall(toserver, 6000.0, "raise exception", NULL, NULL); @@ -164,7 +162,7 @@ int client(int argc,char *argv[]) { } } /* doxygen_resume */ - + /* 9. Call a RPC which raises an exception (to test that exception propagation works) */ for (i=0;i<5;i++) { INFO1("Call the exception raising RPC on the forwarder (i=%d)",i); @@ -175,13 +173,12 @@ int client(int argc,char *argv[]) { } if (!gotit) { THROW0(unknown_error,0,"Didn't got the remote exception!"); - } + } xbt_assert1(e.value == 42, "Got wrong value: %d (!=42)", e.value); - xbt_assert1(!strncmp(e.msg,"Some error we will catch on client side", - strlen("Some error we will catch on client side")), + xbt_assert1(!strncmp(e.msg,exception_msg,strlen(exception_msg)), "Got wrong message: %s", e.msg); - xbt_assert2(e.category == unknown_error, - "Got wrong category: %d (instead of %d)", + xbt_assert2(e.category == unknown_error, + "Got wrong category: %d (instead of %d)", e.category,unknown_error); INFO0("Got the expected exception when calling the exception raising RPC"); xbt_ex_free(e); @@ -292,23 +289,23 @@ static int server_cb_raise_ex(gras_msg_cb_ctx_t ctx, static int server_cb_ping(gras_msg_cb_ctx_t ctx, void *payload_data) { - + /* 1. Get the payload into the msg variable, and retrieve who called us */ int msg=*(int*)payload_data; gras_socket_t expeditor = gras_msg_cb_ctx_from(ctx); - + /* 2. Log which client connected */ INFO3("Got message PING(%d) from %s:%d", - msg, + msg, gras_socket_peer_name(expeditor), gras_socket_peer_port(expeditor)); - + /* 4. Change the value of the msg variable */ msg = 4321; /* 5. Return as result */ gras_msg_rpcreturn(6000,ctx,&msg); INFO0("Answered with PONG(4321)"); - + /* 6. Cleanups, if any */ /* 7. Tell GRAS that we consummed this message */ @@ -321,12 +318,12 @@ int server (int argc,char *argv[]) { server_data_t sdata; int port = 4000; - + /* 1. Init the GRAS infrastructure */ gras_init(&argc,argv); /* 2. Get the port I should listen on from the command line, if specified */ - if (argc == 2) + if (argc == 2) port=atoi(argv[1]); sdata=gras_userdata_new(s_server_data_t); @@ -346,11 +343,11 @@ int server (int argc,char *argv[]) { INFO1("Listening on port %d", gras_socket_my_port(mysock)); /* 5. Wait for the ping incomming messages */ - - /** \bug if the server is gone before the forwarder tries to connect, + + /** \bug if the server is gone before the forwarder tries to connect, it dies awfully with the following message. The problem stands somewhere at the interface between the gras_socket_t and the msg mess. There is thus - no way for me to dive into this before this interface is rewritten + no way for me to dive into this before this interface is rewritten ==15875== Invalid read of size 4 ==15875== at 0x408B805: find_port (transport_plugin_sg.c:68) ==15875== by 0x408BD64: gras_trp_sg_socket_client (transport_plugin_sg.c:115) @@ -372,16 +369,16 @@ int server (int argc,char *argv[]) { ==15875== by 0x42AA549: clone (clone.S:119) */ while (!sdata->done) { - gras_msg_handle(600.0); + gras_msg_handle(600.0); exception_catching(); } - + /* 8. Free the allocated resources, and shut GRAS down */ free(sdata); gras_socket_close(mysock); INFO0("Done."); gras_exit(); - + return 0; } /* end_of_server */ diff --git a/examples/gras/rpc/test_rl b/examples/gras/rpc/test_rl index 5acea95284..35ea317464 100755 --- a/examples/gras/rpc/test_rl +++ b/examples/gras/rpc/test_rl @@ -3,6 +3,17 @@ > Listening on port 4002 > Got message PING(1234) from 127.0.0.1:0 > Answered with PONG(4321) +> Propagate local exception ('Error for the client') from 'raise exception' RPC cb back to 127.0.0.1:0 +> Propagate local exception ('Error for the client') from 'raise exception' RPC cb back to 127.0.0.1:0 +> Propagate local exception ('Error for the client') from 'raise exception' RPC cb back to 127.0.0.1:0 +> Propagate local exception ('Error for the client') from 'raise exception' RPC cb back to 127.0.0.1:0 +> Propagate local exception ('Error for the client') from 'raise exception' RPC cb back to 127.0.0.1:0 +> Propagate local exception ('Error for the client') from 'raise exception' RPC cb back to 127.0.0.1:0 +> Propagate local exception ('Error for the client') from 'raise exception' RPC cb back to 127.0.0.1:4003 +> Propagate local exception ('Error for the client') from 'raise exception' RPC cb back to 127.0.0.1:4003 +> Propagate local exception ('Error for the client') from 'raise exception' RPC cb back to 127.0.0.1:4003 +> Propagate local exception ('Error for the client') from 'raise exception' RPC cb back to 127.0.0.1:4003 +> Propagate local exception ('Error for the client') from 'raise exception' RPC cb back to 127.0.0.1:4003 > Asked to die by 127.0.0.1:0 > Done. > Exiting GRAS @@ -10,10 +21,15 @@ & $SG_TEST_EXENV ./rpc_forwarder$EXEEXT 4003 127.0.0.1 4002 --log=root.fmt:%m%n $@ > Launch forwarder (port=4003) > Forward a request +> Propagate remote exception ('Error for the client') from 'forward exception' RPC cb back to 127.0.0.1:0 > Forward a request +> Propagate remote exception ('Error for the client') from 'forward exception' RPC cb back to 127.0.0.1:0 > Forward a request +> Propagate remote exception ('Error for the client') from 'forward exception' RPC cb back to 127.0.0.1:0 > Forward a request +> Propagate remote exception ('Error for the client') from 'forward exception' RPC cb back to 127.0.0.1:0 > Forward a request +> Propagate remote exception ('Error for the client') from 'forward exception' RPC cb back to 127.0.0.1:0 > Asked to die by 127.0.0.1:0 > Done. > Exiting GRAS diff --git a/examples/gras/rpc/test_sg_32 b/examples/gras/rpc/test_sg_32 index 6f4b8f8c94..0ed5f172a4 100755 --- a/examples/gras/rpc/test_sg_32 +++ b/examples/gras/rpc/test_sg_32 @@ -15,27 +15,43 @@ $ $SG_TEST_EXENV ./rpc_simulator$EXEEXT ${srcdir:=.}/../../msg/small_platform.xm > [Tremblay:server:(1)] [Rpc/INFO] Answered with PONG(4321) > [Fafard:client:(3)] [Rpc/INFO] The answer to PING(1234) on Tremblay:4000 is PONG(4321) > [Fafard:client:(3)] [Rpc/INFO] Call the exception raising RPC +> [Tremblay:server:(1)] [gras_msg/INFO] Propagate local exception ('Error for the client') from 'raise exception' RPC cb back to Fafard:0 > [Fafard:client:(3)] [Rpc/INFO] Got the expected exception when calling the exception raising RPC > [Fafard:client:(3)] [Rpc/INFO] Called the exception raising RPC > [Fafard:client:(3)] [Rpc/INFO] Call the exception raising RPC (i=0) +> [Tremblay:server:(1)] [gras_msg/INFO] Propagate local exception ('Error for the client') from 'raise exception' RPC cb back to Fafard:0 > [Fafard:client:(3)] [Rpc/INFO] Call the exception raising RPC (i=1) +> [Tremblay:server:(1)] [gras_msg/INFO] Propagate local exception ('Error for the client') from 'raise exception' RPC cb back to Fafard:0 > [Fafard:client:(3)] [Rpc/INFO] Call the exception raising RPC (i=2) +> [Tremblay:server:(1)] [gras_msg/INFO] Propagate local exception ('Error for the client') from 'raise exception' RPC cb back to Fafard:0 > [Fafard:client:(3)] [Rpc/INFO] Call the exception raising RPC (i=3) +> [Tremblay:server:(1)] [gras_msg/INFO] Propagate local exception ('Error for the client') from 'raise exception' RPC cb back to Fafard:0 > [Fafard:client:(3)] [Rpc/INFO] Call the exception raising RPC (i=4) +> [Tremblay:server:(1)] [gras_msg/INFO] Propagate local exception ('Error for the client') from 'raise exception' RPC cb back to Fafard:0 > [Fafard:client:(3)] [Rpc/INFO] Call the exception raising RPC on the forwarder (i=0) > [Ginette:forwarder:(2)] [Rpc/INFO] Forward a request +> [Tremblay:server:(1)] [gras_msg/INFO] Propagate local exception ('Error for the client') from 'raise exception' RPC cb back to Ginette:4000 +> [Ginette:forwarder:(2)] [gras_msg/INFO] Propagate remote exception ('Error for the client') from 'forward exception' RPC cb back to Fafard:0 > [Fafard:client:(3)] [Rpc/INFO] Got the expected exception when calling the exception raising RPC > [Fafard:client:(3)] [Rpc/INFO] Call the exception raising RPC on the forwarder (i=1) > [Ginette:forwarder:(2)] [Rpc/INFO] Forward a request +> [Tremblay:server:(1)] [gras_msg/INFO] Propagate local exception ('Error for the client') from 'raise exception' RPC cb back to Ginette:4000 +> [Ginette:forwarder:(2)] [gras_msg/INFO] Propagate remote exception ('Error for the client') from 'forward exception' RPC cb back to Fafard:0 > [Fafard:client:(3)] [Rpc/INFO] Got the expected exception when calling the exception raising RPC > [Fafard:client:(3)] [Rpc/INFO] Call the exception raising RPC on the forwarder (i=2) > [Ginette:forwarder:(2)] [Rpc/INFO] Forward a request +> [Tremblay:server:(1)] [gras_msg/INFO] Propagate local exception ('Error for the client') from 'raise exception' RPC cb back to Ginette:4000 +> [Ginette:forwarder:(2)] [gras_msg/INFO] Propagate remote exception ('Error for the client') from 'forward exception' RPC cb back to Fafard:0 > [Fafard:client:(3)] [Rpc/INFO] Got the expected exception when calling the exception raising RPC > [Fafard:client:(3)] [Rpc/INFO] Call the exception raising RPC on the forwarder (i=3) > [Ginette:forwarder:(2)] [Rpc/INFO] Forward a request +> [Tremblay:server:(1)] [gras_msg/INFO] Propagate local exception ('Error for the client') from 'raise exception' RPC cb back to Ginette:4000 +> [Ginette:forwarder:(2)] [gras_msg/INFO] Propagate remote exception ('Error for the client') from 'forward exception' RPC cb back to Fafard:0 > [Fafard:client:(3)] [Rpc/INFO] Got the expected exception when calling the exception raising RPC > [Fafard:client:(3)] [Rpc/INFO] Call the exception raising RPC on the forwarder (i=4) > [Ginette:forwarder:(2)] [Rpc/INFO] Forward a request +> [Tremblay:server:(1)] [gras_msg/INFO] Propagate local exception ('Error for the client') from 'raise exception' RPC cb back to Ginette:4000 +> [Ginette:forwarder:(2)] [gras_msg/INFO] Propagate remote exception ('Error for the client') from 'forward exception' RPC cb back to Fafard:0 > [Fafard:client:(3)] [Rpc/INFO] Got the expected exception when calling the exception raising RPC > [Fafard:client:(3)] [Rpc/INFO] Ask Ginette:4000 to die > [Fafard:client:(3)] [Rpc/INFO] Ask Tremblay:4000 to die diff --git a/src/gras/Msg/gras_msg_exchange.c b/src/gras/Msg/gras_msg_exchange.c index 89bd7d74c2..ebc637b3cf 100644 --- a/src/gras/Msg/gras_msg_exchange.c +++ b/src/gras/Msg/gras_msg_exchange.c @@ -423,7 +423,7 @@ gras_msg_handle(double timeOut) { msg.type->name, gras_socket_peer_name(msg.expe), gras_socket_peer_port(msg.expe)); - if (XBT_LOG_ISENABLED(gras_msg,xbt_log_priority_info)) + if (XBT_LOG_ISENABLED(gras_msg,xbt_log_priority_verbose)) xbt_ex_display(&e); gras_msg_send_ext(msg.expe, e_gras_msg_kind_rpcerror, msg.ID, msg.type, &e);