From c53508b7305c6b91c250a39fd90bf16ea949484a Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Thu, 11 Jul 2013 16:12:19 +0200 Subject: [PATCH] kernel tracing: implement fallback for meta data allocation We the meta data area couldn't be allocated in any of the supported (reattachable) places, just use a static allocation. The tracing feature wouldn't be available at all in such a case. --- src/system/kernel/debug/tracing.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/system/kernel/debug/tracing.cpp b/src/system/kernel/debug/tracing.cpp index aa9c880243..7855455338 100644 --- a/src/system/kernel/debug/tracing.cpp +++ b/src/system/kernel/debug/tracing.cpp @@ -127,8 +127,8 @@ private: uint32 fMagic3; }; -static TracingMetaData sDummyTracingMetaData; -static TracingMetaData* sTracingMetaData = &sDummyTracingMetaData; +static TracingMetaData sFallbackTracingMetaData; +static TracingMetaData* sTracingMetaData = &sFallbackTracingMetaData; static bool sTracingDataRecovered = false; @@ -525,7 +525,15 @@ TracingMetaData::_CreateMetaDataArea(bool findPrevious, area_id& _area, delete_area(area); } - return B_ENTRY_NOT_FOUND; + if (findPrevious) + return B_ENTRY_NOT_FOUND; + + // We could allocate any of the standard locations. Instead of failing + // entirely, we use the static meta data. The tracing buffer won't be + // reattachable in the next session, but at least we can use it in this + // session. + _metaData = &sFallbackTracingMetaData; + return B_OK; } @@ -1786,7 +1794,8 @@ tracing_init(void) #if ENABLE_TRACING status_t result = TracingMetaData::Create(sTracingMetaData); if (result != B_OK) { - sTracingMetaData = &sDummyTracingMetaData; + memset(&sFallbackTracingMetaData, 0, sizeof(sFallbackTracingMetaData)); + sTracingMetaData = &sFallbackTracingMetaData; return result; }