From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id aFOFNU0T4mnwPh4AWB0awg (envelope-from ) for ; Fri, 17 Apr 2026 07:02:37 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=fgigasXE; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id C0AB41E0C3; Fri, 17 Apr 2026 07:02:37 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIMWL_WL_HIGH,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 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 E92261E0B1 for ; Fri, 17 Apr 2026 07:02:36 -0400 (EDT) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 341184C900D8 for ; Fri, 17 Apr 2026 11:02:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 341184C900D8 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=fgigasXE Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTP id 42DFA4BA23C2 for ; Fri, 17 Apr 2026 11:02:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 42DFA4BA23C2 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 42DFA4BA23C2 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776423723; cv=none; b=X/hK57Nwxczhjfr+jm9qmchDKQOITcOQqUydIdJOs3LLxEakRWD8EcfHUPcU9I1iPJAxR4tufF6ViriEhz8vqNkSfKSX+SRZ0mMZpCtw/HPVIh8vDl8h/5zk5Flie752/wfz2GYJNSdkxNwhGtjQJtjVmLuuBZ1kf5QSzAQaJJU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776423723; c=relaxed/simple; bh=4T5pZwJYNFekm5MPnXVx0Kp+uNg5iASic+Xh5jO8/6g=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=wlAAPvfrpa7nN9p8GEQfVJKhipxz/W+H5eeoh41robBhhSYH2WU3aADCaARfE8jyhV9S3XFtvijHCHPwHdjDSupuJ6+pzDGqYNm91ujDi351d58i07V10+2ttdWqA3deAyNYRZflN5WKjzTEAEIM2LjasRU74/gODaF6EM5d2D4= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 42DFA4BA23C2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1776423722; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=45ZoY6fomnwRk9w2MDHX6Ls1LgKg3dR2B+RPoZ/RlXc=; b=fgigasXEzS4wXz6olQcuOWo+ckgJJ5J3gqwwHN9bOcfmudpU1xCErbn8BoBAwhcfOWPDJJ 7m++5mf7egu/vAwvOZ01meW4puo441KGKFwc7sukPpIX0Y1r8RYEwR/SEUvQyJe3mFOQjw bVxn1iVCM09xDKT05aHbEqku3qNIUj0= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-299-hrdNEFfwP4O2S0aebVoLGg-1; Fri, 17 Apr 2026 07:02:01 -0400 X-MC-Unique: hrdNEFfwP4O2S0aebVoLGg-1 X-Mimecast-MFC-AGG-ID: hrdNEFfwP4O2S0aebVoLGg_1776423720 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-488be33b7a6so3681955e9.0 for ; Fri, 17 Apr 2026 04:02:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776423718; x=1777028518; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=45ZoY6fomnwRk9w2MDHX6Ls1LgKg3dR2B+RPoZ/RlXc=; b=rj4NPGreqTvwh478oqdtxvifzYn4VNUAkf7Yavu0NEOO1M9hjOMb0ZuOvNmBkuYABw CgNfP+T8HXqidfBXqXvIsIn9NAo7GkPrheo+L3gwBm3iF2qSGoBEW/E0zd6a63D6seOO M0g4gPE5EDJKUZYMsWohsvqfkhZLnKRXgMtw1poXbP5jOKU1w5rXRF9PuSJ3L3rZcrry mhCT9ua94f0Tej6AOJH19X3+OXvImEDOufrodGiDC7CgLLZ//UKNs2ZD5w5swognuuA0 ZwLrmh71koGwbwMmc0XGzzWv/bAAtIEZnQM4K4XKNPrNyqHTB4ut5xvDJHRlcnhpmQt+ AoPg== X-Forwarded-Encrypted: i=1; AFNElJ9HQyJFgeo/ohztjqKooM5rbOkGTiuUy5s9OukZ0NOHScf+jhZ0J8eo3t6DWNU5XxC51EqM8mIKhGjiRQ==@sourceware.org X-Gm-Message-State: AOJu0YzTsKJ1u7R/LypMYbX5eJcd6nLrcxb2tAJPj+csVwTYESwydtkY QTcX4wjNU8JONgW6lBg6zScOHg2zzobHTFJ/xMQh+hDg/acE8w2bbDqyQl7+9h5dcZgjJqHzxMy DaoggEKGcUxMjkMjJQ0Zglrj3b+7n5bu63ajRZAiQ2uFcDuzvWahmpPB5wsW8ha9+kNrbxM8= X-Gm-Gg: AeBDievV7yjRZNI7MnfIoz2NNMokSKQox5Mq6T6Wa8y00LiDDjkaW2uNN686rKwtDe6 1Y3/ajbGiTmhCvufFmUCEZTta6z1fivSInTQMG+CSdkXRjkfzYSZLa3/h4vd9zX5NUYycLldIg4 4BGPsWbDDJg6zZtzWPUymHwZGlWWrN4D6vV9Zwb2c/qxWZZv/OtwLlHNaHmXbGXvCVpnLWlEvEV cA/6raTTZfwsUWhsEb9ORHXDvluXcvZ1cSve8ciMbM96KvSNuFUr5ajbW812iCr0JNeTMQjLdI6 2vQpCbDZccutpwNX9BhFsJs6WE3os56WrPyf+6ZnhxoARPLkIIlJVueb+tloBbj+HBO2CBSNfPD 0y3DBdP8xK4du/LkcbFCL95V2VhE= X-Received: by 2002:a05:600c:a318:b0:488:a2ac:a340 with SMTP id 5b1f17b1804b1-488fb7579demr24122105e9.12.1776423718064; Fri, 17 Apr 2026 04:01:58 -0700 (PDT) X-Received: by 2002:a05:600c:a318:b0:488:a2ac:a340 with SMTP id 5b1f17b1804b1-488fb7579demr24121605e9.12.1776423717350; Fri, 17 Apr 2026 04:01:57 -0700 (PDT) Received: from localhost ([31.111.84.232]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-488fc1393d3sm56959625e9.11.2026.04.17.04.01.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Apr 2026 04:01:55 -0700 (PDT) From: Andrew Burgess To: Simon Marchi , gdb-patches@sourceware.org Cc: Simon Marchi Subject: Re: [PATCH 03/11] gdb: introduce iteration_status enum, use it for search callbacks In-Reply-To: <20260416202408.422441-4-simon.marchi@efficios.com> References: <20260416202408.422441-1-simon.marchi@efficios.com> <20260416202408.422441-4-simon.marchi@efficios.com> Date: Fri, 17 Apr 2026 12:01:53 +0100 Message-ID: <87wly5etpa.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: kDpElbDK-2j4LVoe5-oDPCJrgkQdMXy91zEKPZNEv3I_1776423720 X-Mimecast-Originator: redhat.com Content-Type: text/plain 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 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); > }; > 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. > > -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, Andrew