Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Yao Qi <yao@codesourcery.com>
To: <gdb-patches@sourceware.org>
Subject: [PATCH 3/6] Move code to get_traceframe_location.
Date: Thu, 13 Jun 2013 01:29:00 -0000	[thread overview]
Message-ID: <1371086914-8398-4-git-send-email-yao@codesourcery.com> (raw)
In-Reply-To: <1371086914-8398-1-git-send-email-yao@codesourcery.com>

This patch is a refactor patch.  It moves some code into a new
function get_traceframe_location, which will be shared in the next
patch in this series.

gdb:

2013-06-13  Pedro Alves  <pedro@codesourcery.com>
	    Yao Qi  <yao@codesourcery.com>

	* tracepoint.c (trace_dump_command): Move code to ...
	(get_traceframe_location): ... here.  New.
---
 gdb/tracepoint.c |   76 +++++++++++++++++++++++++++++++++--------------------
 1 files changed, 47 insertions(+), 29 deletions(-)

diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c
index 05f51ea..86a573e 100644
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -2933,6 +2933,48 @@ trace_dump_actions (struct command_line *action,
     }
 }
 
+/* Return bp_location of the tracepoint associated with the current
+   traceframe.  Set *STEPPING_FRAME_P to 1 if the current traceframe
+   is the stepping traceframe.  */
+
+static struct bp_location *
+get_traceframe_location (int *stepping_frame_p)
+{
+  struct tracepoint *t;
+  struct bp_location *tloc;
+  struct regcache *regcache;
+
+  if (tracepoint_number == -1)
+    error (_("No current trace frame."));
+
+  t = get_tracepoint (tracepoint_number);
+
+  if (t == NULL)
+    error (_("No known tracepoint matches 'current' tracepoint #%d."),
+	   tracepoint_number);
+
+  /* The current frame is a trap frame if the frame PC is equal to the
+     tracepoint PC.  If not, then the current frame was collected
+     during single-stepping.  */
+  regcache = get_current_regcache ();
+
+  /* If the traceframe's address matches any of the tracepoint's
+     locations, assume it is a direct hit rather than a while-stepping
+     frame.  (FIXME this is not reliable, should record each frame's
+     type.)  */
+  for (tloc = t->base.loc; tloc; tloc = tloc->next)
+    if (tloc->address == regcache_read_pc (regcache))
+      {
+	*stepping_frame_p = 0;
+	return tloc;
+      }
+
+  /* If this is a stepping frame, we don't know which location
+     triggered.  The first is as good (or bad) a guess as any...  */
+  *stepping_frame_p = 1;
+  return t->base.loc;
+}
+
 /* Return all the actions, including default collect, of a tracepoint
    T.  It constructs cleanups into the chain, and leaves the caller to
    handle them (call do_cleanups).  */
