From: Kevin Buettner <kevinb@redhat.com>
To: gdb-patches@sourceware.org
Cc: Tom de Vries <tdevries@suse.de>, Kevin Buettner <kevinb@redhat.com>
Subject: [PATCH] gcore: Query auxv for AT_PAGESZ in gcore_copy_callback
Date: Tue, 17 Feb 2026 19:09:48 -0700 [thread overview]
Message-ID: <20260218021217.1821113-1-kevinb@redhat.com> (raw)
This is a followup patch to commit c1da013915e, titled "gcore: Handle
unreadable pages within readable memory regions".
In his review of that earlier patch, Tom de Vries recommended using
target_auxv_search with AT_PAGESZ to find the page size if it's
available; this patch implements that suggestion. As before, a 4k
fallback size is used should the search for an AT_PAGESZ value not
succeed.
---
gdb/gcore.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/gdb/gcore.c b/gdb/gcore.c
index 7bf2f00e866..66a9f6c4153 100644
--- a/gdb/gcore.c
+++ b/gdb/gcore.c
@@ -36,6 +36,7 @@
#include "gdbsupport/gdb_unlinker.h"
#include "gdbsupport/byte-vector.h"
#include "gdbsupport/scope-exit.h"
+#include "auxv.h"
/* To generate sparse cores, we look at the data to write in chunks of
this size when considering whether to skip the write. Only if we
@@ -766,6 +767,11 @@ gcore_copy_callback (bfd *obfd, asection *osec)
size = std::min (total_size, (bfd_size_type) MAX_COPY_BYTES);
gdb::byte_vector memhunk (size);
+ bfd_size_type page_size = FALLBACK_PAGE_SIZE;
+ CORE_ADDR at_pagesz;
+ if (target_auxv_search (AT_PAGESZ, &at_pagesz) > 0)
+ page_size = (bfd_size_type) at_pagesz;
+
while (total_size > 0)
{
if (size > total_size)
@@ -786,8 +792,7 @@ gcore_copy_callback (bfd *obfd, asection *osec)
while (remaining > 0)
{
- bfd_size_type chunk_size
- = std::min (remaining, (bfd_size_type) FALLBACK_PAGE_SIZE);
+ bfd_size_type chunk_size = std::min (remaining, page_size);
if (target_read_memory (addr, p, chunk_size) != 0)
{
--
2.52.0
next reply other threads:[~2026-02-18 2:13 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-18 2:09 Kevin Buettner [this message]
2026-02-18 8:43 ` Tom de Vries
2026-02-21 19:47 ` Kevin Buettner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260218021217.1821113-1-kevinb@redhat.com \
--to=kevinb@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=tdevries@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox