* Made TraceEntryIterator available in the kernel.
* Fixed TraceEntryIterator::Current(): If fEntry was NULL, it would return 0x4. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26955 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -63,6 +63,7 @@ class TraceOutput {
|
||||
bigtime_t fLastEntryTime;
|
||||
};
|
||||
|
||||
|
||||
class TraceEntry {
|
||||
public:
|
||||
TraceEntry();
|
||||
@@ -89,6 +90,7 @@ class TraceEntry {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class AbstractTraceEntry : public TraceEntry {
|
||||
public:
|
||||
AbstractTraceEntry();
|
||||
@@ -108,6 +110,7 @@ class AbstractTraceEntry : public TraceEntry {
|
||||
bigtime_t fTime;
|
||||
};
|
||||
|
||||
|
||||
class LazyTraceOutput : public TraceOutput {
|
||||
public:
|
||||
LazyTraceOutput(char* buffer, size_t bufferSize, uint32 flags)
|
||||
@@ -126,6 +129,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class TraceFilter {
|
||||
public:
|
||||
virtual ~TraceFilter();
|
||||
@@ -145,11 +149,52 @@ public:
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
class WrapperTraceFilter : public TraceFilter {
|
||||
public:
|
||||
virtual void Init(TraceFilter* filter, int direction, bool continued) = 0;
|
||||
};
|
||||
|
||||
|
||||
class TraceEntryIterator {
|
||||
public:
|
||||
TraceEntryIterator()
|
||||
:
|
||||
fEntry(NULL),
|
||||
fIndex(0)
|
||||
{
|
||||
}
|
||||
|
||||
void Reset()
|
||||
{
|
||||
fEntry = NULL;
|
||||
fIndex = 0;
|
||||
}
|
||||
|
||||
int32 Index() const
|
||||
{
|
||||
return fIndex;
|
||||
}
|
||||
|
||||
TraceEntry* Current() const
|
||||
{
|
||||
return fEntry != NULL ? TraceEntry::FromTraceEntry(fEntry) : NULL;
|
||||
}
|
||||
|
||||
TraceEntry* Next();
|
||||
TraceEntry* Previous();
|
||||
TraceEntry* MoveTo(int32 index);
|
||||
|
||||
private:
|
||||
trace_entry* _NextNonBufferEntry(trace_entry* entry);
|
||||
trace_entry* _PreviousNonBufferEntry(trace_entry* entry);
|
||||
|
||||
private:
|
||||
trace_entry* fEntry;
|
||||
int32 fIndex;
|
||||
};
|
||||
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -697,33 +697,9 @@ TraceFilterParser TraceFilterParser::sParser;
|
||||
#if ENABLE_TRACING
|
||||
|
||||
|
||||
class TraceEntryIterator {
|
||||
public:
|
||||
TraceEntryIterator()
|
||||
:
|
||||
fEntry(NULL),
|
||||
fIndex(0)
|
||||
{
|
||||
}
|
||||
|
||||
void Reset()
|
||||
{
|
||||
fEntry = NULL;
|
||||
fIndex = 0;
|
||||
}
|
||||
|
||||
int32 Index() const
|
||||
{
|
||||
return fIndex;
|
||||
}
|
||||
|
||||
TraceEntry* Current() const
|
||||
{
|
||||
return TraceEntry::FromTraceEntry(fEntry);
|
||||
}
|
||||
|
||||
TraceEntry* Next()
|
||||
{
|
||||
TraceEntry*
|
||||
TraceEntryIterator::Next()
|
||||
{
|
||||
if (fIndex == 0) {
|
||||
fEntry = _NextNonBufferEntry(sFirstEntry);
|
||||
fIndex = 1;
|
||||
@@ -733,10 +709,12 @@ public:
|
||||
}
|
||||
|
||||
return Current();
|
||||
}
|
||||
}
|
||||
|
||||
TraceEntry* Previous()
|
||||
{
|
||||
|
||||
TraceEntry*
|
||||
TraceEntryIterator::Previous()
|
||||
{
|
||||
if (fIndex == (int32)sEntries + 1)
|
||||
fEntry = sAfterLastEntry;
|
||||
|
||||
@@ -746,10 +724,12 @@ public:
|
||||
}
|
||||
|
||||
return Current();
|
||||
}
|
||||
}
|
||||
|
||||
TraceEntry* MoveTo(int32 index)
|
||||
{
|
||||
|
||||
TraceEntry*
|
||||
TraceEntryIterator::MoveTo(int32 index)
|
||||
{
|
||||
if (index == fIndex)
|
||||
return Current();
|
||||
|
||||
@@ -787,29 +767,27 @@ public:
|
||||
}
|
||||
|
||||
return Current();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
trace_entry* _NextNonBufferEntry(trace_entry* entry)
|
||||
{
|
||||
|
||||
trace_entry*
|
||||
TraceEntryIterator::_NextNonBufferEntry(trace_entry* entry)
|
||||
{
|
||||
while (entry != NULL && (entry->flags & BUFFER_ENTRY) != 0)
|
||||
entry = next_entry(entry);
|
||||
|
||||
return entry;
|
||||
}
|
||||
}
|
||||
|
||||
trace_entry* _PreviousNonBufferEntry(trace_entry* entry)
|
||||
{
|
||||
|
||||
trace_entry*
|
||||
TraceEntryIterator::_PreviousNonBufferEntry(trace_entry* entry)
|
||||
{
|
||||
while (entry != NULL && (entry->flags & BUFFER_ENTRY) != 0)
|
||||
entry = previous_entry(entry);
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
private:
|
||||
trace_entry* fEntry;
|
||||
int32 fIndex;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
|
||||
Reference in New Issue
Block a user