From f737fbbf25a785fcdf5cad3b197a61b3c79a509c Mon Sep 17 00:00:00 2001 From: mbs Date: Fri, 19 Jan 2024 23:02:42 +0000 Subject: [PATCH] removed DEBUG macros --- src/LightApp/LightApp_Application.cxx | 23 +- src/LightApp/LightApp_DataModel.cxx | 18 +- src/LightApp/LightApp_Study.cxx | 30 +-- src/LightApp/MBDebug.h | 313 -------------------------- src/SalomeApp/MBDebug.h | 313 -------------------------- src/SalomeApp/SalomeApp_Study.cxx | 29 --- 6 files changed, 3 insertions(+), 723 deletions(-) delete mode 100644 src/LightApp/MBDebug.h delete mode 100644 src/SalomeApp/MBDebug.h diff --git a/src/LightApp/LightApp_Application.cxx b/src/LightApp/LightApp_Application.cxx index 7be6a4c19..d86509cc7 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2023 CEA, EDF, OPEN CASCADE +// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE // // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -224,15 +224,6 @@ #include -//--------------------------------------------------------- -#define USE_DEBUG -//#define MB_IGNORE_QT -//#define MB_FULL_DUMP -#define MBCLASSNAME "LightApp_Application" -#include "MBDebug.h" -// <-- insert includes for addtional debug headers here! -//--------------------------------------------------------- - #define ToolBarMarker 0 #define DockWidgetMarker 1 @@ -382,7 +373,6 @@ LightApp_Application::LightApp_Application() myPrefs( 0 ), myScreenHelper(new LightApp_FullScreenHelper()) { - DBG_FUN(); Q_INIT_RESOURCE( LightApp ); STD_TabDesktop* desk = new STD_TabDesktop(); @@ -495,7 +485,6 @@ LightApp_Application::LightApp_Application() */ LightApp_Application::~LightApp_Application() { - DBG_FUN(); savePreferences(); delete mySelMgr; delete myScreenHelper; @@ -505,7 +494,6 @@ LightApp_Application::~LightApp_Application() /*!Start application.*/ void LightApp_Application::start() { - DBG_FUN(); CAM_Application::start(); updateWindows(); @@ -523,7 +511,6 @@ void LightApp_Application::start() /*!Closeapplication.*/ void LightApp_Application::closeApplication() { - DBG_FUN(); #ifndef DISABLE_QTXWEBBROWSER QProcess::startDetached( "HelpBrowser", QStringList() << QString( "--remove=%1" ).arg( QApplication::instance()->applicationPid() ) ); @@ -2232,7 +2219,6 @@ void LightApp_Application::onStudyCreated( SUIT_Study* theStudy ) */ void LightApp_Application::onStudyOpened( SUIT_Study* theStudy ) { - DBG_FUN(); SUIT_DataObject* aRoot = 0; if ( theStudy && theStudy->root() ) { @@ -2264,10 +2250,8 @@ void LightApp_Application::onStudyOpened( SUIT_Study* theStudy ) /*!Protected SLOT. On study saved.*/ void LightApp_Application::onStudySaved( SUIT_Study* s ) { - DBG_FUN(); QtxMRUAction* mru = ::qobject_cast( action( MRUId ) ); if ( mru && s ) { - MSGEL("...adding [" << s->studyName().toStdString() << "] to MRU"); mru->insert( s->studyName() ); } @@ -2277,7 +2261,6 @@ void LightApp_Application::onStudySaved( SUIT_Study* s ) /*!Protected SLOT. On study closed.*/ void LightApp_Application::onStudyClosed( SUIT_Study* /*s*/ ) { - DBG_FUN(); /* disconnect( this, SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ), this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ) ); @@ -2306,7 +2289,6 @@ void LightApp_Application::onDesktopActivated() void LightApp_Application::studyOpened( SUIT_Study* s ) { - DBG_FUN(); CAM_Application::studyOpened( s ); updateWindows(); @@ -2315,7 +2297,6 @@ void LightApp_Application::studyOpened( SUIT_Study* s ) void LightApp_Application::studySaved( SUIT_Study* s ) { - DBG_FUN(); CAM_Application::studyOpened( s ); SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); if ( aResMgr && activeStudy() ) { @@ -4991,8 +4972,6 @@ void LightApp_Application::onWCDestroyed( QObject* ob ) void LightApp_Application::onMRUActivated( const QString& name ) { - DBG_FUN(); - ARG(name); SUIT_Session* s = SUIT_Session::session(); if ( s && s->activeApplication() == this ) onOpenDoc( name ); diff --git a/src/LightApp/LightApp_DataModel.cxx b/src/LightApp/LightApp_DataModel.cxx index e057671aa..3c2f50c54 100644 --- a/src/LightApp/LightApp_DataModel.cxx +++ b/src/LightApp/LightApp_DataModel.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2023 CEA, EDF, OPEN CASCADE +// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE // // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -34,14 +34,6 @@ #include #include -//--------------------------------------------------------- -#define USE_DEBUG -//#define MB_IGNORE_QT -//#define MB_FULL_DUMP -#define MBCLASSNAME "LightApp_DataModel" -#include "MBDebug.h" -// <-- insert includes for addtional debug headers here! -//--------------------------------------------------------- /*! Constructor @@ -49,7 +41,6 @@ LightApp_DataModel::LightApp_DataModel( CAM_Module* theModule ) : CAM_DataModel( theModule ) { - DBG_FUN(); myGroupId = 0; if( module() ) myGroupId = qHash( module()->name() ); @@ -60,7 +51,6 @@ LightApp_DataModel::LightApp_DataModel( CAM_Module* theModule ) */ LightApp_DataModel::~LightApp_DataModel() { - DBG_FUN(); } /*! @@ -68,7 +58,6 @@ LightApp_DataModel::~LightApp_DataModel() */ bool LightApp_DataModel::open( const QString&, CAM_Study*, QStringList ) { - DBG_FUN(); emit opened(); //TODO: is it really needed? to be removed maybe... return true; } @@ -78,7 +67,6 @@ bool LightApp_DataModel::open( const QString&, CAM_Study*, QStringList ) */ bool LightApp_DataModel::save( QStringList& ) { - DBG_FUN(); emit saved(); return true; } @@ -88,8 +76,6 @@ bool LightApp_DataModel::save( QStringList& ) */ bool LightApp_DataModel::saveAs( const QString&, CAM_Study*, QStringList&, bool isBackup/*=false*/ ) { - DBG_FUN(); - ARG(isBackup); if (!isBackup) emit saved(); return true; @@ -109,7 +95,6 @@ bool LightApp_DataModel::dumpPython( const QString&, CAM_Study*, bool, QStringLi */ bool LightApp_DataModel::close() { - DBG_FUN(); emit closed(); return true; } @@ -136,7 +121,6 @@ void LightApp_DataModel::updateWidgets() */ void LightApp_DataModel::update( LightApp_DataObject*, LightApp_Study* ) { - DBG_FUN(); // san: Previously modelRoot was casted to LightApp_ModuleObject*, // BUT this is incorrect: in full SALOME the model root has different type. // Hopefully LightApp_DataObject* is sufficient here. diff --git a/src/LightApp/LightApp_Study.cxx b/src/LightApp/LightApp_Study.cxx index b08fd5d3e..48bef22a8 100644 --- a/src/LightApp/LightApp_Study.cxx +++ b/src/LightApp/LightApp_Study.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2023 CEA, EDF, OPEN CASCADE +// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE // // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -36,14 +36,6 @@ #include -//--------------------------------------------------------- -#define USE_DEBUG -//#define MB_IGNORE_QT -//#define MB_FULL_DUMP -#define MBCLASSNAME "LightApp_Study" -#include "MBDebug.h" -// <-- insert includes for addtional debug headers here! -//--------------------------------------------------------- /*! Constructor. @@ -51,7 +43,6 @@ LightApp_Study::LightApp_Study( SUIT_Application* app ) : CAM_Study( app ) { - DBG_FUN(); // HDF persistence myDriver = new LightApp_HDFDriver(); //myDriver = new LightApp_Driver(); @@ -62,7 +53,6 @@ LightApp_Study::LightApp_Study( SUIT_Application* app ) */ LightApp_Study::~LightApp_Study() { - DBG_FUN(); delete myDriver; myDriver = 0; } @@ -71,8 +61,6 @@ LightApp_Study::~LightApp_Study() */ bool LightApp_Study::createDocument( const QString& theStr ) { - DBG_FUN(); - ARG(theStr); // create myRoot setRoot( new LightApp_RootObject( this ) ); @@ -88,8 +76,6 @@ bool LightApp_Study::createDocument( const QString& theStr ) */ bool LightApp_Study::openDocument( const QString& theFileName ) { - DBG_FUN(); - ARG(theFileName); myDriver->ClearDriverContents(); // create files for models from theFileName if( !openStudyData(theFileName, 0)) // 0 means persistence file @@ -119,8 +105,6 @@ bool LightApp_Study::openDocument( const QString& theFileName ) */ bool LightApp_Study::loadDocument( const QString& theStudyName ) { - DBG_FUN(); - ARG(theStudyName); myDriver->ClearDriverContents(); if( !openStudyData(theStudyName, 0)) // 0 means persistence file return false; @@ -153,9 +137,6 @@ bool LightApp_Study::loadDocument( const QString& theStudyName ) */ bool LightApp_Study::saveDocumentAs( const QString& theFileName, bool isBackup/*=false*/ ) { - DBG_FUN(); - ARG(theFileName); - ARG(isBackup); SUIT_ResourceMgr* resMgr = application()->resourceMgr(); if( !resMgr ) return false; @@ -221,7 +202,6 @@ bool LightApp_Study::saveDocumentAs( const QString& theFileName, bool isBackup/* */ bool LightApp_Study::saveDocument() { - DBG_FUN(); ModelList list; dataModels( list ); myDriver->ClearDriverContents(); @@ -250,8 +230,6 @@ bool LightApp_Study::saveDocument() */ void LightApp_Study::closeDocument(bool permanently) { - DBG_FUN(); - ARG(permanently); // Inform everybody that this study is going to close when it's most safe to, // i.e. in the very beginning emit closed( this ); @@ -351,10 +329,6 @@ void LightApp_Study::addComponent(const CAM_DataModel* /*dm*/) */ void LightApp_Study::saveModuleData(QString theModuleName, int type, QStringList theListOfFiles) { - DBG_FUN(); - ARG(theModuleName); - ARG(type); - ARG(theListOfFiles); int aNb = theListOfFiles.count(); if ( aNb == 0 ) return; @@ -391,8 +365,6 @@ void LightApp_Study::openModuleData(QString theModuleName, int /*type*/, QString */ bool LightApp_Study::saveStudyData( const QString& theFileName, int /*type*/ ) { - DBG_FUN(); - ARG(theFileName); ModelList list; dataModels( list ); SUIT_ResourceMgr* resMgr = application()->resourceMgr(); if( !resMgr ) diff --git a/src/LightApp/MBDebug.h b/src/LightApp/MBDebug.h deleted file mode 100644 index 800d81246..000000000 --- a/src/LightApp/MBDebug.h +++ /dev/null @@ -1,313 +0,0 @@ -#ifndef MBDebug_HeaderFile -#define MBDebug_HeaderFile - -//--------------------------------------------------------------- -// Usage of the logging facilities: -// -// (1) At the beginning of each class file to be debugged, there -// should be a static string variable defined with the name -// of the class. Then, include the "MBDebug.h" header file. -// -// //--------------------------------------------------------- -// #define USE_DEBUG -// //#define MB_IGNORE_QT -// //#define MB_FULL_DUMP -// #define MBCLASSNAME "ClassName" -// #include "MBDebug.h" -// // <-- insert includes for addtional debug headers here! -// //--------------------------------------------------------- -// -// (2) At the beginning of each class method, call the DBG_FUN -// macro. -// -// int ClassName::MyMethod(int x) -// { -// DBG_FUN(); -// ... -// } -// -// NOTE: For static methods, call the DBG_FUNC() macro!! -//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// This debugging/logging class is a "header-only" solution and -// does NOT require any additional implementation (.cpp) file! -//--------------------------------------------------------------- - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifndef MB_IGNORE_QT -# include -# include -#endif - -static std::mutex mtx; - -//--------------------------------------------------------------- -// Set the debug flags dependent on the preprocessor definitions -//--------------------------------------------------------------- -#ifdef USE_DEBUG -# define MBS_DEBUG_FLAG MBDebug::DF_DEBUG -#else -# define MBS_DEBUG_FLAG 0 -#endif /*DEBUG*/ - -#define MBS_DBG_FLAGS (MBS_DEBUG_FLAG) - - -//--------------------------------------------------------------- -// Define the global debug macros -//--------------------------------------------------------------- -#define DLOG MBDebug::LogPrint() -#define RETURN(var) { RET(var); return (var); } - -#ifdef USE_DEBUG - -# define DBG_FUN() MBDebug _dbg(MBCLASSNAME, __FUNCTION__, MBS_DBG_FLAGS, (void*)this) -# define DBG_FUNC() MBDebug _dbg(MBCLASSNAME, __FUNCTION__, MBS_DBG_FLAGS) -# define DBG_FUNB(blk) MBDebug _dbg(MBCLASSNAME, blk, MBS_DBG_FLAGS) -# define MSGEL(txt) MBDebug::LogPrint() << ":" << txt << std::endl -# define PRINT(txt) MBDebug::LogPrint() << txt -# define SHOW2(var,typ) do { PRINT(std::this_thread::get_id()); DumpVar(#var,(typ)(var)); } while (0) -# define SHOW(var) do { PRINT(std::this_thread::get_id()); DumpVar(#var,var); } while (0) -# define ARG(var) do { PRINT(std::this_thread::get_id() << ":in:"); DumpVar(#var,var); } while (0) -# define ARG2(var,typ) do { PRINT(std::this_thread::get_id() << ":in:"); DumpVar(#var,(typ)(var)); } while (0) -# define RET(var) do { PRINT(std::this_thread::get_id() << ":out:"); DumpVar(#var,var); } while (0) -# define MSG(txt) MBDebug::LogPrint() << std::this_thread::get_id() << ":" << txt - -#else /*!USE_DEBUG*/ - -# define DBG_FUN() -# define DBG_FUNC() -# define DBG_FUNB(blk) -# define MSGEL(txt) -# define PRINT(txt) -# define SHOW2(var,typ) -# define SHOW(var) -# define ARG(var) -# define ARG2(var,typ) -# define RET(var) -# define MSG(txt) - -#endif /*USE_DEBUG*/ - - -//--------------------------------------------------------------- -// Declare the debugging and profiling class -//--------------------------------------------------------------- -class MBDebug -{ -public: - enum { - DF_NONE = 0x00, // no debug - DF_DEBUG = 0x01 // debug a function - }; - - MBDebug(const char* aClassName, const char* aFuncName, const short aFlag, void* aThis=NULL) - :mClassName(aClassName),mFuncName(aFuncName),mThis(aThis),mFlags((unsigned char)aFlag) - { - if (mFlags & (DF_DEBUG)) - { - std::lock_guard lck(mtx); - std::cout << std::this_thread::get_id() << ":{ENTER: " << mClassName + "::" + mFuncName; - if (mThis) std::cout << "(this=" << mThis << ")"; - std::cout << std::endl; - } - } - virtual ~MBDebug() - { - if (mFlags & (DF_DEBUG)) - { - std::lock_guard lck(mtx); - std::cout << std::this_thread::get_id() << ":}LEAVE: " << mClassName << "::" << mFuncName << std::endl; - } - } - - // Log file output management - static std::ostream& LogPrint() { return std::cout; } - -private: - std::string mClassName; // Name of class to be debugged - std::string mFuncName; // Name of function to be debugged - void* mThis; // The "this" pointer to the class being debugged - unsigned char mFlags; // Debug mode flags -}; - - - -#define YesNo(b) (b ? "Yes" : "No") - - - -inline std::string w2s(std::wstring ws) -{ - using convert_typeX = std::codecvt_utf8; - std::wstring_convert converterX; - return(converterX.to_bytes(ws)); -} - -// Primitive types -inline void DumpVar(const char *szName, char value) -{ - std::lock_guard lck(mtx); - DLOG << "[chr]: " << szName << "='" << value << "'" << std::endl; -} - -inline void DumpVar(const char *szName, bool value) -{ - std::lock_guard lck(mtx); - DLOG << "[bool]: " << szName << "=" << (value ? "true" : "false") << std::endl; -} - -inline void DumpVar(const char *szName, short value) -{ - std::lock_guard lck(mtx); - DLOG << "[shrt]: " << szName << "=" << value << std::endl; -} - -inline void DumpVar(const char *szName, int value) -{ - std::lock_guard lck(mtx); - DLOG << "[int]: " << szName << "=" << value << std::endl; -} - -inline void DumpVar(const char *szName, long value) -{ - std::lock_guard lck(mtx); - DLOG << "[long]: " << szName << "=" << value << std::endl; -} - -inline void DumpVar(const char *szName, double value) -{ - std::lock_guard lck(mtx); - DLOG << "[dbl]: " << szName << "=" << value << std::endl; -} - -inline void DumpVar(const char *szName, unsigned char value) -{ - std::lock_guard lck(mtx); - DLOG << "[byte]: " << szName << "=0x" << std::hex << value << std::dec << std::endl; -} - -inline void DumpVar(const char *szName, unsigned short value) -{ - std::lock_guard lck(mtx); - DLOG << "[word]: " << szName << "=0x" << std::hex << value << std::dec << std::endl; -} - -inline void DumpVar(const char *szName, unsigned int value) -{ - std::lock_guard lck(mtx); - DLOG << "[uint]: " << szName << "=0x" << std::hex << value << std::dec << std::endl; -} - -inline void DumpVar(const char *szName, unsigned long value) -{ - std::lock_guard lck(mtx); - DLOG << "[dword]: " << szName << "=0x" << std::hex << value << std::dec << std::endl; -} - -inline void DumpVar(const char *szName, const char* value) -{ - std::lock_guard lck(mtx); - DLOG << "[str]: " << szName << "=\"" << (value ? value : "") << "\"" << std::endl; -} - -inline void DumpVar(const char *szName, const std::string &value) -{ - std::lock_guard lck(mtx); - DLOG << "[Str]: " << szName << "=\"" << value << "\"" << std::endl; -} - -inline void DumpVar(const char *szName, const std::wstring &value) -{ - std::lock_guard lck(mtx); - DLOG << "[WStr]: " << szName << "=\"" << w2s(value) << "\"" << std::endl; -} - -#ifndef MB_IGNORE_QT -inline void DumpVar(const char *szName, const QString &value) -{ - std::lock_guard lck(mtx); - DLOG << "[QStr]: " << szName << "=\"" << value.toStdString() << "\"" << std::endl; -} - -inline void DumpVar(const char *szName, const QStringList &value) -{ - std::lock_guard lck(mtx); - DLOG << "[QStrLst]: " << szName << "=[len=" << value.length() << "] {"; - bool first = true; - QStringList::const_iterator it = value.constBegin(); - for ( ; it != value.constEnd(); ++it) - { - DLOG << (first ? "" : ",") << "\"" << (*it).toStdString() << "\""; - first = false; - } - DLOG << "}" << std::endl; -} -#endif - -inline void DumpVar(const char *szName, const void* value) -{ - std::lock_guard lck(mtx); - DLOG << "[ptr]: " << szName << "=" << value << std::endl; -} - - -// Collection of primitive types -inline void DumpVar(const char *szName, const std::set &values) -{ - std::lock_guard lck(mtx); - DLOG << "[intSet]: " << szName << "={" << values.size() << "}["; - bool bFirst = true; - for (auto it=values.cbegin(); it!=values.cend(); ++it) { - DLOG << (bFirst ? "" : ",") << *it; - bFirst = false; - } - DLOG << "]" << std::endl; -} - -inline void DumpVar(const char *szName, const std::vector &values) -{ - std::lock_guard lck(mtx); - DLOG << "[intVect]: " << szName << "={" << values.size() << "}["; - bool bFirst = true; - for (auto it=values.cbegin(); it!=values.cend(); ++it) { - DLOG << (bFirst ? "" : ",") << *it; - bFirst = false; - } - DLOG << "]" << std::endl; -} - -inline void DumpVar(const char *szName, const std::list& values) -{ - std::lock_guard lck(mtx); - DLOG << "[boolList]: " << szName << "={" << values.size() << "}["; - bool bFirst = true; - for (auto it=values.cbegin(); it!=values.cend(); ++it) { - DLOG << (bFirst ? "" : ",") << (*it ? "Y" : "N"); - bFirst = false; - } - DLOG << "]" << std::endl; -} - -inline void DumpVar(const char *szName, const std::list &values) -{ - std::lock_guard lck(mtx); - DLOG << "[strLst]: " << szName << "={" << values.size() << "}["; - bool bFirst = true; - for (auto it=values.cbegin(); it!=values.cend(); ++it) { - DLOG << (bFirst ? "\"" : ", \"") << *it << "\""; - bFirst = false; - } - DLOG << "]" << std::endl; -} - -#endif // MBDebug_HeaderFile - diff --git a/src/SalomeApp/MBDebug.h b/src/SalomeApp/MBDebug.h deleted file mode 100644 index 800d81246..000000000 --- a/src/SalomeApp/MBDebug.h +++ /dev/null @@ -1,313 +0,0 @@ -#ifndef MBDebug_HeaderFile -#define MBDebug_HeaderFile - -//--------------------------------------------------------------- -// Usage of the logging facilities: -// -// (1) At the beginning of each class file to be debugged, there -// should be a static string variable defined with the name -// of the class. Then, include the "MBDebug.h" header file. -// -// //--------------------------------------------------------- -// #define USE_DEBUG -// //#define MB_IGNORE_QT -// //#define MB_FULL_DUMP -// #define MBCLASSNAME "ClassName" -// #include "MBDebug.h" -// // <-- insert includes for addtional debug headers here! -// //--------------------------------------------------------- -// -// (2) At the beginning of each class method, call the DBG_FUN -// macro. -// -// int ClassName::MyMethod(int x) -// { -// DBG_FUN(); -// ... -// } -// -// NOTE: For static methods, call the DBG_FUNC() macro!! -//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// This debugging/logging class is a "header-only" solution and -// does NOT require any additional implementation (.cpp) file! -//--------------------------------------------------------------- - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifndef MB_IGNORE_QT -# include -# include -#endif - -static std::mutex mtx; - -//--------------------------------------------------------------- -// Set the debug flags dependent on the preprocessor definitions -//--------------------------------------------------------------- -#ifdef USE_DEBUG -# define MBS_DEBUG_FLAG MBDebug::DF_DEBUG -#else -# define MBS_DEBUG_FLAG 0 -#endif /*DEBUG*/ - -#define MBS_DBG_FLAGS (MBS_DEBUG_FLAG) - - -//--------------------------------------------------------------- -// Define the global debug macros -//--------------------------------------------------------------- -#define DLOG MBDebug::LogPrint() -#define RETURN(var) { RET(var); return (var); } - -#ifdef USE_DEBUG - -# define DBG_FUN() MBDebug _dbg(MBCLASSNAME, __FUNCTION__, MBS_DBG_FLAGS, (void*)this) -# define DBG_FUNC() MBDebug _dbg(MBCLASSNAME, __FUNCTION__, MBS_DBG_FLAGS) -# define DBG_FUNB(blk) MBDebug _dbg(MBCLASSNAME, blk, MBS_DBG_FLAGS) -# define MSGEL(txt) MBDebug::LogPrint() << ":" << txt << std::endl -# define PRINT(txt) MBDebug::LogPrint() << txt -# define SHOW2(var,typ) do { PRINT(std::this_thread::get_id()); DumpVar(#var,(typ)(var)); } while (0) -# define SHOW(var) do { PRINT(std::this_thread::get_id()); DumpVar(#var,var); } while (0) -# define ARG(var) do { PRINT(std::this_thread::get_id() << ":in:"); DumpVar(#var,var); } while (0) -# define ARG2(var,typ) do { PRINT(std::this_thread::get_id() << ":in:"); DumpVar(#var,(typ)(var)); } while (0) -# define RET(var) do { PRINT(std::this_thread::get_id() << ":out:"); DumpVar(#var,var); } while (0) -# define MSG(txt) MBDebug::LogPrint() << std::this_thread::get_id() << ":" << txt - -#else /*!USE_DEBUG*/ - -# define DBG_FUN() -# define DBG_FUNC() -# define DBG_FUNB(blk) -# define MSGEL(txt) -# define PRINT(txt) -# define SHOW2(var,typ) -# define SHOW(var) -# define ARG(var) -# define ARG2(var,typ) -# define RET(var) -# define MSG(txt) - -#endif /*USE_DEBUG*/ - - -//--------------------------------------------------------------- -// Declare the debugging and profiling class -//--------------------------------------------------------------- -class MBDebug -{ -public: - enum { - DF_NONE = 0x00, // no debug - DF_DEBUG = 0x01 // debug a function - }; - - MBDebug(const char* aClassName, const char* aFuncName, const short aFlag, void* aThis=NULL) - :mClassName(aClassName),mFuncName(aFuncName),mThis(aThis),mFlags((unsigned char)aFlag) - { - if (mFlags & (DF_DEBUG)) - { - std::lock_guard lck(mtx); - std::cout << std::this_thread::get_id() << ":{ENTER: " << mClassName + "::" + mFuncName; - if (mThis) std::cout << "(this=" << mThis << ")"; - std::cout << std::endl; - } - } - virtual ~MBDebug() - { - if (mFlags & (DF_DEBUG)) - { - std::lock_guard lck(mtx); - std::cout << std::this_thread::get_id() << ":}LEAVE: " << mClassName << "::" << mFuncName << std::endl; - } - } - - // Log file output management - static std::ostream& LogPrint() { return std::cout; } - -private: - std::string mClassName; // Name of class to be debugged - std::string mFuncName; // Name of function to be debugged - void* mThis; // The "this" pointer to the class being debugged - unsigned char mFlags; // Debug mode flags -}; - - - -#define YesNo(b) (b ? "Yes" : "No") - - - -inline std::string w2s(std::wstring ws) -{ - using convert_typeX = std::codecvt_utf8; - std::wstring_convert converterX; - return(converterX.to_bytes(ws)); -} - -// Primitive types -inline void DumpVar(const char *szName, char value) -{ - std::lock_guard lck(mtx); - DLOG << "[chr]: " << szName << "='" << value << "'" << std::endl; -} - -inline void DumpVar(const char *szName, bool value) -{ - std::lock_guard lck(mtx); - DLOG << "[bool]: " << szName << "=" << (value ? "true" : "false") << std::endl; -} - -inline void DumpVar(const char *szName, short value) -{ - std::lock_guard lck(mtx); - DLOG << "[shrt]: " << szName << "=" << value << std::endl; -} - -inline void DumpVar(const char *szName, int value) -{ - std::lock_guard lck(mtx); - DLOG << "[int]: " << szName << "=" << value << std::endl; -} - -inline void DumpVar(const char *szName, long value) -{ - std::lock_guard lck(mtx); - DLOG << "[long]: " << szName << "=" << value << std::endl; -} - -inline void DumpVar(const char *szName, double value) -{ - std::lock_guard lck(mtx); - DLOG << "[dbl]: " << szName << "=" << value << std::endl; -} - -inline void DumpVar(const char *szName, unsigned char value) -{ - std::lock_guard lck(mtx); - DLOG << "[byte]: " << szName << "=0x" << std::hex << value << std::dec << std::endl; -} - -inline void DumpVar(const char *szName, unsigned short value) -{ - std::lock_guard lck(mtx); - DLOG << "[word]: " << szName << "=0x" << std::hex << value << std::dec << std::endl; -} - -inline void DumpVar(const char *szName, unsigned int value) -{ - std::lock_guard lck(mtx); - DLOG << "[uint]: " << szName << "=0x" << std::hex << value << std::dec << std::endl; -} - -inline void DumpVar(const char *szName, unsigned long value) -{ - std::lock_guard lck(mtx); - DLOG << "[dword]: " << szName << "=0x" << std::hex << value << std::dec << std::endl; -} - -inline void DumpVar(const char *szName, const char* value) -{ - std::lock_guard lck(mtx); - DLOG << "[str]: " << szName << "=\"" << (value ? value : "") << "\"" << std::endl; -} - -inline void DumpVar(const char *szName, const std::string &value) -{ - std::lock_guard lck(mtx); - DLOG << "[Str]: " << szName << "=\"" << value << "\"" << std::endl; -} - -inline void DumpVar(const char *szName, const std::wstring &value) -{ - std::lock_guard lck(mtx); - DLOG << "[WStr]: " << szName << "=\"" << w2s(value) << "\"" << std::endl; -} - -#ifndef MB_IGNORE_QT -inline void DumpVar(const char *szName, const QString &value) -{ - std::lock_guard lck(mtx); - DLOG << "[QStr]: " << szName << "=\"" << value.toStdString() << "\"" << std::endl; -} - -inline void DumpVar(const char *szName, const QStringList &value) -{ - std::lock_guard lck(mtx); - DLOG << "[QStrLst]: " << szName << "=[len=" << value.length() << "] {"; - bool first = true; - QStringList::const_iterator it = value.constBegin(); - for ( ; it != value.constEnd(); ++it) - { - DLOG << (first ? "" : ",") << "\"" << (*it).toStdString() << "\""; - first = false; - } - DLOG << "}" << std::endl; -} -#endif - -inline void DumpVar(const char *szName, const void* value) -{ - std::lock_guard lck(mtx); - DLOG << "[ptr]: " << szName << "=" << value << std::endl; -} - - -// Collection of primitive types -inline void DumpVar(const char *szName, const std::set &values) -{ - std::lock_guard lck(mtx); - DLOG << "[intSet]: " << szName << "={" << values.size() << "}["; - bool bFirst = true; - for (auto it=values.cbegin(); it!=values.cend(); ++it) { - DLOG << (bFirst ? "" : ",") << *it; - bFirst = false; - } - DLOG << "]" << std::endl; -} - -inline void DumpVar(const char *szName, const std::vector &values) -{ - std::lock_guard lck(mtx); - DLOG << "[intVect]: " << szName << "={" << values.size() << "}["; - bool bFirst = true; - for (auto it=values.cbegin(); it!=values.cend(); ++it) { - DLOG << (bFirst ? "" : ",") << *it; - bFirst = false; - } - DLOG << "]" << std::endl; -} - -inline void DumpVar(const char *szName, const std::list& values) -{ - std::lock_guard lck(mtx); - DLOG << "[boolList]: " << szName << "={" << values.size() << "}["; - bool bFirst = true; - for (auto it=values.cbegin(); it!=values.cend(); ++it) { - DLOG << (bFirst ? "" : ",") << (*it ? "Y" : "N"); - bFirst = false; - } - DLOG << "]" << std::endl; -} - -inline void DumpVar(const char *szName, const std::list &values) -{ - std::lock_guard lck(mtx); - DLOG << "[strLst]: " << szName << "={" << values.size() << "}["; - bool bFirst = true; - for (auto it=values.cbegin(); it!=values.cend(); ++it) { - DLOG << (bFirst ? "\"" : ", \"") << *it << "\""; - bFirst = false; - } - DLOG << "]" << std::endl; -} - -#endif // MBDebug_HeaderFile - diff --git a/src/SalomeApp/SalomeApp_Study.cxx b/src/SalomeApp/SalomeApp_Study.cxx index 4b3da9174..a36f35476 100644 --- a/src/SalomeApp/SalomeApp_Study.cxx +++ b/src/SalomeApp/SalomeApp_Study.cxx @@ -60,14 +60,6 @@ #include #include CORBA_SERVER_HEADER(SALOME_Exception) -//--------------------------------------------------------- -#define USE_DEBUG -//#define MB_IGNORE_QT -//#define MB_FULL_DUMP -#define MBCLASSNAME "SalomeApp_Study" -#include "MBDebug.h" -// <-- insert includes for addtional debug headers here! -//--------------------------------------------------------- //#define NOTIFY_BY_EVENT @@ -400,7 +392,6 @@ private: SalomeApp_Study::SalomeApp_Study( SUIT_Application* app ) : LightApp_Study( app ), myObserver( 0 ) { - DBG_FUN(); myStudyDS = SalomeApp_Application::getStudy(); } @@ -409,7 +400,6 @@ SalomeApp_Study::SalomeApp_Study( SUIT_Application* app ) */ SalomeApp_Study::~SalomeApp_Study() { - DBG_FUN(); if ( myObserver ) { PortableServer::ObjectId_var oid = myObserver->_default_POA()->servant_to_id( myObserver ); myObserver->_default_POA()->deactivate_object( oid.in() ); @@ -458,8 +448,6 @@ _PTR(Study) SalomeApp_Study::studyDS() const */ bool SalomeApp_Study::createDocument( const QString& theStr ) { - DBG_FUN(); - ARG(theStr); MESSAGE( "createDocument" ); setStudyName( QString::fromUtf8(myStudyDS->URL().c_str()) ); @@ -490,8 +478,6 @@ bool SalomeApp_Study::createDocument( const QString& theStr ) */ bool SalomeApp_Study::openDocument( const QString& theFileName ) { - DBG_FUN(); - ARG(theFileName); MESSAGE( "openDocument" ); // read HDF file @@ -562,8 +548,6 @@ bool SalomeApp_Study::openDocument( const QString& theFileName ) */ bool SalomeApp_Study::loadDocument( const QString& theStudyName ) { - DBG_FUN(); - ARG(theStudyName); MESSAGE( "loadDocument" ); setRoot( new SalomeApp_RootObject( this ) ); // create myRoot @@ -614,10 +598,6 @@ bool SalomeApp_Study::loadDocument( const QString& theStudyName ) */ bool SalomeApp_Study::saveDocumentAs( const QString& theFileName, bool isBackup/*=false*/ ) { - DBG_FUN(); - ARG(theFileName); - ARG(isBackup); - bool wasSaved = isSaved(); bool wasModified = isModified(); std::string oldName = (studyDS() ? studyDS()->Name() : ""); @@ -666,8 +646,6 @@ bool SalomeApp_Study::saveDocumentAs( const QString& theFileName, bool isBackup/ // If the document hasn't been saved before, reset here its name and URL if (studyDS()) { - MSGEL("Restore URL to: " << oldURL); - MSGEL("Restore Name to: " << oldName); studyDS()->URL(oldURL); studyDS()->Name(oldName); } @@ -681,7 +659,6 @@ bool SalomeApp_Study::saveDocumentAs( const QString& theFileName, bool isBackup/ */ bool SalomeApp_Study::saveDocument() { - DBG_FUN(); bool store = application()->resourceMgr()->booleanValue( "Study", "store_visual_state", true ); if ( store ) SalomeApp_VisualState( (SalomeApp_Application*)application() ).storeState(); @@ -724,7 +701,6 @@ bool SalomeApp_Study::saveDocument() */ void SalomeApp_Study::closeDocument(bool permanently) { - DBG_FUN(); LightApp_Study::closeDocument(permanently); // close SALOMEDS document @@ -763,11 +739,6 @@ bool SalomeApp_Study::dump( const QString& theFileName, bool isMultiFile, bool toSaveGUI ) { - DBG_FUN(); - ARG(theFileName); - ARG(toPublish); - ARG(isMultiFile); - ARG(toSaveGUI); int savePoint = 0; _PTR(AttributeParameter) ap; _PTR(IParameters) ip = ClientFactory::getIParameters(ap); -- 2.39.2