From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19087 invoked by alias); 7 Jun 2013 13:07:39 -0000 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 Received: (qmail 18995 invoked by uid 89); 7 Jun 2013 13:07:33 -0000 X-Spam-SWARE-Status: No, score=-4.6 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL,TW_EG autolearn=ham version=3.3.1 Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Fri, 07 Jun 2013 13:07:32 +0000 Received: from svr-orw-fem-01.mgc.mentorg.com ([147.34.98.93]) by relay1.mentorg.com with esmtp id 1UkwOB-0007f0-6H from Yao_Qi@mentor.com for gdb-patches@sourceware.org; Fri, 07 Jun 2013 06:07:31 -0700 Received: from SVR-ORW-FEM-03.mgc.mentorg.com ([147.34.97.39]) by svr-orw-fem-01.mgc.mentorg.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Fri, 7 Jun 2013 06:07:30 -0700 Received: from qiyao.dyndns.org.dyndns.org (147.34.91.1) by svr-orw-fem-03.mgc.mentorg.com (147.34.97.39) with Microsoft SMTP Server id 14.2.247.3; Fri, 7 Jun 2013 06:06:49 -0700 From: Yao Qi To: Subject: [PATCH 2/5] Move code to get_traceframe_location. Date: Fri, 07 Jun 2013 13:07:00 -0000 Message-ID: <1370610493-26468-3-git-send-email-yao@codesourcery.com> In-Reply-To: <1370610493-26468-1-git-send-email-yao@codesourcery.com> References: <1370610493-26468-1-git-send-email-yao@codesourcery.com> MIME-Version: 1.0 Content-Type: text/plain X-SW-Source: 2013-06/txt/msg00145.txt.bz2 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-06 Pedro Alves Yao Qi * tracepoint.c (trace_dump_command): Move code to ... (get_traceframe_location): ... here. New. --- gdb/tracepoint.c | 79 ++++++++++++++++++++++++++++++++---------------------- 1 files changed, 47 insertions(+), 32 deletions(-) diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c index 03f9230..ab0d0bf 100644 --- a/gdb/tracepoint.c +++ b/gdb/tracepoint.c @@ -2942,6 +2942,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). */ @@ -2982,46 +3024,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) - { - warning (_("No current trace frame.")); - return; - } - - 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