From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14695 invoked by alias); 24 Aug 2012 06:56:55 -0000 Received: (qmail 14666 invoked by uid 22791); 24 Aug 2012 06:56:53 -0000 X-SWARE-Spam-Status: No, hits=-4.4 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL 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 Aug 2012 06:56:24 +0000 Received: from svr-orw-fem-01.mgc.mentorg.com ([147.34.98.93]) by relay1.mentorg.com with esmtp id 1T4noc-0001sA-HQ from Yao_Qi@mentor.com ; Thu, 23 Aug 2012 23:56:22 -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); Thu, 23 Aug 2012 23:56:22 -0700 Received: from qiyao.dyndns.org (147.34.91.1) by svr-orw-fem-03.mgc.mentorg.com (147.34.97.39) with Microsoft SMTP Server id 14.1.289.1; Thu, 23 Aug 2012 23:56:21 -0700 Message-ID: <50372591.7080404@codesourcery.com> Date: Fri, 24 Aug 2012 06:56:00 -0000 From: Yao Qi User-Agent: Mozilla/5.0 (X11; Linux i686; rv:14.0) Gecko/20120717 Thunderbird/14.0 MIME-Version: 1.0 To: CC: Subject: Re: [PATCH 1/3] var_integer -> var_uinteger References: <7A6A55B4-0293-4AD6-AB1F-B3169F8ADCC1@cs.umd.edu> <1344871663-915-1-git-send-email-yao@codesourcery.com> <1344871663-915-2-git-send-email-yao@codesourcery.com> <20534.29766.629459.204573@ruffy2.mtv.corp.google.com> In-Reply-To: <20534.29766.629459.204573@ruffy2.mtv.corp.google.com> Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit 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-08/txt/msg00711.txt.bz2 On 08/24/2012 02:19 AM, dje@google.com wrote: > > - if (history_size == INT_MAX) > > + if (history_size == UINT_MAX) > > unstifle_history (); > > - else if (history_size >= 0) > > - stifle_history (history_size); > > + else if (history_size >= INT_MAX) > > + /* The type of parameter in stifle_history is int, so check the range. */ > > + error (_("History size must be less than %d"), INT_MAX); > > I think we don't want to remove resetting "history_size = INT_MAX;" > in the error case here (but see below). Checking the value is negative should be done in do_set_command, and patch was posted here, [PATCH 1/3] var_zuinteger_unlimited and 'set listsize'. http://sourceware.org/ml/gdb-patches/2012-08/msg00021.html Posting a new one has been on my TODO list, and I'll do it once this patch goes in. > Also, new style rules say that since the clause is multiple lines > it needs to be wrapped in {}. > OK. > It's kinda funny that explicitly setting the value to UINT_MAX (instead > of zero) is ok, but setting the value to anywhere between INT_MAX and > UINT_MAX-1 is an error because it's too big.:-) > That makes me think it'd be better to just bite the bullet and say > any value from INT_MAX and up means "unlimited". > They're effectively that anyway. Agreed. Here is a new version. I'll commit it in three days. -- Yao gdb: 2012-08-24 Yao Qi * cli/cli-cmds.c (max_user_call_depth): Add 'unsigned'. (init_cmds): Call add_setshow_uinteger_cmd for command 'max-user-call-depth'. * cli/cli-script.c (execute_user_command): Add 'unsigned' to the declaration of 'max_user_call_depth'. * frame.c (backtrace_limit): Add 'unsigned'. (_initialize_frame): Call add_setshow_uinteger_cmd for command 'limit'. * remote.c (remoteaddresssize): Add 'unsigned'. (remote_address_masked): Change local var 'address_size' to 'unsigned'. (_initialize_remote): Call add_setshow_uinteger_cmd for 'remoteaddresssize'. * top.c (history_size): Add 'unsigned'. (show_commands): Change local variables to 'unsigned'. (set_history_size_command): Don't check history_size is negative. Adjust the condition to call unstifle_history. --- gdb/cli/cli-cmds.c | 10 +++++----- gdb/cli/cli-script.c | 2 +- gdb/frame.c | 14 +++++++------- gdb/remote.c | 14 +++++++------- gdb/top.c | 23 ++++++++++------------- 5 files changed, 30 insertions(+), 33 deletions(-) diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c index 5d8a124..d3473d5 100644 --- a/gdb/cli/cli-cmds.c +++ b/gdb/cli/cli-cmds.c @@ -96,7 +96,7 @@ static void filter_sals (struct symtabs_and_lines *); /* Limit the call depth of user-defined commands */ -int max_user_call_depth; +unsigned int max_user_call_depth; /* Define all cmd_list_elements. */ @@ -1907,13 +1907,13 @@ With no argument, show definitions of all user defined commands."), &showlist); add_com ("apropos", class_support, apropos_command, _("Search for commands matching a REGEXP")); - add_setshow_integer_cmd ("max-user-call-depth", no_class, + add_setshow_uinteger_cmd ("max-user-call-depth", no_class, &max_user_call_depth, _("\ Set the max call depth for non-python user-defined commands."), _("\ Show the max call depth for non-python user-defined commands."), NULL, - NULL, - show_max_user_call_depth, - &setlist, &showlist); + NULL, + show_max_user_call_depth, + &setlist, &showlist); add_setshow_boolean_cmd ("trace-commands", no_class, &trace_commands, _("\ Set tracing of GDB CLI commands."), _("\ diff --git a/gdb/cli/cli-script.c b/gdb/cli/cli-script.c index 4b6c416..743c65f 100644 --- a/gdb/cli/cli-script.c +++ b/gdb/cli/cli-script.c @@ -314,7 +314,7 @@ execute_user_command (struct cmd_list_element *c, char *args) struct cleanup *old_chain; enum command_control_type ret; static int user_call_depth = 0; - extern int max_user_call_depth; + extern unsigned int max_user_call_depth; cmdlines = c->user_commands; if (cmdlines == 0) diff --git a/gdb/frame.c b/gdb/frame.c index 278269d..9ed49f6 100644 --- a/gdb/frame.c +++ b/gdb/frame.c @@ -196,7 +196,7 @@ show_backtrace_past_entry (struct ui_file *file, int from_tty, value); } -static int backtrace_limit = INT_MAX; +static unsigned int backtrace_limit = UINT_MAX; static void show_backtrace_limit (struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value) @@ -2488,16 +2488,16 @@ the rest of the stack trace."), &set_backtrace_cmdlist, &show_backtrace_cmdlist); - add_setshow_integer_cmd ("limit", class_obscure, - &backtrace_limit, _("\ + add_setshow_uinteger_cmd ("limit", class_obscure, + &backtrace_limit, _("\ Set an upper bound on the number of backtrace levels."), _("\ Show the upper bound on the number of backtrace levels."), _("\ No more than the specified number of frames can be displayed or examined.\n\ Zero is unlimited."), - NULL, - show_backtrace_limit, - &set_backtrace_cmdlist, - &show_backtrace_cmdlist); + NULL, + show_backtrace_limit, + &set_backtrace_cmdlist, + &show_backtrace_cmdlist); /* Debug this files internals. */ add_setshow_zuinteger_cmd ("frame", class_maintenance, &frame_debug, _("\ diff --git a/gdb/remote.c b/gdb/remote.c index 2db2c9d..528f374 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -834,7 +834,7 @@ static struct serial *remote_desc = NULL; some remote targets this variable is principly provided to facilitate backward compatibility. */ -static int remote_address_size; +static unsigned int remote_address_size; /* Temporary to track who currently owns the terminal. See remote_terminal_* for more details. */ @@ -6314,7 +6314,7 @@ hexnumnstr (char *buf, ULONGEST num, int width) static CORE_ADDR remote_address_masked (CORE_ADDR addr) { - int address_size = remote_address_size; + unsigned int address_size = remote_address_size; /* If "remoteaddresssize" was not set, default to target address size. */ if (!address_size) @@ -11461,13 +11461,13 @@ Specify a negative limit for unlimited."), breakpoints is %s. */ &remote_set_cmdlist, &remote_show_cmdlist); - add_setshow_integer_cmd ("remoteaddresssize", class_obscure, - &remote_address_size, _("\ + add_setshow_uinteger_cmd ("remoteaddresssize", class_obscure, + &remote_address_size, _("\ Set the maximum size of the address (in bits) in a memory packet."), _("\ Show the maximum size of the address (in bits) in a memory packet."), NULL, - NULL, - NULL, /* FIXME: i18n: */ - &setlist, &showlist); + NULL, + NULL, /* FIXME: i18n: */ + &setlist, &showlist); add_packet_config_cmd (&remote_protocol_packets[PACKET_X], "X", "binary-download", 1); diff --git a/gdb/top.c b/gdb/top.c index 7084116..2c049bf 100644 --- a/gdb/top.c +++ b/gdb/top.c @@ -710,7 +710,7 @@ show_write_history_p (struct ui_file *file, int from_tty, value); } -static int history_size; +static unsigned int history_size; static void show_history_size (struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value) @@ -1380,7 +1380,7 @@ show_commands (char *args, int from_tty) /* The first command in the history which doesn't exist (i.e. one more than the number of the last command). Relative to history_base. */ - int hist_len; + unsigned int hist_len; /* Print out some of the commands from the command history. */ /* First determine the length of the history list. */ @@ -1445,15 +1445,12 @@ show_commands (char *args, int from_tty) static void set_history_size_command (char *args, int from_tty, struct cmd_list_element *c) { - if (history_size == INT_MAX) + /* The type of parameter in stifle_history is int, so value from INT_MAX and + up means "unlimited". */ + if (history_size >= INT_MAX) unstifle_history (); - else if (history_size >= 0) - stifle_history (history_size); else - { - history_size = INT_MAX; - error (_("History size must be non-negative")); - } + stifle_history (history_size); } void @@ -1633,13 +1630,13 @@ Without an argument, saving is enabled."), show_write_history_p, &sethistlist, &showhistlist); - add_setshow_integer_cmd ("size", no_class, &history_size, _("\ + add_setshow_uinteger_cmd ("size", no_class, &history_size, _("\ Set the size of the command history,"), _("\ Show the size of the command history,"), _("\ ie. the number of previous commands to keep a record of."), - set_history_size_command, - show_history_size, - &sethistlist, &showhistlist); + set_history_size_command, + show_history_size, + &sethistlist, &showhistlist); add_setshow_filename_cmd ("filename", no_class, &history_filename, _("\ Set the filename in which to record the command history"), _("\ -- 1.7.7.6