|
From: Carlo W. <li...@us...> - 2002-02-01 05:21:16
|
CVSROOT : /cvsroot/libcw
Module : src
Commit time: 2002-01-01 05:21:16 UTC
Modified files:
libcwd/bfd.cc libcwd/configure.in libcwd/threading.cc
libcwd/wrapcnclpnts.c libcwd/include/libcw/debug_config.ho.in
libcwd/include/libcw/private_struct_TSD.h
libcwd/include/libcw/private_threading.h
Log message:
New configure options --enable-libcwd-debugt.
Use DEBUGDEBUGTHREADS instead of LIBCWD_DEBUGTHREADS.
---------------------- diff included ----------------------
Index: src/libcwd/bfd.cc
diff -u src/libcwd/bfd.cc:1.97 src/libcwd/bfd.cc:1.98
--- src/libcwd/bfd.cc:1.97 Thu Jan 31 21:11:19 2002
+++ src/libcwd/bfd.cc Thu Jan 31 21:21:05 2002
@@ -1,4 +1,4 @@
-// $Header: /cvsroot/l/li/libcw/src/libcwd/bfd.cc,v 1.97 2002/02/01 05:11:19 libcw Exp $
+// $Header: /cvsroot/l/li/libcw/src/libcwd/bfd.cc,v 1.98 2002/02/01 05:21:05 libcw Exp $
//
// Copyright (C) 2000 - 2001, by
//
@@ -1023,7 +1023,7 @@
BFD_INITIALIZE_LOCK
LIBCWD_DEFER_CANCEL
BFD_ACQUIRE_WRITE_LOCK
-#if LIBCWD_DEBUGTHREADS
+#ifdef DEBUGDEBUGTHREADS
--__libcwd_tsd.cancel_explicitely_deferred;
#endif
load_object_file(fullpath.value->data(), 0);
@@ -1052,7 +1052,7 @@
load_object_file(l->l_name, reinterpret_cast<void*>(l->l_addr));
}
NEEDS_WRITE_LOCK_object_files().sort(object_file_greater());
-#if LIBCWD_DEBUGTHREADS
+#ifdef DEBUGDEBUGTHREADS
++__libcwd_tsd.cancel_explicitely_deferred;
#endif
BFD_RELEASE_WRITE_LOCK
Index: src/libcwd/configure.in
diff -u src/libcwd/configure.in:1.99 src/libcwd/configure.in:1.100
--- src/libcwd/configure.in:1.99 Fri Jan 25 18:06:33 2002
+++ src/libcwd/configure.in Thu Jan 31 21:21:05 2002
@@ -1,5 +1,5 @@
dnl Process this file with autoconf to produce a configure script.
-AC_REVISION($Revision: 1.99 $)dnl
+AC_REVISION($Revision: 1.100 $)dnl
dnl General intialization of `autoconf' varaibles.
dnl Ensure that the directory specified with --srcdir was correct
@@ -101,6 +101,12 @@
threading where needed.],
libcwd_config_threading=$enableval)
+libcwd_config_debugt=no
+AC_ARG_ENABLE(libcwd-debugt,
+ [ --enable-libcwd-debugt enable debugging of threading debugging code
+ in libcwd itself.],
+ libcwd_config_debugt=$enableval)
+
dnl Restore the environment variables used when running `configure' when
dnl `config.status --recheck' was invoked.
dnl Always let CXX and CXXCPP override cached values
@@ -208,6 +214,8 @@
CW_CONFIG_DEBUGDEBUGOUTPUT=undef
AC_SUBST(CW_CONFIG_DEBUGDEBUGMALLOC)
CW_CONFIG_DEBUGDEBUGMALLOC=undef
+AC_SUBST(CW_CONFIG_DEBUGDEBUGTHREADS)
+CW_CONFIG_DEBUGDEBUGTHREADS=undef
AC_SUBST(CW_CONFIG_DEBUGMARKER)
CW_CONFIG_DEBUGMARKER=undef
AC_SUBST(CW_CONFIG_HAVE___LIBC_MALLOC)
@@ -391,6 +399,10 @@
if test "$libcwd_config_debugm" = yes; then
CW_CONFIG_DEBUGDEBUGMALLOC=define
+fi
+
+if test "$libcwd_config_debugt" = yes; then
+ CW_CONFIG_DEBUGDEBUGTHREADS=define
fi
if test "$libcwd_config_marker" = yes; then
Index: src/libcwd/include/libcw/debug_config.ho.in
diff -u src/libcwd/include/libcw/debug_config.ho.in:1.16 src/libcwd/include/libcw/debug_config.ho.in:1.17
--- src/libcwd/include/libcw/debug_config.ho.in:1.16 Fri Jan 25 18:06:33 2002
+++ src/libcwd/include/libcw/debug_config.ho.in Thu Jan 31 21:21:05 2002
@@ -1,5 +1,5 @@
// @configure_input@
-// $Header: /cvsroot/l/li/libcw/src/libcwd/include/libcw/debug_config.ho.in,v 1.16 2002/01/26 02:06:33 libcw Exp $
+// $Header: /cvsroot/l/li/libcw/src/libcwd/include/libcw/debug_config.ho.in,v 1.17 2002/02/01 05:21:05 libcw Exp $
//
// Copyright (C) 2000 - 2001, by
//
@@ -263,9 +263,50 @@
#endif
//
+// autoconf defines that are needed.
+//
+
+#ifdef DEBUGMALLOC
+#@CW_CONFIG_HAVE___LIBC_MALLOC@ DEBUGMALLOCEXTERNALCLINKAGE
+#endif
+
+#ifdef DEBUGUSEBFD
+#@CW_CONFIG_HAVE_DLOPEN@ CWDEBUG_DLOPEN_DEFINED
+#endif
+
+#@CW_CONFIG_THREAD_SAFE@ LIBCWD_THREAD_SAFE
+#@CW_CONFIG_HAVE_PTHREADS@ LIBCWD_HAVE_PTHREAD
+
+#ifdef LIBCWD_THREAD_SAFE
+/** \defgroup enable_libcwd_debugt --enable-libcwd-debugt (DEBUGDEBUGTHREADS)
+ * \ingroup group_configuration
+ *
+ * \par Description
+ *
+ * Turns on sanity checks related to libcwds critical areas and cancellation points.
+ * The checks test if cancellation has been explicitely deferred or disabled at the entrance
+ * of a critical area and that no cancellation point is called from within critical areas
+ * without cleanup handler.
+ *
+ * \par When to use it
+ *
+ * Never, unless you are a developer of libcwd.
+ * If someone requests it then I might extend this to a user interface however.
+ *
+ * \par Configure option
+ *
+ * This is disabled by default.
+ * Use \shellcommand configure --enable-libcwd-debugt \endshellcommand to enable it.
+ */
+
+#@CW_CONFIG_DEBUGDEBUGTHREADS@ DEBUGDEBUGTHREADS
+#endif // LIBCWD_THREAD_SAFE
+
+//
// Configuration signature
//
+#ifdef __cplusplus
namespace libcw {
namespace debug {
@@ -325,21 +366,6 @@
} // namespace debug
} // namespace libcw
-
-//
-// autoconf defines that are needed.
-//
-
-#ifdef DEBUGMALLOC
-#@CW_CONFIG_HAVE___LIBC_MALLOC@ DEBUGMALLOCEXTERNALCLINKAGE
-#endif
-
-#ifdef DEBUGUSEBFD
-#@CW_CONFIG_HAVE_DLOPEN@ CWDEBUG_DLOPEN_DEFINED
-#endif
-
-#@CW_CONFIG_THREAD_SAFE@ LIBCWD_THREAD_SAFE
-#@CW_CONFIG_HAVE_PTHREADS@ LIBCWD_HAVE_PTHREAD
-#@CW_CONFIG_HAVE__PTHREAD_CLEANUP_BUFFER@ HAVE__PTHREAD_CLEANUP_BUFFER
+#endif // __cplusplus
#endif // LIBCW_DEBUG_CONFIG_H
Index: src/libcwd/include/libcw/private_struct_TSD.h
diff -u src/libcwd/include/libcw/private_struct_TSD.h:1.2 src/libcwd/include/libcw/private_struct_TSD.h:1.3
--- src/libcwd/include/libcw/private_struct_TSD.h:1.2 Wed Jan 30 20:42:08 2002
+++ src/libcwd/include/libcw/private_struct_TSD.h Thu Jan 31 21:21:05 2002
@@ -1,4 +1,4 @@
-// $Header: /cvsroot/l/li/libcw/src/libcwd/include/libcw/private_struct_TSD.h,v 1.2 2002/01/31 04:42:08 libcw Exp $
+// $Header: /cvsroot/l/li/libcw/src/libcwd/include/libcw/private_struct_TSD.h,v 1.3 2002/02/01 05:21:05 libcw Exp $
//
// Copyright (C) 2001, by
//
@@ -26,12 +26,6 @@
#include <cstring> // Needed for std::memset.
#endif
-#ifndef DEBUGDEBUG
-#define LIBCWD_DEBUGTHREADS 0 // Toggle this if necessary.
-#else
-#define LIBCWD_DEBUGTHREADS 1
-#endif
-
namespace libcw {
namespace debug {
namespace _private_ {
@@ -87,7 +81,7 @@
#endif
#ifdef LIBCWD_THREAD_SAFE // Directly contained in debug_ct when not threaded.
debug_tsd_st do_array[16]; // Thread Specific Data of Debug Objects.
-#if LIBCWD_DEBUGTHREADS
+#ifdef DEBUGDEBUGTHREADS
int cancel_explicitely_deferred;
int cancel_explicitely_disabled;
#endif
Index: src/libcwd/include/libcw/private_threading.h
diff -u src/libcwd/include/libcw/private_threading.h:1.16 src/libcwd/include/libcw/private_threading.h:1.17
--- src/libcwd/include/libcw/private_threading.h:1.16 Wed Jan 30 20:42:08 2002
+++ src/libcwd/include/libcw/private_threading.h Thu Jan 31 21:21:05 2002
@@ -1,4 +1,4 @@
-// $Header: /cvsroot/l/li/libcw/src/libcwd/include/libcw/private_threading.h,v 1.16 2002/01/31 04:42:08 libcw Exp $
+// $Header: /cvsroot/l/li/libcw/src/libcwd/include/libcw/private_threading.h,v 1.17 2002/02/01 05:21:05 libcw Exp $
//
// Copyright (C) 2001 - 2002, by
//
@@ -62,13 +62,13 @@
#define LIBCWD_USE_POSIX_THREADS 0
#endif
-#if LIBCWD_DEBUGTHREADS
+#ifdef DEBUGDEBUGTHREADS
#define LibcwDebugThreads(x) x
#else
#define LibcwDebugThreads(x)
#endif
-#if LIBCWD_DEBUGTHREADS
+#ifdef DEBUGDEBUGTHREADS
#ifndef LIBCW_CASSERT
#define LIBCW_CASSERT
#include <cassert>
@@ -297,14 +297,14 @@
class mutex_tct {
public:
static pthread_mutex_t S_mutex;
-#if !LIBCWD_USE_LINUXTHREADS || LIBCWD_DEBUGTHREADS
+#if !LIBCWD_USE_LINUXTHREADS || defined(DEBUGDEBUGTHREADS)
protected:
static bool S_initialized;
static void S_initialize(void) throw();
#endif
public:
static void initialize(void) throw()
-#if LIBCWD_USE_LINUXTHREADS && !LIBCWD_DEBUGTHREADS
+#if LIBCWD_USE_LINUXTHREADS && !defined(DEBUGDEBUGTHREADS)
{ }
#else
{
@@ -333,11 +333,11 @@
#if LIBCWD_DEBUGDEBUGRWLOCK
if (instance != tsd_initialization_instance) LIBCWD_DEBUGDEBUGRWLOCK_CERR(pthread_self() << ": locking mutex " << instance);
#endif
-#if LIBCWD_DEBUGTHREADS
+#ifdef DEBUGDEBUGTHREADS
int res =
#endif
pthread_mutex_lock(&S_mutex);
-#if LIBCWD_DEBUGTHREADS
+#ifdef DEBUGDEBUGTHREADS
assert( res == 0 );
#endif
#if LIBCWD_DEBUGDEBUGRWLOCK
@@ -363,7 +363,7 @@
}
};
-#if !LIBCWD_USE_LINUXTHREADS || LIBCWD_DEBUGTHREADS
+#if !LIBCWD_USE_LINUXTHREADS || defined(DEBUGDEBUGTHREADS)
template <int instance>
bool mutex_tct<instance>::S_initialized = false;
@@ -374,7 +374,7 @@
{
#if !LIBCWD_USE_LINUXTHREADS
pthread_mutexattr_t mutex_attr;
-#if LIBCWD_DEBUGTHREADS
+#ifdef DEBUGDEBUGTHREADS
pthread_mutexattr_settype(&mutex_attr, PTHREAD_MUTEX_ERRORCHECK);
#else
pthread_mutexattr_settype(&mutex_attr, PTHREAD_MUTEX_NORMAL);
@@ -395,7 +395,7 @@
pthread_mutexattr_settype(&mutex_attr, PTHREAD_MUTEX_RECURSIVE);
else
{
-#if LIBCWD_DEBUGTHREADS
+#ifdef DEBUGDEBUGTHREADS
pthread_mutexattr_settype(&mutex_attr, PTHREAD_MUTEX_ERRORCHECK);
#else
pthread_mutexattr_settype(&mutex_attr, PTHREAD_MUTEX_NORMAL);
@@ -408,13 +408,13 @@
/* LIBCWD_UNLOCKMUTEX_POP_RESTORE(mutex_initialization_instance); */
}
}
-#endif // !LIBCWD_USE_LINUXTHREADS || LIBCWD_DEBUGTHREADS
+#endif // !LIBCWD_USE_LINUXTHREADS || defined(DEBUGDEBUGTHREADS)
template <int instance>
pthread_mutex_t mutex_tct<instance>::S_mutex
#if LIBCWD_USE_LINUXTHREADS
=
-#if LIBCWD_DEBUGTHREADS
+#ifdef DEBUGDEBUGTHREADS
PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP;
#else
PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP;
@@ -436,13 +436,13 @@
class cond_tct : public mutex_tct<instance> {
private:
static pthread_cond_t S_condition;
-#if LIBCWD_DEBUGTHREADS || !LIBCWD_USE_LINUXTHREADS
+#if defined(DEBUGDEBUGTHREADS) || !LIBCWD_USE_LINUXTHREADS
private:
static void S_initialize(void) throw();
#endif
public:
static void initialize(void) throw()
-#if LIBCWD_DEBUGTHREADS || !LIBCWD_USE_LINUXTHREADS
+#if defined(DEBUGDEBUGTHREADS) || !LIBCWD_USE_LINUXTHREADS
{
if (S_initialized)
return;
@@ -462,7 +462,7 @@
void broadcast(void) { pthread_cond_broadcast(&S_condition); }
};
-#if LIBCWD_DEBUGTHREADS || !LIBCWD_USE_LINUXTHREADS
+#if defined(DEBUGDEBUGTHREADS) || !LIBCWD_USE_LINUXTHREADS
template <int instance>
void cond_tct<instance>::S_initialize(void) throw()
{
@@ -527,13 +527,13 @@
static int S_holders_count; // Number of readers or -1 if a writer locked this object.
static bool S_writer_is_waiting;
static pthread_t S_writer_id;
-#if LIBCWD_DEBUGTHREADS || !LIBCWD_USE_LINUXTHREADS
+#if defined(DEBUGDEBUGTHREADS) || !LIBCWD_USE_LINUXTHREADS
static bool S_initialized; // Set when initialized.
#endif
public:
static void initialize(void) throw()
{
-#if LIBCWD_DEBUGTHREADS || !LIBCWD_USE_LINUXTHREADS
+#if defined(DEBUGDEBUGTHREADS) || !LIBCWD_USE_LINUXTHREADS
if (S_initialized)
return;
LIBCWD_DEBUGDEBUGRWLOCK_CERR(pthread_self() << ": Calling initialize() instance " << instance);
@@ -713,7 +713,7 @@
template <int instance>
pthread_t rwlock_tct<instance>::S_writer_id = 0;
-#if LIBCWD_DEBUGTHREADS || !LIBCWD_USE_LINUXTHREADS
+#if defined(DEBUGDEBUGTHREADS) || !LIBCWD_USE_LINUXTHREADS
template <int instance>
bool rwlock_tct<instance>::S_initialized = 0;
#endif
@@ -756,7 +756,7 @@
LIBCWD_TSD_DECLARATION
set_alloc_checking_off(LIBCWD_TSD);
delete instance;
-#if LIBCWD_DEBUGTHREADS
+#ifdef DEBUGDEBUGTHREADS
// Hopefully S_destroy doesn't get called in the thread itself!
assert( instance != &thread_specific_data_tct<TSD>::instance() );
#endif
Index: src/libcwd/threading.cc
diff -u src/libcwd/threading.cc:1.3 src/libcwd/threading.cc:1.4
--- src/libcwd/threading.cc:1.3 Wed Jan 30 20:42:08 2002
+++ src/libcwd/threading.cc Thu Jan 31 21:21:05 2002
@@ -1,4 +1,4 @@
-// $Header: /cvsroot/l/li/libcw/src/libcwd/threading.cc,v 1.3 2002/01/31 04:42:08 libcw Exp $
+// $Header: /cvsroot/l/li/libcw/src/libcwd/threading.cc,v 1.4 2002/02/01 05:21:05 libcw Exp $
//
// Copyright (C) 2001, by
//
@@ -30,7 +30,7 @@
void initialize_global_mutexes(void) throw()
{
-#if !LIBCWD_USE_LINUXTHREADS || LIBCWD_DEBUGTHREADS
+#if !LIBCWD_USE_LINUXTHREADS || defined(DEBUGDEBUGTHREADS)
mutex_tct<mutex_initialization_instance>::initialize();
rwlock_tct<object_files_instance>::initialize();
mutex_tct<dlopen_map_instance>::initialize();
@@ -41,7 +41,7 @@
#if __GNUC__ == 2 && __GNUC_MINOR__ < 96
mutex_tct<type_info_of_instance>::initialize();
#endif
-#endif // !LIBCWD_USE_LINUXTHREADS || LIBCWD_DEBUGTHREADS
+#endif // !LIBCWD_USE_LINUXTHREADS || defined(DEBUGDEBUGTHREADS)
}
#ifdef LIBCWD_USE_LINUXTHREADS
Index: src/libcwd/wrapcnclpnts.c
diff -u src/libcwd/wrapcnclpnts.c:1.2 src/libcwd/wrapcnclpnts.c:1.3
--- src/libcwd/wrapcnclpnts.c:1.2 Thu Jan 31 21:14:12 2002
+++ src/libcwd/wrapcnclpnts.c Thu Jan 31 21:21:05 2002
@@ -1,6 +1,6 @@
-#include <libcw/debug_config.h> // Needed for LIBCWD_DEBUG_THREADS
+#include <libcw/debug_config.h> // Needed for DEBUGDEBUGTHREADS
-#if LIBCWD_DEBUG_THREADS
+#ifdef DEBUGDEBUGTHREADS
#define _LARGEFILE64_SOURCE
#include <unistd.h>
@@ -116,4 +116,4 @@
CANCELABLE_SYSCALL (ssize_t, sendto, (int fd, const __ptr_t buf, size_t n, int flags, __CONST_SOCKADDR_ARG addr, socklen_t addr_len), (fd, buf, n, flags, addr, addr_len))
-#endif // LIBCWD_DEBUG_THREADS
+#endif // DEBUGDEBUGTHREADS
----------------------- End of diff -----------------------
|