@@ -2973,43 +3015,19 @@ all_tracepoint_actions_and_cleanup (struct breakpoint *t)
 static void
 trace_dump_command (char *args, int from_tty)
 {
-  struct regcache *regcache;
-  struct tracepoint *t;
   int stepping_frame = 0;
   struct bp_location *loc;
-  char *default_collect_line = NULL;
-  struct command_line *actions, *default_collect_action = NULL;
   struct cleanup *old_chain;
+  struct command_line *actions;
 
-  if (tracepoint_number == -1)
-    error (_("No current trace frame."));
-
-  old_chain = make_cleanup (null_cleanup, NULL);
-  t = get_tracepoint (tracepoint_number);
-
-  if (t == NULL)
-    error (_("No known tracepoint matches 'current' tracepoint #%d."),
-	   tracepoint_number);
+  /* This throws an error is not inspecting a trace frame.  */
+  loc = get_traceframe_location (&stepping_frame);
 
   printf_filtered ("Data collected at tracepoint %d, trace frame %d:\n",
 		   tracepoint_number, traceframe_number);
 
-  /* The current frame is a trap frame if the frame PC is equal
-     to the tracepoint PC.  If not, then the current frame was
-     collected during single-stepping.  */
-
-  regcache = get_current_regcache ();
-
-  /* If the traceframe's address matches any of the tracepoint's
-     locations, assume it is a direct hit rather than a while-stepping
-     frame.  (FIXME this is not reliable, should record each frame's
-     type.)  */
-  stepping_frame = 1;
-  for (loc = t->base.loc; loc; loc = loc->next)
-    if (loc->address == regcache_read_pc (regcache))
-      stepping_frame = 0;
-
-  actions = all_tracepoint_actions_and_cleanup (&t->base);
+  old_chain = make_cleanup (null_cleanup, NULL);
+  actions = all_tracepoint_actions_and_cleanup (loc->owner);
 
   trace_dump_actions (actions, 0, stepping_frame, from_tty);
 
-- 
1.7.7.6


  parent reply	other threads:[~2013-06-13  1:29 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-07 13:07 [PATCH 0/5] New MI command -trace-frame-collected Yao Qi
2013-06-07 13:07 ` [PATCH 1/5] Remove global variable tracepoint_list and stepping_list Yao Qi
2013-06-07 20:50   ` Pedro Alves
2013-06-07 13:07 ` [PATCH 4/5] New MI command -trace-frame-collected Yao Qi
2013-06-07 13:07 ` [PATCH 5/5] New test: gdb.trace/mi-trace-frame-collected.exp Yao Qi
2013-06-07 13:07 ` [PATCH 2/5] Move code to get_traceframe_location Yao Qi
2013-06-07 21:09   ` Pedro Alves
2013-06-07 13:07 ` [PATCH 3/5] Add id of TSV into traceframe_info Yao Qi
2013-06-07 14:39   ` Eli Zaretskii
2013-06-08 11:06     ` Yao Qi
2013-06-13  1:29 ` [PATCH 0/6 V2] New MI command -trace-frame-collected Yao Qi
2013-06-13  1:29   ` [PATCH 5/6] " Yao Qi
2013-06-13 14:27     ` Eli Zaretskii
2013-06-14  9:52       ` Yao Qi
2013-06-14 12:34         ` Eli Zaretskii
2013-06-17 10:21           ` Yao Qi
2013-06-17 15:48             ` Eli Zaretskii
2013-06-18 14:09               ` Yao Qi
2013-06-18 17:24                 ` Eli Zaretskii
2013-06-25 17:31                 ` Pedro Alves
2013-06-26  8:29                   ` Yao Qi
2013-06-26 11:22                     ` Pedro Alves
2013-06-13  1:29   ` [PATCH 4/6] Add id of TSV into traceframe_info Yao Qi
2013-06-13  3:40     ` Eli Zaretskii
2013-06-25 16:18     ` Pedro Alves
2013-06-26  8:19       ` Yao Qi
2013-06-13  1:29   ` [PATCH 2/6] Emit error in tdump command when traceframe is not selected Yao Qi
2013-06-25 15:32     ` Pedro Alves
2013-06-13  1:29   ` Yao Qi [this message]
2013-06-25 15:43     ` [PATCH 3/6] Move code to get_traceframe_location Pedro Alves
2013-06-13  1:29   ` [PATCH 6/6] New test: gdb.trace/mi-trace-frame-collected.exp Yao Qi
2013-06-25 18:42     ` Pedro Alves
2013-06-26 10:32       ` Yao Qi
2013-06-13  2:46   ` [PATCH 1/6] Remove global variable tracepoint_list and stepping_list Yao Qi
2013-06-25 15:28     ` Pedro Alves
2013-06-24 15:25   ` [ping]: [PATCH 0/6 V2] New MI command -trace-frame-collected Yao Qi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1371086914-8398-4-git-send-email-yao@codesourcery.com \
    --to=yao@codesourcery.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox