From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18733 invoked by alias); 23 Jan 2008 03:04:19 -0000 Received: (qmail 18724 invoked by uid 22791); 23 Jan 2008 03:04:18 -0000 X-Spam-Check-By: sourceware.org Received: from viper.snap.net.nz (HELO viper.snap.net.nz) (202.37.101.8) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 23 Jan 2008 03:03:52 +0000 Received: from kahikatea.snap.net.nz (29.63.255.123.dynamic.snap.net.nz [123.255.63.29]) by viper.snap.net.nz (Postfix) with ESMTP id 1CC143D9FA1; Wed, 23 Jan 2008 16:03:49 +1300 (NZDT) Received: by kahikatea.snap.net.nz (Postfix, from userid 1000) id 1C5B68FC6D; Wed, 23 Jan 2008 16:03:41 +1300 (NZDT) From: Nick Roberts MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <18326.44682.805865.581205@kahikatea.snap.net.nz> Date: Wed, 23 Jan 2008 03:04:00 -0000 To: "Marc Khouzam" Cc: Subject: Re: [Patch] -var-evaluate-expression NAME [FORMAT] In-Reply-To: <6D19CA8D71C89C43A057926FE0D4ADAA04290E50@ecamlmw720.eamcs.ericsson.se> References: <6D19CA8D71C89C43A057926FE0D4ADAA04290E50@ecamlmw720.eamcs.ericsson.se> X-Mailer: VM 7.19 under Emacs 23.0.50.34 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: 2008-01/txt/msg00537.txt.bz2 > I kind of cheated and used NULL to indicate that the format used should be > the one stored in the varobj structure. I would use a new function, e.g., something like char * varobj_get_formatted_value (struct varobj *var, enum varobj_display_formats format) { enum varobj_display_formats oldformat; char* value; oldformat = var->format; var->format = format; value = varobj_get_value (var); var->format = oldformat; return value; } and call it when argc == 2 in mi_cmd_var_evaluate_expression so that you don't have to change all calls to varobj_get_value and related functions. (Note: not tested) >... > +/* Parse a string argument into a format value. */ > + > +static enum varobj_display_formats > +mi_parse_format (const char *arg) > +{ > + int len; > + > + len = strlen (arg); > + > + if (strncmp (arg, "natural", len) == 0) > + return FORMAT_NATURAL; > + else if (strncmp (arg, "binary", len) == 0) > + return FORMAT_BINARY; > + else if (strncmp (arg, "decimal", len) == 0) > + return FORMAT_DECIMAL; > + else if (strncmp (arg, "hexadecimal", len) == 0) > + return FORMAT_HEXADECIMAL; > + else if (strncmp (arg, "octal", len) == 0) > + return FORMAT_OCTAL; > + else > + error (_("Unknown display format: must be: \"natural\", \"binary\", \"decimal\", \"hexadecimal\", or \"octal\"")); > +} > + and I would refactor this out of mi_cmd_var_set_format. -- Nick http://www.inet.net.nz/~nickrob