Page MenuHomeFreeBSD

kdb: Handle process enumeration before procinit()
ClosedPublic

Authored by mhorne on Aug 10 2021, 11:11 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Apr 26, 6:25 PM
Unknown Object (File)
Thu, Apr 25, 9:04 PM
Unknown Object (File)
Tue, Apr 23, 11:01 AM
Unknown Object (File)
Thu, Apr 18, 6:46 AM
Unknown Object (File)
Tue, Apr 16, 9:45 PM
Unknown Object (File)
Feb 26 2024, 3:43 PM
Unknown Object (File)
Jan 19 2024, 8:43 PM
Unknown Object (File)
Jan 10 2024, 12:11 AM
Subscribers

Details

Summary

Make kdb_thr_first() and kdb_thr_next() return sane values if the
allproc list and pidhashtbl haven't been initialized yet. This can
happen if the debugger is entered very early on, for example with the
'-d' boot flag.

This allows remote gdb to attach at such a time, and fixes some ddb
commands like 'show threads'.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 40998
Build 37887: arc lint + arc unit

Event Timeline

This seems sane to me.

This revision is now accepted and ready to land.Aug 10 2021, 11:12 PM
sys/kern/subr_kdb.c
612

Why not check pidhashtbl != NULL instead?

656

Similarly here, we could check pidhashtbl != NULL after checking TAILQ_NEXT(thr, td_plist).

sys/kern/subr_kdb.c
612

Sure, this is slightly preferable.

656

Why is it better after this check? It doesn't seem possible for td_plist to be populated but pidhashtbl be NULL.

sys/kern/subr_kdb.c
656

It's not possible today, it just seemed very slightly cleaner to me to not make that assumption, supposing that someone might someday add a static thread1 to proc0 or something.

Update with markj's feedback. Keep the allproc initialization bit, as it may be checked early by db_ps().

This revision now requires review to proceed.Aug 11 2021, 3:04 PM
mhorne marked 3 inline comments as done.

Also give pidhashtbl a specific initial value of NULL. NFC, but semantically correct.

This revision is now accepted and ready to land.Aug 11 2021, 3:15 PM