Page MenuHomeFreeBSD

ktrace: make ktr_tid a long not intptr_t (NFC)
ClosedPublic

Authored by brooks on Sep 16 2022, 2:22 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sep 27 2024, 2:08 PM
Unknown Object (File)
Sep 26 2024, 9:56 AM
Unknown Object (File)
Sep 25 2024, 4:47 PM
Unknown Object (File)
Sep 24 2024, 4:37 AM
Unknown Object (File)
Sep 24 2024, 4:37 AM
Unknown Object (File)
Sep 22 2024, 11:26 PM
Unknown Object (File)
Sep 19 2024, 5:44 PM
Unknown Object (File)
Sep 19 2024, 7:37 AM
Subscribers

Details

Summary

Long ago, ktr_tid was ktr_buffer which pointed to the buffer following
the header and was used internally in the kernel. Use was removed in
efbbbf570d70b and it was repurposed as ktr_kid in c6854c347f4d8. For
ABI reasons, it stayed an intptr_t rather than becoming an lwpid_t at
the time. Since it doesn't hold a pointer any more (unless you have
a ktrace.out from 2005), change the type to long which is always the
same size on all supported architectures. Add a suggestion to change
the type to lwpid_t (__int32_t) on a future ABI break.

Remove most remaining references to ktr_buffer, retaing a comment in
kdump.c explaining why negative values are treated as 0. While here,
accept that pid_t and lwpid_t are of type int and simplify casts in
printf.

This changed was motivated by CheriBSD where intptr_t is 16-bytes
in the pure-capability ABI.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

kib added inline comments.
usr.bin/kdump/kdump.c
452–453

this assumes specific type for lwpid still

This revision is now accepted and ready to land.Sep 16 2022, 2:42 PM
usr.bin/kdump/kdump.c
452–453

It does. Changing the type of lwpid_t wouldn't be as disruptive as changing pid_t, but it seems impractical and unlikely given its part of the ABI in several places. I don't think this makes things appreciably worse.

usr.bin/kdump/kdump.c
452–453

I did not suggested changing the type of ktr_tid. Rather I mean that you should cast it to int instead of lwpid_t.