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-03-28 01:01:38 +03:00
|
|
|
#include "tracing_config.h"
|
2008-01-12 21:41:35 +03:00
|
|
|
|
|
|
|
|
|
|
|
struct trace_entry {
|
2008-01-21 03:41:45 +03:00
|
|
|
uint32 size : 14; // actual size is *4
|
|
|
|
uint32 previous_size : 14; // actual size is *4
|
|
|
|
uint32 flags : 4;
|
2008-01-12 21:41:35 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
|
|
|
#include <new>
|
|
|
|
|
2008-02-04 20:54:40 +03:00
|
|
|
|
|
|
|
// trace output flags
|
|
|
|
#define TRACE_OUTPUT_TEAM_ID 0x01
|
|
|
|
// print the team ID
|
|
|
|
#define TRACE_OUTPUT_DIFF_TIME 0x02
|
|
|
|
// print the difference time to the previously printed entry instead of the
|
|
|
|
// absolute time
|
|
|
|
|
|
|
|
|
2008-01-19 01:15:30 +03:00
|
|
|
class TraceOutput {
|
|
|
|
public:
|
2008-02-04 20:54:40 +03:00
|
|
|
TraceOutput(char* buffer, size_t bufferSize, uint32 flags);
|
2008-01-19 01:15:30 +03:00
|
|
|
|
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-02-04 20:54:40 +03:00
|
|
|
uint32 Flags() const { return fFlags; }
|
|
|
|
|
|
|
|
void SetLastEntryTime(bigtime_t time);
|
|
|
|
bigtime_t LastEntryTime() const;
|
|
|
|
|
2008-01-19 01:15:30 +03:00
|
|
|
private:
|
2008-02-04 20:54:40 +03:00
|
|
|
char* fBuffer;
|
|
|
|
size_t fCapacity;
|
|
|
|
size_t fSize;
|
|
|
|
uint32 fFlags;
|
|
|
|
bigtime_t fLastEntryTime;
|
2008-01-19 01:15:30 +03:00
|
|
|
};
|
|
|
|
|
2008-01-21 03:41:45 +03:00
|
|
|
class TraceEntry : public trace_entry {
|
2008-01-12 21:41:35 +03:00
|
|
|
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:
|
2008-01-21 16:31:27 +03:00
|
|
|
AbstractTraceEntry();
|
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; }
|
2008-01-21 16:31:27 +03:00
|
|
|
thread_id Team() const { return fTeam; }
|
2008-01-13 02:55:53 +03:00
|
|
|
bigtime_t Time() const { return fTime; }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
thread_id fThread;
|
2008-01-21 16:31:27 +03:00
|
|
|
team_id fTeam;
|
2008-01-13 02:55:53 +03:00
|
|
|
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-21 18:10:05 +03:00
|
|
|
void _user_ktrace_output(const char *message);
|
|
|
|
|
2008-01-13 05:50:32 +03:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2008-01-19 20:24:34 +03:00
|
|
|
#endif /* KERNEL_TRACING_H */
|