Fixed debug-to-file output to actually work when run in R5 kernel mode.

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@4749 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Tyler Dauwalder 2003-09-18 07:30:38 +00:00
parent d5366ff7e1
commit eaa70c976c
2 changed files with 23 additions and 4 deletions

View File

@ -304,7 +304,7 @@ private:
int fFile;
};
DebugOutputFile out;
DebugOutputFile *out = NULL;
/*! \brief It doesn't appear that the constructor for the global
\c out variable is called when built as an R5 filesystem add-on,
@ -313,7 +313,16 @@ DebugOutputFile out;
*/
void initialize_debugger(const char *filename)
{
out.Init(filename);
#if DEBUG_TO_FILE
if (!out) {
out = new DebugOutputFile(filename);
dbg_printf("out was NULL!\n");
} else {
DebugOutputFile *temp = out;
out = new DebugOutputFile(filename);
dbg_printf("out was %p!\n", temp);
}
#endif
}
// dbg_printf, stolen from Ingo's ReiserFS::Debug.cpp.
@ -321,6 +330,9 @@ void
dbg_printf(const char *format,...)
{
#if DEBUG_TO_FILE
if (!out)
return;
char buffer[1024];
va_list args;
va_start(args, format);
@ -332,7 +344,7 @@ dbg_printf(const char *format,...)
#endif
va_end(args);
buffer[sizeof(buffer) - 1] = '\0';
write(out.File(), buffer, strlen(buffer));
write(out->File(), buffer, strlen(buffer));
#endif
}

View File

@ -22,7 +22,7 @@
#endif
#include <unistd.h>
#define DEBUG_TO_FILE 0
#define DEBUG_TO_FILE 1
#if DEBUG_TO_FILE
# include <stdio.h>
@ -62,12 +62,17 @@ enum _DebugCategoryFlags {
CF_INDEX_OPS = 0x00000080,
CF_QUERY_OPS = 0x00000100,
// Misc categories
CF_HIGH_VOLUME = 0x00000200, //!< often-called functions
CF_HELPER = 0x00000400, //!< helper functions and classes (i.e. Array, CS0String, etc.)
CF_DEBUGGING = 0x00000800, //!< internal debugging functions
CF_DUMP = 0x00001000, //!< dump() functions
// Specific entry functions
CF_UDF_READ_FS_STAT = 0x00002000,
CF_UDF_READ = 0x00004000,
//-------------------------------
// Handy combinations
@ -83,6 +88,8 @@ enum _DebugCategoryFlags {
\brief Bitmask of currently enabled debugging categories.
*/
#define CATEGORY_FILTER CF_ALL
//#define CATEGORY_FILTER ~CF_DIRECTORY_OPS & ~CF_HIGH_VOLUME & ~CF_HELPER
//#define CATEGORY_FILTER CF_UDF_READ
//#define CATEGORY_FILTER ~CF_DUMP
//#define CATEGORY_FILTER ~CF_DUMP & ~CF_HIGH_VOLUME
//#define CATEGORY_FILTER CF_ALL_STANDARD