Extend and rework tracing. If ATA_TRACING is enabled in the tracing config it
will now log all the tracing details with ktrace_printf. Additionally messages that should always be printed are outputted to the syslog. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30108 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright 2009, Michael Lotz, [email protected].
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
#include "ATATracing.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
static char sTraceBuffer[256];
|
||||
static uint32 sTraceBufferOffset = 0;
|
||||
|
||||
void
|
||||
ata_trace_printf(uint32 flags, const char *format, ...)
|
||||
{
|
||||
va_list arguments;
|
||||
va_start(arguments, format);
|
||||
sTraceBufferOffset += vsnprintf(sTraceBuffer + sTraceBufferOffset,
|
||||
sizeof(sTraceBuffer) - sTraceBufferOffset, format, arguments);
|
||||
va_end(arguments);
|
||||
|
||||
if (flags & ATA_TRACE_FLUSH) {
|
||||
#if ATA_TRACING
|
||||
ktrace_printf(sTraceBuffer);
|
||||
#endif
|
||||
if (flags & ATA_TRACE_SYSLOG)
|
||||
dprintf(sTraceBuffer);
|
||||
|
||||
sTraceBufferOffset = 0;
|
||||
}
|
||||
}
|
||||
@@ -5,16 +5,24 @@
|
||||
#ifndef ATA_TRACING_H
|
||||
#define ATA_TRACING_H
|
||||
|
||||
//#define TRACE_ATA
|
||||
#ifdef TRACE_ATA
|
||||
#include <tracing.h>
|
||||
|
||||
#define ATA_TRACE_START 0x00
|
||||
#define ATA_TRACE_FLUSH 0x01
|
||||
#define ATA_TRACE_SYSLOG 0x02
|
||||
#define ATA_TRACE_FLUSH_SYSLOG 0x03
|
||||
|
||||
#if ATA_TRACING
|
||||
#define TRACE(x...) { \
|
||||
dprintf("ata%s: ", _DebugContext()); \
|
||||
dprintf(x); \
|
||||
ata_trace_printf(ATA_TRACE_START, \
|
||||
"ata%s: ", _DebugContext()); \
|
||||
ata_trace_printf(ATA_TRACE_FLUSH, x); \
|
||||
}
|
||||
#define TRACE_FUNCTION(x...) { \
|
||||
dprintf("ata%s: %s: ", _DebugContext(), \
|
||||
ata_trace_printf(ATA_TRACE_START, \
|
||||
"ata%s: %s: ", _DebugContext(), \
|
||||
__FUNCTION__); \
|
||||
dprintf(x); \
|
||||
ata_trace_printf(ATA_TRACE_FLUSH, x); \
|
||||
}
|
||||
#else
|
||||
#define TRACE(x...) /* nothing */
|
||||
@@ -22,14 +30,18 @@
|
||||
#endif
|
||||
|
||||
#define TRACE_ALWAYS(x...) { \
|
||||
dprintf("ata%s: ", _DebugContext()); \
|
||||
dprintf(x); \
|
||||
ata_trace_printf(ATA_TRACE_START, \
|
||||
"ata%s: ", _DebugContext()); \
|
||||
ata_trace_printf(ATA_TRACE_FLUSH_SYSLOG, x); \
|
||||
}
|
||||
#define TRACE_ERROR(x...) { \
|
||||
dprintf("ata%s error: ", _DebugContext()); \
|
||||
dprintf(x); \
|
||||
ata_trace_printf(ATA_TRACE_START, \
|
||||
"ata%s error: ", _DebugContext()); \
|
||||
ata_trace_printf(ATA_TRACE_FLUSH_SYSLOG, x); \
|
||||
}
|
||||
|
||||
void ata_trace_printf(uint32 flags, const char *format, ...);
|
||||
|
||||
inline const char *
|
||||
_DebugContext()
|
||||
{
|
||||
|
||||
@@ -27,4 +27,5 @@ KernelAddon ata :
|
||||
ATAModule.cpp
|
||||
ATAPIDevice.cpp
|
||||
ATARequest.cpp
|
||||
ATATracing.cpp
|
||||
;
|
||||
|
||||
Reference in New Issue
Block a user