On 2/9/26 10:56, Minsoo Choo wrote:
On Monday, February 9th, 2026 at 10:12 AM, John Baldwin <[email protected]>
wrote:
On 2/8/26 23:18, Konstantin Belousov wrote:
The branch main has been updated by kib:
URL:
https://cgit.FreeBSD.org/src/commit/?id=8f23665fed2fbaf4481359b4d2fcdd7b9feb40e3
commit 8f23665fed2fbaf4481359b4d2fcdd7b9feb40e3
Author: Minsoo Choo [email protected]
AuthorDate: 2026-02-06 20:03:53 +0000
Commit: Konstantin Belousov [email protected]
CommitDate: 2026-02-09 04:17:16 +0000
pcb.h: mark struct pcb to be preserved
There are programs that depend on this structure (e.g. kernel debuggers)
that breaks when the ABI changes.
Signed-off-by: Minsoo Choo [email protected]
Reviewed by: kib
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D55149
Hmmm, I think it is useful to know which fields debuggers use (typically just
registers) vs which ones can be safely changed without impacting debuggers.
--
John Baldwin
In the review, kib said:
I had to add and preserve the padding fields pcb_pad in the amd64 structure to
be compatible with kgdb at least. This makes me sure that the whole pcb layout
is fixed by ABI.
It is no longer needed and hasn't been needed in a decade. Back when the field
was
first added, kgdb did indeed assume a fixed size for `struct pcb`. However,
back in
2015 I added a pcb_size variable that debuggers can use to determine this size
(to properly index the stoppcbs[] array) even if debug symbols weren't present:
commit 645743ea99829e6d578cca5a580cf0a4102fb7dd
Author: John Baldwin <[email protected]>
Date: Thu Nov 12 22:00:59 2015 +0000
Export various helper variables describing the layout and size of
certain kernel structures for use by debuggers. This mostly aids
in examining cores from a kernel without debug symbols as a debugger
can infer these values if debug symbols are available.
One set of variables describes the layout of 'struct linker_file' to
walk the list of loaded kernel modules.
A second set of variables describes the layout of 'struct proc' and
'struct thread' to walk the list of processes in the kernel and the
threads in each process.
The 'pcb_size' variable is used to index into the stoppcbs[] array.
The 'vm_maxuser_address' is used to distinguish kernel virtual addresses
from user addresses. This doesn't have to be perfect, and
'vm_maxuser_address' is a cheap and simple way to differentiate kernel
pointers from simple values like TIDs and PIDs.
While here, annotate the fields in struct pcb used by kgdb on amd64
and i386 to note that their ABI should be preserved. Annotations for
other platforms will be added in the future.
This was even the commit that added the annotations just removed, so a simple
blame for why the annotations were present would have turned this up.
--
John Baldwin