Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Srinath Parvathaneni <Srinath.Parvathaneni@arm.com>
To: gdb-patches <gdb-patches@sourceware.org>
Cc: Luis Machado <luis.machado.foss@gmail.com>,
	Thiago Jung Bauermann <thiago.bauermann@linaro.org>,
	Yury Khrustalev <Yury.Khrustalev@arm.com>,
	Andre Simoes Dias Vieira <Andre.SimoesDiasVieira@arm.com>,
	Guinevere Larsen <guinevere@redhat.com>,
	Matthieu Longo <Matthieu.Longo@arm.com>
Subject: [RFC] gdb/linux-tdep: Show per-thread overlay and effective permissions in info proc mappings
Date: Mon, 16 Nov 2026 14:12:32 +0000	[thread overview]
Message-ID: <DB9PR08MB714505E78EBED3CAB6EFD43D9B7C2@DB9PR08MB7145.eurprd08.prod.outlook.com> (raw)

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

             reply	other threads:[~2026-11-16 14:13 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-16 14:12 Srinath Parvathaneni [this message]
2026-11-20  7:13 ` Thiago Jung Bauermann
2026-11-26 12:17   ` Matthieu Longo

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=DB9PR08MB714505E78EBED3CAB6EFD43D9B7C2@DB9PR08MB7145.eurprd08.prod.outlook.com \
    --to=srinath.parvathaneni@arm.com \
    --cc=Andre.SimoesDiasVieira@arm.com \
    --cc=Matthieu.Longo@arm.com \
    --cc=Yury.Khrustalev@arm.com \
    --cc=gdb-patches@sourceware.org \
    --cc=guinevere@redhat.com \
    --cc=luis.machado.foss@gmail.com \
    --cc=thiago.bauermann@linaro.org \
    /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