write code aligned to what one has written in the comment (or the
other way around).
* Made trace_entry structure doubly linked, by introducing a
previous_size member. By using bit fields, shrinking the flags field
to 4 bits, and not saving the lower two bits of size and previous_size
(which are always 0 due to alignment), the structure remains 4 byte
sized and can still address the same entry size.
* kBufferSize is no longer one less than it could be.
* "traced" command:
- Use static variable for the iteration state rather then cluttering
the temporary debug variable name space.
- The <count> parameter can now be negative, in which case the entries
before (and including) <start> are printed.
- Added a new optional parameter, specifying the maximal number of
entries to be filtered. Filtered iteration is beautifully
comfortable now.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23678 a95241bf-73f2-0310-859d-f6bbb57e9c96
96 lines
1.7 KiB
C++
96 lines
1.7 KiB
C++
#ifndef KERNEL_TRACING_H
|
|
#define KERNEL_TRACING_H
|
|
|
|
|
|
#include <SupportDefs.h>
|
|
#include <KernelExport.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <tracing_config.h>
|
|
|
|
|
|
struct trace_entry {
|
|
uint32 size : 14; // actual size is *4
|
|
uint32 previous_size : 14; // actual size is *4
|
|
uint32 flags : 4;
|
|
};
|
|
|
|
#ifdef __cplusplus
|
|
|
|
#include <new>
|
|
|
|
class TraceOutput {
|
|
public:
|
|
TraceOutput(char* buffer, size_t bufferSize);
|
|
|
|
void Clear();
|
|
void Print(const char* format,...);
|
|
bool IsFull() const { return fSize >= fCapacity; }
|
|
|
|
char* Buffer() const { return fBuffer; }
|
|
size_t Capacity() const { return fCapacity; }
|
|
size_t Size() const { return fSize; }
|
|
|
|
private:
|
|
char* fBuffer;
|
|
size_t fCapacity;
|
|
size_t fSize;
|
|
};
|
|
|
|
class TraceEntry : public trace_entry {
|
|
public:
|
|
TraceEntry();
|
|
virtual ~TraceEntry();
|
|
|
|
virtual void Dump(TraceOutput& out);
|
|
|
|
size_t Size() const { return size; }
|
|
uint16 Flags() const { return flags; }
|
|
|
|
void Initialized();
|
|
|
|
void* operator new(size_t size, const std::nothrow_t&) throw();
|
|
};
|
|
|
|
class AbstractTraceEntry : public TraceEntry {
|
|
public:
|
|
AbstractTraceEntry()
|
|
:
|
|
fThread(find_thread(NULL)),
|
|
fTime(system_time())
|
|
{
|
|
}
|
|
|
|
virtual ~AbstractTraceEntry();
|
|
|
|
virtual void Dump(TraceOutput& out);
|
|
|
|
virtual void AddDump(TraceOutput& out);
|
|
|
|
thread_id Thread() const { return fThread; }
|
|
bigtime_t Time() const { return fTime; }
|
|
|
|
protected:
|
|
thread_id fThread;
|
|
bigtime_t fTime;
|
|
};
|
|
|
|
#endif // __cplusplus
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
uint8* alloc_tracing_buffer(size_t size);
|
|
uint8* alloc_tracing_buffer_memcpy(const void* source, size_t size, bool user);
|
|
char* alloc_tracing_buffer_strcpy(const char* source, size_t maxSize,
|
|
bool user);
|
|
status_t tracing_init(void);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* KERNEL_TRACING_H */
|