diff options
Diffstat (limited to 'framework/inc/macros/debug')
-rw-r--r-- | framework/inc/macros/debug/assertion.hxx | 235 | ||||
-rw-r--r-- | framework/inc/macros/debug/event.hxx | 132 | ||||
-rw-r--r-- | framework/inc/macros/debug/filterdbg.hxx | 130 | ||||
-rw-r--r-- | framework/inc/macros/debug/logmechanism.hxx | 102 | ||||
-rw-r--r-- | framework/inc/macros/debug/memorymeasure.hxx | 223 | ||||
-rw-r--r-- | framework/inc/macros/debug/mutex.hxx | 117 | ||||
-rw-r--r-- | framework/inc/macros/debug/plugin.hxx | 202 | ||||
-rw-r--r-- | framework/inc/macros/debug/registration.hxx | 100 | ||||
-rw-r--r-- | framework/inc/macros/debug/targeting.hxx | 252 | ||||
-rw-r--r-- | framework/inc/macros/debug/timemeasure.hxx | 140 |
10 files changed, 1633 insertions, 0 deletions
diff --git a/framework/inc/macros/debug/assertion.hxx b/framework/inc/macros/debug/assertion.hxx new file mode 100644 index 000000000000..a2e6197a8b91 --- /dev/null +++ b/framework/inc/macros/debug/assertion.hxx @@ -0,0 +1,235 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef __FRAMEWORK_MACROS_DEBUG_ASSERTION_HXX_ +#define __FRAMEWORK_MACROS_DEBUG_ASSERTION_HXX_ + +//_________________________________________________________________________________________________________________ +// includes +//_________________________________________________________________________________________________________________ + +#if defined( ENABLE_ASSERTIONS ) || defined( ENABLE_WARNINGS ) + + #ifndef _OSL_DIAGNOSE_H_ + #include <osl/diagnose.h> + #endif + + #ifndef _RTL_STRBUF_HXX_ + #include <rtl/strbuf.hxx> + #endif + +#endif + +//***************************************************************************************************************** +// special macros for assertion handling +// 1) LOGTYPE use it to define the output of all assertions, errors, exception infos +// 2) LOGFILE_ASSERTIONS use it to define the file name to log assertions if LOGTYPE=LOGTYPE_FILE... +// 3) LOGFILE_WARNINGS use it to define the file name to log warnings if LOGTYPE=LOGTYPE_FILE... +// +// active for "non product": +// +// 4) LOG_ASSERT( BCONDITION, STEXT ) assert some critical errors wich depend from given condition +// 4a) LOG_ASSERT2( BCONDITION, SMETHOD, STEXT ) same like 4) + additional location of error +// 5) LOG_ERROR( SMETHOD, STEXT ) show errors without any condition +// +// active for debug only! +// +// 6) LOG_EXCEPTION( SMETHOD, SOWNMESSAGE, SEXCEPTIONMESSAGE ) show/log an exception for easier debug +// 7) LOG_WARNING( SMETHOD, STEXT ) should be used to detect leaks in algorithm, mechanism or operation handling +//***************************************************************************************************************** + +//_________________________________________________________________________________________________________________ +#if defined( ENABLE_ASSERTIONS ) || defined( ENABLE_WARNINGS ) + + /*_____________________________________________________________________________________________________________ + LOGFILE_ASSERTIONS + + For follow macros we need a special log file. If user forget to specify anyone, we must do it for him! + _____________________________________________________________________________________________________________*/ + + #ifndef LOGFILE_ASSERTIONS + #define LOGFILE_ASSERTIONS "_framework_assertions.log" + #endif + + /*_____________________________________________________________________________________________________________ + LOG_ASSERT ( BCONDITION, STEXT ) + LOG_ASSERT2( BCONDITION, SMETHOD, STEXT ) + + Forward assertion to logfile (if condition is FALSE - like a DBG_ASSERT!) and continue with program. + Set LOGTYPE to LOGTYPE_FILECONTINUE to do this. + BCONDITION is inserted in "(...)" because user can call this macro with an complex expression! + _____________________________________________________________________________________________________________*/ + #if LOGTYPE==LOGTYPE_FILECONTINUE + + #define LOG_ASSERT( BCONDITION, STEXT ) \ + if ( ( BCONDITION ) == sal_False ) \ + { \ + WRITE_LOGFILE( LOGFILE_ASSERTIONS, STEXT ) \ + } + + #define LOG_ASSERT2( BCONDITION, SMETHOD, STEXT ) \ + if ( ( BCONDITION ) == sal_True ) \ + { \ + ::rtl::OStringBuffer _sAssertBuffer( 256 ); \ + _sAssertBuffer.append( "ASSERT:\n\t" ); \ + _sAssertBuffer.append( SMETHOD ); \ + _sAssertBuffer.append( "\n\t\"" ); \ + _sAssertBuffer.append( STEXT ); \ + _sAssertBuffer.append( "\"\n" ); \ + WRITE_LOGFILE( LOGFILE_ASSERTIONS, _sAssertBuffer.makeStringAndClear() ) \ + } + + #endif + + /*_____________________________________________________________________________________________________________ + LOG_ASSERT ( BCONDITION, STEXT ) + LOG_ASSERT2( BCONDITION, SMETHOD, STEXT ) + + Forward assertion to file and exit the program. + Set LOGTYPE to LOGTYPE_FILEEXIT to do this. + BCONDITION is inserted in "(...)" because user can call this macro with an complex expression! + _____________________________________________________________________________________________________________*/ + #if LOGTYPE==LOGTYPE_FILEEXIT + + #define LOG_ASSERT( BCONDITION, STEXT ) \ + if ( ( BCONDITION ) == sal_False ) \ + { \ + WRITE_LOGFILE( LOGFILE_ASSERTIONS, STEXT ) \ + exit(-1); \ + } + + #define LOG_ASSERT2( BCONDITION, SMETHODE, STEXT ) \ + if ( ( BCONDITION ) == sal_True ) \ + { \ + ::rtl::OStringBuffer _sAssertBuffer( 256 ); \ + _sAssertBuffer.append( "ASSERT:\n\t" ); \ + _sAssertBuffer.append( SMETHOD ); \ + _sAssertBuffer.append( "\n\t\"" ); \ + _sAssertBuffer.append( STEXT ); \ + _sAssertBuffer.append( "\"\n" ); \ + WRITE_LOGFILE( LOGFILE_ASSERTIONS, _sAssertBuffer.makeStringAndClear() ) \ + exit(-1); \ + } + + #endif + + /*_____________________________________________________________________________________________________________ + LOG_ASSERT ( BCONDITION, STEXT ) + LOG_ASSERT2( BCONDITION, SMETHOD, STEXT ) + + Forward assertions to messagebox. (We use OSL_ENSURE to do this.) + Set LOGTYPE to LOGTYPE_MESSAGEBOX to do this. + BCONDITION is inserted in "(...)" because user can call this macro with an complex expression! + _____________________________________________________________________________________________________________*/ + #if LOGTYPE==LOGTYPE_MESSAGEBOX + + #define LOG_ASSERT( BCONDITION, STEXT ) \ + OSL_ENSURE( ( BCONDITION ), STEXT ); + + #define LOG_ASSERT2( BCONDITION, SMETHOD, STEXT ) \ + { \ + ::rtl::OStringBuffer _sAssertBuffer( 256 ); \ + _sAssertBuffer.append( "ASSERT:\n\t" ); \ + _sAssertBuffer.append( SMETHOD ); \ + _sAssertBuffer.append( "\n\t\"" ); \ + _sAssertBuffer.append( STEXT ); \ + _sAssertBuffer.append( "\"\n" ); \ + OSL_ENSURE( !( BCONDITION ), _sAssertBuffer.makeStringAndClear() ); \ + } + + #endif + + /*_____________________________________________________________________________________________________________ + LOG_ERROR( SMETHOD, STEXT ) + + Show an error by using current set output mode by define LOGTYPE! + _____________________________________________________________________________________________________________*/ + + #define LOG_ERROR( SMETHOD, STEXT ) \ + LOG_ASSERT2( sal_True, SMETHOD, STEXT ) + +#else + + // If right testmode is'nt set - implements these macros empty! + #undef LOGFILE_ASSERTIONS + #define LOG_ASSERT( BCONDITION, STEXT ) + #define LOG_ASSERT2( BCONDITION, SMETHOD, STEXT ) + #define LOG_ERROR( SMETHOD, STEXT ) + +#endif // ENABLE_ASSERTIONS + +//_________________________________________________________________________________________________________________ +#if defined( ENABLE_WARNINGS ) + + /*_____________________________________________________________________________________________________________ + LOGFILE_WARNINGS + + For follow macros we need a special log file. If user forget to specify anyone, we must do it for him! + _____________________________________________________________________________________________________________*/ + + #ifndef LOGFILE_WARNINGS + #define LOGFILE_WARNINGS "_framework_warnings.log" + #endif + + /*_____________________________________________________________________________________________________________ + LOG_EXCEPTION( SMETHOD, SOWNMESSAGE, SEXCEPTIONMESSAGE ) + + Show some exception info by using current set output mode by define LOGTYPE! + We use a seperated scope {} do protect us against multiple variable definitions. + _____________________________________________________________________________________________________________*/ + + #define LOG_EXCEPTION( SMETHOD, SOWNMESSAGE, SEXCEPTIONMESSAGE ) \ + { \ + ::rtl::OStringBuffer _sAssertBuffer2( 256 ); \ + _sAssertBuffer2.append( SOWNMESSAGE ); \ + _sAssertBuffer2.append( "\n" ); \ + _sAssertBuffer2.append( U2B(SEXCEPTIONMESSAGE) ); \ + LOG_ERROR( SMETHOD, _sAssertBuffer2.makeStringAndClear() ) \ + } + + /*_____________________________________________________________________________________________________________ + LOG_WARNING( SMETHOD, STEXT ) + + Use it to show/log warnings for programmer for follow reasons: + - algorithm errors + - undefined states + - unknown errors from other modules ... + _____________________________________________________________________________________________________________*/ + + #define LOG_WARNING( SMETHOD, STEXT ) \ + LOG_ERROR( SMETHOD, STEXT ) + +#else + + // If right testmode is'nt set - implements these macros empty! + #undef LOGFILE_WARNINGS + #define LOG_EXCEPTION( SMETHOD, SOWNMESSAGE, SEXCEPTIONMESSAGE ) + #define LOG_WARNING( SMETHOD, STEXT ) + +#endif // ENABLE_WARNINGS + +#endif // #ifndef __FRAMEWORK_MACROS_DEBUG_ASSERTION_HXX_ diff --git a/framework/inc/macros/debug/event.hxx b/framework/inc/macros/debug/event.hxx new file mode 100644 index 000000000000..794057100766 --- /dev/null +++ b/framework/inc/macros/debug/event.hxx @@ -0,0 +1,132 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef __FRAMEWORK_MACROS_DEBUG_EVENT_HXX_ +#define __FRAMEWORK_MACROS_DEBUG_EVENT_HXX_ + +//************************************************************************************************************* +// special macros for event handling +//************************************************************************************************************* + +#ifdef ENABLE_EVENTDEBUG + + //_________________________________________________________________________________________________________________ + // includes + //_________________________________________________________________________________________________________________ + + #ifndef _RTL_STRBUF_HXX_ + #include <rtl/strbuf.hxx> + #endif + + /*_____________________________________________________________________________________________________________ + LOGFILE_EVENTDEBUG + + For follow macros we need a special log file. If user forget to specify anyone, we must do it for him! + _____________________________________________________________________________________________________________*/ + + #ifndef LOGFILE_EVENTDEBUG + #define LOGFILE_EVENTDEBUG \ + "events.log" + #endif + + /*_____________________________________________________________________________________________________________ + LOG_FRAMEACTIONEVENT( SFRAMETYPE, SFRAMENAME, AFRAMEACTION ) + + Use this macro to print debug informations about sending of events to listener for controling right order. + ( Use new scope in macro to declare sBuffer more then on time in same "parentscope"! ) + _____________________________________________________________________________________________________________*/ + + #define LOG_FRAMEACTIONEVENT( SFRAMETYPE, SFRAMENAME, AFRAMEACTION ) \ + { \ + ::rtl::OStringBuffer sBuffer(1024); \ + sBuffer.append( "[ " ); \ + sBuffer.append( SFRAMETYPE ); \ + sBuffer.append( " ] \"" ); \ + sBuffer.append( U2B( SFRAMENAME ) ); \ + sBuffer.append( "\" send event \"" ); \ + switch( AFRAMEACTION ) \ + { \ + case ::com::sun::star::frame::FrameAction_COMPONENT_ATTACHED : sBuffer.append("COMPONENT ATTACHED" ); \ + break; \ + case ::com::sun::star::frame::FrameAction_COMPONENT_DETACHING : sBuffer.append("COMPONENT DETACHING" ); \ + break; \ + case ::com::sun::star::frame::FrameAction_COMPONENT_REATTACHED : sBuffer.append("COMPONENT REATTACHED" ); \ + break; \ + case ::com::sun::star::frame::FrameAction_FRAME_ACTIVATED : sBuffer.append("FRAME ACTIVATED" ); \ + break; \ + case ::com::sun::star::frame::FrameAction_FRAME_DEACTIVATING : sBuffer.append("FRAME DEACTIVATING" ); \ + break; \ + case ::com::sun::star::frame::FrameAction_CONTEXT_CHANGED : sBuffer.append("CONTEXT CHANGED" ); \ + break; \ + case ::com::sun::star::frame::FrameAction_FRAME_UI_ACTIVATED : sBuffer.append("FRAME UI ACTIVATED" ); \ + break; \ + case ::com::sun::star::frame::FrameAction_FRAME_UI_DEACTIVATING : sBuffer.append("FRAME UI DEACTIVATING" ); \ + break; \ + case ::com::sun::star::frame::FrameAction_MAKE_FIXED_SIZE : sBuffer.append("MAKE_FIXED_SIZE" ); \ + break; \ + default: sBuffer.append("... ERROR: invalid FrameAction detected!" ); \ + break; \ + } \ + sBuffer.append( " ... event to listener.\n\n" ); \ + WRITE_LOGFILE( LOGFILE_EVENTDEBUG, sBuffer.makeStringAndClear() ) \ + } + + /*_____________________________________________________________________________________________________________ + LOG_FRAMEACTIONEVENT( SFRAMETYPE, SFRAMENAME ) + + These macro log information about sending of dispose events to listener. + ( Use new scope in macro to declare sBuffer more then on time in same "parentscope"! ) + _____________________________________________________________________________________________________________*/ + + #define LOG_DISPOSEEVENT( SFRAMETYPE, SFRAMENAME ) \ + { \ + ::rtl::OStringBuffer sBuffer(1024); \ + sBuffer.append( "[ " ); \ + sBuffer.append( SFRAMETYPE ); \ + sBuffer.append( " ] \"" ); \ + sBuffer.append( U2B( SFRAMENAME ) ); \ + sBuffer.append( "\" send dispose event to listener.\n\n"); \ + WRITE_LOGFILE( LOGFILE_EVENTDEBUG, sBuffer.makeStringAndClear() ) \ + } + +#else // #ifdef ENABLE_EVENTDEBUG + + /*_____________________________________________________________________________________________________________ + If right testmode is'nt set - implements these macros empty! + _____________________________________________________________________________________________________________*/ + + #undef LOGFILE_EVENTDEBUG + #define LOG_FRAMEACTIONEVENT( SFRAMETYPE, SFRAMENAME, AFRAMEACTION ) + #define LOG_DISPOSEEVENT( SFRAMETYPE, SFRAMENAME ) + +#endif // #ifdef ENABLE_EVENTDEBUG + +//***************************************************************************************************************** +// end of file +//***************************************************************************************************************** + +#endif // #ifndef __FRAMEWORK_MACROS_DEBUG_EVENT_HXX_ diff --git a/framework/inc/macros/debug/filterdbg.hxx b/framework/inc/macros/debug/filterdbg.hxx new file mode 100644 index 000000000000..ab408f1b50e5 --- /dev/null +++ b/framework/inc/macros/debug/filterdbg.hxx @@ -0,0 +1,130 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef __FRAMEWORK_MACROS_DEBUG_FILTERDBG_HXX_ +#define __FRAMEWORK_MACROS_DEBUG_FILTERDBG_HXX_ + +//************************************************************************************************************* +// special macros for time measures +// 1) LOGFILE_FILTERDBG used it to define log file for this operations (default will be set automaticly) +// 4) LOG_FILTERDBG write debug info to log file +//************************************************************************************************************* + +#ifdef ENABLE_FILTERDBG + + //_________________________________________________________________________________________________________________ + // includes + //_________________________________________________________________________________________________________________ + + #ifndef _RTL_STRBUF_HXX_ + #include <rtl/strbuf.hxx> + #endif + + /*_____________________________________________________________________________________________________________ + LOGFILE_FILTERDBG + + For follow macros we need a special log file. If user forget to specify anyone, we must do it for him! + _____________________________________________________________________________________________________________*/ + + #ifndef LOGFILE_FILTERDBG + #define LOGFILE_FILTERDBG "filterdbg.log" + #endif + + /*_____________________________________________________________________________________________________________ + LOG_FILTERDBG( SOPERATION, SMESSAGE ) + + Write special debug info to the log file. + _____________________________________________________________________________________________________________*/ + + #define LOG_FILTERDBG( SOPERATION, SMESSAGE ) \ + { \ + ::rtl::OStringBuffer _sBuffer( 256 ); \ + _sBuffer.append( SOPERATION ); \ + _sBuffer.append( "\t" ); \ + _sBuffer.append( SMESSAGE ); \ + _sBuffer.append( "\n" ); \ + WRITE_LOGFILE( LOGFILE_FILTERDBG, _sBuffer.makeStringAndClear().getStr() ) \ + } + + /*_____________________________________________________________________________________________________________ + LOG_FILTERDBG_1_PARAM( SOPERATION, SPARAM, SMESSAGE ) + + Write special debug info into the log file and mark SNAME as special parameter before SMESSAGE is printed. + _____________________________________________________________________________________________________________*/ + + #define LOG_FILTERDBG_1_PARAM( SOPERATION, SPARAM, SMESSAGE ) \ + { \ + ::rtl::OStringBuffer _sBuffer( 256 ); \ + _sBuffer.append( SOPERATION ); \ + _sBuffer.append( "\t\"" ); \ + _sBuffer.append( SPARAM ); \ + _sBuffer.append( "\" " ); \ + _sBuffer.append( SMESSAGE ); \ + _sBuffer.append( "\n" ); \ + WRITE_LOGFILE( LOGFILE_FILTERDBG, _sBuffer.makeStringAndClear().getStr() ) \ + } + + /*_____________________________________________________________________________________________________________ + LOG_COND_FILTERDBG( CONDITION, SOPERATION, SMESSAGE ) + + Write special debug info to the log file, if given condition returns true. + _____________________________________________________________________________________________________________*/ + + #define LOG_COND_FILTERDBG( CONDITION, SOPERATION, SMESSAGE ) \ + if (CONDITION) \ + LOG_FILTERDBG( SOPERATION, SMESSAGE ) + + /*_____________________________________________________________________________________________________________ + LOG_COND_FILTERDBG_1_PARAM( CONDITION, SOPERATION, SPARAM, SMESSAGE ) + + Write special debug info into the log file and mark SNAME as special parameter before SMESSAGE is printed. + But it will be done only, if CONDITION returns true. + _____________________________________________________________________________________________________________*/ + + #define LOG_COND_FILTERDBG_1_PARAM( CONDITION, SOPERATION, SPARAM, SMESSAGE ) \ + if (CONDITION) \ + LOG_FILTERDBG_1_PARAM( SOPERATION, SPARAM, SMESSAGE ) + +#else // #ifdef ENABLE_FILTERDBG + + /*_____________________________________________________________________________________________________________ + If right testmode is'nt set - implements these macros empty! + _____________________________________________________________________________________________________________*/ + + #undef LOGFILE_FILTERDBG + #define LOG_FILTERDBG( SOPERATION, SMESSAGE ) + #define LOG_COND_FILTERDBG( CONDITION, SOPERATION, SMESSAGE ) + #define LOG_FILTERDBG_1_PARAM( SOPERATION, SPARAM, SMESSAGE ) + #define LOG_COND_FILTERDBG_1_PARAM( CONDITION, SOPERATION, SPARAM, SMESSAGE ) + +#endif // #ifdef ENABLE_FILTERDBG + +//***************************************************************************************************************** +// end of file +//***************************************************************************************************************** + +#endif // #ifndef __FRAMEWORK_MACROS_DEBUG_FILTERDBG_HXX_ diff --git a/framework/inc/macros/debug/logmechanism.hxx b/framework/inc/macros/debug/logmechanism.hxx new file mode 100644 index 000000000000..a2f6e4ec6f48 --- /dev/null +++ b/framework/inc/macros/debug/logmechanism.hxx @@ -0,0 +1,102 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef __FRAMEWORK_MACROS_DEBUG_LOGMECHANISM_HXX_ +#define __FRAMEWORK_MACROS_DEBUG_LOGMECHANISM_HXX_ + +//***************************************************************************************************************** +// generic macros for logging +//***************************************************************************************************************** + +#ifdef ENABLE_LOGMECHANISM + + //_____________________________________________________________________________________________________________ + // includes + //_____________________________________________________________________________________________________________ + + #ifndef _RTL_STRING_HXX_ + #include <rtl/string.hxx> + #endif + + #include <stdio.h> + + /*_____________________________________________________________________________________________________________ + WRITE_LOGFILE( SFILENAME, STEXT ) + + Log any information in file. We append any information at file and don't clear it anymore. + ( Use new scope in macro to declare pFile more then on time in same "parentscope"! + Don't control pFile before access! What will you doing if its not valid? Log an error ... + An error and an error is an error ... ) + + Attention: You must use "%s" and STEXT as parameter ... because otherwise encoded strings (they include e.g. %...) + are handled wrong. + _____________________________________________________________________________________________________________*/ + + #define WRITE_LOGFILE( SFILENAME, STEXT ) \ + { \ + ::rtl::OString _swriteLogfileFileName ( SFILENAME ); \ + ::rtl::OString _swriteLogfileText ( STEXT ); \ + FILE* pFile = fopen( _swriteLogfileFileName.getStr(), "a" ); \ + fprintf( pFile, "%s", _swriteLogfileText.getStr() ); \ + fclose ( pFile ); \ + } + + /*_____________________________________________________________________________________________________________ + LOGTYPE + + For other debug macros we need information about the output mode. If user forget to set this information we + do it for him. Valid values are: LOGTYPE_FILECONTINUE + LOGTYPE_FILEEXIT + LOGTYPE_MESSAGEBOX + The normal case is LOGTYPE_MESSAGEBOX to show assertions in normal manner! + _____________________________________________________________________________________________________________*/ + + #define LOGTYPE_MESSAGEBOX 1 + #define LOGTYPE_FILECONTINUE 2 + #define LOGTYPE_FILEEXIT 3 + + #ifndef LOGTYPE + #define LOGTYPE \ + LOGTYPE_MESSAGEBOX + #endif + +#else // #ifdef ENABLE_LOGMECHANISM + + /*_____________________________________________________________________________________________________________ + If right testmode is'nt set - implements these macro empty! + _____________________________________________________________________________________________________________*/ + + #define WRITE_LOGFILE( SFILENAME, STEXT ) + #undef LOGTYPE + +#endif // #ifdef ENABLE_LOGMECHANISM + +//***************************************************************************************************************** +// end of file +//***************************************************************************************************************** + +#endif // #ifndef __FRAMEWORK_MACROS_DEBUG_LOGMECHANISM_HXX_ diff --git a/framework/inc/macros/debug/memorymeasure.hxx b/framework/inc/macros/debug/memorymeasure.hxx new file mode 100644 index 000000000000..06bd9305adeb --- /dev/null +++ b/framework/inc/macros/debug/memorymeasure.hxx @@ -0,0 +1,223 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef __FRAMEWORK_MACROS_DEBUG_MEMORYMEASURE_HXX_ +#define __FRAMEWORK_MACROS_DEBUG_MEMORYMEASURE_HXX_ + +//************************************************************************************************************* +// special macros for time measures +// 1) LOGFILE_MEMORYMEASURE used it to define log file for this operations (default will be set automaticly) +// 2) MAKE_MEMORY_SNAPSHOT make snapshot of currently set memory informations of OS +// 3) LOG_MEMORYMEASURE write measured time to logfile +//************************************************************************************************************* + +#ifdef ENABLE_MEMORYMEASURE + + #if !defined( WIN ) && !defined( WNT ) + #error "Macros to measure memory access not available under platforms different from windows!" + #endif + + //_________________________________________________________________________________________________________________ + // includes + //_________________________________________________________________________________________________________________ + + #ifndef _RTL_STRBUF_HXX_ + #include <rtl/strbuf.hxx> + #endif + + #ifndef __SGI_STL_VECTOR + #include <vector> + #endif + + /*_____________________________________________________________________________________________________________ + LOGFILE_MEMORYMEASURE + + For follow macros we need a special log file. If user forget to specify anyone, we must do it for him! + _____________________________________________________________________________________________________________*/ + + #ifndef LOGFILE_MEMORYMEASURE + #define LOGFILE_MEMORYMEASURE "memorymeasure.log" + #endif + + /*_____________________________________________________________________________________________________________ + class MemoryMeasure + + We use this baseclass to collect all snapshots in one object and analyze this information at one point. + Macros of this file are used to enable using of this class by special compile-parameter only! + _____________________________________________________________________________________________________________*/ + + class _DBGMemoryMeasure + { + //--------------------------------------------------------------------------------------------------------- + private: + struct _MemoryInfo + { + MEMORYSTATUS aStatus ; + ::rtl::OString sComment ; + }; + + //--------------------------------------------------------------------------------------------------------- + public: + //_____________________________________________________________________________________________________ + inline _DBGMemoryMeasure() + { + } + + //_____________________________________________________________________________________________________ + // clear used container! + inline ~_DBGMemoryMeasure() + { + ::std::vector< _MemoryInfo >().swap( m_lSnapshots ); + } + + //_____________________________________________________________________________________________________ + inline void makeSnapshot( const ::rtl::OString& sComment ) + { + _MemoryInfo aInfo; + aInfo.sComment = sComment; + GlobalMemoryStatus ( &(aInfo.aStatus) ); + m_lSnapshots.push_back( aInfo ); + } + + //_____________________________________________________________________________________________________ + inline ::rtl::OString getLog() + { + ::rtl::OStringBuffer sBuffer( 10000 ); + + if( !m_lSnapshots.empty() ) + { + // Write informations to return buffer + ::std::vector< _MemoryInfo >::const_iterator pItem1; + ::std::vector< _MemoryInfo >::const_iterator pItem2; + + pItem1 = m_lSnapshots.begin(); + pItem2 = pItem1; + ++pItem2; + + while( pItem1!=m_lSnapshots.end() ) + { + sBuffer.append( "snap [ " ); + sBuffer.append( pItem1->sComment ); + sBuffer.append( " ]\n\tavail phys\t=\t" ); + sBuffer.append( (sal_Int32)pItem1->aStatus.dwAvailPhys ); + sBuffer.append( "\n\tavail page\t=\t" ); + sBuffer.append( (sal_Int32)pItem1->aStatus.dwAvailPageFile ); + sBuffer.append( "\n\tavail virt\t=\t" ); + sBuffer.append( (sal_Int32)pItem1->aStatus.dwAvailVirtual ); + sBuffer.append( "\n\tdifference\t=\t[ " ); + + if( pItem1 == m_lSnapshots.begin() ) + { + sBuffer.append( (sal_Int32)pItem1->aStatus.dwAvailPhys ); + sBuffer.append( ", " ); + sBuffer.append( (sal_Int32)pItem1->aStatus.dwAvailPageFile ); + sBuffer.append( ", " ); + sBuffer.append( (sal_Int32)pItem1->aStatus.dwAvailVirtual ); + sBuffer.append( " ]\n\n" ); + } + else if( pItem2 != m_lSnapshots.end() ) + { + sBuffer.append( (sal_Int32)(pItem2->aStatus.dwAvailPhys - pItem1->aStatus.dwAvailPhys ) ); + sBuffer.append( ", " ); + sBuffer.append( (sal_Int32)(pItem2->aStatus.dwAvailPageFile - pItem1->aStatus.dwAvailPageFile ) ); + sBuffer.append( ", " ); + sBuffer.append( (sal_Int32)(pItem2->aStatus.dwAvailVirtual - pItem1->aStatus.dwAvailVirtual ) ); + sBuffer.append( " ]\n\n" ); + } + else + { + sBuffer.append( "0, 0, 0 ]\n\n" ); + } + if( pItem1!=m_lSnapshots.end() ) ++pItem1; + if( pItem2!=m_lSnapshots.end() ) ++pItem2; + } + // clear current list ... make it empty for further snapshots! + ::std::vector< _MemoryInfo >().swap( m_lSnapshots ); + } + + return sBuffer.makeStringAndClear(); + } + + //--------------------------------------------------------------------------------------------------------- + private: + ::std::vector< _MemoryInfo > m_lSnapshots; + }; + + /*_____________________________________________________________________________________________________________ + START_MEMORY_MEASURE + + Create new object to measure memory access. + _____________________________________________________________________________________________________________*/ + + #define START_MEMORYMEASURE( AOBJECT ) \ + _DBGMemoryMeasure AOBJECT; + + /*_____________________________________________________________________________________________________________ + MAKE_MEMORY_SNAPSHOT + + Make snapshot of currently set memory informations of OS. + see _DBGMemoryMeasure for further informations + _____________________________________________________________________________________________________________*/ + + #define MAKE_MEMORY_SNAPSHOT( AOBJECT, SCOMMENT ) \ + AOBJECT.makeSnapshot( SCOMMENT ); + + /*_____________________________________________________________________________________________________________ + LOG_MEMORYMEASURE( SOPERATION, SCOMMENT, AOBJECT ) + + Write measured values to logfile. + _____________________________________________________________________________________________________________*/ + + #define LOG_MEMORYMEASURE( SOPERATION, SCOMMENT, AOBJECT ) \ + { \ + ::rtl::OStringBuffer _sBuffer( 256 ); \ + _sBuffer.append( SOPERATION ); \ + _sBuffer.append( "\n" ); \ + _sBuffer.append( SCOMMENT ); \ + _sBuffer.append( "\n\n" ); \ + _sBuffer.append( AOBJECT.getLog() ); \ + WRITE_LOGFILE( LOGFILE_MEMORYMEASURE, _sBuffer.makeStringAndClear() ) \ + } + +#else // #ifdef ENABLE_MEMORYMEASURE + + /*_____________________________________________________________________________________________________________ + If right testmode is'nt set - implements these macros empty! + _____________________________________________________________________________________________________________*/ + + #undef LOGFILE_MEMORYMEASURE + #define START_MEMORYMEASURE( AOBJECT ) + #define MAKE_MEMORY_SNAPSHOT( AOBJECT, SCOMMENT ) + #define LOG_MEMORYMEASURE( SOPERATION, SCOMMENT, AOBJECT ) + +#endif // #ifdef ENABLE_MEMORYMEASURE + +//***************************************************************************************************************** +// end of file +//***************************************************************************************************************** + +#endif // #ifndef __FRAMEWORK_MACROS_DEBUG_MEMORYMEASURE_HXX_ diff --git a/framework/inc/macros/debug/mutex.hxx b/framework/inc/macros/debug/mutex.hxx new file mode 100644 index 000000000000..85aec5acd9cd --- /dev/null +++ b/framework/inc/macros/debug/mutex.hxx @@ -0,0 +1,117 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef __FRAMEWORK_MACROS_DEBUG_MUTEX_HXX_ +#define __FRAMEWORK_MACROS_DEBUG_MUTEX_HXX_ + +//***************************************************************************************************************** +// special macros for mutex handling +//***************************************************************************************************************** + +#ifdef ENABLE_MUTEXDEBUG + + //_____________________________________________________________________________________________________________ + // includes + //_____________________________________________________________________________________________________________ + + #ifndef _RTL_STRBUF_HXX_ + #include <rtl/strbuf.hxx> + #endif + + /*_____________________________________________________________________________________________________________ + LOGFILE_MUTEX + + For follow macros we need a special log file. If user forget to specify anyone, we must do it for him! + _____________________________________________________________________________________________________________*/ + + #ifndef LOGFILE_MUTEX + #define LOGFILE_MUTEX "mutex.log" + #endif + + /*_____________________________________________________________________________________________________________ + LOG_LOCKTYPE( _EFALLBACK, _ECURRENT ) + + Write informations about current set lock type for whole framework project to special file. + _____________________________________________________________________________________________________________*/ + + #define LOG_LOCKTYPE( _EFALLBACK, _ECURRENT ) \ + /* new scope to prevent us against multiple definitions of variables ... */ \ + { \ + ::rtl::OStringBuffer _sBuffer( 256 ); \ + _sBuffer.append( "Set framework lock type to fallback: \"" ); \ + switch( _EFALLBACK ) \ + { \ + case E_NOTHING : _sBuffer.append( "E_NOTHING" ); \ + break; \ + case E_OWNMUTEX : _sBuffer.append( "E_OWNMUTEX" ); \ + break; \ + case E_SOLARMUTEX : _sBuffer.append( "E_SOLARMUTEX" ); \ + break; \ + case E_FAIRRWLOCK : _sBuffer.append( "E_FAIRRWLOCK" ); \ + break; \ + } \ + _sBuffer.append( "\"\n" ); \ + if( _EFALLBACK != _ECURRENT ) \ + { \ + _sBuffer.append( "... environment overwrite framework lock type with: \"" ); \ + switch( _ECURRENT ) \ + { \ + case E_NOTHING : _sBuffer.append( "E_NOTHING" ); \ + break; \ + case E_OWNMUTEX : _sBuffer.append( "E_OWNMUTEX" ); \ + break; \ + case E_SOLARMUTEX : _sBuffer.append( "E_SOLARMUTEX" ); \ + break; \ + case E_FAIRRWLOCK : _sBuffer.append( "E_FAIRRWLOCK" ); \ + break; \ + } \ + _sBuffer.append( "\"\n" ); \ + } \ + else \ + { \ + _sBuffer.append( "... use fallback, because user don't set another value!\n" ); \ + } \ + WRITE_LOGFILE( LOGFILE_MUTEX, _sBuffer.makeStringAndClear() ) \ + } + +#else // #ifdef ENABLE_MUTEXDEBUG + + /*_____________________________________________________________________________________________________________ + If right testmode is'nt set - implements these macro with normal functionality! + We need the guard but not the log mechanism. + _____________________________________________________________________________________________________________*/ + + #undef LOGFILE_MUTEX + #define LOG_LOCKTYPE( _EFALLBACK, _ECURRENT ) + +#endif // #ifdef ENABLE_MUTEXDEBUG + +//***************************************************************************************************************** +// end of file +//***************************************************************************************************************** + +#endif // #ifndef __FRAMEWORK_MACROS_DEBUG_MUTEX_HXX_ diff --git a/framework/inc/macros/debug/plugin.hxx b/framework/inc/macros/debug/plugin.hxx new file mode 100644 index 000000000000..6ef4af316877 --- /dev/null +++ b/framework/inc/macros/debug/plugin.hxx @@ -0,0 +1,202 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef __FRAMEWORK_MACROS_DEBUG_PLUGIN_HXX_ +#define __FRAMEWORK_MACROS_DEBUG_PLUGIN_HXX_ + +//***************************************************************************************************************** +// special macros to debug asynchronous methods of plugin frame +//***************************************************************************************************************** + +#ifdef ENABLE_PLUGINDEBUG + + //_____________________________________________________________________________________________________________ + // includes + //_____________________________________________________________________________________________________________ + + #ifndef _RTL_STRBUF_HXX_ + #include <rtl/strbuf.hxx> + #endif + + #ifndef _RTL_STRING_HXX_ + #include <rtl/string.hxx> + #endif + + /*_____________________________________________________________________________________________________________ + LOGFILE_PLUGIN + + For follow macros we need a special log file. If user forget to specify anyone, we must do it for him! + _____________________________________________________________________________________________________________*/ + + #ifndef LOGFILE_PLUGIN + #define LOGFILE_PLUGIN \ + "plugin.log" + #endif + + /*_____________________________________________________________________________________________________________ + LOG_URLSEND( SFRAMENAME, SSENDMODE, SINTERNALURL, SEXTERNALURL ) + + Our plugin forward special url's to plugin dll, browser and webserver. + We convert internal url's to an external notation. + With this macro you can log some parameter of this operation. + _____________________________________________________________________________________________________________*/ + + #define LOG_URLSEND( SFRAMENAME, SSENDMODE, SINTERNALURL, SEXTERNALURL ) \ + /* Use new scope to declare local private variables! */ \ + { \ + ::rtl::OStringBuffer sBuffer(1024); \ + sBuffer.append( "PlugInFrame [ \"" ); \ + sBuffer.append( SFRAMENAME ); \ + sBuffer.append( "\" ] send " ); \ + sBuffer.append( SSENDMODE ); \ + sBuffer.append( "( internalURL=\"" ); \ + sBuffer.append( U2B( SINTERNALURL ) ); \ + sBuffer.append( "\", externalURL=\""); \ + sBuffer.append( U2B( SEXTERNALURL ) ); \ + sBuffer.append( "\" ) to browser.\n"); \ + WRITE_LOGFILE( LOGFILE_PLUGIN, sBuffer.makeStringAndClear() ) \ + } + + /*_____________________________________________________________________________________________________________ + LOG_URLRECEIVE( SFRAMENAME, SRECEIVEMODE, SEXTERNALURL, SINTERNALURL ) + + A plugin frame can get a url request in two different modes. + 1) newURL() + 2) newStream() + We convert external url's to an internal notation. + With this macro you can log some parameter of this operations. + _____________________________________________________________________________________________________________*/ + + #define LOG_URLRECEIVE( SFRAMENAME, SRECEIVEMODE, SEXTERNALURL, SINTERNALURL ) \ + /* Use new scope to declare local private variables! */ \ + { \ + ::rtl::OStringBuffer sBuffer(1024); \ + sBuffer.append( "PlugInFrame [ \"" ); \ + sBuffer.append( U2B( SFRAMENAME ) ); \ + sBuffer.append( "\" ] receive " ); \ + sBuffer.append( SRECEIVEMODE ); \ + sBuffer.append( "( externalURL=\"" ); \ + sBuffer.append( U2B( SEXTERNALURL ) ); \ + sBuffer.append( "\", internalURL=\"" ); \ + sBuffer.append( U2B( SINTERNALURL ) ); \ + sBuffer.append( "\" ) from browser.\n" ); \ + WRITE_LOGFILE( LOGFILE_PLUGIN, sBuffer.makeStringAndClear() ) \ + } + + /*_____________________________________________________________________________________________________________ + LOG_PARAMETER_NEWURL( SFRAMENAME, SMIMETYPE, SURL, AANY ) + + Log information about parameter of a newURL() at a plugin frame. + _____________________________________________________________________________________________________________*/ + + #define LOG_PARAMETER_NEWURL( SFRAMENAME, SMIMETYPE, SURL, sFILTER, AANY ) \ + /* Use new scope to declare local private variables! */ \ + { \ + ::rtl::OStringBuffer sBuffer(1024); \ + sBuffer.append( "PlugInFrame [ \"" ); \ + sBuffer.append( U2B( SFRAMENAME ) ); \ + sBuffer.append( "\" ] called with newURL( \"" ); \ + sBuffer.append( U2B( SMIMETYPE ) ); \ + sBuffer.append( "\", \"" ); \ + sBuffer.append( U2B( SURL ) ); \ + sBuffer.append( "\", \"" ); \ + sBuffer.append( U2B( SFILTER ) ); \ + sBuffer.append( "\", " ); \ + if( AANY.hasValue() == sal_True ) \ + { \ + sBuffer.append( "filled Any )" ); \ + } \ + else \ + { \ + sBuffer.append( "empty Any )" ); \ + } \ + sBuffer.append( "\n" ); \ + WRITE_LOGFILE( LOGFILE_PLUGIN, sBuffer.makeStringAndClear() ) \ + } + + /*_____________________________________________________________________________________________________________ + LOG_PARAMETER_NEWSTREAM( SFRAMENAME, SMIMETYPE, SURL, ASTREAM, AANY ) + + Log information about parameter of a newStream() at a plugin frame. + _____________________________________________________________________________________________________________*/ + + #define LOG_PARAMETER_NEWSTREAM( SFRAMENAME, SMIMETYPE, SURL, SFILTER, XSTREAM, AANY ) \ + /* Use new scope to declare local private variables! */ \ + { \ + ::rtl::OStringBuffer sBuffer(1024); \ + sBuffer.append( "PlugInFrame [ \"" ); \ + sBuffer.append( U2B( SFRAMENAME ) ); \ + sBuffer.append( "\" ] called with newStream( \""); \ + sBuffer.append( U2B( SMIMETYPE ) ); \ + sBuffer.append( "\", \"" ); \ + sBuffer.append( U2B( SURL ) ); \ + sBuffer.append( "\", \"" ); \ + sBuffer.append( U2B( SFILTER ) ); \ + sBuffer.append( "\", " ); \ + if( XSTREAM.is() == sal_True ) \ + { \ + sal_Int32 nBytes = XSTREAM->available(); \ + OString sInfo("Stream with "); \ + sInfo += OString::valueOf( (sal_Int32)nBytes ); \ + sInfo += " Bytes, "; \ + sBuffer.append( sInfo ); \ + } \ + else \ + { \ + sBuffer.append( "empty Stream, " ); \ + } \ + if( AANY.hasValue() == sal_True ) \ + { \ + sBuffer.append( "filled Any )" ); \ + } \ + else \ + { \ + sBuffer.append( "empty Any )" ); \ + } \ + sBuffer.append( "\n" ); \ + WRITE_LOGFILE( LOGFILE_PLUGIN, sBuffer.makeStringAndClear() ) \ + } + +#else // #ifdef ENABLE_PLUGINDEBUG + + /*_____________________________________________________________________________________________________________ + If right testmode is'nt set - implements these macro empty! + _____________________________________________________________________________________________________________*/ + + #undef LOGFILE_PLUGIN + #define LOG_URLSEND( SFRAMENAME, SSENDMODE, SINTERNALURL, SEXTERNALURL ) + #define LOG_URLRECEIVE( SFRAMENAME, SRECEIVEMODE, SEXTERNALURL, SINTERNALURL ) + #define LOG_PARAMETER_NEWURL( SFRAMENAME, SMIMETYPE, SURL, SFILTER, AANY ) + #define LOG_PARAMETER_NEWSTREAM( SFRAMENAME, SMIMETYPE, SURL, SFILTER, XSTREAM, AANY ) + +#endif // #ifdef ENABLE_PLUGINDEBUG + +//***************************************************************************************************************** +// end of file +//***************************************************************************************************************** + +#endif // #ifndef __FRAMEWORK_MACROS_DEBUG_PLUGIN_HXX_ diff --git a/framework/inc/macros/debug/registration.hxx b/framework/inc/macros/debug/registration.hxx new file mode 100644 index 000000000000..e8ea5a0bafe6 --- /dev/null +++ b/framework/inc/macros/debug/registration.hxx @@ -0,0 +1,100 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef __FRAMEWORK_MACROS_DEBUG_REGISTRATION_HXX_ +#define __FRAMEWORK_MACROS_DEBUG_REGISTRATION_HXX_ + +//***************************************************************************************************************** +// special macros for assertion handling +//***************************************************************************************************************** + +#ifdef ENABLE_REGISTRATIONDEBUG + + //_____________________________________________________________________________________________________________ + // includes + //_____________________________________________________________________________________________________________ + + #ifndef _RTL_STRBUF_HXX_ + #include <rtl/strbuf.hxx> + #endif + + /*_____________________________________________________________________________________________________________ + LOGFILE_ASSERTIONS + + For follow macros we need a special log file. If user forget to specify anyone, we must do it for him! + _____________________________________________________________________________________________________________*/ + + #ifndef LOGFILE_REGISTRATION + #define LOGFILE_REGISTRATION \ + "registration.log" + #endif + + /*_____________________________________________________________________________________________________________ + LOG_REGISTRATION_WRITEINFO( SINFOTEXT ) + + Write informations for component_writeInfo() in log file. + _____________________________________________________________________________________________________________*/ + + #define LOG_REGISTRATION_WRITEINFO( SINFOTEXT ) \ + { \ + ::rtl::OStringBuffer sOut( 1024 ); \ + sOut.append( "component_writeInfo():" ); \ + sOut.append( SINFOTEXT ); \ + WRITE_LOGFILE( LOGFILE_REGISTRATION, sOut.makeStringAndClear() ) \ + } + + /*_____________________________________________________________________________________________________________ + LOG_REGISTRATION_WRITEINFO( SINFOTEXT ) + + Write informations for component_getFactory() in log file. + _____________________________________________________________________________________________________________*/ + + #define LOG_REGISTRATION_GETFACTORY( SINFOTEXT ) \ + { \ + ::rtl::OStringBuffer sOut( 1024 ); \ + sOut.append( "component_getFactory():" ); \ + sOut.append( SINFOTEXT ); \ + WRITE_LOGFILE( LOGFILE_REGISTRATION, sOut.makeStringAndClear() ) \ + } + +#else // #ifdef ENABLE_REGISTRATIONDEBUG + + /*_____________________________________________________________________________________________________________ + If right testmode is'nt set - implements these macro empty! + _____________________________________________________________________________________________________________*/ + + #undef LOGFILE_REGISTRATION + #define LOG_REGISTRATION_WRITEINFO( SINFOTEXT ) + #define LOG_REGISTRATION_GETFACTORY( SINFOTEXT ) + +#endif // #ifdef ENABLE_REGISTRATIONDEBUG + +//***************************************************************************************************************** +// end of file +//***************************************************************************************************************** + +#endif // #ifndef __FRAMEWORK_MACROS_DEBUG_REGISTRATION_HXX_ diff --git a/framework/inc/macros/debug/targeting.hxx b/framework/inc/macros/debug/targeting.hxx new file mode 100644 index 000000000000..3f87b2fb7a30 --- /dev/null +++ b/framework/inc/macros/debug/targeting.hxx @@ -0,0 +1,252 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef __FRAMEWORK_MACROS_DEBUG_TARGETING_HXX_ +#define __FRAMEWORK_MACROS_DEBUG_TARGETING_HXX_ + +//***************************************************************************************************************** +// special macros for targeting of frames +//***************************************************************************************************************** + +#ifdef ENABLE_TARGETINGDEBUG + + //_____________________________________________________________________________________________________________ + // includes + //_____________________________________________________________________________________________________________ + + #ifndef _RTL_STRBUF_HXX_ + #include <rtl/strbuf.hxx> + #endif + + /*_____________________________________________________________________________________________________________ + LOGFILE_TARGETING + + For follow macros we need a special log file. If user forget to specify anyone, we must do it for him! + _____________________________________________________________________________________________________________*/ + + #ifndef LOGFILE_TARGETING + #define LOGFILE_TARGETSTEPS "targetsteps.log" + #define LOGFILE_TARGETPARAM "targetparam.log" + #endif + + /*_____________________________________________________________________________________________________________ + LOG_PARAMETER_FINDFRAME( SSERVICE, SFRAMENAME, STARGETNAME, NSEARCHFLAGS ) + + Log format for parameter e.g.: Desktop::findFrame( "frame1", 23 ) my name is "desktop" + Log format for steps e.g.: desktop-- + + With this macro you can log informations about search parameter of method "findFrame()" of an service. + Use it at beginning of search only! + _____________________________________________________________________________________________________________*/ + + #define LOG_PARAMETER_FINDFRAME( SSERVICE, SFRAMENAME, STARGETNAME, NSEARCHFLAGS ) \ + /* Use new scope to prevent code against multiple variable defines! */ \ + { \ + ::rtl::OStringBuffer sBufferParam(256); \ + ::rtl::OStringBuffer sBufferSteps(256); \ + sBufferParam.append( SSERVICE ); \ + sBufferParam.append( "::findFrame( \"" ); \ + sBufferParam.append( U2B( STARGETNAME ) ); \ + sBufferParam.append( "\", " ); \ + sBufferParam.append( ::rtl::OString::valueOf( sal_Int32( NSEARCHFLAGS ) ) ); \ + sBufferParam.append( " ) my name is \"" ); \ + sBufferParam.append( U2B( SFRAMENAME ) ); \ + sBufferParam.append( "\"\n" ); \ + sBufferSteps.append( U2B( SFRAMENAME ) ); \ + sBufferSteps.append( "--" ); \ + WRITE_LOGFILE( LOGFILE_TARGETPARAM, sBufferParam.makeStringAndClear() ) \ + WRITE_LOGFILE( LOGFILE_TARGETSTEPS, sBufferSteps.makeStringAndClear() ) \ + } + + /*_____________________________________________________________________________________________________________ + LOG_PARAMETER_QUERYDISPATCH( SSERVICE, SFRAMENAME, AURL, STARGETNAME, NSEARCHFLAGS ) + + With this macro you can log informations about search parameter of method "queryDispatch()" of an service. + Use it at beginning of search only! + _____________________________________________________________________________________________________________*/ + + #define LOG_PARAMETER_QUERYDISPATCH( SSERVICE, SFRAMENAME, AURL, STARGETNAME, NSEARCHFLAGS ) \ + /* Use new scope to prevent code against multiple variable defines! */ \ + { \ + ::rtl::OStringBuffer sBuffer(1024); \ + sBuffer.append( "[ " ); \ + sBuffer.append( U2B( SFRAMENAME ) ); \ + sBuffer.append( "] " ); \ + sBuffer.append( SSERVICE ); \ + sBuffer.append( "::queryDispatch( \"" ); \ + sBuffer.append( U2B( AURL.Complete ) ); \ + sBuffer.append( "\", \"" ); \ + sBuffer.append( U2B( STARGETNAME ) ); \ + sBuffer.append( "\", " ); \ + sBuffer.append( ::rtl::OString::valueOf( sal_Int32( NSEARCHFLAGS ) ) ); \ + sBuffer.append( " )\n" ); \ + WRITE_LOGFILE( LOGFILE_TARGETPARAM, sBuffer.makeStringAndClear() ) \ + } + + /*_____________________________________________________________________________________________________________ + LOG_PARAMETER_LOADCOMPONENTFROMURL( SSERVICE, SFRAMENAME, SURL, STARGETNAME, NSEARCHFLAGS, SEQPARAMETER ) + + With this macro you can log informations about search parameter of method "loadComponentFromURL()" of an service. + Use it at beginning of search only! + _____________________________________________________________________________________________________________*/ + + #define LOG_PARAMETER_LOADCOMPONENTFROMURL( SSERVICE, SFRAMENAME, SURL, STARGETNAME, NSEARCHFLAGS, SEQPARAMETER ) \ + /* Use new scope to prevent code against multiple variable defines! */ \ + { \ + ::rtl::OStringBuffer sBuffer(1024); \ + sBuffer.append( "[ " ); \ + sBuffer.append( U2B( SFRAMENAME ) ); \ + sBuffer.append( "] " ); \ + sBuffer.append( SSERVICE ); \ + sBuffer.append( "::loadComponentFromURL( \"" ); \ + sBuffer.append( U2B( SURL ) ); \ + sBuffer.append( "\", \"" ); \ + sBuffer.append( U2B( STARGETNAME ) ); \ + sBuffer.append( "\", " ); \ + sBuffer.append( ::rtl::OString::valueOf( sal_Int32( NSEARCHFLAGS ) ) ); \ + sBuffer.append( ", " ); \ + sal_Int32 nCount = SEQPARAMETER.getLength(); \ + for( sal_Int32 nParameter=0; nParameter<nCount; ++nParameter ) \ + { \ + sBuffer.append( U2B( SEQPARAMETER[nParameter].Name )); \ + if( nParameter<(nCount-1) ) \ + { \ + sBuffer.append( " | " ); \ + } \ + } \ + sBuffer.append( " )\n" ); \ + WRITE_LOGFILE( LOGFILE_TARGETPARAM, sBuffer.makeStringAndClear() ) \ + } + + /*_____________________________________________________________________________________________________________ + LOG_RESULT_FINDFRAME( SSERVICE, SFRAMENAME, XFRAME ) + + With this macro you can log informations about search result of "findFrame()". + Use it at the end of this method only! + _____________________________________________________________________________________________________________*/ + + #define LOG_RESULT_FINDFRAME( SSERVICE, SFRAMENAME, XFRAME ) \ + /* Use new scope to prevent code against multiple variable defines! */ \ + { \ + ::rtl::OStringBuffer sBufferParam(256); \ + ::rtl::OStringBuffer sBufferSteps(256); \ + sBufferParam.append( SSERVICE ); \ + sBufferParam.append( "::findFrame() at \"" ); \ + sBufferParam.append( U2B( SFRAMENAME ) ); \ + sBufferParam.append( "\" " ); \ + if( XFRAME.is() == sal_True ) \ + { \ + sBufferParam.append( "return with valid frame.\n" ); \ + sBufferSteps.append( "OK [" ); \ + sBufferSteps.append( U2B( XFRAME->getName() ) ); \ + sBufferSteps.append( "]\n" ); \ + } \ + else \ + { \ + sBufferParam.append( "return with NULL frame!\n"); \ + sBufferSteps.append( "??\n" ); \ + } \ + WRITE_LOGFILE( LOGFILE_TARGETPARAM, sBufferParam.makeStringAndClear() ) \ + WRITE_LOGFILE( LOGFILE_TARGETSTEPS, sBufferSteps.makeStringAndClear() ) \ + } + + /*_____________________________________________________________________________________________________________ + LOG_RESULT_QUERYDISPATCH( SSERVICE, SFRAMENAME, XDISPATCHER ) + + With this macro you can log informations about search result of "queryDispatch()". + Use it at the end of this method only! + _____________________________________________________________________________________________________________*/ + + #define LOG_RESULT_QUERYDISPATCH( SSERVICE, SFRAMENAME, XDISPATCHER ) \ + /* Use new scope to prevent code against multiple variable defines! */ \ + { \ + ::rtl::OStringBuffer sBuffer(1024); \ + sBuffer.append( "[ " ); \ + sBuffer.append( U2B( SFRAMENAME ) ); \ + sBuffer.append( "] " ); \ + sBuffer.append( SSERVICE ); \ + if( XDISPATCHER.is() == sal_True ) \ + { \ + sBuffer.append( "::queryDispatch() return with valid dispatcher." ); \ + } \ + else \ + { \ + sBuffer.append( "::queryDispatch() return with NULL dispatcher!" ); \ + } \ + sBuffer.append( "\n" ); \ + WRITE_LOGFILE( LOGFILE_TARGETPARAM, sBuffer.makeStringAndClear() ) \ + } + + /*_____________________________________________________________________________________________________________ + LOG_RESULT_LOADCOMPONENTFROMURL( SSERVICE, SFRAMENAME, XCOMPONENT ) + + With this macro you can log informations about search result of "loadComponentFromURL()". + Use it at the end of this method only! + _____________________________________________________________________________________________________________*/ + + #define LOG_RESULT_LOADCOMPONENTFROMURL( SSERVICE, SFRAMENAME, XCOMPONENT ) \ + /* Use new scope to prevent code against multiple variable defines! */ \ + { \ + ::rtl::OStringBuffer sBuffer(1024); \ + sBuffer.append( "[ " ); \ + sBuffer.append( U2B( SFRAMENAME ) ); \ + sBuffer.append( "] " ); \ + sBuffer.append( SSERVICE ); \ + if( XCOMPONENT.is() == sal_True ) \ + { \ + sBuffer.append( "::loadComponentFromURL() return with valid component." ); \ + } \ + else \ + { \ + sBuffer.append( "::loadComponentFromURL() return with NULL component!" ); \ + } \ + sBuffer.append( "\n" ); \ + WRITE_LOGFILE( LOGFILE_TARGETPARAM, sBuffer.makeStringAndClear() ) \ + } + +#else // #ifdef ENABLE_TARGETINGDEBUG + + /*_____________________________________________________________________________________________________________ + If right testmode is'nt set - implements these macro empty! + _____________________________________________________________________________________________________________*/ + + #undef LOGFILE_TARGETPARAM + #undef LOGFILE_TARGETSTEPS + #define LOG_PARAMETER_FINDFRAME( SSERVICE, SFRAMENAME, STARGETNAME, NSEARCHFLAGS ) + #define LOG_PARAMETER_QUERYDISPATCH( SSERVICE, SFRAMENAME, AURL, STARGETNAME, NSEARCHFLAGS ) + #define LOG_PARAMETER_LOADCOMPONENTFROMURL( SSERVICE, SFRAMENAME, SURL, STARGETNAME, NSEARCHFLAGS, SEQPARAMETER ) + #define LOG_RESULT_FINDFRAME( SSERVICE, SFRAMENAME, XFRAME ) + #define LOG_RESULT_QUERYDISPATCH( SSERVICE, SFRAMENAME, XDISPATCHER ) + #define LOG_RESULT_LOADCOMPONENTFROMURL( SSERVICE, SFRAMENAME, XCOMPONENT ) + +#endif // #ifdef ENABLE_TARGETINGDEBUG + +//***************************************************************************************************************** +// end of file +//***************************************************************************************************************** + +#endif // #ifndef __FRAMEWORK_MACROS_DEBUG_TARGETING_HXX_ diff --git a/framework/inc/macros/debug/timemeasure.hxx b/framework/inc/macros/debug/timemeasure.hxx new file mode 100644 index 000000000000..119c6f7b1eb1 --- /dev/null +++ b/framework/inc/macros/debug/timemeasure.hxx @@ -0,0 +1,140 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef __FRAMEWORK_MACROS_DEBUG_TIMEMEASURE_HXX_ +#define __FRAMEWORK_MACROS_DEBUG_TIMEMEASURE_HXX_ + +//************************************************************************************************************* +// special macros for time measures +// 1) LOGFILE_TIMEMEASURE used it to define log file for this operations (default will be set automaticly) +// 2) START_TIMEMEASURE start new measure by using given variable names +// 3) START_TIMEMEASURE stop current measure by using given variable names and return time +// 4) LOG_TIMEMEASURE write measured time to logfile +//************************************************************************************************************* + +#ifdef ENABLE_TIMEMEASURE + + //_________________________________________________________________________________________________________________ + // includes + //_________________________________________________________________________________________________________________ + + #ifndef _RTL_STRBUF_HXX_ + #include <rtl/strbuf.hxx> + #endif + + #ifndef _OSL_TIME_H_ + #include <osl/time.h> + #endif + + /*_____________________________________________________________________________________________________________ + LOGFILE_TIMEMEASURE + + For follow macros we need a special log file. If user forget to specify anyone, we must do it for him! + _____________________________________________________________________________________________________________*/ + + #ifndef LOGFILE_TIMEMEASURE + #define LOGFILE_TIMEMEASURE "timemeasure.log" + #endif + + /*_____________________________________________________________________________________________________________ + class TimeMeasure + + We need this inline class as global timer to make it possible measure times over different objects! + zB. Use it as baseclass to start timer at ctor (must be first called baseclass!!!) and stop it by calling stop method. + _____________________________________________________________________________________________________________*/ + + class DBGTimeMeasureBase + { + public: + inline DBGTimeMeasureBase() + { + m_nEnd = 0 ; + m_nStart = osl_getGlobalTimer(); + } + + inline sal_Int32 stopAndGet() + { + m_nEnd = osl_getGlobalTimer(); + return( m_nEnd-m_nStart ); + } + + private: + sal_Int32 m_nStart ; + sal_Int32 m_nEnd ; + }; + + /*_____________________________________________________________________________________________________________ + START_TIMEMEASURE( NSTART, NEND ) + STOP_TIMEMEASURE( NSTART, NEND, NTIME ) + + If you doesn't need a time measure above different classes ... you can try this macros! + They initialize your given members with start end end time ... You can calculate differenz by himself. + _____________________________________________________________________________________________________________*/ + + #define START_TIMEMEASURE( NSTART, NEND ) \ + sal_Int32 NSTART = 0; \ + sal_Int32 NEND = 0; \ + NSTART = osl_getGlobalTimer(); + + #define STOP_TIMEMEASURE( NSTART, NEND, NTIME ) \ + NEND = osl_getGlobalTimer(); \ + sal_Int32 NTIME = NEND-NSTART; + + /*_____________________________________________________________________________________________________________ + LOG_TIMEMEASURE( SOPERATION, NSTART ) + + Write measured time to logfile. + _____________________________________________________________________________________________________________*/ + + #define LOG_TIMEMEASURE( SOPERATION, NTIME ) \ + { \ + ::rtl::OStringBuffer _sBuffer( 256 ); \ + _sBuffer.append( SOPERATION ); \ + _sBuffer.append( "\t=\t" ); \ + _sBuffer.append( (sal_Int32)(NTIME) ); \ + _sBuffer.append( " ms\n" ); \ + WRITE_LOGFILE( LOGFILE_TIMEMEASURE, _sBuffer.makeStringAndClear().getStr() ) \ + } + +#else // #ifdef ENABLE_TIMEMEASURE + + /*_____________________________________________________________________________________________________________ + If right testmode is'nt set - implements these macros empty! + _____________________________________________________________________________________________________________*/ + + #undef LOGFILE_TIMEMEASURE + #define START_TIMEMEASURE( NSTART, NEND ) + #define STOP_TIMEMEASURE( NSTART, NEND, NTIME ) + #define LOG_TIMEMEASURE( SOPERATION, NTIME ) + +#endif // #ifdef ENABLE_TIMEMEASURE + +//***************************************************************************************************************** +// end of file +//***************************************************************************************************************** + +#endif // #ifndef __FRAMEWORK_MACROS_DEBUG_TIMEMEASURE_HXX_ |