diff options
Diffstat (limited to 'sal/osl/w32')
-rwxr-xr-x[-rw-r--r--] | sal/osl/w32/diagnose.c | 36 | ||||
-rwxr-xr-x[-rw-r--r--] | sal/osl/w32/thread.c | 25 |
2 files changed, 32 insertions, 29 deletions
diff --git a/sal/osl/w32/diagnose.c b/sal/osl/w32/diagnose.c index e9caaf2b504e..e25c60e8c886 100644..100755 --- a/sal/osl/w32/diagnose.c +++ b/sal/osl/w32/diagnose.c @@ -33,6 +33,8 @@ #include <osl/diagnose.h> #include <osl/thread.h> +#include "printtrace.h" + #define NO_DEBUG_CRT static pfunc_osl_printDebugMessage _pPrintDebugMessage = NULL; @@ -62,45 +64,21 @@ void SAL_CALL osl_breakDebug(void) DebugBreak(); } - - -/* Uncomment this define to get profiling time output */ -/* #define OSL_PROFILING */ -/* comment this define to stop output thread identifier*/ -#define OSL_TRACE_THREAD 1 -void SAL_CALL osl_trace(const sal_Char* lpszFormat, ...) -{ +void osl_trace(char const * pszFormat, ...) { va_list args; - - va_start(args, lpszFormat); - -#if defined(OSL_PROFILING) - fprintf(stderr, "time : %06lu : ", osl_getGlobalTimer() ); -#else -#if defined(OSL_TRACE_THREAD) - fprintf(stderr,"Thread: %6d :",osl_getThreadIdentifier(NULL)); -#else - fprintf(stderr,"Trace Message : "); -#endif -#endif - + va_start(args, pszFormat); if ( IsDebuggerPresent() ) { sal_Char szMessage[512]; - int written = _vsnprintf( szMessage, sizeof(szMessage) - 2, lpszFormat, args ); + int written = _vsnprintf( + szMessage, sizeof(szMessage) - 2, pszFormat, args ); if ( written == -1 ) written = sizeof(szMessage) - 2; szMessage[ written++ ] = '\n'; szMessage[ written ] = 0; OutputDebugString( szMessage ); } - - vfprintf(stderr,lpszFormat, args); - - fprintf(stderr,"\n"); - - fflush(stderr); - + printTrace((unsigned long) _getpid(), pszFormat, args); va_end(args); } diff --git a/sal/osl/w32/thread.c b/sal/osl/w32/thread.c index 92ac312d5a4e..02a67050083d 100644..100755 --- a/sal/osl/w32/thread.c +++ b/sal/osl/w32/thread.c @@ -395,6 +395,31 @@ void SAL_CALL osl_yieldThread(void) Sleep(0); } +void SAL_CALL osl_setThreadName(char const * name) { +#ifdef _MSC_VER + /* See <http://msdn.microsoft.com/en-us/library/xcb2z8hs.aspx>: */ +#pragma pack(push, 8) + struct { + DWORD dwType; + LPCSTR szName; + DWORD dwThreadID; + DWORD dwFlags; + } info; +#pragma pack(pop) + info.dwType = 0x1000; + info.szName = name; + info.dwThreadID = (DWORD) -1; + info.dwFlags = 0; + __try { + RaiseException( + 0x406D1388, 0, sizeof info / sizeof (ULONG_PTR), + (ULONG_PTR *) &info); + } __except (EXCEPTION_EXECUTE_HANDLER) {} +#else + (void) name; +#endif +} + typedef struct _TLS { DWORD dwIndex; |