From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id CWTFMlNytWn8NSkAWB0awg (envelope-from ) for ; Sat, 14 Mar 2026 10:36:03 -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=fvYShb3C; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id C41171E0E1; Sat, 14 Mar 2026 10:36:03 -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 0871E1E08D for ; Sat, 14 Mar 2026 10:36:02 -0400 (EDT) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id C7B244C318B9 for ; Sat, 14 Mar 2026 14:36:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C7B244C318B9 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=fvYShb3C 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 94A8E4C318B4 for ; Sat, 14 Mar 2026 14:32:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 94A8E4C318B4 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 94A8E4C318B4 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=1773498759; cv=none; b=fY/fmFM9O77+D1pzC2VRXuOViJMlCitvDGG8F739ekUgsFKfblTccdcUIsE20ygpEDdNwjlvdDcuaX7zcJRzgHQ1ADJbUj6Ohi3flnsnxSyr7BKqIhgNsQf/LxflHqZkDp6NAQBE1S97xio3u1hNf2YvEL1QmnOhokBSU03bZZ0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1773498759; c=relaxed/simple; bh=2JFANH9h7OkN8jzkEeKwN5Q06J5KPM2P0DzbOlaHVr4=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=KYdeQBWkHaqDEqvVNM4N1qKd+IMbxNEjt1Uy+SbKGSbHALqKI874jHJbqvqNoa4R4OHxq1+HZPLZiNS3bV+ADuIxdnPicjLtG0XeF7Gx9K3PTYztWEUzrneXUvYX6wJeKWPyJ3g7xhDpgjO+NZIHGwtOwtTh1REjFeR4iF8OT5c= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 94A8E4C318B4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1773498759; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UFvlakfk+PLr8IwTL2E1KpDUtB86m+FCeg/4Tt6DR48=; b=fvYShb3CMTrqKDCzPmazixB9Xo3BuCxhCiIWwMnl2Bizch7eWLaCoBFL1HCY4XgoAh9JQx mMMnEKuhkRnRinqWcatodbHCCHW0c8QSVKWuD6+eLUW9QbwHgnLY7MtRXnELtXGdEdKFyt r0iuL+JHKX9Pp8/xRENMUO+jriSSCJA= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-149-fMNJMVN8P5GzNXyfoVScBw-1; Sat, 14 Mar 2026 10:32:37 -0400 X-MC-Unique: fMNJMVN8P5GzNXyfoVScBw-1 X-Mimecast-MFC-AGG-ID: fMNJMVN8P5GzNXyfoVScBw_1773498757 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-485350666bfso24695215e9.3 for ; Sat, 14 Mar 2026 07:32:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773498756; x=1774103556; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=UFvlakfk+PLr8IwTL2E1KpDUtB86m+FCeg/4Tt6DR48=; b=sW4AuiU/UKJVSwmIiw5ObJIKo4pHPJBBAOpL8+2NBiyktTADkNCVdtVoJLDEWntBsl 9VzL9VltcDlxLRwW41QOU7F+hOH5lidgb20NVz/ZP6Ug//bu/xY3zt6xBx362pF8QdvO E6iQ06TFfW6nNLWWp289ytJT13QALwibYAKrX2OKOMLrO0osCwO4uii/yhOKHBNwTbQd sHtRpU0p+8g2e5r8IaFPgxP+9YbI6EePc8f4KS6fhCkvGnvAmUYH9bX4wWmvlu+f5cX4 gwUM1+6LhT6zU0CLRugaIyvABrLLNwfZGXhA/+RvzzAXnySjC8MVlhWjiP+X5gAG8/P2 +A0A== X-Gm-Message-State: AOJu0Yx8vCdsyCGmJv6vIg8PmjaBc12ExfzFWLP9Omdxm/0Q+UIz07aS NNh5P1gzZHfR+Lo2KFPMIuuTBIwitKQ6PRvqX+1xTufYkSZSFfRGlxVc24fJZiHbn4bUV1Hsx+N NlSjeZoRyXVcXevPcRBI1JaP7OgK3MryRhXBg9ebpog7wPbhuPDqmtt7qS4ZCQ84ND9yz2+4n2I 3OZVRlfPL7f0ynbmtZeBY+8UdedcCqT6QIgjaoJT859FV2tpc= X-Gm-Gg: ATEYQzybTlXgdrKAEhbWBI10q+sUOS+AJnbarRA6eV7w9d7+RBGi5+4T1D5q30VbSJi qb9E+BJazbCJbL8R3ktAU1EQMEG3cl2sZ4IkobDffaOUYGGxtJqL+Y6+nrZ2Vd4yydywq618hos GxfOTMgYnAh4J4lqdtdiV0GLYby7lHqYXUb8tjqZqxOviWPSIxhNdTZ+zahJqC3I1h1T+1QXtmt ADJ8YGtO4I0gqMjLi/RIavELXkjqdjyBsSYmZ5EmdYZBs+lBhaGSTA8Nj+pM3d8HreAxz79V+P2 FnuO3gAD8qHnrzc3IHlTlhwhm712uhva1tY4Y2VIQOl4iNfvcTBQj5IcN8vP0PinzQjINcEEYF9 ovGAVIDt2pAc2QgosdwSRY0Id9j9GOIzNmsOD3WdColkr0w== X-Received: by 2002:a05:600c:4753:b0:485:3fe6:2209 with SMTP id 5b1f17b1804b1-485566d516dmr110240975e9.11.1773498756149; Sat, 14 Mar 2026 07:32:36 -0700 (PDT) X-Received: by 2002:a05:600c:4753:b0:485:3fe6:2209 with SMTP id 5b1f17b1804b1-485566d516dmr110240335e9.11.1773498755469; Sat, 14 Mar 2026 07:32:35 -0700 (PDT) Received: from localhost (92.40.185.182.threembb.co.uk. [92.40.185.182]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4854b5e912fsm753917775e9.2.2026.03.14.07.32.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 14 Mar 2026 07:32:34 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCH 4/5] gdb: remove pre-loop callback from gdbarch_read_core_file_mappings Date: Sat, 14 Mar 2026 14:32:21 +0000 Message-Id: X-Mailer: git-send-email 2.25.4 In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: NLyP0WQl08GbVRNG-7SHTVfl7jhFNMV_PmIxmrn8hvg_1773498757 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true 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 Currently only one target, Linux, implements gdbarch_read_core_file_mappings, with linux_read_core_file_mappings. There is one use of gdbarch_read_core_file_mappings in corelow.c, and one direct use of linux_read_core_file_mappings in linux-tdep.c. The gdbarch_read_core_file_mappings takes two callbacks, a pre-loop callback, which is called once, then a loop callback which is called multiple times for each mapping that is discovered. The only user of the pre-loop callback is in linux-tdep.c. Within corelow.c, the pre-loop callback is not used. In the next commit I plan to change linux_read_core_file_mappings, and as a result of this change the use of linux_read_core_file_mappings in linux-tdep.c will no longer be able to make use of the pre-loop callback. This means that, after the next commit, there will be no users of the pre-loop callback. Additionally, the pre-loop callback takes an argument, the number of mappings found. After the next commit it is no longer clear what number we should pass here as the next commit will introduce the idea of there being two types of mapping, anonymous and non-anonymous. Should the number passed to the pre-loop callback be the combined total? Or should we count each separately? I could try to answer this question. Or I could just delete the pre-loop callback from gdbarch_read_core_file_mappings. This commit takes the second approach and deletes the callback. As part of this work I've updated linux_core_info_proc_mappings, which is the function that calls linux_read_core_file_mappings, so that the pre-loop callback is no longer used. The lambda capture on the loop callback needed to change from [=] to [&] with this commit so `emitter` from the enclosing scope can be modified. There is one subtle change of behaviour in linux_core_info_proc_mappings after this commit. Previously, linux_core_info_proc_mappings would print the table header so long as the core file had a valid NT_FILE note, even if that note contained no actual file mappings. With the removal of the pre-loop callback I had a choice, either always print the table header, or only print the table header if I saw some entries being printed. I selected the second choice as that seemed like the smallest change, but there is a change here. If a user has a core file with an NT_FILE note containing no mapped files, then the table header will no longer be printed. Hopefully this isn't too disruptive. This is a refactoring commit in preparation for the next one. --- gdb/arch-utils.c | 1 - gdb/arch-utils.h | 1 - gdb/corelow.c | 10 ++-------- gdb/gdbarch-gen.c | 4 ++-- gdb/gdbarch-gen.h | 4 ++-- gdb/gdbarch.h | 5 +---- gdb/gdbarch_components.py | 1 - gdb/linux-tdep.c | 41 +++++++++++++++------------------------ 8 files changed, 23 insertions(+), 44 deletions(-) diff --git a/gdb/arch-utils.c b/gdb/arch-utils.c index 9d3dbfa2d81..f649cfae82c 100644 --- a/gdb/arch-utils.c +++ b/gdb/arch-utils.c @@ -1077,7 +1077,6 @@ void default_read_core_file_mappings (struct gdbarch *gdbarch, struct bfd *cbfd, - read_core_file_mappings_pre_loop_ftype pre_loop_cb, read_core_file_mappings_loop_ftype loop_cb) { } diff --git a/gdb/arch-utils.h b/gdb/arch-utils.h index 670136c9cac..7d16b219106 100644 --- a/gdb/arch-utils.h +++ b/gdb/arch-utils.h @@ -375,7 +375,6 @@ extern std::string default_get_pc_address_flags (const frame_info_ptr &frame, extern void default_read_core_file_mappings (struct gdbarch *gdbarch, struct bfd *cbfd, - read_core_file_mappings_pre_loop_ftype pre_loop_cb, read_core_file_mappings_loop_ftype loop_cb); /* Default implementation of gdbarch_core_parse_exec_context. Returns diff --git a/gdb/corelow.c b/gdb/corelow.c index e540e44474b..d63dd5f8f0d 100644 --- a/gdb/corelow.c +++ b/gdb/corelow.c @@ -2130,14 +2130,8 @@ gdb_read_core_file_mappings (struct gdbarch *gdbarch, struct bfd *cbfd) /* See linux_read_core_file_mappings() in linux-tdep.c for an example read_core_file_mappings method. */ gdbarch_read_core_file_mappings (gdbarch, cbfd, - /* After determining the number of mappings, read_core_file_mappings - will invoke this lambda. */ - [&] (ULONGEST) - { - }, - - /* read_core_file_mappings will invoke this lambda for each mapping - that it finds. */ + /* gdbarch_read_core_file_mappings will invoke this lambda for each + mapping that it finds. */ [&] (ULONGEST start, ULONGEST end, ULONGEST file_ofs, const char *filename, const bfd_build_id *build_id) { diff --git a/gdb/gdbarch-gen.c b/gdb/gdbarch-gen.c index 573f6eefc96..f3a038b4a51 100644 --- a/gdb/gdbarch-gen.c +++ b/gdb/gdbarch-gen.c @@ -5202,13 +5202,13 @@ set_gdbarch_get_pc_address_flags (struct gdbarch *gdbarch, } void -gdbarch_read_core_file_mappings (struct gdbarch *gdbarch, struct bfd *cbfd, read_core_file_mappings_pre_loop_ftype pre_loop_cb, read_core_file_mappings_loop_ftype loop_cb) +gdbarch_read_core_file_mappings (struct gdbarch *gdbarch, struct bfd *cbfd, read_core_file_mappings_loop_ftype loop_cb) { gdb_assert (gdbarch != NULL); gdb_assert (gdbarch->read_core_file_mappings != NULL); if (gdbarch_debug >= 2) gdb_printf (gdb_stdlog, "gdbarch_read_core_file_mappings called\n"); - gdbarch->read_core_file_mappings (gdbarch, cbfd, pre_loop_cb, loop_cb); + gdbarch->read_core_file_mappings (gdbarch, cbfd, loop_cb); } void diff --git a/gdb/gdbarch-gen.h b/gdb/gdbarch-gen.h index 1ff02b1067c..dbc0a070b7c 100644 --- a/gdb/gdbarch-gen.h +++ b/gdb/gdbarch-gen.h @@ -1691,8 +1691,8 @@ extern void set_gdbarch_get_pc_address_flags (struct gdbarch *gdbarch, gdbarch_g /* Read core file mappings */ -typedef void (gdbarch_read_core_file_mappings_ftype) (struct gdbarch *gdbarch, struct bfd *cbfd, read_core_file_mappings_pre_loop_ftype pre_loop_cb, read_core_file_mappings_loop_ftype loop_cb); -extern void gdbarch_read_core_file_mappings (struct gdbarch *gdbarch, struct bfd *cbfd, read_core_file_mappings_pre_loop_ftype pre_loop_cb, read_core_file_mappings_loop_ftype loop_cb); +typedef void (gdbarch_read_core_file_mappings_ftype) (struct gdbarch *gdbarch, struct bfd *cbfd, read_core_file_mappings_loop_ftype loop_cb); +extern void gdbarch_read_core_file_mappings (struct gdbarch *gdbarch, struct bfd *cbfd, read_core_file_mappings_loop_ftype loop_cb); extern void set_gdbarch_read_core_file_mappings (struct gdbarch *gdbarch, gdbarch_read_core_file_mappings_ftype *read_core_file_mappings); /* Return true if the target description for all threads should be read from the diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h index 356aae0fee8..7d0f46ab8e2 100644 --- a/gdb/gdbarch.h +++ b/gdb/gdbarch.h @@ -121,10 +121,7 @@ enum class memtag_type allocation, }; -/* Callback types for 'read_core_file_mappings' gdbarch method. */ - -using read_core_file_mappings_pre_loop_ftype = - gdb::function_view; +/* Callback type for 'read_core_file_mappings' gdbarch method. */ using read_core_file_mappings_loop_ftype = gdb::function_viewbuild_id = orig_build_id; - pre_loop_cb (count); /* Vector to collect proc mappings. */ struct proc_mapping @@ -1274,11 +1267,8 @@ linux_read_core_file_mappings }); /* Call loop_cb with sorted proc mappings. */ - for (int i = 0; i < count; i++) - { - const auto &m = proc_mappings[i]; - loop_cb (m.start, m.end, m.file_ofs, m.filename, m.build_id); - } + for (const auto &m : proc_mappings) + loop_cb (m.start, m.end, m.file_ofs, m.filename, m.build_id); } /* Implement "info proc mappings" for corefile CBFD. */ @@ -1290,21 +1280,22 @@ linux_core_info_proc_mappings (struct gdbarch *gdbarch, struct bfd *cbfd, std::optional emitter; linux_read_core_file_mappings (gdbarch, cbfd, - [&] (ULONGEST count) - { - gdb_printf (_("Mapped address spaces:\n\n")); - emitter.emplace (current_uiout, 5, -1, "ProcMappings"); - int width = gdbarch_addr_bit (gdbarch) == 32 ? 10 : 18; - current_uiout->table_header (width, ui_left, "start", "Start Addr"); - current_uiout->table_header (width, ui_left, "end", "End Addr"); - current_uiout->table_header (width, ui_left, "size", "Size"); - current_uiout->table_header (width, ui_left, "offset", "Offset"); - current_uiout->table_header (0, ui_left, "objfile", "File"); - current_uiout->table_body (); - }, - [=] (ULONGEST start, ULONGEST end, ULONGEST file_ofs, + [&] (ULONGEST start, ULONGEST end, ULONGEST file_ofs, const char *filename, const bfd_build_id *build_id) { + if (!emitter.has_value ()) + { + gdb_printf (_("Mapped address spaces:\n\n")); + emitter.emplace (current_uiout, 5, -1, "ProcMappings"); + int width = gdbarch_addr_bit (gdbarch) == 32 ? 10 : 18; + current_uiout->table_header (width, ui_left, "start", "Start Addr"); + current_uiout->table_header (width, ui_left, "end", "End Addr"); + current_uiout->table_header (width, ui_left, "size", "Size"); + current_uiout->table_header (width, ui_left, "offset", "Offset"); + current_uiout->table_header (0, ui_left, "objfile", "File"); + current_uiout->table_body (); + } + ui_out_emit_tuple tuple_emitter (current_uiout, nullptr); current_uiout->field_core_addr ("start", gdbarch, start); current_uiout->field_core_addr ("end", gdbarch, end); -- 2.25.4