PATCH: two gdbserver tweaks

Daniel Jacobowitz drow@mvista.com
Thu Jun 5 14:28:00 GMT 2003


Two minor gdbserver fixes I found while debugging a software single step
problem.  First, check for removed breakpoints a little earlier, in case
multiple threads pile up on the software-single-step breakpoint; second,
make sure that we send a SIGINT to the currently running thread if there's
only one currently running thread.

-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer

2003-06-05  Daniel Jacobowitz  <drow@mvista.com>

	* linux-low.c (linux_wait_for_event): Correct comment typos.
	(linux_resume_one_process): Call check_removed_breakpoint.
	(linux_send_signal): New function.
	(linux_target_ops): Add linux_send_signal.
	* remote-utils.c (putpkt, input_interrupt): Use send_signal instead
	of kill.
	* target.h (struct target_ops): Add send_signal.

Index: linux-low.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbserver/linux-low.c,v
retrieving revision 1.22
diff -u -p -r1.22 linux-low.c
--- linux-low.c	29 May 2003 22:56:50 -0000	1.22
+++ linux-low.c	5 Jun 2003 14:24:20 -0000
@@ -399,7 +399,7 @@ linux_wait_for_event (struct thread_info
   /* Check for a process with a pending status.  */
   /* It is possible that the user changed the pending task's registers since
      it stopped.  We correctly handle the change of PC if we hit a breakpoint
-     (in check_removed_breakpoints); signals should be reported anyway.  */
+     (in check_removed_breakpoint); signals should be reported anyway.  */
   if (child == NULL)
     {
       event_child = (struct process_info *)
@@ -541,7 +541,7 @@ linux_wait_for_event (struct thread_info
       if (check_breakpoints (stop_pc) != 0)
 	{
 	  /* We hit one of our own breakpoints.  We mark it as a pending
-	     breakpoint, so that check_removed_breakpoints () will do the PC
+	     breakpoint, so that check_removed_breakpoint () will do the PC
 	     adjustment for us at the appropriate time.  */
 	  event_child->pending_is_breakpoint = 1;
 	  event_child->pending_stop_pc = stop_pc;
@@ -587,7 +587,7 @@ linux_wait_for_event (struct thread_info
 	 will give us a new action for this thread, but clear it for
 	 consistency anyway.  It's safe to clear the stepping flag
          because the only consumer of get_stop_pc () after this point
-	 is check_removed_breakpoints, and pending_is_breakpoint is not
+	 is check_removed_breakpoint, and pending_is_breakpoint is not
 	 set.  It might be wiser to use a step_completed flag instead.  */
       if (event_child->stepping)
 	{
@@ -786,7 +786,7 @@ linux_resume_one_process (struct inferio
       process->pending_signals = p_sig;
     }
 
-  if (process->status_pending_p)
+  if (process->status_pending_p && !check_removed_breakpoint (process))
     return;
 
   saved_inferior = current_inferior;
@@ -1228,6 +1228,22 @@ linux_look_up_symbols (void)
 #endif
 }
 
+static void
+linux_send_signal (int signum)
+{
+  extern int signal_pid;
+
+  if (cont_thread > 0)
+    {
+      struct process_info *process;
+
+      process = get_thread_process (current_inferior);
+      kill (process->lwpid, signum);
+    }
+  else
+    kill (signal_pid, signum);
+}
+
 
 static struct target_ops linux_target_ops = {
   linux_create_inferior,
@@ -1241,6 +1257,7 @@ static struct target_ops linux_target_op
   linux_read_memory,
   linux_write_memory,
   linux_look_up_symbols,
+  linux_send_signal,
 };
 
 static void
Index: remote-utils.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbserver/remote-utils.c,v
retrieving revision 1.16
diff -u -p -r1.16 remote-utils.c
--- remote-utils.c	29 Aug 2002 18:50:25 -0000	1.16
+++ remote-utils.c	5 Jun 2003 14:24:20 -0000
@@ -46,8 +46,6 @@ static int remote_desc;
 extern int using_threads;
 extern int debug_threads;
 
-extern int signal_pid;
-
 /* Open a connection to a remote debugger.
    NAME is the filename used for communication.  */
 
@@ -326,7 +324,7 @@ putpkt (char *buf)
 
       /* Check for an input interrupt while we're here.  */
       if (buf3[0] == '\003')
-	kill (signal_pid, SIGINT);
+	(*the_target->send_signal) (SIGINT);
     }
   while (buf3[0] != '+');
 
@@ -363,7 +361,7 @@ input_interrupt (int unused)
 	  return;
 	}
       
-      kill (signal_pid, SIGINT);
+      (*the_target->send_signal) (SIGINT);
     }
 }
 
Index: target.h
===================================================================
RCS file: /cvs/src/src/gdb/gdbserver/target.h,v
retrieving revision 1.5
diff -u -p -r1.5 target.h
--- target.h	29 Aug 2002 18:50:25 -0000	1.5
+++ target.h	5 Jun 2003 14:24:20 -0000
@@ -104,6 +104,9 @@ struct target_ops
      symbols.  */
 
   void (*look_up_symbols) (void);
+
+  /* Send a signal to the inferior process, however is appropriate.  */
+  void (*send_signal) (int);
 };
 
 extern struct target_ops *the_target;



More information about the Gdb-patches mailing list