|
From: Carlo W. <li...@us...> - 2002-01-12 02:54:54
|
CVSROOT : /cvsroot/libcw
Module : src
Commit time: 2002-00-12 02:54:52 UTC
Modified files:
libcwd/acinclude.m4 libcwd/bfd.cc libcwd/configure.in
libcwd/debug.cc libcwd/elf32.cc
libcwd/include/libcw/class_channel.h
libcwd/include/libcw/class_debug.h
libcwd/include/libcw/private_threading.h
Log message:
Left over from previous patch :/ and fix for 2.96 (initialization order
fiasco actually).
---------------------- diff included ----------------------
Index: src/libcwd/acinclude.m4
diff -u src/libcwd/acinclude.m4:1.46 src/libcwd/acinclude.m4:1.47
--- src/libcwd/acinclude.m4:1.46 Wed Jan 9 21:04:34 2002
+++ src/libcwd/acinclude.m4 Fri Jan 11 18:54:42 2002
@@ -879,7 +879,7 @@
AC_CANONICAL_HOST
case "$host" in
*freebsd*) DEBUGOPTS=-ggdb ;; dnl FreeBSD needs -ggdb to include sourcefile:linenumber info in its object files.
- *) DEBUGOPTS=-ggdb3 ;;
+ *) DEBUGOPTS=-g ;;
esac
AC_SUBST(DEBUGOPTS)
Index: src/libcwd/bfd.cc
diff -u src/libcwd/bfd.cc:1.90 src/libcwd/bfd.cc:1.91
--- src/libcwd/bfd.cc:1.90 Sun Dec 30 21:01:23 2001
+++ src/libcwd/bfd.cc Fri Jan 11 18:54:42 2002
@@ -1,4 +1,4 @@
-// $Header: /cvsroot/l/li/libcw/src/libcwd/bfd.cc,v 1.90 2001/12/31 05:01:23 libcw Exp $
+// $Header: /cvsroot/l/li/libcw/src/libcwd/bfd.cc,v 1.91 2002/01/12 02:54:42 libcw Exp $
//
// Copyright (C) 2000 - 2001, by
//
@@ -956,18 +956,10 @@
#ifdef ALWAYS_PRINT_LOADING
// We want debug output to BFD
- bool const libcwd_was_off =
-#ifdef DEBUGDEBUG
- false;
-#else
- true;
-#endif
- if (libcwd_was_off)
- Debug( libcw_do.on() );
- bool bfd_was_off;
- Debug( bfd_was_off = !dc::bfd.is_on() );
- if (bfd_was_off)
- Debug( dc::bfd.on() );
+ libcw::debug::debug_ct::OnOffState state;
+ Debug( libcw_do.force_on(state) );
+ libcw::debug::channel_ct::OnOffState state2;
+ Debug( dc::bfd.force_on(state2, "BFD") );
#endif
// Initialize object files list, we don't really need the
@@ -1043,10 +1035,8 @@
BFD_RELEASE_WRITE_LOCK
#ifdef ALWAYS_PRINT_LOADING
- if (libcwd_was_off)
- Debug( libcw_do.off() );
- if (bfd_was_off)
- Debug( dc::bfd.off() );
+ Debug( dc::bfd.restore(state2) );
+ Debug( libcw_do.restore(state) );
#endif
WST_initialized = true; // MT: Safe, this function is Single Threaded.
Index: src/libcwd/configure.in
diff -u src/libcwd/configure.in:1.94 src/libcwd/configure.in:1.95
--- src/libcwd/configure.in:1.94 Tue Jan 8 15:39:18 2002
+++ src/libcwd/configure.in Fri Jan 11 18:54:42 2002
@@ -1,5 +1,5 @@
dnl Process this file with autoconf to produce a configure script.
-AC_REVISION($Revision: 1.94 $)dnl
+AC_REVISION($Revision: 1.95 $)dnl
dnl General intialization of `autoconf' varaibles.
dnl Ensure that the directory specified with --srcdir was correct
@@ -159,8 +159,6 @@
dnl Configuration needed by the testsuite, extract this from the generated 'libtool'
enable_shared=`./libtool --config | grep '^build_libtool_libs=' | sed -e 's/build_libtool_libs=//'`
enable_static=`./libtool --config | grep '^build_old_libs=' | sed -e 's/build_old_libs=//'`
-AC_SUBST(enable_shared)
-AC_SUBST(enable_static)
if test $enable_shared = yes; then
if expr "$host" : ".*openbsd.*" >/dev/null; then
AC_MSG_ERROR([
@@ -220,6 +218,7 @@
dnl Configuration needed by the testsuite
AC_SUBST(enable_shared)
AC_SUBST(enable_static)
+AC_SUBST(libcwd_config_threading)
if test "$libcwd_config_alloc" = yes; then
CW_CONFIG_DEBUGMALLOC=define
Index: src/libcwd/debug.cc
diff -u src/libcwd/debug.cc:1.52 src/libcwd/debug.cc:1.53
--- src/libcwd/debug.cc:1.52 Thu Jan 10 06:33:01 2002
+++ src/libcwd/debug.cc Fri Jan 11 18:54:42 2002
@@ -1,4 +1,4 @@
-// $Header: /cvsroot/l/li/libcw/src/libcwd/debug.cc,v 1.52 2002/01/10 14:33:01 libcw Exp $
+// $Header: /cvsroot/l/li/libcw/src/libcwd/debug.cc,v 1.53 2002/01/12 02:54:42 libcw Exp $
//
// Copyright (C) 2000 - 2001, by
//
@@ -950,22 +950,20 @@
corelim.rlim_cur = corelim.rlim_max;
if (corelim.rlim_max != RLIM_INFINITY)
{
- _off = -1;
+ OnOffState state;
+ force_on(state);
// The cast is necessary on platforms where corelim.rlim_max is long long
// and libstdc++ was not compiled with support for long long.
Dout(dc::warning, "core size is limited (hard limit: " << (unsigned long)(corelim.rlim_max / 1024) << " kb). Core dumps might be truncated!");
-#ifndef DEBUGDEBUGOUTPUT
- _off = 0;
-#endif
+ restore(state);
}
if (setrlimit(RLIMIT_CORE, &corelim))
DoutFatal(dc::fatal|error_cf, "unlimit core size failed");
#else
- _off = -1;
+ OnOffState state;
+ force_on(state);
Dout(dc::warning, "Please unlimit core size manually");
-#ifndef DEBUGDEBUGOUTPUT
- _off = 0;
-#endif
+ restore(state);
#endif
}
}
@@ -1106,10 +1104,10 @@
LIBCWD_TSD_DECLARATION
#ifdef LIBCWD_THREAD_SAFE
- // MT: Take advantage of the `write_max_len_instance' lock to prevend simultaneous access
+ // MT: Take advantage of the `write_max_len_instance' lock to prefend simultaneous access
// to `next_index' in the case of simultaneously dlopen-loaded libraries.
static int next_index;
- WNS_index = next_index++;
+ WNS_index = ++next_index; // Don't use index 0, it is used to make sure that uninitialized channels appear to be off.
_private_::mutex_tct<_private_::write_max_len_instance>::unlock();
@@ -1334,6 +1332,49 @@
}
} // namespace _private_
+
+ void debug_ct::force_on(debug_ct::OnOffState& state)
+ {
+ NS_init();
+ state._off = _off;
+#ifdef DEBUGDEBUGOUTPUT
+ state.first_time = first_time;
+#endif
+ _off = -1; // Turn object on.
+ }
+
+ void debug_ct::restore(debug_ct::OnOffState const& state)
+ {
+#ifdef DEBUGDEBUGOUTPUT
+ if (state.first_time != first_time) // state.first_time && !first_time.
+ core_dump(); // on() was called without first a call to off().
+#endif
+ if (_off != -1)
+ core_dump(); // off() and on() where called and not in equal pairs.
+ _off = state._off; // Restore.
+ }
+
+ void channel_ct::force_on(channel_ct::OnOffState& state, char const* label)
+ {
+ NS_initialize(label);
+#ifdef LIBCWD_THREAD_SAFE
+ LIBCWD_TSD_DECLARATION
+ int& off_cnt(__libcwd_tsd.off_cnt_array[WNS_index]);
+#endif
+ state.off_cnt = off_cnt;
+ off_cnt = -1; // Turn channel on.
+ }
+
+ void channel_ct::restore(channel_ct::OnOffState const& state)
+ {
+#ifdef LIBCWD_THREAD_SAFE
+ LIBCWD_TSD_DECLARATION
+ int& off_cnt(__libcwd_tsd.off_cnt_array[WNS_index]);
+#endif
+ if (off_cnt != -1)
+ core_dump(); // off() and on() where called and not in equal pairs.
+ off_cnt = state.off_cnt; // Restore.
+ }
} // namespace debug
} // namespace libcw
Index: src/libcwd/elf32.cc
diff -u src/libcwd/elf32.cc:1.32 src/libcwd/elf32.cc:1.33
--- src/libcwd/elf32.cc:1.32 Thu Jan 10 18:23:32 2002
+++ src/libcwd/elf32.cc Fri Jan 11 18:54:42 2002
@@ -1,4 +1,4 @@
-// $Header: /cvsroot/l/li/libcw/src/libcwd/elf32.cc,v 1.32 2002/01/11 02:23:32 libcw Exp $
+// $Header: /cvsroot/l/li/libcw/src/libcwd/elf32.cc,v 1.33 2002/01/12 02:54:42 libcw Exp $
//
// Copyright (C) 2001, by
//
@@ -1886,23 +1886,18 @@
M_inside_find_nearest_line = true;
#if DEBUGSTABS || DEBUGDWARF
int off = libcw::debug::libcw_do._off;
- libcw::debug::libcw_do._off = -1; // Force debug output on.
- int cnt = 0;
- Debug(
- while(!dc::bfd.is_on())
- {
- ++cnt;
- dc::bfd.on();
- }
- );
+ libcw::debug::debug_ct::OnOffState state;
+ Debug( libcw_do.force_on(state) );
+ libcw::debug::channel_ct::OnOffState state2;
+ Debug( dc::bfd.force_on(state2, "BFD") );
#endif
if (M_dwarf_debug_line_section_index)
load_dwarf();
else if (M_stabs_section_index)
load_stabs();
#if DEBUGSTABS || DEBUGDWARF
- Debug( while(cnt) { --cnt; dc::bfd.off(); } );
- libcw::debug::libcw_do._off = off;
+ Debug( dc::bfd.restore(state2) );
+ Debug( libcw_do.restore(state) );
#endif
M_inside_find_nearest_line = false;
#ifdef LIBCWD_THREAD_SAFE
Index: src/libcwd/include/libcw/class_channel.h
diff -u src/libcwd/include/libcw/class_channel.h:1.3 src/libcwd/include/libcw/class_channel.h:1.4
--- src/libcwd/include/libcw/class_channel.h:1.3 Tue Jan 8 15:04:59 2002
+++ src/libcwd/include/libcw/class_channel.h Fri Jan 11 18:54:42 2002
@@ -1,4 +1,4 @@
-// $Header: /cvsroot/l/li/libcw/src/libcwd/include/libcw/class_channel.h,v 1.3 2002/01/08 23:04:59 libcw Exp $
+// $Header: /cvsroot/l/li/libcw/src/libcwd/include/libcw/class_channel.h,v 1.4 2002/01/12 02:54:42 libcw Exp $
//
// Copyright (C) 2000 - 2001, by
//
@@ -122,6 +122,13 @@
void off(void);
void on(void);
+
+ struct OnOffState {
+ int off_cnt;
+ };
+
+ void force_on(OnOffState& state, char const* label);
+ void restore(OnOffState const& state);
public:
//---------------------------------------------------------------------------
Index: src/libcwd/include/libcw/class_debug.h
diff -u src/libcwd/include/libcw/class_debug.h:1.2 src/libcwd/include/libcw/class_debug.h:1.3
--- src/libcwd/include/libcw/class_debug.h:1.2 Sat Dec 29 20:17:50 2001
+++ src/libcwd/include/libcw/class_debug.h Fri Jan 11 18:54:42 2002
@@ -1,4 +1,4 @@
-// $Header: /cvsroot/l/li/libcw/src/libcwd/include/libcw/class_debug.h,v 1.2 2001/12/30 04:17:50 libcw Exp $
+// $Header: /cvsroot/l/li/libcw/src/libcwd/include/libcw/class_debug.h,v 1.3 2002/01/12 02:54:42 libcw Exp $
//
// Copyright (C) 2000 - 2001, by
//
@@ -236,6 +236,16 @@
void set_ostream(std::ostream* os);
void off(void);
void on(void);
+
+ struct OnOffState {
+ int _off;
+#ifdef DEBUGDEBUGOUTPUT
+ bool first_time;
+#endif
+ };
+
+ void force_on(OnOffState& state);
+ void restore(OnOffState const& state);
#ifdef DEBUGDEBUGOUTPUT
// Since with DEBUGDEBUG defined we start with _off is -1 instead of 0,
Index: src/libcwd/include/libcw/private_threading.h
diff -u src/libcwd/include/libcw/private_threading.h:1.6 src/libcwd/include/libcw/private_threading.h:1.7
--- src/libcwd/include/libcw/private_threading.h:1.6 Wed Jan 9 17:28:46 2002
+++ src/libcwd/include/libcw/private_threading.h Fri Jan 11 18:54:42 2002
@@ -1,4 +1,4 @@
-// $Header: /cvsroot/l/li/libcw/src/libcwd/include/libcw/private_threading.h,v 1.6 2002/01/10 01:28:46 libcw Exp $
+// $Header: /cvsroot/l/li/libcw/src/libcwd/include/libcw/private_threading.h,v 1.7 2002/01/12 02:54:42 libcw Exp $
//
// Copyright (C) 2001, by
//
@@ -474,11 +474,15 @@
TSD new_TSD;
S_temporary_instance = &new_TSD;
S_initializing = true;
- LIBCWD_TSD_DECLARATION
- set_alloc_checking_off(LIBCWD_TSD);
+ set_alloc_checking_off(new_TSD);
TSD* instance = new TSD;
- set_alloc_checking_on(LIBCWD_TSD);
+ set_alloc_checking_on(new_TSD);
pthread_setspecific(S_key, instance);
+ // Because pthread_setspecific calls calloc, it is possible that in
+ // the mean time all of libcwd was initialized. Therefore we need
+ // to copy the temporary TSD to the real TSD because it might
+ // contain relevant information.
+ *instance = new_TSD; // This will not call malloc() et al, and thus not change new_TSD while we're copying it.
S_initializing = false;
S_WNS_initialized = true;
mutex_tct<tsd_initialization_instance>::unlock();
----------------------- End of diff -----------------------
|