From bc670e2e0983a7af33ae76568297298ae1c04650 Mon Sep 17 00:00:00 2001 From: nanbor Date: Thu, 30 Mar 2006 17:49:52 +0000 Subject: Better and less confusing semantics for debug print out --- ace/DLL.cpp | 13 +++++++------ ace/DLL.h | 11 ++++++++--- ace/DLL_Manager.cpp | 20 ++++++++++---------- ace/DLL_Manager.h | 4 ++-- 4 files changed, 27 insertions(+), 21 deletions(-) (limited to 'ace') diff --git a/ace/DLL.cpp b/ace/DLL.cpp index 270a6afb5b3..be510bee73e 100644 --- a/ace/DLL.cpp +++ b/ace/DLL.cpp @@ -51,7 +51,8 @@ ACE_DLL::ACE_DLL (const ACE_DLL &rhs) ACE_DLL::ACE_DLL (const ACE_TCHAR *dll_name, int open_mode, - int close_handle_on_destruction) + int close_handle_on_destruction, + int debug) : open_mode_ (open_mode), dll_name_ (0), close_handle_on_destruction_ (close_handle_on_destruction), @@ -60,7 +61,7 @@ ACE_DLL::ACE_DLL (const ACE_TCHAR *dll_name, { ACE_TRACE ("ACE_DLL::ACE_DLL"); - if (this->open (dll_name, this->open_mode_, close_handle_on_destruction) != 0 + if (this->open (dll_name, this->open_mode_, close_handle_on_destruction, debug) != 0 && ACE::debug ()) ACE_ERROR ((LM_ERROR, ACE_LIB_TEXT ("ACE_DLL::open: error calling open: %s\n"), @@ -99,11 +100,11 @@ int ACE_DLL::open (const ACE_TCHAR *dll_filename, int open_mode, int close_handle_on_destruction, - int debug_level) + int debug) { ACE_TRACE ("ACE_DLL::open"); - return open_i (dll_filename, open_mode, close_handle_on_destruction, NULL, debug_level); + return open_i (dll_filename, open_mode, close_handle_on_destruction, NULL, debug); } int @@ -111,7 +112,7 @@ ACE_DLL::open_i (const ACE_TCHAR *dll_filename, int open_mode, int close_handle_on_destruction, ACE_SHLIB_HANDLE handle, - int debug_level) + int debug) { ACE_TRACE ("ACE_DLL::open_i"); @@ -145,7 +146,7 @@ ACE_DLL::open_i (const ACE_TCHAR *dll_filename, this->dll_handle_ = ACE_DLL_Manager::instance()->open_dll (this->dll_name_, this->open_mode_, handle, - debug_level); + debug); if (!this->dll_handle_) this->error_ = 1; diff --git a/ace/DLL.h b/ace/DLL.h index 1f4dea57e89..e7b15ce25a3 100644 --- a/ace/DLL.h +++ b/ace/DLL.h @@ -75,10 +75,13 @@ public: * Set this parameter to 0 for situations where the DLL's lifetime * is controlled in a scope other than that of this ACE_DLL object. * For example, termination by ACE_DLL_Manager via ACE::fini(). + * @param debug Instruct open to print out debug information when attempting + * to open the DLL using various naming conventions. */ explicit ACE_DLL (const ACE_TCHAR *dll_name, int open_mode = ACE_DEFAULT_SHLIB_MODE, - int close_handle_on_destruction = 1); + int close_handle_on_destruction = 1, + int debug = 0); /// Copy constructor. ACE_DLL (const ACE_DLL &); @@ -101,13 +104,15 @@ public: * Set this parameter to 0 for situations where the DLL's lifetime * is controlled in a scope other than that of this ACE_DLL object. * For example, termination by ACE_DLL_Manager via ACE::fini(). + * @param debug Instruct open to print out debug information when attempting + * to open the DLL using various naming conventions. * @retval -1 On failure * @retval 0 On success. */ int open (const ACE_TCHAR *dll_name, int open_mode = ACE_DEFAULT_SHLIB_MODE, int close_handle_on_destruction = 1, - int debug_leve = 0); + int debug = 0); /// Call to close the DLL object. int close (void); @@ -155,7 +160,7 @@ private: int open_mode = ACE_DEFAULT_SHLIB_MODE, int close_handle_on_destruction = 1, ACE_SHLIB_HANDLE handle = 0, - int debug_level = 0); + int debug = 0); // Disallow assignment since we don't handle it. diff --git a/ace/DLL_Manager.cpp b/ace/DLL_Manager.cpp index f9b7bfaf86d..641c4192185 100644 --- a/ace/DLL_Manager.cpp +++ b/ace/DLL_Manager.cpp @@ -49,7 +49,7 @@ int ACE_DLL_Handle::open (const ACE_TCHAR *dll_name, int open_mode, ACE_SHLIB_HANDLE handle, - int debug_level) + int debug) { ACE_TRACE ("ACE_DLL_Handle::open"); ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, 0)); @@ -63,7 +63,7 @@ ACE_DLL_Handle::open (const ACE_TCHAR *dll_name, // Once dll_name_ has been set, it can't be changed.. if (ACE_OS::strcmp (this->dll_name_, dll_name) != 0) { - if (ACE::debug () || debug_level > 9) + if (debug != 0) ACE_ERROR ((LM_ERROR, ACE_LIB_TEXT ("ACE_DLL_Handle::open: error, ") ACE_LIB_TEXT ("tried to reopen %s with name %s\n"), @@ -86,7 +86,7 @@ ACE_DLL_Handle::open (const ACE_TCHAR *dll_name, this->handle_ = handle; else { - if (ACE::debug () || debug_level > 9) + if (debug != 0) ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("ACE_DLL_Handle::open: calling dlopen on ") ACE_LIB_TEXT ("\"%s\"\n"), dll_name)); @@ -129,7 +129,7 @@ ACE_DLL_Handle::open (const ACE_TCHAR *dll_name, ACE_TString *name = 0; while (name_iter.next (name)) { - if (ACE::debug () || debug_level > 9) + if (debug != 0) ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("ACE_DLL_Handle::open: Trying to open DLL %s with %s name\n"), this->dll_name_, @@ -141,7 +141,7 @@ ACE_DLL_Handle::open (const ACE_TCHAR *dll_name, if (this->handle_ != ACE_SHLIB_INVALID_HANDLE) // Good one break; - if (ACE::debug () || debug_level > 9) + if (debug != 0) ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("ACE_DLL_Handle: opening DLL %s: %s\n"), this->dll_name_, @@ -170,7 +170,7 @@ ACE_DLL_Handle::open (const ACE_TCHAR *dll_name, if (this->handle_ == ACE_SHLIB_INVALID_HANDLE) { - if (ACE::debug () || debug_level > 9) + if (debug != 0) ACE_ERROR ((LM_ERROR, ACE_LIB_TEXT ("ACE_DLL_Handle::open: Invalid handle when opening DLL %s: %s\n"), this->dll_name_, @@ -181,7 +181,7 @@ ACE_DLL_Handle::open (const ACE_TCHAR *dll_name, } } - if (ACE::debug () || debug_level > 9) + if (debug != 0) ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("ACE_DLL_Handle::open: loading %s (%d)\n"), this->dll_name_, @@ -486,7 +486,7 @@ ACE_DLL_Handle * ACE_DLL_Manager::open_dll (const ACE_TCHAR *dll_name, int open_mode, ACE_SHLIB_HANDLE handle, - int debug_level) + int debug) { ACE_TRACE ("ACE_DLL_Manager::open_dll"); ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, 0)); @@ -507,13 +507,13 @@ ACE_DLL_Manager::open_dll (const ACE_TCHAR *dll_name, if (dll_handle) { - if (dll_handle->open (dll_name, open_mode, handle, debug_level) != 0) + if (dll_handle->open (dll_name, open_mode, handle, debug) != 0) { // Don't worry about freeing the memory right now, since // the handle_vector_ will be cleaned up automatically // later. - if (ACE::debug () || debug_level > 9) + if (debug != 0) ACE_ERROR ((LM_ERROR, ACE_LIB_TEXT ("ACE_DLL_Manager::open_dll: Could not ") ACE_LIB_TEXT ("open dll %s.\n"), diff --git a/ace/DLL_Manager.h b/ace/DLL_Manager.h index 140988281f7..336532cdd50 100644 --- a/ace/DLL_Manager.h +++ b/ace/DLL_Manager.h @@ -82,7 +82,7 @@ public: int open (const ACE_TCHAR *dll_name, int open_mode, ACE_SHLIB_HANDLE handle, - int debug_level = 0); + int debug = 0); /// Call to close the DLL object. If unload = 0, it only decrements /// the refcount, but if unload = 1, then it will actually unload @@ -200,7 +200,7 @@ public: ACE_DLL_Handle *open_dll (const ACE_TCHAR *dll_name, int openmode, ACE_SHLIB_HANDLE handle, - int debug_level = 0); + int debug = 0); /// Close the underlying dll. Decrements the refcount. int close_dll (const ACE_TCHAR *dll_name); -- cgit v1.2.1