Author: mmlr Date: 2011-11-04 19:03:34 +0100 (Fri, 04 Nov 2011) New Revision: 43188 Changeset: https://dev.haiku-os.org/changeset/43188 Added: haiku/trunk/headers/private/kernel/AllocationTracking.h Modified: haiku/trunk/src/system/kernel/slab/slab_debug.h Log: 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. Added: haiku/trunk/headers/private/kernel/AllocationTracking.h =================================================================== --- haiku/trunk/headers/private/kernel/AllocationTracking.h (rev 0) +++ haiku/trunk/headers/private/kernel/AllocationTracking.h 2011-11-04 18:03:34 UTC (rev 43188) @@ -0,0 +1,60 @@ +/* + * Copyright 2011, Michael Lotz <mmlr@xxxxxxxx>. + * Copyright 2011, Ingo Weinhold <ingo_weinhold@xxxxxx>. + * + * Distributed under the terms of the MIT License. + */ +#ifndef ALLOCATION_TRACKING_H +#define ALLOCATION_TRACKING_H + + +#include <debug.h> +#include <tracing.h> + + +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 Modified: haiku/trunk/src/system/kernel/slab/slab_debug.h =================================================================== --- haiku/trunk/src/system/kernel/slab/slab_debug.h 2011-11-04 18:01:15 UTC (rev 43187) +++ haiku/trunk/src/system/kernel/slab/slab_debug.h 2011-11-04 18:03:34 UTC (rev 43188) @@ -8,6 +8,7 @@ #define SLAB_DEBUG_H +#include <AllocationTracking.h> #include <debug.h> #include <slab/Slab.h> #include <tracing.h> @@ -49,44 +50,6 @@ #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 {