bonefish+mmlr:
* Add an AbstractTraceEntryWithStackTrace that includes stack trace handling. * Add a selector macro/template combo to conveniently select the right base class depending on whether stack traces are enabled or not. * Minor style cleanups. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43045 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
ebf63109bb
commit
fe8f0f4601
@ -92,25 +92,72 @@ class TraceEntry {
|
||||
|
||||
|
||||
class AbstractTraceEntry : public TraceEntry {
|
||||
public:
|
||||
AbstractTraceEntry();
|
||||
virtual ~AbstractTraceEntry();
|
||||
public:
|
||||
AbstractTraceEntry()
|
||||
{
|
||||
_Init();
|
||||
}
|
||||
|
||||
virtual void Dump(TraceOutput& out);
|
||||
// dummy, ignores all arguments
|
||||
AbstractTraceEntry(size_t, size_t, bool)
|
||||
{
|
||||
_Init();
|
||||
}
|
||||
|
||||
virtual void AddDump(TraceOutput& out);
|
||||
virtual ~AbstractTraceEntry();
|
||||
|
||||
thread_id ThreadID() const { return fThread; }
|
||||
thread_id TeamID() const { return fTeam; }
|
||||
bigtime_t Time() const { return fTime; }
|
||||
virtual void Dump(TraceOutput& out);
|
||||
|
||||
protected:
|
||||
thread_id fThread;
|
||||
team_id fTeam;
|
||||
bigtime_t fTime;
|
||||
virtual void AddDump(TraceOutput& out);
|
||||
|
||||
thread_id ThreadID() const { return fThread; }
|
||||
thread_id TeamID() const { return fTeam; }
|
||||
bigtime_t Time() const { return fTime; }
|
||||
|
||||
protected:
|
||||
typedef AbstractTraceEntry TraceEntryBase;
|
||||
|
||||
private:
|
||||
void _Init();
|
||||
|
||||
protected:
|
||||
thread_id fThread;
|
||||
team_id fTeam;
|
||||
bigtime_t fTime;
|
||||
};
|
||||
|
||||
|
||||
class AbstractTraceEntryWithStackTrace : public AbstractTraceEntry {
|
||||
public:
|
||||
AbstractTraceEntryWithStackTrace(size_t stackTraceDepth,
|
||||
size_t skipFrames, bool kernelOnly);
|
||||
|
||||
virtual void DumpStackTrace(TraceOutput& out);
|
||||
|
||||
protected:
|
||||
typedef AbstractTraceEntryWithStackTrace TraceEntryBase;
|
||||
|
||||
private:
|
||||
tracing_stack_trace* fStackTrace;
|
||||
};
|
||||
|
||||
|
||||
template<bool stackTraceDepth>
|
||||
struct AbstractTraceEntrySelector {
|
||||
typedef AbstractTraceEntryWithStackTrace Type;
|
||||
};
|
||||
|
||||
|
||||
template<>
|
||||
struct AbstractTraceEntrySelector<0> {
|
||||
typedef AbstractTraceEntry Type;
|
||||
};
|
||||
|
||||
|
||||
#define TRACE_ENTRY_SELECTOR(stackTraceDepth) \
|
||||
AbstractTraceEntrySelector<stackTraceDepth>::Type
|
||||
|
||||
|
||||
class LazyTraceOutput : public TraceOutput {
|
||||
public:
|
||||
LazyTraceOutput(char* buffer, size_t bufferSize, uint32 flags)
|
||||
|
@ -737,17 +737,6 @@ TraceEntry::operator new(size_t size, const std::nothrow_t&) throw()
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
AbstractTraceEntry::AbstractTraceEntry()
|
||||
{
|
||||
Thread* thread = thread_get_current_thread();
|
||||
if (thread != NULL) {
|
||||
fThread = thread->id;
|
||||
if (thread->team)
|
||||
fTeam = thread->team->id;
|
||||
}
|
||||
fTime = system_time();
|
||||
}
|
||||
|
||||
AbstractTraceEntry::~AbstractTraceEntry()
|
||||
{
|
||||
}
|
||||
@ -777,6 +766,38 @@ AbstractTraceEntry::AddDump(TraceOutput& out)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
AbstractTraceEntry::_Init()
|
||||
{
|
||||
Thread* thread = thread_get_current_thread();
|
||||
if (thread != NULL) {
|
||||
fThread = thread->id;
|
||||
if (thread->team)
|
||||
fTeam = thread->team->id;
|
||||
}
|
||||
fTime = system_time();
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark - AbstractTraceEntryWithStackTrace
|
||||
|
||||
|
||||
|
||||
AbstractTraceEntryWithStackTrace::AbstractTraceEntryWithStackTrace(
|
||||
size_t stackTraceDepth, size_t skipFrames, bool kernelOnly)
|
||||
{
|
||||
fStackTrace = capture_tracing_stack_trace(stackTraceDepth, skipFrames + 1,
|
||||
kernelOnly);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
AbstractTraceEntryWithStackTrace::DumpStackTrace(TraceOutput& out)
|
||||
{
|
||||
out.PrintStackTrace(fStackTrace);
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user