From 989a6e05ec97b2f8dc26505e4d768e7eb5430b7e Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Thu, 27 Mar 2008 23:10:22 +0000 Subject: [PATCH] Made kernel tracing safe to be used right after it has officially been initialized. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24613 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/kernel/debug/tracing.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/system/kernel/debug/tracing.cpp b/src/system/kernel/debug/tracing.cpp index 9677e508d6..f23d831694 100644 --- a/src/system/kernel/debug/tracing.cpp +++ b/src/system/kernel/debug/tracing.cpp @@ -171,7 +171,7 @@ make_space(size_t needed) static trace_entry* allocate_entry(size_t size, uint16 flags) { - if (sBuffer == NULL || size == 0 || size >= 65532) + if (sAfterLastEntry == NULL || size == 0 || size >= 65532) return NULL; InterruptsSpinLocker _(sLock); @@ -290,9 +290,8 @@ TraceEntry::operator new(size_t size, const std::nothrow_t&) throw() { #if ENABLE_TRACING return allocate_entry(size, 0); -#else - return NULL; #endif + return NULL; } @@ -300,11 +299,14 @@ TraceEntry::operator new(size_t size, const std::nothrow_t&) throw() AbstractTraceEntry::AbstractTraceEntry() - : - fThread(thread_get_current_thread_id()), - fTeam(team_get_current_team_id()), - fTime(system_time()) { + struct thread* thread = thread_get_current_thread(); + if (thread != NULL) { + fThread = thread->id; + if (thread->team) + fTeam = thread->team->id; + } + fTime = system_time(); } AbstractTraceEntry::~AbstractTraceEntry()