From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29030 invoked by alias); 11 Dec 2008 23:51:19 -0000 Received: (qmail 29019 invoked by uid 22791); 11 Dec 2008 23:51:18 -0000 X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (65.74.133.4) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 11 Dec 2008 23:50:43 +0000 Received: (qmail 26144 invoked from network); 11 Dec 2008 23:50:41 -0000 Received: from unknown (HELO orlando.local) (pedro@127.0.0.2) by mail.codesourcery.com with ESMTPA; 11 Dec 2008 23:50:41 -0000 From: Pedro Alves To: gdb-patches@sourceware.org, Tom Tromey Subject: Re: RFA: fix macro expansion bug Date: Thu, 11 Dec 2008 23:51:00 -0000 User-Agent: KMail/1.9.10 References: <200812112304.39302.pedro@codesourcery.com> In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200812112350.41037.pedro@codesourcery.com> 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-12/txt/msg00218.txt.bz2 On Thursday 11 December 2008 23:38:19, Tom Tromey wrote: > >>>>> "Pedro" == Pedro Alves writes: > > >> +gdb_test "macro expand siginfo.si_addr" \ > >> + "expands to: siginfo. fields.fault.si_addr" \ > > Pedro> Just curious, as it's just a visual annoyance: do you know where > Pedro> this space comes from? Do we store the definition with the space for > Pedro> some reason? We don't get that extra space if the define came > Pedro> from the code, instead of from a 'macro define'. > > Here's a patch to fix it. > > This requires a minor tweak to the previous patch's test case, but > otherwise nothing. > > As with the previous, I'm sending this through the regression tester, > but I don't expect problems. Ok if it passes? Looks obvious enough. Ok if it passes. Got curious and confirmed that somehow the trailing end whitespace is stripped already. (gdb) macro define foo bar ^^^^^^ ^^^^^^ (spaces) (gdb) macro expand a->foo->b expands to: a-> bar->b (gdb) > > Tom > > 2008-12-11 Tom Tromey > > * macrocmd.c (macro_define_command): Skip whitespace after > macro name. > (print_one_macro): Print space after macro name. > > diff --git a/gdb/macrocmd.c b/gdb/macrocmd.c > index 56e9a48..fa639d1 100644 > --- a/gdb/macrocmd.c > +++ b/gdb/macrocmd.c > @@ -315,13 +315,17 @@ macro_define_command (char *exp, int from_tty) > } > /* Skip the closing paren. */ > ++exp; > + skip_ws (&exp); > > macro_define_function (macro_main (macro_user_macros), -1, name, > new_macro.argc, (const char **) new_macro.argv, > exp); > } > else > - macro_define_object (macro_main (macro_user_macros), -1, name, exp); > + { > + skip_ws (&exp); > + macro_define_object (macro_main (macro_user_macros), -1, name, exp); > + } > > do_cleanups (cleanup_chain); > } > @@ -358,9 +362,7 @@ print_one_macro (const char *name, const struct macro_definition *macro, > macro->argv[i]); > fprintf_filtered (gdb_stdout, ")"); > } > - /* Note that we don't need a leading space here -- "macro define" > - provided it. */ > - fprintf_filtered (gdb_stdout, "%s\n", macro->replacement); > + fprintf_filtered (gdb_stdout, " %s\n", macro->replacement); > } > > > -- Pedro Alves