From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5663 invoked by alias); 13 Mar 2014 02:35:11 -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 5642 invoked by uid 89); 13 Mar 2014 02:35:09 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.6 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.3.2 X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Mar 2014 02:35:08 +0000 Received: from svr-orw-fem-01.mgc.mentorg.com ([147.34.98.93]) by relay1.mentorg.com with esmtp id 1WNvU8-0001OZ-TY from Yao_Qi@mentor.com for gdb-patches@sourceware.org; Wed, 12 Mar 2014 19:35:04 -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); Wed, 12 Mar 2014 19:35:04 -0700 Received: from qiyao.dyndns.org.com (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; Wed, 12 Mar 2014 19:35:03 -0700 From: Yao Qi To: Subject: [PATCH 1/5] Remove argument 'state' from get_tracepoint_by_number Date: Thu, 13 Mar 2014 02:35:00 -0000 Message-ID: <1394677950-4054-2-git-send-email-yao@codesourcery.com> In-Reply-To: <1394677950-4054-1-git-send-email-yao@codesourcery.com> References: <1394677950-4054-1-git-send-email-yao@codesourcery.com> MIME-Version: 1.0 Content-Type: text/plain X-IsSubscribed: yes X-SW-Source: 2014-03/txt/msg00303.txt.bz2 Nowadays, get_tracepoint_by_number gets number from two sources, ARG and STATE, which looks a little odd. It's better to change get_tracepoint_by_number to get number only from ARG, and use get_number_or_range to get number from STATE. This patch removes 'state' argument, get get_tracepoint_by_number cleaner. gdb: 2014-03-13 Yao Qi * breakpoint.c (trace_pass_command): Get tracepoint number by get_number_or_range and get tracepoint get_tracepoint. (get_tracepoint_by_number): Remove argument 'state'. Update comments. Don't check 'state'. All callers updated. * breakpoint.h (get_tracepoint_by_number): Update declaration. --- gdb/breakpoint.c | 46 ++++++++++++++++++++++++++-------------------- gdb/breakpoint.h | 3 +-- gdb/tracepoint.c | 2 +- 3 files changed, 28 insertions(+), 23 deletions(-) diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 1551b99..800cead 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -15532,7 +15532,7 @@ trace_pass_command (char *args, int from_tty) } else if (*args == '\0') { - t1 = get_tracepoint_by_number (&args, NULL); + t1 = get_tracepoint_by_number (&args); if (t1) trace_pass_set_count (t1, count, from_tty); } @@ -15543,9 +15543,14 @@ trace_pass_command (char *args, int from_tty) init_number_or_range (&state, args); while (!state.finished) { - t1 = get_tracepoint_by_number (&args, &state); + int tpnum = get_number_or_range (&state); + + t1 = get_tracepoint (tpnum); + if (t1) trace_pass_set_count (t1, count, from_tty); + else + printf_unfiltered ("No tracepoint number %d.\n", tpnum); } } } @@ -15583,36 +15588,37 @@ get_tracepoint_by_number_on_target (int num) } /* Utility: parse a tracepoint number and look it up in the list. - If STATE is not NULL, use, get_number_or_range_state and ignore ARG. If the argument is missing, the most recent tracepoint (tracepoint_count) is returned. */ struct tracepoint * -get_tracepoint_by_number (char **arg, - struct get_number_or_range_state *state) +get_tracepoint_by_number (char **arg) { struct breakpoint *t; int tpnum; - char *instring = arg == NULL ? NULL : *arg; - if (state) + if (arg == NULL || *arg == NULL || ! **arg) { - gdb_assert (!state->finished); - tpnum = get_number_or_range (state); + if (tracepoint_count == 0) + { + printf_filtered (_("No previous tracepoint\n")); + return NULL; + } + + tpnum = tracepoint_count; } - else if (arg == NULL || *arg == NULL || ! **arg) - tpnum = tracepoint_count; else - tpnum = get_number (arg); - - if (tpnum <= 0) { - if (instring && *instring) - printf_filtered (_("bad tracepoint number at or near '%s'\n"), - instring); - else - printf_filtered (_("No previous tracepoint\n")); - return NULL; + char *instring = *arg; + + tpnum = get_number (arg); + + if (tpnum == 0) + { + printf_filtered (_("bad tracepoint number at or near '%s'\n"), + instring); + return NULL; + } } ALL_TRACEPOINTS (t) diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h index bf1f52a..c1ed2e6 100644 --- a/gdb/breakpoint.h +++ b/gdb/breakpoint.h @@ -1490,8 +1490,7 @@ extern struct tracepoint *get_tracepoint_by_number_on_target (int num); /* Find a tracepoint by parsing a number in the supplied string. */ extern struct tracepoint * - get_tracepoint_by_number (char **arg, - struct get_number_or_range_state *state); + get_tracepoint_by_number (char **arg); /* Return a vector of all tracepoints currently defined. The vector is newly allocated; the caller should free when done with it. */ diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c index 673fddd..cea40e3 100644 --- a/gdb/tracepoint.c +++ b/gdb/tracepoint.c @@ -653,7 +653,7 @@ trace_actions_command (char *args, int from_tty) struct tracepoint *t; struct command_line *l; - t = get_tracepoint_by_number (&args, NULL); + t = get_tracepoint_by_number (&args); if (t) { char *tmpbuf = -- 1.7.7.6