* [PATCH] gcore: Query auxv for AT_PAGESZ in gcore_copy_callback
@ 2026-02-18 2:09 Kevin Buettner
2026-02-18 8:43 ` Tom de Vries
0 siblings, 1 reply; 3+ messages in thread
From: Kevin Buettner @ 2026-02-18 2:09 UTC (permalink / raw)
To: gdb-patches; +Cc: Tom de Vries, Kevin Buettner
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
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] gcore: Query auxv for AT_PAGESZ in gcore_copy_callback
2026-02-18 2:09 [PATCH] gcore: Query auxv for AT_PAGESZ in gcore_copy_callback Kevin Buettner
@ 2026-02-18 8:43 ` Tom de Vries
2026-02-21 19:47 ` Kevin Buettner
0 siblings, 1 reply; 3+ messages in thread
From: Tom de Vries @ 2026-02-18 8:43 UTC (permalink / raw)
To: Kevin Buettner, gdb-patches
On 2/18/26 3:09 AM, Kevin Buettner wrote:
> 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.
Hi Kevin,
LGTM.
Approved-By: Tom de Vries <tdevries@suse.de>
Thanks,
- Tom
> ---
> 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)
> {
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] gcore: Query auxv for AT_PAGESZ in gcore_copy_callback
2026-02-18 8:43 ` Tom de Vries
@ 2026-02-21 19:47 ` Kevin Buettner
0 siblings, 0 replies; 3+ messages in thread
From: Kevin Buettner @ 2026-02-21 19:47 UTC (permalink / raw)
To: gdb-patches
On Wed, 18 Feb 2026 09:43:04 +0100
Tom de Vries <tdevries@suse.de> wrote:
> On 2/18/26 3:09 AM, Kevin Buettner wrote:
> > 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.
>
> Hi Kevin,
>
> LGTM.
>
> Approved-By: Tom de Vries <tdevries@suse.de>
Thanks, pushed.
Kevin
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-02-21 19:48 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-02-18 2:09 [PATCH] gcore: Query auxv for AT_PAGESZ in gcore_copy_callback Kevin Buettner
2026-02-18 8:43 ` Tom de Vries
2026-02-21 19:47 ` Kevin Buettner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox