* [RFC] gdb/linux-tdep: Show per-thread overlay and effective permissions in info proc mappings
@ 2026-11-16 14:12 Srinath Parvathaneni
2026-11-20 7:13 ` Thiago Jung Bauermann
0 siblings, 1 reply; 3+ messages in thread
From: Srinath Parvathaneni @ 2026-11-16 14:12 UTC (permalink / raw)
To: gdb-patches
Cc: Luis Machado, Thiago Jung Bauermann, Yury Khrustalev,
Andre Simoes Dias Vieira, Guinevere Larsen, Matthieu Longo
Hi all,
I've been working on extending `info proc mappings` to show memory Protection
Keys (PKeys), and I'd like to get some feedback on adding per-thread overlay
and effective permissions.
I've got the PKey extraction from `/proc/PID/smaps` working locally, but haven't
submitted that part upstream yet.
On AArch64 Linux, threads can have different effective permissions for the same
memory mapping because each thread has its own `POR_EL0` value. I'd like to make
this information visible directly in `info proc mappings`.
I'm thinking of adding two optional arguments:
(gdb) info proc mappings [PID] [-threads | -thread=N]
* `-threads` would show overlay and effective permissions for all threads of the
current inferior.
* `-thread=N` would show permissions for a specific GDB thread, using its
per-inferior thread number.
Without either option, the command would continue to show the usual mappings,
with the PKey column when available.
Here are a few examples of how the output would look. The mapping tables are
shortened for readability.
1. Normal mappings with PKey (working locally)
(gdb) info proc mappings
process 847
Start Addr End Addr Perms PKey File
0x400000 0x401000 r-xp 0 /tmp/a.out
0x500000 0x502000 rw-p 1 [heap]
2. Show permissions for all threads
(gdb) info proc mappings -threads
process 847
Start Addr End Addr Perms PKey File
0x400000 0x401000 r-xp 0 /tmp/a.out
Thread 1: effective perms: r-x overlay perms: rwx
Thread 2: effective perms: r-x overlay perms: rwx
0x500000 0x502000 rw-p 1 [heap]
Thread 1: effective perms: rw- overlay perms: rwx
Thread 2: effective perms: r-- overlay perms: r--
3. Show permissions for a specific thread
(gdb) info proc mappings 847 -thread=2
process 847
Start Addr End Addr Perms PKey File
0x400000 0x401000 r-xp 0 /tmp/a.out
Thread 2: effective perms: r-x overlay perms: rwx
0x500000 0x502000 rw-p 1 [heap]
Thread 2: effective perms: r-- overlay perms: r--
4. Inspect mappings of another process
(gdb) info proc mappings 950
process 950
Start Addr End Addr Perms PKey File
0x700000 0x701000 r-xp 0 /tmp/worker
0x710000 0x712000 rw-p 3 [heap]
For now, I'd limit the thread-specific output to the current inferior. If a
different PID is specified with `-threads` or `-thread=N`, the command would
report an error.
5. When PKey information isn't available
If the kernel doesn't report `ProtectionKey` in `smaps`, the normal mappings
output would remain unchanged, without the PKey column.
If thread information is explicitly requested, I'd report an error:
(gdb) info proc mappings -threads
ProtectionKey information is unavailable; thread permissions cannot be displayed.
6. When PKey is available but overlay permissions aren't
GDB already supports `POR_EL0` through `NT_ARM_POE` on AArch64 Linux. However,
other architectures can report PKeys without having `POR_EL0`, and the register
might also be unavailable on some targets.
In that case, I'd report:
(gdb) info proc mappings -thread=2
Overlay permissions for ProtectionKey 1 are unavailable for Thread 2.
The idea is to keep the existing command behaviour unchanged unless thread
information is explicitly requested. Thread details would only be shown for
mappings with a reported PKey, including PKey 0.
Before I start implementing the thread-specific part, I'd appreciate feedback on
a few things:
1. Does adding this information to `info proc mappings` seem reasonable?
2. Do `-threads` and `-thread=N` look suitable?
3. Does the indented output for each thread look sensible?
4. Have I missed any scenarios or existing behaviour that these changes might
affect?
Note: The `-threads` option could produce substantial output for processes with
many mappings and threads. I considered limiting or grouping the output,
but GDB already supports pagination for long command output. I intend to
keep the output straightforward and verify that pagination, including
quitting with `q`, works correctly with the additional thread information.
Regards,
Srinath
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [RFC] gdb/linux-tdep: Show per-thread overlay and effective permissions in info proc mappings
2026-11-16 14:12 [RFC] gdb/linux-tdep: Show per-thread overlay and effective permissions in info proc mappings Srinath Parvathaneni
@ 2026-11-20 7:13 ` Thiago Jung Bauermann
2026-11-26 12:17 ` Matthieu Longo
0 siblings, 1 reply; 3+ messages in thread
From: Thiago Jung Bauermann @ 2026-11-20 7:13 UTC (permalink / raw)
To: Srinath Parvathaneni
Cc: gdb-patches, Luis Machado, Yury Khrustalev,
Andre Simoes Dias Vieira, Guinevere Larsen, Matthieu Longo
Hello Srinath,
Sorry for the delay in answering.
Srinath Parvathaneni <Srinath.Parvathaneni@arm.com> writes:
> Hi all,
>
> I've been working on extending `info proc mappings` to show memory Protection
> Keys (PKeys), and I'd like to get some feedback on adding per-thread overlay
> and effective permissions.
Thank you for the detailed explanation and examples.
> Before I start implementing the thread-specific part, I'd appreciate feedback on
> a few things:
>
> 1. Does adding this information to `info proc mappings` seem reasonable?
Yes, I think it's a good place to put it.
> 2. Do `-threads` and `-thread=N` look suitable?
Yes, except for the equal sign separating the option and its value.
AFAIK no GDB command option uses this convention. `-thread N` is what we use.
> 3. Does the indented output for each thread look sensible?
It does.
> 4. Have I missed any scenarios or existing behaviour that these changes might
> affect?
I can't think of anything.
> Note: The `-threads` option could produce substantial output for processes with
> many mappings and threads. I considered limiting or grouping the output,
> but GDB already supports pagination for long command output. I intend to
> keep the output straightforward and verify that pagination, including
> quitting with `q`, works correctly with the additional thread information.
I agree that the existing pagination that GDB does is enough.
--
Thiago
(he/him)
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFC] gdb/linux-tdep: Show per-thread overlay and effective permissions in info proc mappings
2026-11-20 7:13 ` Thiago Jung Bauermann
@ 2026-11-26 12:17 ` Matthieu Longo
0 siblings, 0 replies; 3+ messages in thread
From: Matthieu Longo @ 2026-11-26 12:17 UTC (permalink / raw)
To: Thiago Jung Bauermann, Srinath Parvathaneni
Cc: gdb-patches, Luis Machado, Yury Khrustalev,
Andre Simoes Dias Vieira, Guinevere Larsen
On 20/11/2026 07:13, Thiago Jung Bauermann wrote:
>> 2. Do `-threads` and `-thread=N` look suitable?
> Yes, except for the equal sign separating the option and its value.
> AFAIK no GDB command option uses this convention. `-thread N` is what we use.
`info proc mappings`'s output could be filtered according to the memory area, pkey, base permissions.
In the same way, the detailed output per thread could be filtered by thread ID, overlay permissions,
and effective permissions.
Please note that I am not saying that we should implement a filter for each of those dimensions.
If I followed Srinath's thoughts correctly, `-threads` mean "display informations related to threads
(if available)".
So filtering threads with something like `-threads=ID1,ID2,ID3` would seem off, hence the proposal
of Srinath to add filtering with a different option `-thread THREAD_ID`.
@Srinath: please correct me if my understanding is wrong.
My issue with this approach is that it makes the filtering very verbose if we would like to filter
on several threads --> -thread THREAD_ID1 -thread THREAD_ID2 ...
Why not filtering options with a common prefix `-filter-${DIM} PARAM1,PARAM2,PARAM3` ?
And allow several filtering values as a list ?
If we want to add a new dimension later, we could do it easily without name collision.
However, since the equal sign separating its option and values is not the standard approach in GDB,
`-option VALUE1,VALUE2,VALUE3` might be more difficult to parse, I don't know.
Matthieu
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-26 12:19 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-16 14:12 [RFC] gdb/linux-tdep: Show per-thread overlay and effective permissions in info proc mappings Srinath Parvathaneni
2026-11-20 7:13 ` Thiago Jung Bauermann
2026-11-26 12:17 ` Matthieu Longo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox