From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15309 invoked by alias); 1 Sep 2011 21:33:47 -0000 Received: (qmail 15301 invoked by uid 22791); 1 Sep 2011 21:33:47 -0000 X-SWARE-Spam-Status: No, hits=-2.6 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: sourceware.org Received: from mail-gw0-f41.google.com (HELO mail-gw0-f41.google.com) (74.125.83.41) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 01 Sep 2011 21:33:33 +0000 Received: by gwaa20 with SMTP id a20so1336551gwa.0 for ; Thu, 01 Sep 2011 14:33:32 -0700 (PDT) MIME-Version: 1.0 Received: by 10.236.177.72 with SMTP id c48mr1936277yhm.79.1314912812801; Thu, 01 Sep 2011 14:33:32 -0700 (PDT) Received: by 10.236.34.162 with HTTP; Thu, 1 Sep 2011 14:33:32 -0700 (PDT) In-Reply-To: References: <1314198654-9008-1-git-send-email-ratmice@gmail.com> <1314198654-9008-2-git-send-email-ratmice@gmail.com> Date: Thu, 01 Sep 2011 21:48:00 -0000 Message-ID: Subject: Re: [PATCH 1/7] [python] API for macros: abort or continuing macro iterators. From: Matt Rice To: pmuldoon@redhat.com Cc: gdb-patches@sourceware.org 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-09/txt/msg00018.txt.bz2 On Tue, Aug 30, 2011 at 4:09 AM, Phil Muldoon wrote: > matt rice writes: > >> diff --git a/gdb/macrocmd.c b/gdb/macrocmd.c >> index d1ac7fa..e929fe0 100644 >> --- a/gdb/macrocmd.c >> +++ b/gdb/macrocmd.c >> @@ -220,13 +220,15 @@ info_macro_command (char *name, int from_tty) >> =A0 =A0 Otherwise USER_DATA is considered to be a string, printing >> =A0 =A0 only macros who's NAME matches USER_DATA. =A0Other arguments are >> =A0 =A0 routed to print_macro_definition. =A0*/ >> -static void >> +static enum macro_walk_status >> =A0print_macro_callback (const char *name, const struct macro_definition= *macro, >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0struct macro_source_file *source, int= line, >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0void *user_data) >> =A0{ >> =A0 =A0if (! user_data || strcmp (user_data, name) =3D=3D 0) >> =A0 =A0 =A0print_macro_definition (name, macro, source, line); >> + >> + =A0return macro_walk_continue; >> =A0} > > Is the unconditional return here due to it being part of a recursive > call chain? I'm not sure what value the unconditional return of an enum > constant over the previous "void" gets us? Why return anything at all? > The previous version assumed the callers knew how to deal with the void > return, but I am not sure what your version achieves by unconditionally > returning macro_walk_continue? This is just matching pre-existing behavior from before macro iteration could abort/continue. the 'void' return was hard coded as 'return 0', in foreach_macro and foreach_macro_in_scope where now they return 'status =3D=3D macro_walk_abort' where 0 means continue and !=3D 0 abort as interpreted by src/libiberty/splay-tree.c:splay_tree_foreach_helper >> =A0/* Implementation of the "info definitions" command. */ >> @@ -435,7 +437,7 @@ macro_undef_command (char *exp, int from_tty) >> =A0} >> >> >> -static void >> +static enum macro_walk_status >> =A0print_one_macro (const char *name, const struct macro_definition *mac= ro, >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0struct macro_source_file *source, int lin= e, >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0void *ignore) >> @@ -452,6 +454,7 @@ print_one_macro (const char *name, const struct macr= o_definition *macro, >> =A0 =A0 =A0 =A0fprintf_filtered (gdb_stdout, ")"); >> =A0 =A0 =A0} >> =A0 =A0fprintf_filtered (gdb_stdout, " %s\n", macro->replacement); >> + =A0return macro_walk_continue; >> =A0} > > Same as above. If you decide to keep them please update the comment > headers with a description of the return value. =A0This function, =A0and > numerous other places too. will do, though, these are documented in macrotab.h:macro_callback_fn, i should at least mention they are implementations of those, and arguments/return values are documented there. does that sound alright?