From 75088a863bbfcdc967650b9cad8284b623020154 Mon Sep 17 00:00:00 2001 From: Michael Lotz Date: Fri, 4 Nov 2011 18:03:34 +0000 Subject: [PATCH] Move AllocationTrackingInfo into a header. This way it can be re-used outside of the slab code. It is generic as it only contains the link to a tracing entry and not any application specific info. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43188 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/private/kernel/AllocationTracking.h | 60 +++++++++++++++++++++ src/system/kernel/slab/slab_debug.h | 39 +------------- 2 files changed, 61 insertions(+), 38 deletions(-) create mode 100644 headers/private/kernel/AllocationTracking.h diff --git a/headers/private/kernel/AllocationTracking.h b/headers/private/kernel/AllocationTracking.h new file mode 100644 index 0000000000..3bd36bd973 --- /dev/null +++ b/headers/private/kernel/AllocationTracking.h @@ -0,0 +1,60 @@ +/* + * Copyright 2011, Michael Lotz . + * Copyright 2011, Ingo Weinhold . + * + * Distributed under the terms of the MIT License. + */ +#ifndef ALLOCATION_TRACKING_H +#define ALLOCATION_TRACKING_H + + +#include +#include + + +namespace BKernel { + +class AllocationTrackingInfo { +public: + AbstractTraceEntryWithStackTrace* traceEntry; + bigtime_t traceEntryTimestamp; + +public: + void Init(AbstractTraceEntryWithStackTrace* entry) + { + traceEntry = entry; + traceEntryTimestamp = entry != NULL ? entry->Time() : -1; + // Note: this is a race condition, if the tracing buffer wrapped and + // got overwritten once, we would access an invalid trace entry + // here. Obviously this is rather unlikely. + } + + void Clear() + { + traceEntry = NULL; + traceEntryTimestamp = 0; + } + + bool IsInitialized() const + { + return traceEntryTimestamp != 0; + } + + AbstractTraceEntryWithStackTrace* TraceEntry() const + { + return traceEntry; + } + + bool IsTraceEntryValid() const + { + return tracing_is_entry_valid(traceEntry, traceEntryTimestamp); + } +}; + +} // namespace BKernel + + +using BKernel::AllocationTrackingInfo; + + +#endif // ALLOCATION_TRACKING_H diff --git a/src/system/kernel/slab/slab_debug.h b/src/system/kernel/slab/slab_debug.h index 319efd4090..b0dd769a6c 100644 --- a/src/system/kernel/slab/slab_debug.h +++ b/src/system/kernel/slab/slab_debug.h @@ -8,6 +8,7 @@ #define SLAB_DEBUG_H +#include #include #include #include @@ -49,44 +50,6 @@ struct object_depot; #if SLAB_ALLOCATION_TRACKING_AVAILABLE -class AllocationTrackingInfo { -public: - AbstractTraceEntryWithStackTrace* traceEntry; - bigtime_t traceEntryTimestamp; - -public: - void Init(AbstractTraceEntryWithStackTrace* entry) - { - traceEntry = entry; - traceEntryTimestamp = entry != NULL ? entry->Time() : -1; - // Note: this is a race condition, if the tracing buffer wrapped and - // got overwritten once, we would access an invalid trace entry - // here. Obviously this is rather unlikely. - } - - void Clear() - { - traceEntry = NULL; - traceEntryTimestamp = 0; - } - - bool IsInitialized() const - { - return traceEntryTimestamp != 0; - } - - AbstractTraceEntryWithStackTrace* TraceEntry() const - { - return traceEntry; - } - - bool IsTraceEntryValid() const - { - return tracing_is_entry_valid(traceEntry, traceEntryTimestamp); - } -}; - - namespace BKernel { class AllocationTrackingCallback {