]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Further fix 297078 : implement conversion between vki and gdb real time sig nr.
authorPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Fri, 30 Mar 2012 20:25:26 +0000 (20:25 +0000)
committerPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Fri, 30 Mar 2012 20:25:26 +0000 (20:25 +0000)
* 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

coregrind/m_gdbserver/signals.c
gdbserver_tests/nlpasssigalrm.stderr.exp
gdbserver_tests/nlpasssigalrm.stdinB.gdb
gdbserver_tests/nlpasssigalrm.stdoutB.exp
gdbserver_tests/passsigalrm.c

index 07b0c248ab598501405ad9688b9a6f52e2c55942..737dcb376afc236b0fb2a6c660d79447da2968fb 100644 (file)
@@ -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;
    }
index fb23a9730958ec73849d983e1f960ece77668552..24f08d5e4f3351e18ee62ef07e17c198f7f07c22 100644 (file)
@@ -6,4 +6,5 @@ Nulgrind, the minimal Valgrind tool
 starting ...
 ok: 1st SIGALRM received
 ok: 2nd SIGALRM received
+ok: SIGRTMIN received
 
index a8f14c794bd01e2235fbefa78205701bd8b0fa5f..0a52d30dc55056af68462811174e92648bbaad1c 100644 (file)
@@ -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
index 98eac299a7edc8cf3ee29b57d0127f87c460f2df..64651c25d4a952cbdae3ed408f83c19abe9b1f62 100644 (file)
@@ -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.
index 6493a85f7751c10130901a295edc59174b2c9abf..f7b5bc290b9b646940d0c65b931c5527dddbd47e 100644 (file)
@@ -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;
 }