From: Philippe Waroquiers Date: Fri, 30 Mar 2012 20:25:26 +0000 (+0000) Subject: Further fix 297078 : implement conversion between vki and gdb real time sig nr. X-Git-Tag: svn/VALGRIND_3_8_0~382 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=72933b25a0780c00c653066d7a66cdb9e30bf422;p=thirdparty%2Fvalgrind.git Further fix 297078 : implement conversion between vki and gdb real time sig nr. * gdbserver_tests/nlpasssigalrm modify test so as to test also a real time signal * coregrind/m_gdbserver/signals.c - implement translation between gdb real time signal numbers and vki real time signal numbers - ensure non-convertible signals are giving an error git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12471 --- diff --git a/coregrind/m_gdbserver/signals.c b/coregrind/m_gdbserver/signals.c index 07b0c248ab..737dcb376a 100644 --- a/coregrind/m_gdbserver/signals.c +++ b/coregrind/m_gdbserver/signals.c @@ -466,6 +466,22 @@ enum target_signal target_signal_from_host (int hostsig) return TARGET_SIGNAL_INFO; #endif +#if defined (VKI_SIGRTMIN) + if (hostsig >= VKI_SIGRTMIN && hostsig < VKI_SIGRTMAX) { + /* This block of TARGET_SIGNAL_REALTIME value is in order. */ + if (33 <= hostsig && hostsig <= 63) + return (enum target_signal) + (hostsig - 33 + (int) TARGET_SIGNAL_REALTIME_33); + else if (hostsig == 32) + return TARGET_SIGNAL_REALTIME_32; + else if (64 <= hostsig && hostsig <= 127) + return (enum target_signal) + (hostsig - 64 + (int) TARGET_SIGNAL_REALTIME_64); + } +#endif + + error ("Valgrind GDBSERVER bug: (target_signal_from_host):" + " unrecognized vki signal %d\n", hostsig); return TARGET_SIGNAL_UNKNOWN; } @@ -476,7 +492,7 @@ enum target_signal target_signal_from_host (int hostsig) static int do_target_signal_to_host (enum target_signal oursig, - int *oursig_ok) + int *oursig_ok) { *oursig_ok = 1; switch (oursig) { @@ -700,6 +716,32 @@ int do_target_signal_to_host (enum target_signal oursig, #endif default: + { +#if defined (VKI_SIGRTMIN) + int retsig = 0; + + if (oursig >= TARGET_SIGNAL_REALTIME_33 + && oursig <= TARGET_SIGNAL_REALTIME_63) { + /* This block of signals is continuous, and + TARGET_SIGNAL_REALTIME_33 is 33 by definition. */ + retsig = (int) oursig - (int) TARGET_SIGNAL_REALTIME_33 + 33; + } else if (oursig == TARGET_SIGNAL_REALTIME_32) { + /* TARGET_SIGNAL_REALTIME_32 isn't contiguous with + TARGET_SIGNAL_REALTIME_33. It is 32 by definition. */ + retsig = 32; + } else if (oursig >= TARGET_SIGNAL_REALTIME_64 + && oursig <= TARGET_SIGNAL_REALTIME_127) { + /* This block of signals is continuous, and + TARGET_SIGNAL_REALTIME_64 is 64 by definition. */ + retsig = (int) oursig - (int) TARGET_SIGNAL_REALTIME_64 + 64; + } + + if (retsig >= VKI_SIGRTMIN && retsig < VKI_SIGRTMAX) + return retsig; + } +#endif + error ("Valgrind GDBSERVER bug: (do_target_signal_to_host):" + " unrecognized target signal %d\n", oursig); *oursig_ok = 0; return 0; } diff --git a/gdbserver_tests/nlpasssigalrm.stderr.exp b/gdbserver_tests/nlpasssigalrm.stderr.exp index fb23a97309..24f08d5e4f 100644 --- a/gdbserver_tests/nlpasssigalrm.stderr.exp +++ b/gdbserver_tests/nlpasssigalrm.stderr.exp @@ -6,4 +6,5 @@ Nulgrind, the minimal Valgrind tool starting ... ok: 1st SIGALRM received ok: 2nd SIGALRM received +ok: SIGRTMIN received diff --git a/gdbserver_tests/nlpasssigalrm.stdinB.gdb b/gdbserver_tests/nlpasssigalrm.stdinB.gdb index a8f14c794b..0a52d30dc5 100644 --- a/gdbserver_tests/nlpasssigalrm.stdinB.gdb +++ b/gdbserver_tests/nlpasssigalrm.stdinB.gdb @@ -2,8 +2,10 @@ target remote | ./vgdb --wait=60 --vgdb-prefix=./vgdb-prefix-nlpasssigalrm echo vgdb launched process attached\n monitor v.set vgdb-error 999999 -break passsigalrm.c:43 -break passsigalrm.c:44 +# break on breakme++: +break passsigalrm.c:48 +# break on the next line: +break passsigalrm.c:50 # # # ensure SIGALRM can be passed directly to the process, without @@ -16,9 +18,12 @@ continue # Tell the 2nd can be given directly handle SIGALRM nostop noprint pass continue -# Here, we expect to stop on the breakme +# Here, we expect to have stop on the breakme++ p breakme continue p breakme +# now continue till the signal SIGRTMIN is encountered +continue +# and continue to deliver it continue quit diff --git a/gdbserver_tests/nlpasssigalrm.stdoutB.exp b/gdbserver_tests/nlpasssigalrm.stdoutB.exp index 98eac299a7..64651c25d4 100644 --- a/gdbserver_tests/nlpasssigalrm.stdoutB.exp +++ b/gdbserver_tests/nlpasssigalrm.stdoutB.exp @@ -1,5 +1,5 @@ -Breakpoint 1 at 0x........: file passsigalrm.c, line 43. -Breakpoint 2 at 0x........: file passsigalrm.c, line 44. +Breakpoint 1 at 0x........: file passsigalrm.c, line 48. +Breakpoint 2 at 0x........: file passsigalrm.c, line 50. Signal Stop Print Pass to program Description SIGALRM Yes Yes Yes Alarm clock Continuing. @@ -8,11 +8,14 @@ Program received signal SIGALRM, Alarm clock. Signal Stop Print Pass to program Description SIGALRM No No Yes Alarm clock Continuing. -Breakpoint 1, main (argc=1, argv=0x........) at passsigalrm.c:43 -43 breakme++; +Breakpoint 1, main (argc=1, argv=0x........) at passsigalrm.c:48 +48 breakme++; $1 = 0 Continuing. -Breakpoint 2, main (argc=1, argv=0x........) at passsigalrm.c:44 -44 return 0; +Breakpoint 2, main (argc=1, argv=0x........) at passsigalrm.c:50 +50 sa.sa_handler = sigrtmin_handler; $2 = 1 Continuing. +Program received signal SIG34, Real-time event 34. +0x........ in syscall ... +Continuing. diff --git a/gdbserver_tests/passsigalrm.c b/gdbserver_tests/passsigalrm.c index 6493a85f77..f7b5bc290b 100644 --- a/gdbserver_tests/passsigalrm.c +++ b/gdbserver_tests/passsigalrm.c @@ -8,6 +8,11 @@ static void sigalrm_handler(int signr) { sigalrm_received++; } +static int sigrtmin_received = 0; +static void sigrtmin_handler(int signr) +{ + sigrtmin_received++; +} static int breakme = 0; @@ -41,5 +46,19 @@ int main (int argc, char *argv[]) system("../tests/true"); breakme++; + + sa.sa_handler = sigrtmin_handler; + sigemptyset(&sa.sa_mask); + sa.sa_flags = 0; + + if (sigaction (SIGRTMIN, &sa, NULL) != 0) + perror("sigaction"); + if (kill(getpid(), SIGRTMIN) != 0) + perror("kill sigrtmin"); + if (sigrtmin_received == 1) + fprintf (stderr, "ok: SIGRTMIN received\n"); + else + fprintf (stderr, "wrong sigrtmin: unexpected value %d sigrtmin_received\n", + sigrtmin_received); return 0; }