2008-01-19 20:24:34 +03:00
|
|
|
#ifndef KERNEL_TRACING_H
|
|
|
|
#define KERNEL_TRACING_H
|
2008-01-12 21:41:35 +03:00
|
|
|
|
|
|
|
|
|
|
|
#include <SupportDefs.h>
|
2008-01-13 02:55:53 +03:00
|
|
|
#include <KernelExport.h>
|
2008-01-12 21:41:35 +03:00
|
|
|
|
2008-01-13 05:50:32 +03:00
|
|
|
#include <stdio.h>
|
|
|
|
|
2008-01-19 20:24:34 +03:00
|
|
|
#include <tracing_config.h>
|
2008-01-12 21:41:35 +03:00
|
|
|
|
|
|
|
|
|
|
|
struct trace_entry {
|
|
|
|
uint16 size;
|
|
|
|
uint16 flags;
|
|
|
|
};
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
|
|
|
#include <new>
|
|
|
|
|
2008-01-19 01:15:30 +03:00
|
|
|
class TraceOutput {
|
|
|
|
public:
|
|
|
|
TraceOutput(char* buffer, size_t bufferSize);
|
|
|
|
|
2008-01-20 01:23:32 +03:00
|
|
|
void Clear();
|
2008-01-19 01:15:30 +03:00
|
|
|
void Print(const char* format,...);
|
|
|
|
bool IsFull() const { return fSize >= fCapacity; }
|
|
|
|
|
2008-01-20 03:34:37 +03:00
|
|
|
char* Buffer() const { return fBuffer; }
|
|
|
|
size_t Capacity() const { return fCapacity; }
|
|
|
|
size_t Size() const { return fSize; }
|
|
|
|
|
2008-01-19 01:15:30 +03:00
|
|
|
private:
|
|
|
|
char* fBuffer;
|
|
|
|
size_t fCapacity;
|
|
|
|
size_t fSize;
|
|
|
|
};
|
|
|
|
|
2008-01-12 21:41:35 +03:00
|
|
|
class TraceEntry : trace_entry {
|
|
|
|
public:
|
|
|
|
TraceEntry();
|
|
|
|
virtual ~TraceEntry();
|
|
|
|
|
2008-01-20 01:23:32 +03:00
|
|
|
virtual void Dump(TraceOutput& out);
|
2008-01-12 21:41:35 +03:00
|
|
|
|
|
|
|
size_t Size() const { return size; }
|
|
|
|
uint16 Flags() const { return flags; }
|
|
|
|
|
|
|
|
void Initialized();
|
|
|
|
|
2008-01-13 02:55:53 +03:00
|
|
|
void* operator new(size_t size, const std::nothrow_t&) throw();
|
|
|
|
};
|
|
|
|
|
|
|
|
class AbstractTraceEntry : public TraceEntry {
|
|
|
|
public:
|
|
|
|
AbstractTraceEntry()
|
|
|
|
:
|
|
|
|
fThread(find_thread(NULL)),
|
|
|
|
fTime(system_time())
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2008-01-19 01:15:30 +03:00
|
|
|
virtual ~AbstractTraceEntry();
|
2008-01-13 05:50:32 +03:00
|
|
|
|
2008-01-20 01:23:32 +03:00
|
|
|
virtual void Dump(TraceOutput& out);
|
2008-01-19 01:15:30 +03:00
|
|
|
|
|
|
|
virtual void AddDump(TraceOutput& out);
|
2008-01-13 02:55:53 +03:00
|
|
|
|
|
|
|
thread_id Thread() const { return fThread; }
|
|
|
|
bigtime_t Time() const { return fTime; }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
thread_id fThread;
|
|
|
|
bigtime_t fTime;
|
2008-01-12 21:41:35 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // __cplusplus
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
2008-01-13 05:50:32 +03:00
|
|
|
extern "C" {
|
2008-01-12 21:41:35 +03:00
|
|
|
#endif
|
2008-01-13 05:50:32 +03:00
|
|
|
|
|
|
|
uint8* alloc_tracing_buffer(size_t size);
|
2008-01-17 04:58:08 +03:00
|
|
|
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);
|
2008-01-12 21:41:35 +03:00
|
|
|
status_t tracing_init(void);
|
|
|
|
|
2008-01-13 05:50:32 +03:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2008-01-19 20:24:34 +03:00
|
|
|
#endif /* KERNEL_TRACING_H */
|