OSDN Git Service

* diagnostics.h, diagnostics.c (print_sigint_message): New function.
authorkevinb <kevinb>
Tue, 1 Dec 2009 09:27:08 +0000 (09:27 +0000)
committerkevinb <kevinb>
Tue, 1 Dec 2009 09:27:08 +0000 (09:27 +0000)
* linux-target.c (linux_process_rcmd): Add monitor commands
"interrupt-with-SIGSTOP and interrupt-with-SIGINT".
* server.h (struct child_process): Add new field
interrupt_with_SIGSTOP.
* thread-db.c (thread_db_break_program): Interrupt using either
SIGSTOP or SIGINT depending upon user's preference.

rda/unix/ChangeLog
rda/unix/diagnostics.c
rda/unix/diagnostics.h
rda/unix/linux-target.c
rda/unix/server.h
rda/unix/thread-db.c

index 610b2be..a7ccc25 100644 (file)
@@ -1,3 +1,13 @@
+2009-11-30  Kevin Buettner  <kevinb@redhat.com>
+
+       * diagnostics.h, diagnostics.c (print_sigint_message): New function.
+       * linux-target.c (linux_process_rcmd): Add monitor commands
+       "interrupt-with-SIGSTOP and interrupt-with-SIGINT".
+       * server.h (struct child_process): Add new field
+       interrupt_with_SIGSTOP.
+       * thread-db.c (thread_db_break_program): Interrupt using either
+       SIGSTOP or SIGINT depending upon user's preference.
+
 2009-11-23  Kevin Buettner  <kevinb@redhat.com>
 
        * ptrace-target.c (syscall.h): Include.
index 33b9712..2dad9ea 100644 (file)
@@ -54,3 +54,21 @@ print_sigstop_message (struct gdbserv *serv)
     }
 }
 
+/* Print out a helpful message regarding SIGINT to the GDB console using
+   an "O" packet.  This message will be printed at most once per session.  */
+void
+print_sigint_message (struct gdbserv *serv)
+{
+  static int once = 0;
+
+  if (!once)
+    {
+      output_O_packet (serv, "\n"
+      "RDA has sent SIGINT to the inferior process.  If the process does not\n"
+      "stop in a timely fashion, it is possible that SIGINT is being blocked.\n"
+      "If that's the case, consider using SIGSTOP to interrupt the process\n"
+      "instead.  The monitor command \"monitor interrupt-with-SIGSTOP\" may\n"
+      "be used to turn on RDA's internal flag for effecting this behavior.\n");
+      once = 1;
+    }
+}
index 2536cbc..aaedd3b 100644 (file)
@@ -39,3 +39,8 @@ void output_O_packet (struct gdbserv *serv, char *message);
    an "O" packet.  This message will only be printed at most once per
    session.  */
 void print_sigstop_message (struct gdbserv *serv);
+
+/* Print out a helpful message regarding SIGINT to the GDB console using
+   an "O" packet.  This message will only be printed at most once per
+   session.  */
+void print_sigint_message (struct gdbserv *serv);
index 96170b8..bfd9623 100644 (file)
@@ -3151,6 +3151,18 @@ linux_process_rcmd (struct gdbserv *serv, const char *cmd, int cmdsize)
       debug_lwp_pool = 0;
       gdbserv_output_string_as_bytes (serv, "All RDA diagnostics disabled.\n");
     }
+  else if (strcmp (cmd, "interrupt-with-SIGSTOP") == 0)
+    {
+      process->interrupt_with_SIGSTOP = 1;
+      gdbserv_output_string_as_bytes (serv,
+        "RDA will use SIGSTOP to perform user requested interrupts.\n");
+    }
+  else if (strcmp (cmd, "interrupt-with-SIGINT") == 0)
+    {
+      process->interrupt_with_SIGSTOP = 0;
+      gdbserv_output_string_as_bytes (serv,
+        "RDA will use SIGINT to perform user requested interrupts.\n");
+    }
   else
     gdbserv_output_string_as_bytes (serv,
       "Unrecognized monitor command.\n"
@@ -3162,7 +3174,9 @@ linux_process_rcmd (struct gdbserv *serv, const char *cmd, int cmdsize)
       "  monitor thread-db-noisy\n"
       "  monitor thread-db-quiet\n"
       "  monitor lwp-pool-noisy\n"
-      "  monitor lwp-pool-quiet\n");
+      "  monitor lwp-pool-quiet\n"
+      "  monitor interrupt-with-SIGSTOP\n"
+      "  monitor interrupt-with-SIGINT\n");
 }
 
 /* This function is called from gdbloop_poll when a new incoming
index d6accd6..7f62367 100644 (file)
@@ -69,6 +69,7 @@ struct child_process {
   long signal_to_send;
   int  debug_backend;
   int  debug_informational;
+  int  interrupt_with_SIGSTOP;
   int  running;
   
 #if defined(_MIPSEL) || defined(_MIPSEB) || defined(AM33_2_0_LINUX_TARGET)
index f50f176..535ea4c 100644 (file)
@@ -2074,18 +2074,35 @@ thread_db_break_program (struct gdbserv *serv)
   /* We always send the signal to the main thread.  It's not correct
      to use process->pid; that's whatever thread last reported a
      status, and it may well have been exiting.
+     
+     We send either SIGSTOP or SIGINT depending upon user preference -
+     a GDB monitor command may be used to change the signal used.  SIGINT
+     has the advantage of allowing the user to continue in the usual
+     manner via GDB's continue command.  SIGSTOP may be preferred in some
+     settings because it cannot be blocked or ignored.  When SIGSTOP is
+     used, it is slightly more difficult to continue without sending
+     another SISSTOP.  */
+
+  if (process->interrupt_with_SIGSTOP)
+    {
+      if (process->debug_backend)
+       fprintf (stderr, " -- send SIGSTOP to child %d\n", proc_handle.pid);
+
+      /* Tell the GDB user that SIGSTOP has been sent to the inferior.  */
+      print_sigstop_message (serv);
 
-     We send SIGSTOP, rather than some other signal such as SIGINT,
-     because SIGSTOP cannot be blocked or ignored.  On Linux, using
-     a signal that can be blocked means that the process never gets
-     interrupted, since it's the kernel which does the blocking.  */
-  if (process->debug_backend)
-    fprintf (stderr, " -- send SIGSTOP to child %d\n", proc_handle.pid);
+      kill (proc_handle.pid, SIGSTOP);
+    }
+  else
+    {
+      if (process->debug_backend)
+       fprintf (stderr, " -- send SIGINT to child %d\n", proc_handle.pid);
 
-  /* Tell the GDB user that SIGSTOP has been sent to the inferior.  */
-  print_sigstop_message (serv);
+      /* Tell the GDB user that SIGINT has been sent to the inferior.  */
+      print_sigint_message (serv);
 
-  kill (proc_handle.pid, SIGSTOP);
+      kill (proc_handle.pid, SIGINT);
+    }
 }
 
 /* Function: check_child_state