xref: /aoo42x/main/tools/source/debug/debug.cxx (revision 89b56da7)
1*89b56da7SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*89b56da7SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*89b56da7SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*89b56da7SAndrew Rist  * distributed with this work for additional information
6*89b56da7SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*89b56da7SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*89b56da7SAndrew Rist  * "License"); you may not use this file except in compliance
9*89b56da7SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*89b56da7SAndrew Rist  *
11*89b56da7SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*89b56da7SAndrew Rist  *
13*89b56da7SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*89b56da7SAndrew Rist  * software distributed under the License is distributed on an
15*89b56da7SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*89b56da7SAndrew Rist  * KIND, either express or implied.  See the License for the
17*89b56da7SAndrew Rist  * specific language governing permissions and limitations
18*89b56da7SAndrew Rist  * under the License.
19*89b56da7SAndrew Rist  *
20*89b56da7SAndrew Rist  *************************************************************/
21*89b56da7SAndrew Rist 
22*89b56da7SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_tools.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #define _TOOLS_DEBUG_CXX
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #if defined (UNX) || defined (GCC)
30cdf0e10cSrcweir #include <unistd.h>
31cdf0e10cSrcweir #else
32cdf0e10cSrcweir #include <direct.h>
33cdf0e10cSrcweir #endif
34cdf0e10cSrcweir 
35cdf0e10cSrcweir #include <time.h>
36cdf0e10cSrcweir #include <cstdarg>  // combinations
37cdf0e10cSrcweir #include <stdlib.h>
38cdf0e10cSrcweir #include <string.h>
39cdf0e10cSrcweir #include <stdio.h>
40cdf0e10cSrcweir 
41cdf0e10cSrcweir #ifdef OS2
42cdf0e10cSrcweir #define INCL_DOSSEMAPHORES
43cdf0e10cSrcweir #define INCL_DOSMISC
44cdf0e10cSrcweir #define INCL_WINDIALOGS
45cdf0e10cSrcweir #define INCL_WINSHELLDATA
46cdf0e10cSrcweir #include <svpm.h>
47cdf0e10cSrcweir #endif
48cdf0e10cSrcweir 
49cdf0e10cSrcweir #if defined ( WNT )
50cdf0e10cSrcweir #ifdef _MSC_VER
51cdf0e10cSrcweir #pragma warning (push,1)
52cdf0e10cSrcweir #endif
53cdf0e10cSrcweir #include <tools/svwin.h>
54cdf0e10cSrcweir #ifdef _MSC_VER
55cdf0e10cSrcweir #pragma warning (pop)
56cdf0e10cSrcweir #endif
57cdf0e10cSrcweir #endif
58cdf0e10cSrcweir 
59cdf0e10cSrcweir #include <tools/debug.hxx>
60cdf0e10cSrcweir #include <rtl/string.h>
61cdf0e10cSrcweir 
62cdf0e10cSrcweir #include <vector>
63cdf0e10cSrcweir 
64cdf0e10cSrcweir #include <osl/diagnose.h>
65cdf0e10cSrcweir 
66cdf0e10cSrcweir // =======================================================================
67cdf0e10cSrcweir 
68cdf0e10cSrcweir #ifdef DBG_UTIL
69cdf0e10cSrcweir 
70cdf0e10cSrcweir // --- DbgErrors ---
71cdf0e10cSrcweir 
72cdf0e10cSrcweir static sal_Char const DbgError_ProfEnd1[]   = "DBG_PROF...() without DBG_PROFSTART(): ";
73cdf0e10cSrcweir static sal_Char const DbgError_Xtor1[]      = "DBG_DTOR() or DBG_CHKTHIS() without DBG_CTOR(): ";
74cdf0e10cSrcweir 
75cdf0e10cSrcweir static sal_Char const DbgError_CtorDtor1[]  = "this == NULL in class ";
76cdf0e10cSrcweir static sal_Char const DbgError_CtorDtor2[]  = "invalid this-Pointer %p in class ";
77cdf0e10cSrcweir static sal_Char const DbgError_CtorDtor3[]  = "Error-Msg from Object %p in class ";
78cdf0e10cSrcweir 
79cdf0e10cSrcweir static sal_Char const DbgTrace_EnterCtor[]  = "Enter Ctor from class ";
80cdf0e10cSrcweir static sal_Char const DbgTrace_LeaveCtor[]  = "Leave Ctor from class ";
81cdf0e10cSrcweir static sal_Char const DbgTrace_EnterDtor[]  = "Enter Dtor from class ";
82cdf0e10cSrcweir static sal_Char const DbgTrace_LeaveDtor[]  = "Leave Dtor from class ";
83cdf0e10cSrcweir static sal_Char const DbgTrace_EnterMeth[]  = "Enter method from class ";
84cdf0e10cSrcweir static sal_Char const DbgTrace_LeaveMeth[]  = "Leave method from class ";
85cdf0e10cSrcweir 
86cdf0e10cSrcweir // --- PointerList ---
87cdf0e10cSrcweir 
88cdf0e10cSrcweir #define PBLOCKCOUNT     1024
89cdf0e10cSrcweir 
90cdf0e10cSrcweir struct PBlock
91cdf0e10cSrcweir {
92cdf0e10cSrcweir     void*       aData[PBLOCKCOUNT];
93cdf0e10cSrcweir     sal_uInt16      nCount;
94cdf0e10cSrcweir     PBlock*     pPrev;
95cdf0e10cSrcweir     PBlock*     pNext;
96cdf0e10cSrcweir };
97cdf0e10cSrcweir 
98cdf0e10cSrcweir class PointerList
99cdf0e10cSrcweir {
100cdf0e10cSrcweir private:
101cdf0e10cSrcweir     PBlock*     pFirst;
102cdf0e10cSrcweir     PBlock*     pLast;
103cdf0e10cSrcweir     sal_uIntPtr       nCount;
104cdf0e10cSrcweir 
105cdf0e10cSrcweir public:
106cdf0e10cSrcweir                 PointerList() { pFirst = NULL; pLast = NULL; nCount = 0; }
107cdf0e10cSrcweir                 ~PointerList();
108cdf0e10cSrcweir 
109cdf0e10cSrcweir     void        Add( const void* p );
110cdf0e10cSrcweir     sal_Bool        Remove( const void* p );
111cdf0e10cSrcweir 
112cdf0e10cSrcweir     const void* Get( sal_uIntPtr nPos ) const;
113cdf0e10cSrcweir     sal_Bool        IsIn( const void* p ) const;
114cdf0e10cSrcweir     sal_uIntPtr       Count() const { return nCount; }
115cdf0e10cSrcweir };
116cdf0e10cSrcweir 
117cdf0e10cSrcweir // --- Datentypen ---
118cdf0e10cSrcweir 
119cdf0e10cSrcweir #define DBG_MAXNAME     28
120cdf0e10cSrcweir 
121cdf0e10cSrcweir struct ProfType
122cdf0e10cSrcweir {
123cdf0e10cSrcweir     sal_uIntPtr                   nCount;
124cdf0e10cSrcweir     sal_uIntPtr                   nTime;
125cdf0e10cSrcweir     sal_uIntPtr                   nMinTime;
126cdf0e10cSrcweir     sal_uIntPtr                   nMaxTime;
127cdf0e10cSrcweir     sal_uIntPtr                   nStart;
128cdf0e10cSrcweir     sal_uIntPtr                   nContinueTime;
129cdf0e10cSrcweir     sal_uIntPtr                   nContinueStart;
130cdf0e10cSrcweir     sal_Char                aName[DBG_MAXNAME+1];
131cdf0e10cSrcweir };
132cdf0e10cSrcweir 
133cdf0e10cSrcweir struct XtorType
134cdf0e10cSrcweir {
135cdf0e10cSrcweir     sal_uIntPtr                   nCtorCalls;
136cdf0e10cSrcweir     sal_uIntPtr                   nDtorCalls;
137cdf0e10cSrcweir     sal_uIntPtr                   nMaxCount;
138cdf0e10cSrcweir     sal_uIntPtr                   nStatics;
139cdf0e10cSrcweir     sal_Char                aName[DBG_MAXNAME+1];
140cdf0e10cSrcweir     sal_Bool                    bTest;
141cdf0e10cSrcweir     PointerList             aThisList;
142cdf0e10cSrcweir };
143cdf0e10cSrcweir 
144cdf0e10cSrcweir struct DebugData
145cdf0e10cSrcweir {
146cdf0e10cSrcweir     DbgData                 aDbgData;
147cdf0e10cSrcweir     sal_uInt16                  bInit;
148cdf0e10cSrcweir     DbgPrintLine            pDbgPrintMsgBox;
149cdf0e10cSrcweir     DbgPrintLine            pDbgPrintWindow;
150cdf0e10cSrcweir     DbgPrintLine            pDbgPrintTestTool;
151cdf0e10cSrcweir 	DbgPrintLine			pDbgAbort;
152cdf0e10cSrcweir     ::std::vector< DbgPrintLine >
153cdf0e10cSrcweir                             aDbgPrintUserChannels;
154cdf0e10cSrcweir     PointerList*            pProfList;
155cdf0e10cSrcweir     PointerList*            pXtorList;
156cdf0e10cSrcweir     DbgTestSolarMutexProc   pDbgTestSolarMutex;
157cdf0e10cSrcweir     pfunc_osl_printDetailedDebugMessage
158cdf0e10cSrcweir                             pOldDebugMessageFunc;
159cdf0e10cSrcweir     bool                    bOslIsHooked;
160cdf0e10cSrcweir 
161cdf0e10cSrcweir     DebugData()
162cdf0e10cSrcweir         :bInit( sal_False )
163cdf0e10cSrcweir         ,pDbgPrintMsgBox( NULL )
164cdf0e10cSrcweir         ,pDbgPrintWindow( NULL )
165cdf0e10cSrcweir         ,pDbgPrintTestTool( NULL )
166cdf0e10cSrcweir 		,pDbgAbort( NULL )
167cdf0e10cSrcweir         ,pProfList( NULL )
168cdf0e10cSrcweir         ,pXtorList( NULL )
169cdf0e10cSrcweir         ,pDbgTestSolarMutex( NULL )
170cdf0e10cSrcweir         ,pOldDebugMessageFunc( NULL )
171cdf0e10cSrcweir         ,bOslIsHooked( false )
172cdf0e10cSrcweir     {
173cdf0e10cSrcweir         aDbgData.nTestFlags = DBG_TEST_RESOURCE | DBG_TEST_MEM_INIT;
174cdf0e10cSrcweir         aDbgData.bOverwrite = sal_True;
175cdf0e10cSrcweir         aDbgData.nTraceOut = DBG_OUT_NULL;
176cdf0e10cSrcweir         aDbgData.nWarningOut = DBG_OUT_NULL;
177cdf0e10cSrcweir         aDbgData.nErrorOut = DBG_OUT_MSGBOX;
178cdf0e10cSrcweir         aDbgData.bMemInit = 0x77;
179cdf0e10cSrcweir         aDbgData.bMemBound = 0x55;
180cdf0e10cSrcweir         aDbgData.bMemFree = 0x33;
181cdf0e10cSrcweir         aDbgData.bHookOSLAssert = sal_True;
182cdf0e10cSrcweir         aDbgData.aDebugName[0] = 0;
183cdf0e10cSrcweir         aDbgData.aInclFilter[0] = 0;
184cdf0e10cSrcweir         aDbgData.aExclFilter[0] = 0;
185cdf0e10cSrcweir         aDbgData.aInclClassFilter[0] = 0;
186cdf0e10cSrcweir         aDbgData.aExclClassFilter[0] = 0;
187cdf0e10cSrcweir         aDbgData.aDbgWinState[0] = 0;
188cdf0e10cSrcweir     }
189cdf0e10cSrcweir };
190cdf0e10cSrcweir 
191cdf0e10cSrcweir #define DBG_TEST_XTOR_EXTRA (DBG_TEST_XTOR_THIS |  DBG_TEST_XTOR_FUNC |               \
192cdf0e10cSrcweir                              DBG_TEST_XTOR_EXIT |  DBG_TEST_XTOR_REPORT )
193cdf0e10cSrcweir 
194cdf0e10cSrcweir // ------------------------------
195cdf0e10cSrcweir // - statische Verwaltungsdaten -
196cdf0e10cSrcweir // ------------------------------
197cdf0e10cSrcweir 
198cdf0e10cSrcweir static DebugData aDebugData;
199cdf0e10cSrcweir 
200cdf0e10cSrcweir static sal_Char aCurPath[260];
201cdf0e10cSrcweir 
202cdf0e10cSrcweir static int bDbgImplInMain = sal_False;
203cdf0e10cSrcweir 
204cdf0e10cSrcweir // =======================================================================
205cdf0e10cSrcweir 
206cdf0e10cSrcweir #if defined( WNT )
207cdf0e10cSrcweir static CRITICAL_SECTION aImplCritDbgSection;
208cdf0e10cSrcweir #elif defined( OS2 )
209cdf0e10cSrcweir static HMTX             hImplCritDbgSection = 0;
210cdf0e10cSrcweir #endif
211cdf0e10cSrcweir static sal_Bool             bImplCritDbgSectionInit = sal_False;
212cdf0e10cSrcweir 
213cdf0e10cSrcweir // -----------------------------------------------------------------------
214cdf0e10cSrcweir 
215cdf0e10cSrcweir void ImplDbgInitLock()
216cdf0e10cSrcweir {
217cdf0e10cSrcweir #if defined( WNT )
218cdf0e10cSrcweir     InitializeCriticalSection( &aImplCritDbgSection );
219cdf0e10cSrcweir #elif defined( OS2 )
220cdf0e10cSrcweir     DosCreateMutexSem( NULL, &hImplCritDbgSection, 0, sal_False );
221cdf0e10cSrcweir #endif
222cdf0e10cSrcweir     bImplCritDbgSectionInit = sal_True;
223cdf0e10cSrcweir }
224cdf0e10cSrcweir 
225cdf0e10cSrcweir // -----------------------------------------------------------------------
226cdf0e10cSrcweir 
227cdf0e10cSrcweir void ImplDbgDeInitLock()
228cdf0e10cSrcweir {
229cdf0e10cSrcweir #if defined( WNT )
230cdf0e10cSrcweir     DeleteCriticalSection( &aImplCritDbgSection );
231cdf0e10cSrcweir #elif defined( OS2 )
232cdf0e10cSrcweir     DosCloseMutexSem( hImplCritDbgSection );
233cdf0e10cSrcweir #endif
234cdf0e10cSrcweir     bImplCritDbgSectionInit = sal_False;
235cdf0e10cSrcweir }
236cdf0e10cSrcweir 
237cdf0e10cSrcweir // -----------------------------------------------------------------------
238cdf0e10cSrcweir 
239cdf0e10cSrcweir void ImplDbgLock()
240cdf0e10cSrcweir {
241cdf0e10cSrcweir     if ( !bImplCritDbgSectionInit )
242cdf0e10cSrcweir         return;
243cdf0e10cSrcweir 
244cdf0e10cSrcweir #if defined( WNT )
245cdf0e10cSrcweir     EnterCriticalSection( &aImplCritDbgSection );
246cdf0e10cSrcweir #elif defined( OS2 )
247cdf0e10cSrcweir     DosRequestMutexSem( hImplCritDbgSection, SEM_INDEFINITE_WAIT );
248cdf0e10cSrcweir #endif
249cdf0e10cSrcweir }
250cdf0e10cSrcweir 
251cdf0e10cSrcweir // -----------------------------------------------------------------------
252cdf0e10cSrcweir 
253cdf0e10cSrcweir void ImplDbgUnlock()
254cdf0e10cSrcweir {
255cdf0e10cSrcweir     if ( !bImplCritDbgSectionInit )
256cdf0e10cSrcweir         return;
257cdf0e10cSrcweir 
258cdf0e10cSrcweir #if defined( WNT )
259cdf0e10cSrcweir     LeaveCriticalSection( &aImplCritDbgSection );
260cdf0e10cSrcweir #elif defined( OS2 )
261cdf0e10cSrcweir     DosReleaseMutexSem( hImplCritDbgSection );
262cdf0e10cSrcweir #endif
263cdf0e10cSrcweir }
264cdf0e10cSrcweir 
265cdf0e10cSrcweir // =======================================================================
266cdf0e10cSrcweir 
267cdf0e10cSrcweir #if (defined WNT || defined OS2) && !defined SVX_LIGHT
268cdf0e10cSrcweir //#define SV_MEMMGR //
269cdf0e10cSrcweir #endif
270cdf0e10cSrcweir #ifdef SV_MEMMGR
271cdf0e10cSrcweir void DbgImpCheckMemory( void* p = NULL );
272cdf0e10cSrcweir void DbgImpCheckMemoryDeInit();
273cdf0e10cSrcweir void DbgImpMemoryInfo( sal_Char* pBuf );
274cdf0e10cSrcweir #endif
275cdf0e10cSrcweir 
276cdf0e10cSrcweir #define FILE_LINEEND    "\n"
277cdf0e10cSrcweir 
278cdf0e10cSrcweir // =======================================================================
279cdf0e10cSrcweir 
280cdf0e10cSrcweir static sal_Bool ImplActivateDebugger( const sal_Char* pMsg )
281cdf0e10cSrcweir {
282cdf0e10cSrcweir #if defined( WNT )
283cdf0e10cSrcweir     static sal_Char aImplDbgOutBuf[DBG_BUF_MAXLEN];
284cdf0e10cSrcweir     strcpy( aImplDbgOutBuf, pMsg );
285cdf0e10cSrcweir     strcat( aImplDbgOutBuf, "\r\n" );
286cdf0e10cSrcweir     OutputDebugString( aImplDbgOutBuf );
287cdf0e10cSrcweir     DebugBreak();
288cdf0e10cSrcweir     return sal_True;
289cdf0e10cSrcweir #else
290cdf0e10cSrcweir     (void) pMsg; // avoid warning about unused parameter
291cdf0e10cSrcweir     return sal_False;
292cdf0e10cSrcweir #endif
293cdf0e10cSrcweir }
294cdf0e10cSrcweir 
295cdf0e10cSrcweir // -----------------------------------------------------------------------
296cdf0e10cSrcweir 
297cdf0e10cSrcweir static sal_Bool ImplCoreDump()
298cdf0e10cSrcweir {
299cdf0e10cSrcweir #if defined( WNT )
300cdf0e10cSrcweir     DebugBreak();
301cdf0e10cSrcweir #else
302cdf0e10cSrcweir     long* pTemp = 0;
303cdf0e10cSrcweir     *pTemp = 0xCCCC;
304cdf0e10cSrcweir #endif
305cdf0e10cSrcweir     return sal_True;
306cdf0e10cSrcweir }
307cdf0e10cSrcweir 
308cdf0e10cSrcweir // =======================================================================
309cdf0e10cSrcweir 
310cdf0e10cSrcweir static sal_uIntPtr ImplGetPerfTime()
311cdf0e10cSrcweir {
312cdf0e10cSrcweir #if defined( WNT )
313cdf0e10cSrcweir     return (sal_uIntPtr)GetTickCount();
314cdf0e10cSrcweir #elif defined( OS2 )
315cdf0e10cSrcweir     sal_uIntPtr nClock;
316cdf0e10cSrcweir     DosQuerySysInfo( QSV_MS_COUNT, QSV_MS_COUNT, &nClock, sizeof( nClock ) );
317cdf0e10cSrcweir     return (sal_uIntPtr)nClock;
318cdf0e10cSrcweir #else
319cdf0e10cSrcweir     static sal_uIntPtr    nImplTicksPerSecond = 0;
320cdf0e10cSrcweir     static double   dImplTicksPerSecond;
321cdf0e10cSrcweir     sal_uIntPtr           nTicks = (sal_uIntPtr)clock();
322cdf0e10cSrcweir 
323cdf0e10cSrcweir     if ( !nImplTicksPerSecond )
324cdf0e10cSrcweir     {
325cdf0e10cSrcweir         nImplTicksPerSecond = CLOCKS_PER_SEC;
326cdf0e10cSrcweir         dImplTicksPerSecond = nImplTicksPerSecond;
327cdf0e10cSrcweir     }
328cdf0e10cSrcweir 
329cdf0e10cSrcweir     double fTicks = nTicks;
330cdf0e10cSrcweir     fTicks *= 1000;
331cdf0e10cSrcweir     fTicks /= dImplTicksPerSecond;
332cdf0e10cSrcweir     return (sal_uIntPtr)fTicks;
333cdf0e10cSrcweir #endif
334cdf0e10cSrcweir }
335cdf0e10cSrcweir 
336cdf0e10cSrcweir // -----------------------------------------------------------------------
337cdf0e10cSrcweir 
338cdf0e10cSrcweir typedef FILE*       FILETYPE;
339cdf0e10cSrcweir #define FileOpen    fopen
340cdf0e10cSrcweir #define FileRead    fread
341cdf0e10cSrcweir #define FileWrite   fwrite
342cdf0e10cSrcweir #define FilePrintF  fprintf
343cdf0e10cSrcweir #define FileClose   fclose
344cdf0e10cSrcweir 
345cdf0e10cSrcweir // =======================================================================
346cdf0e10cSrcweir 
347cdf0e10cSrcweir namespace
348cdf0e10cSrcweir {
349cdf0e10cSrcweir     enum ConfigSection
350cdf0e10cSrcweir     {
351cdf0e10cSrcweir         eOutput,
352cdf0e10cSrcweir         eMemory,
353cdf0e10cSrcweir         eGUI,
354cdf0e10cSrcweir         eObjects,
355cdf0e10cSrcweir         eTest,
356cdf0e10cSrcweir 
357cdf0e10cSrcweir         eUnknown
358cdf0e10cSrcweir     };
359cdf0e10cSrcweir 
360cdf0e10cSrcweir     void lcl_lineFeed( FILETYPE _pFile )
361cdf0e10cSrcweir     {
362cdf0e10cSrcweir         FilePrintF( _pFile, "%s", FILE_LINEEND );
363cdf0e10cSrcweir     }
364cdf0e10cSrcweir 
365cdf0e10cSrcweir     const sal_Char* lcl_getSectionName( ConfigSection _eSection )
366cdf0e10cSrcweir     {
367cdf0e10cSrcweir         const sal_Char* pSectionName = NULL;
368cdf0e10cSrcweir         switch ( _eSection )
369cdf0e10cSrcweir         {
370cdf0e10cSrcweir             case eOutput    : pSectionName = "output";  break;
371cdf0e10cSrcweir             case eMemory    : pSectionName = "memory";  break;
372cdf0e10cSrcweir             case eGUI       : pSectionName = "gui";     break;
373cdf0e10cSrcweir             case eObjects   : pSectionName = "objects"; break;
374cdf0e10cSrcweir             case eTest      : pSectionName = "test";    break;
375cdf0e10cSrcweir             case eUnknown:
376cdf0e10cSrcweir                 OSL_ASSERT(false);
377cdf0e10cSrcweir                 break;
378cdf0e10cSrcweir         }
379cdf0e10cSrcweir         return pSectionName;
380cdf0e10cSrcweir     }
381cdf0e10cSrcweir 
382cdf0e10cSrcweir     ConfigSection lcl_getSectionFromName( const sal_Char* _pSectionName, size_t _nSectionNameLength )
383cdf0e10cSrcweir     {
384cdf0e10cSrcweir         if ( strncmp( _pSectionName, "output",  _nSectionNameLength < 6 ? _nSectionNameLength : 6 ) == 0 )
385cdf0e10cSrcweir             return eOutput;
386cdf0e10cSrcweir         if ( strncmp( _pSectionName, "memory",  _nSectionNameLength < 6 ? _nSectionNameLength : 6 ) == 0 )
387cdf0e10cSrcweir             return eMemory;
388cdf0e10cSrcweir         if ( strncmp( _pSectionName, "gui",     _nSectionNameLength < 3 ? _nSectionNameLength : 3 ) == 0 )
389cdf0e10cSrcweir             return eGUI;
390cdf0e10cSrcweir         if ( strncmp( _pSectionName, "objects", _nSectionNameLength < 7 ? _nSectionNameLength : 7 ) == 0 )
391cdf0e10cSrcweir             return eObjects;
392cdf0e10cSrcweir         if ( strncmp( _pSectionName, "test",    _nSectionNameLength < 4 ? _nSectionNameLength : 4 ) == 0 )
393cdf0e10cSrcweir             return eTest;
394cdf0e10cSrcweir         return eUnknown;
395cdf0e10cSrcweir     }
396cdf0e10cSrcweir 
397cdf0e10cSrcweir     void lcl_startSection( FILETYPE _pFile, ConfigSection _eSection )
398cdf0e10cSrcweir     {
399cdf0e10cSrcweir         FilePrintF( _pFile, "[%s]%s", lcl_getSectionName( _eSection ), FILE_LINEEND );
400cdf0e10cSrcweir     }
401cdf0e10cSrcweir 
402cdf0e10cSrcweir     void lcl_writeConfigString( FILETYPE _pFile, const sal_Char* _pKeyName, const sal_Char* _pValue )
403cdf0e10cSrcweir     {
404cdf0e10cSrcweir         FilePrintF( _pFile, "%s=%s%s", _pKeyName, _pValue, FILE_LINEEND );
405cdf0e10cSrcweir     }
406cdf0e10cSrcweir 
407cdf0e10cSrcweir     void lcl_writeConfigBoolean( FILETYPE _pFile, const sal_Char* _pKeyName, bool _bValue )
408cdf0e10cSrcweir     {
409cdf0e10cSrcweir         lcl_writeConfigString( _pFile, _pKeyName, _bValue ? "1" : "0" );
410cdf0e10cSrcweir     }
411cdf0e10cSrcweir 
412cdf0e10cSrcweir     void lcl_writeConfigFlag( FILETYPE _pFile, const sal_Char* _pKeyName, sal_uIntPtr _nAllFlags, sal_uIntPtr _nCheckFlag )
413cdf0e10cSrcweir     {
414cdf0e10cSrcweir         lcl_writeConfigBoolean( _pFile, _pKeyName, ( _nAllFlags & _nCheckFlag ) != 0 );
415cdf0e10cSrcweir     }
416cdf0e10cSrcweir 
417cdf0e10cSrcweir     void lcl_writeConfigOutChannel( FILETYPE _pFile, const sal_Char* _pKeyName, sal_uIntPtr _nValue )
418cdf0e10cSrcweir     {
419cdf0e10cSrcweir         const sal_Char* names[ DBG_OUT_COUNT ] =
420cdf0e10cSrcweir         {
421cdf0e10cSrcweir             "dev/null", "file", "window", "shell", "messagebox", "testtool", "debugger", "abort"
422cdf0e10cSrcweir         };
423cdf0e10cSrcweir         lcl_writeConfigString( _pFile, _pKeyName, names[ _nValue ] );
424cdf0e10cSrcweir     }
425cdf0e10cSrcweir     void lcl_writeHexByte( FILETYPE _pFile, const sal_Char* _pKeyName, sal_uInt8 _nValue )
426cdf0e10cSrcweir     {
427cdf0e10cSrcweir         sal_Char buf[RTL_STR_MAX_VALUEOFINT32];
428cdf0e10cSrcweir         rtl_String* stringData = NULL;
429cdf0e10cSrcweir         rtl_string_newFromStr_WithLength( &stringData, buf, rtl_str_valueOfInt32( buf, _nValue, 16 ) );
430cdf0e10cSrcweir 
431cdf0e10cSrcweir         lcl_writeConfigString( _pFile, _pKeyName, stringData->buffer );
432cdf0e10cSrcweir 
433cdf0e10cSrcweir         rtl_string_release( stringData );
434cdf0e10cSrcweir     }
435cdf0e10cSrcweir     bool lcl_isConfigSection( const sal_Char* _pLine, size_t _nLineLen )
436cdf0e10cSrcweir     {
437cdf0e10cSrcweir         if ( _nLineLen < 2 )
438cdf0e10cSrcweir             // not even enough space for '[' and ']'
439cdf0e10cSrcweir             return false;
440cdf0e10cSrcweir         if ( ( _pLine[0] == '[' ) && ( _pLine[ _nLineLen - 1 ] == ']' ) )
441cdf0e10cSrcweir             return true;
442cdf0e10cSrcweir         return false;
443cdf0e10cSrcweir     }
444cdf0e10cSrcweir     bool lcl_isConfigKey( const sal_Char* _pLine, size_t _nLineLen, const sal_Char* _pKeyName )
445cdf0e10cSrcweir     {
446cdf0e10cSrcweir         size_t nKeyLength = strlen( _pKeyName );
447cdf0e10cSrcweir         if ( nKeyLength + 1 >= _nLineLen )
448cdf0e10cSrcweir             // not even long enough for the key name plus "=" plus a one-character value
449cdf0e10cSrcweir             return false;
450cdf0e10cSrcweir         if ( ( strncmp( _pLine, _pKeyName, nKeyLength ) == 0 ) && ( _pLine[ nKeyLength ] == '=' ) )
451cdf0e10cSrcweir             return true;
452cdf0e10cSrcweir         return false;
453cdf0e10cSrcweir     }
454cdf0e10cSrcweir     sal_Int32 lcl_tryReadConfigString( const sal_Char* _pLine, size_t _nLineLen, const sal_Char* _pKeyName, sal_Char* _pValue, size_t _nValueLen )
455cdf0e10cSrcweir     {
456cdf0e10cSrcweir         if ( !lcl_isConfigKey( _pLine, _nLineLen, _pKeyName ) )
457cdf0e10cSrcweir             return 0;
458cdf0e10cSrcweir         size_t nValuePos = strlen( _pKeyName ) + 1;
459cdf0e10cSrcweir         size_t nValueLen = _nLineLen - nValuePos;
460cdf0e10cSrcweir         const sal_Char* pValue = _pLine + nValuePos;
461cdf0e10cSrcweir         strncpy( _pValue, pValue, ( _nValueLen > nValueLen ) ? nValueLen : _nValueLen );
462cdf0e10cSrcweir         _pValue[ ( _nValueLen > nValueLen ) ? nValueLen : _nValueLen - 1 ] = 0;
463cdf0e10cSrcweir         return strlen( _pValue );
464cdf0e10cSrcweir     }
465cdf0e10cSrcweir     void lcl_tryReadConfigBoolean( const sal_Char* _pLine, size_t _nLineLen, const sal_Char* _pKeyName, sal_uIntPtr* _out_pnValue )
466cdf0e10cSrcweir     {
467cdf0e10cSrcweir         sal_Char aBuf[2];
468cdf0e10cSrcweir         size_t nValueLen = lcl_tryReadConfigString( _pLine, _nLineLen, _pKeyName, aBuf, sizeof( aBuf ) );
469cdf0e10cSrcweir         if ( nValueLen )
470cdf0e10cSrcweir             *_out_pnValue = strcmp( aBuf, "1" ) == 0 ? sal_True : sal_False;
471cdf0e10cSrcweir     }
472cdf0e10cSrcweir     void lcl_matchOutputChannel( sal_Char const * i_buffer, sal_uIntPtr* o_value )
473cdf0e10cSrcweir     {
474cdf0e10cSrcweir         if ( i_buffer == NULL )
475cdf0e10cSrcweir             return;
476cdf0e10cSrcweir         const sal_Char* names[ DBG_OUT_COUNT ] =
477cdf0e10cSrcweir         {
478cdf0e10cSrcweir             "dev/null", "file", "window", "shell", "messagebox", "testtool", "debugger", "abort"
479cdf0e10cSrcweir         };
480cdf0e10cSrcweir         for ( sal_uIntPtr name = 0; name < sizeof( names ) / sizeof( names[0] ); ++name )
481cdf0e10cSrcweir         {
482cdf0e10cSrcweir             if ( strcmp( i_buffer, names[ name ] ) == 0 )
483cdf0e10cSrcweir             {
484cdf0e10cSrcweir                 *o_value = name;
485cdf0e10cSrcweir                 return;
486cdf0e10cSrcweir             }
487cdf0e10cSrcweir         }
488cdf0e10cSrcweir     }
489cdf0e10cSrcweir     void lcl_tryReadOutputChannel( const sal_Char* _pLine, size_t _nLineLen, const sal_Char* _pKeyName, sal_uIntPtr* _out_pnValue )
490cdf0e10cSrcweir     {
491cdf0e10cSrcweir         sal_Char aBuf[20];
492cdf0e10cSrcweir         size_t nValueLen = lcl_tryReadConfigString( _pLine, _nLineLen, _pKeyName, aBuf, sizeof( aBuf ) );
493cdf0e10cSrcweir         if ( nValueLen )
494cdf0e10cSrcweir             lcl_matchOutputChannel( aBuf, _out_pnValue );
495cdf0e10cSrcweir     }
496cdf0e10cSrcweir     void lcl_tryReadConfigFlag( const sal_Char* _pLine, size_t _nLineLen, const sal_Char* _pKeyName, sal_uIntPtr* _out_pnAllFlags, sal_uIntPtr _nCheckFlag )
497cdf0e10cSrcweir     {
498cdf0e10cSrcweir         sal_Char aBuf[2];
499cdf0e10cSrcweir         size_t nValueLen = lcl_tryReadConfigString( _pLine, _nLineLen, _pKeyName, aBuf, sizeof( aBuf ) );
500cdf0e10cSrcweir         if ( nValueLen )
501cdf0e10cSrcweir             if ( strcmp( aBuf, "1" ) == 0 )
502cdf0e10cSrcweir                 *_out_pnAllFlags |= _nCheckFlag;
503cdf0e10cSrcweir             else
504cdf0e10cSrcweir                 *_out_pnAllFlags &= ~_nCheckFlag;
505cdf0e10cSrcweir     }
506cdf0e10cSrcweir     void lcl_tryReadHexByte( const sal_Char* _pLine, size_t _nLineLen, const sal_Char* _pKeyName, sal_uInt8* _out_pnValue )
507cdf0e10cSrcweir     {
508cdf0e10cSrcweir         sal_Char aBuf[3];
509cdf0e10cSrcweir         size_t nValueLen = lcl_tryReadConfigString( _pLine, _nLineLen, _pKeyName, aBuf, sizeof( aBuf ) );
510cdf0e10cSrcweir         if ( nValueLen )
511cdf0e10cSrcweir             *_out_pnValue = (sal_uInt8)rtl_str_toInt32( aBuf, 16 );
512cdf0e10cSrcweir     }
513cdf0e10cSrcweir }
514cdf0e10cSrcweir 
515cdf0e10cSrcweir // =======================================================================
516cdf0e10cSrcweir 
517cdf0e10cSrcweir PointerList::~PointerList()
518cdf0e10cSrcweir {
519cdf0e10cSrcweir     PBlock* pBlock = pFirst;
520cdf0e10cSrcweir     while ( pBlock )
521cdf0e10cSrcweir     {
522cdf0e10cSrcweir         PBlock* pNextBlock = pBlock->pNext;
523cdf0e10cSrcweir         delete pBlock;
524cdf0e10cSrcweir         pBlock = pNextBlock;
525cdf0e10cSrcweir     }
526cdf0e10cSrcweir }
527cdf0e10cSrcweir 
528cdf0e10cSrcweir // -----------------------------------------------------------------------
529cdf0e10cSrcweir 
530cdf0e10cSrcweir void PointerList::Add( const void* p )
531cdf0e10cSrcweir {
532cdf0e10cSrcweir     if ( !pFirst )
533cdf0e10cSrcweir     {
534cdf0e10cSrcweir         pFirst = new PBlock;
535cdf0e10cSrcweir         memset( pFirst->aData, 0, PBLOCKCOUNT * sizeof( void* ) );
536cdf0e10cSrcweir         pFirst->nCount = 0;
537cdf0e10cSrcweir         pFirst->pPrev  = NULL;
538cdf0e10cSrcweir         pFirst->pNext  = NULL;
539cdf0e10cSrcweir         pLast = pFirst;
540cdf0e10cSrcweir     }
541cdf0e10cSrcweir 
542cdf0e10cSrcweir     PBlock* pBlock = pFirst;
543cdf0e10cSrcweir     while ( pBlock && (pBlock->nCount == PBLOCKCOUNT) )
544cdf0e10cSrcweir         pBlock = pBlock->pNext;
545cdf0e10cSrcweir 
546cdf0e10cSrcweir     if ( !pBlock )
547cdf0e10cSrcweir     {
548cdf0e10cSrcweir         pBlock = new PBlock;
549cdf0e10cSrcweir         memset( pBlock->aData, 0, PBLOCKCOUNT * sizeof( void* ) );
550cdf0e10cSrcweir         pBlock->nCount = 0;
551cdf0e10cSrcweir         pBlock->pPrev  = pLast;
552cdf0e10cSrcweir         pBlock->pNext  = NULL;
553cdf0e10cSrcweir         pLast->pNext   = pBlock;
554cdf0e10cSrcweir         pLast          = pBlock;
555cdf0e10cSrcweir     }
556cdf0e10cSrcweir 
557cdf0e10cSrcweir     sal_uInt16 i = 0;
558cdf0e10cSrcweir     while ( pBlock->aData[i] )
559cdf0e10cSrcweir         i++;
560cdf0e10cSrcweir 
561cdf0e10cSrcweir     pBlock->aData[i] = (void*)p;
562cdf0e10cSrcweir     pBlock->nCount++;
563cdf0e10cSrcweir     nCount++;
564cdf0e10cSrcweir }
565cdf0e10cSrcweir 
566cdf0e10cSrcweir // -----------------------------------------------------------------------
567cdf0e10cSrcweir 
568cdf0e10cSrcweir sal_Bool PointerList::Remove( const void* p )
569cdf0e10cSrcweir {
570cdf0e10cSrcweir     if ( !p )
571cdf0e10cSrcweir        return sal_False;
572cdf0e10cSrcweir 
573cdf0e10cSrcweir     PBlock* pBlock = pFirst;
574cdf0e10cSrcweir     while ( pBlock )
575cdf0e10cSrcweir     {
576cdf0e10cSrcweir         sal_uInt16 i = 0;
577cdf0e10cSrcweir         while ( i < PBLOCKCOUNT )
578cdf0e10cSrcweir         {
579cdf0e10cSrcweir             if ( ((sal_uIntPtr)p) == ((sal_uIntPtr)pBlock->aData[i]) )
580cdf0e10cSrcweir             {
581cdf0e10cSrcweir                 pBlock->aData[i] = NULL;
582cdf0e10cSrcweir                 pBlock->nCount--;
583cdf0e10cSrcweir                 nCount--;
584cdf0e10cSrcweir 
585cdf0e10cSrcweir                 if ( !pBlock->nCount )
586cdf0e10cSrcweir                 {
587cdf0e10cSrcweir                     if ( pBlock->pPrev )
588cdf0e10cSrcweir                         pBlock->pPrev->pNext = pBlock->pNext;
589cdf0e10cSrcweir                     if ( pBlock->pNext )
590cdf0e10cSrcweir                         pBlock->pNext->pPrev = pBlock->pPrev;
591cdf0e10cSrcweir                     if ( pBlock == pFirst )
592cdf0e10cSrcweir                         pFirst = pBlock->pNext;
593cdf0e10cSrcweir                     if ( pBlock == pLast )
594cdf0e10cSrcweir                         pLast = pBlock->pPrev;
595cdf0e10cSrcweir                     delete pBlock;
596cdf0e10cSrcweir                 }
597cdf0e10cSrcweir 
598cdf0e10cSrcweir                 return sal_True;
599cdf0e10cSrcweir             }
600cdf0e10cSrcweir             i++;
601cdf0e10cSrcweir         }
602cdf0e10cSrcweir 
603cdf0e10cSrcweir         pBlock = pBlock->pNext;
604cdf0e10cSrcweir     }
605cdf0e10cSrcweir 
606cdf0e10cSrcweir     return sal_False;
607cdf0e10cSrcweir }
608cdf0e10cSrcweir 
609cdf0e10cSrcweir // -----------------------------------------------------------------------
610cdf0e10cSrcweir 
611cdf0e10cSrcweir const void* PointerList::Get( sal_uIntPtr nPos ) const
612cdf0e10cSrcweir {
613cdf0e10cSrcweir     if ( nCount <= nPos )
614cdf0e10cSrcweir         return NULL;
615cdf0e10cSrcweir 
616cdf0e10cSrcweir     PBlock* pBlock = pFirst;
617cdf0e10cSrcweir     sal_uIntPtr   nStart = 0;
618cdf0e10cSrcweir     while ( pBlock )
619cdf0e10cSrcweir     {
620cdf0e10cSrcweir         sal_uInt16 i = 0;
621cdf0e10cSrcweir         while ( i < PBLOCKCOUNT )
622cdf0e10cSrcweir         {
623cdf0e10cSrcweir             if ( pBlock->aData[i] )
624cdf0e10cSrcweir             {
625cdf0e10cSrcweir                 nStart++;
626cdf0e10cSrcweir                 if ( (nStart-1) == nPos )
627cdf0e10cSrcweir                     return pBlock->aData[i];
628cdf0e10cSrcweir             }
629cdf0e10cSrcweir 
630cdf0e10cSrcweir             i++;
631cdf0e10cSrcweir         }
632cdf0e10cSrcweir 
633cdf0e10cSrcweir         pBlock = pBlock->pNext;
634cdf0e10cSrcweir     }
635cdf0e10cSrcweir 
636cdf0e10cSrcweir     return NULL;
637cdf0e10cSrcweir }
638cdf0e10cSrcweir 
639cdf0e10cSrcweir // -----------------------------------------------------------------------
640cdf0e10cSrcweir 
641cdf0e10cSrcweir sal_Bool PointerList::IsIn( const void* p ) const
642cdf0e10cSrcweir {
643cdf0e10cSrcweir     if ( !p )
644cdf0e10cSrcweir        return sal_False;
645cdf0e10cSrcweir 
646cdf0e10cSrcweir     PBlock* pBlock = pFirst;
647cdf0e10cSrcweir     while ( pBlock )
648cdf0e10cSrcweir     {
649cdf0e10cSrcweir         sal_uInt16 i = 0;
650cdf0e10cSrcweir         while ( i < PBLOCKCOUNT )
651cdf0e10cSrcweir         {
652cdf0e10cSrcweir             if ( ((sal_uIntPtr)p) == ((sal_uIntPtr)pBlock->aData[i]) )
653cdf0e10cSrcweir                 return sal_True;
654cdf0e10cSrcweir             i++;
655cdf0e10cSrcweir         }
656cdf0e10cSrcweir 
657cdf0e10cSrcweir         pBlock = pBlock->pNext;
658cdf0e10cSrcweir     }
659cdf0e10cSrcweir 
660cdf0e10cSrcweir     return sal_False;
661cdf0e10cSrcweir }
662cdf0e10cSrcweir 
663cdf0e10cSrcweir 
664cdf0e10cSrcweir // =======================================================================
665cdf0e10cSrcweir 
666cdf0e10cSrcweir static void DbgGetDbgFileName( sal_Char* pStr, sal_Int32 nMaxLen )
667cdf0e10cSrcweir {
668cdf0e10cSrcweir #if defined( UNX )
669cdf0e10cSrcweir     const sal_Char* pName = getenv("DBGSV_INIT");
670cdf0e10cSrcweir     if ( !pName )
671cdf0e10cSrcweir         pName = ".dbgsv.init";
672cdf0e10cSrcweir     strncpy( pStr, pName, nMaxLen );
673cdf0e10cSrcweir #elif defined( WNT )
674cdf0e10cSrcweir     const sal_Char* pName = getenv("DBGSV_INIT");
675cdf0e10cSrcweir     if ( pName )
676cdf0e10cSrcweir         strncpy( pStr, pName, nMaxLen );
677cdf0e10cSrcweir     else
678cdf0e10cSrcweir         GetProfileStringA( "sv", "dbgsv", "dbgsv.ini", pStr, nMaxLen );
679cdf0e10cSrcweir #elif defined( OS2 )
680cdf0e10cSrcweir     PrfQueryProfileString( HINI_PROFILE, (PSZ)"SV", (PSZ)"DBGSV",
681cdf0e10cSrcweir                            "dbgsv.ini", (PSZ)pStr, nMaxLen );
682cdf0e10cSrcweir #else
683cdf0e10cSrcweir     strncpy( pStr, "dbgsv.ini", nMaxLen );
684cdf0e10cSrcweir #endif
685cdf0e10cSrcweir     pStr[ nMaxLen - 1 ] = 0;
686cdf0e10cSrcweir }
687cdf0e10cSrcweir 
688cdf0e10cSrcweir // -----------------------------------------------------------------------
689cdf0e10cSrcweir 
690cdf0e10cSrcweir static void DbgGetLogFileName( sal_Char* pStr )
691cdf0e10cSrcweir {
692cdf0e10cSrcweir #if defined( UNX )
693cdf0e10cSrcweir     const sal_Char* pName = getenv("DBGSV_LOG");
694cdf0e10cSrcweir     if ( !pName )
695cdf0e10cSrcweir         pName = "dbgsv.log";
696cdf0e10cSrcweir     strcpy( pStr, pName );
697cdf0e10cSrcweir #elif defined( WNT )
698cdf0e10cSrcweir     const sal_Char* pName = getenv("DBGSV_LOG");
699cdf0e10cSrcweir     if ( pName )
700cdf0e10cSrcweir         strcpy( pStr, pName );
701cdf0e10cSrcweir     else
702cdf0e10cSrcweir         GetProfileStringA( "sv", "dbgsvlog", "dbgsv.log", pStr, 200 );
703cdf0e10cSrcweir #elif defined( OS2 )
704cdf0e10cSrcweir     PrfQueryProfileString( HINI_PROFILE, (PSZ)"SV", (PSZ)"DBGSVLOG",
705cdf0e10cSrcweir                            "dbgsv.log", (PSZ)pStr, 200 );
706cdf0e10cSrcweir #else
707cdf0e10cSrcweir     strcpy( pStr, "dbgsv.log" );
708cdf0e10cSrcweir #endif
709cdf0e10cSrcweir }
710cdf0e10cSrcweir 
711cdf0e10cSrcweir // -----------------------------------------------------------------------
712cdf0e10cSrcweir 
713cdf0e10cSrcweir static void DbgDebugBeep()
714cdf0e10cSrcweir {
715cdf0e10cSrcweir #if defined( WNT )
716cdf0e10cSrcweir     MessageBeep( MB_ICONHAND );
717cdf0e10cSrcweir #elif defined( OS2 )
718cdf0e10cSrcweir     WinAlarm( HWND_DESKTOP, WA_ERROR );
719cdf0e10cSrcweir #endif
720cdf0e10cSrcweir }
721cdf0e10cSrcweir 
722cdf0e10cSrcweir // -----------------------------------------------------------------------
723cdf0e10cSrcweir 
724cdf0e10cSrcweir static DebugData* GetDebugData()
725cdf0e10cSrcweir {
726cdf0e10cSrcweir     if ( !aDebugData.bInit )
727cdf0e10cSrcweir     {
728cdf0e10cSrcweir         aDebugData.bInit = sal_True;
729cdf0e10cSrcweir 
730cdf0e10cSrcweir         // Default Debug-Namen setzen
731cdf0e10cSrcweir         DbgGetLogFileName( aDebugData.aDbgData.aDebugName );
732cdf0e10cSrcweir 
733cdf0e10cSrcweir         // DEBUG.INI-File
734cdf0e10cSrcweir         sal_Char aBuf[ 4096 ];
735cdf0e10cSrcweir         DbgGetDbgFileName( aBuf, sizeof( aBuf ) );
736cdf0e10cSrcweir         FILETYPE pIniFile = FileOpen( aBuf, "r" );
737cdf0e10cSrcweir         if ( pIniFile != NULL )
738cdf0e10cSrcweir         {
739cdf0e10cSrcweir             ConfigSection eCurrentSection = eUnknown;
740cdf0e10cSrcweir 
741cdf0e10cSrcweir             // no sophisticated algorithm here, assume that the whole file fits into aBuf ...
742cdf0e10cSrcweir             sal_uIntPtr nReallyRead = FileRead( aBuf, 1, sizeof( aBuf ) / sizeof( sal_Char ) - 1, pIniFile );
743cdf0e10cSrcweir             aBuf[ nReallyRead ] = 0;
744cdf0e10cSrcweir             const sal_Char* pLine = aBuf;
745cdf0e10cSrcweir             while ( const sal_Char* pNextLine = strstr( pLine, FILE_LINEEND ) )
746cdf0e10cSrcweir             {
747cdf0e10cSrcweir                 size_t nLineLength = pNextLine - pLine;
748cdf0e10cSrcweir 
749cdf0e10cSrcweir                 if ( lcl_isConfigSection( pLine, nLineLength ) )
750cdf0e10cSrcweir                     eCurrentSection = lcl_getSectionFromName( pLine + 1, nLineLength - 2 );
751cdf0e10cSrcweir 
752cdf0e10cSrcweir                 // elements of the [output] section
753cdf0e10cSrcweir                 if ( eCurrentSection == eOutput )
754cdf0e10cSrcweir                 {
755cdf0e10cSrcweir                     lcl_tryReadConfigString( pLine, nLineLength, "log_file", aDebugData.aDbgData.aDebugName, sizeof( aDebugData.aDbgData.aDebugName ) );
756cdf0e10cSrcweir                     lcl_tryReadConfigBoolean( pLine, nLineLength, "overwrite", &aDebugData.aDbgData.bOverwrite );
757cdf0e10cSrcweir                     lcl_tryReadConfigString( pLine, nLineLength, "include", aDebugData.aDbgData.aInclFilter, sizeof( aDebugData.aDbgData.aInclFilter ) );
758cdf0e10cSrcweir                     lcl_tryReadConfigString( pLine, nLineLength, "exclude", aDebugData.aDbgData.aExclFilter, sizeof( aDebugData.aDbgData.aExclFilter ) );
759cdf0e10cSrcweir                     lcl_tryReadConfigString( pLine, nLineLength, "include_class", aDebugData.aDbgData.aInclClassFilter, sizeof( aDebugData.aDbgData.aInclClassFilter ) );
760cdf0e10cSrcweir                     lcl_tryReadConfigString( pLine, nLineLength, "exclude_class", aDebugData.aDbgData.aExclClassFilter, sizeof( aDebugData.aDbgData.aExclClassFilter ) );
761cdf0e10cSrcweir                     lcl_tryReadOutputChannel( pLine, nLineLength, "trace", &aDebugData.aDbgData.nTraceOut );
762cdf0e10cSrcweir                     lcl_tryReadOutputChannel( pLine, nLineLength, "warning", &aDebugData.aDbgData.nWarningOut );
763cdf0e10cSrcweir                     lcl_tryReadOutputChannel( pLine, nLineLength, "error", &aDebugData.aDbgData.nErrorOut );
764cdf0e10cSrcweir                     lcl_tryReadConfigBoolean( pLine, nLineLength, "oslhook", &aDebugData.aDbgData.bHookOSLAssert );
765cdf0e10cSrcweir                 }
766cdf0e10cSrcweir 
767cdf0e10cSrcweir                 // elements of the [memory] section
768cdf0e10cSrcweir                 if ( eCurrentSection == eMemory )
769cdf0e10cSrcweir                 {
770cdf0e10cSrcweir                     lcl_tryReadConfigFlag( pLine, nLineLength, "initialize", &aDebugData.aDbgData.nTestFlags, DBG_TEST_MEM_INIT );
771cdf0e10cSrcweir                     lcl_tryReadConfigFlag( pLine, nLineLength, "overwrite", &aDebugData.aDbgData.nTestFlags, DBG_TEST_MEM_OVERWRITE );
772cdf0e10cSrcweir                     lcl_tryReadConfigFlag( pLine, nLineLength, "overwrite_free", &aDebugData.aDbgData.nTestFlags, DBG_TEST_MEM_OVERWRITEFREE );
773cdf0e10cSrcweir                     lcl_tryReadConfigFlag( pLine, nLineLength, "pointer", &aDebugData.aDbgData.nTestFlags, DBG_TEST_MEM_POINTER );
774cdf0e10cSrcweir                     lcl_tryReadConfigFlag( pLine, nLineLength, "report", &aDebugData.aDbgData.nTestFlags, DBG_TEST_MEM_REPORT );
775cdf0e10cSrcweir                     lcl_tryReadConfigFlag( pLine, nLineLength, "trace", &aDebugData.aDbgData.nTestFlags, DBG_TEST_MEM_TRACE );
776cdf0e10cSrcweir                     lcl_tryReadConfigFlag( pLine, nLineLength, "new_and_delete", &aDebugData.aDbgData.nTestFlags, DBG_TEST_MEM_NEWDEL );
777cdf0e10cSrcweir                     lcl_tryReadConfigFlag( pLine, nLineLength, "object_test", &aDebugData.aDbgData.nTestFlags, DBG_TEST_MEM_XTOR );
778cdf0e10cSrcweir                     lcl_tryReadConfigFlag( pLine, nLineLength, "sys_alloc", &aDebugData.aDbgData.nTestFlags, DBG_TEST_MEM_SYSALLOC );
779cdf0e10cSrcweir                     lcl_tryReadConfigFlag( pLine, nLineLength, "leak_report", &aDebugData.aDbgData.nTestFlags, DBG_TEST_MEM_LEAKREPORT );
780cdf0e10cSrcweir 
781cdf0e10cSrcweir                     lcl_tryReadHexByte( pLine, nLineLength, "init_byte", &aDebugData.aDbgData.bMemInit );
782cdf0e10cSrcweir                     lcl_tryReadHexByte( pLine, nLineLength, "bound_byte", &aDebugData.aDbgData.bMemBound );
783cdf0e10cSrcweir                     lcl_tryReadHexByte( pLine, nLineLength, "free_byte", &aDebugData.aDbgData.bMemFree );
784cdf0e10cSrcweir                 }
785cdf0e10cSrcweir 
786cdf0e10cSrcweir                 // elements of the [gui] section
787cdf0e10cSrcweir                 if ( eCurrentSection == eGUI )
788cdf0e10cSrcweir                 {
789cdf0e10cSrcweir                     lcl_tryReadConfigString( pLine, nLineLength, "debug_window_state", aDebugData.aDbgData.aDbgWinState, sizeof( aDebugData.aDbgData.aDbgWinState ) );
790cdf0e10cSrcweir                 }
791cdf0e10cSrcweir 
792cdf0e10cSrcweir                 // elements of the [objects] section
793cdf0e10cSrcweir                 if ( eCurrentSection == eObjects )
794cdf0e10cSrcweir                 {
795cdf0e10cSrcweir                     lcl_tryReadConfigFlag( pLine, nLineLength, "check_this", &aDebugData.aDbgData.nTestFlags, DBG_TEST_XTOR_THIS );
796cdf0e10cSrcweir                     lcl_tryReadConfigFlag( pLine, nLineLength, "check_function", &aDebugData.aDbgData.nTestFlags, DBG_TEST_XTOR_FUNC );
797cdf0e10cSrcweir                     lcl_tryReadConfigFlag( pLine, nLineLength, "check_exit", &aDebugData.aDbgData.nTestFlags, DBG_TEST_XTOR_EXIT );
798cdf0e10cSrcweir                     lcl_tryReadConfigFlag( pLine, nLineLength, "generate_report", &aDebugData.aDbgData.nTestFlags, DBG_TEST_XTOR_REPORT );
799cdf0e10cSrcweir                     lcl_tryReadConfigFlag( pLine, nLineLength, "trace", &aDebugData.aDbgData.nTestFlags, DBG_TEST_XTOR_TRACE );
800cdf0e10cSrcweir                 }
801cdf0e10cSrcweir 
802cdf0e10cSrcweir                 // elements of the [test] section
803cdf0e10cSrcweir                 if ( eCurrentSection == eTest )
804cdf0e10cSrcweir                 {
805cdf0e10cSrcweir                     lcl_tryReadConfigFlag( pLine, nLineLength, "profiling", &aDebugData.aDbgData.nTestFlags, DBG_TEST_PROFILING );
806cdf0e10cSrcweir                     lcl_tryReadConfigFlag( pLine, nLineLength, "resources", &aDebugData.aDbgData.nTestFlags, DBG_TEST_RESOURCE );
807cdf0e10cSrcweir                     lcl_tryReadConfigFlag( pLine, nLineLength, "dialog", &aDebugData.aDbgData.nTestFlags, DBG_TEST_DIALOG );
808cdf0e10cSrcweir                     lcl_tryReadConfigFlag( pLine, nLineLength, "bold_app_font", &aDebugData.aDbgData.nTestFlags, DBG_TEST_BOLDAPPFONT );
809cdf0e10cSrcweir                 }
810cdf0e10cSrcweir 
811cdf0e10cSrcweir                 pLine = pNextLine + strlen( FILE_LINEEND );
812cdf0e10cSrcweir             }
813cdf0e10cSrcweir 
814cdf0e10cSrcweir             FileClose( pIniFile );
815cdf0e10cSrcweir         }
816cdf0e10cSrcweir         else
817cdf0e10cSrcweir         {
818cdf0e10cSrcweir             lcl_matchOutputChannel( getenv( "DBGSV_TRACE_OUT" ), &aDebugData.aDbgData.nTraceOut );
819cdf0e10cSrcweir             lcl_matchOutputChannel( getenv( "DBGSV_WARNING_OUT" ), &aDebugData.aDbgData.nWarningOut );
820cdf0e10cSrcweir             lcl_matchOutputChannel( getenv( "DBGSV_ERROR_OUT" ), &aDebugData.aDbgData.nErrorOut );
821cdf0e10cSrcweir 
822cdf0e10cSrcweir         }
823cdf0e10cSrcweir 
824cdf0e10cSrcweir         getcwd( aCurPath, sizeof( aCurPath ) );
825cdf0e10cSrcweir 
826cdf0e10cSrcweir         // Daten initialisieren
827cdf0e10cSrcweir         if ( aDebugData.aDbgData.nTestFlags & DBG_TEST_XTOR )
828cdf0e10cSrcweir             aDebugData.pXtorList = new PointerList;
829cdf0e10cSrcweir         if ( aDebugData.aDbgData.nTestFlags & DBG_TEST_PROFILING )
830cdf0e10cSrcweir             aDebugData.pProfList = new PointerList;
831cdf0e10cSrcweir     }
832cdf0e10cSrcweir 
833cdf0e10cSrcweir     return &aDebugData;
834cdf0e10cSrcweir }
835cdf0e10cSrcweir 
836cdf0e10cSrcweir // -----------------------------------------------------------------------
837cdf0e10cSrcweir 
838cdf0e10cSrcweir inline DebugData* ImplGetDebugData()
839cdf0e10cSrcweir {
840cdf0e10cSrcweir     if ( !aDebugData.bInit )
841cdf0e10cSrcweir         return GetDebugData();
842cdf0e10cSrcweir     else
843cdf0e10cSrcweir         return &aDebugData;
844cdf0e10cSrcweir }
845cdf0e10cSrcweir 
846cdf0e10cSrcweir // -----------------------------------------------------------------------
847cdf0e10cSrcweir 
848cdf0e10cSrcweir static FILETYPE ImplDbgInitFile()
849cdf0e10cSrcweir {
850cdf0e10cSrcweir     static sal_Bool bFileInit = sal_False;
851cdf0e10cSrcweir 
852cdf0e10cSrcweir     sal_Char aBuf[4096];
853cdf0e10cSrcweir     getcwd( aBuf, sizeof( aBuf ) );
854cdf0e10cSrcweir     chdir( aCurPath );
855cdf0e10cSrcweir 
856cdf0e10cSrcweir     DebugData*  pData = GetDebugData();
857cdf0e10cSrcweir     FILETYPE    pDebugFile;
858cdf0e10cSrcweir 
859cdf0e10cSrcweir     if ( !bFileInit )
860cdf0e10cSrcweir     {
861cdf0e10cSrcweir         bFileInit = sal_True;
862cdf0e10cSrcweir 
863cdf0e10cSrcweir         if ( pData->aDbgData.bOverwrite )
864cdf0e10cSrcweir             pDebugFile = FileOpen( pData->aDbgData.aDebugName, "w" );
865cdf0e10cSrcweir         else
866cdf0e10cSrcweir             pDebugFile = FileOpen( pData->aDbgData.aDebugName, "a" );
867cdf0e10cSrcweir 
868cdf0e10cSrcweir         if ( pDebugFile )
869cdf0e10cSrcweir         {
870cdf0e10cSrcweir             time_t  nTime = time( 0 );
871cdf0e10cSrcweir             tm*     pTime;
872cdf0e10cSrcweir #ifdef UNX
873cdf0e10cSrcweir             tm      aTime;
874cdf0e10cSrcweir             pTime = localtime_r( &nTime, &aTime );
875cdf0e10cSrcweir #else
876cdf0e10cSrcweir             pTime = localtime( &nTime );
877cdf0e10cSrcweir #endif
878cdf0e10cSrcweir 
879cdf0e10cSrcweir             // Header ausgeben
880cdf0e10cSrcweir             FilePrintF( pDebugFile, "******************************************************************************%s", FILE_LINEEND );
881cdf0e10cSrcweir             FilePrintF( pDebugFile, "%s%s", pData->aDbgData.aDebugName, FILE_LINEEND );
882cdf0e10cSrcweir             if ( pTime )
883cdf0e10cSrcweir                 FilePrintF( pDebugFile, "%s%s", asctime( pTime ), FILE_LINEEND );
884cdf0e10cSrcweir         }
885cdf0e10cSrcweir     }
886cdf0e10cSrcweir     else
887cdf0e10cSrcweir         pDebugFile = FileOpen( pData->aDbgData.aDebugName, "a" );
888cdf0e10cSrcweir 
889cdf0e10cSrcweir     chdir( aBuf );
890cdf0e10cSrcweir 
891cdf0e10cSrcweir     return pDebugFile;
892cdf0e10cSrcweir }
893cdf0e10cSrcweir 
894cdf0e10cSrcweir // -----------------------------------------------------------------------
895cdf0e10cSrcweir 
896cdf0e10cSrcweir static void ImplDbgPrintFile( const sal_Char* pLine )
897cdf0e10cSrcweir {
898cdf0e10cSrcweir     FILETYPE pDebugFile = ImplDbgInitFile();
899cdf0e10cSrcweir 
900cdf0e10cSrcweir     if ( pDebugFile )
901cdf0e10cSrcweir     {
902cdf0e10cSrcweir         FilePrintF( pDebugFile, "%s%s", pLine, FILE_LINEEND );
903cdf0e10cSrcweir         FileClose( pDebugFile );
904cdf0e10cSrcweir     }
905cdf0e10cSrcweir }
906cdf0e10cSrcweir 
907cdf0e10cSrcweir // -----------------------------------------------------------------------
908cdf0e10cSrcweir 
909cdf0e10cSrcweir static int ImplStrSearch( const sal_Char* pSearchStr, int nSearchLen,
910cdf0e10cSrcweir                           const sal_Char* pStr, int nLen )
911cdf0e10cSrcweir {
912cdf0e10cSrcweir     int nPos = 0;
913cdf0e10cSrcweir     while ( nPos+nSearchLen <= nLen )
914cdf0e10cSrcweir     {
915cdf0e10cSrcweir         if ( strncmp( pStr+nPos, pSearchStr, nSearchLen ) == 0 )
916cdf0e10cSrcweir             return 1;
917cdf0e10cSrcweir         nPos++;
918cdf0e10cSrcweir     }
919cdf0e10cSrcweir 
920cdf0e10cSrcweir     return 0;
921cdf0e10cSrcweir }
922cdf0e10cSrcweir 
923cdf0e10cSrcweir // -----------------------------------------------------------------------
924cdf0e10cSrcweir 
925cdf0e10cSrcweir static int ImplDbgFilter( const sal_Char* pFilter, const sal_Char* pMsg,
926cdf0e10cSrcweir                           int bEmpty )
927cdf0e10cSrcweir {
928cdf0e10cSrcweir     int nStrLen = strlen( pFilter );
929cdf0e10cSrcweir     if ( !nStrLen )
930cdf0e10cSrcweir         return bEmpty;
931cdf0e10cSrcweir 
932cdf0e10cSrcweir     int nMsgLen = strlen( pMsg );
933cdf0e10cSrcweir     const sal_Char* pTok = pFilter;
934cdf0e10cSrcweir     int         nTok = 0;
935cdf0e10cSrcweir     while ( pTok[nTok] )
936cdf0e10cSrcweir     {
937cdf0e10cSrcweir         if ( pTok[nTok] == ';' )
938cdf0e10cSrcweir         {
939cdf0e10cSrcweir             if ( nTok && ImplStrSearch( pTok, nTok, pMsg, nMsgLen ) )
940cdf0e10cSrcweir                 return sal_True;
941cdf0e10cSrcweir 
942cdf0e10cSrcweir             pTok += nTok+1;
943cdf0e10cSrcweir             nTok = 0;
944cdf0e10cSrcweir         }
945cdf0e10cSrcweir 
946cdf0e10cSrcweir         nTok++;
947cdf0e10cSrcweir     }
948cdf0e10cSrcweir 
949cdf0e10cSrcweir     if ( nTok && ImplStrSearch( pTok, nTok, pMsg, nMsgLen ) )
950cdf0e10cSrcweir         return sal_True;
951cdf0e10cSrcweir     else
952cdf0e10cSrcweir         return sal_False;
953cdf0e10cSrcweir }
954cdf0e10cSrcweir 
955cdf0e10cSrcweir // -----------------------------------------------------------------------
956cdf0e10cSrcweir 
957cdf0e10cSrcweir extern "C"
958cdf0e10cSrcweir void SAL_CALL dbg_printOslDebugMessage( const sal_Char * pszFileName, sal_Int32 nLine, const sal_Char * pszMessage )
959cdf0e10cSrcweir {
960cdf0e10cSrcweir     DbgOut( pszMessage ? pszMessage : "assertion failed!", DBG_OUT_ERROR, pszFileName, (sal_uInt16)nLine );
961cdf0e10cSrcweir }
962cdf0e10cSrcweir 
963cdf0e10cSrcweir // -----------------------------------------------------------------------
964cdf0e10cSrcweir 
965cdf0e10cSrcweir static void DebugInit()
966cdf0e10cSrcweir {
967cdf0e10cSrcweir     bDbgImplInMain = sal_True;
968cdf0e10cSrcweir     ImplDbgInitLock();
969cdf0e10cSrcweir 
970cdf0e10cSrcweir     DebugData* pData = GetDebugData();
971cdf0e10cSrcweir     if( pData->aDbgData.bHookOSLAssert && ! pData->bOslIsHooked )
972cdf0e10cSrcweir     {
973cdf0e10cSrcweir         pData->pOldDebugMessageFunc = osl_setDetailedDebugMessageFunc( &dbg_printOslDebugMessage );
974cdf0e10cSrcweir         pData->bOslIsHooked = true;
975cdf0e10cSrcweir     }
976cdf0e10cSrcweir }
977cdf0e10cSrcweir 
978cdf0e10cSrcweir // -----------------------------------------------------------------------
979cdf0e10cSrcweir 
980cdf0e10cSrcweir static void DebugDeInit()
981cdf0e10cSrcweir {
982cdf0e10cSrcweir     DebugData*  pData = GetDebugData();
983cdf0e10cSrcweir     sal_uIntPtr       i;
984cdf0e10cSrcweir     sal_uIntPtr       nCount;
985cdf0e10cSrcweir     sal_uIntPtr       nOldOut;
986cdf0e10cSrcweir 
987cdf0e10cSrcweir     if( pData->bOslIsHooked )
988cdf0e10cSrcweir     {
989cdf0e10cSrcweir         osl_setDetailedDebugMessageFunc( pData->pOldDebugMessageFunc );
990cdf0e10cSrcweir         pData->bOslIsHooked = sal_False;
991cdf0e10cSrcweir     }
992cdf0e10cSrcweir 
993cdf0e10cSrcweir     // Statistik-Ausgaben immer in File
994cdf0e10cSrcweir     nOldOut = pData->aDbgData.nTraceOut;
995cdf0e10cSrcweir     pData->aDbgData.nTraceOut = DBG_OUT_FILE;
996cdf0e10cSrcweir 
997cdf0e10cSrcweir     // Xtor-Liste ausgeben
998cdf0e10cSrcweir     if ( pData->pXtorList && pData->pXtorList->Count() &&
999cdf0e10cSrcweir          (pData->aDbgData.nTestFlags & DBG_TEST_XTOR_REPORT) )
1000cdf0e10cSrcweir     {
1001cdf0e10cSrcweir         DbgOutf( "------------------------------------------------------------------------------" );
1002cdf0e10cSrcweir         DbgOutf( "Object Report" );
1003cdf0e10cSrcweir         DbgOutf( "------------------------------------------------------------------------------" );
1004cdf0e10cSrcweir         DbgOutf( "%-27s : %-9s : %-9s : %-7s : %-3s : %-6s :",
1005cdf0e10cSrcweir                  "XTor-List", "Ctor", "Dtor", "MaxInst", "St.", "Diff." );
1006cdf0e10cSrcweir         DbgOutf( "----------------------------:-----------:-----------:---------:----:---------:" );
1007cdf0e10cSrcweir         for( i = 0, nCount = pData->pXtorList->Count(); i < nCount; i++ )
1008cdf0e10cSrcweir         {
1009cdf0e10cSrcweir             XtorType* pXtorData = (XtorType*)pData->pXtorList->Get( i );
1010cdf0e10cSrcweir             if ( pXtorData->bTest )
1011cdf0e10cSrcweir             {
1012cdf0e10cSrcweir                 // Static-Objekte dazurechnen
1013cdf0e10cSrcweir                 pXtorData->nDtorCalls += pXtorData->nStatics;
1014cdf0e10cSrcweir                 if ( pXtorData->nStatics && (pXtorData->nDtorCalls > pXtorData->nCtorCalls) )
1015cdf0e10cSrcweir                     pXtorData->nDtorCalls = pXtorData->nCtorCalls;
1016cdf0e10cSrcweir                 DbgOutf( "%-27s : %9lu : %9lu : %7lu : %3lu : %4lu %-1s :",
1017cdf0e10cSrcweir                          pXtorData->aName, pXtorData->nCtorCalls, pXtorData->nDtorCalls,
1018cdf0e10cSrcweir                          pXtorData->nMaxCount, pXtorData->nStatics,
1019cdf0e10cSrcweir                          pXtorData->nCtorCalls - pXtorData->nDtorCalls,
1020cdf0e10cSrcweir                          (pXtorData->nCtorCalls - pXtorData->nDtorCalls) ? "!" : " " );
1021cdf0e10cSrcweir             }
1022cdf0e10cSrcweir         }
1023cdf0e10cSrcweir         DbgOutf( "==============================================================================" );
1024cdf0e10cSrcweir     }
1025cdf0e10cSrcweir 
1026cdf0e10cSrcweir     // Aufraeumen
1027cdf0e10cSrcweir     if ( pData->pXtorList )
1028cdf0e10cSrcweir     {
1029cdf0e10cSrcweir         for( i = 0, nCount = pData->pXtorList->Count(); i < nCount; i++ )
1030cdf0e10cSrcweir         {
1031cdf0e10cSrcweir             XtorType* pXtorData = (XtorType*)pData->pXtorList->Get( i );
1032cdf0e10cSrcweir             delete pXtorData;
1033cdf0e10cSrcweir         }
1034cdf0e10cSrcweir         delete pData->pXtorList;
1035cdf0e10cSrcweir         pData->pXtorList = NULL;
1036cdf0e10cSrcweir     }
1037cdf0e10cSrcweir 
1038cdf0e10cSrcweir     // Alles auf sal_False setzen, damit globale Variablen nicht das
1039cdf0e10cSrcweir     // System zum Abstuerzen bringt. Dabei muessen aber die
1040cdf0e10cSrcweir     // Memory-Flags erhalten bleiben, da sonst new/delete in globalen
1041cdf0e10cSrcweir     // Variablen abstuerzen, da die Pointeranpassung dann nicht mehr richtig
1042cdf0e10cSrcweir     // funktioniert
1043cdf0e10cSrcweir     pData->aDbgData.nTraceOut   = nOldOut;
1044cdf0e10cSrcweir     pData->aDbgData.nTestFlags &= (DBG_TEST_MEM | DBG_TEST_PROFILING);
1045cdf0e10cSrcweir     pData->aDbgPrintUserChannels.clear();
1046cdf0e10cSrcweir     pData->pDbgPrintTestTool    = NULL;
1047cdf0e10cSrcweir     pData->pDbgPrintWindow      = NULL;
1048cdf0e10cSrcweir     pData->pOldDebugMessageFunc = NULL;
1049cdf0e10cSrcweir     ImplDbgDeInitLock();
1050cdf0e10cSrcweir }
1051cdf0e10cSrcweir 
1052cdf0e10cSrcweir // -----------------------------------------------------------------------
1053cdf0e10cSrcweir 
1054cdf0e10cSrcweir static void DebugGlobalDeInit()
1055cdf0e10cSrcweir {
1056cdf0e10cSrcweir     DebugData*  pData = GetDebugData();
1057cdf0e10cSrcweir     sal_uIntPtr       i;
1058cdf0e10cSrcweir     sal_uIntPtr       nCount;
1059cdf0e10cSrcweir     sal_uIntPtr       nOldOut;
1060cdf0e10cSrcweir 
1061cdf0e10cSrcweir     // Statistik-Ausgaben immer in File
1062cdf0e10cSrcweir     nOldOut = pData->aDbgData.nTraceOut;
1063cdf0e10cSrcweir     pData->aDbgData.nTraceOut = DBG_OUT_FILE;
1064cdf0e10cSrcweir 
1065cdf0e10cSrcweir     // Profileliste ausgeben
1066cdf0e10cSrcweir     if ( pData->pProfList && pData->pProfList->Count() )
1067cdf0e10cSrcweir     {
1068cdf0e10cSrcweir         DbgOutf( "------------------------------------------------------------------------------" );
1069cdf0e10cSrcweir         DbgOutf( "Profiling Report" );
1070cdf0e10cSrcweir         DbgOutf( "------------------------------------------------------------------------------" );
1071cdf0e10cSrcweir         DbgOutf( "%-25s : %-9s : %-6s : %-6s : %-6s : %-9s :",
1072cdf0e10cSrcweir                  "Prof-List (ms)", "Time", "Min", "Max", "Ave", "Count" );
1073cdf0e10cSrcweir         DbgOutf( "--------------------------:-----------:--------:--------:--------:-----------:" );
1074cdf0e10cSrcweir         for( i = 0, nCount = pData->pProfList->Count(); i < nCount; i++ )
1075cdf0e10cSrcweir         {
1076cdf0e10cSrcweir             ProfType* pProfData = (ProfType*)pData->pProfList->Get( i );
1077cdf0e10cSrcweir             sal_uIntPtr nAve = pProfData->nTime / pProfData->nCount;
1078cdf0e10cSrcweir             DbgOutf( "%-25s : %9lu : %6lu : %6lu : %6lu : %9lu :",
1079cdf0e10cSrcweir                      pProfData->aName, pProfData->nTime,
1080cdf0e10cSrcweir                      pProfData->nMinTime, pProfData->nMaxTime, nAve,
1081cdf0e10cSrcweir                      pProfData->nCount );
1082cdf0e10cSrcweir         }
1083cdf0e10cSrcweir         DbgOutf( "==============================================================================" );
1084cdf0e10cSrcweir     }
1085cdf0e10cSrcweir 
1086cdf0e10cSrcweir     // Aufraeumen
1087cdf0e10cSrcweir     if ( pData->pProfList )
1088cdf0e10cSrcweir     {
1089cdf0e10cSrcweir         for( i = 0, nCount = pData->pProfList->Count(); i < nCount; i++ )
1090cdf0e10cSrcweir         {
1091cdf0e10cSrcweir             ProfType* pProfData = (ProfType*)pData->pProfList->Get( i );
1092cdf0e10cSrcweir             delete pProfData;
1093cdf0e10cSrcweir         }
1094cdf0e10cSrcweir         delete pData->pProfList;
1095cdf0e10cSrcweir         pData->pProfList = NULL;
1096cdf0e10cSrcweir     }
1097cdf0e10cSrcweir 
1098cdf0e10cSrcweir #ifdef SV_MEMMGR
1099cdf0e10cSrcweir     DbgImpCheckMemoryDeInit();
1100cdf0e10cSrcweir #endif
1101cdf0e10cSrcweir 
1102cdf0e10cSrcweir     // Profiling-Flags ausschalten
1103cdf0e10cSrcweir     pData->aDbgData.nTraceOut   = nOldOut;
1104cdf0e10cSrcweir     pData->aDbgData.nTestFlags &= ~DBG_TEST_PROFILING;
1105cdf0e10cSrcweir }
1106cdf0e10cSrcweir 
1107cdf0e10cSrcweir // -----------------------------------------------------------------------
1108cdf0e10cSrcweir 
1109cdf0e10cSrcweir void ImpDbgOutfBuf( sal_Char* pBuf, const sal_Char* pFStr, ... )
1110cdf0e10cSrcweir {
1111cdf0e10cSrcweir     va_list pList;
1112cdf0e10cSrcweir 
1113cdf0e10cSrcweir     va_start( pList, pFStr );
1114cdf0e10cSrcweir     sal_Char aBuf[DBG_BUF_MAXLEN];
1115cdf0e10cSrcweir     vsprintf( aBuf, pFStr, pList );
1116cdf0e10cSrcweir     va_end( pList );
1117cdf0e10cSrcweir 
1118cdf0e10cSrcweir     strcat( pBuf, aBuf );
1119cdf0e10cSrcweir     strcat( pBuf, "\n" );
1120cdf0e10cSrcweir }
1121cdf0e10cSrcweir 
1122cdf0e10cSrcweir // -----------------------------------------------------------------------
1123cdf0e10cSrcweir 
1124cdf0e10cSrcweir static void DebugXTorInfo( sal_Char* pBuf )
1125cdf0e10cSrcweir {
1126cdf0e10cSrcweir     DebugData*  pData = GetDebugData();
1127cdf0e10cSrcweir     sal_uIntPtr       i;
1128cdf0e10cSrcweir     sal_uIntPtr       nCount;
1129cdf0e10cSrcweir 
1130cdf0e10cSrcweir     // Xtor-Liste ausgeben
1131cdf0e10cSrcweir     if ( pData->pXtorList && pData->pXtorList->Count() &&
1132cdf0e10cSrcweir          (pData->aDbgData.nTestFlags & DBG_TEST_XTOR_REPORT) )
1133cdf0e10cSrcweir     {
1134cdf0e10cSrcweir         ImpDbgOutfBuf( pBuf, "------------------------------------------------------------------------------" );
1135cdf0e10cSrcweir         ImpDbgOutfBuf( pBuf, "Object Report" );
1136cdf0e10cSrcweir         ImpDbgOutfBuf( pBuf, "------------------------------------------------------------------------------" );
1137cdf0e10cSrcweir         ImpDbgOutfBuf( pBuf, "%-27s : %-9s : %-9s : %-7s : %-3s : %-6s :",
1138cdf0e10cSrcweir                        "XTor-List", "Ctor", "Dtor", "MaxInst", "St.", "Diff." );
1139cdf0e10cSrcweir         ImpDbgOutfBuf( pBuf, "----------------------------:-----------:-----------:---------:----:---------:" );
1140cdf0e10cSrcweir         for( i = 0, nCount = pData->pXtorList->Count(); i < nCount; i++ )
1141cdf0e10cSrcweir         {
1142cdf0e10cSrcweir             XtorType* pXtorData = (XtorType*)pData->pXtorList->Get( i );
1143cdf0e10cSrcweir             if ( pXtorData->bTest )
1144cdf0e10cSrcweir             {
1145cdf0e10cSrcweir                 ImpDbgOutfBuf( pBuf, "%-27s : %9lu : %9lu : %7lu : %3lu : %6lu :",
1146cdf0e10cSrcweir                                pXtorData->aName, pXtorData->nCtorCalls, pXtorData->nDtorCalls,
1147cdf0e10cSrcweir                                pXtorData->nMaxCount, pXtorData->nStatics,
1148cdf0e10cSrcweir                                pXtorData->nCtorCalls - pXtorData->nDtorCalls );
1149cdf0e10cSrcweir             }
1150cdf0e10cSrcweir         }
1151cdf0e10cSrcweir         ImpDbgOutfBuf( pBuf, "==============================================================================" );
1152cdf0e10cSrcweir         ImpDbgOutfBuf( pBuf, "" );
1153cdf0e10cSrcweir     }
1154cdf0e10cSrcweir }
1155cdf0e10cSrcweir 
1156cdf0e10cSrcweir // -----------------------------------------------------------------------
1157cdf0e10cSrcweir sal_Bool ImplDbgFilterMessage( const sal_Char* pMsg )
1158cdf0e10cSrcweir {
1159cdf0e10cSrcweir     DebugData*  pData = GetDebugData();
1160cdf0e10cSrcweir     if ( !ImplDbgFilter( pData->aDbgData.aInclFilter, pMsg, sal_True ) )
1161cdf0e10cSrcweir         return sal_True;
1162cdf0e10cSrcweir     if ( ImplDbgFilter( pData->aDbgData.aExclFilter, pMsg, sal_False ) )
1163cdf0e10cSrcweir         return sal_True;
1164cdf0e10cSrcweir     return sal_False;
1165cdf0e10cSrcweir }
1166cdf0e10cSrcweir 
1167cdf0e10cSrcweir // -----------------------------------------------------------------------
1168cdf0e10cSrcweir 
1169cdf0e10cSrcweir void* DbgFunc( sal_uInt16 nAction, void* pParam )
1170cdf0e10cSrcweir {
1171cdf0e10cSrcweir     DebugData* pDebugData = ImplGetDebugData();
1172cdf0e10cSrcweir 
1173cdf0e10cSrcweir     if ( nAction == DBG_FUNC_GETDATA )
1174cdf0e10cSrcweir         return (void*)&(pDebugData->aDbgData);
1175cdf0e10cSrcweir     else if ( nAction == DBG_FUNC_GETPRINTMSGBOX )
1176cdf0e10cSrcweir         return (void*)(long)(pDebugData->pDbgPrintMsgBox);
1177cdf0e10cSrcweir     else if ( nAction == DBG_FUNC_FILTERMESSAGE )
1178cdf0e10cSrcweir         if ( ImplDbgFilterMessage( (const sal_Char*) pParam ) )
1179cdf0e10cSrcweir             return (void*) -1;
1180cdf0e10cSrcweir         else
1181cdf0e10cSrcweir             return (void*) 0;   // aka NULL
1182cdf0e10cSrcweir     else
1183cdf0e10cSrcweir 
1184cdf0e10cSrcweir     {
1185cdf0e10cSrcweir         switch ( nAction )
1186cdf0e10cSrcweir         {
1187cdf0e10cSrcweir             case DBG_FUNC_DEBUGSTART:
1188cdf0e10cSrcweir                 DebugInit();
1189cdf0e10cSrcweir                 break;
1190cdf0e10cSrcweir 
1191cdf0e10cSrcweir             case DBG_FUNC_DEBUGEND:
1192cdf0e10cSrcweir                 DebugDeInit();
1193cdf0e10cSrcweir                 break;
1194cdf0e10cSrcweir 
1195cdf0e10cSrcweir             case DBG_FUNC_GLOBALDEBUGEND:
1196cdf0e10cSrcweir                 DebugGlobalDeInit();
1197cdf0e10cSrcweir                 break;
1198cdf0e10cSrcweir 
1199cdf0e10cSrcweir             case DBG_FUNC_SETPRINTMSGBOX:
1200cdf0e10cSrcweir                 pDebugData->pDbgPrintMsgBox = (DbgPrintLine)(long)pParam;
1201cdf0e10cSrcweir                 break;
1202cdf0e10cSrcweir 
1203cdf0e10cSrcweir             case DBG_FUNC_SETPRINTWINDOW:
1204cdf0e10cSrcweir                 pDebugData->pDbgPrintWindow = (DbgPrintLine)(long)pParam;
1205cdf0e10cSrcweir                 break;
1206cdf0e10cSrcweir 
1207cdf0e10cSrcweir             case DBG_FUNC_SETPRINTTESTTOOL:
1208cdf0e10cSrcweir                 pDebugData->pDbgPrintTestTool = (DbgPrintLine)(long)pParam;
1209cdf0e10cSrcweir                 break;
1210cdf0e10cSrcweir 
1211cdf0e10cSrcweir             case DBG_FUNC_SET_ABORT:
1212cdf0e10cSrcweir                 pDebugData->pDbgAbort = (DbgPrintLine)(long)pParam;
1213cdf0e10cSrcweir                 break;
1214cdf0e10cSrcweir 
1215cdf0e10cSrcweir             case DBG_FUNC_SAVEDATA:
1216cdf0e10cSrcweir                 {
1217cdf0e10cSrcweir                 const DbgData* pData = static_cast< const DbgData* >( pParam );
1218cdf0e10cSrcweir 
1219cdf0e10cSrcweir                 sal_Char aBuf[ 4096 ];
1220cdf0e10cSrcweir                 DbgGetDbgFileName( aBuf, sizeof( aBuf ) );
1221cdf0e10cSrcweir                 FILETYPE pIniFile = FileOpen( aBuf, "w" );
1222cdf0e10cSrcweir                 if ( pIniFile == NULL )
1223cdf0e10cSrcweir                     break;
1224cdf0e10cSrcweir 
1225cdf0e10cSrcweir                 lcl_startSection( pIniFile, eOutput );
1226cdf0e10cSrcweir                 lcl_writeConfigString( pIniFile, "log_file", pData->aDebugName );
1227cdf0e10cSrcweir                 lcl_writeConfigBoolean( pIniFile, "overwrite", pData->bOverwrite );
1228cdf0e10cSrcweir                 lcl_writeConfigString( pIniFile, "include", pData->aInclFilter );
1229cdf0e10cSrcweir                 lcl_writeConfigString( pIniFile, "exclude", pData->aExclFilter );
1230cdf0e10cSrcweir                 lcl_writeConfigString( pIniFile, "include_class", pData->aInclClassFilter );
1231cdf0e10cSrcweir                 lcl_writeConfigString( pIniFile, "exclude_class", pData->aExclClassFilter );
1232cdf0e10cSrcweir                 lcl_writeConfigOutChannel( pIniFile, "trace", pData->nTraceOut );
1233cdf0e10cSrcweir                 lcl_writeConfigOutChannel( pIniFile, "warning", pData->nWarningOut );
1234cdf0e10cSrcweir                 lcl_writeConfigOutChannel( pIniFile, "error", pData->nErrorOut );
1235cdf0e10cSrcweir                 lcl_writeConfigBoolean( pIniFile, "oslhook", pData->bHookOSLAssert );
1236cdf0e10cSrcweir 
1237cdf0e10cSrcweir                 lcl_lineFeed( pIniFile );
1238cdf0e10cSrcweir                 lcl_startSection( pIniFile, eMemory );
1239cdf0e10cSrcweir                 lcl_writeConfigFlag( pIniFile, "initialize", pData->nTestFlags, DBG_TEST_MEM_INIT );
1240cdf0e10cSrcweir                 lcl_writeConfigFlag( pIniFile, "overwrite", pData->nTestFlags, DBG_TEST_MEM_OVERWRITE );
1241cdf0e10cSrcweir                 lcl_writeConfigFlag( pIniFile, "overwrite_free", pData->nTestFlags, DBG_TEST_MEM_OVERWRITEFREE );
1242cdf0e10cSrcweir                 lcl_writeConfigFlag( pIniFile, "pointer", pData->nTestFlags, DBG_TEST_MEM_POINTER );
1243cdf0e10cSrcweir                 lcl_writeConfigFlag( pIniFile, "report", pData->nTestFlags, DBG_TEST_MEM_REPORT );
1244cdf0e10cSrcweir                 lcl_writeConfigFlag( pIniFile, "trace", pData->nTestFlags, DBG_TEST_MEM_TRACE );
1245cdf0e10cSrcweir                 lcl_writeConfigFlag( pIniFile, "new_and_delete", pData->nTestFlags, DBG_TEST_MEM_NEWDEL );
1246cdf0e10cSrcweir                 lcl_writeConfigFlag( pIniFile, "object_test", pData->nTestFlags, DBG_TEST_MEM_XTOR );
1247cdf0e10cSrcweir                 lcl_writeConfigFlag( pIniFile, "sys_alloc", pData->nTestFlags, DBG_TEST_MEM_SYSALLOC );
1248cdf0e10cSrcweir                 lcl_writeConfigFlag( pIniFile, "leak_report", pData->nTestFlags, DBG_TEST_MEM_LEAKREPORT );
1249cdf0e10cSrcweir 
1250cdf0e10cSrcweir                 lcl_lineFeed( pIniFile );
1251cdf0e10cSrcweir                 lcl_writeHexByte( pIniFile, "init_byte", pData->bMemInit );
1252cdf0e10cSrcweir                 lcl_writeHexByte( pIniFile, "bound_byte", pData->bMemBound );
1253cdf0e10cSrcweir                 lcl_writeHexByte( pIniFile, "free_byte", pData->bMemFree );
1254cdf0e10cSrcweir 
1255cdf0e10cSrcweir                 lcl_lineFeed( pIniFile );
1256cdf0e10cSrcweir                 lcl_startSection( pIniFile, eGUI );
1257cdf0e10cSrcweir                 lcl_writeConfigString( pIniFile, "debug_window_state", pData->aDbgWinState );
1258cdf0e10cSrcweir 
1259cdf0e10cSrcweir                 lcl_lineFeed( pIniFile );
1260cdf0e10cSrcweir                 lcl_startSection( pIniFile, eObjects );
1261cdf0e10cSrcweir                 lcl_writeConfigFlag( pIniFile, "check_this", pData->nTestFlags, DBG_TEST_XTOR_THIS );
1262cdf0e10cSrcweir                 lcl_writeConfigFlag( pIniFile, "check_function", pData->nTestFlags, DBG_TEST_XTOR_FUNC );
1263cdf0e10cSrcweir                 lcl_writeConfigFlag( pIniFile, "check_exit", pData->nTestFlags, DBG_TEST_XTOR_EXIT );
1264cdf0e10cSrcweir                 lcl_writeConfigFlag( pIniFile, "generate_report", pData->nTestFlags, DBG_TEST_XTOR_REPORT );
1265cdf0e10cSrcweir                 lcl_writeConfigFlag( pIniFile, "trace", pData->nTestFlags, DBG_TEST_XTOR_TRACE );
1266cdf0e10cSrcweir 
1267cdf0e10cSrcweir                 lcl_lineFeed( pIniFile );
1268cdf0e10cSrcweir                 lcl_startSection( pIniFile, eTest );
1269cdf0e10cSrcweir                 lcl_writeConfigFlag( pIniFile, "profiling", pData->nTestFlags, DBG_TEST_PROFILING );
1270cdf0e10cSrcweir                 lcl_writeConfigFlag( pIniFile, "resources", pData->nTestFlags, DBG_TEST_RESOURCE );
1271cdf0e10cSrcweir                 lcl_writeConfigFlag( pIniFile, "dialog", pData->nTestFlags, DBG_TEST_DIALOG );
1272cdf0e10cSrcweir                 lcl_writeConfigFlag( pIniFile, "bold_app_font", pData->nTestFlags, DBG_TEST_BOLDAPPFONT );
1273cdf0e10cSrcweir 
1274cdf0e10cSrcweir                 FileClose( pIniFile );
1275cdf0e10cSrcweir                 }
1276cdf0e10cSrcweir                 break;
1277cdf0e10cSrcweir 
1278cdf0e10cSrcweir             case DBG_FUNC_MEMTEST:
1279cdf0e10cSrcweir #ifdef SV_MEMMGR
1280cdf0e10cSrcweir                 DbgImpCheckMemory( pParam );
1281cdf0e10cSrcweir #endif
1282cdf0e10cSrcweir                 break;
1283cdf0e10cSrcweir 
1284cdf0e10cSrcweir             case DBG_FUNC_XTORINFO:
1285cdf0e10cSrcweir                 DebugXTorInfo( (sal_Char*)pParam );
1286cdf0e10cSrcweir                 break;
1287cdf0e10cSrcweir 
1288cdf0e10cSrcweir             case DBG_FUNC_MEMINFO:
1289cdf0e10cSrcweir #ifdef SV_MEMMGR
1290cdf0e10cSrcweir                 DbgImpMemoryInfo( (sal_Char*)pParam );
1291cdf0e10cSrcweir #endif
1292cdf0e10cSrcweir                 break;
1293cdf0e10cSrcweir 
1294cdf0e10cSrcweir             case DBG_FUNC_COREDUMP:
1295cdf0e10cSrcweir                 ImplCoreDump();
1296cdf0e10cSrcweir                 break;
1297cdf0e10cSrcweir 
1298cdf0e10cSrcweir             case DBG_FUNC_ALLERROROUT:
1299cdf0e10cSrcweir                 return (void*)(sal_uIntPtr)sal_True;
1300cdf0e10cSrcweir 
1301cdf0e10cSrcweir             case DBG_FUNC_SETTESTSOLARMUTEX:
1302cdf0e10cSrcweir                 pDebugData->pDbgTestSolarMutex = (DbgTestSolarMutexProc)(long)pParam;
1303cdf0e10cSrcweir                 break;
1304cdf0e10cSrcweir 
1305cdf0e10cSrcweir             case DBG_FUNC_TESTSOLARMUTEX:
1306cdf0e10cSrcweir                 if ( pDebugData->pDbgTestSolarMutex )
1307cdf0e10cSrcweir                     pDebugData->pDbgTestSolarMutex();
1308cdf0e10cSrcweir                 break;
1309cdf0e10cSrcweir 
1310cdf0e10cSrcweir             case DBG_FUNC_PRINTFILE:
1311cdf0e10cSrcweir                 ImplDbgPrintFile( (const sal_Char*)pParam );
1312cdf0e10cSrcweir                 break;
1313cdf0e10cSrcweir             case DBG_FUNC_UPDATEOSLHOOK:
1314cdf0e10cSrcweir             {
1315cdf0e10cSrcweir                 const DbgData* pData = static_cast< const DbgData* >( pParam );
1316cdf0e10cSrcweir                 pDebugData->aDbgData.bHookOSLAssert = pData->bHookOSLAssert;
1317cdf0e10cSrcweir                 if( pDebugData->bOslIsHooked && ! pData->bHookOSLAssert )
1318cdf0e10cSrcweir                 {
1319cdf0e10cSrcweir                     osl_setDetailedDebugMessageFunc( pDebugData->pOldDebugMessageFunc );
1320cdf0e10cSrcweir                     pDebugData->bOslIsHooked = sal_False;
1321cdf0e10cSrcweir                 }
1322cdf0e10cSrcweir                 else if( ! pDebugData->bOslIsHooked && pData->bHookOSLAssert )
1323cdf0e10cSrcweir                 {
1324cdf0e10cSrcweir                     pDebugData->pOldDebugMessageFunc = osl_setDetailedDebugMessageFunc( &dbg_printOslDebugMessage );
1325cdf0e10cSrcweir                     pDebugData->bOslIsHooked = sal_True;
1326cdf0e10cSrcweir                 }
1327cdf0e10cSrcweir             }
1328cdf0e10cSrcweir             break;
1329cdf0e10cSrcweir        }
1330cdf0e10cSrcweir 
1331cdf0e10cSrcweir         return NULL;
1332cdf0e10cSrcweir     }
1333cdf0e10cSrcweir }
1334cdf0e10cSrcweir 
1335cdf0e10cSrcweir // -----------------------------------------------------------------------
1336cdf0e10cSrcweir 
1337cdf0e10cSrcweir DbgChannelId DbgRegisterUserChannel( DbgPrintLine pProc )
1338cdf0e10cSrcweir {
1339cdf0e10cSrcweir     DebugData* pData = ImplGetDebugData();
1340cdf0e10cSrcweir     pData->aDbgPrintUserChannels.push_back( pProc );
1341cdf0e10cSrcweir     return (DbgChannelId)( pData->aDbgPrintUserChannels.size() - 1 + DBG_OUT_USER_CHANNEL_0 );
1342cdf0e10cSrcweir }
1343cdf0e10cSrcweir 
1344cdf0e10cSrcweir // -----------------------------------------------------------------------
1345cdf0e10cSrcweir 
1346cdf0e10cSrcweir void DbgProf( sal_uInt16 nAction, DbgDataType* pDbgData )
1347cdf0e10cSrcweir {
1348cdf0e10cSrcweir     // Ueberhaupt Profiling-Test an
1349cdf0e10cSrcweir     DebugData* pData = ImplGetDebugData();
1350cdf0e10cSrcweir 
1351cdf0e10cSrcweir     if ( !(pData->aDbgData.nTestFlags & DBG_TEST_PROFILING) )
1352cdf0e10cSrcweir         return;
1353cdf0e10cSrcweir 
1354cdf0e10cSrcweir     sal_Char    aBuf[DBG_BUF_MAXLEN];
1355cdf0e10cSrcweir     ProfType*   pProfData = (ProfType*)pDbgData->pData;
1356cdf0e10cSrcweir     sal_uIntPtr       nTime;
1357cdf0e10cSrcweir     if ( (nAction != DBG_PROF_START) && !pProfData )
1358cdf0e10cSrcweir     {
1359cdf0e10cSrcweir         strcpy( aBuf, DbgError_ProfEnd1 );
1360cdf0e10cSrcweir         strcat( aBuf, pDbgData->pName );
1361cdf0e10cSrcweir         DbgError( aBuf );
1362cdf0e10cSrcweir         return;
1363cdf0e10cSrcweir     }
1364cdf0e10cSrcweir 
1365cdf0e10cSrcweir     switch ( nAction )
1366cdf0e10cSrcweir     {
1367cdf0e10cSrcweir         case DBG_PROF_START:
1368cdf0e10cSrcweir             if ( !pDbgData->pData )
1369cdf0e10cSrcweir             {
1370cdf0e10cSrcweir                 pDbgData->pData = (void*)new ProfType;
1371cdf0e10cSrcweir                 pProfData = (ProfType*)pDbgData->pData;
1372cdf0e10cSrcweir                 strncpy( pProfData->aName, pDbgData->pName, DBG_MAXNAME );
1373cdf0e10cSrcweir                 pProfData->aName[DBG_MAXNAME] = '\0';
1374cdf0e10cSrcweir                 pProfData->nCount           = 0;
1375cdf0e10cSrcweir                 pProfData->nTime            = 0;
1376cdf0e10cSrcweir                 pProfData->nMinTime         = 0xFFFFFFFF;
1377cdf0e10cSrcweir                 pProfData->nMaxTime         = 0;
1378cdf0e10cSrcweir                 pProfData->nStart           = 0xFFFFFFFF;
1379cdf0e10cSrcweir                 pProfData->nContinueTime    = 0;
1380cdf0e10cSrcweir                 pProfData->nContinueStart   = 0xFFFFFFFF;
1381cdf0e10cSrcweir                 pData->pProfList->Add( (void*)pProfData );
1382cdf0e10cSrcweir             }
1383cdf0e10cSrcweir 
1384cdf0e10cSrcweir             if ( pProfData->nStart == 0xFFFFFFFF )
1385cdf0e10cSrcweir             {
1386cdf0e10cSrcweir                 pProfData->nStart = ImplGetPerfTime();
1387cdf0e10cSrcweir                 pProfData->nCount++;
1388cdf0e10cSrcweir             }
1389cdf0e10cSrcweir             break;
1390cdf0e10cSrcweir 
1391cdf0e10cSrcweir         case DBG_PROF_STOP:
1392cdf0e10cSrcweir             nTime = ImplGetPerfTime();
1393cdf0e10cSrcweir 
1394cdf0e10cSrcweir             if ( pProfData->nStart == 0xFFFFFFFF )
1395cdf0e10cSrcweir             {
1396cdf0e10cSrcweir                 DbgError( DbgError_ProfEnd1 );
1397cdf0e10cSrcweir                 return;
1398cdf0e10cSrcweir             }
1399cdf0e10cSrcweir 
1400cdf0e10cSrcweir             if ( pProfData->nContinueStart != 0xFFFFFFFF )
1401cdf0e10cSrcweir             {
1402cdf0e10cSrcweir                 pProfData->nContinueTime += ImplGetPerfTime() - pProfData->nContinueStart;
1403cdf0e10cSrcweir                 pProfData->nContinueStart = 0xFFFFFFFF;
1404cdf0e10cSrcweir             }
1405cdf0e10cSrcweir 
1406cdf0e10cSrcweir             nTime -= pProfData->nStart;
1407cdf0e10cSrcweir             nTime -= pProfData->nContinueTime;
1408cdf0e10cSrcweir 
1409cdf0e10cSrcweir             if ( nTime < pProfData->nMinTime )
1410cdf0e10cSrcweir                 pProfData->nMinTime = nTime;
1411cdf0e10cSrcweir 
1412cdf0e10cSrcweir             if ( nTime > pProfData->nMaxTime )
1413cdf0e10cSrcweir                 pProfData->nMaxTime = nTime;
1414cdf0e10cSrcweir 
1415cdf0e10cSrcweir             pProfData->nTime += nTime;
1416cdf0e10cSrcweir 
1417cdf0e10cSrcweir             pProfData->nStart         = 0xFFFFFFFF;
1418cdf0e10cSrcweir             pProfData->nContinueTime  = 0;
1419cdf0e10cSrcweir             pProfData->nContinueStart = 0xFFFFFFFF;
1420cdf0e10cSrcweir             break;
1421cdf0e10cSrcweir 
1422cdf0e10cSrcweir         case DBG_PROF_CONTINUE:
1423cdf0e10cSrcweir             if ( pProfData->nContinueStart != 0xFFFFFFFF )
1424cdf0e10cSrcweir             {
1425cdf0e10cSrcweir                 pProfData->nContinueTime += ImplGetPerfTime() - pProfData->nContinueStart;
1426cdf0e10cSrcweir                 pProfData->nContinueStart = 0xFFFFFFFF;
1427cdf0e10cSrcweir             }
1428cdf0e10cSrcweir             break;
1429cdf0e10cSrcweir 
1430cdf0e10cSrcweir         case DBG_PROF_PAUSE:
1431cdf0e10cSrcweir             if ( pProfData->nContinueStart == 0xFFFFFFFF )
1432cdf0e10cSrcweir                 pProfData->nContinueStart = ImplGetPerfTime();
1433cdf0e10cSrcweir             break;
1434cdf0e10cSrcweir     }
1435cdf0e10cSrcweir }
1436cdf0e10cSrcweir 
1437cdf0e10cSrcweir // -----------------------------------------------------------------------
1438cdf0e10cSrcweir 
1439cdf0e10cSrcweir void DbgXtor( DbgDataType* pDbgData, sal_uInt16 nAction, const void* pThis,
1440cdf0e10cSrcweir               DbgUsr fDbgUsr )
1441cdf0e10cSrcweir {
1442cdf0e10cSrcweir     DebugData* pData = ImplGetDebugData();
1443cdf0e10cSrcweir 
1444cdf0e10cSrcweir     // Verbindung zu Debug-Memory-Manager testen
1445cdf0e10cSrcweir #ifdef SV_MEMMGR
1446cdf0e10cSrcweir     if ( pData->aDbgData.nTestFlags & DBG_TEST_MEM_XTOR )
1447cdf0e10cSrcweir         DbgImpCheckMemory();
1448cdf0e10cSrcweir #endif
1449cdf0e10cSrcweir 
1450cdf0e10cSrcweir     // Schnell-Test
1451cdf0e10cSrcweir     if ( !(pData->aDbgData.nTestFlags & DBG_TEST_XTOR) )
1452cdf0e10cSrcweir         return;
1453cdf0e10cSrcweir 
1454cdf0e10cSrcweir     XtorType* pXtorData = (XtorType*)pDbgData->pData;
1455cdf0e10cSrcweir     if ( !pXtorData )
1456cdf0e10cSrcweir     {
1457cdf0e10cSrcweir         pDbgData->pData = (void*)new XtorType;
1458cdf0e10cSrcweir         pXtorData = (XtorType*)pDbgData->pData;
1459cdf0e10cSrcweir         strncpy( pXtorData->aName, pDbgData->pName, DBG_MAXNAME );
1460cdf0e10cSrcweir         pXtorData->aName[DBG_MAXNAME] = '\0';
1461cdf0e10cSrcweir         pXtorData->nCtorCalls   = 0;
1462cdf0e10cSrcweir         pXtorData->nDtorCalls   = 0;
1463cdf0e10cSrcweir         pXtorData->nMaxCount    = 0;
1464cdf0e10cSrcweir         pXtorData->nStatics     = 0;
1465cdf0e10cSrcweir         pXtorData->bTest        = sal_True;
1466cdf0e10cSrcweir         pData->pXtorList->Add( (void*)pXtorData );
1467cdf0e10cSrcweir 
1468cdf0e10cSrcweir         if ( !ImplDbgFilter( pData->aDbgData.aInclClassFilter, pXtorData->aName, sal_True ) )
1469cdf0e10cSrcweir             pXtorData->bTest = sal_False;
1470cdf0e10cSrcweir         if ( ImplDbgFilter( pData->aDbgData.aExclClassFilter, pXtorData->aName, sal_False ) )
1471cdf0e10cSrcweir             pXtorData->bTest = sal_False;
1472cdf0e10cSrcweir     }
1473cdf0e10cSrcweir     if ( !pXtorData->bTest )
1474cdf0e10cSrcweir         return;
1475cdf0e10cSrcweir 
1476cdf0e10cSrcweir     sal_Char    aBuf[DBG_BUF_MAXLEN];
1477cdf0e10cSrcweir     sal_uInt16      nAct = nAction & ~DBG_XTOR_DTOROBJ;
1478cdf0e10cSrcweir 
1479cdf0e10cSrcweir     // Trace (Enter)
1480cdf0e10cSrcweir     if ( (pData->aDbgData.nTestFlags & DBG_TEST_XTOR_TRACE) &&
1481cdf0e10cSrcweir          !(nAction & DBG_XTOR_DTOROBJ) )
1482cdf0e10cSrcweir     {
1483cdf0e10cSrcweir         if ( nAct != DBG_XTOR_CHKOBJ )
1484cdf0e10cSrcweir         {
1485cdf0e10cSrcweir             if ( nAct == DBG_XTOR_CTOR )
1486cdf0e10cSrcweir                 strcpy( aBuf, DbgTrace_EnterCtor );
1487cdf0e10cSrcweir             else if ( nAct == DBG_XTOR_DTOR )
1488cdf0e10cSrcweir                 strcpy( aBuf, DbgTrace_EnterDtor );
1489cdf0e10cSrcweir             else
1490cdf0e10cSrcweir                 strcpy( aBuf, DbgTrace_EnterMeth );
1491cdf0e10cSrcweir             strcat( aBuf, pDbgData->pName );
1492cdf0e10cSrcweir             DbgTrace( aBuf );
1493cdf0e10cSrcweir         }
1494cdf0e10cSrcweir     }
1495cdf0e10cSrcweir 
1496cdf0e10cSrcweir     // Sind noch Xtor-Tests als Trace an
1497cdf0e10cSrcweir     if ( pData->aDbgData.nTestFlags & DBG_TEST_XTOR_EXTRA )
1498cdf0e10cSrcweir     {
1499cdf0e10cSrcweir         // DBG_CTOR-Aufruf vor allen anderen DBG_XTOR-Aufrufen
1500cdf0e10cSrcweir         if ( ((nAction & ~DBG_XTOR_DTOROBJ) != DBG_XTOR_CTOR) && !pDbgData->pData )
1501cdf0e10cSrcweir         {
1502cdf0e10cSrcweir             strcpy( aBuf, DbgError_Xtor1 );
1503cdf0e10cSrcweir             strcat( aBuf, pDbgData->pName );
1504cdf0e10cSrcweir             DbgError( aBuf );
1505cdf0e10cSrcweir             return;
1506cdf0e10cSrcweir         }
1507cdf0e10cSrcweir 
1508cdf0e10cSrcweir         // Testen, ob This-Pointer gueltig
1509cdf0e10cSrcweir         if ( pData->aDbgData.nTestFlags & DBG_TEST_XTOR_THIS )
1510cdf0e10cSrcweir         {
1511cdf0e10cSrcweir             if ( (pData->aDbgData.nTestFlags & DBG_TEST_XTOR_EXIT) ||
1512cdf0e10cSrcweir                  !(nAction & DBG_XTOR_DTOROBJ) )
1513cdf0e10cSrcweir             {
1514cdf0e10cSrcweir                 // This-Pointer == NULL
1515cdf0e10cSrcweir                 if ( !pThis )
1516cdf0e10cSrcweir                 {
1517cdf0e10cSrcweir                     strcpy( aBuf, DbgError_CtorDtor1 );
1518cdf0e10cSrcweir                     strcat( aBuf, pDbgData->pName );
1519cdf0e10cSrcweir                     DbgError( aBuf );
1520cdf0e10cSrcweir                     return;
1521cdf0e10cSrcweir                 }
1522cdf0e10cSrcweir 
1523cdf0e10cSrcweir                 if ( (nAction & ~DBG_XTOR_DTOROBJ) != DBG_XTOR_CTOR )
1524cdf0e10cSrcweir                 {
1525cdf0e10cSrcweir                     if ( !pXtorData->aThisList.IsIn( pThis ) )
1526cdf0e10cSrcweir                     {
1527cdf0e10cSrcweir                         sprintf( aBuf, DbgError_CtorDtor2, pThis );
1528cdf0e10cSrcweir                         strcat( aBuf, pDbgData->pName );
1529cdf0e10cSrcweir                         DbgError( aBuf );
1530cdf0e10cSrcweir                     }
1531cdf0e10cSrcweir                 }
1532cdf0e10cSrcweir             }
1533cdf0e10cSrcweir         }
1534cdf0e10cSrcweir 
1535cdf0e10cSrcweir         // Function-Test durchfuehren und Verwaltungsdaten updaten
1536cdf0e10cSrcweir         const sal_Char* pMsg = NULL;
1537cdf0e10cSrcweir         switch ( nAction & ~DBG_XTOR_DTOROBJ )
1538cdf0e10cSrcweir         {
1539cdf0e10cSrcweir             case DBG_XTOR_CTOR:
1540cdf0e10cSrcweir                 if ( nAction & DBG_XTOR_DTOROBJ )
1541cdf0e10cSrcweir                 {
1542cdf0e10cSrcweir                     if ( fDbgUsr &&
1543cdf0e10cSrcweir                          (pData->aDbgData.nTestFlags & DBG_TEST_XTOR_EXIT) &&
1544cdf0e10cSrcweir                          (pData->aDbgData.nTestFlags & DBG_TEST_XTOR_FUNC) )
1545cdf0e10cSrcweir                         pMsg = fDbgUsr( pThis );
1546cdf0e10cSrcweir                 }
1547cdf0e10cSrcweir                 else
1548cdf0e10cSrcweir                 {
1549cdf0e10cSrcweir                     pXtorData->nCtorCalls++;
1550cdf0e10cSrcweir                     if ( !bDbgImplInMain )
1551cdf0e10cSrcweir                         pXtorData->nStatics++;
1552cdf0e10cSrcweir                     if ( (pXtorData->nCtorCalls-pXtorData->nDtorCalls) > pXtorData->nMaxCount )
1553cdf0e10cSrcweir                         pXtorData->nMaxCount = pXtorData->nCtorCalls - pXtorData->nDtorCalls;
1554cdf0e10cSrcweir 
1555cdf0e10cSrcweir                     if ( pData->aDbgData.nTestFlags & DBG_TEST_XTOR_THIS )
1556cdf0e10cSrcweir                         pXtorData->aThisList.Add( pThis );
1557cdf0e10cSrcweir                 }
1558cdf0e10cSrcweir                 break;
1559cdf0e10cSrcweir 
1560cdf0e10cSrcweir             case DBG_XTOR_DTOR:
1561cdf0e10cSrcweir                 if ( nAction & DBG_XTOR_DTOROBJ )
1562cdf0e10cSrcweir                 {
1563cdf0e10cSrcweir                     pXtorData->nDtorCalls++;
1564cdf0e10cSrcweir                     if ( pData->aDbgData.nTestFlags & DBG_TEST_XTOR_THIS )
1565cdf0e10cSrcweir                         pXtorData->aThisList.Remove( pThis );
1566cdf0e10cSrcweir                 }
1567cdf0e10cSrcweir                 else
1568cdf0e10cSrcweir                 {
1569cdf0e10cSrcweir                     if ( fDbgUsr &&
1570cdf0e10cSrcweir                          (pData->aDbgData.nTestFlags & DBG_TEST_XTOR_FUNC) )
1571cdf0e10cSrcweir                         pMsg = fDbgUsr( pThis );
1572cdf0e10cSrcweir                 }
1573cdf0e10cSrcweir                 break;
1574cdf0e10cSrcweir 
1575cdf0e10cSrcweir             case DBG_XTOR_CHKTHIS:
1576cdf0e10cSrcweir             case DBG_XTOR_CHKOBJ:
1577cdf0e10cSrcweir                 if ( nAction & DBG_XTOR_DTOROBJ )
1578cdf0e10cSrcweir                 {
1579cdf0e10cSrcweir                     if ( fDbgUsr &&
1580cdf0e10cSrcweir                          (pData->aDbgData.nTestFlags & DBG_TEST_XTOR_EXIT) &&
1581cdf0e10cSrcweir                          (pData->aDbgData.nTestFlags & DBG_TEST_XTOR_FUNC) )
1582cdf0e10cSrcweir                         pMsg = fDbgUsr( pThis );
1583cdf0e10cSrcweir                 }
1584cdf0e10cSrcweir                 else
1585cdf0e10cSrcweir                 {
1586cdf0e10cSrcweir                     if ( fDbgUsr &&
1587cdf0e10cSrcweir                          (pData->aDbgData.nTestFlags & DBG_TEST_XTOR_FUNC) )
1588cdf0e10cSrcweir                         pMsg = fDbgUsr( pThis );
1589cdf0e10cSrcweir                 }
1590cdf0e10cSrcweir                 break;
1591cdf0e10cSrcweir         }
1592cdf0e10cSrcweir 
1593cdf0e10cSrcweir         // Gegebenenfalls Fehlermeldung ausgeben
1594cdf0e10cSrcweir         if ( pMsg )
1595cdf0e10cSrcweir         {
1596cdf0e10cSrcweir             sprintf( aBuf, DbgError_CtorDtor3, pThis );
1597cdf0e10cSrcweir             strcat( aBuf, pDbgData->pName );
1598cdf0e10cSrcweir             strcat( aBuf, ": \n" );
1599cdf0e10cSrcweir             strcat( aBuf, pMsg );
1600cdf0e10cSrcweir             DbgError( aBuf );
1601cdf0e10cSrcweir         }
1602cdf0e10cSrcweir     }
1603cdf0e10cSrcweir 
1604cdf0e10cSrcweir     // Trace (Leave)
1605cdf0e10cSrcweir     if ( (pData->aDbgData.nTestFlags & DBG_TEST_XTOR_TRACE) &&
1606cdf0e10cSrcweir          (nAction & DBG_XTOR_DTOROBJ) )
1607cdf0e10cSrcweir     {
1608cdf0e10cSrcweir         if ( nAct != DBG_XTOR_CHKOBJ )
1609cdf0e10cSrcweir         {
1610cdf0e10cSrcweir             if ( nAct == DBG_XTOR_CTOR )
1611cdf0e10cSrcweir                 strcpy( aBuf, DbgTrace_LeaveCtor );
1612cdf0e10cSrcweir             else if ( nAct == DBG_XTOR_DTOR )
1613cdf0e10cSrcweir                 strcpy( aBuf, DbgTrace_LeaveDtor );
1614cdf0e10cSrcweir             else
1615cdf0e10cSrcweir                 strcpy( aBuf, DbgTrace_LeaveMeth );
1616cdf0e10cSrcweir             strcat( aBuf, pDbgData->pName );
1617cdf0e10cSrcweir             DbgTrace( aBuf );
1618cdf0e10cSrcweir         }
1619cdf0e10cSrcweir     }
1620cdf0e10cSrcweir }
1621cdf0e10cSrcweir 
1622cdf0e10cSrcweir // -----------------------------------------------------------------------
1623cdf0e10cSrcweir 
1624cdf0e10cSrcweir void DbgOut( const sal_Char* pMsg, sal_uInt16 nDbgOut, const sal_Char* pFile, sal_uInt16 nLine )
1625cdf0e10cSrcweir {
1626cdf0e10cSrcweir     static sal_Bool bIn = sal_False;
1627cdf0e10cSrcweir     if ( bIn )
1628cdf0e10cSrcweir         return;
1629cdf0e10cSrcweir     bIn = sal_True;
1630cdf0e10cSrcweir 
1631cdf0e10cSrcweir     DebugData*  pData = GetDebugData();
1632cdf0e10cSrcweir     sal_Char const *   pStr;
1633cdf0e10cSrcweir     sal_uIntPtr       nOut;
1634cdf0e10cSrcweir     int         nBufLen = 0;
1635cdf0e10cSrcweir 
1636cdf0e10cSrcweir     if ( nDbgOut == DBG_OUT_ERROR )
1637cdf0e10cSrcweir     {
1638cdf0e10cSrcweir         nOut = pData->aDbgData.nErrorOut;
1639cdf0e10cSrcweir         pStr = "Error: ";
1640cdf0e10cSrcweir         if ( pData->aDbgData.nErrorOut == DBG_OUT_FILE )
1641cdf0e10cSrcweir             DbgDebugBeep();
1642cdf0e10cSrcweir     }
1643cdf0e10cSrcweir     else if ( nDbgOut == DBG_OUT_WARNING )
1644cdf0e10cSrcweir     {
1645cdf0e10cSrcweir         nOut = pData->aDbgData.nWarningOut;
1646cdf0e10cSrcweir         pStr = "Warning: ";
1647cdf0e10cSrcweir     }
1648cdf0e10cSrcweir     else
1649cdf0e10cSrcweir     {
1650cdf0e10cSrcweir         nOut = pData->aDbgData.nTraceOut;
1651cdf0e10cSrcweir         pStr = NULL;
1652cdf0e10cSrcweir     }
1653cdf0e10cSrcweir 
1654cdf0e10cSrcweir     if ( nOut == DBG_OUT_NULL )
1655cdf0e10cSrcweir     {
1656cdf0e10cSrcweir         bIn = sal_False;
1657cdf0e10cSrcweir         return;
1658cdf0e10cSrcweir     }
1659cdf0e10cSrcweir 
1660cdf0e10cSrcweir     if ( ImplDbgFilterMessage( pMsg ) )
1661cdf0e10cSrcweir     {
1662cdf0e10cSrcweir         bIn = sal_False;
1663cdf0e10cSrcweir         return;
1664cdf0e10cSrcweir     }
1665cdf0e10cSrcweir 
1666cdf0e10cSrcweir     ImplDbgLock();
1667cdf0e10cSrcweir 
1668cdf0e10cSrcweir     sal_Char aBufOut[DBG_BUF_MAXLEN];
1669cdf0e10cSrcweir     if ( pStr )
1670cdf0e10cSrcweir     {
1671cdf0e10cSrcweir         strcpy( aBufOut, pStr );
1672cdf0e10cSrcweir         nBufLen = strlen( pStr );
1673cdf0e10cSrcweir     }
1674cdf0e10cSrcweir     else
1675cdf0e10cSrcweir         aBufOut[0] = '\0';
1676cdf0e10cSrcweir 
1677cdf0e10cSrcweir     int nMsgLen = strlen( pMsg );
1678cdf0e10cSrcweir     if ( nBufLen+nMsgLen > DBG_BUF_MAXLEN )
1679cdf0e10cSrcweir     {
1680cdf0e10cSrcweir         int nCopyLen = DBG_BUF_MAXLEN-nBufLen-3;
1681cdf0e10cSrcweir         strncpy( &(aBufOut[nBufLen]), pMsg, nCopyLen );
1682cdf0e10cSrcweir         strcpy( &(aBufOut[nBufLen+nCopyLen]), "..." );
1683cdf0e10cSrcweir     }
1684cdf0e10cSrcweir     else
1685cdf0e10cSrcweir         strcpy( &(aBufOut[nBufLen]), pMsg );
1686cdf0e10cSrcweir 
1687cdf0e10cSrcweir     if ( pFile && nLine && (nBufLen+nMsgLen < DBG_BUF_MAXLEN) )
1688cdf0e10cSrcweir     {
1689cdf0e10cSrcweir         if ( nOut == DBG_OUT_MSGBOX )
1690cdf0e10cSrcweir             strcat( aBufOut, "\n" );
1691cdf0e10cSrcweir         else
1692cdf0e10cSrcweir             strcat( aBufOut, " " );
1693cdf0e10cSrcweir         strcat( aBufOut, "From File " );
1694cdf0e10cSrcweir         strcat( aBufOut, pFile );
1695cdf0e10cSrcweir         strcat( aBufOut, " at Line " );
1696cdf0e10cSrcweir 
1697cdf0e10cSrcweir         // Line in String umwandeln und dranhaengen
1698cdf0e10cSrcweir         sal_Char    aLine[9];
1699cdf0e10cSrcweir         sal_Char*   pLine = &aLine[7];
1700cdf0e10cSrcweir         sal_uInt16      i;
1701cdf0e10cSrcweir         memset( aLine, 0, sizeof( aLine ) );
1702cdf0e10cSrcweir         do
1703cdf0e10cSrcweir         {
1704cdf0e10cSrcweir             i = nLine % 10;
1705cdf0e10cSrcweir             pLine--;
1706cdf0e10cSrcweir             *(pLine) = (sal_Char)i + 48;
1707cdf0e10cSrcweir             nLine /= 10;
1708cdf0e10cSrcweir         }
1709cdf0e10cSrcweir         while ( nLine );
1710cdf0e10cSrcweir         strcat( aBufOut, pLine );
1711cdf0e10cSrcweir     }
1712cdf0e10cSrcweir 
1713cdf0e10cSrcweir     if ( ( nOut >= DBG_OUT_USER_CHANNEL_0 ) && ( nOut - DBG_OUT_USER_CHANNEL_0 < pData->aDbgPrintUserChannels.size() ) )
1714cdf0e10cSrcweir     {
1715cdf0e10cSrcweir         DbgPrintLine pPrinter = pData->aDbgPrintUserChannels[ nOut - DBG_OUT_USER_CHANNEL_0 ];
1716cdf0e10cSrcweir         if ( pPrinter )
1717cdf0e10cSrcweir             pPrinter( aBufOut );
1718cdf0e10cSrcweir         else
1719cdf0e10cSrcweir             nOut = DBG_OUT_DEBUGGER;
1720cdf0e10cSrcweir     }
1721cdf0e10cSrcweir 
1722cdf0e10cSrcweir     if ( nOut == DBG_OUT_ABORT )
1723cdf0e10cSrcweir     {
1724cdf0e10cSrcweir         if ( pData->pDbgAbort != NULL )
1725cdf0e10cSrcweir             pData->pDbgAbort( aBufOut );
1726cdf0e10cSrcweir         abort();
1727cdf0e10cSrcweir     }
1728cdf0e10cSrcweir 
1729cdf0e10cSrcweir     if ( nOut == DBG_OUT_DEBUGGER )
1730cdf0e10cSrcweir     {
1731cdf0e10cSrcweir         if ( !ImplActivateDebugger( aBufOut ) )
1732cdf0e10cSrcweir             nOut = DBG_OUT_TESTTOOL;
1733cdf0e10cSrcweir     }
1734cdf0e10cSrcweir 
1735cdf0e10cSrcweir     if ( nOut == DBG_OUT_TESTTOOL )
1736cdf0e10cSrcweir     {
1737cdf0e10cSrcweir         if ( pData->pDbgPrintTestTool )
1738cdf0e10cSrcweir             pData->pDbgPrintTestTool( aBufOut );
1739cdf0e10cSrcweir         else
1740cdf0e10cSrcweir             nOut = DBG_OUT_MSGBOX;
1741cdf0e10cSrcweir     }
1742cdf0e10cSrcweir 
1743cdf0e10cSrcweir     if ( nOut == DBG_OUT_MSGBOX )
1744cdf0e10cSrcweir     {
1745cdf0e10cSrcweir         if ( pData->pDbgPrintMsgBox )
1746cdf0e10cSrcweir             pData->pDbgPrintMsgBox( aBufOut );
1747cdf0e10cSrcweir         else
1748cdf0e10cSrcweir             nOut = DBG_OUT_WINDOW;
1749cdf0e10cSrcweir     }
1750cdf0e10cSrcweir 
1751cdf0e10cSrcweir     if ( nOut == DBG_OUT_WINDOW )
1752cdf0e10cSrcweir     {
1753cdf0e10cSrcweir         if ( pData->pDbgPrintWindow )
1754cdf0e10cSrcweir             pData->pDbgPrintWindow( aBufOut );
1755cdf0e10cSrcweir         else
1756cdf0e10cSrcweir             nOut = DBG_OUT_FILE;
1757cdf0e10cSrcweir     }
1758cdf0e10cSrcweir 
1759cdf0e10cSrcweir     switch ( nOut )
1760cdf0e10cSrcweir     {
1761cdf0e10cSrcweir     case DBG_OUT_SHELL:
1762cdf0e10cSrcweir         DbgPrintShell( aBufOut );
1763cdf0e10cSrcweir         break;
1764cdf0e10cSrcweir     case DBG_OUT_FILE:
1765cdf0e10cSrcweir         ImplDbgPrintFile( aBufOut );
1766cdf0e10cSrcweir         break;
1767cdf0e10cSrcweir     }
1768cdf0e10cSrcweir 
1769cdf0e10cSrcweir     ImplDbgUnlock();
1770cdf0e10cSrcweir 
1771cdf0e10cSrcweir     bIn = sal_False;
1772cdf0e10cSrcweir }
1773cdf0e10cSrcweir 
1774cdf0e10cSrcweir void DbgPrintShell(char const * message) {
1775cdf0e10cSrcweir     fprintf(stderr, "%s\n", message);
1776cdf0e10cSrcweir #if defined WNT
1777cdf0e10cSrcweir     OutputDebugStringA(message);
1778cdf0e10cSrcweir #endif
1779cdf0e10cSrcweir }
1780cdf0e10cSrcweir 
1781cdf0e10cSrcweir // -----------------------------------------------------------------------
1782cdf0e10cSrcweir 
1783cdf0e10cSrcweir void DbgOutTypef( sal_uInt16 nDbgOut, const sal_Char* pFStr, ... )
1784cdf0e10cSrcweir {
1785cdf0e10cSrcweir     va_list pList;
1786cdf0e10cSrcweir 
1787cdf0e10cSrcweir     va_start( pList, pFStr );
1788cdf0e10cSrcweir     sal_Char aBuf[DBG_BUF_MAXLEN];
1789cdf0e10cSrcweir     vsprintf( aBuf, pFStr, pList );
1790cdf0e10cSrcweir     va_end( pList );
1791cdf0e10cSrcweir 
1792cdf0e10cSrcweir     DbgOut( aBuf, nDbgOut );
1793cdf0e10cSrcweir }
1794cdf0e10cSrcweir 
1795cdf0e10cSrcweir // -----------------------------------------------------------------------
1796cdf0e10cSrcweir 
1797cdf0e10cSrcweir void DbgOutf( const sal_Char* pFStr, ... )
1798cdf0e10cSrcweir {
1799cdf0e10cSrcweir     va_list pList;
1800cdf0e10cSrcweir 
1801cdf0e10cSrcweir     va_start( pList, pFStr );
1802cdf0e10cSrcweir     sal_Char aBuf[DBG_BUF_MAXLEN];
1803cdf0e10cSrcweir     vsprintf( aBuf, pFStr, pList );
1804cdf0e10cSrcweir     va_end( pList );
1805cdf0e10cSrcweir 
1806cdf0e10cSrcweir     DbgOut( aBuf );
1807cdf0e10cSrcweir }
1808cdf0e10cSrcweir 
1809cdf0e10cSrcweir // =======================================================================
1810cdf0e10cSrcweir 
1811cdf0e10cSrcweir #else
1812cdf0e10cSrcweir 
1813cdf0e10cSrcweir void* DbgFunc( sal_uInt16, void* ) { return NULL; }
1814cdf0e10cSrcweir 
1815cdf0e10cSrcweir void DbgProf( sal_uInt16, DbgDataType* ) {}
1816cdf0e10cSrcweir void DbgXtor( DbgDataType*, sal_uInt16, const void*, DbgUsr ) {}
1817cdf0e10cSrcweir 
1818cdf0e10cSrcweir void DbgOut( const sal_Char*, sal_uInt16, const sal_Char*, sal_uInt16 ) {}
1819cdf0e10cSrcweir void DbgOutTypef( sal_uInt16, const sal_Char*, ... ) {}
1820cdf0e10cSrcweir void DbgOutf( const sal_Char*, ... ) {}
1821cdf0e10cSrcweir 
1822cdf0e10cSrcweir #endif
1823