This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH 2/5] move tp installation to cmd_qtdp


function `install_tracepoint' does something irrelevant to installing
tracepoint.  This patch is to move irrelevant code out of it.

2012-03-07  Yao Qi  <yao@codesourcery.com>

	* tracepoint.c (install_tracepoint): Move tracepoint installation
	irrelevant code to ...
	(cmd_qtdp): ... here.
---
 gdb/gdbserver/tracepoint.c |   55 +++++++++++++++++++++++++------------------
 1 files changed, 32 insertions(+), 23 deletions(-)

diff --git a/gdb/gdbserver/tracepoint.c b/gdb/gdbserver/tracepoint.c
index fcb0877..97f44d0 100644
--- a/gdb/gdbserver/tracepoint.c
+++ b/gdb/gdbserver/tracepoint.c
@@ -1312,6 +1312,8 @@ static struct tracepoint *fast_tracepoint_from_ipa_tpoint_address (CORE_ADDR);
 static void install_tracepoint (struct tracepoint *, char *own_buf);
 static void download_tracepoint (struct tracepoint *);
 static int install_fast_tracepoint (struct tracepoint *, char *errbuf);
+static void clone_fast_tracepoint (struct tracepoint *to,
+				   const struct tracepoint *from);
 #endif
 
 static LONGEST get_timestamp (void);
@@ -2479,6 +2481,8 @@ cmd_qtdp (char *own_buf)
      trailing hyphen in QTDP packet.  */
   if (tracing && !trail_hyphen)
     {
+      struct tracepoint *tp = NULL;
+
       /* Pause all threads temporarily while we patch tracepoints.  */
       pause_all (0);
 
@@ -2489,8 +2493,33 @@ cmd_qtdp (char *own_buf)
       /* Freeze threads.  */
       pause_all (1);
 
+
+      if (tpoint->type != trap_tracepoint)
+	{
+	  /* Find another fast or static tracepoint at the same address.  */
+	  for (tp = tracepoints; tp; tp = tp->next)
+	    {
+	      if (tp->address == tpoint->address && tp->type == tpoint->type
+		  && tp->number != tpoint->number)
+		break;
+	    }
+
+	  /* TPOINT is installed at the same address as TP.  */
+	  if (tp)
+	    {
+	      if (tpoint->type == fast_tracepoint)
+		clone_fast_tracepoint (tpoint, tp);
+	      else if (tpoint->type == static_tracepoint)
+		tpoint->handle = (void *) -1;
+	    }
+	}
+
       download_tracepoint (tpoint);
-      install_tracepoint (tpoint, own_buf);
+
+      if (tpoint->type == trap_tracepoint || tp == NULL)
+	install_tracepoint (tpoint, own_buf);
+      else
+	write_ok (own_buf);
 
       unpause_all (1);
       return;
@@ -2994,8 +3023,6 @@ install_tracepoint (struct tracepoint *tpoint, char *own_buf)
     }
   else if (tpoint->type == fast_tracepoint || tpoint->type == static_tracepoint)
     {
-      struct tracepoint *tp;
-
       if (!agent_loaded_p ())
 	{
 	  trace_debug ("Requested a %s tracepoint, but fast "
@@ -3013,30 +3040,12 @@ install_tracepoint (struct tracepoint *tpoint, char *own_buf)
 	  return;
 	}
 
-      /* Find another fast or static tracepoint at the same address.  */
-      for (tp = tracepoints; tp; tp = tp->next)
-	{
-	  if (tp->address == tpoint->address && tp->type == tpoint->type
-	      && tp->number != tpoint->number)
-	    break;
-	}
-
       if (tpoint->type == fast_tracepoint)
-	{
-	  if (tp) /* TPOINT is installed at the same address as TP.  */
-	    clone_fast_tracepoint (tpoint, tp);
-	  else
-	    install_fast_tracepoint (tpoint, own_buf);
-	}
+	install_fast_tracepoint (tpoint, own_buf);
       else
 	{
-	  if (tp)
+	  if (probe_marker_at (tpoint->address, own_buf) == 0)
 	    tpoint->handle = (void *) -1;
-	  else
-	    {
-	      if (probe_marker_at (tpoint->address, own_buf) == 0)
-		tpoint->handle = (void *) -1;
-	    }
 	}
 
     }
-- 
1.7.0.4


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]