[Kernel] Add null-safe XThread::TryGetCurrentThread() accessor
The additive event_log extraction tracer needs a current-thread lookup that returns nullptr instead of asserting when called from boot code before any XThread exists (GetCurrentThread asserts on non-guest threads). New read-only static accessor over the thread-local; no behaviour change. Fixes the native Linux build of the phase-a args/file.read tracer. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -117,6 +117,8 @@ XThread* XThread::GetCurrentThread() {
|
|||||||
return thread;
|
return thread;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
XThread* XThread::TryGetCurrentThread() { return current_xthread_tls_; }
|
||||||
|
|
||||||
uint32_t XThread::GetCurrentThreadHandle() {
|
uint32_t XThread::GetCurrentThreadHandle() {
|
||||||
XThread* thread = XThread::GetCurrentThread();
|
XThread* thread = XThread::GetCurrentThread();
|
||||||
return thread->handle();
|
return thread->handle();
|
||||||
|
|||||||
@@ -408,6 +408,11 @@ class XThread : public XObject, public cpu::Thread {
|
|||||||
static bool IsInThread(XThread* other);
|
static bool IsInThread(XThread* other);
|
||||||
static bool IsInThread();
|
static bool IsInThread();
|
||||||
static XThread* GetCurrentThread();
|
static XThread* GetCurrentThread();
|
||||||
|
// Null-safe variant of GetCurrentThread: returns nullptr (instead of
|
||||||
|
// asserting) when the calling OS thread is not a guest XThread. Used by
|
||||||
|
// additive instrumentation that can fire from boot code before any XThread
|
||||||
|
// exists. Read-only accessor; no behaviour change.
|
||||||
|
static XThread* TryGetCurrentThread();
|
||||||
static uint32_t GetCurrentThreadHandle();
|
static uint32_t GetCurrentThreadHandle();
|
||||||
static uint32_t GetCurrentThreadId();
|
static uint32_t GetCurrentThreadId();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user