Main Page | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

arch/windows/debug.c

Go to the documentation of this file.
00001 
00010 #ifndef DBG_KERNELMODE
00011 
00012     #define DBG_USERMODE
00013 #endif // #ifndef DBG_KERNELMODE
00014 
00015 #include "debug.h"
00016 
00017 #if DBG
00018 
00019 #include <stdarg.h>
00020 #include <stdio.h>
00021 
00022 
00023 
00027 unsigned char DbgBuffer[DBG_MAX_BUFFER][DBG_MAX_BUFFERLEN];
00028 
00030 int  DbgBufferPos[DBG_MAX_BUFFER];
00031 
00033 unsigned long DbgFlags = 0  // | 0x7FFFFFFF
00034 //                       | DBGF_BREAK
00035 
00036 //                       | DBGF_ENTER
00037 //                       | DBGF_LEAVE
00038 //                       | DBGF_LEAVE_FAILURE
00039 //                       | DBGF_PARAM
00040 #ifdef DBG_KERNELMODE
00041 //                       | DBGF_IEC
00042 //                       | DBGF_IRQ
00043                          | DBGF_ASSERTIRQL
00044 //                       | DBGF_PORT
00045                          | DBGF_THREAD
00046 //                       | DBGF_IRPPATH
00047 //                       | DBGF_IRP
00048 //                       | DBGF_DPC
00049                          | DBGF_DBGMEMBUF
00050                          | DBGF_DBGPRINT
00051 
00052 #endif // #ifdef DBG_KERNELMODE
00053 //                       | DBGF_PPORT
00054 //                       | DBGF_SUCCESS
00055 //                       | DBGF_ERROR
00056 //                       | DBGF_WARNING
00057                          | DBGF_ASSERT
00058                          ;
00059 
00060 #ifdef DBG_KERNELMODE
00061 
00065 LONG DebugBufferCounter;
00066 
00070 LONG DebugBufferUsed[DBG_MAX_BUFFER];
00071 
00072 #endif // #ifdef DBG_KERNELMODE
00073 
00074 
00091 void
00092 DbgOutputIntoBuffer(unsigned long BufferNumber, const char * const Format, ...)
00093 {
00094     va_list arg_ptr;
00095 
00096     // Get a pointer to the current position in the given DebugBuffer
00097 
00098     char *buffer = &DbgBuffer[BufferNumber][DbgBufferPos[BufferNumber]];
00099 
00100     va_start(arg_ptr, Format);
00101 
00102     // If there is some space left in the DebugBuffer, append the contents
00103 
00104     if ((DBG_MAX_BUFFERLEN - DbgBufferPos[BufferNumber] - 1) > 0) 
00105     {
00106         int n;
00107         
00108         // Output at most the number of bytes which are left in the DebugBuffer
00109 
00110         n = _vsnprintf(buffer, DBG_MAX_BUFFERLEN - DbgBufferPos[BufferNumber] - 1,
00111             Format, arg_ptr);
00112 
00113         // Was the buffer too small? If yes, the number of bytes
00114         // inserted is the size of the remaining buffer, so, set
00115         // this value
00116 
00117         if (n<0) 
00118         {
00119             n = DBG_MAX_BUFFERLEN - DbgBufferPos[BufferNumber] - 1;
00120         }
00121 
00122         // advance the buffer into the DebugBuffer
00123 
00124         DbgBufferPos[BufferNumber] += n;
00125 
00126         // Make sure the string is null terminated
00127 
00128         DbgBuffer[BufferNumber][DbgBufferPos[BufferNumber]] = 0;
00129     }
00130     va_end(arg_ptr);
00131 }
00132 
00133 #endif // #if DBG

Generated on Sun Apr 30 18:45:48 2006 for opencbm by  doxygen 1.4.2