From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31715 invoked by alias); 31 May 2013 01:41:15 -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 31705 invoked by uid 89); 31 May 2013 01:41:14 -0000 X-Spam-SWARE-Status: No, score=-3.9 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL 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, 31 May 2013 01:41:11 +0000 Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1UiEL6-0002Ap-M4 from Yao_Qi@mentor.com for gdb-patches@sourceware.org; Thu, 30 May 2013 18:41:08 -0700 Received: from SVR-ORW-FEM-03.mgc.mentorg.com ([147.34.97.39]) by SVR-ORW-EXC-10.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Thu, 30 May 2013 18:41:08 -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; Thu, 30 May 2013 18:41:06 -0700 From: Yao Qi To: Subject: [PATCH] Move common code to all_tracepoint_actions_and_cleanup Date: Fri, 31 May 2013 01:41:00 -0000 Message-ID: <1369964501-30926-1-git-send-email-yao@codesourcery.com> MIME-Version: 1.0 Content-Type: text/plain X-SW-Source: 2013-05/txt/msg01099.txt.bz2 Hi, This patch moves the duplicated code in encode_actions and trace_dump_command out into a new function all_tracepoint_actions_and_cleanup. Regression tested on x86_64-linux with native and gdbserver. gdb: 2013-05-31 Pedro Alves Yao Qi * tracepoint.c (all_tracepoint_actions_and_cleanup): Declare. (encode_actions): Move code to ... (all_tracepoint_actions_and_cleanup): ... here. New. (trace_dump_command): Likewise. --- gdb/tracepoint.c | 75 ++++++++++++++++++++++++++++-------------------------- 1 files changed, 39 insertions(+), 36 deletions(-) diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c index 614f6b7..d6ff051 100644 --- a/gdb/tracepoint.c +++ b/gdb/tracepoint.c @@ -204,6 +204,8 @@ static void add_register (struct collection_list *collection, static void free_uploaded_tps (struct uploaded_tp **utpp); static void free_uploaded_tsvs (struct uploaded_tsv **utsvp); +static struct command_line * + all_tracepoint_actions_and_cleanup (struct breakpoint *t); extern void _initialize_tracepoint (void); @@ -1628,26 +1630,8 @@ encode_actions (struct bp_location *tloc, char ***tdp_actions, gdbarch_virtual_frame_pointer (tloc->gdbarch, tloc->address, &frame_reg, &frame_offset); - actions = breakpoint_commands (tloc->owner); + actions = all_tracepoint_actions_and_cleanup (tloc->owner); - /* If there are default expressions to collect, make up a collect - action and prepend to the action list to encode. Note that since - validation is per-tracepoint (local var "xyz" might be valid for - one tracepoint and not another, etc), we make up the action on - the fly, and don't cache it. */ - if (*default_collect) - { - default_collect_line = xstrprintf ("collect %s", default_collect); - make_cleanup (xfree, default_collect_line); - - validate_actionline (default_collect_line, tloc->owner); - - default_collect_action = xmalloc (sizeof (struct command_line)); - make_cleanup (xfree, default_collect_action); - default_collect_action->next = actions; - default_collect_action->line = default_collect_line; - actions = default_collect_action; - } encode_actions_1 (actions, tloc, frame_reg, frame_offset, &tracepoint_list, &stepping_list); @@ -2912,6 +2896,41 @@ trace_dump_actions (struct command_line *action, } } +/* 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). */ + +static struct command_line * +all_tracepoint_actions_and_cleanup (struct breakpoint *t) +{ + struct command_line *actions; + + actions = breakpoint_commands (t); + + /* If there are default expressions to collect, make up a collect + action and prepend to the action list to encode. Note that since + validation is per-tracepoint (local var "xyz" might be valid for + one tracepoint and not another, etc), we make up the action on + the fly, and don't cache it. */ + if (*default_collect) + { + struct command_line *default_collect_action; + char *default_collect_line; + + default_collect_line = xstrprintf ("collect %s", default_collect); + make_cleanup (xfree, default_collect_line); + + validate_actionline (default_collect_line, t); + default_collect_action = xmalloc (sizeof (struct command_line)); + make_cleanup (xfree, default_collect_action); + default_collect_action->next = actions; + default_collect_action->line = default_collect_line; + actions = default_collect_action; + } + + return actions; +} + /* The tdump command. */ static void @@ -2956,23 +2975,7 @@ trace_dump_command (char *args, int from_tty) if (loc->address == regcache_read_pc (regcache)) stepping_frame = 0; - actions = breakpoint_commands (&t->base); - - /* If there is a default-collect list, make up a collect command, - prepend to the tracepoint's commands, and pass the whole mess to - the trace dump scanner. We need to validate because - default-collect might have been junked since the trace run. */ - if (*default_collect) - { - default_collect_line = xstrprintf ("collect %s", default_collect); - make_cleanup (xfree, default_collect_line); - validate_actionline (default_collect_line, &t->base); - default_collect_action = xmalloc (sizeof (struct command_line)); - make_cleanup (xfree, default_collect_action); - default_collect_action->next = actions; - default_collect_action->line = default_collect_line; - actions = default_collect_action; - } + actions = all_tracepoint_actions_and_cleanup (&t->base); trace_dump_actions (actions, 0, stepping_frame, from_tty); -- 1.7.7.6