From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2825 invoked by alias); 17 Aug 2011 13:39:57 -0000 Received: (qmail 2815 invoked by uid 22791); 17 Aug 2011 13:39:56 -0000 X-SWARE-Spam-Status: No, hits=-2.1 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW X-Spam-Check-By: sourceware.org Received: from mail-fx0-f41.google.com (HELO mail-fx0-f41.google.com) (209.85.161.41) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 17 Aug 2011 13:39:41 +0000 Received: by fxg9 with SMTP id 9so807079fxg.0 for ; Wed, 17 Aug 2011 06:39:40 -0700 (PDT) Received: by 10.223.36.89 with SMTP id s25mr1495805fad.19.1313588380334; Wed, 17 Aug 2011 06:39:40 -0700 (PDT) MIME-Version: 1.0 Received: by 10.223.120.207 with HTTP; Wed, 17 Aug 2011 06:39:00 -0700 (PDT) From: Hui Zhu Date: Wed, 17 Aug 2011 13:39:00 -0000 Message-ID: Subject: PING: Re: [PATCH] printcmd.c (ui_printf): make internalvar string can be printf and eval when inferior cannot alloc memory To: Tom Tromey Cc: gdb-patches ml Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 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: 2011-08/txt/msg00340.txt.bz2 Thanks, Hui On Tue, Aug 16, 2011 at 12:57, Hui Zhu wrote: > Hi Tom, > > Thanks for your help. > > On Tue, Aug 16, 2011 at 03:06, Tom Tromey wrote: >>>>>>> ">" =3D=3D Hui Zhu writes: >> >>>> Thanks for your help. >>>> I make a new patch according to your mail. >> >>>> 2011-08-14 =A0Hui Zhu =A0 >>>> =A0 =A0 =A0 =A0* printcmd.c (ui_printf): Add a handler for internalvar= and >>>> TYPE_CODE_ARRAY. >> >> I still don't think this is correct. >> >> This special-cases lval_internalvar, but IIUC this will still fail for >> something like: >> >> =A0 =A0printf "hi %s\n", "bob" >> >> In this code I don't think you need to call value_as_address for an >> array; likewise reading from memory. > > I make a new patch according to it. =A0Please help me review it. > >> >> The patch also doesn't address the wide-string case, which it should. > > I don't know howto input a =A0wide-string to GDB command line. > Could you help me with that and let me write a separate patch special > for wide-string case? > >> >> Tom >> > > Best, > Hui > > 2011-08-16 =A0Hui Zhu =A0 > > =A0 =A0 =A0 =A0* printcmd.c (ui_printf): Add a handler for internalvar or= not_lval > =A0 =A0 =A0 =A0and TYPE_CODE_ARRAY. > --- > =A0printcmd.c | =A0 49 ++++++++++++++++++++++++++++--------------------- > =A01 file changed, 28 insertions(+), 21 deletions(-) > > --- a/printcmd.c > +++ b/printcmd.c > @@ -2343,32 +2343,39 @@ ui_printf (char *arg, struct ui_file *st > =A0 =A0 =A0 =A0switch (argclass[i]) > =A0 =A0 =A0 =A0 =A0{ > =A0 =A0 =A0 =A0 =A0case string_arg: > - =A0 =A0 =A0 =A0 =A0 { > - =A0 =A0 =A0 =A0 =A0 =A0 gdb_byte *str; > - =A0 =A0 =A0 =A0 =A0 =A0 CORE_ADDR tem; > - =A0 =A0 =A0 =A0 =A0 =A0 int j; > + =A0 =A0 =A0 =A0 =A0 =A0if ((VALUE_LVAL (val_args[i]) =3D=3D lval_intern= alvar > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0|| VALUE_LVAL (val_args[i]) =3D=3D not_l= val) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 && TYPE_CODE (check_typedef (value_type (va= l_args[i]))) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=3D=3D TYPE_CODE_ARRAY) > + =A0 =A0 =A0 =A0 =A0 =A0 fprintf_filtered (stream, current_substring, > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (char *) va= lue_contents (val_args[i])); > + =A0 =A0 =A0 =A0 =A0 else > + =A0 =A0 =A0 =A0 =A0 =A0 { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 gdb_byte *str; > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 CORE_ADDR tem; > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 int j; > > - =A0 =A0 =A0 =A0 =A0 =A0 tem =3D value_as_address (val_args[i]); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 tem =3D value_as_address (val_args[i]); > > - =A0 =A0 =A0 =A0 =A0 =A0 /* This is a %s argument. =A0Find the length of= the string. =A0*/ > - =A0 =A0 =A0 =A0 =A0 =A0 for (j =3D 0;; j++) > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 { > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 gdb_byte c; > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 /* This is a %s argument. =A0Find the lengt= h of the string. =A0*/ > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 for (j =3D 0;; j++) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 gdb_byte c; > > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 QUIT; > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 read_memory (tem + j, &c, 1); > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (c =3D=3D 0) > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 break; > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 } > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 QUIT; > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 read_memory (tem + j, &c, 1); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (c =3D=3D 0) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 break; > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 } > > - =A0 =A0 =A0 =A0 =A0 =A0 /* Copy the string contents into a string insid= e GDB. =A0*/ > - =A0 =A0 =A0 =A0 =A0 =A0 str =3D (gdb_byte *) alloca (j + 1); > - =A0 =A0 =A0 =A0 =A0 =A0 if (j !=3D 0) > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 read_memory (tem, str, j); > - =A0 =A0 =A0 =A0 =A0 =A0 str[j] =3D 0; > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 /* Copy the string contents into a string i= nside GDB. =A0*/ > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 str =3D (gdb_byte *) alloca (j + 1); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (j !=3D 0) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 read_memory (tem, str, j); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 str[j] =3D 0; > > - =A0 =A0 =A0 =A0 =A0 =A0 =A0fprintf_filtered (stream, current_substring,= (char *) str); > - =A0 =A0 =A0 =A0 =A0 } > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0fprintf_filtered (stream, current_substr= ing, (char *) str); > + =A0 =A0 =A0 =A0 =A0 =A0 } > =A0 =A0 =A0 =A0 =A0 =A0break; > =A0 =A0 =A0 =A0 =A0case wide_string_arg: > =A0 =A0 =A0 =A0 =A0 =A0{ >