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 9/9] info static tracepoint in linux-nat.
Date: Fri, 17 Feb 2012 03:02:00 -0000	[thread overview]
Message-ID: <1329447300-18841-10-git-send-email-yao@codesourcery.com> (raw)
In-Reply-To: <1329447300-18841-1-git-send-email-yao@codesourcery.com>

This patch is to exercise agent in linux native gdb by command `info
static-tracepoint-marker'.  The implementation of `linux_child_static_tracepoint_markers_by_strid'
is quite similar to its counterpart in remote target, except bits to pause and unpause
all threads in current process.

gdb.trace/strace.exp is updated as well to test this point.

2012-02-14  Yao Qi  <yao@codesourcery.com>

	* linux-nat.c (linux_child_static_tracepoint_markers_by_strid):
	New.
        (linux_target_install_ops): Initialize field
	`to_static_tracepoint_markers_by_strid'.
	* remote.c (free_current_marker): Move it to ...
	* tracepoint.c (free_current_marker): ... here.  New.
	(cleanup_target_stop): New.
	* tracepoint.h: Declare free_current_marker.

gdb/testsuite/
2012-02-15  Yao Qi  <yao@codesourcery.com>

	* gdb.trace/strace.exp: run strace_info_marker in native gdb.
---
 gdb/linux-nat.c                    |   71 ++++++++++++++++++++++++++++++++++++
 gdb/remote.c                       |   14 -------
 gdb/testsuite/gdb.trace/strace.exp |   35 +++++++++++-------
 gdb/tracepoint.c                   |   14 +++++++
 gdb/tracepoint.h                   |    1 +
 5 files changed, 107 insertions(+), 28 deletions(-)

diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
index 3e81fd0..f77ec6e 100644
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -60,6 +60,7 @@
 #include "linux-osdata.h"
 #include "linux-tdep.h"
 #include "agent.h"
+#include "tracepoint.h"
 
 #ifndef SPUFS_MAGIC
 #define SPUFS_MAGIC 0x23c9b64e
@@ -4819,6 +4820,73 @@ linux_child_can_use_agent (void)
   return agent_loaded_p ();
 }
 
+static void
+cleanup_target_stop (void *arg)
+{
+  ptid_t *ptid = (ptid_t *) arg;
+
+  gdb_assert (arg != NULL);
+
+  /* Unpause all */
+  target_resume (*ptid, 0, TARGET_SIGNAL_0);
+}
+
+static VEC(static_tracepoint_marker_p) *
+linux_child_static_tracepoint_markers_by_strid (const char *strid)
+{
+  char s[IPA_CMD_BUF_SIZE];
+  struct cleanup *old_chain;
+  int pid = ptid_get_pid (inferior_ptid);
+  VEC(static_tracepoint_marker_p) *markers = NULL;
+  struct static_tracepoint_marker *marker = NULL;
+  char *p = s;
+  ptid_t ptid = ptid_build (pid, 0, 0);
+
+  /* Pause all */
+  target_stop (ptid);
+
+  memcpy (s, "qTfSTM", sizeof ("qTfSTM"));
+  s[sizeof ("qTfSTM")] = 0;
+
+  agent_run_command (pid, s);
+
+  old_chain = make_cleanup (free_current_marker, &marker);
+  make_cleanup (cleanup_target_stop, &ptid);
+
+  while (*p++ == 'm')
+    {
+      if (marker == NULL)
+	marker = XCNEW (struct static_tracepoint_marker);
+
+      do
+	{
+	  parse_static_tracepoint_marker_definition (p, &p, marker);
+
+	  if (strid == NULL || strcmp (strid, marker->str_id) == 0)
+	    {
+	      VEC_safe_push (static_tracepoint_marker_p,
+			     markers, marker);
+	      marker = NULL;
+	    }
+	  else
+	    {
+	      release_static_tracepoint_marker (marker);
+	      memset (marker, 0, sizeof (*marker));
+	    }
+	}
+      while (*p++ == ',');	/* comma-separated list */
+
+      memcpy (s, "qTsSTM", sizeof ("qTsSTM"));
+      s[sizeof ("qTsSTM")] = 0;
+      agent_run_command (pid, s);
+      p = s;
+    }
+
+  do_cleanups (old_chain);
+
+  return markers;
+}
+
 /* Create a prototype generic GNU/Linux target.  The client can override
    it with local methods.  */
 
@@ -4843,6 +4911,9 @@ linux_target_install_ops (struct target_ops *t)
 
   t->to_use_agent = linux_child_use_agent;
   t->to_can_use_agent = linux_child_can_use_agent;
+
+  t->to_static_tracepoint_markers_by_strid
+    = linux_child_static_tracepoint_markers_by_strid;
 }
 
 struct target_ops *
diff --git a/gdb/remote.c b/gdb/remote.c
index 2977e31..422c7d4 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -2846,20 +2846,6 @@ remote_static_tracepoint_marker_at (CORE_ADDR addr,
   return 0;
 }
 
-static void
-free_current_marker (void *arg)
-{
-  struct static_tracepoint_marker **marker_p = arg;
-
-  if (*marker_p != NULL)
-    {
-      release_static_tracepoint_marker (*marker_p);
-      xfree (*marker_p);
-    }
-  else
-    *marker_p = NULL;
-}
-
 static VEC(static_tracepoint_marker_p) *
 remote_static_tracepoint_markers_by_strid (const char *strid)
 {
diff --git a/gdb/testsuite/gdb.trace/strace.exp b/gdb/testsuite/gdb.trace/strace.exp
index 8b0c4ef..f30eb79 100644
--- a/gdb/testsuite/gdb.trace/strace.exp
+++ b/gdb/testsuite/gdb.trace/strace.exp
@@ -38,20 +38,6 @@ if { [gdb_compile $srcdir/$subdir/$srcfile $binfile executable $additional_flags
     return -1
 }
 
-clean_restart $executable
-
-if ![runto_main] {
-    fail "Can't run to main to check for trace support"
-    return -1
-}
-
-if { ![gdb_target_supports_trace] } then {
-    unsupported "Current target does not support trace"
-    return -1;
-}
-
-gdb_load_shlibs $libipa
-
 proc strace_info_marker { } {
     global executable
     global pf_prefix
@@ -269,6 +255,27 @@ proc strace_trace_on_diff_addr { } {
     set pf_prefix $old_pf_prefix
 }
 
+clean_restart $executable
+
+if ![runto_main] {
+    fail "Can't run to main to check for trace support"
+    return -1
+}
+
+# Run it on native x86/x86_64 linux.
+if { ![is_remote target]
+     && ([istarget "x86_64-*-linux*"] || [istarget "i\[34567\]86-*-linux*"]) } {
+    strace_info_marker
+    return
+}
+
+if { ![gdb_target_supports_trace] } then {
+    unsupported "Current target does not support trace"
+    return -1;
+}
+
+gdb_load_shlibs $libipa
+
 strace_info_marker
 strace_probe_marker
 
diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c
index c2801f9..c4bfbd5 100644
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -4701,6 +4701,20 @@ init_tfile_ops (void)
   tfile_ops.to_magic = OPS_MAGIC;
 }
 
+void
+free_current_marker (void *arg)
+{
+  struct static_tracepoint_marker **marker_p = arg;
+
+  if (*marker_p != NULL)
+    {
+      release_static_tracepoint_marker (*marker_p);
+      xfree (*marker_p);
+    }
+  else
+    *marker_p = NULL;
+}
+
 /* Given a line of text defining a static tracepoint marker, parse it
    into a "static tracepoint marker" object.  Throws an error is
    parsing fails.  If PP is non-null, it points to one past the end of
diff --git a/gdb/tracepoint.h b/gdb/tracepoint.h
index 00c4d7c..30a810a 100644
--- a/gdb/tracepoint.h
+++ b/gdb/tracepoint.h
@@ -209,6 +209,7 @@ extern void parse_static_tracepoint_marker_definition
   (char *line, char **pp,
    struct static_tracepoint_marker *marker);
 extern void release_static_tracepoint_marker (struct static_tracepoint_marker *);
+extern void free_current_marker (void *arg);
 
 /* A hook used to notify the UI of tracepoint operations.  */
 
-- 
1.7.0.4


  parent reply	other threads:[~2012-02-17  2:57 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-17  2:56 [patch v2] GDB/GDBserver talks with agents Yao Qi
2012-02-17  2:56 ` [PATCH 3/9] command set agent on and off Yao Qi
2012-02-23 21:51   ` Pedro Alves
2012-02-24 13:13     ` Yao Qi
2012-02-24 14:15       ` Pedro Alves
2012-02-17  2:56 ` [PATCH 1/9] move agent related code from gdbserver to common/agent.c Yao Qi
2012-02-17  9:55   ` Mark Kettenis
2012-02-23 21:05   ` Pedro Alves
2012-02-23 21:17     ` Pedro Alves
2012-02-24  7:57     ` Yao Qi
2012-02-24 13:40       ` Yao Qi
2012-02-17  2:57 ` [PATCH 8/9] impl of use_agent and can_use_agent in linux-nat Yao Qi
2012-02-23 22:15   ` Pedro Alves
2012-02-24  8:34     ` Yao Qi
2012-02-24 10:47       ` Pedro Alves
2012-02-24 13:31     ` Yao Qi
2012-02-24 14:10       ` Pedro Alves
2012-02-24 14:34         ` Yao Qi
2012-02-17  2:57 ` [PATCH 6/9] agent capability of static tracepoint Yao Qi
2012-02-23 22:06   ` Pedro Alves
2012-02-24 13:19     ` Yao Qi
2012-02-24 14:25       ` Pedro Alves
2012-02-17  2:57 ` [PATCH 2/9] add target_ops fields use_agent and can_use_agent Yao Qi
2012-02-17 11:40   ` Eli Zaretskii
2012-02-23 21:21   ` Pedro Alves
2012-02-24 13:01     ` Yao Qi
2012-02-24 13:05       ` Pedro Alves
2012-02-17  2:57 ` [PATCH 5/9] agent capability Yao Qi
2012-02-17  2:57 ` [PATCH 4/9] agent doc Yao Qi
2012-02-17 11:38   ` Eli Zaretskii
2012-02-17 13:34     ` Yao Qi
2012-02-17 16:10       ` Pedro Alves
2012-02-18 17:11       ` Eli Zaretskii
2012-02-20  3:56         ` Yao Qi
2012-02-20  6:22           ` Eli Zaretskii
2012-02-21 18:18           ` Pedro Alves
2012-02-22  1:56             ` Yao Qi
2012-02-22 20:41               ` Pedro Alves
2012-02-22 23:43                 ` Eli Zaretskii
2012-02-27 13:23                 ` Yao Qi
2012-02-17  2:57 ` [PATCH 7/9] move in_process_agent_loaded to agent_loaded_p Yao Qi
2012-02-23 22:11   ` Pedro Alves
2012-02-23 22:27     ` Pedro Alves
2012-02-17  3:02 ` Yao Qi [this message]
2012-02-24 13:37   ` [PATCH 9/9] info static tracepoint in linux-nat Yao Qi
2012-02-17  4:02 ` [patch v2] GDB/GDBserver talks with agents Yao Qi
2012-02-17 12:03 ` Eli Zaretskii
2012-02-27  9:43   ` Yao Qi
2012-02-27 18:04     ` Eli Zaretskii

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=1329447300-18841-10-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