From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17103 invoked by alias); 24 Feb 2012 13:31:39 -0000 Received: (qmail 17092 invoked by uid 22791); 24 Feb 2012 13:31:37 -0000 X-SWARE-Spam-Status: No, hits=-1.4 required=5.0 tests=AWL,BAYES_00,TW_CP X-Spam-Check-By: sourceware.org Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 24 Feb 2012 13:31:21 +0000 Received: from svr-orw-fem-01.mgc.mentorg.com ([147.34.98.93]) by relay1.mentorg.com with esmtp id 1S0vF3-0001kV-18 from Yao_Qi@mentor.com for gdb-patches@sourceware.org; Fri, 24 Feb 2012 05:31:21 -0800 Received: from SVR-ORW-FEM-04.mgc.mentorg.com ([147.34.97.41]) by svr-orw-fem-01.mgc.mentorg.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Fri, 24 Feb 2012 05:31:21 -0800 Received: from [127.0.0.1] (147.34.91.1) by svr-orw-fem-04.mgc.mentorg.com (147.34.97.41) with Microsoft SMTP Server id 14.1.289.1; Fri, 24 Feb 2012 05:31:17 -0800 Message-ID: <4F4790E6.1030403@codesourcery.com> Date: Fri, 24 Feb 2012 13:37:00 -0000 From: Yao Qi User-Agent: Mozilla/5.0 (X11; Linux i686; rv:10.0) Gecko/20120130 Thunderbird/10.0 MIME-Version: 1.0 To: Subject: Re: [PATCH 9/9] info static tracepoint in linux-nat. References: <1329447300-18841-1-git-send-email-yao@codesourcery.com> <1329447300-18841-10-git-send-email-yao@codesourcery.com> In-Reply-To: <1329447300-18841-10-git-send-email-yao@codesourcery.com> Content-Type: multipart/mixed; boundary="------------070308080403000202000309" X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2012-02/txt/msg00555.txt.bz2 --------------070308080403000202000309 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit Content-length: 937 On 02/17/2012 10:55 AM, Yao Qi wrote: > 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. Even target_ops hook `can_use_agent' and `use_agent' are implemented in inf-child.c by patch [PATCH 8/9] impl of use_agent and can_use_agent in linux-nat http://sourceware.org/ml/gdb-patches/2012-02/msg00553.html I am still inclined to implement static_tracepoint_markers_by_strid in linux-nat, because there is no agent at all for non-linux system. Although agent itself is quite generic to all unix system, it still needs de-couple from tracepoint. On the other hand, UST is Linux-specific, so it is better to keep static_tracepoint_markers_by_strid implemented in linux-nat. -- Yao (齐尧) --------------070308080403000202000309 Content-Type: text/x-patch; name="0009-info-static-tracepoint-in-linux-nat.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0009-info-static-tracepoint-in-linux-nat.patch" Content-length: 6254 2012-02-17 Yao Qi * 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-17 Yao Qi * gdb.trace/strace.exp: run strace_info_marker in linux native gdb. --- gdb/linux-nat.c | 72 ++++++++++++++++++++++++++++++++++++ gdb/remote.c | 14 ------- gdb/testsuite/gdb.trace/strace.exp | 35 ++++++++++------- gdb/tracepoint.c | 14 +++++++ gdb/tracepoint.h | 1 + 5 files changed, 108 insertions(+), 28 deletions(-) diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c index 6aab087..82b7b57 100644 --- a/gdb/linux-nat.c +++ b/gdb/linux-nat.c @@ -59,6 +59,8 @@ #include "solib.h" #include "linux-osdata.h" #include "linux-tdep.h" +#include "agent.h" +#include "tracepoint.h" #ifndef SPUFS_MAGIC #define SPUFS_MAGIC 0x23c9b64e @@ -4800,6 +4802,73 @@ linux_xfer_partial (struct target_ops *ops, enum target_object object, offset, len); } +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. */ @@ -4821,6 +4890,9 @@ linux_target_install_ops (struct target_ops *t) super_xfer_partial = t->to_xfer_partial; t->to_xfer_partial = linux_xfer_partial; + + 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 4d6ea10..d4a9a9e 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 @@ -265,6 +251,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 194977b..243ec4d 100644 --- a/gdb/tracepoint.c +++ b/gdb/tracepoint.c @@ -4700,6 +4700,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 --------------070308080403000202000309--