Some more work on the tracing API:

* Added function to allocate space in the buffer.
* Dump() now fills a buffer instead of printing its data directly.
* This allows the new "#pattern" argument of the "traced" command to 
  work. When you're using that, the index of the trace entry is printed
  out, too, so that you can then get a full dump around the hits.
* Added an AddDump() method to the AbstractTraceEntry class so that 
  there is no need to call the inherited function anymore.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23479 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2008-01-13 02:50:32 +00:00
parent a5ec34950d
commit 8e43ece8b8
4 changed files with 128 additions and 76 deletions
+18 -4
View File
@@ -5,6 +5,8 @@
#include <SupportDefs.h>
#include <KernelExport.h>
#include <stdio.h>
#define ENABLE_TRACING 0
#define MAX_TRACE_SIZE 1024 * 1024
@@ -23,7 +25,7 @@ class TraceEntry : trace_entry {
TraceEntry();
virtual ~TraceEntry();
virtual void Dump();
virtual void Dump(char* buffer, size_t bufferSize);
size_t Size() const { return size; }
uint16 Flags() const { return flags; }
@@ -42,9 +44,15 @@ class AbstractTraceEntry : public TraceEntry {
{
}
virtual void Dump()
virtual void Dump(char* buffer, size_t bufferSize)
{
int length = snprintf(buffer, bufferSize, "[%6ld] %Ld: ",
fThread, fTime);
AddDump(buffer + length, bufferSize - length);
}
virtual void AddDump(char* buffer, size_t bufferSize)
{
kprintf("[%6ld] %Ld: ", fThread, fTime);
}
thread_id Thread() const { return fThread; }
@@ -58,8 +66,14 @@ class AbstractTraceEntry : public TraceEntry {
#endif // __cplusplus
#ifdef __cplusplus
extern "C"
extern "C" {
#endif
uint8* alloc_tracing_buffer(size_t size);
status_t tracing_init(void);
#ifdef __cplusplus
}
#endif
#endif /* KERNEL_UTIL_TRACING_H */