Adding ITADebug for RAVEN

parent b3bcd32c
......@@ -50,6 +50,7 @@ set( ITABaseHeader
"include/ITAConstants.h"
"include/ITACriticalSection.h"
"include/ITADataLog.h"
"include/ITADebug.h"
"include/ITAEndianness.h"
"include/ITAException.h"
"include/ITAFade.h"
......@@ -82,6 +83,7 @@ set( ITABaseSources
"src/ITACriticalSectionImpl.h"
"src/ITACriticalSectionPosixImpl.h"
"src/ITACriticalSectionWin32Impl.h"
"src/ITADebug.cpp"
"src/ITAEndianness.cpp"
"src/ITAException.cpp"
"src/ITAFade.cpp"
......
/*
* ----------------------------------------------------------------
*
* ITA core libs
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2016
*
* ----------------------------------------------------------------
* ____ __________ _______
* // / //__ ___/ // _ |
* // / // / // /_| |
* // / // / // ___ |
* //__/ //__/ //__/ |__|
*
* ----------------------------------------------------------------
*
*/
#ifndef INCLUDE_WATCHER_ITA_DEBUG
#define INCLUDE_WATCHER_ITA_DEBUG
#include <ITABaseDefinitions.h>
void ITA_BASE_API DEBUG_PRINTF(const char* format, ... );
// Setzt den Namen eines Thread, welcher in der VisualStudio Thread-Liste angezeigt wird
void ITA_BASE_API SetThreadName( long lThreadID, const char* szThreadName );
#endif // INCLUDE_WATCHER_ITA_DEBUG
/*
+-----------------------------------------------------------------------+
| |
| ITAToolkit |
| |
| (c) Copyright Institut fr technische Akustik (ITA) |
| Aachen university of technology (RWTH), 2005-2011 |
| |
+-----------------------------------------------------------------------+
| |
| File: ITADebug.cpp |
| Purpose: Hilfsfunktionen frs Debugging |
| Authors: Frank Wefers |
| |
+-----------------------------------------------------------------------+
*/
// $Id: $
#include <ITADebug.h>
#include <ITACriticalSection.h>
#include <stdio.h>
#include <stdarg.h>
#ifdef WIN32
#include <windows.h>
#define DEBUG_PRINTF_BUFSIZE 16384
// Lock fr den Puffer in den Ausgabe-Routinen
static ITACriticalSection g_csDebugPrintf;
static char g_pszDebugPrintfBuf[16384];
#ifdef _DEBUG
void DEBUG_PRINTF(const char * format, ... ) {
g_csDebugPrintf.enter();
va_list args;
va_start(args, format);
vsprintf_s(g_pszDebugPrintfBuf, DEBUG_PRINTF_BUFSIZE, format, args);
va_end(args);
OutputDebugStringA(g_pszDebugPrintfBuf);
g_csDebugPrintf.leave();
}
#else
void DEBUG_PRINTF(const char * format, ... ) {
/* NUR BENUTZEN WENN DEBUG_PRINTF IM RELEASE MODE BENTIGT WIRD!!!
g_csDebugPrintf.enter();
va_list args;
va_start(args, format);
vsprintf_s(g_pszDebugPrintfBuf, DEBUG_PRINTF_BUFSIZE, format, args);
va_end(args);
OutputDebugStringA(g_pszDebugPrintfBuf);
g_csDebugPrintf.leave();
*/
}
#endif // _DEBUG
/*
* Kommt von hier: http://www.codeproject.com/KB/threads/Name_threads_in_debugger.aspx
*/
typedef struct tagTHREADNAME_INFO {
DWORD dwType; // must be 0x1000
LPCSTR szName; // pointer to name (in user addr space)
DWORD dwThreadID; // thread ID (-1=caller thread)
DWORD dwFlags; // reserved for future use, must be zero
} THREADNAME_INFO;
void SetThreadName(long lThreadID, const char* szThreadName) {
THREADNAME_INFO info;
{
info.dwType = 0x1000;
info.szName = szThreadName;
info.dwThreadID = (DWORD) lThreadID;
info.dwFlags = 0;
}
__try {
RaiseException( 0x406D1388, 0, sizeof(info)/sizeof(DWORD), (ULONG_PTR*) &info );
} __except (EXCEPTION_CONTINUE_EXECUTION) {}
}
#endif // Win32
#ifndef WIN32 // Linux oder was auch immer
void DEBUG_PRINTF(const char * format, ... ) {
va_list args;
va_start(args, format);
printf(format, args);
va_end(args);
}
#endif // Linux
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment