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)
Dec 20 2023, 2:54 AM
Unknown Object (File)
Oct 13 2023, 3:40 PM
Unknown Object (File)
Oct 11 2023, 5:18 PM
Unknown Object (File)
Aug 1 2023, 11:05 AM
Unknown Object (File)
Aug 1 2023, 11:04 AM
Unknown Object (File)
Aug 1 2023, 10:58 AM
Unknown Object (File)
Aug 1 2023, 10:48 AM
Unknown Object (File)
Jul 6 2023, 11:05 PM
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.