From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id sz0dKthE4mls4x4AWB0awg (envelope-from ) for ; Fri, 17 Apr 2026 10:34:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1776436440; bh=M8LBlL2a7fpSGUsat22Kez5bfAs4X6I08mgXr1ZlMAM=; h=Date:Subject:To:References:From:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=P4rQ3FxlQoD7h7/u8plBB2Fd004fneg0Gz89NlkGA/UC8HOIjoVewzGZ+5X8yG0ML wXt7OuKspvxVMDlF0Gj/aPJ1MMZxml0k9mV26iCSPlQqvzGir3OHiVxVxreikZkh2u cudJYU/kIEHVx3f6Pj+MV7Xnkb/0PF7GutTkOuPg= Received: by simark.ca (Postfix, from userid 112) id 92B081E093; Fri, 17 Apr 2026 10:34:00 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=simark.ca header.i=@simark.ca header.a=rsa-sha256 header.s=mail header.b=A1f87X4N; dkim-atps=neutral Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id C15401E093 for ; Fri, 17 Apr 2026 10:33:59 -0400 (EDT) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id E67514CCCA12 for ; Fri, 17 Apr 2026 14:33:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E67514CCCA12 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=simark.ca header.i=@simark.ca header.a=rsa-sha256 header.s=mail header.b=A1f87X4N Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id D78E14C9176C for ; Fri, 17 Apr 2026 14:33:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D78E14C9176C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=simark.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=simark.ca ARC-Filter: OpenARC Filter v1.0.0 sourceware.org D78E14C9176C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=158.69.221.121 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776436414; cv=none; b=ZL8gv2wFB2Uc1F6Y0BUm/obdxPG4ztFnW2auUcP0PFkznqJ4RC19igF7QYxeS6qnhDVOEZvuSA7z/qv75CNrq1N7svWXzu4RrA1waHzozH38U6Jv1+tfd1VqMPoObtdC5GH6fnqUHZRs/BH+kzb9mCULEVvNyBSdqd4vsFUrH9U= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776436414; c=relaxed/simple; bh=M8LBlL2a7fpSGUsat22Kez5bfAs4X6I08mgXr1ZlMAM=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=HrD1hM3hofIEn4bJD9iSlTJzS8Kz3QsOqXg2ksYzKhFSYHtbvRCx3PtA/eSU9IniJn6C2qbcsnPKHQCmJygun33Iq1JBjgDQoxWD6xkgl2wckCcnTzcxlpGJ+g9zCh62GKab+XutWLuFBKs6fSs/J0/NM2CviYVW+uCvemKx19k= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D78E14C9176C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1776436412; bh=M8LBlL2a7fpSGUsat22Kez5bfAs4X6I08mgXr1ZlMAM=; h=Date:Subject:To:References:From:In-Reply-To:From; b=A1f87X4NNoFGckbDVXBdm2oQCTs7IUOgMs2PVan9OO+NF3NwVExJF/Ob18B0YlDxu pPWjjHN08Z/uMD6IrYEePGgidO7VAWYQX2CmhzPpaE/28s7XBpFfOON7QxLFEkOKu/ gdjixvpH4V+6LLjfxxQ/2XRVs+jwVCJkvY7uJFLg= Received: by simark.ca (Postfix) id 9180E1E0A2; Fri, 17 Apr 2026 10:33:31 -0400 (EDT) Message-ID: <3c340461-f647-42f2-b768-5abd6c11062f@simark.ca> Date: Fri, 17 Apr 2026 10:33:30 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 03/11] gdb: introduce iteration_status enum, use it for search callbacks To: Andrew Burgess , Simon Marchi , gdb-patches@sourceware.org References: <20260416202408.422441-1-simon.marchi@efficios.com> <20260416202408.422441-4-simon.marchi@efficios.com> <87wly5etpa.fsf@redhat.com> Content-Language: fr From: Simon Marchi In-Reply-To: <87wly5etpa.fsf@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org On 4/17/26 7:01 AM, Andrew Burgess wrote: > Simon Marchi writes: > >> There are a bunch of iteration functions that take a callback returning >> true or false to indicate whether to continue or stop iterating. These >> functions then return the same value, indicate whether the iteration was >> done until the end of interrupted. I think this is confusing and >> error-prone, as I never know which value means what. It is especially >> confusing when two opposite conventions collide, such as in >> objfile::map_symtabs_matching_filename. >> >> I propose to make that more obvious by introducing a new >> iteration_status enum with self-documenting values. >> >> I started to change the callback type >> compunit_symtab_iteration_callback, taken by >> quick_symbol_functions::search, and then followed that path to update a >> bunch of other functions. >> >> I chose the name to be kind of generic, so that it can be used for other >> similar iteration patterns. I also put it in gdbsupport, in case we >> want to use it in gdbserver too. >> >> Change-Id: I55d84d0c1af8ac0b82cc9f49ccf0d6b60e1769e0 > > >> @@ -260,30 +259,37 @@ objfile::map_symtabs_matching_filename >> /* Skip included compunits, as they are searched by >> iterate_over_one_compunit_symtab. */ >> if (symtab->user != nullptr) >> - return true; >> + return iteration_status::keep_going; >> >> - /* CALLBACK returns false to keep going and true to continue, so >> - we have to invert the result here, for search. */ >> - return !iterate_over_one_compunit_symtab (name_basename, name, real_path, >> - symtab, callback); >> + /* iterate_over_one_compunit_symtab returns true to stop, >> + convert to iteration_status. */ >> + if (iterate_over_one_compunit_symtab (name_basename, name, real_path, >> + symtab, callback) >> + == iteration_status::stop) >> + return iteration_status::stop; >> + >> + return iteration_status::keep_going; > > I think this needs fixing. You've updated > iterate_over_one_compunit_symtab to return an iteration_status, so I > think you can just do: > > return iterate_over_one_compunit_symtab (name_basename, name, real_path, > symtab, callback); > > >> }; Ah, of course. I initially did not convert iterate_over_one_compunit_symtab, which is why I had to have the if to convert from boolean to iteration_status. I then decided to convert iterate_over_one_compunit_symtab too, while at it, and left the if in. >> diff --git a/gdb/symtab.h b/gdb/symtab.h >> index 0db85bcf5baa..9e45f087adda 100644 >> --- a/gdb/symtab.h >> +++ b/gdb/symtab.h >> @@ -30,6 +30,7 @@ >> #include "gdbsupport/gdb_regex.h" >> #include "gdbsupport/enum-flags.h" >> #include "gdbsupport/function-view.h" >> +#include "gdbsupport/iteration-status.h" >> #include >> #include >> #include "gdbsupport/next-iterator.h" >> @@ -2795,8 +2796,9 @@ bool compare_filenames_for_search (const char *filename, >> Call CALLBACK with each symtab that is found. If CALLBACK returns >> true, the search stops. */ > > This comment that's just peeking in here, needs to be updated. CALLBACK > no longer returns a bool. Thanks, fixed. The comment also talks about psymtabs, which is stale, but that gets removed in a subsequent commit IIRC. >> -void iterate_over_symtabs (program_space *pspace, const char *name, >> - gdb::function_view callback); >> +void iterate_over_symtabs >> + (program_space *pspace, const char *name, >> + gdb::function_view callback); > > With these fixed, looks good. > > Approved-By: Andrew Burgess Thanks, all fixed locally for now. Simon