libcw-cvs-patches Mailing List for libcw (Page 2)
Abandoned project
Status: Beta
Brought to you by:
libcw
You can subscribe to this list here.
2001 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(13) |
Dec
(60) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2002 |
Jan
(60) |
Feb
(54) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Carlo W. <li...@us...> - 2002-02-15 05:19:44
|
CVSROOT : /cvsroot/libcw Module : src Commit time: 2002-01-15 05:19:42 UTC Modified files: libcwd/NEWS libcwd/acconfig.h libcwd/bfd.cc libcwd/configure.in libcwd/documentation/styles/Makefile libcwd/documentation/styles/defines.h libcwd/documentation/styles/main.css libcwd/documentation/tutorial/tut1.m4 libcwd/include/sys.ho.in Log message: Several bug fixes. ---------------------- diff included ---------------------- Index: src/libcwd/NEWS diff -u src/libcwd/NEWS:1.69 src/libcwd/NEWS:1.70 --- src/libcwd/NEWS:1.69 Thu Feb 14 10:43:23 2002 +++ src/libcwd/NEWS Thu Feb 14 21:19:31 2002 @@ -1,3 +1,22 @@ +libcwd-0.99.17 + + Bug fixes: + + Libcwd failed to find an executable in the current directory + when one of the command line parameters contained a '/'. + + The tutorial had several occurances of '<' where '<' should + have been used, with as result that parts of example code didn't + show up in a browser. + + `pthread_kill_other_threads_np' was not detected by ./configure. + + Due to a problem with how RedHat ships fonts, using mozilla, + italic helvetica looks horrible. The documentation now uses + plain 'sans-serif' instead which will use the default font + that is defined under preferences -> appearance -> fonts. + This should be set to -adobe-helvetica-*-. + libcwd-0.99.16 * libcwd is now thread-safe * Index: src/libcwd/acconfig.h diff -u src/libcwd/acconfig.h:1.11 src/libcwd/acconfig.h:1.12 --- src/libcwd/acconfig.h:1.11 Sun Feb 10 19:00:24 2002 +++ src/libcwd/acconfig.h Thu Feb 14 21:19:31 2002 @@ -22,6 +22,9 @@ // Defined when both -lpthread and pthread.h could be found. #undef LIBCWD_HAVE_PTHREAD +// This is needed when using threading, for example to get `pthread_kill_other_threads_np'. +#undef _GNU_SOURCE + // Defined when --enable-libcwd-threading is used. #undef LIBCWD_THREAD_SAFE @BOTTOM@ Index: src/libcwd/bfd.cc diff -u src/libcwd/bfd.cc:1.102 src/libcwd/bfd.cc:1.103 --- src/libcwd/bfd.cc:1.102 Thu Feb 14 10:43:23 2002 +++ src/libcwd/bfd.cc Thu Feb 14 21:19:31 2002 @@ -1,4 +1,4 @@ -// $Header: /cvsroot/l/li/libcw/src/libcwd/bfd.cc,v 1.102 2002/02/14 18:43:23 libcw Exp $ +// $Header: /cvsroot/l/li/libcw/src/libcwd/bfd.cc,v 1.103 2002/02/15 05:19:31 libcw Exp $ // // Copyright (C) 2000 - 2001, by // @@ -782,15 +782,16 @@ DoutFatal(dc::fatal|error_cf, "Failed to execute \"" << ps_prog << "\""); } - //std::cerr << "argv0 = \"" << argv0 << '"' << std::endl; - if (argv0.find('/') != 0) + argv0 += '\0'; + // argv0 now contains a zero terminated string optionally followed by the command line + // arguments (which is why we can't use argv0.find('/') here), all seperated by the 0 character. + if (!strchr(argv0.data(), '/')) { _private_::ST_internal_string prog_name(argv0); _private_::ST_internal_string path_list(getenv("PATH")); _private_::ST_internal_string::size_type start_pos = 0, end_pos; _private_::ST_internal_string path; struct stat finfo; - prog_name += '\0'; for (;;) { end_pos = path_list.find(':', start_pos); Index: src/libcwd/configure.in diff -u src/libcwd/configure.in:1.103 src/libcwd/configure.in:1.104 --- src/libcwd/configure.in:1.103 Tue Feb 12 21:41:24 2002 +++ src/libcwd/configure.in Thu Feb 14 21:19:32 2002 @@ -1,5 +1,5 @@ dnl Process this file with autoconf to produce a configure script. -AC_REVISION($Revision: 1.103 $)dnl +AC_REVISION($Revision: 1.104 $)dnl dnl General intialization of `autoconf' varaibles. dnl Ensure that the directory specified with --srcdir was correct @@ -368,13 +368,6 @@ * include posix threads by itself and I can't find -lpthread. * Use --disable-libcwd-threading to compile a libcwd that is not thread safe. ])]) - AC_LANG_RESTORE - CW_CONFIG_THREAD_SAFE=define - SAVE_LIBS="$LIBS" - LIBS="$LIBS $LIB_THREADS" - AC_CHECK_FUNCS(pthread_kill_other_threads_np) - LIBS="$SAVE_LIBS" - if test "$ac_cv_search_pthread_create" = "none required"; then dnl Even if nothing is required, we still need to use -lpthread explicitly dnl while linking a shared library, otherwise the versioning info of @@ -382,6 +375,17 @@ dnl itself even!. AC_CHECK_LIB(pthread, pthread_create, [LIB_THREADS_SHARED=-lpthread]) fi + + AC_LANG_RESTORE + CW_CONFIG_THREAD_SAFE=define + + dnl pthread_kill_other_threads_np is a GNU extension, therefore we need to + dnl define _GNU_SOURCE. The extension also needs -lpthread to be available. + AC_DEFINE_UNQUOTED(_GNU_SOURCE, "1") + SAVE_LIBS="$LIBS" + LIBS="$LIBS $LIB_THREADS $LIB_THREADS_SHARED" + AC_CHECK_FUNCS(pthread_kill_other_threads_np) + LIBS="$SAVE_LIBS" fi dnl This test needs the full set of libraries we just determined. Index: src/libcwd/documentation/styles/Makefile diff -u src/libcwd/documentation/styles/Makefile:1.2 src/libcwd/documentation/styles/Makefile:1.3 --- src/libcwd/documentation/styles/Makefile:1.2 Sat Dec 29 20:17:48 2001 +++ src/libcwd/documentation/styles/Makefile Thu Feb 14 21:19:32 2002 @@ -4,15 +4,15 @@ all: $(OUTPUT) -%/main.css: main.css +%/main.css: main.css defines.h @MACRO=`echo $@ | sed -e 's%\([^/]*\)/.*%\1%' | tr a-z A-Z`; \ cat main.css | gcc -D$$MACRO -E -c - | egrep -v '^(#|$$)' > $@ -%/doxygen.css: doxygen.css +%/doxygen.css: doxygen.css defines.h @MACRO=`echo $@ | sed -e 's%\([^/]*\)/.*%\1%' | tr a-z A-Z`; \ cat doxygen.css | gcc -D$$MACRO -E -c - | egrep -v '^(#|$$)' > $@ -%/tutorial.css: tutorial.css +%/tutorial.css: tutorial.css defines.h @MACRO=`echo $@ | sed -e 's%\([^/]*\)/.*%\1%' | tr a-z A-Z`; \ cat tutorial.css | gcc -D$$MACRO -E -c - | egrep -v '^(#|$$)' > $@ Index: src/libcwd/documentation/styles/defines.h diff -u src/libcwd/documentation/styles/defines.h:1.2 src/libcwd/documentation/styles/defines.h:1.3 --- src/libcwd/documentation/styles/defines.h:1.2 Sat Dec 29 20:17:48 2001 +++ src/libcwd/documentation/styles/defines.h Thu Feb 14 21:19:32 2002 @@ -23,6 +23,13 @@ #endif #define NORMAL_FONT font-family: arial, sans-serif; font-size: NORMAL_SIZE; font-size-adjust: none +/* Don't use helvetica, it is broken on RedHat which has an alias "-alias-helvetica-medium-i-normal--*-iso8859-1" + * installed that is actually a horrible looking japanese font. See https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=59911 */ +#ifndef IE +#define NORMAL_ITALICS_FONT font-family: sans-serif; font-size: NORMAL_SIZE; font-size-adjust: none +#else +#define NORMAL_ITALICS_FONT NORMAL_FONT +#endif #ifdef KONQUEROR #define HSIZE1 24pt Index: src/libcwd/documentation/styles/main.css diff -u src/libcwd/documentation/styles/main.css:1.2 src/libcwd/documentation/styles/main.css:1.3 --- src/libcwd/documentation/styles/main.css:1.2 Sat Dec 29 20:17:48 2001 +++ src/libcwd/documentation/styles/main.css Thu Feb 14 21:19:32 2002 @@ -216,3 +216,11 @@ font-size : NORMAL_SIZE; } +I { + NORMAL_ITALICS_FONT +} + +EM { + NORMAL_ITALICS_FONT +} + Index: src/libcwd/documentation/tutorial/tut1.m4 diff -u src/libcwd/documentation/tutorial/tut1.m4:1.5 src/libcwd/documentation/tutorial/tut1.m4:1.6 --- src/libcwd/documentation/tutorial/tut1.m4:1.5 Thu Feb 14 15:32:12 2002 +++ src/libcwd/documentation/tutorial/tut1.m4 Thu Feb 14 21:19:32 2002 @@ -13,14 +13,16 @@ <P>Compile as: <SPAN class="shell-command">g++ -g -DCWDEBUG hello_world.cc -lcwd -o hello_world</SPAN></P> <PRE> -#define _GNU_SOURCE // This must be defined before including <libcw/sysd.h> -#include <libcw/sysd.h> // This must be the first header file +// These two lines should actually be part of a custom "sys.h" file. See <A HREF="tut2.html">tutorial 2</A>. +#define _GNU_SOURCE // This must be defined before including <libcw/sysd.h> +#include <libcw/sysd.h> // This must be the first header file +// This line should actually be part of a custom "debug.h" file. See <A HREF="tut2.html">tutorial 2</A>. #include <libcw/debug.h> int main(void) { - Debug( dc::notice.on() ); // Turn on the NOTICE Debug Channel - Debug( libcw_do.on() ); // Turn on the default Debug Object + Debug( dc::notice.on() ); // Turn on the NOTICE Debug Channel. + Debug( libcw_do.on() ); // Turn on the default Debug Object. Dout( dc::notice, "Hello World" ); @@ -37,7 +39,7 @@ In order to make you explicitely aware of the fact that it is defined, libcwd does not define this macro itself (which it could do inside <libcw/sysd.h>), but forces you to define it when using libcwd. -Note you only really have to define it when you compiled libcwd with +Note that you only really have to define it when you compiled libcwd with threading support. If you do not define this macro and libcwd needs it, then you will get a compile error in <libcw/sysd.h> telling you so.</P> Index: src/libcwd/include/sys.ho.in diff -u src/libcwd/include/sys.ho.in:1.7 src/libcwd/include/sys.ho.in:1.8 --- src/libcwd/include/sys.ho.in:1.7 Tue Jan 8 15:04:59 2002 +++ src/libcwd/include/sys.ho.in Thu Feb 14 21:19:32 2002 @@ -1,5 +1,5 @@ // @configure_input@ -// $Header: /cvsroot/l/li/libcw/src/libcwd/include/sys.ho.in,v 1.7 2002/01/08 23:04:59 libcw Exp $ +// $Header: /cvsroot/l/li/libcw/src/libcwd/include/sys.ho.in,v 1.8 2002/02/15 05:19:32 libcw Exp $ // // Copyright (C) 2000 - 2001, by // @@ -20,7 +20,7 @@ // // Use all GNU extensions. // -#ifndef _GNU_SOURCE +#if !defined(_GNU_SOURCE) && defined(LIBCWD_THREAD_SAFE) #define _GNU_SOURCE #endif ----------------------- End of diff ----------------------- |
From: Carlo W. <li...@us...> - 2002-02-14 23:32:25
|
CVSROOT : /cvsroot/libcw Module : src Commit time: 2002-01-14 23:32:23 UTC Modified files: libcwd/documentation/tutorial/faq.m4 libcwd/documentation/tutorial/tut1.m4 libcwd/documentation/tutorial/tut2.m4 libcwd/documentation/tutorial/tut5.in Log message: Errors (using '<' instead of <) in tutorial. ---------------------- diff included ---------------------- Index: src/libcwd/documentation/tutorial/faq.m4 diff -u src/libcwd/documentation/tutorial/faq.m4:1.4 src/libcwd/documentation/tutorial/faq.m4:1.5 --- src/libcwd/documentation/tutorial/faq.m4:1.4 Thu Feb 7 20:03:47 2002 +++ src/libcwd/documentation/tutorial/faq.m4 Thu Feb 14 15:32:12 2002 @@ -295,7 +295,7 @@ Dout(dc::notice, "An error occured"); exit(0); - cerr << "We should never reach this\n"; + cerr << "We should never reach this\n"; </PRE> <P>If the complete line <SPAN class="code">Dout(dc::notice, "An error occured");</SPAN>, @@ -309,7 +309,7 @@ if (error) Dout(dc::notice, "An error occured"); else - cout << "Everything is ok\n"; + cout << "Everything is ok\n"; </PRE> <P>because after macro expansion that would become:</P> @@ -318,8 +318,8 @@ if (error) ; ; - else // <-- syntax error - cout << "Everything is ok\n"; + else // <-- syntax error + cout << "Everything is ok\n"; </PRE> <A name="LibcwDout"></A> @@ -341,7 +341,7 @@ <PRE class="code"> if (debug object and any of the debug channels are turned on) - the_ostream << your message; + the_ostream << your message; </PRE> <P>and so, "your message" is <EM>not</EM> evaluated when it isn't also Index: src/libcwd/documentation/tutorial/tut1.m4 diff -u src/libcwd/documentation/tutorial/tut1.m4:1.4 src/libcwd/documentation/tutorial/tut1.m4:1.5 --- src/libcwd/documentation/tutorial/tut1.m4:1.4 Fri Feb 8 13:32:13 2002 +++ src/libcwd/documentation/tutorial/tut1.m4 Thu Feb 14 15:32:12 2002 @@ -114,7 +114,7 @@ <CODE>dc::notice</CODE> is turned on.</P> <P>Output is written as if everything in the second field of the macro <CODE>Dout</CODE> is -written to an ostream; It is "equivalent" with: <CODE>cerr << "Hello World" << '\n';</CODE></P> +written to an ostream; It is "equivalent" with: <CODE>cerr << "Hello World" << '\n';</CODE></P> <DIV class="faq-frame"><H4>FAQ</H4><UL class="faq"> <LI><A HREF="faq.html#macros">Why is <CODE>Dout</CODE> a macro and not a template?</A></LI> Index: src/libcwd/documentation/tutorial/tut2.m4 diff -u src/libcwd/documentation/tutorial/tut2.m4:1.3 src/libcwd/documentation/tutorial/tut2.m4:1.4 --- src/libcwd/documentation/tutorial/tut2.m4:1.3 Thu Feb 7 20:03:47 2002 +++ src/libcwd/documentation/tutorial/tut2.m4 Thu Feb 14 15:32:12 2002 @@ -41,19 +41,19 @@ #define ForAllDebugObjects(STATEMENT) #define LibcwDebug(dc_namespace, x) #define LibcwDout(a, b, c, d) -#define LibcwDoutFatal(a, b, c, d) do { ::std::cerr << d << ::std::endl; ::std::exit(254); } while(1) +#define LibcwDoutFatal(a, b, c, d) do { ::std::cerr << d << ::std::endl; ::std::exit(254); } while(1) #define NEW(x) new x #else // CWDEBUG #ifndef DEBUGCHANNELS -// This must be defined before <libcw/debug.h> is included and must be the +// This must be defined before <libcw/debug.h> is included and must be the // name of the namespace containing your `dc' namespace (see below). // You can use any namespace(s) you like, except existing namespaces // (like ::, ::std and ::libcw). #define DEBUGCHANNELS ::myproject::debug::channels #endif -#include <libcw/debug.h> +#include <libcw/debug.h> namespace myproject { namespace debug { Index: src/libcwd/documentation/tutorial/tut5.in diff -u src/libcwd/documentation/tutorial/tut5.in:1.2 src/libcwd/documentation/tutorial/tut5.in:1.3 --- src/libcwd/documentation/tutorial/tut5.in:1.2 Sat Dec 29 20:17:49 2001 +++ src/libcwd/documentation/tutorial/tut5.in Thu Feb 14 15:32:13 2002 @@ -552,12 +552,12 @@ Debug( libcw_do.on() ); ForAllDebugChannels( if (!debugChannel.is_on()) debugChannel.on() ); - Debug( libcw_do.<SPAN class="highlight">set_margin</SPAN>("<-- margin -->") ); - Debug( libcw_do.<SPAN class="highlight">set_marker</SPAN>("<-- marker -->") ); + Debug( libcw_do.<SPAN class="highlight">set_margin</SPAN>("<-- margin -->") ); + Debug( libcw_do.<SPAN class="highlight">set_marker</SPAN>("<-- marker -->") ); Dout( dc::cat|dc::mouse, "The cat chases the mouse." ); Dout( dc::mouse|dc::elephant, "The mouse chases the elephant." ); Dout( dc::notice|<SPAN class="highlight">nolabel_cf</SPAN>, "Setting indentation to 8 spaces:" ); - Dout( dc::notice|<SPAN class="highlight">blank_label_cf</SPAN>, "<------>" ); + Dout( dc::notice|<SPAN class="highlight">blank_label_cf</SPAN>, "<------>" ); Debug( libcw_do.<SPAN class="highlight">set_indent(8)</SPAN> ); Dout( dc::cat, "The cat sleeps." ); Dout( dc::elephant, "The elephant looks around:" ); ----------------------- End of diff ----------------------- |
From: Carlo W. <li...@us...> - 2002-02-14 18:43:39
|
CVSROOT : /cvsroot/libcw Module : src Commit time: 2002-01-14 18:43:33 UTC Modified files: libcwd/NEWS libcwd/bfd.cc libcwd/documentation/Makefile Log message: Temporary fix for reported bug. ---------------------- diff included ---------------------- Index: src/libcwd/NEWS diff -u src/libcwd/NEWS:1.68 src/libcwd/NEWS:1.69 --- src/libcwd/NEWS:1.68 Sun Feb 10 19:00:24 2002 +++ src/libcwd/NEWS Thu Feb 14 10:43:23 2002 @@ -13,7 +13,7 @@ New are environment variables that influence libcwd. At the moment there are two: LIBCWD_NO_STARTUP_MSGS : Don't print anything before main(). - LIBCWD_ALWAYS_PRINT_LOADING : Print messages about loading + LIBCWD_PRINT_LOADING : Print messages about loading the shared libraries, even when this is done before libcw_do is turned on (except when LIBCWD_NO_STARTUP_MSGS is defined). Index: src/libcwd/bfd.cc diff -u src/libcwd/bfd.cc:1.101 src/libcwd/bfd.cc:1.102 --- src/libcwd/bfd.cc:1.101 Sat Feb 9 18:42:16 2002 +++ src/libcwd/bfd.cc Thu Feb 14 10:43:23 2002 @@ -1,4 +1,4 @@ -// $Header: /cvsroot/l/li/libcw/src/libcwd/bfd.cc,v 1.101 2002/02/10 02:42:16 libcw Exp $ +// $Header: /cvsroot/l/li/libcw/src/libcwd/bfd.cc,v 1.102 2002/02/14 18:43:23 libcw Exp $ // // Copyright (C) 2000 - 2001, by // @@ -782,7 +782,8 @@ DoutFatal(dc::fatal|error_cf, "Failed to execute \"" << ps_prog << "\""); } - if (argv0.find('/') == _private_::ST_internal_string::npos) + //std::cerr << "argv0 = \"" << argv0 << '"' << std::endl; + if (argv0.find('/') != 0) { _private_::ST_internal_string prog_name(argv0); _private_::ST_internal_string path_list(getenv("PATH")); Index: src/libcwd/documentation/Makefile diff -u src/libcwd/documentation/Makefile:1.2 src/libcwd/documentation/Makefile:1.3 --- src/libcwd/documentation/Makefile:1.2 Sat Dec 29 20:17:47 2001 +++ src/libcwd/documentation/Makefile Thu Feb 14 10:43:23 2002 @@ -15,7 +15,12 @@ -e 's/"sys\.h"/"<a class="code" href="#preparation_step2">sys.h<\/a>"/' \ > html/preparation.html rm html/preparation.tmp - + for i in `grep -l '<h2>Modules</h2>' html/*.html`; do \ + mv $$i $$i.tmp; \ + cat $$i.tmp | \ + sed -e 's%<h2>Modules</h2>%<h2>Related</h2>%' > $$i; \ + rm $$i.tmp; \ + done external: external/INSTALL external/sys.h external/debug.h external/debug.cc ----------------------- End of diff ----------------------- |
From: Carlo W. <li...@us...> - 2002-02-13 16:18:42
|
CVSROOT : /cvsroot/libcw Module : src Commit time: 2002-01-13 16:18:39 UTC Modified files: libcwd/documentation/scripts/load_style_sheets.js Log message: Needed for on-line inclusion of documentation on sourceforge. ---------------------- diff included ---------------------- Index: src/libcwd/documentation/scripts/load_style_sheets.js diff -u src/libcwd/documentation/scripts/load_style_sheets.js:1.2 src/libcwd/documentation/scripts/load_style_sheets.js:1.3 --- src/libcwd/documentation/scripts/load_style_sheets.js:1.2 Sat Dec 29 20:17:48 2001 +++ src/libcwd/documentation/scripts/load_style_sheets.js Wed Feb 13 08:18:29 2002 @@ -2,24 +2,25 @@ { var styles_path; var rootpath; - var rootpos = location.href.lastIndexOf("libcw.sourceforge.net"); + var rootpos; + rootpos = location.pathname.lastIndexOf("/documentation/"); if (rootpos != -1) - rootpath = location.href.substring(0,rootpos) + "libcw.sourceforge.net/"; + rootpath = location.pathname.substring(0,rootpos) + "/documentation/"; else { - rootpos = location.pathname.lastIndexOf("/html/"); - if (rootpos != -1) - rootpath = location.pathname.substring(0,rootpos) + "/"; + rootpos = location.href.lastIndexOf("libcw.sourceforge.net"); + if (rootpos != -1) + rootpath = location.href.substring(0,rootpos) + "libcw.sourceforge.net/"; else { - rootpos = location.pathname.lastIndexOf("/tutorial/"); + rootpos = location.pathname.lastIndexOf("/html/"); if (rootpos != -1) rootpath = location.pathname.substring(0,rootpos) + "/"; else { - rootpos = location.pathname.lastIndexOf("/documentation/"); - if (rootpos != -1) - rootpath = location.pathname.substring(0,rootpos) + "/documentation/"; + rootpos = location.pathname.lastIndexOf("/tutorial/"); + if (rootpos != -1) + rootpath = location.pathname.substring(0,rootpos) + "/"; } } } ----------------------- End of diff ----------------------- |
From: Carlo W. <li...@us...> - 2002-02-13 14:59:50
|
CVSROOT : /cvsroot/libcw Module : src Commit time: 2002-01-13 14:59:45 UTC Removed files: libcwd/wrapcnclpnts.c Log message: Remove old file. ---------------------- diff included ---------------------- Index: src/libcwd/wrapcnclpnts.c diff -u src/libcwd/wrapcnclpnts.c:1.3 src/libcwd/wrapcnclpnts.c:removed --- src/libcwd/wrapcnclpnts.c:1.3 Thu Jan 31 21:21:05 2002 +++ src/libcwd/wrapcnclpnts.c Wed Feb 13 06:59:45 2002 @@ -1,119 +0,0 @@ -#include <libcw/debug_config.h> // Needed for DEBUGDEBUGTHREADS - -#ifdef DEBUGDEBUGTHREADS - -#define _LARGEFILE64_SOURCE -#include <unistd.h> -#include <fcntl.h> -#include <sys/mman.h> -#include <pthread.h> -#include <stdarg.h> -#include <stddef.h> -#include <stdlib.h> -#include <termios.h> -#include <sys/resource.h> -#include <sys/wait.h> -#include <sys/socket.h> - -#define CANCELABLE_SYSCALL(res_type, name, param_list, params) \ -res_type __libc_##name param_list; \ -res_type \ -__attribute__ ((weak)) \ -name param_list \ -{ \ - res_type result; \ - int oldtype; \ - pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, &oldtype); \ - result = __libc_##name params; \ - pthread_setcanceltype (oldtype, NULL); \ - return result; \ -} - -#define CANCELABLE_SYSCALL_VA(res_type, name, param_list, params, last_arg) \ -res_type __libc_##name param_list; \ -res_type \ -__attribute__ ((weak)) \ -name param_list \ -{ \ - res_type result; \ - int oldtype; \ - va_list ap; \ - pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, &oldtype); \ - va_start (ap, last_arg); \ - result = __libc_##name params; \ - va_end (ap); \ - pthread_setcanceltype (oldtype, NULL); \ - return result; \ -} - -#define strong_alias(name, aliasname) extern __typeof (name) aliasname __attribute__ ((alias (#name))); - -CANCELABLE_SYSCALL (int, close, (int fd), (fd)) -strong_alias (close, __close) - -CANCELABLE_SYSCALL_VA (int, fcntl, (int fd, int cmd, ...), (fd, cmd, va_arg (ap, long int)), cmd) -strong_alias (fcntl, __fcntl) - -CANCELABLE_SYSCALL (int, fsync, (int fd), (fd)) - -CANCELABLE_SYSCALL (off_t, lseek, (int fd, off_t offset, int whence), (fd, offset, whence)) -strong_alias (lseek, __lseek) - -CANCELABLE_SYSCALL (off64_t, lseek64, (int fd, off64_t offset, int whence), (fd, offset, whence)) - -CANCELABLE_SYSCALL (int, msync, (__ptr_t addr, size_t length, int flags), (addr, length, flags)) - -CANCELABLE_SYSCALL (int, nanosleep, (const struct timespec *requested_time, struct timespec *remaining), (requested_time, remaining)) - -CANCELABLE_SYSCALL_VA (int, open, (const char *pathname, int flags, ...), (pathname, flags, va_arg (ap, mode_t)), flags) -strong_alias (open, __open) - -CANCELABLE_SYSCALL_VA (int, open64, (const char *pathname, int flags, ...), (pathname, flags, va_arg (ap, mode_t)), flags) -strong_alias (open64, __open64) - -CANCELABLE_SYSCALL (int, pause, (void), ()) - -CANCELABLE_SYSCALL (ssize_t, pread, (int fd, void *buf, size_t count, off_t offset), (fd, buf, count, offset)) - -CANCELABLE_SYSCALL (ssize_t, pread64, (int fd, void *buf, size_t count, off64_t offset), (fd, buf, count, offset)) -strong_alias (pread64, __pread64) - -CANCELABLE_SYSCALL (ssize_t, pwrite, (int fd, const void *buf, size_t n, off_t offset), (fd, buf, n, offset)) - -CANCELABLE_SYSCALL (ssize_t, pwrite64, (int fd, const void *buf, size_t n, off64_t offset), (fd, buf, n, offset)) -strong_alias (pwrite64, __pwrite64) - -CANCELABLE_SYSCALL (ssize_t, read, (int fd, void *buf, size_t count), (fd, buf, count)) -strong_alias (read, __read) - -CANCELABLE_SYSCALL (int, system, (const char *line), (line)) - -CANCELABLE_SYSCALL (int, tcdrain, (int fd), (fd)) - -CANCELABLE_SYSCALL (__pid_t, wait, (__WAIT_STATUS_DEFN stat_loc), (stat_loc)) -strong_alias (wait, __wait) - -CANCELABLE_SYSCALL (__pid_t, waitpid, (__pid_t pid, int *stat_loc, int options), (pid, stat_loc, options)) - -CANCELABLE_SYSCALL (ssize_t, write, (int fd, const void *buf, size_t n), (fd, buf, n)) -strong_alias (write, __write) - -CANCELABLE_SYSCALL (int, accept, (int fd, __SOCKADDR_ARG addr, socklen_t *addr_len), (fd, addr, addr_len)) - -CANCELABLE_SYSCALL (int, connect, (int fd, __CONST_SOCKADDR_ARG addr, socklen_t len), (fd, addr, len)) -strong_alias (connect, __connect) - -CANCELABLE_SYSCALL (ssize_t, recv, (int fd, __ptr_t buf, size_t n, int flags), (fd, buf, n, flags)) - -CANCELABLE_SYSCALL (ssize_t, recvfrom, (int fd, __ptr_t buf, size_t n, int flags, __SOCKADDR_ARG addr, socklen_t *addr_len), (fd, buf, n, flags, addr, addr_len)) - -CANCELABLE_SYSCALL (ssize_t, recvmsg, (int fd, struct msghdr *message, int flags), (fd, message, flags)) - -CANCELABLE_SYSCALL (ssize_t, send, (int fd, const __ptr_t buf, size_t n, int flags), (fd, buf, n, flags)) -strong_alias (send, __send) - -CANCELABLE_SYSCALL (ssize_t, sendmsg, (int fd, const struct msghdr *message, int flags), (fd, message, flags)) - -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 // DEBUGDEBUGTHREADS ----------------------- End of diff ----------------------- |
From: Carlo W. <li...@us...> - 2002-02-13 14:58:36
|
CVSROOT : /cvsroot/libcw Module : src Commit time: 2002-01-13 14:58:33 UTC Modified files: libcwd/libcwd.spec.in Log message: Update of spec file. ---------------------- diff included ---------------------- Index: src/libcwd/libcwd.spec.in diff -u src/libcwd/libcwd.spec.in:1.10 src/libcwd/libcwd.spec.in:1.11 --- src/libcwd/libcwd.spec.in:1.10 Wed Feb 13 06:45:50 2002 +++ src/libcwd/libcwd.spec.in Wed Feb 13 06:58:23 2002 @@ -17,9 +17,9 @@ %description Libcwd is a full-featured, professional, well documented library to support C++ developers with debugging their applications. It includes support for -ostream-based debug output, custom debug channels and devices, powerful -memory allocation debugging, run-time sourcefile:linenumber information and -demangled type-names of variables. +ostream-based debug output, custom debug channels and devices, threading, +powerful memory allocation debugging, run-time sourcefile:linenumber +information and demangled type-names of variables. %prep %setup @@ -41,7 +41,8 @@ echo echo "Please look at %{__prefix}/doc/libcwd-%{version}/example-project.tar.gz" echo "for an example of how to write an application that uses libcwd." -echo "Detailed documentation can be found in file://%{__prefix}/doc/libcwd-%{version}/html/index.html" +echo "Detailed documentation can be found in" +echo "file://%{__prefix}/doc/libcwd-%{version}/html/index.html" echo %files @@ -60,6 +61,9 @@ %{__prefix}/include/libcw/* %changelog +* Wed Feb 13 2002 Carlo Wood <li...@al...> +- Allow also version of autoconf larger than 2.13. + * Sun Dec 09 2001 Carlo Wood <li...@al...> - Added a URL: and BuildPrereq: entry. - Added doxygen documentation to the rpm. ----------------------- End of diff ----------------------- |
From: Carlo W. <li...@us...> - 2002-02-13 14:46:06
|
CVSROOT : /cvsroot/libcw Module : src Commit time: 2002-01-13 14:46:01 UTC Modified files: libcwd/libcwd.spec.in libcwd/include/libcw/Makefile.am Log message: rpm build and install bug fixes. ---------------------- diff included ---------------------- Index: src/libcwd/include/libcw/Makefile.am diff -u src/libcwd/include/libcw/Makefile.am:1.24 src/libcwd/include/libcw/Makefile.am:1.25 --- src/libcwd/include/libcw/Makefile.am:1.24 Tue Feb 12 19:55:26 2002 +++ src/libcwd/include/libcw/Makefile.am Wed Feb 13 06:45:50 2002 @@ -60,5 +60,6 @@ MAINTAINERCLEANFILES = Makefile.in install-data-local: + $(mkinstalldirs) $(DESTDIR)$(libcwddir) $(INSTALL_DATA) $(EXTRA_HEADERS) $(DESTDIR)$(libcwddir) Index: src/libcwd/libcwd.spec.in diff -u src/libcwd/libcwd.spec.in:1.9 src/libcwd/libcwd.spec.in:1.10 --- src/libcwd/libcwd.spec.in:1.9 Sat Dec 29 20:17:47 2001 +++ src/libcwd/libcwd.spec.in Wed Feb 13 06:45:50 2002 @@ -11,7 +11,7 @@ Requires: gcc-c++ >= 2.95.1, binutils >= 2.9 %endif Buildroot: %{_tmppath}/%{name}-root -BuildPrereq: make, m4, which >= 2.5, autoconf = 2.13, automake >= 1.4p1, libtool >= 1.4 +BuildPrereq: make, m4, which >= 2.5, autoconf >= 2.13, automake >= 1.4p1, libtool >= 1.4 URL: http://libcw.sourceforge.net/debugging/ %description ----------------------- End of diff ----------------------- |
From: Carlo W. <li...@us...> - 2002-02-13 05:41:35
|
CVSROOT : /cvsroot/libcw Module : src Commit time: 2002-01-13 05:41:34 UTC Modified files: libcwd/configure.in Log message: Configure options help text update. ---------------------- diff included ---------------------- Index: src/libcwd/configure.in diff -u src/libcwd/configure.in:1.102 src/libcwd/configure.in:1.103 --- src/libcwd/configure.in:1.102 Fri Feb 8 19:22:59 2002 +++ src/libcwd/configure.in Tue Feb 12 21:41:24 2002 @@ -1,5 +1,5 @@ dnl Process this file with autoconf to produce a configure script. -AC_REVISION($Revision: 1.102 $)dnl +AC_REVISION($Revision: 1.103 $)dnl dnl General intialization of `autoconf' varaibles. dnl Ensure that the directory specified with --srcdir was correct @@ -49,8 +49,8 @@ AC_SUBST(CW_CONFIG_BUILTIN_RETURN_ADDRESS_OFFSET) dnl Manual configuration options of libcwd. -AC_ARG_ENABLE(libcwd, -[Options of package libcwd:]) +AC_ARG_ENABLE(libcwd, [ +Options of package libcwd:]) libcwd_config_alloc=yes AC_ARG_ENABLE(libcwd-alloc, @@ -69,8 +69,8 @@ libcwd_config_location=yes AC_ARG_ENABLE(libcwd-location, - [ --disable-libcwd-location disable the ability to lookup source file and line number, - you might need this on a non-ELF32 system.], + [ --disable-libcwd-location disable the ability to lookup source file and line + number, you might need this on a non-ELF32 system.], libcwd_config_location=$enableval) libcwd_config_bfd=no ----------------------- End of diff ----------------------- |
From: Carlo W. <li...@us...> - 2002-02-13 04:04:06
|
CVSROOT : /cvsroot/libcw Module : src Commit time: 2002-01-13 04:04:06 UTC Modified files: libcwd/debug.cc Log message: Small documentation update. ---------------------- diff included ---------------------- Index: src/libcwd/debug.cc diff -u src/libcwd/debug.cc:1.68 src/libcwd/debug.cc:1.69 --- src/libcwd/debug.cc:1.68 Tue Feb 12 19:55:25 2002 +++ src/libcwd/debug.cc Tue Feb 12 20:03:56 2002 @@ -1,4 +1,4 @@ -// $Header: /cvsroot/l/li/libcw/src/libcwd/debug.cc,v 1.68 2002/02/13 03:55:25 libcw Exp $ +// $Header: /cvsroot/l/li/libcw/src/libcwd/debug.cc,v 1.69 2002/02/13 04:03:56 libcw Exp $ // // Copyright (C) 2000 - 2001, by // @@ -1529,8 +1529,8 @@ * \ingroup group_destination * * Assign a new \c ostream to this %debug object. - * The \c ostream will only be written to after obtaining the lock - * that is passed as second argument. + * The \c ostream will only be written to after acquiring the + * pthread mutex passed in the second argument. * * <b>Example:</b> * @@ -1568,10 +1568,11 @@ #endif // LIBCWD_THREAD_SAFE /** - * \brief Set output device. + * \brief Set output device (single threaded applications). * \ingroup group_destination * * Assign a new \c ostream to this %debug object (default is <CODE>std::cerr</CODE>). + * For use in single threaded applications only. */ void debug_ct::set_ostream(std::ostream* os) { ----------------------- End of diff ----------------------- |
From: Carlo W. <li...@us...> - 2002-02-13 03:55:37
|
CVSROOT : /cvsroot/libcw Module : src Commit time: 2002-01-13 03:55:36 UTC Modified files: libcwd/debug.cc libcwd/threading.cc libcwd/include/libcw/Makefile.am libcwd/include/libcw/class_debug.h libcwd/include/libcw/class_debug.inl libcwd/include/libcw/private_threading.h libcwd/testsuite/libcwd.nodebug/nodebug.cc libcwd/testsuite/libcwd.nodebug/nodebug.re libcwd/testsuite/libcwd.tst/alloctag.cc libcwd/testsuite/libcwd.tst/bfd.cc libcwd/testsuite/libcwd.tst/dlopen.re libcwd/testsuite/libcwd.tst/flush.cc libcwd/testsuite/libcwd.tst/leak.cc libcwd/testsuite/libcwd.tst/marker.cc libcwd/testsuite/libcwd.tst/test_delete.cc Added files: libcwd/include/libcw/private_lock_interface.h libcwd/include/libcw/set_ostream.inl Log message: Make 'make full-check' work again. Use locking inside set_ostream and free the previous mutex if any. ---------------------- diff included ---------------------- Index: src/libcwd/debug.cc diff -u src/libcwd/debug.cc:1.67 src/libcwd/debug.cc:1.68 --- src/libcwd/debug.cc:1.67 Mon Feb 11 21:40:31 2002 +++ src/libcwd/debug.cc Tue Feb 12 19:55:25 2002 @@ -1,4 +1,4 @@ -// $Header: /cvsroot/l/li/libcw/src/libcwd/debug.cc,v 1.67 2002/02/12 05:40:31 libcw Exp $ +// $Header: /cvsroot/l/li/libcw/src/libcwd/debug.cc,v 1.68 2002/02/13 03:55:25 libcw Exp $ // // Copyright (C) 2000 - 2001, by // @@ -94,6 +94,7 @@ ++__libcwd_tsd.library_call; ++LIBCWD_DO_TSD_MEMBER_OFF(libcw_do); #endif +#ifdef LIBCWD_THREAD_SAFE LIBCWD_DISABLE_CANCEL // We don't want Dout() to be a cancellation point. if (mutex) { @@ -109,12 +110,16 @@ else { WST_second_time = true; - DoutFatal(dc::core, "When using multiple threads, you must provide a locking mechanism for the debug output stream. You can pass a pointer to a mutex with `debug_ct::set_ostream'."); + DoutFatal(dc::core, "When using multiple threads, you must provide a locking mechanism for the debug output stream. " + "You can pass a pointer to a mutex with `debug_ct::set_ostream' (see documentation/html/group__group__destination.html)."); } } else os->write(buf, curlen); LIBCWD_ENABLE_CANCEL +#else // !LIBCWD_THREAD_SAFE + os->write(buf, curlen); +#endif // !LIBCWD_THREAD_SAFE #ifdef DEBUGMALLOC --LIBCWD_DO_TSD_MEMBER_OFF(libcw_do); --__libcwd_tsd.library_call; @@ -1544,10 +1549,44 @@ template<> void debug_ct::set_ostream(std::ostream* os, pthread_mutex_t* mutex) { - M_mutex = new _private_::pthread_lock_interface_ct(mutex); + _private_::lock_interface_base_ct* new_mutex = new _private_::pthread_lock_interface_ct(mutex); + LIBCWD_DEFER_CANCEL + _private_::mutex_tct<_private_::set_ostream_instance>::lock(); + _private_::lock_interface_base_ct* old_mutex = M_mutex; + if (old_mutex) + old_mutex->lock(); // Make sure all other threads left this critical area. + M_mutex = new_mutex; + if (old_mutex) + { + old_mutex->unlock(); + delete old_mutex; + } private_set_ostream(os); + _private_::mutex_tct<_private_::set_ostream_instance>::unlock(); + LIBCWD_RESTORE_CANCEL } #endif // LIBCWD_THREAD_SAFE + +/** + * \brief Set output device. + * \ingroup group_destination + * + * Assign a new \c ostream to this %debug object (default is <CODE>std::cerr</CODE>). + */ +void debug_ct::set_ostream(std::ostream* os) +{ +#ifdef LIBCWD_THREAD_SAFE + if (_private_::WST_multi_threaded) + Dout(dc::warning, location_ct((char*)__builtin_return_address(0) + builtin_return_address_offset) << ": You should passing a locking mechanism to `set_ostream' for the ostream (see documentation/html/group__group__destination.html)"); + LIBCWD_DEFER_CANCEL + _private_::mutex_tct<_private_::set_ostream_instance>::lock(); +#endif + private_set_ostream(os); +#ifdef LIBCWD_THREAD_SAFE + _private_::mutex_tct<_private_::set_ostream_instance>::unlock(); + LIBCWD_RESTORE_CANCEL +#endif +} } // namespace debug } // namespace libcw Index: src/libcwd/include/libcw/Makefile.am diff -u src/libcwd/include/libcw/Makefile.am:1.23 src/libcwd/include/libcw/Makefile.am:1.24 --- src/libcwd/include/libcw/Makefile.am:1.23 Fri Feb 8 14:29:29 2002 +++ src/libcwd/include/libcw/Makefile.am Tue Feb 12 19:55:26 2002 @@ -43,9 +43,11 @@ private_internal_string.h \ private_internal_stringstream.h \ private_internal_vector.h \ + private_lock_interface.h \ private_set_alloc_checking.h \ private_struct_TSD.h \ private_threading.h \ + set_ostream.inl \ strerrno.h \ struct_debug_tsd.h \ type_info.h Index: src/libcwd/include/libcw/class_debug.h diff -u src/libcwd/include/libcw/class_debug.h:1.10 src/libcwd/include/libcw/class_debug.h:1.11 --- src/libcwd/include/libcw/class_debug.h:1.10 Mon Feb 11 21:40:32 2002 +++ src/libcwd/include/libcw/class_debug.h Tue Feb 12 19:55:26 2002 @@ -1,4 +1,4 @@ -// $Header: /cvsroot/l/li/libcw/src/libcwd/include/libcw/class_debug.h,v 1.10 2002/02/12 05:40:32 libcw Exp $ +// $Header: /cvsroot/l/li/libcw/src/libcwd/include/libcw/class_debug.h,v 1.11 2002/02/13 03:55:26 libcw Exp $ // // Copyright (C) 2000 - 2002, by // @@ -30,6 +30,9 @@ #ifndef LIBCW_STRUCT_DEBUG_TSD #include <libcw/struct_debug_tsd.h> #endif +#ifndef LIBCW_PRIVATE_LOCK_INTERFACE_H +#include <libcw/private_lock_interface.h> +#endif #ifndef LIBCW_IOSFWD #define LIBCW_IOSFWD #include <iosfwd> @@ -38,10 +41,6 @@ namespace libcw { namespace debug { -namespace _private_ { - class lock_interface_base_ct; -} // namespace _private_ - //=================================================================================================== // class debug_ct // @@ -260,73 +259,12 @@ #endif // LIBCWD_THREAD_SAFE }; -#ifdef LIBCWD_THREAD_SAFE -namespace _private_ { - -class lock_interface_base_ct { -public: - virtual int trylock(void) = 0; - virtual void lock(void) = 0; - virtual void unlock(void) = 0; -}; - -template<class T> - class lock_interface_tct : public lock_interface_base_ct { - private: - T* ptr; - virtual int trylock(void) { return ptr->trylock(); } - virtual void lock(void) { ptr->lock(); } - virtual void unlock(void) { ptr->unlock(); } - public: - lock_interface_tct(T* mutex) : ptr(mutex) { } - }; - - class pthread_lock_interface_ct : public lock_interface_base_ct { - private: - pthread_mutex_t* ptr; - virtual int trylock(void) { return pthread_mutex_trylock(ptr); } - virtual void lock(void) { pthread_mutex_lock(ptr); } - virtual void unlock(void) { pthread_mutex_unlock(ptr); } - public: - pthread_lock_interface_ct(pthread_mutex_t* mutex) : ptr(mutex) { } - }; - -} // namespace _private_ - -/** - * \brief Set output device and provide external lock. - * \ingroup group_destination - * - * Assign a new \c ostream to this %debug object. - * The \c ostream will only be written to after obtaining the lock - * that is passed as second argument. Each \c ostream needs to have - * a unique lock. If the application also writes directly - * to the same \c ostream then use the same lock. - * - * <b>Example:</b> - * - * \code - * MyLock lock; - * - * // Uses MyLock::lock(), MyLock::trylock() and MyLock::unlock(). - * Debug( libcw_do.set_ostream(&std::cerr, &lock) ); - * - * lock.lock(); - * std::cerr << "The application uses cerr too\n"; - * lock.unlock(); - * \endcode - */ -template<class T> - void debug_ct::set_ostream(std::ostream* os, T* mutex) - { - M_mutex = new _private_::lock_interface_tct<T>(mutex); - private_set_ostream(os); - } - -#endif // LIBCWD_THREAD_SAFE - } // namespace debug } // namespace libcw + +#ifndef LIBCW_SET_OSTREAM_INL +#include <libcw/set_ostream.inl> +#endif #endif // LIBCW_CLASS_DEBUG_H Index: src/libcwd/include/libcw/class_debug.inl diff -u src/libcwd/include/libcw/class_debug.inl:1.7 src/libcwd/include/libcw/class_debug.inl:1.8 --- src/libcwd/include/libcw/class_debug.inl:1.7 Mon Feb 11 21:40:32 2002 +++ src/libcwd/include/libcw/class_debug.inl Tue Feb 12 19:55:26 2002 @@ -1,4 +1,4 @@ -// $Header: /cvsroot/l/li/libcw/src/libcwd/include/libcw/class_debug.inl,v 1.7 2002/02/12 05:40:32 libcw Exp $ +// $Header: /cvsroot/l/li/libcw/src/libcwd/include/libcw/class_debug.inl,v 1.8 2002/02/13 03:55:26 libcw Exp $ // // Copyright (C) 2000 - 2001, by // @@ -178,19 +178,6 @@ if (LIBCWD_TSD_MEMBER(laf_stack).size() == 0) LIBCWD_TSD_MEMBER(current_oss) = NULL; #endif -} - -/** - * \brief Set output device. - * \ingroup group_destination - * - * Assign a new \c ostream to this %debug object (default is <CODE>std::cerr</CODE>). - */ -__inline__ -void -debug_ct::set_ostream(std::ostream* os) -{ - private_set_ostream(os); } /** \} */ Index: src/libcwd/include/libcw/private_lock_interface.h diff -u /dev/null src/libcwd/include/libcw/private_lock_interface.h:1.1 --- /dev/null Tue Feb 12 19:55:36 2002 +++ src/libcwd/include/libcw/private_lock_interface.h Tue Feb 12 19:55:26 2002 @@ -0,0 +1,60 @@ +// $Header: /cvsroot/l/li/libcw/src/libcwd/include/libcw/private_lock_interface.h,v 1.1 2002/02/13 03:55:26 libcw Exp $ +// +// Copyright (C) 2002, by +// +// Carlo Wood, Run on IRC <ca...@al...> +// RSA-1024 0x624ACAD5 1997-01-26 Sign & Encrypt +// Fingerprint16 = 32 EC A7 B6 AC DB 65 A6 F6 F6 55 DD 1C DC FF 61 +// +// This file may be distributed under the terms of the Q Public License +// version 1.0 as appearing in the file LICENSE.QPL included in the +// packaging of this file. +// + +/** \file private_lock_interface.h + * Do not include this header file directly, instead include "\ref preparation_step2 "debug.h"". + */ + +#ifndef LIBCW_PRIVATE_LOCK_INTERFACE_H +#define LIBCW_PRIVATE_LOCK_INTERFACE_H + +#ifdef LIBCWD_THREAD_SAFE +namespace libcw { + namespace debug { + namespace _private_ { + +class lock_interface_base_ct { +public: + virtual int trylock(void) = 0; + virtual void lock(void) = 0; + virtual void unlock(void) = 0; + virtual ~lock_interface_base_ct() { } +}; + +template<class T> + class lock_interface_tct : public lock_interface_base_ct { + private: + T* ptr; + virtual int trylock(void) { return ptr->trylock(); } + virtual void lock(void) { ptr->lock(); } + virtual void unlock(void) { ptr->unlock(); } + public: + lock_interface_tct(T* mutex) : ptr(mutex) { } + }; + +class pthread_lock_interface_ct : public lock_interface_base_ct { + private: + pthread_mutex_t* ptr; + virtual int trylock(void) { return pthread_mutex_trylock(ptr); } + virtual void lock(void) { pthread_mutex_lock(ptr); } + virtual void unlock(void) { pthread_mutex_unlock(ptr); } + public: + pthread_lock_interface_ct(pthread_mutex_t* mutex) : ptr(mutex) { } +}; + + } // namespace _private_ + } // namespace debug +} // namespace libcw +#endif // LIBCWD_THREAD_SAFE +#endif // LIBCW_PRIVATE_LOCK_INTERFACE_H + Index: src/libcwd/include/libcw/private_threading.h diff -u src/libcwd/include/libcw/private_threading.h:1.22 src/libcwd/include/libcw/private_threading.h:1.23 --- src/libcwd/include/libcw/private_threading.h:1.22 Mon Feb 11 21:40:32 2002 +++ src/libcwd/include/libcw/private_threading.h Tue Feb 12 19:55:26 2002 @@ -1,4 +1,4 @@ -// $Header: /cvsroot/l/li/libcw/src/libcwd/include/libcw/private_threading.h,v 1.22 2002/02/12 05:40:32 libcw Exp $ +// $Header: /cvsroot/l/li/libcw/src/libcwd/include/libcw/private_threading.h,v 1.23 2002/02/13 03:55:26 libcw Exp $ // // Copyright (C) 2001 - 2002, by // @@ -112,6 +112,7 @@ type_info_of_instance, dlopen_map_instance, write_max_len_instance, + set_ostream_instance, debug_objects_instance, // rwlock debug_channels_instance, // rwlock // Values reserved for read/write locks. Index: src/libcwd/include/libcw/set_ostream.inl diff -u /dev/null src/libcwd/include/libcw/set_ostream.inl:1.1 --- /dev/null Tue Feb 12 19:55:36 2002 +++ src/libcwd/include/libcw/set_ostream.inl Tue Feb 12 19:55:26 2002 @@ -0,0 +1,75 @@ +// $Header: /cvsroot/l/li/libcw/src/libcwd/include/libcw/set_ostream.inl,v 1.1 2002/02/13 03:55:26 libcw Exp $ +// +// Copyright (C) 2002, by +// +// Carlo Wood, Run on IRC <ca...@al...> +// RSA-1024 0x624ACAD5 1997-01-26 Sign & Encrypt +// Fingerprint16 = 32 EC A7 B6 AC DB 65 A6 F6 F6 55 DD 1C DC FF 61 +// +// This file may be distributed under the terms of the Q Public License +// version 1.0 as appearing in the file LICENSE.QPL included in the +// packaging of this file. +// + +#ifndef LIBCW_SET_OSTREAM_INL +#define LIBCW_SET_OSTREAM_INL + +#ifndef LIBCW_PRIVATE_LOCK_INTERFACE_H +#include <libcw/private_lock_interface.h> +#endif +#ifndef LIBCW_PRIVATE_THREADING_H +#include <libcw/private_threading.h> +#endif + +#ifdef LIBCWD_THREAD_SAFE +namespace libcw { + namespace debug { + +/** + * \brief Set output device and provide external lock. + * \ingroup group_destination + * + * Assign a new \c ostream to this %debug object. + * The \c ostream will only be written to after obtaining the lock + * that is passed as second argument. Each \c ostream needs to have + * a unique lock. If the application also writes directly + * to the same \c ostream then use the same lock. + * + * <b>Example:</b> + * + * \code + * MyLock lock; + * + * // Uses MyLock::lock(), MyLock::trylock() and MyLock::unlock(). + * Debug( libcw_do.set_ostream(&std::cerr, &lock) ); + * + * lock.lock(); + * std::cerr << "The application uses cerr too\n"; + * lock.unlock(); + * \endcode + */ +template<class T> + void debug_ct::set_ostream(std::ostream* os, T* mutex) + { + _private_::lock_interface_base_ct* new_mutex = new _private_::lock_interface_tct<T>(mutex); + LIBCWD_DEFER_CANCEL + _private_::mutex_tct<_private_::set_ostream_instance>::lock(); + _private_::lock_interface_base_ct* old_mutex = M_mutex; + if (old_mutex) + old_mutex->lock(); // Make sure all other threads left this critical area. + M_mutex = new_mutex; + if (old_mutex) + { + old_mutex->unlock(); + delete old_mutex; + } + private_set_ostream(os); + _private_::mutex_tct<_private_::set_ostream_instance>::unlock(); + LIBCWD_RESTORE_CANCEL + } + + } // namespace debug +} // namespace libcw +#endif // LIBCWD_THREAD_SAFE +#endif // LIBCW_SET_OSTREAM_INL + Index: src/libcwd/testsuite/libcwd.nodebug/nodebug.cc diff -u src/libcwd/testsuite/libcwd.nodebug/nodebug.cc:1.7 src/libcwd/testsuite/libcwd.nodebug/nodebug.cc:1.8 --- src/libcwd/testsuite/libcwd.nodebug/nodebug.cc:1.7 Wed Sep 19 16:34:50 2001 +++ src/libcwd/testsuite/libcwd.nodebug/nodebug.cc Tue Feb 12 19:55:26 2002 @@ -7,13 +7,13 @@ DoutFatal(dc::fatal, "Expected Failure."); #endif - Debug( make_all_allocations_invisible_except(NULL) ); - Debug( libcw_do.on() ); Debug( dc::malloc.on() ); #ifdef DEBUGUSEBFD Debug( dc::bfd.on() ); #endif + + Debug( make_all_allocations_invisible_except(NULL) ); int* p = new int [100]; Index: src/libcwd/testsuite/libcwd.nodebug/nodebug.re diff -u src/libcwd/testsuite/libcwd.nodebug/nodebug.re:1.10 src/libcwd/testsuite/libcwd.nodebug/nodebug.re:1.11 --- src/libcwd/testsuite/libcwd.nodebug/nodebug.re:1.10 Tue Jan 8 18:20:50 2002 +++ src/libcwd/testsuite/libcwd.nodebug/nodebug.re Tue Feb 12 19:55:26 2002 @@ -8,6 +8,10 @@ does not have a line number, perhaps the unit containing the function `_*main' wasn't compiled with flag -(g|ggdb)\? MALLOC : <continued> 0x[a-f0-9]+ -MALLOC : Allocated memory: 400 bytes in 1 blocks\. +MALLOC : Allocated memory: (400|408) bytes in (1|2) blocks\. new\[\] 0x[a-f0-9]+ (_*main|) *<unknown type>; \(sz = 400\) +// input lines 2 +// output till ^MALLOC +(malloc 0x[a-f0-9]+ *eh_globals\.cc:[0-9]* *<unknown type>; \(sz = 8\) +)* MALLOC : delete\[\] 0x[a-f0-9]+ (_*main|) *<unknown type>; \(sz = 400\) Index: src/libcwd/testsuite/libcwd.tst/alloctag.cc diff -u src/libcwd/testsuite/libcwd.tst/alloctag.cc:1.17 src/libcwd/testsuite/libcwd.tst/alloctag.cc:1.18 --- src/libcwd/testsuite/libcwd.tst/alloctag.cc:1.17 Sat Dec 29 20:17:51 2001 +++ src/libcwd/testsuite/libcwd.tst/alloctag.cc Tue Feb 12 19:55:26 2002 @@ -1,4 +1,4 @@ -// $Header: /cvsroot/l/li/libcw/src/libcwd/testsuite/libcwd.tst/alloctag.cc,v 1.17 2001/12/30 04:17:51 libcw Exp $ +// $Header: /cvsroot/l/li/libcw/src/libcwd/testsuite/libcwd.tst/alloctag.cc,v 1.18 2002/02/13 03:55:26 libcw Exp $ // // Copyright (C) 2000 - 2001, by // @@ -90,5 +90,7 @@ free(cp2i); free(rp); free(rpi); + + Debug( libcw_do.off() ); return 0; } Index: src/libcwd/testsuite/libcwd.tst/bfd.cc diff -u src/libcwd/testsuite/libcwd.tst/bfd.cc:1.24 src/libcwd/testsuite/libcwd.tst/bfd.cc:1.25 --- src/libcwd/testsuite/libcwd.tst/bfd.cc:1.24 Sat Dec 29 20:17:51 2001 +++ src/libcwd/testsuite/libcwd.tst/bfd.cc Tue Feb 12 19:55:26 2002 @@ -1,4 +1,4 @@ -// $Header: /cvsroot/l/li/libcw/src/libcwd/testsuite/libcwd.tst/bfd.cc,v 1.24 2001/12/30 04:17:51 libcw Exp $ +// $Header: /cvsroot/l/li/libcw/src/libcwd/testsuite/libcwd.tst/bfd.cc,v 1.25 2002/02/13 03:55:26 libcw Exp $ // // Copyright (C) 2000 - 2001, by // @@ -157,5 +157,6 @@ #endif libcw_bfd_test(); + Debug( libcw_do.off() ); return 0; } Index: src/libcwd/testsuite/libcwd.tst/dlopen.re diff -u src/libcwd/testsuite/libcwd.tst/dlopen.re:1.11 src/libcwd/testsuite/libcwd.tst/dlopen.re:1.12 --- src/libcwd/testsuite/libcwd.tst/dlopen.re:1.11 Sat Feb 9 21:41:58 2002 +++ src/libcwd/testsuite/libcwd.tst/dlopen.re Tue Feb 12 19:55:26 2002 @@ -18,6 +18,6 @@ malloc 0x[0-9a-f]* module\.cc:19 void\*; \(sz = 310\) Allocated inside global_test_symbol // input lines 2 // output till ^NOTICE -(malloc 0x[0-9a-f]* *(dl-[a-z]*\.c|stl_alloc\.h|specific\.c|dlerror\.c):[0-9]* *<unknown type>; \(sz = [0-9]*\) +(malloc 0x[0-9a-f]* *(dl-[a-z]*\.c|stl_alloc\.h|specific\.c|dlerror\.c|eh_globals\.cc):[0-9]* *<unknown type>; \(sz = [0-9]*\) )* NOTICE : Finished Index: src/libcwd/testsuite/libcwd.tst/flush.cc diff -u src/libcwd/testsuite/libcwd.tst/flush.cc:1.10 src/libcwd/testsuite/libcwd.tst/flush.cc:1.11 --- src/libcwd/testsuite/libcwd.tst/flush.cc:1.10 Sat Dec 29 20:17:51 2001 +++ src/libcwd/testsuite/libcwd.tst/flush.cc Tue Feb 12 19:55:26 2002 @@ -46,4 +46,6 @@ Dout( dc::continued, "part2... " ); generate_tables(); Dout( dc::finish, "done" ); + + Debug( libcw_do.off() ); } Index: src/libcwd/testsuite/libcwd.tst/leak.cc diff -u src/libcwd/testsuite/libcwd.tst/leak.cc:1.16 src/libcwd/testsuite/libcwd.tst/leak.cc:1.17 --- src/libcwd/testsuite/libcwd.tst/leak.cc:1.16 Sat Dec 29 20:17:51 2001 +++ src/libcwd/testsuite/libcwd.tst/leak.cc Tue Feb 12 19:55:26 2002 @@ -1,4 +1,4 @@ -// $Header: /cvsroot/l/li/libcw/src/libcwd/testsuite/libcwd.tst/leak.cc,v 1.16 2001/12/30 04:17:51 libcw Exp $ +// $Header: /cvsroot/l/li/libcw/src/libcwd/testsuite/libcwd.tst/leak.cc,v 1.17 2002/02/13 03:55:26 libcw Exp $ // // Copyright (C) 2000 - 2001, by // @@ -160,5 +160,6 @@ free(ptr2); free(ptr3); + Debug( libcw_do.off() ); return 0; } Index: src/libcwd/testsuite/libcwd.tst/marker.cc diff -u src/libcwd/testsuite/libcwd.tst/marker.cc:1.15 src/libcwd/testsuite/libcwd.tst/marker.cc:1.16 --- src/libcwd/testsuite/libcwd.tst/marker.cc:1.15 Sat Dec 29 20:17:51 2001 +++ src/libcwd/testsuite/libcwd.tst/marker.cc Tue Feb 12 19:55:26 2002 @@ -1,4 +1,4 @@ -// $Header: /cvsroot/l/li/libcw/src/libcwd/testsuite/libcwd.tst/marker.cc,v 1.15 2001/12/30 04:17:51 libcw Exp $ +// $Header: /cvsroot/l/li/libcw/src/libcwd/testsuite/libcwd.tst/marker.cc,v 1.16 2002/02/13 03:55:26 libcw Exp $ // // Copyright (C) 2000 - 2001, by // @@ -87,5 +87,6 @@ Dout(dc::notice, "Finished successfully."); + Debug( libcw_do.off() ); exit(0); } Index: src/libcwd/testsuite/libcwd.tst/test_delete.cc diff -u src/libcwd/testsuite/libcwd.tst/test_delete.cc:1.11 src/libcwd/testsuite/libcwd.tst/test_delete.cc:1.12 --- src/libcwd/testsuite/libcwd.tst/test_delete.cc:1.11 Sat Dec 29 20:17:51 2001 +++ src/libcwd/testsuite/libcwd.tst/test_delete.cc Tue Feb 12 19:55:26 2002 @@ -1,4 +1,4 @@ -// $Header: /cvsroot/l/li/libcw/src/libcwd/testsuite/libcwd.tst/test_delete.cc,v 1.11 2001/12/30 04:17:51 libcw Exp $ +// $Header: /cvsroot/l/li/libcw/src/libcwd/testsuite/libcwd.tst/test_delete.cc,v 1.12 2002/02/13 03:55:26 libcw Exp $ // // Copyright (C) 2000 - 2001, by // @@ -85,5 +85,6 @@ std::cout << "Finished successfully.\n"; #endif + Debug( libcw_do.off() ); exit(0); } Index: src/libcwd/threading.cc diff -u src/libcwd/threading.cc:1.10 src/libcwd/threading.cc:1.11 --- src/libcwd/threading.cc:1.10 Mon Feb 11 21:40:32 2002 +++ src/libcwd/threading.cc Tue Feb 12 19:55:26 2002 @@ -1,4 +1,4 @@ -// $Header: /cvsroot/l/li/libcw/src/libcwd/threading.cc,v 1.10 2002/02/12 05:40:32 libcw Exp $ +// $Header: /cvsroot/l/li/libcw/src/libcwd/threading.cc,v 1.11 2002/02/13 03:55:26 libcw Exp $ // // Copyright (C) 2001, by // @@ -33,6 +33,7 @@ mutex_tct<mutex_initialization_instance>::initialize(); rwlock_tct<object_files_instance>::initialize(); mutex_tct<dlopen_map_instance>::initialize(); + mutex_tct<set_ostream_instance>::initialize(); #ifdef DEBUGMALLOC mutex_tct<alloc_tag_desc_instance>::initialize(); mutex_tct<memblk_map_instance>::initialize(); ----------------------- End of diff ----------------------- |
From: Carlo W. <li...@us...> - 2002-02-12 05:40:43
|
CVSROOT : /cvsroot/libcw Module : src Commit time: 2002-01-12 05:40:42 UTC Modified files: libcwd/debug.cc libcwd/threading.cc libcwd/include/libcw/class_debug.h libcwd/include/libcw/class_debug.inl libcwd/include/libcw/debug.h libcwd/include/libcw/macro_ForAllDebugObjects.h libcwd/include/libcw/private_threading.h libcwd/tests/threads4.cc Log message: ostream locking first try. ---------------------- diff included ---------------------- Index: src/libcwd/debug.cc diff -u src/libcwd/debug.cc:1.66 src/libcwd/debug.cc:1.67 --- src/libcwd/debug.cc:1.66 Sat Feb 9 21:41:58 2002 +++ src/libcwd/debug.cc Mon Feb 11 21:40:31 2002 @@ -1,4 +1,4 @@ -// $Header: /cvsroot/l/li/libcw/src/libcwd/debug.cc,v 1.66 2002/02/10 05:41:58 libcw Exp $ +// $Header: /cvsroot/l/li/libcw/src/libcwd/debug.cc,v 1.67 2002/02/12 05:40:31 libcw Exp $ // // Copyright (C) 2000 - 2001, by // @@ -70,7 +70,11 @@ pos_type position; #endif public: +#ifdef LIBCWD_THREAD_SAFE + void writeto(std::ostream* os, _private_::lock_interface_base_ct* mutex LIBCWD_COMMA_TSD_PARAM) +#else void writeto(std::ostream* os LIBCWD_COMMA_TSD_PARAM) +#endif { char* buf; bool used_malloc = false; @@ -91,7 +95,25 @@ ++LIBCWD_DO_TSD_MEMBER_OFF(libcw_do); #endif LIBCWD_DISABLE_CANCEL // We don't want Dout() to be a cancellation point. - os->write(buf, curlen); + if (mutex) + { + mutex->lock(); + os->write(buf, curlen); + mutex->unlock(); + } + else if (_private_::WST_multi_threaded) + { + static bool WST_second_time = false; // Break infinite loop. + if (WST_second_time) + os->write(buf, curlen); + else + { + WST_second_time = true; + DoutFatal(dc::core, "When using multiple threads, you must provide a locking mechanism for the debug output stream. You can pass a pointer to a mutex with `debug_ct::set_ostream'."); + } + } + else + os->write(buf, curlen); LIBCWD_ENABLE_CANCEL #ifdef DEBUGMALLOC --LIBCWD_DO_TSD_MEMBER_OFF(libcw_do); @@ -323,9 +345,6 @@ // Force allocation of a __cxa_eh_globals struct in libsupc++. (void)std::uncaught_exception(); #endif -#if defined(DEBUGDEBUG) && defined(LIBCWD_THREAD_SAFE) - _private_::WST_multi_threaded = true; -#endif } namespace _private_ { @@ -630,6 +649,12 @@ /** \} */ +#ifdef LIBCWD_THREAD_SAFE +#define LIBCWD_COMMA_MUTEX ,debug_object.M_mutex +#else +#define LIBCWD_COMMA_MUTEX +#endif + void debug_tsd_st::start(debug_ct& debug_object, channel_set_data_st& channel_set LIBCWD_COMMA_TSD_PARAM) { #ifdef DEBUGDEBUG @@ -651,7 +676,23 @@ if (!(current->mask & continued_expected_maskbit)) { std::ostream* target_os = (channel_set.mask & cerr_cf) ? &std::cerr : debug_object.real_os; +#ifdef LIBCWD_THREAD_SAFE + // Try to get the lock, but don't try too long... + int res; + struct timespec const t = { 0, 5000000 }; + for(int count = 0; count < 40; ++count) + { + res = debug_object.M_mutex->trylock(); + if (res == 0) + break; + nanosleep(&t, NULL); + } +#endif target_os->put('\n'); +#ifdef LIBCWD_THREAD_SAFE + if (res == 0) + debug_object.M_mutex->unlock(); +#endif char const* channame = (channel_set.mask & finish_maskbit) ? "finish" : "continued"; #ifdef DEBUGUSEBFD DoutFatal(dc::core, "Using `dc::" << channame << "' in " << @@ -684,11 +725,11 @@ // (current->mask & continued_cf_maskbit) is false and this if is skipped. LIBCWD_ASSERT( current != reinterpret_cast<laf_ct*>(_private_::WST_dummy_laf) ); #endif - // Write out what is in the buffer till now. + // Append <unfinished> to the current buffer. + current_oss->write("<unfinished>\n", 13); // Continued debug output should end on a space by itself, + // And write out what is in the buffer till now. std::ostream* target_os = (channel_set.mask & cerr_cf) ? &std::cerr : debug_object.real_os; - static_cast<buffer_ct*>(current_oss)->writeto(target_os LIBCWD_COMMA_TSD); - // Append <unfinished> to it. - target_os->write("<unfinished>\n", 13); // Continued debug output should end on a space by itself, + static_cast<buffer_ct*>(current_oss)->writeto(target_os LIBCWD_COMMA_MUTEX LIBCWD_COMMA_TSD); // Truncate the buffer to its prefix and append "<continued>" to it already. static_cast<buffer_ct*>(current_oss)->restore_position(); current_oss->write("<continued> ", 12); // therefore we repeat the space here. @@ -784,7 +825,7 @@ if ((current->mask & flush_cf)) { // Write buffer to ostream. - static_cast<buffer_ct*>(current_oss)->writeto(target_os LIBCWD_COMMA_TSD); + static_cast<buffer_ct*>(current_oss)->writeto(target_os LIBCWD_COMMA_MUTEX LIBCWD_COMMA_TSD); // Flush ostream. Note that in the case of nested debug output this `os' can be an stringstream, // in that case, no actual flushing is done until the debug output to the real ostream has // finished. @@ -804,7 +845,7 @@ current_oss->put('\n'); // Write buffer to ostream. - static_cast<buffer_ct*>(current_oss)->writeto(target_os LIBCWD_COMMA_TSD); + static_cast<buffer_ct*>(current_oss)->writeto(target_os LIBCWD_COMMA_MUTEX LIBCWD_COMMA_TSD); // Handle control flags, if any: if (current->mask != 0) @@ -829,12 +870,18 @@ } if ((current->mask & wait_cf)) { +#ifdef LIBCWD_THREAD_SAFE + debug_object.M_mutex->lock(); +#endif *target_os << "(type return)"; if (debug_object.interactive) { *target_os << std::flush; while(std::cin.get() != '\n'); } +#ifdef LIBCWD_THREAD_SAFE + debug_object.M_mutex->unlock(); +#endif } if ((current->mask & flush_cf)) { @@ -906,6 +953,10 @@ if (WNS_initialized) return; +#ifdef LIBCWD_THREAD_SAFE + M_mutex = NULL; +#endif + #ifdef DEBUGDEBUG if (!WST_debug_object_init_magic) init_debug_object_init_magic(); @@ -1466,6 +1517,37 @@ core_dump(); // off() and on() where called and not in equal pairs. off_cnt = state.off_cnt; // Restore. } + +#ifdef LIBCWD_THREAD_SAFE +/** + * \brief Set output device and provide external pthread mutex. + * \ingroup group_destination + * + * Assign a new \c ostream to this %debug object. + * The \c ostream will only be written to after obtaining the lock + * that is passed as second argument. + * + * <b>Example:</b> + * + * \code + * pthread_mutex_t lock; + * + * // Use the same lock as you use in your application for std::cerr. + * Debug( libcw_do.set_ostream(&std::cerr, &lock) ); + * + * pthread_mutex_lock(&lock); + * std::cerr << "The application uses cerr too\n"; + * pthread_mutex_unlock(&lock); + * \endcode + */ +// Specialization +template<> + void debug_ct::set_ostream(std::ostream* os, pthread_mutex_t* mutex) + { + M_mutex = new _private_::pthread_lock_interface_ct(mutex); + private_set_ostream(os); + } +#endif // LIBCWD_THREAD_SAFE } // namespace debug } // namespace libcw Index: src/libcwd/include/libcw/class_debug.h diff -u src/libcwd/include/libcw/class_debug.h:1.9 src/libcwd/include/libcw/class_debug.h:1.10 --- src/libcwd/include/libcw/class_debug.h:1.9 Thu Feb 7 20:03:47 2002 +++ src/libcwd/include/libcw/class_debug.h Mon Feb 11 21:40:32 2002 @@ -1,4 +1,4 @@ -// $Header: /cvsroot/l/li/libcw/src/libcwd/include/libcw/class_debug.h,v 1.9 2002/02/08 04:03:47 libcw Exp $ +// $Header: /cvsroot/l/li/libcw/src/libcwd/include/libcw/class_debug.h,v 1.10 2002/02/12 05:40:32 libcw Exp $ // // Copyright (C) 2000 - 2002, by // @@ -38,6 +38,10 @@ namespace libcw { namespace debug { +namespace _private_ { + class lock_interface_base_ct; +} // namespace _private_ + //=================================================================================================== // class debug_ct // @@ -83,7 +87,13 @@ // std::ostream* real_os; - // The original output ostream (as set with set_ostream() or set_fd()). + // The original output ostream (as set with set_ostream()). + // +#ifdef LIBCWD_THREAD_SAFE + _private_::lock_interface_base_ct* M_mutex; + // Pointer to the mutex that should be used for `real_os' or NULL when no lock is used. + // A value of NULL is only allowed prior to creating a second thread. +#endif private: //------------------------------------------------------------------------------------------------- @@ -182,12 +192,24 @@ debug_ct(void); ~debug_ct(); +private: + void private_set_ostream(std::ostream* os); + public: //------------------------------------------------------------------------------------------------- // Manipulators: // void set_ostream(std::ostream* os); +#ifdef LIBCWD_THREAD_SAFE + template<class T> + void set_ostream(std::ostream* os, T* mutex); +#ifdef LIBCW_DOXYGEN + // Specialization. + template<> + void set_ostream(std::ostream* os, pthread_mutex_t* mutex); +#endif +#endif void off(void); void on(void); @@ -235,8 +257,73 @@ * \returns The previous value. */ bool keep_tsd(bool keep); -#endif +#endif // LIBCWD_THREAD_SAFE +}; + +#ifdef LIBCWD_THREAD_SAFE +namespace _private_ { + +class lock_interface_base_ct { +public: + virtual int trylock(void) = 0; + virtual void lock(void) = 0; + virtual void unlock(void) = 0; }; + +template<class T> + class lock_interface_tct : public lock_interface_base_ct { + private: + T* ptr; + virtual int trylock(void) { return ptr->trylock(); } + virtual void lock(void) { ptr->lock(); } + virtual void unlock(void) { ptr->unlock(); } + public: + lock_interface_tct(T* mutex) : ptr(mutex) { } + }; + + class pthread_lock_interface_ct : public lock_interface_base_ct { + private: + pthread_mutex_t* ptr; + virtual int trylock(void) { return pthread_mutex_trylock(ptr); } + virtual void lock(void) { pthread_mutex_lock(ptr); } + virtual void unlock(void) { pthread_mutex_unlock(ptr); } + public: + pthread_lock_interface_ct(pthread_mutex_t* mutex) : ptr(mutex) { } + }; + +} // namespace _private_ + +/** + * \brief Set output device and provide external lock. + * \ingroup group_destination + * + * Assign a new \c ostream to this %debug object. + * The \c ostream will only be written to after obtaining the lock + * that is passed as second argument. Each \c ostream needs to have + * a unique lock. If the application also writes directly + * to the same \c ostream then use the same lock. + * + * <b>Example:</b> + * + * \code + * MyLock lock; + * + * // Uses MyLock::lock(), MyLock::trylock() and MyLock::unlock(). + * Debug( libcw_do.set_ostream(&std::cerr, &lock) ); + * + * lock.lock(); + * std::cerr << "The application uses cerr too\n"; + * lock.unlock(); + * \endcode + */ +template<class T> + void debug_ct::set_ostream(std::ostream* os, T* mutex) + { + M_mutex = new _private_::lock_interface_tct<T>(mutex); + private_set_ostream(os); + } + +#endif // LIBCWD_THREAD_SAFE } // namespace debug } // namespace libcw Index: src/libcwd/include/libcw/class_debug.inl diff -u src/libcwd/include/libcw/class_debug.inl:1.6 src/libcwd/include/libcw/class_debug.inl:1.7 --- src/libcwd/include/libcw/class_debug.inl:1.6 Tue Feb 5 16:46:08 2002 +++ src/libcwd/include/libcw/class_debug.inl Mon Feb 11 21:40:32 2002 @@ -1,4 +1,4 @@ -// $Header: /cvsroot/l/li/libcw/src/libcwd/include/libcw/class_debug.inl,v 1.6 2002/02/06 00:46:08 libcw Exp $ +// $Header: /cvsroot/l/li/libcw/src/libcwd/include/libcw/class_debug.inl,v 1.7 2002/02/12 05:40:32 libcw Exp $ // // Copyright (C) 2000 - 2001, by // @@ -167,15 +167,9 @@ return real_os; } -/** - * \brief Set output device. - * \ingroup group_destination - * - * Assign a new \c ostream to this %debug object (default is <CODE>std::cerr</CODE>). - */ __inline__ void -debug_ct::set_ostream(std::ostream* os) +debug_ct::private_set_ostream(std::ostream* os) { real_os = os; #ifdef DEBUGDEBUG @@ -184,6 +178,19 @@ if (LIBCWD_TSD_MEMBER(laf_stack).size() == 0) LIBCWD_TSD_MEMBER(current_oss) = NULL; #endif +} + +/** + * \brief Set output device. + * \ingroup group_destination + * + * Assign a new \c ostream to this %debug object (default is <CODE>std::cerr</CODE>). + */ +__inline__ +void +debug_ct::set_ostream(std::ostream* os) +{ + private_set_ostream(os); } /** \} */ Index: src/libcwd/include/libcw/debug.h diff -u src/libcwd/include/libcw/debug.h:1.41 src/libcwd/include/libcw/debug.h:1.42 --- src/libcwd/include/libcw/debug.h:1.41 Fri Feb 8 14:29:29 2002 +++ src/libcwd/include/libcw/debug.h Mon Feb 11 21:40:32 2002 @@ -1,4 +1,4 @@ -// $Header: /cvsroot/l/li/libcw/src/libcwd/include/libcw/debug.h,v 1.41 2002/02/08 22:29:29 libcw Exp $ +// $Header: /cvsroot/l/li/libcw/src/libcwd/include/libcw/debug.h,v 1.42 2002/02/12 05:40:32 libcw Exp $ // // Copyright (C) 2000 - 2001, by // @@ -148,15 +148,16 @@ * <b>Examples:</b> * * \code - * Debug( check_configuration() ); // Configuration consistency check. - * Debug( dc::notice.on() ); // Switch debug channel NOTICE on. - * Debug( libcw_do.on() ); // Turn all debugging temporally off. - * Debug( list_channels_on(libcw_do) ); // List all debug channels. + * Debug( check_configuration() ); // Configuration consistency check. + * Debug( dc::notice.on() ); // Switch debug channel NOTICE on. + * Debug( libcw_do.on() ); // Turn all debugging temporally off. + * Debug( list_channels_on(libcw_do) ); // List all debug channels. * Debug( make_all_allocations_invisible_except(NULL) ); // Hide all allocations so far. - * Debug( list_allocations_on(libcw_do) ); // List all allocations. - * Debug( libcw_do.set_ostream(&std::cout) ); // Use std::cout as debug output stream. - * Debug( libcw_do.inc_indent(4) ); // Increment indentation by 4 spaces. - * Debug( libcw_do.get_ostream()->flush() ); // Flush the current debug output stream. + * Debug( list_allocations_on(libcw_do) ); // List all allocations. + * Debug( libcw_do.set_ostream(&std::cout) ); // Use std::cout as debug output stream. + * Debug( libcw_do.set_ostream(&std::cout, &mutex) ); // use `mutex' as lock for std::cout. + * Debug( libcw_do.inc_indent(4) ); // Increment indentation by 4 spaces. + * Debug( libcw_do.get_ostream()->flush() ); // Flush the current debug output stream. * \endcode */ #define Debug(x) \ Index: src/libcwd/include/libcw/macro_ForAllDebugObjects.h diff -u src/libcwd/include/libcw/macro_ForAllDebugObjects.h:1.5 src/libcwd/include/libcw/macro_ForAllDebugObjects.h:1.6 --- src/libcwd/include/libcw/macro_ForAllDebugObjects.h:1.5 Sat Feb 2 20:15:11 2002 +++ src/libcwd/include/libcw/macro_ForAllDebugObjects.h Mon Feb 11 21:40:32 2002 @@ -1,4 +1,4 @@ -// $Header: /cvsroot/l/li/libcw/src/libcwd/include/libcw/macro_ForAllDebugObjects.h,v 1.5 2002/02/03 04:15:11 libcw Exp $ +// $Header: /cvsroot/l/li/libcw/src/libcwd/include/libcw/macro_ForAllDebugObjects.h,v 1.6 2002/02/12 05:40:32 libcw Exp $ // // Copyright (C) 2000 - 2001, by // @@ -104,7 +104,7 @@ * For example, * * \code - * ForAllDebugObjects( debugObject.set_ostream(&std::cerr) ); + * ForAllDebugObjects( debugObject.set_ostream(&std::cerr, &cerr_mutex) ); * \endcode * * would set the output stream of all %debug objects to <CODE>std::cerr</CODE>. Index: src/libcwd/include/libcw/private_threading.h diff -u src/libcwd/include/libcw/private_threading.h:1.21 src/libcwd/include/libcw/private_threading.h:1.22 --- src/libcwd/include/libcw/private_threading.h:1.21 Thu Feb 7 20:03:47 2002 +++ src/libcwd/include/libcw/private_threading.h Mon Feb 11 21:40:32 2002 @@ -1,4 +1,4 @@ -// $Header: /cvsroot/l/li/libcw/src/libcwd/include/libcw/private_threading.h,v 1.21 2002/02/08 04:03:47 libcw Exp $ +// $Header: /cvsroot/l/li/libcw/src/libcwd/include/libcw/private_threading.h,v 1.22 2002/02/12 05:40:32 libcw Exp $ // // Copyright (C) 2001 - 2002, by // @@ -78,9 +78,7 @@ namespace _private_ { extern void initialize_global_mutexes(void) throw(); -#ifdef DEBUGDEBUG extern bool WST_multi_threaded; -#endif //=================================================================================================== // Index: src/libcwd/tests/threads4.cc diff -u src/libcwd/tests/threads4.cc:1.9 src/libcwd/tests/threads4.cc:1.10 --- src/libcwd/tests/threads4.cc:1.9 Tue Feb 5 16:46:08 2002 +++ src/libcwd/tests/threads4.cc Mon Feb 11 21:40:32 2002 @@ -76,7 +76,8 @@ #ifdef DEBUGMALLOC libcw::debug::make_all_allocations_invisible_except(NULL); #endif - Debug( libcw_do.set_ostream(&std::cout) ); + pthread_mutex_t cout_mutex = PTHREAD_MUTEX_INITIALIZER; + Debug( libcw_do.set_ostream(&std::cout, &cout_mutex) ); Debug( libcw_do.on() ); char margin[32]; sprintf(margin, "%-10lu (%04lu) ", pthread_self(), thread_index(pthread_self())); Index: src/libcwd/threading.cc diff -u src/libcwd/threading.cc:1.9 src/libcwd/threading.cc:1.10 --- src/libcwd/threading.cc:1.9 Sat Feb 9 21:41:58 2002 +++ src/libcwd/threading.cc Mon Feb 11 21:40:32 2002 @@ -1,4 +1,4 @@ -// $Header: /cvsroot/l/li/libcw/src/libcwd/threading.cc,v 1.9 2002/02/10 05:41:58 libcw Exp $ +// $Header: /cvsroot/l/li/libcw/src/libcwd/threading.cc,v 1.10 2002/02/12 05:40:32 libcw Exp $ // // Copyright (C) 2001, by // @@ -22,9 +22,7 @@ namespace _private_ { #ifdef LIBCWD_THREAD_SAFE -#ifdef DEBUGDEBUG bool WST_multi_threaded = false; -#endif #ifdef DEBUGDEBUG int instance_locked[instance_locked_size]; #endif @@ -86,6 +84,7 @@ mutex_tct<tsd_initialization_instance>::unlock(); if (thread_index(pthread_self()) != 0) // Is this a second (or later) thread? { + WST_multi_threaded = true; set_alloc_checking_off(*this); for (int i = 0; i < LIBCWD_DO_MAX; ++i) if (old_array[i]) ----------------------- End of diff ----------------------- |
From: Carlo W. <li...@us...> - 2002-02-11 03:00:36
|
CVSROOT : /cvsroot/libcw Module : src Commit time: 2002-01-11 03:00:35 UTC Modified files: libcwd/NEWS libcwd/acconfig.h libcwd/include/libcw/macro_AllocTag.h libcwd/include/libcw/macro_Libcwd_macros.h Log message: make full-test now runs without errors. Update of NEWS ---------------------- diff included ---------------------- Index: src/libcwd/NEWS diff -u src/libcwd/NEWS:1.67 src/libcwd/NEWS:1.68 --- src/libcwd/NEWS:1.67 Fri Feb 8 14:29:29 2002 +++ src/libcwd/NEWS Sun Feb 10 19:00:24 2002 @@ -27,33 +27,31 @@ IMPORTANT: 'channel_ct const' -> 'channel_ct'. Debug channels should no longer be declared constant. - Declarations like - libcw::debug::channel_ct const my_channel("FOO"); - will have to be changed to - libcw::debug::selector_ct my_channel("FOO"); - removing the `const'. + [ "libcw::debug::channel_ct const my_channel("FOO");" --> + "libcw::debug::selector_ct my_channel("FOO");" ] `long memblks()' has been renamed to `unsigned long mem_blocks()'. + [ "memblks()" --> "mem_blocks()" ] - In debug_ct, set_margin, get_margin, set_marker and get_marker are - a bit slow for heavy swapping of the margin and marker (std::string - is 'slow'); therefore (using internal allocations, which is not - possible with std::string (see bug fixes below)) public access - to members debug_ct::margin and debug_ct::marker is now granted, - providing the following methods of the returned object: size(), - c_str() (the terminating zero is already there, this just returns - an internal pointer), reserve(), capacity(), append(), prepend() - and assign() - all with meanings borrowed from std::string. - For example, when capacity() returns a value larger or equal to - the length of a string that would result from a call to append(), - then calling append is garanteed not to invalidate the pointer - returned by c_str(). The default capacity can be set with `reserve'. - append/prepend/assign accept both a std::string reference or a - char*/size_t pair. - Finally, the following methods are added to debug_ct directly: - `push_margin', `pop_margin', `push_marker' and `pop_marker'. + The margin and marker are no longer using std::string, which is + a bit slow. Access to the margin and marker is now granted through + debug_ct::margin() and debug_ct::marker(). The returned objects + provide the following methods: size(), c_str() (this just returns + an internal pointer, the termination zero is already there), + reserve(), capacity(), append(), prepend() and assign() - all with + their meanings borrowed from std::string. For example, when + capacity() returns a value larger or equal to the length of a string + that would result from a call to append(), then calling append is + garanteed not to invalidate the pointer returned by c_str(). The + default capacity can be set with `reserve'. append/prepend/assign + accept both a std::string reference or a char*/size_t pair. + Finally, the following methods are added to debug_ct: + `push_margin()', `pop_margin()', `push_marker()' and `pop_marker()'. These functions can be used to quickly store and restore the respective formatting strings. + [ "Debug( libcw_do.set_margin(std::string(buf, len)) );" --> + "Debug( libcw_do.margin().assign(buf, len) );" ] + A debug function for internal use (by the maintainers): `debugdebugcheckpoint()' has been removed. If you need a user @@ -63,6 +61,7 @@ CWASSERT was renamed to LIBCWD_ASSERT; Note that all macros that start with LIBCWD_ should NOT be used by the user, they are for internal use by libcwd. + [ "CWASSERT( i == 1 );" --> "assert( i == 1);" ] debug_ct::get_os() has been removed. Use cwprint or cwprint_using. Reason: the temporary stringstream that was returned was only valid Index: src/libcwd/acconfig.h diff -u src/libcwd/acconfig.h:1.10 src/libcwd/acconfig.h:1.11 --- src/libcwd/acconfig.h:1.10 Fri Jan 25 18:06:32 2002 +++ src/libcwd/acconfig.h Sun Feb 10 19:00:24 2002 @@ -7,9 +7,6 @@ #ifndef LIBCW_CONFIG_H #define LIBCW_CONFIG_H @TOP@ -// Defined when RETSIGTYPE is `int'. -#undef CW_RETSIGTYPE_IS_INT - // Full path to the `ps' executable. #undef CW_PATH_PROG_PS Index: src/libcwd/include/libcw/macro_AllocTag.h diff -u src/libcwd/include/libcw/macro_AllocTag.h:1.6 src/libcwd/include/libcw/macro_AllocTag.h:1.7 --- src/libcwd/include/libcw/macro_AllocTag.h:1.6 Wed Jan 30 20:42:08 2002 +++ src/libcwd/include/libcw/macro_AllocTag.h Sun Feb 10 19:00:24 2002 @@ -1,4 +1,4 @@ -// $Header: /cvsroot/l/li/libcw/src/libcwd/include/libcw/macro_AllocTag.h,v 1.6 2002/01/31 04:42:08 libcw Exp $ +// $Header: /cvsroot/l/li/libcw/src/libcwd/include/libcw/macro_AllocTag.h,v 1.7 2002/02/11 03:00:24 libcw Exp $ // // Copyright (C) 2000 - 2001, by // @@ -185,7 +185,7 @@ desc = new char [size]; \ buf.rdbuf()->sgetn(desc, size); \ } \ - ::libcw::debug::_private:::set_alloc_checking_on(LIBCWD_TSD); \ + ::libcw::debug::_private_::set_alloc_checking_on(LIBCWD_TSD); \ ::libcw::debug::set_alloc_label(p, ::libcw::debug::type_info_of(p), \ ::libcw::lockable_auto_ptr<char, true>(desc)); \ } while(0) Index: src/libcwd/include/libcw/macro_Libcwd_macros.h diff -u src/libcwd/include/libcw/macro_Libcwd_macros.h:1.5 src/libcwd/include/libcw/macro_Libcwd_macros.h:1.6 --- src/libcwd/include/libcw/macro_Libcwd_macros.h:1.5 Tue Feb 5 16:46:08 2002 +++ src/libcwd/include/libcw/macro_Libcwd_macros.h Sun Feb 10 19:00:24 2002 @@ -1,4 +1,4 @@ -// $Header: /cvsroot/l/li/libcw/src/libcwd/include/libcw/macro_Libcwd_macros.h,v 1.5 2002/02/06 00:46:08 libcw Exp $ +// $Header: /cvsroot/l/li/libcw/src/libcwd/include/libcw/macro_Libcwd_macros.h,v 1.6 2002/02/11 03:00:24 libcw Exp $ // // Copyright (C) 2000 - 2002, by // @@ -58,7 +58,7 @@ #define LIBCWD_STR1(x) #x #define LIBCWD_STR2(x) LIBCWD_STR1(x) #define LIBCWD_STR3 "LibcwDout at " __FILE__ ":" LIBCWD_STR2(__LINE__) "\n" -#define DEBUGDEBUGLIBCWDOUTMARKER ::write(2, LIBCWD_STR3, sizeof(LIBCWD_STR3) - 1); +#define DEBUGDEBUGLIBCWDOUTMARKER LibcwDebugThreads( ++__libcwd_tsd.internal_debugging_code ); ::write(2, LIBCWD_STR3, sizeof(LIBCWD_STR3) - 1); LibcwDebugThreads( --__libcwd_tsd.internal_debugging_code ); #else // !DEBUGDEBUGOUTPUT #define DEBUGDEBUGLIBCWDOUTMARKER #endif // !DEBUGDEBUGOUTPUT @@ -80,8 +80,8 @@ #define LibcwDoutScopeBegin( dc_namespace, debug_obj, cntrl ) \ do \ { \ - DEBUGDEBUGLIBCWDOUTMARKER \ LIBCWD_TSD_DECLARATION \ + DEBUGDEBUGLIBCWDOUTMARKER \ if (LIBCWD_DO_TSD_MEMBER_OFF(debug_obj) < 0) \ { \ using namespace ::libcw::debug; \ @@ -114,7 +114,7 @@ #ifndef DEBUGDEBUGLIBCWDOUTFATALMARKER #ifdef DEBUGDEBUGOUTPUT #define LIBCWD_STR4 "LibcwDoutFatal at " __FILE__ ":" LIBCWD_STR2(__LINE__) "\n" -#define DEBUGDEBUGLIBCWDOUTFATALMARKER ::write(2, LIBCWD_STR4, sizeof(LIBCWD_STR4) - 1); +#define DEBUGDEBUGLIBCWDOUTFATALMARKER LibcwDebugThreads( ++__libcwd_tsd.internal_debugging_code ); ::write(2, LIBCWD_STR4, sizeof(LIBCWD_STR4) - 1); LibcwDebugThreads( --__libcwd_tsd.internal_debugging_code ); #else #define DEBUGDEBUGLIBCWDOUTFATALMARKER #endif @@ -136,8 +136,8 @@ #define LibcwDoutFatalScopeBegin( dc_namespace, debug_obj, cntrl ) \ do \ { \ - DEBUGDEBUGLIBCWDOUTFATALMARKER \ LIBCWD_TSD_DECLARATION \ + DEBUGDEBUGLIBCWDOUTFATALMARKER \ using namespace ::libcw::debug; \ ::libcw::debug::channel_set_bootstrap_st __libcwd_channel_set(LIBCWD_DO_TSD(debug_obj) LIBCWD_COMMA_TSD); \ { \ ----------------------- End of diff ----------------------- |
From: Carlo W. <li...@us...> - 2002-02-10 05:42:10
|
CVSROOT : /cvsroot/libcw Module : src Commit time: 2002-01-10 05:42:08 UTC Modified files: libcwd/debug.cc libcwd/maintMakefile.in libcwd/threading.cc libcwd/include/libcw/private_struct_TSD.h libcwd/testsuite/module.cc libcwd/testsuite/libcwd.tst/dlopen.re Log message: Several fixes, trying to get 'make full-check' working again. ---------------------- diff included ---------------------- Index: src/libcwd/debug.cc diff -u src/libcwd/debug.cc:1.65 src/libcwd/debug.cc:1.66 --- src/libcwd/debug.cc:1.65 Sat Feb 9 18:42:16 2002 +++ src/libcwd/debug.cc Sat Feb 9 21:41:58 2002 @@ -1,4 +1,4 @@ -// $Header: /cvsroot/l/li/libcw/src/libcwd/debug.cc,v 1.65 2002/02/10 02:42:16 libcw Exp $ +// $Header: /cvsroot/l/li/libcw/src/libcwd/debug.cc,v 1.66 2002/02/10 05:41:58 libcw Exp $ // // Copyright (C) 2000 - 2001, by // @@ -285,7 +285,9 @@ channels::dc::system.NS_initialize("SYSTEM"); libcw_do.NS_init(); // Initialize debug code. +#ifdef LIBCWD_THREAD_SAFE libcw_do.keep_tsd(true); +#endif // Unlimit core size. #ifdef RLIMIT_CORE @@ -989,6 +991,7 @@ tsd_initialized = true; } +#ifdef LIBCWD_THREAD_SAFE namespace _private_ { void debug_tsd_init(LIBCWD_TSD_PARAM) { @@ -1002,6 +1005,7 @@ ); } } +#endif debug_tsd_st::~debug_tsd_st() { Index: src/libcwd/include/libcw/private_struct_TSD.h diff -u src/libcwd/include/libcw/private_struct_TSD.h:1.6 src/libcwd/include/libcw/private_struct_TSD.h:1.7 --- src/libcwd/include/libcw/private_struct_TSD.h:1.6 Wed Feb 6 16:38:38 2002 +++ src/libcwd/include/libcw/private_struct_TSD.h Sat Feb 9 21:41:58 2002 @@ -1,4 +1,4 @@ -// $Header: /cvsroot/l/li/libcw/src/libcwd/include/libcw/private_struct_TSD.h,v 1.6 2002/02/07 00:38:38 libcw Exp $ +// $Header: /cvsroot/l/li/libcw/src/libcwd/include/libcw/private_struct_TSD.h,v 1.7 2002/02/10 05:41:58 libcw Exp $ // // Copyright (C) 2001, by // @@ -157,8 +157,8 @@ int do_off_array[LIBCWD_DO_MAX]; // Thread Specific on/off counter for Debug Objects. debug_tsd_st* do_array[LIBCWD_DO_MAX];// Thread Specific Data of Debug Objects or NULL when no debug object. void cleanup_routine(void) throw(); -#endif int off_cnt_array[LIBCWD_DC_MAX]; // Thread Specific Data of Debug Channels. +#endif void S_initialize(void) throw(); Index: src/libcwd/maintMakefile.in diff -u src/libcwd/maintMakefile.in:1.19 src/libcwd/maintMakefile.in:1.20 --- src/libcwd/maintMakefile.in:1.19 Thu Jan 10 18:23:32 2002 +++ src/libcwd/maintMakefile.in Sat Feb 9 21:41:58 2002 @@ -104,12 +104,15 @@ @( \ for c in \ '--enable-maintainer-mode --enable-libcwd-threading --enable-libcwd-debugm --enable-libcwd-debug --disable-libcwd-debug-output --compilers=3.0.3,2.96,2.95.3' \ + '--enable-maintainer-mode --enable-libcwd-threading --enable-libcwd-debugt --enable-libcwd-debugm --enable-libcwd-debug --disable-libcwd-debug-output --compilers=3.0.3,2.96,2.95.3' \ '--enable-maintainer-mode --enable-libcwd-debugm --enable-libcwd-debug --disable-libcwd-debug-output --compilers=3.0.3,2.96,2.95.3' \ '--enable-maintainer-mode --enable-libcwd-threading --enable-libcwd-debugm --compilers=3.0.3,2.96,2.95.3' \ '--enable-maintainer-mode --enable-libcwd-debugm --compilers=3.0.3,2.96,2.95.3' \ '--enable-maintainer-mode --enable-libcwd-threading --enable-libcwd-debug --disable-libcwd-debug-output --compilers=3.0.3,2.96,2.95.3' \ + '--enable-maintainer-mode --enable-libcwd-threading --enable-libcwd-debugt --enable-libcwd-debug --disable-libcwd-debug-output --compilers=3.0.3,2.96,2.95.3' \ '--enable-maintainer-mode --enable-libcwd-debug --disable-libcwd-debug-output --compilers=3.0.3,2.96,2.95.3' \ '--enable-maintainer-mode --enable-libcwd-threading --enable-libcwd-debugm --enable-libcwd-debug --compilers=3.0.3,2.96,2.95.3' \ + '--enable-maintainer-mode --enable-libcwd-threading --enable-libcwd-debugt --enable-libcwd-debugm --enable-libcwd-debug --compilers=3.0.3,2.96,2.95.3' \ '--enable-maintainer-mode --enable-libcwd-debugm --enable-libcwd-debug --compilers=3.0.3,2.96,2.95.3' \ '--enable-maintainer-mode --enable-libcwd-threading --compilers=3.0.3,3.0.2,3.0.1,2.96,2.95.3,2.95.2' \ '--enable-maintainer-mode --compilers=3.0.3,3.0.2,3.0.1,2.96,2.95.3,2.95.2' \ Index: src/libcwd/testsuite/libcwd.tst/dlopen.re diff -u src/libcwd/testsuite/libcwd.tst/dlopen.re:1.10 src/libcwd/testsuite/libcwd.tst/dlopen.re:1.11 --- src/libcwd/testsuite/libcwd.tst/dlopen.re:1.10 Fri Jan 4 20:34:22 2002 +++ src/libcwd/testsuite/libcwd.tst/dlopen.re Sat Feb 9 21:41:58 2002 @@ -8,14 +8,14 @@ (.* )* MALLOC : malloc\(310\) = <unfinished> -BFD : address 0x[0-9a-f]* corresponds to module.cc:16 +BFD : address 0x[0-9a-f]* corresponds to module.cc:19 MALLOC : <continued> 0x[0-9a-f]* MALLOC : malloc\(300\) = <unfinished> -BFD : address 0x[0-9a-f]* corresponds to module.cc:7 +BFD : address 0x[0-9a-f]* corresponds to module.cc:10 MALLOC : <continued> 0x[0-9a-f]* MALLOC : Allocated memory: [0-9]* bytes in [0-9]* blocks\. -malloc 0x[0-9a-f]* module\.cc:7 void\*; \(sz = 300\) Allocated inside static_test_symbol -malloc 0x[0-9a-f]* module\.cc:16 void\*; \(sz = 310\) Allocated inside global_test_symbol +malloc 0x[0-9a-f]* module\.cc:10 void\*; \(sz = 300\) Allocated inside static_test_symbol +malloc 0x[0-9a-f]* module\.cc:19 void\*; \(sz = 310\) Allocated inside global_test_symbol // input lines 2 // output till ^NOTICE (malloc 0x[0-9a-f]* *(dl-[a-z]*\.c|stl_alloc\.h|specific\.c|dlerror\.c):[0-9]* *<unknown type>; \(sz = [0-9]*\) Index: src/libcwd/testsuite/module.cc diff -u src/libcwd/testsuite/module.cc:1.4 src/libcwd/testsuite/module.cc:1.5 --- src/libcwd/testsuite/module.cc:1.4 Thu Feb 7 20:03:47 2002 +++ src/libcwd/testsuite/module.cc Sat Feb 9 21:41:58 2002 @@ -1,5 +1,7 @@ // A shared library +#ifndef _GNU_SOURCE #define _GNU_SOURCE +#endif #include <libcw/sysd.h> #include <libcw/debug.h> Index: src/libcwd/threading.cc diff -u src/libcwd/threading.cc:1.8 src/libcwd/threading.cc:1.9 --- src/libcwd/threading.cc:1.8 Thu Feb 7 20:03:46 2002 +++ src/libcwd/threading.cc Sat Feb 9 21:41:58 2002 @@ -1,4 +1,4 @@ -// $Header: /cvsroot/l/li/libcw/src/libcwd/threading.cc,v 1.8 2002/02/08 04:03:46 libcw Exp $ +// $Header: /cvsroot/l/li/libcw/src/libcwd/threading.cc,v 1.9 2002/02/10 05:41:58 libcw Exp $ // // Copyright (C) 2001, by // @@ -84,7 +84,7 @@ tid = pthread_self(); initialize_global_mutexes(); // This is a good moment to initialize all pthread mutexes. mutex_tct<tsd_initialization_instance>::unlock(); - if (WST_multi_threaded) // Is this a second (or later) thread? + if (thread_index(pthread_self()) != 0) // Is this a second (or later) thread? { set_alloc_checking_off(*this); for (int i = 0; i < LIBCWD_DO_MAX; ++i) ----------------------- End of diff ----------------------- |
From: Carlo W. <li...@us...> - 2002-02-10 02:42:28
|
CVSROOT : /cvsroot/libcw Module : src Commit time: 2002-01-10 02:42:27 UTC Modified files: libcwd/INSTALL libcwd/bfd.cc libcwd/debug.cc libcwd/documentation/doxygen.config libcwd/documentation/location.dox libcwd/documentation/reference.dox Added files: libcwd/documentation/environment.dox Log message: Documentation update and fixes. ---------------------- diff included ---------------------- Index: src/libcwd/INSTALL diff -u src/libcwd/INSTALL:1.23 src/libcwd/INSTALL:1.24 --- src/libcwd/INSTALL:1.23 Tue Jan 8 10:14:37 2002 +++ src/libcwd/INSTALL Sat Feb 9 18:42:16 2002 @@ -27,7 +27,7 @@ i) The GNU compiler, version 2.95.1 or higher. Location: gnu/gcc/ - Current version: 3.0.2 + Current version: 3.0.4 Alternatively you can install only ia) gnu/gcc/gcc-core-<version>.tar.gz and @@ -55,7 +55,7 @@ Don't delete those libraries if you have them though since existing binaries might need to link with them. -libcwd-0.99.16 was tested with gcc-2.95.x, gcc-2.96-97 (RedHat) +libcwd-0.99.16 was tested with gcc-2.95.x, gcc-2.96-98 (RedHat) and gcc-3.0.x. Packages needed to run the testsuite @@ -125,10 +125,10 @@ If it can't find one (it will only find one when there is a g++ or c++ in your PATH), then you can specify the right path during configuration. For example, I configure libcwd as follows to compile with the latest CVS -version of g++, which I installed in /usr/local/bin/g++-cvs (and +version of g++, which I installed in /usr/local/bin/g++-cvs-3.0 (and /usr/local/bin is in my PATH): -CC="gcc-cvs" CXX="g++-cvs" ./configure +CC="gcc-cvs-3.0" CXX="g++-cvs-3.0" ./configure -=iii=- @@ -168,7 +168,7 @@ make tar // Create tar ball make rpm // Create rpms make ChangeLog // Generate ChangeLog from cvs database -make CC="gcc-3.0.2" CXX="g++-3.0.2" reconfig // Switch compilers keeping the same configuration +make CC="gcc-3.0.4" CXX="g++-3.0.4" reconfig // Switch compilers keeping the same configuration make full-check // Iterate over all configurations and all compiler versions It is not garanteed that these work on another machine than mine however. Index: src/libcwd/bfd.cc diff -u src/libcwd/bfd.cc:1.100 src/libcwd/bfd.cc:1.101 --- src/libcwd/bfd.cc:1.100 Fri Feb 8 14:29:29 2002 +++ src/libcwd/bfd.cc Sat Feb 9 18:42:16 2002 @@ -1,4 +1,4 @@ -// $Header: /cvsroot/l/li/libcw/src/libcwd/bfd.cc,v 1.100 2002/02/08 22:29:29 libcw Exp $ +// $Header: /cvsroot/l/li/libcw/src/libcwd/bfd.cc,v 1.101 2002/02/10 02:42:16 libcw Exp $ // // Copyright (C) 2000 - 2001, by // @@ -1368,7 +1368,7 @@ } /** - * \brief Move \p prototype to this location object; + * \brief Move \p prototype to this location object * * \p prototype must be \ref is_known "known" and the current object \ref is_known "unknown"; * \p prototype is clear()-ed afterwards. Index: src/libcwd/debug.cc diff -u src/libcwd/debug.cc:1.64 src/libcwd/debug.cc:1.65 --- src/libcwd/debug.cc:1.64 Fri Feb 8 14:29:29 2002 +++ src/libcwd/debug.cc Sat Feb 9 18:42:16 2002 @@ -1,4 +1,4 @@ -// $Header: /cvsroot/l/li/libcw/src/libcwd/debug.cc,v 1.64 2002/02/08 22:29:29 libcw Exp $ +// $Header: /cvsroot/l/li/libcw/src/libcwd/debug.cc,v 1.65 2002/02/10 02:42:16 libcw Exp $ // // Copyright (C) 2000 - 2001, by // @@ -131,7 +131,7 @@ /** * \brief The default %debug object. * - * The %debug object that is used by default by Dout and DoutFatal, the only %debug object used by libcwd itself. + * The %debug object that is used by default by \ref Dout and \ref DoutFatal, the only %debug object used by libcwd itself. * \sa \ref chapter_custom_do */ @@ -197,7 +197,7 @@ * * This channel is <EM>%always</EM> on; * it can not be turned off. - * It is not in the list of debug channels. + * It is not in the list of \ref ForAllDebugChannels "debug channels". * When used with a label it will print as many '>' * characters as the size of the largest real channel. */ Index: src/libcwd/documentation/doxygen.config diff -u src/libcwd/documentation/doxygen.config:1.2 src/libcwd/documentation/doxygen.config:1.3 --- src/libcwd/documentation/doxygen.config:1.2 Sat Dec 29 20:17:47 2001 +++ src/libcwd/documentation/doxygen.config Sat Feb 9 18:42:16 2002 @@ -16,8 +16,8 @@ REPEAT_BRIEF = YES ALWAYS_DETAILED_SEC = NO FULL_PATH_NAMES = YES -STRIP_FROM_PATH = /home/carlo/c++/libcw_branch-threading/src/libcwd/include/ \ - /home/carlo/c++/libcw_branch-threading/src/libcwd/ +STRIP_FROM_PATH = /home/carlo/c++/libcw/src/libcwd/include/ \ + /home/carlo/c++/libcw/src/libcwd/ INTERNAL_DOCS = NO STRIP_CODE_COMMENTS = YES CASE_SENSE_NAMES = YES Index: src/libcwd/documentation/environment.dox diff -u /dev/null src/libcwd/documentation/environment.dox:1.1 --- /dev/null Sat Feb 9 18:42:27 2002 +++ src/libcwd/documentation/environment.dox Sat Feb 9 18:42:16 2002 @@ -0,0 +1,18 @@ +/*! +\defgroup chapter_environment Environment Variables +\ingroup book_start +*/ +/*! +\page page_environment +\ingroup chapter_environment + +<dl compact> +<dt>LIBCWD_NO_STARTUP_MSGS<dd>Don't print anything before main(). + +<dt>LIBCWD_ALWAYS_PRINT_LOADING<dd>Print messages about loading +the shared libraries, even when this is done before libcw_do +is turned on (except when LIBCWD_NO_STARTUP_MSGS is defined). +</dl> + +*/ + Index: src/libcwd/documentation/location.dox diff -u src/libcwd/documentation/location.dox:1.2 src/libcwd/documentation/location.dox:1.3 --- src/libcwd/documentation/location.dox:1.2 Sat Dec 29 20:17:47 2001 +++ src/libcwd/documentation/location.dox Sat Feb 9 18:42:17 2002 @@ -9,10 +9,10 @@ \section section_The_BFD_library The BFD library Libcwd attempts to determine the source file and line number where memory is allocated. -It does this by directly reading the .stabs section of the ELF32 object files. -If you are using an Operating System that isn't ELF then you need to enable the use of libbfd for +It does this by directly reading the .debug_line (DWARF2) or .stabs (STABS) section of the ELF32 object files. +If you are using an Operating System that isn't ELF32 then you need to enable the use of GNU libbfd for this to work by configuring libcwd with \link enable_libcwd_libbfd --enable-libcwd-libbfd \endlink. -If you don't have an ELF system and you don't have libbfd installed and are not able to install it +If you don't have an ELF32 system and you don't have GNU libbfd installed and are not able to install it yourself (note: you also need libiberty and libdl) then you can disable it using \link enable_libcwd_location --disable-libcwd-location \endlink. There is a seperate page that deals with libcwd and \link group_locations location \endlink support. Index: src/libcwd/documentation/reference.dox diff -u src/libcwd/documentation/reference.dox:1.2 src/libcwd/documentation/reference.dox:1.3 --- src/libcwd/documentation/reference.dox:1.2 Sat Dec 29 20:17:47 2001 +++ src/libcwd/documentation/reference.dox Sat Feb 9 18:42:17 2002 @@ -50,6 +50,7 @@ <li>\ref chapter_custom_debug_h <li>\ref chapter_alloc_locations <li>\ref group_configuration + <li>\ref chapter_environment </ul> */ ----------------------- End of diff ----------------------- |
From: Carlo W. <li...@us...> - 2002-02-09 03:23:11
|
CVSROOT : /cvsroot/libcw Module : src Commit time: 2002-01-09 03:23:09 UTC Modified files: libcwd/configure.in libcwd/debugmalloc.cc libcwd/include/libcw/debug_config.ho.in Log message: Support _libc_malloc et al too. ---------------------- diff included ---------------------- Index: src/libcwd/configure.in diff -u src/libcwd/configure.in:1.101 src/libcwd/configure.in:1.102 --- src/libcwd/configure.in:1.101 Sat Feb 2 20:15:11 2002 +++ src/libcwd/configure.in Fri Feb 8 19:22:59 2002 @@ -1,5 +1,5 @@ dnl Process this file with autoconf to produce a configure script. -AC_REVISION($Revision: 1.101 $)dnl +AC_REVISION($Revision: 1.102 $)dnl dnl General intialization of `autoconf' varaibles. dnl Ensure that the directory specified with --srcdir was correct @@ -220,6 +220,8 @@ CW_CONFIG_DEBUGMARKER=undef AC_SUBST(CW_CONFIG_HAVE___LIBC_MALLOC) CW_CONFIG_HAVE___LIBC_MALLOC=undef +AC_SUBST(CW_CONFIG_HAVE__LIBC_MALLOC) +CW_CONFIG_HAVE__LIBC_MALLOC=undef AC_SUBST(CW_CONFIG_HAVE_DLOPEN) CW_CONFIG_HAVE_DLOPEN=undef @@ -431,11 +433,13 @@ AC_C_BIGENDIAN dnl Check for library functions. -AC_CHECK_FUNCS(getgid getegid getgroups __libc_malloc wmemcpy) +AC_CHECK_FUNCS(getgid getegid getgroups __libc_malloc _libc_malloc wmemcpy) if test "$ac_cv_func___libc_malloc" = "yes"; then CW_CONFIG_HAVE___LIBC_MALLOC=define -fi +else if test "$ac_cv_func__libc_malloc" = "yes"; then + CW_CONFIG_HAVE__LIBC_MALLOC=define +fi fi dnl Check for system services. Index: src/libcwd/debugmalloc.cc diff -u src/libcwd/debugmalloc.cc:1.81 src/libcwd/debugmalloc.cc:1.82 --- src/libcwd/debugmalloc.cc:1.81 Wed Feb 6 16:38:38 2002 +++ src/libcwd/debugmalloc.cc Fri Feb 8 19:22:59 2002 @@ -1,4 +1,4 @@ -// $Header: /cvsroot/l/li/libcw/src/libcwd/debugmalloc.cc,v 1.81 2002/02/07 00:38:38 libcw Exp $ +// $Header: /cvsroot/l/li/libcw/src/libcwd/debugmalloc.cc,v 1.82 2002/02/09 03:22:59 libcw Exp $ // // Copyright (C) 2000 - 2001, by // @@ -198,6 +198,12 @@ #define __libcwd_realloc realloc #define __libcwd_free free #define dc_malloc dc::malloc +#ifdef LIBCWD_HAVE__LIBC_MALLOC +#define __libc_malloc _libc_malloc +#define __libc_calloc _libc_calloc +#define __libc_realloc _libc_realloc +#define __libc_free _libc_free +#endif #else #define __libc_malloc malloc #define __libc_calloc calloc Index: src/libcwd/include/libcw/debug_config.ho.in diff -u src/libcwd/include/libcw/debug_config.ho.in:1.18 src/libcwd/include/libcw/debug_config.ho.in:1.19 --- src/libcwd/include/libcw/debug_config.ho.in:1.18 Tue Feb 5 16:46:08 2002 +++ src/libcwd/include/libcw/debug_config.ho.in Fri Feb 8 19:22:59 2002 @@ -1,5 +1,5 @@ // @configure_input@ -// $Header: /cvsroot/l/li/libcw/src/libcwd/include/libcw/debug_config.ho.in,v 1.18 2002/02/06 00:46:08 libcw Exp $ +// $Header: /cvsroot/l/li/libcw/src/libcwd/include/libcw/debug_config.ho.in,v 1.19 2002/02/09 03:22:59 libcw Exp $ // // Copyright (C) 2000 - 2001, by // @@ -267,7 +267,11 @@ // #ifdef DEBUGMALLOC -#@CW_CONFIG_HAVE___LIBC_MALLOC@ DEBUGMALLOCEXTERNALCLINKAGE +#@CW_CONFIG_HAVE___LIBC_MALLOC@ LIBCWD_HAVE___LIBC_MALLOC +#@CW_CONFIG_HAVE__LIBC_MALLOC@ LIBCWD_HAVE__LIBC_MALLOC +#if defined(LIBCWD_HAVE___LIBC_MALLOC) || defined(LIBCWD_HAVE__LIBC_MALLOC) +#define DEBUGMALLOCEXTERNALCLINKAGE +#endif #endif #ifdef DEBUGUSEBFD ----------------------- End of diff ----------------------- |
From: Carlo W. <li...@us...> - 2002-02-08 22:33:38
|
CVSROOT : /cvsroot/libcw Module : src Commit time: 2002-01-08 22:33:38 UTC Added files: libcwd/environ.cc libcwd/include/libcw/private_environ.h Log message: And the two new files that go with it... ---------------------- diff included ---------------------- Index: src/libcwd/environ.cc diff -u /dev/null src/libcwd/environ.cc:1.1 --- /dev/null Fri Feb 8 14:33:38 2002 +++ src/libcwd/environ.cc Fri Feb 8 14:33:27 2002 @@ -0,0 +1,33 @@ +// $Header: /cvsroot/l/li/libcw/src/libcwd/environ.cc,v 1.1 2002/02/08 22:33:27 libcw Exp $ +// +// Copyright (C) 2002, by +// +// Carlo Wood, Run on IRC <ca...@al...> +// RSA-1024 0x624ACAD5 1997-01-26 Sign & Encrypt +// Fingerprint16 = 32 EC A7 B6 AC DB 65 A6 F6 F6 55 DD 1C DC FF 61 +// +// This file may be distributed under the terms of the Q Public License +// version 1.0 as appearing in the file LICENSE.QPL included in the +// packaging of this file. +// + +#include "sys.h" +#include <cstdlib> +#include "cwd_debug.h" + +namespace libcw { + namespace debug { + namespace _private_ { + +bool always_print_loading = false; +bool suppress_startup_msgs = false; + +void process_environment_variables(void) +{ + always_print_loading = (getenv("LIBCWD_PRINT_LOADING") != NULL); + suppress_startup_msgs = (getenv("LIBCWD_NO_STARTUP_MSGS") != NULL); +} + + } // namespace _private_ + } // namespace debug +} // namespace libcw Index: src/libcwd/include/libcw/private_environ.h diff -u /dev/null src/libcwd/include/libcw/private_environ.h:1.1 --- /dev/null Fri Feb 8 14:33:38 2002 +++ src/libcwd/include/libcw/private_environ.h Fri Feb 8 14:33:28 2002 @@ -0,0 +1,43 @@ +// $Header: /cvsroot/l/li/libcw/src/libcwd/include/libcw/private_environ.h,v 1.1 2002/02/08 22:33:28 libcw Exp $ +// +// Copyright (C) 2002, by +// +// Carlo Wood, Run on IRC <ca...@al...> +// RSA-1024 0x624ACAD5 1997-01-26 Sign & Encrypt +// Fingerprint16 = 32 EC A7 B6 AC DB 65 A6 F6 F6 55 DD 1C DC FF 61 +// +// This file may be distributed under the terms of the Q Public License +// version 1.0 as appearing in the file LICENSE.QPL included in the +// packaging of this file. +// + +#ifndef LIBCW_PRIVATE_FUNCTIONS_H +#define LIBCW_PRIVATE_FUNCTIONS_H + +#ifndef LIBCW_SYSD_H +#error "You need to #include "sys.h" at the top of every source file (which in turn should #include <libcw/sysd.h>)." +#endif + +namespace libcw { + namespace debug { + namespace _private_ { + +extern void process_environment_variables(void); + +// Environment variable: LIBCWD_PRINT_LOADING +// Print the list with "BFD : Loading debug info from /lib/libc.so.6 (0x40271000) ... done (4189 symbols)" etc. +// at the start of the program *even* when this happens before main() is reached and libcw_do and dc::bfd are +// still turned off. +extern bool always_print_loading; + +// Environment variable: LIBCWD_NO_STARTUP_MSGS +// This will suppress all messages that normally could be printed +// before reaching main, including warning messages. +// This overrides LIBCWD_PRINT_LOADING. +extern bool suppress_startup_msgs; + + } // namespace _private_ + } // namespace debug +} // namespace libcw + +#endif // LIBCW_PRIVATE_FUNCTIONS_H ----------------------- End of diff ----------------------- |
From: Carlo W. <li...@us...> - 2002-02-08 22:29:42
|
CVSROOT : /cvsroot/libcw Module : src Commit time: 2002-01-08 22:29:40 UTC Modified files: libcwd/Makefile.am libcwd/NEWS libcwd/bfd.cc libcwd/debug.cc libcwd/include/libcw/Makefile.am libcwd/include/libcw/debug.h Log message: Added two environment variables to suppress (or enable) debug output during initialization. This was requested by a user in order to be able to suppress *all* debug output. ---------------------- diff included ---------------------- Index: src/libcwd/Makefile.am diff -u src/libcwd/Makefile.am:1.45 src/libcwd/Makefile.am:1.46 --- src/libcwd/Makefile.am:1.45 Sat Feb 2 20:15:11 2002 +++ src/libcwd/Makefile.am Fri Feb 8 14:29:29 2002 @@ -21,6 +21,7 @@ libcwd_la_SOURCES = \ threading.cc \ elf32.cc \ + environ.cc \ bfd.cc \ debug.cc \ debugmalloc.cc \ Index: src/libcwd/NEWS diff -u src/libcwd/NEWS:1.66 src/libcwd/NEWS:1.67 --- src/libcwd/NEWS:1.66 Thu Feb 7 20:03:46 2002 +++ src/libcwd/NEWS Fri Feb 8 14:29:29 2002 @@ -10,6 +10,13 @@ allow the use of the testsuite together with --enable-libcwd-debug. (You shouldn't use either unless you are hacking libcwd itself). + New are environment variables that influence libcwd. + At the moment there are two: + LIBCWD_NO_STARTUP_MSGS : Don't print anything before main(). + LIBCWD_ALWAYS_PRINT_LOADING : Print messages about loading + the shared libraries, even when this is done before libcw_do + is turned on (except when LIBCWD_NO_STARTUP_MSGS is defined). + Miscellaneous: - The configuration option --disable-libcwd-location is fixed. - Automake-1.5 now works. Index: src/libcwd/bfd.cc diff -u src/libcwd/bfd.cc:1.99 src/libcwd/bfd.cc:1.100 --- src/libcwd/bfd.cc:1.99 Sat Feb 2 20:15:11 2002 +++ src/libcwd/bfd.cc Fri Feb 8 14:29:29 2002 @@ -1,4 +1,4 @@ -// $Header: /cvsroot/l/li/libcw/src/libcwd/bfd.cc,v 1.99 2002/02/03 04:15:11 libcw Exp $ +// $Header: /cvsroot/l/li/libcw/src/libcwd/bfd.cc,v 1.100 2002/02/08 22:29:29 libcw Exp $ // // Copyright (C) 2000 - 2001, by // @@ -11,7 +11,6 @@ // packaging of this file. // -#define ALWAYS_PRINT_LOADING // Define to temporally turn on dc::bfd in order to print the "Loading debug info from ..." lines. #undef DEBUGDEBUGBFD // Define to add debug code for this file. #include <libcw/debug_config.h> @@ -964,13 +963,14 @@ init_debugmalloc(); #endif -#ifdef ALWAYS_PRINT_LOADING - // We want debug output to BFD 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 (_private_::always_print_loading && !_private_::suppress_startup_msgs) + { + // We want debug output to BFD + Debug( libcw_do.force_on(state) ); + Debug( dc::bfd.force_on(state2, "BFD") ); + } // Initialize object files list, we don't really need the // write lock because this function is Single Threaded. @@ -1054,10 +1054,11 @@ // We put this outside the 'internal' region because it might call __pthread_do_exit. LIBCWD_CLEANUP_POP_RESTORE(false) -#ifdef ALWAYS_PRINT_LOADING - Debug( dc::bfd.restore(state2) ); - Debug( libcw_do.restore(state) ); -#endif + if (_private_::always_print_loading) + { + Debug( dc::bfd.restore(state2) ); + Debug( libcw_do.restore(state) ); + } WST_initialized = true; // MT: Safe, this function is Single Threaded. Index: src/libcwd/debug.cc diff -u src/libcwd/debug.cc:1.63 src/libcwd/debug.cc:1.64 --- src/libcwd/debug.cc:1.63 Thu Feb 7 20:03:46 2002 +++ src/libcwd/debug.cc Fri Feb 8 14:29:29 2002 @@ -1,4 +1,4 @@ -// $Header: /cvsroot/l/li/libcw/src/libcwd/debug.cc,v 1.63 2002/02/08 04:03:46 libcw Exp $ +// $Header: /cvsroot/l/li/libcw/src/libcwd/debug.cc,v 1.64 2002/02/08 22:29:29 libcw Exp $ // // Copyright (C) 2000 - 2001, by // @@ -265,6 +265,7 @@ #ifdef LIBCWD_THREAD_SAFE _private_::initialize_global_mutexes(); #endif + _private_::process_environment_variables(); // Fatal channels need to be marked fatal, otherwise we get into an endless loop // when they are used before they are created. @@ -292,7 +293,7 @@ if (getrlimit(RLIMIT_CORE, &corelim)) DoutFatal(dc::fatal|error_cf, "getrlimit(RLIMIT_CORE, &corelim)"); corelim.rlim_cur = corelim.rlim_max; - if (corelim.rlim_max != RLIM_INFINITY) + if (corelim.rlim_max != RLIM_INFINITY && !_private_::suppress_startup_msgs) { debug_ct::OnOffState state; libcw_do.force_on(state); @@ -304,10 +305,13 @@ if (setrlimit(RLIMIT_CORE, &corelim)) DoutFatal(dc::fatal|error_cf, "unlimit core size failed"); #else - debug_ct::OnOffState state; - libcw_do.force_on(state); - Dout(dc::warning, "Please unlimit core size manually"); - libcw_do.restore(state); + if (!_private_::suppress_startup_msgs) + { + debug_ct::OnOffState state; + libcw_do.force_on(state); + Dout(dc::warning, "Please unlimit core size manually"); + libcw_do.restore(state); + } #endif #ifdef DEBUGUSEBFD Index: src/libcwd/include/libcw/Makefile.am diff -u src/libcwd/include/libcw/Makefile.am:1.22 src/libcwd/include/libcw/Makefile.am:1.23 --- src/libcwd/include/libcw/Makefile.am:1.22 Thu Jan 24 13:16:09 2002 +++ src/libcwd/include/libcw/Makefile.am Fri Feb 8 14:29:29 2002 @@ -39,6 +39,7 @@ private_allocator.h \ private_assert.h \ private_debug_stack.h \ + private_environ.h \ private_internal_string.h \ private_internal_stringstream.h \ private_internal_vector.h \ Index: src/libcwd/include/libcw/debug.h diff -u src/libcwd/include/libcw/debug.h:1.40 src/libcwd/include/libcw/debug.h:1.41 --- src/libcwd/include/libcw/debug.h:1.40 Fri Jan 18 21:08:54 2002 +++ src/libcwd/include/libcw/debug.h Fri Feb 8 14:29:29 2002 @@ -1,4 +1,4 @@ -// $Header: /cvsroot/l/li/libcw/src/libcwd/include/libcw/debug.h,v 1.40 2002/01/19 05:08:54 libcw Exp $ +// $Header: /cvsroot/l/li/libcw/src/libcwd/include/libcw/debug.h,v 1.41 2002/02/08 22:29:29 libcw Exp $ // // Copyright (C) 2000 - 2001, by // @@ -226,6 +226,7 @@ #include <libcw/macro_ForAllDebugChannels.h> #include <libcw/macro_ForAllDebugObjects.h> +#include <libcw/private_environ.h> // Include the inline functions. #include <libcw/class_channel.inl> // Debug channels. ----------------------- End of diff ----------------------- |
From: Carlo W. <li...@us...> - 2002-02-08 21:32:25
|
CVSROOT : /cvsroot/libcw Module : src Commit time: 2002-01-08 21:32:23 UTC Modified files: libcwd/documentation/tutorial/tut1.m4 Log message: Little fix. ---------------------- diff included ---------------------- Index: src/libcwd/documentation/tutorial/tut1.m4 diff -u src/libcwd/documentation/tutorial/tut1.m4:1.3 src/libcwd/documentation/tutorial/tut1.m4:1.4 --- src/libcwd/documentation/tutorial/tut1.m4:1.3 Thu Feb 7 20:03:47 2002 +++ src/libcwd/documentation/tutorial/tut1.m4 Fri Feb 8 13:32:13 2002 @@ -43,7 +43,7 @@ a compile error in <libcw/sysd.h> telling you so.</P> <DIV class="faq-frame"><H4>FAQ</H4><UL class="faq"> -<LI><A HREF="faq.html#GNU_SOURCE">Won't this define make my code non-portable?</LI> +<LI><A HREF="faq.html#GNU_SOURCE">Won't this define make my code non-portable?</A></LI> </UL></DIV> <H3><CODE>#include <libcw/sysd.h></CODE></H3> ----------------------- End of diff ----------------------- |
From: Carlo W. <li...@us...> - 2002-02-08 04:03:59
|
CVSROOT : /cvsroot/libcw Module : src Commit time: 2002-01-08 04:03:58 UTC Modified files: libcwd/NEWS libcwd/debug.cc libcwd/demangle3.cc libcwd/threading.cc libcwd/wrapcnclpnts.cc libcwd/documentation/html.footer libcwd/documentation/doxygen-examples/markers.cc libcwd/documentation/tutorial/channel.cc libcwd/documentation/tutorial/faq.m4 libcwd/documentation/tutorial/hello_world.cc libcwd/documentation/tutorial/log_file.cc libcwd/documentation/tutorial/tut1.m4 libcwd/documentation/tutorial/tut2.m4 libcwd/documentation/tutorial/tut3.m4 libcwd/documentation/tutorial/tut6.m4 libcwd/documentation/tutorial/examples5/sys.h libcwd/documentation/tutorial/examples7/sys.h libcwd/example-project/sys.h libcwd/include/libcw/class_debug.h libcwd/include/libcw/private_threading.h libcwd/include/libcw/struct_debug_tsd.h libcwd/include/libcw/sysd.ho.in libcwd/include/libcw/type_info.h libcwd/tests/lines.cc libcwd/tests/stabs.cc libcwd/tests/sys.h libcwd/testsuite/module.cc libcwd/testsuite/libcwd.tst/sys.h Log message: Bug fixes for doxygen. Added debug_ct::keep_tsd Added documentation about the need to define _GNU_SOURCE and updated all sys.h related things. ---------------------- diff included ---------------------- Index: src/libcwd/NEWS diff -u src/libcwd/NEWS:1.65 src/libcwd/NEWS:1.66 --- src/libcwd/NEWS:1.65 Fri Jan 18 21:08:53 2002 +++ src/libcwd/NEWS Thu Feb 7 20:03:46 2002 @@ -61,6 +61,17 @@ Reason: the temporary stringstream that was returned was only valid inside a Dout to begin with. The use of get_os() was dangerous. + You will need to add + #ifndef _GNU_SOURCE + #define _GNU_SOURCE + #endif + to your "sys.h" file, prior to including any other header file, + just before including <libcw/sysd.h>. This is needed because libcwd + uses GNU extensions. Of course, it is not necessary to define + _GNU_SOURCE when CWDEBUG isn't defined, so you may put it inside the + #ifdef CWDEBUG ... #endif. + If you don't understand this, read documentation/html/preparation.html. + Bug fixes: When using .stabs, each first line of code after a source file scope change Index: src/libcwd/debug.cc diff -u src/libcwd/debug.cc:1.62 src/libcwd/debug.cc:1.63 --- src/libcwd/debug.cc:1.62 Tue Feb 5 16:46:07 2002 +++ src/libcwd/debug.cc Thu Feb 7 20:03:46 2002 @@ -1,4 +1,4 @@ -// $Header: /cvsroot/l/li/libcw/src/libcwd/debug.cc,v 1.62 2002/02/06 00:46:07 libcw Exp $ +// $Header: /cvsroot/l/li/libcw/src/libcwd/debug.cc,v 1.63 2002/02/08 04:03:46 libcw Exp $ // // Copyright (C) 2000 - 2001, by // @@ -284,6 +284,7 @@ channels::dc::system.NS_initialize("SYSTEM"); libcw_do.NS_init(); // Initialize debug code. + libcw_do.keep_tsd(true); // Unlimit core size. #ifdef RLIMIT_CORE @@ -1069,7 +1070,7 @@ } /** - * \fn void list_channels_on(debug_ct const& debug_object) + * \fn void list_channels_on(debug_ct& debug_object) * \ingroup group_special * * \brief List all %debug %channels to a given %debug object. @@ -1425,6 +1426,16 @@ core_dump(); // off() and on() where called and not in equal pairs. LIBCWD_TSD_MEMBER_OFF = state._off; // Restore. } + +#ifdef LIBCWD_THREAD_SAFE + bool debug_ct::keep_tsd(bool keep) + { + LIBCWD_TSD_DECLARATION + bool old = LIBCWD_TSD_MEMBER(tsd_keep); + LIBCWD_TSD_MEMBER(tsd_keep) = keep; + return old; + } +#endif void channel_ct::force_on(channel_ct::OnOffState& state, char const* label) { Index: src/libcwd/demangle3.cc diff -u src/libcwd/demangle3.cc:1.13 src/libcwd/demangle3.cc:1.14 --- src/libcwd/demangle3.cc:1.13 Wed Jan 9 08:16:04 2002 +++ src/libcwd/demangle3.cc Thu Feb 7 20:03:46 2002 @@ -1,4 +1,4 @@ -// $Header: /cvsroot/l/li/libcw/src/libcwd/demangle3.cc,v 1.13 2002/01/09 16:16:04 libcw Exp $ +// $Header: /cvsroot/l/li/libcw/src/libcwd/demangle3.cc,v 1.14 2002/02/08 04:03:46 libcw Exp $ // // Copyright (C) 2001, by // @@ -249,7 +249,7 @@ }; enum param_qualifier_nt { - vendor_extention = 'U', + vendor_extension = 'U', array = 'A', pointer_to_member = 'M' }; @@ -1240,7 +1240,7 @@ failure = true; break; } - qualifiers->add_qualifier_start(vendor_extention, start_pos, source_name, M_inside_substitution); + qualifiers->add_qualifier_start(vendor_extension, start_pos, source_name, M_inside_substitution); continue; } case 'A': @@ -1816,7 +1816,7 @@ || (M_pos += decode_encoding(M_str + M_pos, output)) < 0) FAILURE; RETURN; - case 'C': // GNU extention? + case 'C': // GNU extension? { internal_string first; output += "construction vtable for "; Index: src/libcwd/documentation/doxygen-examples/markers.cc diff -u src/libcwd/documentation/doxygen-examples/markers.cc:1.2 src/libcwd/documentation/doxygen-examples/markers.cc:1.3 --- src/libcwd/documentation/doxygen-examples/markers.cc:1.2 Sat Dec 29 20:17:47 2001 +++ src/libcwd/documentation/doxygen-examples/markers.cc Thu Feb 7 20:03:47 2002 @@ -1,3 +1,4 @@ +#define _GNU_SOURCE #include <libcw/sysd.h> #include <libcw/debug.h> Index: src/libcwd/documentation/html.footer diff -u src/libcwd/documentation/html.footer:1.2 src/libcwd/documentation/html.footer:1.3 --- src/libcwd/documentation/html.footer:1.2 Sat Dec 29 20:17:47 2001 +++ src/libcwd/documentation/html.footer Thu Feb 7 20:03:47 2002 @@ -1,4 +1,4 @@ -<ADDRESS>Copyright © 2001 Carlo Wood. All rights reserved.</ADDRESS> +<ADDRESS>Copyright © 2001, 2002 Carlo Wood. All rights reserved.</ADDRESS> </DIV> </BODY> Index: src/libcwd/documentation/tutorial/channel.cc diff -u src/libcwd/documentation/tutorial/channel.cc:1.2 src/libcwd/documentation/tutorial/channel.cc:1.3 --- src/libcwd/documentation/tutorial/channel.cc:1.2 Sat Dec 29 20:17:49 2001 +++ src/libcwd/documentation/tutorial/channel.cc Thu Feb 7 20:03:47 2002 @@ -2,17 +2,16 @@ // Please see the "example-project" in the source distribution of libcwd // for a better Real Life example. +#define _GNU_SOURCE #include <libcw/sysd.h> #define DEBUGCHANNELS ::example // Where we'll put our namespace dc #include <libcw/debug.h> -#ifdef CWDEBUG namespace example { // namespace dc cannot be put in :: namespace dc { libcw::debug::channel_ct ghost("GHOST"); // Create our own Debug Channel } } -#endif int main(void) { Index: src/libcwd/documentation/tutorial/examples5/sys.h diff -u src/libcwd/documentation/tutorial/examples5/sys.h:1.1 src/libcwd/documentation/tutorial/examples5/sys.h:1.2 --- src/libcwd/documentation/tutorial/examples5/sys.h:1.1 Sat Dec 29 17:22:09 2001 +++ src/libcwd/documentation/tutorial/examples5/sys.h Thu Feb 7 20:03:47 2002 @@ -1,6 +1,11 @@ -#ifdef HAVE_CONFIG_H // This is just an example of what you could do -#include "config.h" // when using autoconf for your project. +// This is just an example of what you could do when using autoconf for your project. +#ifdef HAVE_CONFIG_H +#include "config.h" #endif -#ifdef CWDEBUG // This is needed so that others can compile -#include <libcw/sysd.h> // your application without having libcwd installed. +// This is needed so that others can compile your application without having libcwd installed. +#ifdef CWDEBUG +#ifndef _GNU_SOURCE +#define _GNU_SOURCE // Libcwd uses GNU extensions. +#endif +#include <libcw/sysd.h> #endif Index: src/libcwd/documentation/tutorial/examples7/sys.h diff -u src/libcwd/documentation/tutorial/examples7/sys.h:1.2 src/libcwd/documentation/tutorial/examples7/sys.h:1.3 --- src/libcwd/documentation/tutorial/examples7/sys.h:1.2 Sat Dec 29 20:17:49 2001 +++ src/libcwd/documentation/tutorial/examples7/sys.h Thu Feb 7 20:03:47 2002 @@ -1,3 +1,10 @@ +#ifdef CWDEBUG +#ifndef _GNU_SOURCE +#define _GNU_SOURCE +#endif +#include <libcw/sysd.h> +#endif + // Bug workaround for libstdc++, avoid warnings like // /usr/include/g++-3/iostream.h:253:5: "_G_CLOG_CONFLICT" is not defined #include <_G_config.h> @@ -6,8 +13,4 @@ #endif #ifndef _G_HAS_LABS #define _G_HAS_LABS 1 -#endif - -#ifdef CWDEBUG -#include <libcw/sysd.h> #endif Index: src/libcwd/documentation/tutorial/faq.m4 diff -u src/libcwd/documentation/tutorial/faq.m4:1.3 src/libcwd/documentation/tutorial/faq.m4:1.4 --- src/libcwd/documentation/tutorial/faq.m4:1.3 Fri Jan 18 21:08:54 2002 +++ src/libcwd/documentation/tutorial/faq.m4 Thu Feb 7 20:03:47 2002 @@ -14,8 +14,22 @@ <HR SIZE=1 NOSHADE> +<A name="GNU_SOURCE"></A> +<H3>1. Won't this define make my code non-portable?</H3> + +<P>No, not unless you actually use the GNU extensions in parts of your +application that need to be portable (like non-debugging code). +While debugging the application you will only benefit from using as +much compiler support as you can get, allowing the compiler to tell you +what could possibly be wrong with your code. +Once the application works, you don't have to define _GNU_SOURCE +because you won't be including the debug code anymore, nor link with +libcwd. Of course, when you are not sure whether or not new code +that you added is a GNU extension or not, you should try to compile it +with CWDEBUG undefined.</P> + <A name="sysd.h"></A> -<H3>1. Why do I have to include "libcw/sysd.h" as first header file?</H3> +<H3>2. Why do I have to include "libcw/sysd.h" as first header file?</H3> <P>This header file is used to fix operating systems bugs, including bugs in the system header files. The only way it can do this is when it @@ -32,7 +46,7 @@ will definitely lead to compile errors in that header file. </P> <A name="libcwd"></A> -<H3>2. What is this <SPAN class="H3code">libcw</SPAN> talk? +<H3>3. What is this <SPAN class="H3code">libcw</SPAN> talk? Aren't you forgetting the <U><SPAN class="H3code">d</SPAN></U> of <SPAN class="H3code">libcw<U>d</U></SPAN>?</H3> @@ -49,7 +63,7 @@ guessed that ;) ].</P> <A name="dir"></A> -<H3>3. Why do I need to type "<SPAN class="H3code">libcw/sysd.h</SPAN>" +<H3>4. Why do I need to type "<SPAN class="H3code">libcw/sysd.h</SPAN>" and not just "<SPAN class="H3code">sysd.h</SPAN>"?</H3> <P>The header file names of libcw are not unique. In order to uniquely @@ -63,20 +77,20 @@ collision in that case.</P> <A name="debug.h"></A> -<H3>4. What is defined <EM>exactly</EM> in <SPAN class="H3code">libcw/debug.h</SPAN>?</H3> +<H3>5. What is defined <EM>exactly</EM> in <SPAN class="H3code">libcw/debug.h</SPAN>?</H3> <P>Everything. Go and read the <A HREF="../html/reference.html>Reference Manual</A> to get <EM>all</EM> gory details if you dare.</P> <A name="macros"></A> -<H3>5. Why are you using macros for <SPAN class="H3code">Debug</SPAN> and <SPAN class="H3code">Dout</SPAN>?</H3> +<H3>6. Why are you using macros for <SPAN class="H3code">Debug</SPAN> and <SPAN class="H3code">Dout</SPAN>?</H3> <P>Because it is the only way to easy remove debugging code from an application as function of a macro and because it allows for the fastest possible code even without optimisation, which is often the case while debugging. A more detailed explanation is given in the <A HREF="../html/page_why_macro.html">Reference Manual</A>.</P> <A name="Debug"></A> -<H3>6. Why do I need to type the <SPAN class="H3code">Debug( )</SPAN> around it?</H3> +<H3>7. Why do I need to type the <SPAN class="H3code">Debug( )</SPAN> around it?</H3> <P>The macro <SPAN class="code">Debug()</SPAN> is used for two things. 1) The code inside it is only included when the macro <SPAN class="code">CWDEBUG</SPAN> is defined. 2) It includes the namespace <SPAN class="code">libcw::debug</SPAN>.</P> @@ -101,7 +115,7 @@ explanation of <SPAN class="code">DEBUGCHANNELS</SPAN>.</P> <A name="DebugChannels"></A> -<H3>7. Which Debug Channels exist? Can I make my own?</H3> +<H3>8. Which Debug Channels exist? Can I make my own?</H3> <P>This question is covered in chapter <A HREF="../html/group__group__debug__channels.html">Controlling The Output Level (Debug Channels)</A> @@ -139,7 +153,7 @@ with the source distribution of libcwd for a Real Life example.</P> <A name="recursive"></A> -<H3>8. Can I turn Debug Channels off again? Can I do that recursively?</H3> +<H3>9. Can I turn Debug Channels off again? Can I do that recursively?</H3> <P>Debug channels can be switched on and off at any time. At the start of your program you should turn on the channels of your choice by calling <SPAN class="code">Debug(dc::<EM>channel</EM>.on())</SPAN> @@ -163,7 +177,7 @@ <SPAN class="code">off()</SPAN> and <SPAN class="code">on()</SPAN> only respectively increment and decrement a counter.</P> <A name="Channel"></A> -<H3>9. Why do you call it a Debug <EM>Channel</EM>? What <EM>is</EM> a Debug Channel?</H3> +<H3>10. Why do you call it a Debug <EM>Channel</EM>? What <EM>is</EM> a Debug Channel?</H3> <P>A Debug Channel is a fictious "news channel". It should contain information of a certain kind that is interesting or not interesting as a whole. A Debug Channel is not a device or stream, a single debug channel is best @@ -173,7 +187,7 @@ to the output stream of the underlaying debug object.</P> <A name="OwnDebugObject"></A> -<H3>10. Can I make my own Debug Object?</H3> +<H3>11. Can I make my own Debug Object?</H3> <P><A HREF="../html/group__chapter__custom__do.html">Yes</A>, you can make as many debug objects as you like. Each debug object is associated with one ostream. However, the default debug output macros <CODE>Dout</CODE> and @@ -193,7 +207,7 @@ </PRE> <A name="recursive2"></A> -<H3>11. Can I turn Debug Objects off again? Can I do that recursively?</H3> +<H3>12. Can I turn Debug Objects off again? Can I do that recursively?</H3> <P>Debug objects can be switched on and off at any time. At the start of your program you should turn on the debug object(s) by calling <SPAN class="code">Debug(<EM>debugobject</EM>.on())</SPAN> @@ -214,7 +228,7 @@ <SPAN class="code">off()</SPAN> and <SPAN class="code">on()</SPAN> only respectively increment and decrement a counter.</P> <A name="SetOstream"></A> -<H3>12. How do I set a new <SPAN class="H3code">ostream</SPAN> for a given Debug Object?</H3> +<H3>13. How do I set a new <SPAN class="H3code">ostream</SPAN> for a given Debug Object?</H3> <P>You can change the <SPAN class="code">ostream</SPAN> that is associated with a Debug Object at any time. For example, changing the <SPAN class="code">ostream</SPAN> of <SPAN class="code">libcw_do</SPAN> from the @@ -227,7 +241,7 @@ <P>See also <A HREF="tut3.html">tutorial 3</A>.</P> <A name="WhyOff"></A> -<H3>13. Why are Debug Objects turned off at creation?</H3> +<H3>14. Why are Debug Objects turned off at creation?</H3> <P>The Debug Objects and Debug Channels are global objects. Because libcwd could not be dependant of libcw, they do not use libcw's <CODE>Global<></CODE> template. @@ -239,7 +253,7 @@ in the state <EM>off</EM>.</P> <A name="Order"></A> -<H3>14. Why do you turn on the debug object after you enable a debug channel, why not the other way around?</H3> +<H3>15. Why do you turn on the debug object after you enable a debug channel, why not the other way around?</H3> <P>The order in which Debug Channels and Debug Objects are turned on does not matter at all. At most, when you think about the Debug Object as the «main switch» then it seems to make @@ -248,7 +262,7 @@ <EM>on</EM> before I forget it. That is a bit <EM>too</EM> fuzzy (logic) for me though ;)</P> <A name="Object"></A> -<H3>15. Why do you call it a Debug <EM>Object</EM>? What <EM>is</EM> a Debug Object?</H3> +<H3>16. Why do you call it a Debug <EM>Object</EM>? What <EM>is</EM> a Debug Object?</H3> <P>Good question. It can't be because I wasn't creative, I am very creative. Note that I didn't think of <EM>Object</EM> as in OOP (<EM>that</EM> would be uncreative) @@ -263,7 +277,7 @@ <SPAN class="code">ostream</SPAN>.</P> <A name="semicolon"></A> -<H3>16. Do I need to type that semi-colon after the macro? Why isn't it part of the macro?</H3> +<H3>17. Do I need to type that semi-colon after the macro? Why isn't it part of the macro?</H3> <P>Yes, that colon needs to be there. It was chosen not to include the semi-colon in the macro because this way it looks @@ -309,7 +323,7 @@ </PRE> <A name="LibcwDout"></A> -<H3>17. I made my own Debug Object, can I still use <SPAN class="H3code">Dout</SPAN>?</H3> +<H3>18. I made my own Debug Object, can I still use <SPAN class="H3code">Dout</SPAN>?</H3> <P>No, macro <SPAN class="code">Dout</SPAN> et al. use exclusively the debug object that comes with libcwd. It is easy to define your own macros however (see <A HREF="#OwnDebugObject">above</A>). @@ -319,7 +333,7 @@ to redefine it).</P> <A name="evaluation"></A> -<H3>18. Is the second field of the macro still evaluated when the Debug Channel and/or Debug Object are turned off?</H3> +<H3>19. Is the second field of the macro still evaluated when the Debug Channel and/or Debug Object are turned off?</H3> <P>No! And that is a direct result of the fact that <SPAN class="code">Dout</SPAN> et al. are <EM>macros</EM>. Indeed this fact could therefore be a little confusing. @@ -338,19 +352,19 @@ In the production version of your application all debug code will be removed and you don't want it to behave differently then!</P> <A name="suppress"></A> -<H3>19. Can I suppress that new-line character?</H3> +<H3>20. Can I suppress that new-line character?</H3> <P>Yes, and a lot more. See <A HREF="tut5.html#Formatting">tutorial 5.4</A>.</P> <A name="label"></A> -<H3>20. What is the maximum length of a label?</H3> +<H3>21. What is the maximum length of a label?</H3> <P>The maximum length of the label of a new Debug Channel is given by the constant<SPAN class="code"> libcw::debug::max_label_len_c</SPAN>. At this moment that is 16.</P> <A name="prefix"></A> -<H3>21. Why do I have to use the <SPAN class="H3code">dc::</SPAN> prefix?</H3> +<H3>22. Why do I have to use the <SPAN class="H3code">dc::</SPAN> prefix?</H3> <P>This is a complex reason. Basically because of a flaw in the design of namespaces in C++. Namespaces have been introduced in order to avoid name collisions, which was a good thing. @@ -422,13 +436,13 @@ in the <A HREF="../html/group__group__debug__channels.html">Reference Manual</A>.</P> <A name="ownnamespace"></A> -<H3>22. Can I put my debug channels in my own name space?</H3> +<H3>23. Can I put my debug channels in my own name space?</H3> <P>Yes. How, is described in the <A HREF="../html/group__group__debug__channels.html">Reference Manual</A>. For some background information on why this has to be so complex, please read the <A HREF="#prefix">previous question</A>.</P> <A name="labelwidth"></A> -<H3>23. Why does it print spaces between the label and the colon? How is the field width of the label determined?</H3> +<H3>24. Why does it print spaces between the label and the colon? How is the field width of the label determined?</H3> <P>The colon is indented so it ends up in the same column for all existing debug channels. Hence, the longest label of all existing/created debug channels determines the number of spaces. Index: src/libcwd/documentation/tutorial/hello_world.cc diff -u src/libcwd/documentation/tutorial/hello_world.cc:1.2 src/libcwd/documentation/tutorial/hello_world.cc:1.3 --- src/libcwd/documentation/tutorial/hello_world.cc:1.2 Sat Dec 29 20:17:49 2001 +++ src/libcwd/documentation/tutorial/hello_world.cc Thu Feb 7 20:03:47 2002 @@ -1,3 +1,4 @@ +#define _GNU_SOURCE #include <libcw/sysd.h> // This must be the first header file #include <libcw/debug.h> Index: src/libcwd/documentation/tutorial/log_file.cc diff -u src/libcwd/documentation/tutorial/log_file.cc:1.2 src/libcwd/documentation/tutorial/log_file.cc:1.3 --- src/libcwd/documentation/tutorial/log_file.cc:1.2 Sat Dec 29 20:17:49 2001 +++ src/libcwd/documentation/tutorial/log_file.cc Thu Feb 7 20:03:47 2002 @@ -1,3 +1,4 @@ +#define _GNU_SOURCE #include <libcw/sysd.h> #include <fstream> #include <libcw/debug.h> Index: src/libcwd/documentation/tutorial/tut1.m4 diff -u src/libcwd/documentation/tutorial/tut1.m4:1.2 src/libcwd/documentation/tutorial/tut1.m4:1.3 --- src/libcwd/documentation/tutorial/tut1.m4:1.2 Sat Dec 29 20:17:49 2001 +++ src/libcwd/documentation/tutorial/tut1.m4 Thu Feb 7 20:03:47 2002 @@ -13,7 +13,8 @@ <P>Compile as: <SPAN class="shell-command">g++ -g -DCWDEBUG hello_world.cc -lcwd -o hello_world</SPAN></P> <PRE> -#include <libcw/sysd.h> // This must be the first header file +#define _GNU_SOURCE // This must be defined before including <libcw/sysd.h> +#include <libcw/sysd.h> // This must be the first header file #include <libcw/debug.h> int main(void) @@ -28,6 +29,22 @@ </PRE> <P>Each of the lines of code in this first example program are explained below:</P> + +<H3><CODE>#define _GNU_SOURCE</CODE></H3> + +<P>This define is necessary to tell the system headers that you +want to use the GNU extensions (see /usr/include/features.h). +In order to make you explicitely aware of the fact that it is +defined, libcwd does not define this macro itself (which it could do inside <libcw/sysd.h>), +but forces you to define it when using libcwd. +Note you only really have to define it when you compiled libcwd with +threading support. +If you do not define this macro and libcwd needs it, then you will get +a compile error in <libcw/sysd.h> telling you so.</P> + +<DIV class="faq-frame"><H4>FAQ</H4><UL class="faq"> +<LI><A HREF="faq.html#GNU_SOURCE">Won't this define make my code non-portable?</LI> +</UL></DIV> <H3><CODE>#include <libcw/sysd.h></CODE></H3> Index: src/libcwd/documentation/tutorial/tut2.m4 diff -u src/libcwd/documentation/tutorial/tut2.m4:1.2 src/libcwd/documentation/tutorial/tut2.m4:1.3 --- src/libcwd/documentation/tutorial/tut2.m4:1.2 Sat Dec 29 20:17:49 2001 +++ src/libcwd/documentation/tutorial/tut2.m4 Thu Feb 7 20:03:47 2002 @@ -17,6 +17,9 @@ #include "config.h" // when using autoconf for your project. #endif #ifdef CWDEBUG // This is needed so that others can compile +#ifndef _GNU_SOURCE +#define _GNU_SOURCE +#endif #include <libcw/sysd.h> // your application without having libcwd installed. #endif </PRE> Index: src/libcwd/documentation/tutorial/tut3.m4 diff -u src/libcwd/documentation/tutorial/tut3.m4:1.2 src/libcwd/documentation/tutorial/tut3.m4:1.3 --- src/libcwd/documentation/tutorial/tut3.m4:1.2 Sat Dec 29 20:17:49 2001 +++ src/libcwd/documentation/tutorial/tut3.m4 Thu Feb 7 20:03:47 2002 @@ -13,6 +13,7 @@ <P>Compile as: <CODE>g++ -DCWDEBUG log_file.cc -lcwd -o log_file</CODE></P> <PRE> +#define _GNU_SOURCE #include <libcw/sysd.h> #include <fstream> #include <libcw/debug.h> Index: src/libcwd/documentation/tutorial/tut6.m4 diff -u src/libcwd/documentation/tutorial/tut6.m4:1.2 src/libcwd/documentation/tutorial/tut6.m4:1.3 --- src/libcwd/documentation/tutorial/tut6.m4:1.2 Sat Dec 29 20:17:49 2001 +++ src/libcwd/documentation/tutorial/tut6.m4 Thu Feb 7 20:03:47 2002 @@ -59,6 +59,7 @@ <P>Compile as: <CODE>g++ -DCWDEBUG amo.cc -lcwd -o amo</CODE></P> <PRE> +#define _GNU_SOURCE #include <libcw/sysd.h> #include <libcw/debug.h> @@ -84,6 +85,7 @@ <P>Now let us actually allocate some memory:</P> <PRE> +#define _GNU_SOURCE #include <libcw/sysd.h> #include <libcw/debug.h> @@ -115,6 +117,7 @@ In order to find out what is wrong, we <EM>also turn on debug channel</EM><CODE> dc::bfd</CODE>:</P> <PRE> +#define _GNU_SOURCE #include <libcw/sysd.h> #include <libcw/debug.h> @@ -180,6 +183,7 @@ your program is doing:</P> <PRE> +#define _GNU_SOURCE #include <libcw/sysd.h> #include <libcw/debug.h> @@ -215,6 +219,7 @@ <P>Consider the following code:</P> <PRE> +#define _GNU_SOURCE #include <libcw/sysd.h> #include <libcw/debug.h> @@ -254,6 +259,7 @@ <CODE>AllocTag_dynamic_description()</CODE>, which <EM>will</EM> work.</P> <PRE> +#define _GNU_SOURCE #include <libcw/sysd.h> #include <libcw/debug.h> @@ -299,6 +305,7 @@ <CODE>AllocTag1(p)</CODE>:</P> <PRE> +#define _GNU_SOURCE #include <libcw/sysd.h> #include <libcw/debug.h> Index: src/libcwd/example-project/sys.h diff -u src/libcwd/example-project/sys.h:1.4 src/libcwd/example-project/sys.h:1.5 --- src/libcwd/example-project/sys.h:1.4 Sat Dec 29 20:17:49 2001 +++ src/libcwd/example-project/sys.h Thu Feb 7 20:03:47 2002 @@ -7,7 +7,10 @@ #define CWDEBUG #endif // The following is the mandatory part of the custom "sys.h". -// This must be included *before* any system header file is included. +// This must be included *before* any system header file is included! #ifdef CWDEBUG +#ifndef _GNU_SOURCE +#define _GNU_SOURCE +#endif #include <libcw/sysd.h> #endif Index: src/libcwd/include/libcw/class_debug.h diff -u src/libcwd/include/libcw/class_debug.h:1.8 src/libcwd/include/libcw/class_debug.h:1.9 --- src/libcwd/include/libcw/class_debug.h:1.8 Tue Jan 22 20:03:44 2002 +++ src/libcwd/include/libcw/class_debug.h Thu Feb 7 20:03:47 2002 @@ -1,4 +1,4 @@ -// $Header: /cvsroot/l/li/libcw/src/libcwd/include/libcw/class_debug.h,v 1.8 2002/01/23 04:03:44 libcw Exp $ +// $Header: /cvsroot/l/li/libcw/src/libcwd/include/libcw/class_debug.h,v 1.9 2002/02/08 04:03:47 libcw Exp $ // // Copyright (C) 2000 - 2002, by // @@ -200,6 +200,42 @@ void force_on(OnOffState& state); void restore(OnOffState const& state); + +#ifdef LIBCWD_THREAD_SAFE + /** + * \brief Keep Thread Specific Data after thread exit. + * + * Each %debug object has an array (of size PTHREAD_THREADS_MAX (= 1024)) + * with pointers to the Thread Specific Data (TSD) for each thread id. + * The size of this TSD is about 640 bytes. + * + * When this data would not be freed when a thread exits, and when + * an application constantly creates new threads, then all 1024 entries + * will become used, causing in total 1024 * 640 bytes of memory to be used + * per %debug object instead of <i>number of running threads</i> * 640 bytes. + * + * However, freeing the Thread Specific Data can not be done at the + * very very last moment (for which there is a complicated reason). + * Therefore, libcwd deletes the TSD of %debug objects in <code>__pthread_destroy_specifics()</code>, + * which is called directly after <code>__pthread_perform_cleanup()</code> in <code>pthread_exit()</code>. + * <code>__pthread_destroy_specifics()</code> calls the destruction routines as set + * by <code>pthread_key_create()</code>. + * As you should know, the order in which these destruction routines + * are called is not specified. + * Therefore it is possible that additional %debug output done + * in other key destruction routines is lost. + * + * By calling <code>keep_tsd(true)</code>, the TSD is not deleted and %debug output + * will stay enabled till the very end. + * Because of the disadvantage that this costs about 640 kb of (swappable) memory, + * the default is <code>false</code> and the TSD will be freed, except for the + * default %debug object \ref libcw_do, allowing for the printing of calls to + * <code>%free()</code> done after the key destruction phase. + * + * \returns The previous value. + */ + bool keep_tsd(bool keep); +#endif }; } // namespace debug Index: src/libcwd/include/libcw/private_threading.h diff -u src/libcwd/include/libcw/private_threading.h:1.20 src/libcwd/include/libcw/private_threading.h:1.21 --- src/libcwd/include/libcw/private_threading.h:1.20 Wed Feb 6 16:38:38 2002 +++ src/libcwd/include/libcw/private_threading.h Thu Feb 7 20:03:47 2002 @@ -1,4 +1,4 @@ -// $Header: /cvsroot/l/li/libcw/src/libcwd/include/libcw/private_threading.h,v 1.20 2002/02/07 00:38:38 libcw Exp $ +// $Header: /cvsroot/l/li/libcw/src/libcwd/include/libcw/private_threading.h,v 1.21 2002/02/08 04:03:47 libcw Exp $ // // Copyright (C) 2001 - 2002, by // @@ -41,8 +41,10 @@ #endif #ifdef LIBCWD_HAVE_PTHREAD +#ifndef __USE_GNU +#error "__USE_GNU is not defined!" +#endif #include <pthread.h> -#include <semaphore.h> #if defined(PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP) && defined(PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP) #define LIBCWD_USE_LINUXTHREADS 1 #else @@ -403,6 +405,7 @@ private: static pthread_cond_t S_condition; #if defined(DEBUGDEBUGTHREADS) || !LIBCWD_USE_LINUXTHREADS + static bool S_initialized; private: static void S_initialize(void) throw(); #endif @@ -445,7 +448,7 @@ } #endif // !LIBCWD_USE_LINUXTHREADS -#if !LIBCWD_USE_LINUXTHREADS +#if defined(DEBUGDEBUGTHREADS) || !LIBCWD_USE_LINUXTHREADS template <int instance> bool cond_tct<instance>::S_initialized = false; #endif Index: src/libcwd/include/libcw/struct_debug_tsd.h diff -u src/libcwd/include/libcw/struct_debug_tsd.h:1.6 src/libcwd/include/libcw/struct_debug_tsd.h:1.7 --- src/libcwd/include/libcw/struct_debug_tsd.h:1.6 Tue Feb 5 16:46:08 2002 +++ src/libcwd/include/libcw/struct_debug_tsd.h Thu Feb 7 20:03:47 2002 @@ -1,4 +1,4 @@ -// $Header: /cvsroot/l/li/libcw/src/libcwd/include/libcw/struct_debug_tsd.h,v 1.6 2002/02/06 00:46:08 libcw Exp $ +// $Header: /cvsroot/l/li/libcw/src/libcwd/include/libcw/struct_debug_tsd.h,v 1.7 2002/02/08 04:03:47 libcw Exp $ // // Copyright (C) 2002, by // @@ -62,6 +62,10 @@ bool tsd_initialized; // Set after initialization is completed. + + bool tsd_keep; + // Do not disable debug output and delete the TSD of the this debug object + // during the pthread key destruction phase. #ifdef DEBUGDEBUGOUTPUT // Since with DEBUGDEBUG defined we start with _off is -1 instead of 0, @@ -108,9 +112,9 @@ // A value of 0 means directly behind the marker. // Accessed from LibcwdDout. - void start(debug_ct&, channel_set_data_st& LIBCWD_COMMA_TSD_PARAM); - void finish(debug_ct&, channel_set_data_st& LIBCWD_COMMA_TSD_PARAM); - void fatal_finish(debug_ct&, channel_set_data_st& LIBCWD_COMMA_TSD_PARAM) __attribute__ ((__noreturn__)); + void start(debug_ct& debug_object, channel_set_data_st& channel_set LIBCWD_COMMA_TSD_PARAM); + void finish(debug_ct& debug_object, channel_set_data_st& channel_set LIBCWD_COMMA_TSD_PARAM); + void fatal_finish(debug_ct& debug_object, channel_set_data_st& channel_set LIBCWD_COMMA_TSD_PARAM) __attribute__ ((__noreturn__)); // Initialization and de-initialization. void init(void); @@ -118,7 +122,7 @@ #ifndef LIBCWD_THREAD_SAFE _off(0), #endif - tsd_initialized(false) { } + tsd_initialized(false), tsd_keep(false) { } ~debug_tsd_st(); }; Index: src/libcwd/include/libcw/sysd.ho.in diff -u src/libcwd/include/libcw/sysd.ho.in:1.5 src/libcwd/include/libcw/sysd.ho.in:1.6 --- src/libcwd/include/libcw/sysd.ho.in:1.5 Tue Jan 8 15:04:59 2002 +++ src/libcwd/include/libcw/sysd.ho.in Thu Feb 7 20:03:47 2002 @@ -1,5 +1,5 @@ // @configure_input@ -// $Header: /cvsroot/l/li/libcw/src/libcwd/include/libcw/sysd.ho.in,v 1.5 2002/01/08 23:04:59 libcw Exp $ +// $Header: /cvsroot/l/li/libcw/src/libcwd/include/libcw/sysd.ho.in,v 1.6 2002/02/08 04:03:47 libcw Exp $ // // Copyright (C) 2000 - 2001, by // @@ -57,7 +57,7 @@ // Abort when someone tries to use MT with libcwd without MT support. #@CW_CONFIG_THREAD_SAFE@ LIBCWD_TMP_THREAD_SAFE #if defined(_REENTRANT) && !defined(LIBCWD_TMP_THREAD_SAFE) -#error "Recompile libcwd with --enable-threading to enable support for Multi-Threading." +#error "Recompile libcwd with --enable-libcwd-threading to enable support for Multi-Threading." #endif #ifdef LIBCWD_TMP_THREAD_SAFE @@ -67,7 +67,13 @@ #define LIBCWD_MT_VOLATILE #endif -// Was only needed for the two tests above. +#if defined(LIBCWD_TMP_THREAD_SAFE) && !defined(_GNU_SOURCE) +#error "Sorry, libcwd with --enable-libcwd-threading uses GNU extensions, also in the header files. " + "Therefore you must also define _GNU_SOURCE when you are linking with libcwd. " + "Please add #define _GNU_SOURCE to your \"sys.h\", see html/preparation.html#preparation_step2." +#endif + +// Was only needed for the three tests above. #undef LIBCWD_TMP_THREAD_SAFE #endif /* LIBCW_SYSD_H */ Index: src/libcwd/include/libcw/type_info.h diff -u src/libcwd/include/libcw/type_info.h:1.18 src/libcwd/include/libcw/type_info.h:1.19 --- src/libcwd/include/libcw/type_info.h:1.18 Wed Jan 30 20:42:08 2002 +++ src/libcwd/include/libcw/type_info.h Thu Feb 7 20:03:47 2002 @@ -1,4 +1,4 @@ -// $Header: /cvsroot/l/li/libcw/src/libcwd/include/libcw/type_info.h,v 1.18 2002/01/31 04:42:08 libcw Exp $ +// $Header: /cvsroot/l/li/libcw/src/libcwd/include/libcw/type_info.h,v 1.19 2002/02/08 04:03:47 libcw Exp $ // // Copyright (C) 2000 - 2001, by // @@ -220,19 +220,13 @@ { LIBCWD_TSD_DECLARATION #ifdef LIBCWD_THREAD_SAFE - // MT: The critical area of spinlock contains no cancellation points: - // extract_exact_name() doesn't and even the constructor of type_info_ct - // that calls make_label, which calls demangle_type, do not print output. - // However, if we are a-synchrone then cancellation can happen at any - // point. Therefore we set the cancellation type to defer. - int oldstate; - pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, &oldstate); - _private_::cancel_buffer_t buffer; - _private_::mutex_tct<_private_::type_info_of_instance>::lock(buffer); + LIBCWD_DEFER_CANCEL + _private_::mutex_tct<_private_::type_info_of_instance>::initialize(); + _private_::mutex_tct<_private_::type_info_of_instance>::lock(); volatile static bool spin_lock = false; while(spin_lock); spin_lock = true; - _private_::mutex_tct<_private_::type_info_of_instance>::unlock(buffer); + _private_::mutex_tct<_private_::type_info_of_instance>::unlock(); if (::libcwd_type_info_exact<T>::value_c.size() == 0) // Recheck now that we acquired the lock. #endif { @@ -241,7 +235,7 @@ } #ifdef LIBCWD_THREAD_SAFE spin_lock = false; - pthread_setcanceltype(oldstate, NULL); + LIBCWD_RESTORE_CANCEL #endif } #endif // __GNUC__ == 2 && __GNUC_MINOR__ < 97 Index: src/libcwd/tests/lines.cc diff -u src/libcwd/tests/lines.cc:1.1 src/libcwd/tests/lines.cc:1.2 --- src/libcwd/tests/lines.cc:1.1 Thu Jan 31 21:12:16 2002 +++ src/libcwd/tests/lines.cc Thu Feb 7 20:03:47 2002 @@ -1,3 +1,4 @@ +#define _GNU_SOURCE #include <libcw/sysd.h> #include <libcw/debug.h> Index: src/libcwd/tests/stabs.cc diff -u src/libcwd/tests/stabs.cc:1.2 src/libcwd/tests/stabs.cc:1.3 --- src/libcwd/tests/stabs.cc:1.2 Sat Dec 29 20:17:50 2001 +++ src/libcwd/tests/stabs.cc Thu Feb 7 20:03:47 2002 @@ -1,3 +1,4 @@ +#define _GNU_SOURCE #include <libcw/sysd.h> #include <libcw/debug.h> Index: src/libcwd/tests/sys.h diff -u src/libcwd/tests/sys.h:1.2 src/libcwd/tests/sys.h:1.3 --- src/libcwd/tests/sys.h:1.2 Wed Sep 19 16:34:50 2001 +++ src/libcwd/tests/sys.h Thu Feb 7 20:03:47 2002 @@ -1,10 +1,13 @@ +#ifdef CWDEBUG +#ifndef _GNU_SOURCE +#define _GNU_SOURCE +#endif +#include <libcw/sysd.h> +#endif #include <_G_config.h> #ifndef _G_CLOG_CONFLICT #define _G_CLOG_CONFLICT 0 #endif #ifndef _G_HAS_LABS #define _G_HAS_LABS 0 -#endif -#ifdef CWDEBUG -#include <libcw/sysd.h> #endif Index: src/libcwd/testsuite/libcwd.tst/sys.h diff -u src/libcwd/testsuite/libcwd.tst/sys.h:1.3 src/libcwd/testsuite/libcwd.tst/sys.h:1.4 --- src/libcwd/testsuite/libcwd.tst/sys.h:1.3 Sun Dec 30 13:26:31 2001 +++ src/libcwd/testsuite/libcwd.tst/sys.h Thu Feb 7 20:03:47 2002 @@ -1,4 +1,4 @@ -// $Header: /cvsroot/l/li/libcw/src/libcwd/testsuite/libcwd.tst/sys.h,v 1.3 2001/12/30 21:26:31 libcw Exp $ +// $Header: /cvsroot/l/li/libcw/src/libcwd/testsuite/libcwd.tst/sys.h,v 1.4 2002/02/08 04:03:47 libcw Exp $ // // Copyright (C) 2000 - 2001, by // @@ -14,6 +14,11 @@ #ifndef TESTSUITE_SYS_H #define TESTSUITE_SYS_H +#ifndef _GNU_SOURCE +#define _GNU_SOURCE +#endif +#include <libcw/sysd.h> + #include "../../config.h" #ifdef HAVE__G_CONFIG_H #include <_G_config.h> @@ -24,7 +29,5 @@ #define _G_HAS_LABS 1 #endif #endif // HAVE__G_CONFIG_H - -#include <libcw/sysd.h> #endif // TESTSUITE_SYS_H Index: src/libcwd/testsuite/module.cc diff -u src/libcwd/testsuite/module.cc:1.3 src/libcwd/testsuite/module.cc:1.4 --- src/libcwd/testsuite/module.cc:1.3 Sat Dec 29 20:17:50 2001 +++ src/libcwd/testsuite/module.cc Thu Feb 7 20:03:47 2002 @@ -1,4 +1,5 @@ // A shared library +#define _GNU_SOURCE #include <libcw/sysd.h> #include <libcw/debug.h> Index: src/libcwd/threading.cc diff -u src/libcwd/threading.cc:1.7 src/libcwd/threading.cc:1.8 --- src/libcwd/threading.cc:1.7 Wed Feb 6 16:38:38 2002 +++ src/libcwd/threading.cc Thu Feb 7 20:03:46 2002 @@ -1,4 +1,4 @@ -// $Header: /cvsroot/l/li/libcw/src/libcwd/threading.cc,v 1.7 2002/02/07 00:38:38 libcw Exp $ +// $Header: /cvsroot/l/li/libcw/src/libcwd/threading.cc,v 1.8 2002/02/08 04:03:46 libcw Exp $ // // Copyright (C) 2001, by // @@ -105,15 +105,16 @@ void TSD_st::cleanup_routine(void) throw() { - Dout(dc::always, "Thread " << tid << " is exiting."); set_alloc_checking_off(*this); for (int i = 0; i < LIBCWD_DO_MAX; ++i) if (do_array[i]) { - do_off_array[i] = 0; // Turn all debugging off! Now, hopefully, we won't use do_array[i] anymore. debug_tsd_st* ptr = do_array[i]; - do_array[i] = NULL; // Be paranoid. - delete ptr; // Free old objects. + if (ptr->tsd_keep) + continue; + do_off_array[i] = 0; // Turn all debugging off! Now, hopefully, we won't use do_array[i] anymore. + do_array[i] = NULL; // So we won't free it again. + delete ptr; // Free debug object TSD. } set_alloc_checking_on(*this); } Index: src/libcwd/wrapcnclpnts.cc diff -u src/libcwd/wrapcnclpnts.cc:1.1 src/libcwd/wrapcnclpnts.cc:1.2 --- src/libcwd/wrapcnclpnts.cc:1.1 Sun Feb 3 19:50:36 2002 +++ src/libcwd/wrapcnclpnts.cc Thu Feb 7 20:03:46 2002 @@ -1,4 +1,4 @@ -// $Header: /cvsroot/l/li/libcw/src/libcwd/wrapcnclpnts.cc,v 1.1 2002/02/04 03:50:36 libcw Exp $ +// $Header: /cvsroot/l/li/libcw/src/libcwd/wrapcnclpnts.cc,v 1.2 2002/02/08 04:03:46 libcw Exp $ // // Copyright (C) 2002, by // @@ -13,7 +13,7 @@ #define _LARGEFILE64_SOURCE -#include <libcw/sysd.h> +#include "sys.h" #include <libcw/debug_config.h> // Needed for DEBUGDEBUGTHREADS #ifdef DEBUGDEBUGTHREADS ----------------------- End of diff ----------------------- |
From: Carlo W. <li...@us...> - 2002-02-07 00:38:50
|
CVSROOT : /cvsroot/libcw Module : src Commit time: 2002-01-07 00:38:48 UTC Modified files: libcwd/debugmalloc.cc libcwd/threading.cc libcwd/include/libcw/private_struct_TSD.h libcwd/include/libcw/private_threading.h libcwd/tests/threads.cc Log message: Bug fix of rwlock_tct<>::trywrlock(). Don't use rwlock in debugmalloc anymore in order to avoid dead-lock. Fix of tests/threads.cc Detect end of thread by means of a 'clean up' key trick. ---------------------- diff included ---------------------- Index: src/libcwd/debugmalloc.cc diff -u src/libcwd/debugmalloc.cc:1.80 src/libcwd/debugmalloc.cc:1.81 --- src/libcwd/debugmalloc.cc:1.80 Tue Feb 5 16:46:07 2002 +++ src/libcwd/debugmalloc.cc Wed Feb 6 16:38:38 2002 @@ -1,4 +1,4 @@ -// $Header: /cvsroot/l/li/libcw/src/libcwd/debugmalloc.cc,v 1.80 2002/02/06 00:46:07 libcw Exp $ +// $Header: /cvsroot/l/li/libcw/src/libcwd/debugmalloc.cc,v 1.81 2002/02/07 00:38:38 libcw Exp $ // // Copyright (C) 2000 - 2001, by // @@ -171,14 +171,18 @@ // D libcw::debug::dm_alloc_ct::memsize // #ifdef LIBCWD_THREAD_SAFE -using libcw::debug::_private_::rwlock_tct; +using libcw::debug::_private_::mutex_tct; using libcw::debug::_private_::memblk_map_instance; -#define ACQUIRE_WRITE_LOCK rwlock_tct<memblk_map_instance>::wrlock(); -#define RELEASE_WRITE_LOCK rwlock_tct<memblk_map_instance>::wrunlock(); -#define ACQUIRE_READ_LOCK rwlock_tct<memblk_map_instance>::rdlock(); -#define RELEASE_READ_LOCK rwlock_tct<memblk_map_instance>::rdunlock(); -#define ACQUIRE_READ2WRITE_LOCK rwlock_tct<memblk_map_instance>::rd2wrlock(); -#define ACQUIRE_WRITE2READ_LOCK rwlock_tct<memblk_map_instance>::wr2rdlock(); +// We can't use rwlock_tct here because that leads to a dead lock. +// rwlocks have to use condition variables or semaphores and both try to get a +// (libpthread internal) self-lock that is already set by libthread when it calls +// free() in order to destroy thread specific data 1st level arrays. +#define ACQUIRE_WRITE_LOCK mutex_tct<memblk_map_instance>::lock(); // rwlock_tct<memblk_map_instance>::wrlock(); +#define RELEASE_WRITE_LOCK mutex_tct<memblk_map_instance>::unlock(); // rwlock_tct<memblk_map_instance>::wrunlock(); +#define ACQUIRE_READ_LOCK mutex_tct<memblk_map_instance>::lock(); // rwlock_tct<memblk_map_instance>::rdlock(); +#define RELEASE_READ_LOCK mutex_tct<memblk_map_instance>::unlock(); // rwlock_tct<memblk_map_instance>::rdunlock(); +#define ACQUIRE_READ2WRITE_LOCK // rwlock_tct<memblk_map_instance>::rd2wrlock(); +#define ACQUIRE_WRITE2READ_LOCK // rwlock_tct<memblk_map_instance>::wr2rdlock(); #else // !LIBCWD_THREAD_SAFE #define ACQUIRE_WRITE_LOCK #define RELEASE_WRITE_LOCK @@ -1660,7 +1664,7 @@ __libcwd_tsd.internal = 0; } - LIBCWD_DEFER_CLEANUP_PUSH(&rwlock_tct<memblk_map_instance>::cleanup, NULL); + LIBCWD_DEFER_CLEANUP_PUSH(&mutex_tct<memblk_map_instance>::cleanup /* &rwlock_tct<memblk_map_instance>::cleanup */, NULL); ACQUIRE_READ_LOCK LibcwDout( channels, debug_object, dc_malloc, "Allocated memory: " << const_dm_alloc_ct::get_memsize() << " bytes in " << const_dm_alloc_ct::get_memblks() << " blocks." ); if (base_alloc_list) Index: src/libcwd/include/libcw/private_struct_TSD.h diff -u src/libcwd/include/libcw/private_struct_TSD.h:1.5 src/libcwd/include/libcw/private_struct_TSD.h:1.6 --- src/libcwd/include/libcw/private_struct_TSD.h:1.5 Tue Feb 5 16:46:08 2002 +++ src/libcwd/include/libcw/private_struct_TSD.h Wed Feb 6 16:38:38 2002 @@ -1,4 +1,4 @@ -// $Header: /cvsroot/l/li/libcw/src/libcwd/include/libcw/private_struct_TSD.h,v 1.5 2002/02/06 00:46:08 libcw Exp $ +// $Header: /cvsroot/l/li/libcw/src/libcwd/include/libcw/private_struct_TSD.h,v 1.6 2002/02/07 00:38:38 libcw Exp $ // // Copyright (C) 2001, by // @@ -156,6 +156,7 @@ pthread_t tid; int do_off_array[LIBCWD_DO_MAX]; // Thread Specific on/off counter for Debug Objects. debug_tsd_st* do_array[LIBCWD_DO_MAX];// Thread Specific Data of Debug Objects or NULL when no debug object. + void cleanup_routine(void) throw(); #endif int off_cnt_array[LIBCWD_DC_MAX]; // Thread Specific Data of Debug Channels. @@ -164,6 +165,11 @@ #ifdef LIBCWD_THREAD_SAFE //------------------------------------------------------- // Static data and methods. +private: + static pthread_key_t S_exit_key; + static pthread_once_t S_exit_key_once; + static void S_exit_key_alloc(void) throw(); + static void S_cleanup_routine(void* arg) throw(); public: static TSD_st& instance(void) throw() Index: src/libcwd/include/libcw/private_threading.h diff -u src/libcwd/include/libcw/private_threading.h:1.19 src/libcwd/include/libcw/private_threading.h:1.20 --- src/libcwd/include/libcw/private_threading.h:1.19 Tue Feb 5 16:46:08 2002 +++ src/libcwd/include/libcw/private_threading.h Wed Feb 6 16:38:38 2002 @@ -1,4 +1,4 @@ -// $Header: /cvsroot/l/li/libcw/src/libcwd/include/libcw/private_threading.h,v 1.19 2002/02/06 00:46:08 libcw Exp $ +// $Header: /cvsroot/l/li/libcw/src/libcwd/include/libcw/private_threading.h,v 1.20 2002/02/07 00:38:38 libcw Exp $ // // Copyright (C) 2001 - 2002, by // @@ -105,7 +105,7 @@ object_files_instance, // rwlock end_recursive_types, // Fast mutexes. - memblk_map_instance, // rwlock + memblk_map_instance, mutex_initialization_instance, ids_singleton_tct_S_ids_instance, alloc_tag_desc_instance, @@ -319,6 +319,8 @@ #endif LibcwDebugThreads( if (instance != tsd_initialization_instance) { LIBCWD_TSD_DECLARATION --__libcwd_tsd.inside_critical_area; } ); } + // This is used as cleanup handler with LIBCWD_DEFER_CLEANUP_PUSH. + static void cleanup(void*); }; #if !LIBCWD_USE_LINUXTHREADS || defined(DEBUGDEBUGTHREADS) @@ -387,6 +389,12 @@ ; #endif // !LIBCWD_USE_LINUXTHREADS +template <int instance> + void mutex_tct<instance>::cleanup(void*) + { + unlock(); + } + //========================================================================================================================================17" // class cond_tct @@ -509,7 +517,7 @@ if (instance < end_recursive_types && pthread_equal(S_writer_id, pthread_self())) { LIBCWD_DEBUGDEBUGRWLOCK_CERR(pthread_self() << ": Leaving rwlock_tct<" << instance << ">::tryrdlock() (skipped: thread has write lock)"); - return; // No error checking is done. + return true; // No error checking is done. } // Give a writer a higher priority (kinda fuzzy). if (S_writer_is_waiting || !S_no_holders_condition.trylock()) @@ -527,25 +535,22 @@ LibcwDebugThreads( LIBCWD_ASSERT( S_initialized ) ); LIBCWD_DEBUGDEBUG_ASSERT_CANCEL_DEFERRED LIBCWD_DEBUGDEBUGRWLOCK_CERR(pthread_self() << ": Calling rwlock_tct<" << instance << ">::trywrlock()"); - bool success = mutex_tct<readers_instance>::trylock(); // Block new readers, - while (success) + bool success; + if ((success = mutex_tct<readers_instance>::trylock())) { - S_writer_is_waiting = true; // from this moment on. - if (!S_no_holders_condition.trylock()) + S_writer_is_waiting = true; + if ((success = S_no_holders_condition.trylock())) { - S_writer_is_waiting = false; - mutex_tct<readers_instance>::unlock(); - success = false; - break; + if ((success = (S_holders_count == 0))) + { + S_holders_count = -1; // Mark that we have a writer. + if (instance < end_recursive_types) + S_writer_id = pthread_self(); + } + S_no_holders_condition.unlock(); } - while (S_holders_count != 0) // Other readers or writers have this lock? - S_no_holders_condition.wait(); // Wait until all current holders are done. - S_writer_is_waiting = false; // Stop checking the lock for new readers. - mutex_tct<readers_instance>::unlock(); // Release blocked readers. - S_holders_count = -1; // Mark that we have a writer. - S_no_holders_condition.unlock(); - if (instance < end_recursive_types) - S_writer_id = pthread_self(); + S_writer_is_waiting = false; + mutex_tct<readers_instance>::unlock(); } LibcwDebugThreads( if (success) { LIBCWD_TSD_DECLARATION; ++__libcwd_tsd.inside_critical_area; } ); LIBCWD_DEBUGDEBUGRWLOCK_CERR(pthread_self() << ": Leaving rwlock_tct<" << instance << ">::trywrlock()"); Index: src/libcwd/tests/threads.cc diff -u src/libcwd/tests/threads.cc:1.8 src/libcwd/tests/threads.cc:1.9 --- src/libcwd/tests/threads.cc:1.8 Sun Jan 20 19:20:24 2002 +++ src/libcwd/tests/threads.cc Wed Feb 6 16:38:38 2002 @@ -87,25 +87,36 @@ << location_ct((char*)__builtin_return_address(0) + builtin_return_address_offset)); } +static pthread_key_t key; +static pthread_once_t key_once = PTHREAD_ONCE_INIT; +static void destroy(void* arg) { TSD* tsd = reinterpret_cast<TSD*>(arg); delete tsd; } +static void key_alloc() { pthread_key_create(&key, destroy); } + void* thread_function(void* arguments) { static int thread_counter = -1; + pthread_once(&key_once, key_alloc); + pthread_setspecific(key, new TSD); + // Set Thread Specific on/off flags of the debug channels. ForAllDebugChannels( if (!debugChannel.is_on()) debugChannel.on(); ); // And for the debug object. Debug( libcw_do.on() ); // Serialize incrementation. + int my_id; + LIBCWD_DEFER_CANCEL mutex_tct<test_instance0>::lock(); - int my_id = ++thread_counter; + my_id = ++thread_counter; mutex_tct<test_instance0>::unlock(); + LIBCWD_RESTORE_CANCEL state_thread[my_id] = 0; Dout(dc::notice, my_id << ": Entering thread " << pthread_self()); // Get TSD. - TSD& tsd(libcw::debug::_private_::thread_specific_data_tct<TSD>::instance()); + TSD& tsd(*reinterpret_cast<TSD*>(pthread_getspecific(key))); Dout(dc::notice, my_id << ": tsd is " << (void*)&tsd << '.'); Dout(dc::notice, my_id << ": Here we are " << in_the_middle(my_id)); @@ -129,10 +140,14 @@ rwlock_tct<test_instance0>::initialize(); // Test if rwlocks allows multiple read locks but only one write lock. + LIBCWD_DEFER_CANCEL rwlock_tct<test_instance0>::wrlock(); LIBCWD_ASSERT( !rwlock_tct<test_instance0>::trywrlock() ); LIBCWD_ASSERT( !rwlock_tct<test_instance0>::tryrdlock() ); rwlock_tct<test_instance0>::wrunlock(); + LIBCWD_RESTORE_CANCEL + + LIBCWD_DEFER_CANCEL rwlock_tct<test_instance0>::rdlock(); LIBCWD_ASSERT( !rwlock_tct<test_instance0>::trywrlock() ); LIBCWD_ASSERT( rwlock_tct<test_instance0>::tryrdlock() && (rwlock_tct<test_instance0>::rdunlock(), true) ); @@ -145,12 +160,14 @@ rwlock_tct<test_instance0>::rdunlock(); LIBCWD_ASSERT( rwlock_tct<test_instance0>::tryrdlock() && (rwlock_tct<test_instance0>::rdunlock(), true) ); LIBCWD_ASSERT( rwlock_tct<test_instance0>::trywrlock() && (rwlock_tct<test_instance0>::wrunlock(), true) ); + LIBCWD_RESTORE_CANCEL // Now test that a mutex allows only one lock. + LIBCWD_DEFER_CANCEL mutex_tct<test_instance0>::lock(); LIBCWD_ASSERT( !mutex_tct<test_instance0>::trylock() ); mutex_tct<test_instance0>::unlock(); - + LIBCWD_RESTORE_CANCEL pthread_t thread_id[number_of_threads]; for (int i = 0; i < number_of_threads; ++i) Index: src/libcwd/threading.cc diff -u src/libcwd/threading.cc:1.6 src/libcwd/threading.cc:1.7 --- src/libcwd/threading.cc:1.6 Tue Feb 5 16:46:07 2002 +++ src/libcwd/threading.cc Wed Feb 6 16:38:38 2002 @@ -1,4 +1,4 @@ -// $Header: /cvsroot/l/li/libcw/src/libcwd/threading.cc,v 1.6 2002/02/06 00:46:07 libcw Exp $ +// $Header: /cvsroot/l/li/libcw/src/libcwd/threading.cc,v 1.7 2002/02/07 00:38:38 libcw Exp $ // // Copyright (C) 2001, by // @@ -37,7 +37,7 @@ mutex_tct<dlopen_map_instance>::initialize(); #ifdef DEBUGMALLOC mutex_tct<alloc_tag_desc_instance>::initialize(); - rwlock_tct<memblk_map_instance>::initialize(); + mutex_tct<memblk_map_instance>::initialize(); #endif #if __GNUC__ == 2 && __GNUC_MINOR__ < 96 mutex_tct<type_info_of_instance>::initialize(); @@ -67,6 +67,9 @@ TSD_st __libcwd_tsd_array[PTHREAD_THREADS_MAX]; #if LIBCWD_USE_POSIX_THREADS || LIBCWD_USE_LINUXTHREADS +pthread_key_t TSD_st::S_exit_key; +pthread_once_t TSD_st::S_exit_key_once = PTHREAD_ONCE_INIT; + extern void debug_tsd_init(LIBCWD_TSD_PARAM); void TSD_st::S_initialize(void) throw() @@ -90,7 +93,35 @@ set_alloc_checking_on(*this); debug_tsd_init(*this); // Initialize the TSD of existing debug objects. } + pthread_once(&S_exit_key_once, &TSD_st::S_exit_key_alloc); + pthread_setspecific(S_exit_key, (void*)this); pthread_setcanceltype(oldtype, NULL); +} + +void TSD_st::S_exit_key_alloc(void) throw() +{ + pthread_key_create(&S_exit_key, &TSD_st::S_cleanup_routine); +} + +void TSD_st::cleanup_routine(void) throw() +{ + Dout(dc::always, "Thread " << tid << " is exiting."); + set_alloc_checking_off(*this); + for (int i = 0; i < LIBCWD_DO_MAX; ++i) + if (do_array[i]) + { + do_off_array[i] = 0; // Turn all debugging off! Now, hopefully, we won't use do_array[i] anymore. + debug_tsd_st* ptr = do_array[i]; + do_array[i] = NULL; // Be paranoid. + delete ptr; // Free old objects. + } + set_alloc_checking_on(*this); +} + +void TSD_st::S_cleanup_routine(void* arg) throw() +{ + TSD_st* obj = reinterpret_cast<TSD_st*>(arg); + obj->cleanup_routine(); } #endif // LIBCWD_USE_POSIX_THREADS || LIBCWD_USE_LINUXTHREADS ----------------------- End of diff ----------------------- |
From: Carlo W. <li...@us...> - 2002-02-06 00:46:20
|
CVSROOT : /cvsroot/libcw Module : src Commit time: 2002-01-06 00:46:18 UTC Modified files: libcwd/debug.cc libcwd/debugmalloc.cc libcwd/threading.cc libcwd/include/cwd_debug.h libcwd/include/libcw/class_debug.inl libcwd/include/libcw/debug_config.ho.in libcwd/include/libcw/macro_Libcwd_macros.h libcwd/include/libcw/private_struct_TSD.h libcwd/include/libcw/private_threading.h libcwd/include/libcw/struct_debug_tsd.h libcwd/tests/threads4.cc Log message: Don't use pthread_setspecific and pthread_getspecific anymore: it would destroy our Thread Specific Data at the start of __pthread_do_exit() and we still need that for the following calls to free() (and perhaps other things, like global destructors, at_exit functions etc etc). ---------------------- diff included ---------------------- Index: src/libcwd/debug.cc diff -u src/libcwd/debug.cc:1.61 src/libcwd/debug.cc:1.62 --- src/libcwd/debug.cc:1.61 Sat Feb 2 20:15:11 2002 +++ src/libcwd/debug.cc Tue Feb 5 16:46:07 2002 @@ -1,4 +1,4 @@ -// $Header: /cvsroot/l/li/libcw/src/libcwd/debug.cc,v 1.61 2002/02/03 04:15:11 libcw Exp $ +// $Header: /cvsroot/l/li/libcw/src/libcwd/debug.cc,v 1.62 2002/02/06 00:46:07 libcw Exp $ // // Copyright (C) 2000 - 2001, by // @@ -88,13 +88,13 @@ int saved_internal = __libcwd_tsd.internal; __libcwd_tsd.internal = 0; ++__libcwd_tsd.library_call; - ++LIBCWD_DO_TSD_MEMBER(libcw_do, _off); + ++LIBCWD_DO_TSD_MEMBER_OFF(libcw_do); #endif LIBCWD_DISABLE_CANCEL // We don't want Dout() to be a cancellation point. os->write(buf, curlen); LIBCWD_ENABLE_CANCEL #ifdef DEBUGMALLOC - --LIBCWD_DO_TSD_MEMBER(libcw_do, _off); + --LIBCWD_DO_TSD_MEMBER_OFF(libcw_do); --__libcwd_tsd.library_call; __libcwd_tsd.internal = saved_internal; #endif @@ -284,6 +284,31 @@ channels::dc::system.NS_initialize("SYSTEM"); libcw_do.NS_init(); // Initialize debug code. + + // Unlimit core size. +#ifdef RLIMIT_CORE + struct rlimit corelim; + if (getrlimit(RLIMIT_CORE, &corelim)) + DoutFatal(dc::fatal|error_cf, "getrlimit(RLIMIT_CORE, &corelim)"); + corelim.rlim_cur = corelim.rlim_max; + if (corelim.rlim_max != RLIM_INFINITY) + { + debug_ct::OnOffState state; + libcw_do.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!"); + libcw_do.restore(state); + } + if (setrlimit(RLIMIT_CORE, &corelim)) + DoutFatal(dc::fatal|error_cf, "unlimit core size failed"); +#else + debug_ct::OnOffState state; + libcw_do.force_on(state); + Dout(dc::warning, "Please unlimit core size manually"); + libcw_do.restore(state); +#endif + #ifdef DEBUGUSEBFD cwbfd::ST_init(); // Initialize BFD code. #endif @@ -641,8 +666,8 @@ return; } - ++_off; - DEBUGDEBUG_CERR( "Entering debug_ct::start(), _off became " << _off ); + ++LIBCWD_DO_TSD_MEMBER_OFF(debug_object); + DEBUGDEBUG_CERR( "Entering debug_ct::start(), _off became " << LIBCWD_DO_TSD_MEMBER_OFF(debug_object) ); // Is this an interrupting debug output (in the middle of a continued debug output)? if ((current->mask & continued_cf_maskbit) && unfinished_expected) @@ -730,8 +755,8 @@ static_cast<buffer_ct*>(current_oss)->store_position(); } - --_off; - DEBUGDEBUG_CERR( "Leaving debug_ct::start(), _off became " << _off ); + --LIBCWD_DO_TSD_MEMBER_OFF(debug_object); + DEBUGDEBUG_CERR( "Leaving debug_ct::start(), _off became " << LIBCWD_DO_TSD_MEMBER_OFF(debug_object) ); } void debug_tsd_st::finish(debug_ct& debug_object, channel_set_data_st& channel_set LIBCWD_COMMA_TSD_PARAM) @@ -762,8 +787,8 @@ return; } - ++_off; - DEBUGDEBUG_CERR( "Entering debug_ct::finish(), _off became " << _off ); + ++LIBCWD_DO_TSD_MEMBER_OFF(debug_object); + DEBUGDEBUG_CERR( "Entering debug_ct::finish(), _off became " << LIBCWD_DO_TSD_MEMBER_OFF(debug_object) ); // Handle control flags, if any: if ((current->mask & error_cf)) @@ -849,8 +874,8 @@ start_expected = true; unfinished_expected = false; - --_off; - DEBUGDEBUG_CERR( "Leaving debug_ct::finish(), _off became " << _off ); + --LIBCWD_DO_TSD_MEMBER_OFF(debug_object); + DEBUGDEBUG_CERR( "Leaving debug_ct::finish(), _off became " << LIBCWD_DO_TSD_MEMBER_OFF(debug_object) ); set_alloc_checking_on(LIBCWD_TSD); } @@ -898,56 +923,42 @@ set_alloc_checking_off(LIBCWD_TSD); // debug_objects is internal. #endif new (_private_::WST_dummy_laf) laf_ct(0, channels::dc::debug.get_label(), 0); // Leaks 24 bytes of memory -#ifndef LIBCWD_THREAD_SAFE +#ifdef LIBCWD_THREAD_SAFE + WNS_index = S_index_count++; +#ifdef DEBUGDEBUGTHREADS + LIBCWD_ASSERT( pthread_self() == PTHREAD_THREADS_MAX ); // Only the initial thread should be initializing debug_ct objects. +#endif + LIBCWD_ASSERT( __libcwd_tsd.do_array[WNS_index] == NULL ); + debug_tsd_st& tsd(*(__libcwd_tsd.do_array[WNS_index] = new debug_tsd_st)); +#endif tsd.init(); + set_alloc_checking_on(LIBCWD_TSD); + +#ifdef DEBUGDEBUGOUTPUT + LIBCWD_TSD_MEMBER_OFF = -1; // Print as much debug output as possible right away. #else - WNS_index = ++S_index_count; - __libcwd_tsd.do_array[WNS_index].init(); + LIBCWD_TSD_MEMBER_OFF = 0; // Don't print debug output till the REAL initialization of the debug system + // has been performed (ie, the _application_ start (don't confuse that with + // the constructor - which does nothing)). #endif - set_alloc_checking_on(LIBCWD_TSD); + DEBUGDEBUG_CERR( "debug_ct::NS_init(void), _off set to " << LIBCWD_TSD_MEMBER_OFF ); - // This set current_oss and must be called after tsd.init(). + // This sets current_oss and must be called after tsd.init(). set_ostream(&std::cerr); // Write to std::cerr by default. interactive = true; // and thus we're interactive. WNS_initialized = true; - - // Unlimit core size. -#ifdef RLIMIT_CORE - struct rlimit corelim; - if (getrlimit(RLIMIT_CORE, &corelim)) - DoutFatal(dc::fatal|error_cf, "getrlimit(RLIMIT_CORE, &corelim)"); - corelim.rlim_cur = corelim.rlim_max; - if (corelim.rlim_max != RLIM_INFINITY) - { - 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!"); - restore(state); - } - if (setrlimit(RLIMIT_CORE, &corelim)) - DoutFatal(dc::fatal|error_cf, "unlimit core size failed"); -#else - OnOffState state; - force_on(state); - Dout(dc::warning, "Please unlimit core size manually"); - restore(state); -#endif } - debug_tsd_st::debug_tsd_st(void) : _off(0), tsd_initialized(false) { } // Turn off all debugging until initialization is completed. - void debug_tsd_st::init(void) { #ifdef DEBUGDEBUGMALLOC LIBCWD_TSD_DECLARATION LIBCWD_ASSERT( __libcwd_tsd.internal ); #endif - DEBUGDEBUG_CERR( "In debug_tsd_st::init(void), _off set to 0" ); - start_expected = true; // Of course, we start with expecting the beginning of a debug output. + unfinished_expected = false; + // `current' needs to be non-zero (saving us a check in start()) and // current.mask needs to be 0 to avoid a crash in start(): current = reinterpret_cast<laf_ct*>(_private_::WST_dummy_laf); @@ -962,13 +973,14 @@ marker.NS_internal_init(": ", 2); #ifdef DEBUGDEBUGOUTPUT - _off = -1; // Print as much debug output as possible right away. - first_time = true; // Needed to ignore the first time we call on(). -#else - _off = 0; // Don't print debug output till the REAL initialization of the debug system has been performed - // (ie, the _application_ start (don't confuse that with the constructor - which does nothing)). + first_time = true; #endif - DEBUGDEBUG_CERR( "After debug_tsd_st::init(void), _off set to " << _off ); + off_count = 0; + M_margin_stack = NULL; + M_marker_stack = NULL; + indent = 0; + + tsd_initialized = true; } @@ -977,8 +989,11 @@ { ForAllDebugObjects( set_alloc_checking_off(LIBCWD_TSD); - LIBCWD_DO_TSD(debugObject).init(); + LIBCWD_ASSERT( __libcwd_tsd.do_array[(debugObject).WNS_index] == NULL ); + debug_tsd_st& tsd(*(__libcwd_tsd.do_array[(debugObject).WNS_index] = new debug_tsd_st)); + tsd.init(); set_alloc_checking_on(LIBCWD_TSD); + LIBCWD_DO_TSD_MEMBER_OFF(debugObject) = 0; ); } } @@ -993,9 +1008,6 @@ if (laf_stack.size()) DoutFatal( dc::core|cerr_cf, "Destructing debug_tsd_st with a non-empty laf_stack" ); - ++_off; // Turn all debug output premanently off, otherwise we might re-initialize - // this object again when we try to write debug output to it! - DEBUGDEBUG_CERR( "debug_tsd_st destructed: _off became " << _off ); LIBCWD_TSD_DECLARATION set_alloc_checking_off(LIBCWD_TSD); marker.ST_internal_deinit(); @@ -1088,7 +1100,7 @@ void list_channels_on(debug_ct& debug_object) { LIBCWD_TSD_DECLARATION - if (LIBCWD_DO_TSD_MEMBER(debug_object, _off) < 0) + if (LIBCWD_DO_TSD_MEMBER_OFF(debug_object) < 0) { LIBCWD_DEFER_CANCEL _private_::debug_channels.init(LIBCWD_TSD); @@ -1395,11 +1407,11 @@ { NS_init(); LIBCWD_TSD_DECLARATION - state._off = LIBCWD_TSD_MEMBER(_off); + state._off = LIBCWD_TSD_MEMBER_OFF; #ifdef DEBUGDEBUGOUTPUT state.first_time = LIBCWD_TSD_MEMBER(first_time); #endif - LIBCWD_TSD_MEMBER(_off) = -1; // Turn object on. + LIBCWD_TSD_MEMBER_OFF = -1; // Turn object on. } void debug_ct::restore(debug_ct::OnOffState const& state) @@ -1409,9 +1421,9 @@ if (state.first_time != LIBCWD_TSD_MEMBER(first_time)) // state.first_time && !first_time. core_dump(); // on() was called without first a call to off(). #endif - if (LIBCWD_TSD_MEMBER(_off) != -1) + if (LIBCWD_TSD_MEMBER_OFF != -1) core_dump(); // off() and on() where called and not in equal pairs. - LIBCWD_TSD_MEMBER(_off) = state._off; // Restore. + LIBCWD_TSD_MEMBER_OFF = state._off; // Restore. } void channel_ct::force_on(channel_ct::OnOffState& state, char const* label) Index: src/libcwd/debugmalloc.cc diff -u src/libcwd/debugmalloc.cc:1.79 src/libcwd/debugmalloc.cc:1.80 --- src/libcwd/debugmalloc.cc:1.79 Sun Feb 3 19:50:36 2002 +++ src/libcwd/debugmalloc.cc Tue Feb 5 16:46:07 2002 @@ -1,4 +1,4 @@ -// $Header: /cvsroot/l/li/libcw/src/libcwd/debugmalloc.cc,v 1.79 2002/02/04 03:50:36 libcw Exp $ +// $Header: /cvsroot/l/li/libcw/src/libcwd/debugmalloc.cc,v 1.80 2002/02/06 00:46:07 libcw Exp $ // // Copyright (C) 2000 - 2001, by // @@ -289,7 +289,7 @@ do \ { \ DEBUGDEBUG_DoutInternal_MARKER; \ - if (__libcwd_tsd.library_call == 0 && LIBCWD_DO_TSD_MEMBER(libcw_do, _off) < 0) \ + if (__libcwd_tsd.library_call == 0 && LIBCWD_DO_TSD_MEMBER_OFF(libcw_do) < 0) \ { \ DEBUGDEBUG_CERR( "Entering 'DoutInternal(cntrl, \"" << data << "\")'. internal == " << __libcwd_tsd.internal << '.' ); \ channel_set_bootstrap_st channel_set(LIBCWD_DO_TSD(libcw_do) LIBCWD_COMMA_TSD); \ @@ -301,10 +301,10 @@ if (on) \ { \ LIBCWD_DO_TSD(libcw_do).start(libcw_do, channel_set LIBCWD_COMMA_TSD); \ - ++ LIBCWD_DO_TSD_MEMBER(libcw_do, _off); \ + ++ LIBCWD_DO_TSD_MEMBER_OFF(libcw_do); \ _private_::no_alloc_ostream_ct no_alloc_ostream(*LIBCWD_DO_TSD_MEMBER(libcw_do, current_oss)); \ no_alloc_ostream << data; \ - -- LIBCWD_DO_TSD_MEMBER(libcw_do, _off); \ + -- LIBCWD_DO_TSD_MEMBER_OFF(libcw_do); \ LIBCWD_DO_TSD(libcw_do).finish(libcw_do, channel_set LIBCWD_COMMA_TSD); \ } \ DEBUGDEBUG_CERR( "Leaving 'DoutInternal(cntrl, \"" << data << "\")'. internal = " << __libcwd_tsd.internal << '.' ); \ @@ -327,10 +327,10 @@ channel_set&cntrl; \ } \ LIBCWD_DO_TSD(libcw_do).start(libcw_do, channel_set LIBCWD_COMMA_TSD); \ - ++ LIBCWD_DO_TSD_MEMBER(libcw_do, _off); \ + ++ LIBCWD_DO_TSD_MEMBER_OFF(libcw_do); \ _private_::no_alloc_ostream_ct no_alloc_ostream(*LIBCWD_DO_TSD_MEMBER(libcw_do, current_oss)); \ no_alloc_ostream << data; \ - -- LIBCWD_DO_TSD_MEMBER(libcw_do, _off); \ + -- LIBCWD_DO_TSD_MEMBER_OFF(libcw_do); \ LIBCWD_DO_TSD(libcw_do).fatal_finish(libcw_do, channel_set LIBCWD_COMMA_TSD); /* Never returns */ \ LIBCWD_ASSERT( !"Bug in libcwd!" ); \ } \ @@ -413,9 +413,9 @@ #endif return true; WST_ios_base_initialized = true; - ++LIBCWD_DO_TSD_MEMBER(libcw_do, _off); + ++LIBCWD_DO_TSD_MEMBER_OFF(libcw_do); make_all_allocations_invisible_except(NULL); // Get rid of the <pre ios initialization> allocation list. - --LIBCWD_DO_TSD_MEMBER(libcw_do, _off); + --LIBCWD_DO_TSD_MEMBER_OFF(libcw_do); DEBUGDEBUG_CERR( "Standard streams initialized." ); return false; } @@ -1202,15 +1202,15 @@ if (WST_initialization_state <= 0) // Only true prior to initialization of std::ios_base::Init. { #ifdef DEBUGDEBUG - bool continued_debug_output = (__libcwd_tsd.library_call == 0 && LIBCWD_DO_TSD_MEMBER(libcw_do, _off) < 0); + bool continued_debug_output = (__libcwd_tsd.library_call == 0 && LIBCWD_DO_TSD_MEMBER_OFF(libcw_do) < 0); #endif init_debugmalloc(); #ifdef DEBUGDEBUG - // It is possible that libcwd is not initialized at this point, libcw_do._off == 0 (turned off) + // It is possible that libcwd is not initialized at this point, LIBCWD_DO_TSD_MEMBER_OFF(libcw_do) == 0 (turned off) // and thus no unfinished debug output was printed before entering this function. // Initialization of libcwd with DEBUGDEBUG defined turns on libcwd_do. In order to balance the // continued stack, we print an unfinished debug message here. - if (continued_debug_output != (__libcwd_tsd.library_call == 0 && LIBCWD_DO_TSD_MEMBER(libcw_do, _off) < 0)) + if (continued_debug_output != (__libcwd_tsd.library_call == 0 && LIBCWD_DO_TSD_MEMBER_OFF(libcw_do) < 0)) DoutInternal( dc_malloc|continued_cf, "internal_malloc(" << size << ", " << flag << ") = " ); #endif } @@ -1233,10 +1233,10 @@ #ifdef DEBUGUSEBFD if (__libcwd_tsd.library_call++) - ++LIBCWD_DO_TSD_MEMBER(libcw_do, _off); // Otherwise debug output will be generated from bfd.cc (location_ct) + ++LIBCWD_DO_TSD_MEMBER_OFF(libcw_do); // Otherwise debug output will be generated from bfd.cc (location_ct) location_ct loc(call_addr LIBCWD_COMMA_TSD); if (--__libcwd_tsd.library_call) - --LIBCWD_DO_TSD_MEMBER(libcw_do, _off); + --LIBCWD_DO_TSD_MEMBER_OFF(libcw_do); #endif #ifdef DEBUGDEBUGMALLOC @@ -2111,10 +2111,10 @@ #ifdef DEBUGUSEBFD if (__libcwd_tsd.library_call++) - libcw_do._off++; // Otherwise debug output will be generated from bfd.cc (location_ct) + ++LIBCWD_DO_TSD_MEMBER_OFF(libcw_do); // Otherwise debug output will be generated from bfd.cc (location_ct) location_ct loc(reinterpret_cast<char*>(__builtin_return_address(0)) + builtin_return_address_offset LIBCWD_COMMA_TSD); if (--__libcwd_tsd.library_call) - libcw_do._off--; + --LIBCWD_DO_TSD_MEMBER_OFF(libcw_do); #endif DEBUGDEBUG_CERR( "register_external_allocation: internal == " << __libcwd_tsd.internal << "; setting it to 1." ); @@ -2448,10 +2448,10 @@ #ifdef DEBUGUSEBFD if (__libcwd_tsd.library_call++) - ++LIBCWD_DO_TSD_MEMBER(libcw_do, _off); // Otherwise debug output will be generated from bfd.cc (location_ct) + ++LIBCWD_DO_TSD_MEMBER_OFF(libcw_do); // Otherwise debug output will be generated from bfd.cc (location_ct) location_ct loc(reinterpret_cast<char*>(__builtin_return_address(0)) + builtin_return_address_offset LIBCWD_COMMA_TSD); if (--__libcwd_tsd.library_call) - --LIBCWD_DO_TSD_MEMBER(libcw_do, _off); + --LIBCWD_DO_TSD_MEMBER_OFF(libcw_do); #endif DEBUGDEBUG_CERR( "__libcwd_realloc: internal == " << __libcwd_tsd.internal << "; setting it to 1." ); Index: src/libcwd/include/cwd_debug.h diff -u src/libcwd/include/cwd_debug.h:1.7 src/libcwd/include/cwd_debug.h:1.8 --- src/libcwd/include/cwd_debug.h:1.7 Tue Jan 22 20:03:44 2002 +++ src/libcwd/include/cwd_debug.h Tue Feb 5 16:46:08 2002 @@ -1,5 +1,5 @@ // Generated automatically from sys.ho.in by configure. -// $Header: /cvsroot/l/li/libcw/src/libcwd/include/cwd_debug.h,v 1.7 2002/01/23 04:03:44 libcw Exp $ +// $Header: /cvsroot/l/li/libcw/src/libcwd/include/cwd_debug.h,v 1.8 2002/02/06 00:46:08 libcw Exp $ // // Copyright (C) 2001, by // @@ -101,7 +101,7 @@ #define LIBCWD_Dout( cntrl, data ) \ do \ { \ - if (LIBCWD_DO_TSD_MEMBER(libcw_do, _off) < 0) \ + if (LIBCWD_DO_TSD_MEMBER_OFF(libcw_do) < 0) \ { \ bool on; \ channel_set_bootstrap_st channel_set(LIBCWD_DO_TSD(libcw_do) LIBCWD_COMMA_TSD); \ Index: src/libcwd/include/libcw/class_debug.inl diff -u src/libcwd/include/libcw/class_debug.inl:1.5 src/libcwd/include/libcw/class_debug.inl:1.6 --- src/libcwd/include/libcw/class_debug.inl:1.5 Sun Jan 20 08:25:11 2002 +++ src/libcwd/include/libcw/class_debug.inl Tue Feb 5 16:46:08 2002 @@ -1,4 +1,4 @@ -// $Header: /cvsroot/l/li/libcw/src/libcwd/include/libcw/class_debug.inl,v 1.5 2002/01/20 16:25:11 libcw Exp $ +// $Header: /cvsroot/l/li/libcw/src/libcwd/include/libcw/class_debug.inl,v 1.6 2002/02/06 00:46:08 libcw Exp $ // // Copyright (C) 2000 - 2001, by // @@ -210,7 +210,7 @@ debug_ct::off(void) { LIBCWD_TSD_DECLARATION - ++LIBCWD_TSD_MEMBER(_off); + ++LIBCWD_TSD_MEMBER_OFF; } /** @@ -243,12 +243,12 @@ { LIBCWD_TSD_DECLARATION #ifdef DEBUGDEBUGOUTPUT - if (LIBCWD_TSD_MEMBER(first_time) && LIBCWD_TSD_MEMBER(_off) == -1) + if (LIBCWD_TSD_MEMBER(first_time) && LIBCWD_TSD_MEMBER_OFF == -1) LIBCWD_TSD_MEMBER(first_time) = false; else - --LIBCWD_TSD_MEMBER(_off); + --LIBCWD_TSD_MEMBER_OFF; #else - --LIBCWD_TSD_MEMBER(_off); + --LIBCWD_TSD_MEMBER_OFF; #endif } Index: src/libcwd/include/libcw/debug_config.ho.in diff -u src/libcwd/include/libcw/debug_config.ho.in:1.17 src/libcwd/include/libcw/debug_config.ho.in:1.18 --- src/libcwd/include/libcw/debug_config.ho.in:1.17 Thu Jan 31 21:21:05 2002 +++ src/libcwd/include/libcw/debug_config.ho.in Tue Feb 5 16:46:08 2002 @@ -1,5 +1,5 @@ // @configure_input@ -// $Header: /cvsroot/l/li/libcw/src/libcwd/include/libcw/debug_config.ho.in,v 1.17 2002/02/01 05:21:05 libcw Exp $ +// $Header: /cvsroot/l/li/libcw/src/libcwd/include/libcw/debug_config.ho.in,v 1.18 2002/02/06 00:46:08 libcw Exp $ // // Copyright (C) 2000 - 2001, by // @@ -278,6 +278,11 @@ #@CW_CONFIG_HAVE_PTHREADS@ LIBCWD_HAVE_PTHREAD #ifdef LIBCWD_THREAD_SAFE +#define LIBCWD_DO_MAX 8 // Maximal total number of debug objects in a single application. + // This costs about 640 kb of memory per object! (640 bytes * PTHREAD_THREADS_MAX). +#define LIBCWD_DC_MAX 256 // Maximal total number of debug channels in a single application. + // Costs 4 kb of memory per channel (exclusive the actual channels). + /** \defgroup enable_libcwd_debugt --enable-libcwd-debugt (DEBUGDEBUGTHREADS) * \ingroup group_configuration * Index: src/libcwd/include/libcw/macro_Libcwd_macros.h diff -u src/libcwd/include/libcw/macro_Libcwd_macros.h:1.4 src/libcwd/include/libcw/macro_Libcwd_macros.h:1.5 --- src/libcwd/include/libcw/macro_Libcwd_macros.h:1.4 Fri Jan 18 21:08:54 2002 +++ src/libcwd/include/libcw/macro_Libcwd_macros.h Tue Feb 5 16:46:08 2002 @@ -1,4 +1,4 @@ -// $Header: /cvsroot/l/li/libcw/src/libcwd/include/libcw/macro_Libcwd_macros.h,v 1.4 2002/01/19 05:08:54 libcw Exp $ +// $Header: /cvsroot/l/li/libcw/src/libcwd/include/libcw/macro_Libcwd_macros.h,v 1.5 2002/02/06 00:46:08 libcw Exp $ // // Copyright (C) 2000 - 2002, by // @@ -82,7 +82,7 @@ { \ DEBUGDEBUGLIBCWDOUTMARKER \ LIBCWD_TSD_DECLARATION \ - if (LIBCWD_DO_TSD_MEMBER(debug_obj, _off) < 0) \ + if (LIBCWD_DO_TSD_MEMBER_OFF(debug_obj) < 0) \ { \ using namespace ::libcw::debug; \ ::libcw::debug::channel_set_bootstrap_st __libcwd_channel_set(LIBCWD_DO_TSD(debug_obj) LIBCWD_COMMA_TSD); \ Index: src/libcwd/include/libcw/private_struct_TSD.h diff -u src/libcwd/include/libcw/private_struct_TSD.h:1.4 src/libcwd/include/libcw/private_struct_TSD.h:1.5 --- src/libcwd/include/libcw/private_struct_TSD.h:1.4 Sat Feb 2 20:15:11 2002 +++ src/libcwd/include/libcw/private_struct_TSD.h Tue Feb 5 16:46:08 2002 @@ -1,4 +1,4 @@ -// $Header: /cvsroot/l/li/libcw/src/libcwd/include/libcw/private_struct_TSD.h,v 1.4 2002/02/03 04:15:11 libcw Exp $ +// $Header: /cvsroot/l/li/libcw/src/libcwd/include/libcw/private_struct_TSD.h,v 1.5 2002/02/06 00:46:08 libcw Exp $ // // Copyright (C) 2001, by // @@ -21,10 +21,17 @@ #ifndef LIBCW_DEBUG_CONFIG_H #include <libcw/debug_config.h> #endif +#ifndef LIBCW_PRIVATE_ASSERT_H +#include <libcw/private_assert.h> +#endif #ifndef LIBCW_CSTRING #define LIBCW_CSTRING #include <cstring> // Needed for std::memset. #endif +#ifndef LIBCW_LIMITS_H +#define LIBCW_LIMITS_H +#include <limits.h> // For PTHREAD_THREADS_MAX +#endif namespace libcw { namespace debug { @@ -40,23 +47,41 @@ // `__libcwd_tsd' reference needs to be passed. We use several helper macros for this: #ifdef LIBCWD_THREAD_SAFE -#define LIBCWD_TSD __libcwd_tsd // Optional `__libcwd_tsd' parameter - // (foo() or foo(__libcwd_tsd)). -#define LIBCWD_COMMA_TSD , LIBCWD_TSD // Idem, but as second or higher parameter. +#define LIBCWD_TSD __libcwd_tsd // Optional `__libcwd_tsd' parameter (foo() or foo(__libcwd_tsd)). +#define LIBCWD_COMMA_TSD , LIBCWD_TSD // Idem, but as second or higher parameter. #define LIBCWD_TSD_PARAM ::libcw::debug::_private_::TSD_st& __libcwd_tsd - // Optional function parameter - // (foo(void) or foo(TSD_st& __libcwd_tsd)). -#define LIBCWD_COMMA_TSD_PARAM , LIBCWD_TSD_PARAM - // Idem, but as second or higher parameter. + // Optional function parameter (foo(void) or foo(TSD_st& __libcwd_tsd)). +#define LIBCWD_COMMA_TSD_PARAM , LIBCWD_TSD_PARAM // Idem, but as second or higher parameter. +#define LIBCWD_TSD_INSTANCE ::libcw::debug::_private_::TSD_st::instance() + // For directly passing the `__libcwd_tsd' instance to a function (foo(TSD::instance())). +#define LIBCWD_COMMA_TSD_INSTANCE , LIBCWD_TSD_INSTANCE // Idem, but as second or higher parameter. +#define LIBCWD_TSD_DECLARATION ::libcw::debug::_private_::TSD_st& __libcwd_tsd(::libcw::debug::_private_::TSD_st::instance()); + // Declaration of local `__libcwd_tsd' structure reference. +#define LIBCWD_DO_TSD(debug_object) (*__libcwd_tsd.do_array[(debug_object).WNS_index]) + // For use inside class debug_ct to access member `m'. +#define LIBCWD_TSD_MEMBER_OFF (__libcwd_tsd.do_off_array[WNS_index]) + // For use inside class debug_ct to access member `_off'. +#define LIBCWD_DO_TSD_MEMBER_OFF(debug_object) (__libcwd_tsd.do_off_array[(debug_object).WNS_index]) + // To access member _off of debug object. + #else // !LIBCWD_THREAD_SAFE #define LIBCWD_TSD #define LIBCWD_COMMA_TSD #define LIBCWD_TSD_PARAM void #define LIBCWD_COMMA_TSD_PARAM +#define LIBCWD_TSD_INSTANCE +#define LIBCWD_COMMA_TSD_INSTANCE +#define LIBCWD_TSD_DECLARATION +#define LIBCWD_DO_TSD(debug_object) ((debug_object).tsd) +#define LIBCWD_TSD_MEMBER_OFF (tsd._off) +#define LIBCWD_DO_TSD_MEMBER_OFF(debug_object) ((debug_object).tsd._off) #endif // !LIBCWD_THREAD_SAFE +#define LIBCWD_DO_TSD_MEMBER(debug_object, m) (LIBCWD_DO_TSD(debug_object).m) +#define LIBCWD_TSD_MEMBER(m) LIBCWD_DO_TSD_MEMBER(*this, m) + // This include uses the above macros. #ifndef LIBCW_STRUCT_DEBUG_TSD #include <libcw/struct_debug_tsd.h> @@ -64,9 +89,50 @@ namespace libcw { namespace debug { + +#ifdef LIBCWD_THREAD_SAFE +// This function must return 0 for the initial thread and an integer smaller than PTHREAD_THREADS_MAX that +// is unique per _running_ thread. It can be used as index into an array of size PTHREAD_THREADS_MAX. +__inline__ +unsigned long +thread_index(pthread_t tid) +{ + return tid % PTHREAD_THREADS_MAX; +} +#endif + namespace _private_ { +struct TSD_st; + +extern int WST_initializing_TSD; +// Thread Specific Data (TSD) is stored in a structure TSD_st +// and is accessed through a reference to `__libcwd_tsd'. +#ifndef LIBCWD_THREAD_SAFE +// When LIBCWD_THREAD_SAFE is not defined then `__libcwd_tsd' is simply a global object in namespace _private_: +extern TSD_st __libcwd_tsd; +#else +// Otherwise, the Thread Specific Data is stored in this global area: +extern TSD_st __libcwd_tsd_array[PTHREAD_THREADS_MAX]; +#endif + +#ifdef LIBCWD_THREAD_SAFE +// Internal structure of a thread description structure. +struct pthread_descr_struct { + union { + struct { + struct pthread_descr_struct* self; // Pointer to this structure. + void* __padding[12]; // Reserved for future use by pthreads. + unsigned short libcwd_tsd_index; // Abuse this space for libcwd. + } data; + void* __padding[16]; + } p_header; + // ... +}; +#endif + struct TSD_st { +public: #ifdef DEBUGMALLOC int internal; int library_call; @@ -79,8 +145,6 @@ #ifdef DEBUGDEBUG bool recursive_assert; // Detect loop involving LIBCWD_ASSERT. #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. #ifdef DEBUGDEBUGTHREADS int cancel_explicitely_deferred; int cancel_explicitely_disabled; @@ -88,18 +152,30 @@ int cleanup_handler_installed; int internal_debugging_code; #endif +#ifdef LIBCWD_THREAD_SAFE + pthread_t tid; + int do_off_array[LIBCWD_DO_MAX]; // Thread Specific on/off counter for Debug Objects. + debug_tsd_st* do_array[LIBCWD_DO_MAX];// Thread Specific Data of Debug Objects or NULL when no debug object. #endif - int off_cnt_array[256]; - TSD_st(void) { std::memset(this, 0, sizeof(struct TSD_st)); } -}; + int off_cnt_array[LIBCWD_DC_MAX]; // Thread Specific Data of Debug Channels. -// Thread Specific Data (TSD) is stored in a structure TSD_st -// and is accessed through a reference to `__libcwd_tsd'. -#ifndef LIBCWD_THREAD_SAFE -// When LIBCWD_THREAD_SAFE is not defined then `__libcwd_tsd' is simply a global object in namespace _private_: -extern TSD_st __libcwd_tsd; -#endif -extern int WST_initializing_TSD; + void S_initialize(void) throw(); + +#ifdef LIBCWD_THREAD_SAFE +//------------------------------------------------------- +// Static data and methods. + +public: + static TSD_st& instance(void) throw() + { + pthread_t tid = pthread_self(); + TSD_st* instance = &__libcwd_tsd_array[thread_index(tid)]; + if (!pthread_equal(tid, instance->tid)) + instance->S_initialize(); + return *instance; + } +#endif // LIBCWD_THREAD_SAFE +}; } // namespace _private_ } // namespace debug Index: src/libcwd/include/libcw/private_threading.h diff -u src/libcwd/include/libcw/private_threading.h:1.18 src/libcwd/include/libcw/private_threading.h:1.19 --- src/libcwd/include/libcw/private_threading.h:1.18 Sat Feb 2 20:15:12 2002 +++ src/libcwd/include/libcw/private_threading.h Tue Feb 5 16:46:08 2002 @@ -1,4 +1,4 @@ -// $Header: /cvsroot/l/li/libcw/src/libcwd/include/libcw/private_threading.h,v 1.18 2002/02/03 04:15:12 libcw Exp $ +// $Header: /cvsroot/l/li/libcw/src/libcwd/include/libcw/private_threading.h,v 1.19 2002/02/06 00:46:08 libcw Exp $ // // Copyright (C) 2001 - 2002, by // @@ -70,61 +70,16 @@ #endif #ifdef LIBCWD_THREAD_SAFE -#define LIBCWD_TSD_INSTANCE ::libcw::debug::_private_::\ - thread_specific_data_tct< ::libcw::debug::_private_::TSD_st>::instance() - // For directly passing the `__libcwd_tsd' instance to a function (foo(TSD::instance())). -#define LIBCWD_COMMA_TSD_INSTANCE , LIBCWD_TSD_INSTANCE - // Idem, but as second or higher parameter. -#define LIBCWD_TSD_DECLARATION ::libcw::debug::_private_::\ - TSD_st& __libcwd_tsd(::libcw::debug::_private_::\ - thread_specific_data_tct< ::libcw::debug::_private_::TSD_st>::instance()); - // Declaration of local `__libcwd_tsd' structure reference. -#define LIBCWD_DO_TSD(debug_object) (__libcwd_tsd.do_array[(debug_object).WNS_index]) - // For use inside class debug_ct to access member `m'. -#else // !LIBCWD_THREAD_SAFE -#define LIBCWD_TSD_INSTANCE -#define LIBCWD_COMMA_TSD_INSTANCE -#define LIBCWD_TSD_DECLARATION -#define LIBCWD_DO_TSD(debug_object) ((debug_object).tsd) -#endif // !LIBCWD_THREAD_SAFE -#define LIBCWD_DO_TSD_MEMBER(debug_object, m) (LIBCWD_DO_TSD(debug_object).m) -#define LIBCWD_TSD_MEMBER(m) LIBCWD_DO_TSD_MEMBER(*this, m) - -#ifdef LIBCWD_THREAD_SAFE - namespace libcw { namespace debug { namespace _private_ { +extern void initialize_global_mutexes(void) throw(); #ifdef DEBUGDEBUG extern bool WST_multi_threaded; #endif -#if LIBCWD_USE_POSIX_THREADS || LIBCWD_USE_LINUXTHREADS -template<class TSD> - class thread_specific_data_tct { - private: - static pthread_once_t S_key_once; - static pthread_key_t S_key; - static TSD* S_temporary_instance; - static bool S_initializing; - static bool S_initialized; - static void S_alloc_key(void) throw(); - static TSD* S_initialize(void) throw(); - static void S_destroy(void* tsd_ptr) throw(); - public: - static TSD& instance(void) throw() - { - TSD* instance = reinterpret_cast<TSD*>(pthread_getspecific(S_key)); - if (!instance) - instance = S_initialize(); - return *instance; - } - static bool initialized(void) { return S_initialized; } - }; -#endif // LIBCWD_USE_POSIX_THREADS || LIBCWD_USE_LINUXTHREADS - //=================================================================================================== // // Mutex locking. @@ -738,89 +693,6 @@ else rdunlock(); } - -//=================================================================================================== -// Implementation of Thread Specific Data. - -#if LIBCWD_USE_POSIX_THREADS || LIBCWD_USE_LINUXTHREADS -template<class TSD> - pthread_once_t thread_specific_data_tct<TSD>::S_key_once = PTHREAD_ONCE_INIT; - -template<class TSD> - pthread_key_t thread_specific_data_tct<TSD>::S_key; - -template<class TSD> - TSD* thread_specific_data_tct<TSD>::S_temporary_instance; - -template<class TSD> - bool thread_specific_data_tct<TSD>::S_initializing; - -template<class TSD> - bool thread_specific_data_tct<TSD>::S_initialized; - -template<class TSD> - void thread_specific_data_tct<TSD>::S_destroy(void* tsd_ptr) throw() - { - TSD* instance = reinterpret_cast<TSD*>(tsd_ptr); - LIBCWD_TSD_DECLARATION - set_alloc_checking_off(LIBCWD_TSD); - delete instance; - // Hopefully S_destroy doesn't get called in the thread itself! - LibcwDebugThreads( LIBCWD_ASSERT( instance != &thread_specific_data_tct<TSD>::instance() ) ); - set_alloc_checking_on(LIBCWD_TSD); - } - -template<class TSD> - void thread_specific_data_tct<TSD>::S_alloc_key(void) throw() - { - pthread_key_create(&S_key, S_destroy); - } - -extern void debug_tsd_init(LIBCWD_TSD_PARAM); -extern void initialize_global_mutexes(void) throw(); - -template<class TSD> - TSD* thread_specific_data_tct<TSD>::S_initialize(void) throw() - { - TSD* instance; - bool initialization_of_second_or_later_thread; - pthread_once(&S_key_once, S_alloc_key); - int oldtype; - pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, &oldtype); // Defer cancellation. - mutex_tct<tsd_initialization_instance>::initialize(); - mutex_tct<tsd_initialization_instance>::lock(); - initialization_of_second_or_later_thread = WST_multi_threaded && !S_initializing; - if (S_initializing) - instance = S_temporary_instance; - else - { - char new_TSD_space[sizeof(TSD)]; // Allocate space on the stack. - S_temporary_instance = new (new_TSD_space) TSD; // Create a temporary TSD. - S_initializing = true; - LIBCWD_TSD_DECLARATION // This will 'return' the temporary TSD if TSD == TSD_st. - initialize_global_mutexes(); // This is a good moment to initialize all pthread mutexes. - set_alloc_checking_off(LIBCWD_TSD); - instance = new TSD; - set_alloc_checking_on(LIBCWD_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. - std::memcpy((void*)instance, new_TSD_space, sizeof(TSD)); // Put the temporary TSD in its final place. - S_initializing = false; - S_initialized = true; - } - mutex_tct<tsd_initialization_instance>::unlock(); - if (initialization_of_second_or_later_thread) // Is this a second (or later) thread? - debug_tsd_init(*instance); // Initialize the TSD of existing debug objects. - pthread_setcanceltype(oldtype, NULL); // Restore cancellation. - return instance; - } -#endif // LIBCWD_USE_POSIX_THREADS || LIBCWD_USE_LINUXTHREADS - -// End of Thread Specific Data -//=================================================================================================== extern void fatal_cancellation(void*) throw(); Index: src/libcwd/include/libcw/struct_debug_tsd.h diff -u src/libcwd/include/libcw/struct_debug_tsd.h:1.5 src/libcwd/include/libcw/struct_debug_tsd.h:1.6 --- src/libcwd/include/libcw/struct_debug_tsd.h:1.5 Tue Jan 22 20:03:45 2002 +++ src/libcwd/include/libcw/struct_debug_tsd.h Tue Feb 5 16:46:08 2002 @@ -1,4 +1,4 @@ -// $Header: /cvsroot/l/li/libcw/src/libcwd/include/libcw/struct_debug_tsd.h,v 1.5 2002/01/23 04:03:45 libcw Exp $ +// $Header: /cvsroot/l/li/libcw/src/libcwd/include/libcw/struct_debug_tsd.h,v 1.6 2002/02/06 00:46:08 libcw Exp $ // // Copyright (C) 2002, by // @@ -55,8 +55,10 @@ struct debug_tsd_st { friend class debug_ct; +#ifndef LIBCWD_THREAD_SAFE int _off; // Debug output is turned on when this variable is -1, otherwise it is off. +#endif bool tsd_initialized; // Set after initialization is completed. @@ -112,7 +114,11 @@ // Initialization and de-initialization. void init(void); - debug_tsd_st(void); + debug_tsd_st(void) : +#ifndef LIBCWD_THREAD_SAFE + _off(0), +#endif + tsd_initialized(false) { } ~debug_tsd_st(); }; Index: src/libcwd/tests/threads4.cc diff -u src/libcwd/tests/threads4.cc:1.8 src/libcwd/tests/threads4.cc:1.9 --- src/libcwd/tests/threads4.cc:1.8 Wed Jan 30 20:42:08 2002 +++ src/libcwd/tests/threads4.cc Tue Feb 5 16:46:08 2002 @@ -9,6 +9,8 @@ libcw::debug::channel_ct hello("HELLO"); } } + +using libcw::debug::thread_index; #endif int const loopsize = 1000; @@ -34,16 +36,16 @@ // And for the debug object. Debug( libcw_do.on() ); char margin[32]; - sprintf(margin, "%-10lu", pthread_self()); - Debug( libcw_do.margin().assign(margin, 10) ); + sprintf(margin, "%-10lu (%04lu) ", pthread_self(), thread_index(pthread_self())); + Debug( libcw_do.margin().assign(margin, 18) ); - Dout(dc::notice, "Entering thread " << pthread_self()); + Dout(dc::notice, "Entering thread " << pthread_self() << " (" << thread_index(pthread_self()) << ')'); int cnt = 0; //strstream ss; for (int i = 0; i < loopsize; ++i) { - Dout(dc::notice, "Thread " << pthread_self() << " now starting loop " << i); - Dout(dc::hello, pthread_self() << ':' << cnt++ << "; This should be printed"); + Dout(dc::notice, "Thread " << pthread_self() << " (" << thread_index(pthread_self()) << ") now starting loop " << i); + Dout(dc::hello, pthread_self() << " (" << thread_index(pthread_self()) << "):" << cnt++ << "; This should be printed"); Debug(dc::hello.off()); Debug(dc::hello.off()); @@ -52,7 +54,7 @@ { Dout(dc::notice|continued_cf, "thread_function: creating thread " << j << ", "); pthread_create(&thread_id[j], NULL, thread_function2, NULL); - Dout(dc::finish, "id " << thread_id[j] << '.'); + Dout(dc::finish, "id " << thread_id[j] << " (" << thread_index(thread_id[j]) << ")."); } Dout(dc::hello, "THIS SHOULD NOT BE PRINTED!!!" << (cnt += loopsize + 1)); Debug(dc::hello.on()); @@ -60,10 +62,10 @@ { void* status; pthread_join(thread_id[j], &status); - Dout(dc::notice, "thread_function: thread " << j << ", id " << thread_id[j] << ", returned with status " << ((bool)status ? "OK" : "ERROR") << '.'); + Dout(dc::notice, "thread_function: thread " << j << ", id " << thread_id[j] << " (" << thread_index(thread_id[j]) << "), returned with status " << ((bool)status ? "OK" : "ERROR") << '.'); } } - Dout(dc::notice, "Leaving thread " << pthread_self()); + Dout(dc::notice, "Leaving thread " << pthread_self() << " (" << thread_index(pthread_self()) << ')'); return (void *)(cnt == loopsize); } @@ -76,7 +78,9 @@ #endif Debug( libcw_do.set_ostream(&std::cout) ); Debug( libcw_do.on() ); - Debug( libcw_do.margin().assign("main ", 10) ); + char margin[32]; + sprintf(margin, "%-10lu (%04lu) ", pthread_self(), thread_index(pthread_self())); + Debug( libcw_do.margin().assign(margin, 18) ); ForAllDebugChannels( if (!debugChannel.is_on()) debugChannel.on(); ); Debug( list_channels_on(libcw_do) ); @@ -86,14 +90,14 @@ { Dout(dc::notice|continued_cf, "main: creating thread " << i << ", "); pthread_create(&thread_id[i], NULL, thread_function, NULL); - Dout(dc::finish, "id " << thread_id[i] << '.'); + Dout(dc::finish, "id " << thread_id[i] << " (" << thread_index(thread_id[i]) << ")."); } for (int i = 0; i < number_of_threads; ++i) { void* status; pthread_join(thread_id[i], &status); - Dout(dc::notice, "main loop: thread " << i << ", id " << thread_id[i] << ", returned with status " << ((bool)status ? "OK" : "ERROR") << '.'); + Dout(dc::notice, "main loop: thread " << i << ", id " << thread_id[i] << " (" << thread_index(thread_id[i]) << "), returned with status " << ((bool)status ? "OK" : "ERROR") << '.'); } Dout(dc::notice, "Exiting from main()"); Index: src/libcwd/threading.cc diff -u src/libcwd/threading.cc:1.5 src/libcwd/threading.cc:1.6 --- src/libcwd/threading.cc:1.5 Sat Feb 2 20:15:11 2002 +++ src/libcwd/threading.cc Tue Feb 5 16:46:07 2002 @@ -1,4 +1,4 @@ -// $Header: /cvsroot/l/li/libcw/src/libcwd/threading.cc,v 1.5 2002/02/03 04:15:11 libcw Exp $ +// $Header: /cvsroot/l/li/libcw/src/libcwd/threading.cc,v 1.6 2002/02/06 00:46:07 libcw Exp $ // // Copyright (C) 2001, by // @@ -60,6 +60,43 @@ char* text = static_cast<char*>(arg); Dout(dc::core, "Cancelling a thread " << text << ". This is not supported by libcwd, sorry."); } + +//=================================================================================================== +// Implementation of Thread Specific Data. + +TSD_st __libcwd_tsd_array[PTHREAD_THREADS_MAX]; + +#if LIBCWD_USE_POSIX_THREADS || LIBCWD_USE_LINUXTHREADS +extern void debug_tsd_init(LIBCWD_TSD_PARAM); + +void TSD_st::S_initialize(void) throw() +{ + int oldtype; + pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, &oldtype); + mutex_tct<tsd_initialization_instance>::initialize(); + mutex_tct<tsd_initialization_instance>::lock(); + debug_tsd_st* old_array[LIBCWD_DO_MAX]; + std::memcpy(old_array, do_array, sizeof(old_array)); + std::memset(this, 0, sizeof(struct TSD_st)); // This structure might be reused and therefore already contain data. + tid = pthread_self(); + initialize_global_mutexes(); // This is a good moment to initialize all pthread mutexes. + mutex_tct<tsd_initialization_instance>::unlock(); + if (WST_multi_threaded) // Is this a second (or later) thread? + { + set_alloc_checking_off(*this); + for (int i = 0; i < LIBCWD_DO_MAX; ++i) + if (old_array[i]) + delete old_array[i]; // Free old objects when this structure is being reused. + set_alloc_checking_on(*this); + debug_tsd_init(*this); // Initialize the TSD of existing debug objects. + } + pthread_setcanceltype(oldtype, NULL); +} + +#endif // LIBCWD_USE_POSIX_THREADS || LIBCWD_USE_LINUXTHREADS + +// End of Thread Specific Data +//=================================================================================================== } // namespace _private_ } // namespace debug ----------------------- End of diff ----------------------- |
From: Carlo W. <li...@us...> - 2002-02-04 03:51:29
|
CVSROOT : /cvsroot/libcw Module : src Commit time: 2002-01-04 03:51:28 UTC Modified files: libcwd/tests/.cvsignore Log message: Ignore threads4 binary. ---------------------- diff included ---------------------- Index: src/libcwd/tests/.cvsignore diff -u src/libcwd/tests/.cvsignore:1.13 src/libcwd/tests/.cvsignore:1.14 --- src/libcwd/tests/.cvsignore:1.13 Sat Dec 29 20:17:50 2001 +++ src/libcwd/tests/.cvsignore Sun Feb 3 19:51:18 2002 @@ -7,6 +7,7 @@ threads threads2 threads3 +threads4 stabs dout_alloc .deps ----------------------- End of diff ----------------------- |
From: Carlo W. <li...@us...> - 2002-02-04 03:50:48
|
CVSROOT : /cvsroot/libcw Module : src Commit time: 2002-01-04 03:50:46 UTC Modified files: libcwd/debugmalloc.cc Added files: libcwd/wrapcnclpnts.cc Log message: Forgot to add wrapcnclpnts.cc is last commit. ---------------------- diff included ---------------------- Index: src/libcwd/debugmalloc.cc diff -u src/libcwd/debugmalloc.cc:1.78 src/libcwd/debugmalloc.cc:1.79 --- src/libcwd/debugmalloc.cc:1.78 Sat Feb 2 20:15:11 2002 +++ src/libcwd/debugmalloc.cc Sun Feb 3 19:50:36 2002 @@ -1,4 +1,4 @@ -// $Header: /cvsroot/l/li/libcw/src/libcwd/debugmalloc.cc,v 1.78 2002/02/03 04:15:11 libcw Exp $ +// $Header: /cvsroot/l/li/libcw/src/libcwd/debugmalloc.cc,v 1.79 2002/02/04 03:50:36 libcw Exp $ // // Copyright (C) 2000 - 2001, by // @@ -1739,7 +1739,6 @@ #ifdef DEBUGDEBUGMALLOC LIBCWD_ASSERT( !__libcwd_tsd.internal ); #endif - //LIBCWD_DEFER_CLEANUP_PUSH(&rwlock_tct<memblk_map_instance>::cleanup, NULL); LIBCWD_DEFER_CANCEL ACQUIRE_WRITE_LOCK for (memblk_map_ct::iterator iter(memblk_map_write->begin()); iter != memblk_map_write->end(); ++iter) @@ -1753,7 +1752,6 @@ } RELEASE_WRITE_LOCK LIBCWD_RESTORE_CANCEL - //LIBCWD_CLEANUP_POP_RESTORE(false); } // Undocumented (used in macro AllocTag) Index: src/libcwd/wrapcnclpnts.cc diff -u /dev/null src/libcwd/wrapcnclpnts.cc:1.1 --- /dev/null Sun Feb 3 19:50:46 2002 +++ src/libcwd/wrapcnclpnts.cc Sun Feb 3 19:50:36 2002 @@ -0,0 +1,145 @@ +// $Header: /cvsroot/l/li/libcw/src/libcwd/wrapcnclpnts.cc,v 1.1 2002/02/04 03:50:36 libcw Exp $ +// +// Copyright (C) 2002, by +// +// Carlo Wood, Run on IRC <ca...@al...> +// RSA-1024 0x624ACAD5 1997-01-26 Sign & Encrypt +// Fingerprint16 = 32 EC A7 B6 AC DB 65 A6 F6 F6 55 DD 1C DC FF 61 +// +// This file may be distributed under the terms of the Q Public License +// version 1.0 as appearing in the file LICENSE.QPL included in the +// packaging of this file. +// + +#define _LARGEFILE64_SOURCE + +#include <libcw/sysd.h> +#include <libcw/debug_config.h> // Needed for DEBUGDEBUGTHREADS + +#ifdef DEBUGDEBUGTHREADS + +#ifndef LIBCW_PRIVATE_THREADING_H +#include <libcw/private_threading.h> +#endif +#ifndef LIBCW_PRIVATE_ASSERT_H +#include <libcw/private_assert.h> +#endif + +extern "C" { +#include <unistd.h> +#include <fcntl.h> +#include <sys/mman.h> +#include <pthread.h> +#include <stdarg.h> +#include <stddef.h> +#include <stdlib.h> +#include <termios.h> +#include <sys/resource.h> +#include <sys/wait.h> +#include <sys/socket.h> +} + +#define CANCELLATION_POINT_SYSCALL(return_t, name, arg_list, args) \ +return_t __libc_##name arg_list; \ +return_t __attribute__ ((weak)) name arg_list \ +{ \ + LIBCWD_TSD_DECLARATION \ + LIBCWD_ASSERT( __libcwd_tsd.inside_critical_area == __libcwd_tsd.cleanup_handler_installed || __libcwd_tsd.cancel_explicitely_disabled || __libcwd_tsd.internal_debugging_code ); \ + int oldtype; \ + pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, &oldtype); \ + return_t res = __libc_##name args; \ + pthread_setcanceltype(oldtype, NULL); \ + return res; \ +} + +#define CANCELLATION_POINT_SYSCALL_VA(return_t, name, arg_list, args, last_arg) \ +return_t __libc_##name arg_list; \ +return_t __attribute__ ((weak)) name arg_list \ +{ \ + LIBCWD_TSD_DECLARATION \ + LIBCWD_ASSERT( __libcwd_tsd.inside_critical_area == __libcwd_tsd.cleanup_handler_installed || __libcwd_tsd.cancel_explicitely_disabled || __libcwd_tsd.internal_debugging_code ); \ + int oldtype; \ + pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, &oldtype); \ + va_list ap; \ + va_start(ap, last_arg); \ + return_t res = __libc_##name args; \ + va_end(ap); \ + pthread_setcanceltype(oldtype, NULL); \ + return res; \ +} + +#define strong_alias(name, aliasname) extern __typeof (name) aliasname __attribute__ ((alias (#name))); + +extern "C" { + +CANCELLATION_POINT_SYSCALL (int, close, (int fd), (fd)) +strong_alias(close, __close) + +CANCELLATION_POINT_SYSCALL_VA (int, fcntl, (int fd, int cmd, ...), (fd, cmd, va_arg (ap, long int)), cmd) +strong_alias(fcntl, __fcntl) + +CANCELLATION_POINT_SYSCALL (int, fsync, (int fd), (fd)) + +CANCELLATION_POINT_SYSCALL (off_t, lseek, (int fd, off_t offset, int whence), (fd, offset, whence)) +strong_alias(lseek, __lseek) + +CANCELLATION_POINT_SYSCALL (off64_t, lseek64, (int fd, off64_t offset, int whence), (fd, offset, whence)) + +CANCELLATION_POINT_SYSCALL (int, msync, (__ptr_t addr, size_t length, int flags), (addr, length, flags)) + +CANCELLATION_POINT_SYSCALL (int, nanosleep, (const struct timespec *requested_time, struct timespec *remaining), (requested_time, remaining)) + +CANCELLATION_POINT_SYSCALL_VA (int, open, (const char *pathname, int flags, ...), (pathname, flags, va_arg (ap, mode_t)), flags) +strong_alias(open, __open) + +CANCELLATION_POINT_SYSCALL_VA (int, open64, (const char *pathname, int flags, ...), (pathname, flags, va_arg (ap, mode_t)), flags) +strong_alias(open64, __open64) + +CANCELLATION_POINT_SYSCALL (int, pause, (void), ()) + +CANCELLATION_POINT_SYSCALL (ssize_t, pread, (int fd, void *buf, size_t count, off_t offset), (fd, buf, count, offset)) + +CANCELLATION_POINT_SYSCALL (ssize_t, pread64, (int fd, void *buf, size_t count, off64_t offset), (fd, buf, count, offset)) +strong_alias(pread64, __pread64) + +CANCELLATION_POINT_SYSCALL (ssize_t, pwrite, (int fd, const void *buf, size_t n, off_t offset), (fd, buf, n, offset)) + +CANCELLATION_POINT_SYSCALL (ssize_t, pwrite64, (int fd, const void *buf, size_t n, off64_t offset), (fd, buf, n, offset)) +strong_alias(pwrite64, __pwrite64) + +CANCELLATION_POINT_SYSCALL (ssize_t, read, (int fd, void *buf, size_t count), (fd, buf, count)) +strong_alias(read, __read) + +CANCELLATION_POINT_SYSCALL (int, system, (const char *line), (line)) + +CANCELLATION_POINT_SYSCALL (int, tcdrain, (int fd), (fd)) + +CANCELLATION_POINT_SYSCALL (__pid_t, wait, (__WAIT_STATUS_DEFN stat_loc), (stat_loc)) +strong_alias(wait, __wait) + +CANCELLATION_POINT_SYSCALL (__pid_t, waitpid, (__pid_t pid, int *stat_loc, int options), (pid, stat_loc, options)) + +CANCELLATION_POINT_SYSCALL (ssize_t, write, (int fd, const void *buf, size_t n), (fd, buf, n)) +strong_alias(write, __write) + +CANCELLATION_POINT_SYSCALL (int, accept, (int fd, __SOCKADDR_ARG addr, socklen_t *addr_len), (fd, addr, addr_len)) + +CANCELLATION_POINT_SYSCALL (int, connect, (int fd, __CONST_SOCKADDR_ARG addr, socklen_t len), (fd, addr, len)) +strong_alias(connect, __connect) + +CANCELLATION_POINT_SYSCALL (ssize_t, recv, (int fd, __ptr_t buf, size_t n, int flags), (fd, buf, n, flags)) + +CANCELLATION_POINT_SYSCALL (ssize_t, recvfrom, (int fd, __ptr_t buf, size_t n, int flags, __SOCKADDR_ARG addr, socklen_t *addr_len), (fd, buf, n, flags, addr, addr_len)) + +CANCELLATION_POINT_SYSCALL (ssize_t, recvmsg, (int fd, struct msghdr *message, int flags), (fd, message, flags)) + +CANCELLATION_POINT_SYSCALL (ssize_t, send, (int fd, const __ptr_t buf, size_t n, int flags), (fd, buf, n, flags)) +strong_alias(send, __send) + +CANCELLATION_POINT_SYSCALL (ssize_t, sendmsg, (int fd, const struct msghdr *message, int flags), (fd, message, flags)) + +CANCELLATION_POINT_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)) + +} // extern "C" + +#endif // DEBUGDEBUGTHREADS ----------------------- End of diff ----------------------- |
From: Carlo W. <li...@us...> - 2002-02-03 04:15:23
|
CVSROOT : /cvsroot/libcw Module : src Commit time: 2002-01-03 04:15:22 UTC Modified files: libcwd/Makefile.am libcwd/bfd.cc libcwd/configure.in libcwd/debug.cc libcwd/debugmalloc.cc libcwd/elf32.cc libcwd/threading.cc libcwd/include/raw_write.h libcwd/include/libcw/macro_ForAllDebugChannels.h libcwd/include/libcw/macro_ForAllDebugObjects.h libcwd/include/libcw/private_struct_TSD.h libcwd/include/libcw/private_threading.h Log message: Now compiles again without --enable-libcwd-threading. Now is cancel-safe: No cancellation point syscalls are done inside libcwd critical areas or cancellation is disabled first or a cleanup handler is installed (it is not certain that these cleanup handlers do the right thing though, but they should at least unlock all locks). ---------------------- diff included ---------------------- Index: src/libcwd/Makefile.am diff -u src/libcwd/Makefile.am:1.44 src/libcwd/Makefile.am:1.45 --- src/libcwd/Makefile.am:1.44 Wed Jan 30 20:42:08 2002 +++ src/libcwd/Makefile.am Sat Feb 2 20:15:11 2002 @@ -28,7 +28,7 @@ demangle3.cc \ strerrno.cc \ type_info.cc \ - wrapcnclpnts.c + wrapcnclpnts.cc libcwd_la_LDFLAGS = -version-info $(VERSIONINFO) $(LIB_THREADS_SHARED) Index: src/libcwd/bfd.cc diff -u src/libcwd/bfd.cc:1.98 src/libcwd/bfd.cc:1.99 --- src/libcwd/bfd.cc:1.98 Thu Jan 31 21:21:05 2002 +++ src/libcwd/bfd.cc Sat Feb 2 20:15:11 2002 @@ -1,4 +1,4 @@ -// $Header: /cvsroot/l/li/libcw/src/libcwd/bfd.cc,v 1.98 2002/02/01 05:21:05 libcw Exp $ +// $Header: /cvsroot/l/li/libcw/src/libcwd/bfd.cc,v 1.99 2002/02/03 04:15:11 libcw Exp $ // // Copyright (C) 2000 - 2001, by // @@ -78,8 +78,8 @@ #define BFD_RELEASE_READ_LOCK rwlock_tct<object_files_instance>::rdunlock(); #define BFD_ACQUIRE_READ2WRITE_LOCK rwlock_tct<object_files_instance>::rd2wrlock(); #define BFD_ACQUIRE_WRITE2READ_LOCK rwlock_tct<object_files_instance>::wr2rdlock(); -#define DLOPEN_MAP_ACQUIRE_LOCK LIBCWD_DEFER_PUSH_LOCKMUTEX(dlopen_map_instance, &mutex_tct<dlopen_map_instance>::unlock); -#define DLOPEN_MAP_RELEASE_LOCK LIBCWD_UNLOCKMUTEX_POP_RESTORE(dlopen_map_instance) +#define DLOPEN_MAP_ACQUIRE_LOCK mutex_tct<dlopen_map_instance>::lock(); +#define DLOPEN_MAP_RELEASE_LOCK mutex_tct<dlopen_map_instance>::unlock(); #else // !LIBCWD_THREAD_SAFE #define BFD_INITIALIZE_LOCK #define BFD_ACQUIRE_WRITE_LOCK @@ -1013,19 +1013,12 @@ // Load executable // No write lock is really needed because this is a Single Threaded function, // but the sanity checks inside the allocators used in load_object_file() - // require the lock to be set. Fortunately is therefore also doesn't hurt + // require the lock to be set. Fortunately it therefore also doesn't hurt // that we keep the lock a long time (during the execution of ldd_prog). // Same thing for the LIBCWD_DEFER_CANCEL, needed for the sanity checks. - // However - here we have another sanity check that controls if we aren't - // setting the cancel state too often (recursively), and in *this* case - // that is unavoidable. Therefore we decrement these sanity check counters - // in order to fool the check, right after we set the lock. BFD_INITIALIZE_LOCK - LIBCWD_DEFER_CANCEL + LIBCWD_DEFER_CLEANUP_PUSH(_private_::fatal_cancellation, const_cast<char*>("while reading debug information from a shared library")) BFD_ACQUIRE_WRITE_LOCK -#ifdef DEBUGDEBUGTHREADS - --__libcwd_tsd.cancel_explicitely_deferred; -#endif load_object_file(fullpath.value->data(), 0); // Load all shared objects @@ -1052,9 +1045,6 @@ load_object_file(l->l_name, reinterpret_cast<void*>(l->l_addr)); } NEEDS_WRITE_LOCK_object_files().sort(object_file_greater()); -#ifdef DEBUGDEBUGTHREADS - ++__libcwd_tsd.cancel_explicitely_deferred; -#endif BFD_RELEASE_WRITE_LOCK set_alloc_checking_on(LIBCWD_TSD); @@ -1062,7 +1052,7 @@ // **************************************************************************** // We put this outside the 'internal' region because it might call __pthread_do_exit. - LIBCWD_RESTORE_CANCEL + LIBCWD_CLEANUP_POP_RESTORE(false) #ifdef ALWAYS_PRINT_LOADING Debug( dc::bfd.restore(state2) ); @@ -1450,6 +1440,16 @@ namespace _private_ { typedef std::map<void*, dlloaded_st, std::less<void*>, userspace_allocator::rebind<void*>::other> dlopen_map_ct; static dlopen_map_ct dlopen_map; + +#ifdef LIBCWD_THREAD_SAFE +void dlopen_cleanup1(void* arg) +{ + TSD_st& __libcwd_tsd = (*static_cast<TSD_st*>(arg)); + set_alloc_checking_on(LIBCWD_TSD); + BFD_RELEASE_WRITE_LOCK +} +#endif + } } } @@ -1464,35 +1464,26 @@ if ((flags & RTLD_NOLOAD)) return handle; #endif - set_alloc_checking_off(LIBCWD_TSD); - LIBCWD_DEFER_CANCEL_NO_BRACE + cwbfd::object_file_ct* object_file; + LIBCWD_DEFER_CLEANUP_PUSH(libcw::debug::_private_::dlopen_cleanup1, &__libcwd_tsd) // In case we are cancelled inside cwbfd::load_object_file(). BFD_ACQUIRE_WRITE_LOCK; - cwbfd::object_file_ct* object_file = cwbfd::load_object_file(name, cwbfd::unknown_l_addr); + set_alloc_checking_off(LIBCWD_TSD); + object_file = cwbfd::load_object_file(name, cwbfd::unknown_l_addr); + if (object_file) + cwbfd::NEEDS_WRITE_LOCK_object_files().sort(cwbfd::object_file_greater()); set_alloc_checking_on(LIBCWD_TSD); + BFD_RELEASE_WRITE_LOCK; + LIBCWD_CLEANUP_POP_RESTORE(false) if (object_file) { - set_alloc_checking_off(LIBCWD_TSD); - cwbfd::NEEDS_WRITE_LOCK_object_files().sort(cwbfd::object_file_greater()); - set_alloc_checking_on(LIBCWD_TSD); - BFD_RELEASE_WRITE_LOCK; - LIBCWD_RESTORE_CANCEL_NO_BRACE // MT: dlopen_map uses a userspace_allocator and might therefore write to dc::malloc. // This means that the thread can be cancelled inside the insert() call, leaving // dlopen_map in an undefined state. Therefore we disable cancellation. LIBCWD_DISABLE_CANCEL - DLOPEN_MAP_ACQUIRE_LOCK; + DLOPEN_MAP_ACQUIRE_LOCK libcw::debug::_private_::dlopen_map.insert(std::pair<void* const, dlloaded_st>(handle, dlloaded_st(object_file, flags))); -#ifdef LIBCWD_THREAD_SAFE - DLOPEN_MAP_RELEASE_LOCK; - // If the thread is cancelled next, then we don't need to take action regarding dlopen_map: - // The shared library will state loaded. + DLOPEN_MAP_RELEASE_LOCK LIBCWD_ENABLE_CANCEL -#endif - } - else - { - BFD_RELEASE_WRITE_LOCK; - LIBCWD_RESTORE_CANCEL_NO_BRACE } return handle; } @@ -1502,8 +1493,8 @@ LIBCWD_TSD_DECLARATION LIBCWD_ASSERT( !__libcwd_tsd.internal ); int ret = ::dlclose(handle); - DLOPEN_MAP_ACQUIRE_LOCK; - // MT: Cancellation is defered at this point. The first cancellation point is in DLOPEN_MAP_RELEASE_LOCK. + LIBCWD_DEFER_CANCEL + DLOPEN_MAP_ACQUIRE_LOCK libcw::debug::_private_::dlopen_map_ct::iterator iter(libcw::debug::_private_::dlopen_map.find(handle)); if (iter != libcw::debug::_private_::dlopen_map.end()) { @@ -1527,7 +1518,8 @@ pthread_setcancelstate(oldstate, NULL); #endif } - DLOPEN_MAP_RELEASE_LOCK; + DLOPEN_MAP_RELEASE_LOCK + LIBCWD_RESTORE_CANCEL return ret; } } // extern "C" Index: src/libcwd/configure.in diff -u src/libcwd/configure.in:1.100 src/libcwd/configure.in:1.101 --- src/libcwd/configure.in:1.100 Thu Jan 31 21:21:05 2002 +++ src/libcwd/configure.in Sat Feb 2 20:15:11 2002 @@ -1,5 +1,5 @@ dnl Process this file with autoconf to produce a configure script. -AC_REVISION($Revision: 1.100 $)dnl +AC_REVISION($Revision: 1.101 $)dnl dnl General intialization of `autoconf' varaibles. dnl Ensure that the directory specified with --srcdir was correct @@ -344,8 +344,6 @@ CW_CONFIG_HAVE_PTHREADS=undef AC_SUBST(LIB_THREADS) AC_SUBST(LIB_THREADS_SHARED) -CW_CONFIG_HAVE__PTHREAD_CLEANUP_BUFFER=undef -AC_SUBST(CW_CONFIG_HAVE__PTHREAD_CLEANUP_BUFFER) if test "$libcwd_config_threading" = yes; then dnl Check if we have POSIX threads @@ -382,8 +380,6 @@ dnl itself even!. AC_CHECK_LIB(pthread, pthread_create, [LIB_THREADS_SHARED=-lpthread]) fi - - AC_CHECK_TYPE([struct _pthread_cleanup_buffer],[CW_CONFIG_HAVE__PTHREAD_CLEANUP_BUFFER=define],,[#include <pthread.h>]) fi dnl This test needs the full set of libraries we just determined. Index: src/libcwd/debug.cc diff -u src/libcwd/debug.cc:1.60 src/libcwd/debug.cc:1.61 --- src/libcwd/debug.cc:1.60 Wed Jan 30 20:42:08 2002 +++ src/libcwd/debug.cc Sat Feb 2 20:15:11 2002 @@ -1,4 +1,4 @@ -// $Header: /cvsroot/l/li/libcw/src/libcwd/debug.cc,v 1.60 2002/01/31 04:42:08 libcw Exp $ +// $Header: /cvsroot/l/li/libcw/src/libcwd/debug.cc,v 1.61 2002/02/03 04:15:11 libcw Exp $ // // Copyright (C) 2000 - 2001, by // @@ -75,7 +75,7 @@ char* buf; bool used_malloc = false; int curlen = rdbuf()->pubseekoff(0, ios_base::cur, ios_base::out) - rdbuf()->pubseekoff(0, ios_base::cur, ios_base::in); - if (curlen > 512 || !(buf = (char*)alloca(curlen))) + if (curlen > 512 || !(buf = (char*)__builtin_alloca(curlen))) { set_alloc_checking_off(LIBCWD_TSD); buf = (char*)malloc(curlen); @@ -90,7 +90,9 @@ ++__libcwd_tsd.library_call; ++LIBCWD_DO_TSD_MEMBER(libcw_do, _off); #endif + LIBCWD_DISABLE_CANCEL // We don't want Dout() to be a cancellation point. os->write(buf, curlen); + LIBCWD_ENABLE_CANCEL #ifdef DEBUGMALLOC --LIBCWD_DO_TSD_MEMBER(libcw_do, _off); --__libcwd_tsd.library_call; @@ -300,11 +302,8 @@ debug_objects_ct debug_objects; // List with all debug devices. // _private_:: - void debug_channels_ct::internal_init(LIBCWD_TSD_PARAM) + void debug_channels_ct::init(LIBCWD_TSD_PARAM) { -#ifdef DEBUGDEBUGMALLOC - LIBCWD_ASSERT( __libcwd_tsd.internal ); -#endif #ifdef LIBCWD_THREAD_SAFE _private_::rwlock_tct<_private_::debug_channels_instance>::initialize(); #endif @@ -312,7 +311,9 @@ if (!WNS_debug_channels) // MT: `WNS_debug_channels' is only false when this object is still Non_Shared. { DEBUG_CHANNELS_ACQUIRE_READ2WRITE_LOCK + set_alloc_checking_off(LIBCWD_TSD); WNS_debug_channels = new debug_channels_ct::container_type; + set_alloc_checking_on(LIBCWD_TSD); DEBUG_CHANNELS_RELEASE_WRITE_LOCK } #ifdef LIBCWD_THREAD_SAFE @@ -340,7 +341,7 @@ #endif // _private_:: - void debug_objects_ct::internal_init(LIBCWD_TSD_PARAM) + void debug_objects_ct::init(LIBCWD_TSD_PARAM) { #ifdef LIBCWD_THREAD_SAFE _private_::rwlock_tct<_private_::debug_objects_instance>::initialize(); @@ -354,7 +355,9 @@ init_debugmalloc(); #endif DEBUG_OBJECTS_ACQUIRE_READ2WRITE_LOCK + set_alloc_checking_off(LIBCWD_TSD); WNS_debug_objects = new debug_objects_ct::container_type; + set_alloc_checking_on(LIBCWD_TSD); DEBUG_OBJECTS_RELEASE_WRITE_LOCK } #ifdef LIBCWD_THREAD_SAFE @@ -762,53 +765,53 @@ ++_off; DEBUGDEBUG_CERR( "Entering debug_ct::finish(), _off became " << _off ); + // Handle control flags, if any: + if ((current->mask & error_cf)) + *current_oss << ": " << strerrno(current->err) << " (" << strerror(current->err) << ')'; + if (!(current->mask & nonewline_cf)) + current_oss->put('\n'); + // Write buffer to ostream. static_cast<buffer_ct*>(current_oss)->writeto(target_os LIBCWD_COMMA_TSD); - channel_set.mask = current->mask; - channel_set.label = current->label; // Handle control flags, if any: - if (channel_set.mask == 0) - target_os->put('\n'); - else + if (current->mask != 0) { - if ((channel_set.mask & error_cf)) - *target_os << ": " << strerrno(current->err) << " (" << strerror(current->err) << ')'; - if ((channel_set.mask & coredump_maskbit)) - { - if (!__libcwd_tsd.recursive_fatal) - { - __libcwd_tsd.recursive_fatal = true; - *target_os << std::endl; // First time, try to write a new-line and flush. - } - core_dump(); - } - if ((channel_set.mask & fatal_maskbit)) + if ((current->mask & (coredump_maskbit|fatal_maskbit))) { + set_alloc_checking_on(LIBCWD_TSD); if (!__libcwd_tsd.recursive_fatal) { __libcwd_tsd.recursive_fatal = true; - *target_os << std::endl; + LIBCWD_DISABLE_CANCEL + *target_os << std::flush; // First time, try to flush. + LIBCWD_ENABLE_CANCEL } + if ((current->mask & coredump_maskbit)) + core_dump(); DEBUGDEBUG_CERR( "Deleting `current' " << (void*)current ); delete current; DEBUGDEBUG_CERR( "Done deleting `current'" ); set_alloc_checking_on(LIBCWD_TSD); exit(254); } - if ((channel_set.mask & wait_cf)) + if ((current->mask & wait_cf)) { - *target_os << "\n(type return)"; + *target_os << "(type return)"; if (debug_object.interactive) { *target_os << std::flush; while(std::cin.get() != '\n'); } } - if (!(channel_set.mask & nonewline_cf)) - *target_os << '\n'; - if ((channel_set.mask & flush_cf)) + if ((current->mask & flush_cf)) + { + set_alloc_checking_on(LIBCWD_TSD); + LIBCWD_DISABLE_CANCEL *target_os << std::flush; + LIBCWD_ENABLE_CANCEL + set_alloc_checking_off(LIBCWD_TSD); + } } DEBUGDEBUG_CERR( "Deleting `current' " << (void*)current ); @@ -825,11 +828,12 @@ // Restore previous buffer as being the current one, if any. if (laf_stack.size()) { + control_flag_t mask = current->mask; current = laf_stack.top(); DEBUGDEBUG_CERR( "current = " << (void*)current ); current_oss = ¤t->oss; DEBUGDEBUG_CERR( "current_oss = " << (void*)current_oss ); - if ((channel_set.mask & flush_cf)) + if ((mask & flush_cf)) current->mask |= flush_cf; // Propagate flush to real ostream. } else @@ -857,7 +861,9 @@ DoutFatal( dc::core, "Don't use `DoutFatal' together with `continued_cf', use `Dout' instead. (This message can also occur when using DoutFatal correctly but from the constructor of a global object)." ); } +#ifdef LIBCWD_THREAD_SAFE int debug_ct::S_index_count = 0; +#endif void debug_ct::NS_init(void) { @@ -878,8 +884,8 @@ LIBCWD_TSD_DECLARATION LIBCWD_DEFER_CANCEL + _private_::debug_objects.init(LIBCWD_TSD); set_alloc_checking_off(LIBCWD_TSD); // debug_objects is internal. - _private_::debug_objects.internal_init(LIBCWD_TSD); DEBUG_OBJECTS_ACQUIRE_WRITE_LOCK if (find(_private_::debug_objects.write_locked().begin(), _private_::debug_objects.write_locked().end(), this) @@ -1037,9 +1043,7 @@ channel_ct* tmp = NULL; LIBCWD_TSD_DECLARATION LIBCWD_DEFER_CANCEL - set_alloc_checking_off(LIBCWD_TSD); - _private_::debug_channels.internal_init(LIBCWD_TSD); - set_alloc_checking_on(LIBCWD_TSD); + _private_::debug_channels.init(LIBCWD_TSD); DEBUG_CHANNELS_ACQUIRE_READ_LOCK for(_private_::debug_channels_ct::container_type::const_iterator i(_private_::debug_channels.read_locked().begin()); i != _private_::debug_channels.read_locked().end(); ++i) @@ -1087,9 +1091,9 @@ if (LIBCWD_DO_TSD_MEMBER(debug_object, _off) < 0) { LIBCWD_DEFER_CANCEL - set_alloc_checking_off(LIBCWD_TSD); - _private_::debug_channels.internal_init(LIBCWD_TSD); - set_alloc_checking_on(LIBCWD_TSD); + _private_::debug_channels.init(LIBCWD_TSD); + LIBCWD_RESTORE_CANCEL + LIBCWD_DEFER_CLEANUP_PUSH(&rwlock_tct<debug_channels_instance>::cleanup, NULL) DEBUG_CHANNELS_ACQUIRE_READ_LOCK for(_private_::debug_channels_ct::container_type::const_iterator i(_private_::debug_channels.read_locked().begin()); i != _private_::debug_channels.read_locked().end(); ++i) @@ -1102,8 +1106,8 @@ LibcwDoutStream.write(": Disabled", 10); LibcwDoutScopeEnd; } - DEBUG_CHANNELS_RELEASE_READ_LOCK - LIBCWD_RESTORE_CANCEL + DEBUG_CHANNELS_RELEASE_READ_LOCK + LIBCWD_CLEANUP_POP_RESTORE(false) } } @@ -1167,19 +1171,19 @@ // dependent on the order in which these global objects are // initialized. LIBCWD_DEFER_CANCEL - set_alloc_checking_off(LIBCWD_TSD); // debug_channels is internal. - _private_::debug_channels.internal_init(LIBCWD_TSD); + _private_::debug_channels.init(LIBCWD_TSD); DEBUG_CHANNELS_ACQUIRE_WRITE_LOCK { + set_alloc_checking_off(LIBCWD_TSD); // debug_channels is internal. _private_::debug_channels_ct::container_type& channels(_private_::debug_channels.write_locked()); _private_::debug_channels_ct::container_type::iterator i(channels.begin()); for(; i != channels.end(); ++i) if (strncmp((*i)->get_label(), WNS_label, max_label_len_c) > 0) break; channels.insert(i, this); + set_alloc_checking_on(LIBCWD_TSD); } DEBUG_CHANNELS_RELEASE_WRITE_LOCK - set_alloc_checking_on(LIBCWD_TSD); LIBCWD_RESTORE_CANCEL // Turn debug channel "WARNING" on by default. @@ -1378,6 +1382,9 @@ core_dump(); } __libcwd_tsd.recursive_assert = true; +#ifdef DEBUGDEBUGTHREADS + __libcwd_tsd.internal_debugging_code = true; +#endif #endif DoutFatal(dc::core, file << ':' << line << ": " << function << ": Assertion `" << expr << "' failed.\n"); } Index: src/libcwd/debugmalloc.cc diff -u src/libcwd/debugmalloc.cc:1.77 src/libcwd/debugmalloc.cc:1.78 --- src/libcwd/debugmalloc.cc:1.77 Wed Jan 30 20:42:08 2002 +++ src/libcwd/debugmalloc.cc Sat Feb 2 20:15:11 2002 @@ -1,4 +1,4 @@ -// $Header: /cvsroot/l/li/libcw/src/libcwd/debugmalloc.cc,v 1.77 2002/01/31 04:42:08 libcw Exp $ +// $Header: /cvsroot/l/li/libcw/src/libcwd/debugmalloc.cc,v 1.78 2002/02/03 04:15:11 libcw Exp $ // // Copyright (C) 2000 - 2001, by // @@ -1660,13 +1660,13 @@ __libcwd_tsd.internal = 0; } - LIBCWD_DEFER_CANCEL + LIBCWD_DEFER_CLEANUP_PUSH(&rwlock_tct<memblk_map_instance>::cleanup, NULL); ACQUIRE_READ_LOCK LibcwDout( channels, debug_object, dc_malloc, "Allocated memory: " << const_dm_alloc_ct::get_memsize() << " bytes in " << const_dm_alloc_ct::get_memblks() << " blocks." ); if (base_alloc_list) const_cast<dm_alloc_ct const*>(base_alloc_list)->show_alloc_list(1, channels::dc_malloc); RELEASE_READ_LOCK - LIBCWD_RESTORE_CANCEL + LIBCWD_CLEANUP_POP_RESTORE(false); } //============================================================================= Index: src/libcwd/elf32.cc diff -u src/libcwd/elf32.cc:1.35 src/libcwd/elf32.cc:1.36 --- src/libcwd/elf32.cc:1.35 Fri Feb 1 07:48:21 2002 +++ src/libcwd/elf32.cc Sat Feb 2 20:15:11 2002 @@ -1,4 +1,4 @@ -// $Header: /cvsroot/l/li/libcw/src/libcwd/elf32.cc,v 1.35 2002/02/01 15:48:21 libcw Exp $ +// $Header: /cvsroot/l/li/libcw/src/libcwd/elf32.cc,v 1.36 2002/02/03 04:15:11 libcw Exp $ // // Copyright (C) 2001, by // @@ -1928,8 +1928,10 @@ char* object_file_ct::allocate_and_read_section(int i) { char* p = new char[M_sections[i].section_header().sh_size]; + LIBCWD_DISABLE_CANCEL M_input_stream.rdbuf()->pubseekpos(M_sections[i].section_header().sh_offset); M_input_stream.read(p, M_sections[i].section_header().sh_size); + LIBCWD_ENABLE_CANCEL return p; } Index: src/libcwd/include/libcw/macro_ForAllDebugChannels.h diff -u src/libcwd/include/libcw/macro_ForAllDebugChannels.h:1.4 src/libcwd/include/libcw/macro_ForAllDebugChannels.h:1.5 --- src/libcwd/include/libcw/macro_ForAllDebugChannels.h:1.4 Wed Jan 30 20:42:08 2002 +++ src/libcwd/include/libcw/macro_ForAllDebugChannels.h Sat Feb 2 20:15:11 2002 @@ -1,4 +1,4 @@ -// $Header: /cvsroot/l/li/libcw/src/libcwd/include/libcw/macro_ForAllDebugChannels.h,v 1.4 2002/01/31 04:42:08 libcw Exp $ +// $Header: /cvsroot/l/li/libcw/src/libcwd/include/libcw/macro_ForAllDebugChannels.h,v 1.5 2002/02/03 04:15:11 libcw Exp $ // // Copyright (C) 2000 - 2001, by // @@ -44,7 +44,7 @@ typedef internal_vector<channel_ct*> container_type; container_type* WNS_debug_channels; public: - void internal_init(LIBCWD_TSD_PARAM); + void init(LIBCWD_TSD_PARAM); #ifdef LIBCWD_THREAD_SAFE void init_and_rdlock(void); #endif Index: src/libcwd/include/libcw/macro_ForAllDebugObjects.h diff -u src/libcwd/include/libcw/macro_ForAllDebugObjects.h:1.4 src/libcwd/include/libcw/macro_ForAllDebugObjects.h:1.5 --- src/libcwd/include/libcw/macro_ForAllDebugObjects.h:1.4 Wed Jan 30 20:42:08 2002 +++ src/libcwd/include/libcw/macro_ForAllDebugObjects.h Sat Feb 2 20:15:11 2002 @@ -1,4 +1,4 @@ -// $Header: /cvsroot/l/li/libcw/src/libcwd/include/libcw/macro_ForAllDebugObjects.h,v 1.4 2002/01/31 04:42:08 libcw Exp $ +// $Header: /cvsroot/l/li/libcw/src/libcwd/include/libcw/macro_ForAllDebugObjects.h,v 1.5 2002/02/03 04:15:11 libcw Exp $ // // Copyright (C) 2000 - 2001, by // @@ -46,7 +46,7 @@ private: container_type* WNS_debug_objects; public: - void internal_init(LIBCWD_TSD_PARAM); + void init(LIBCWD_TSD_PARAM); #ifdef LIBCWD_THREAD_SAFE void init_and_rdlock(void); #endif Index: src/libcwd/include/libcw/private_struct_TSD.h diff -u src/libcwd/include/libcw/private_struct_TSD.h:1.3 src/libcwd/include/libcw/private_struct_TSD.h:1.4 --- src/libcwd/include/libcw/private_struct_TSD.h:1.3 Thu Jan 31 21:21:05 2002 +++ src/libcwd/include/libcw/private_struct_TSD.h Sat Feb 2 20:15:11 2002 @@ -1,4 +1,4 @@ -// $Header: /cvsroot/l/li/libcw/src/libcwd/include/libcw/private_struct_TSD.h,v 1.3 2002/02/01 05:21:05 libcw Exp $ +// $Header: /cvsroot/l/li/libcw/src/libcwd/include/libcw/private_struct_TSD.h,v 1.4 2002/02/03 04:15:11 libcw Exp $ // // Copyright (C) 2001, by // @@ -84,6 +84,9 @@ #ifdef DEBUGDEBUGTHREADS int cancel_explicitely_deferred; int cancel_explicitely_disabled; + int inside_critical_area; + int cleanup_handler_installed; + int internal_debugging_code; #endif #endif int off_cnt_array[256]; Index: src/libcwd/include/libcw/private_threading.h diff -u src/libcwd/include/libcw/private_threading.h:1.17 src/libcwd/include/libcw/private_threading.h:1.18 --- src/libcwd/include/libcw/private_threading.h:1.17 Thu Jan 31 21:21:05 2002 +++ src/libcwd/include/libcw/private_threading.h Sat Feb 2 20:15:12 2002 @@ -1,4 +1,4 @@ -// $Header: /cvsroot/l/li/libcw/src/libcwd/include/libcw/private_threading.h,v 1.17 2002/02/01 05:21:05 libcw Exp $ +// $Header: /cvsroot/l/li/libcw/src/libcwd/include/libcw/private_threading.h,v 1.18 2002/02/03 04:15:12 libcw Exp $ // // Copyright (C) 2001 - 2002, by // @@ -35,10 +35,6 @@ #ifndef LIBCW_PRIVATE_STRUCT_TSD_H #include <libcw/private_struct_TSD.h> #endif -#ifndef LIBCW_CASSERT -#define LIBCW_CASSERT -#include <cassert> -#endif #ifndef LIBCW_CSTRING #define LIBCW_CSTRING #include <cstring> // Needed for std::memset and std::memcpy. @@ -56,7 +52,6 @@ #ifndef LIBCWD_USE_LINUXTHREADS #define LIBCWD_USE_LINUXTHREADS 0 -#undef HAVE__PTHREAD_CLEANUP_BUFFER #endif #ifndef LIBCWD_USE_POSIX_THREADS #define LIBCWD_USE_POSIX_THREADS 0 @@ -68,10 +63,9 @@ #define LibcwDebugThreads(x) #endif -#ifdef DEBUGDEBUGTHREADS -#ifndef LIBCW_CASSERT -#define LIBCW_CASSERT -#include <cassert> +#if defined(DEBUGDEBUGTHREADS) || defined(DEBUGDEBUG) +#ifndef LIBCW_PRIVATE_ASSERT_H +#include <libcw/private_assert.h> #endif #endif @@ -203,13 +197,12 @@ LibcwDebugThreads(\ { \ LIBCWD_TSD_DECLARATION; \ - if (--__libcwd_tsd.cancel_explicitely_disabled < 0) \ - ::libcw::debug::core_dump(); \ + LIBCWD_ASSERT( __libcwd_tsd.cancel_explicitely_disabled > 0 ); \ + --__libcwd_tsd.cancel_explicitely_disabled; \ /* pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL) can call */ \ /* __pthread_do_exit() when the thread is cancelled in the meantime. */ \ /* This might free allocations that are allocated in userspace. */ \ - if (__libcwd_tsd.internal) \ - ::libcw::debug::core_dump(); \ + LIBCWD_ASSERT( !__libcwd_tsd.internal || __libcwd_tsd.cancel_explicitely_disabled || __libcwd_tsd.cancel_explicitely_deferred ); \ } ) \ pthread_setcancelstate(__libcwd_oldstate, NULL); #define LIBCWD_ENABLE_CANCEL \ @@ -231,13 +224,12 @@ LibcwDebugThreads(\ { \ LIBCWD_TSD_DECLARATION; \ - if (--__libcwd_tsd.cancel_explicitely_deferred < 0) \ - ::libcw::debug::core_dump(); \ + LIBCWD_ASSERT( __libcwd_tsd.cancel_explicitely_deferred > 0 ); \ + --__libcwd_tsd.cancel_explicitely_deferred; \ /* pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL) will calls */ \ /* __pthread_do_exit() when the thread is cancelled in the meantime. */ \ /* This might free allocations that are allocated in userspace. */ \ - if (__libcwd_tsd.internal) \ - ::libcw::debug::core_dump(); \ + LIBCWD_ASSERT( !__libcwd_tsd.internal || __libcwd_tsd.cancel_explicitely_disabled || __libcwd_tsd.cancel_explicitely_deferred ); \ } ) \ pthread_setcanceltype(__libcwd_oldtype, NULL); #define LIBCWD_RESTORE_CANCEL \ @@ -251,22 +243,33 @@ { \ LIBCWD_TSD_DECLARATION; \ ++__libcwd_tsd.cancel_explicitely_deferred; \ + ++__libcwd_tsd.cleanup_handler_installed; \ } ) #define LIBCWD_CLEANUP_POP_RESTORE(execute) \ LibcwDebugThreads(\ { \ LIBCWD_TSD_DECLARATION; \ - if (--__libcwd_tsd.cancel_explicitely_deferred < 0) \ - ::libcw::debug::core_dump(); \ - if (__libcwd_tsd.internal) \ - ::libcw::debug::core_dump(); \ + --__libcwd_tsd.cleanup_handler_installed; \ + LIBCWD_ASSERT( __libcwd_tsd.cancel_explicitely_deferred > 0 ); \ + --__libcwd_tsd.cancel_explicitely_deferred; \ + LIBCWD_ASSERT( !__libcwd_tsd.internal ); \ } ) \ pthread_cleanup_pop_restore_np(static_cast<int>(execute)) #else // !LIBCWD_USE_LINUXTHREADS #define LIBCWD_DEFER_CLEANUP_PUSH(routine, arg) \ LIBCWD_DEFER_CANCEL \ + LibcwDebugThreads( \ + { \ + LIBCWD_TSD_DECLARATION; \ + ++__libcwd_tsd.cleanup_handler_installed; \ + } ) \ pthread_cleanup_push(reinterpret_cast<void(*)(void*)>(routine), reinterpret_cast<void*>(arg)) #define LIBCWD_CLEANUP_POP_RESTORE(execute) \ + LibcwDebugThreads( \ + { \ + LIBCWD_TSD_DECLARATION; \ + --__libcwd_tsd.cleanup_handler_installed; \ + } ) \ pthread_cleanup_pop(static_cast<int>(execute)); \ LIBCWD_RESTORE_CANCEL #endif // !LIBCWD_USE_LINUXTHREADS @@ -289,8 +292,7 @@ /* When entering a critical area, make sure that we have explictely deferred cancellation of this */ \ /* thread (or disabled that) because when cancellation would happen in the middle of the critical */ \ /* area then the lock would stay locked. */ \ - if (!__libcwd_tsd.cancel_explicitely_deferred && !__libcwd_tsd.cancel_explicitely_disabled) \ - ::libcw::debug::core_dump(); \ + LIBCWD_ASSERT( __libcwd_tsd.cancel_explicitely_deferred || __libcwd_tsd.cancel_explicitely_disabled ); \ } ) template <int instance> @@ -317,19 +319,21 @@ public: static bool trylock(void) throw() { - LibcwDebugThreads( assert( S_initialized ) ); + LibcwDebugThreads( LIBCWD_ASSERT( S_initialized ) ); LIBCWD_DEBUGDEBUG_ASSERT_CANCEL_DEFERRED bool success = (pthread_mutex_trylock(&S_mutex) == 0); #ifdef DEBUGDEBUG if (success) instance_locked[instance] += 1; #endif + LibcwDebugThreads( if (success) { LIBCWD_TSD_DECLARATION; ++__libcwd_tsd.inside_critical_area; } ); return success; } static void lock(void) throw() { - LibcwDebugThreads( assert( S_initialized ) ); + LibcwDebugThreads( LIBCWD_ASSERT( S_initialized ) ); LIBCWD_DEBUGDEBUG_ASSERT_CANCEL_DEFERRED + LibcwDebugThreads( if (instance != tsd_initialization_instance) { LIBCWD_TSD_DECLARATION ++__libcwd_tsd.inside_critical_area; } ); #if LIBCWD_DEBUGDEBUGRWLOCK if (instance != tsd_initialization_instance) LIBCWD_DEBUGDEBUGRWLOCK_CERR(pthread_self() << ": locking mutex " << instance); #endif @@ -337,9 +341,7 @@ int res = #endif pthread_mutex_lock(&S_mutex); -#ifdef DEBUGDEBUGTHREADS - assert( res == 0 ); -#endif + LibcwDebugThreads( LIBCWD_ASSERT( res == 0 ) ); #if LIBCWD_DEBUGDEBUGRWLOCK if (instance != tsd_initialization_instance) LIBCWD_DEBUGDEBUGRWLOCK_CERR(pthread_self() << ": mutex " << instance << " locked"); #endif @@ -360,6 +362,7 @@ #if LIBCWD_DEBUGDEBUGRWLOCK if (instance != tsd_initialization_instance) LIBCWD_DEBUGDEBUGRWLOCK_CERR(pthread_self() << ": mutex " << instance << " unlocked"); #endif + LibcwDebugThreads( if (instance != tsd_initialization_instance) { LIBCWD_TSD_DECLARATION --__libcwd_tsd.inside_critical_area; } ); } }; @@ -454,7 +457,7 @@ public: void wait(void) { #ifdef DEBUGDEBUG - assert( is_locked(instance) ); + LIBCWD_ASSERT( is_locked(instance) ); #endif pthread_cond_wait(&S_condition, &S_mutex); } @@ -545,7 +548,7 @@ } static bool tryrdlock(void) throw() { - LibcwDebugThreads( assert( S_initialized ) ); + LibcwDebugThreads( LIBCWD_ASSERT( S_initialized ) ); LIBCWD_DEBUGDEBUG_ASSERT_CANCEL_DEFERRED LIBCWD_DEBUGDEBUGRWLOCK_CERR(pthread_self() << ": Calling rwlock_tct<" << instance << ">::tryrdlock()"); if (instance < end_recursive_types && pthread_equal(S_writer_id, pthread_self())) @@ -560,12 +563,13 @@ if (success) ++S_holders_count; // Add one reader. S_no_holders_condition.unlock(); + LibcwDebugThreads( if (success) { LIBCWD_TSD_DECLARATION; ++__libcwd_tsd.inside_critical_area; } ); LIBCWD_DEBUGDEBUGRWLOCK_CERR(pthread_self() << ": Leaving rwlock_tct<" << instance << ">::tryrdlock()"); return success; } static bool trywrlock(void) throw() { - LibcwDebugThreads( assert( S_initialized ) ); + LibcwDebugThreads( LIBCWD_ASSERT( S_initialized ) ); LIBCWD_DEBUGDEBUG_ASSERT_CANCEL_DEFERRED LIBCWD_DEBUGDEBUGRWLOCK_CERR(pthread_self() << ": Calling rwlock_tct<" << instance << ">::trywrlock()"); bool success = mutex_tct<readers_instance>::trylock(); // Block new readers, @@ -588,12 +592,13 @@ if (instance < end_recursive_types) S_writer_id = pthread_self(); } + LibcwDebugThreads( if (success) { LIBCWD_TSD_DECLARATION; ++__libcwd_tsd.inside_critical_area; } ); LIBCWD_DEBUGDEBUGRWLOCK_CERR(pthread_self() << ": Leaving rwlock_tct<" << instance << ">::trywrlock()"); return success; } static void rdlock(void) throw() { - LibcwDebugThreads( assert( S_initialized ) ); + LibcwDebugThreads( LIBCWD_ASSERT( S_initialized ) ); LIBCWD_DEBUGDEBUG_ASSERT_CANCEL_DEFERRED LIBCWD_DEBUGDEBUGRWLOCK_CERR(pthread_self() << ": Calling rwlock_tct<" << instance << ">::rdlock()"); if (instance < end_recursive_types && pthread_equal(S_writer_id, pthread_self())) @@ -612,6 +617,7 @@ S_no_holders_condition.wait(); // Wait for writer to finish. ++S_holders_count; // Add one reader. S_no_holders_condition.unlock(); + LibcwDebugThreads( LIBCWD_TSD_DECLARATION; ++__libcwd_tsd.inside_critical_area ); LIBCWD_DEBUGDEBUGRWLOCK_CERR(pthread_self() << ": Leaving rwlock_tct<" << instance << ">::rdlock()"); } static void rdunlock(void) throw() @@ -623,6 +629,7 @@ LIBCWD_DEBUGDEBUGRWLOCK_CERR(pthread_self() << ": Leaving rwlock_tct<" << instance << ">::rdunlock() (skipped: thread has write lock)"); return; // No error checking is done. } + LibcwDebugThreads( LIBCWD_TSD_DECLARATION; --__libcwd_tsd.inside_critical_area ); S_no_holders_condition.lock(); if (--S_holders_count == 0) // Was this the last reader? S_no_holders_condition.signal(); // Tell waiting threads. @@ -631,7 +638,7 @@ } static void wrlock(void) throw() { - LibcwDebugThreads( assert( S_initialized ) ); + LibcwDebugThreads( LIBCWD_ASSERT( S_initialized ) ); LIBCWD_DEBUGDEBUG_ASSERT_CANCEL_DEFERRED LIBCWD_DEBUGDEBUGRWLOCK_CERR(pthread_self() << ": Calling rwlock_tct<" << instance << ">::wrlock()"); mutex_tct<readers_instance>::lock(); // Block new readers, @@ -645,6 +652,7 @@ S_no_holders_condition.unlock(); if (instance < end_recursive_types) S_writer_id = pthread_self(); + LibcwDebugThreads( LIBCWD_TSD_DECLARATION; ++__libcwd_tsd.inside_critical_area ); LIBCWD_DEBUGDEBUGRWLOCK_CERR(pthread_self() << ": Leaving rwlock_tct<" << instance << ">::wrlock()"); #ifdef DEBUGDEBUG instance_locked[instance] += 1; @@ -657,6 +665,7 @@ instance_locked[instance] -= 1; #endif LIBCWD_DEBUGDEBUGRWLOCK_CERR(pthread_self() << ": Calling rwlock_tct<" << instance << ">::wrunlock()"); + LibcwDebugThreads( LIBCWD_TSD_DECLARATION; --__libcwd_tsd.inside_critical_area) ; if (instance < end_recursive_types) S_writer_id = 0; S_no_holders_condition.lock(); @@ -756,10 +765,8 @@ LIBCWD_TSD_DECLARATION set_alloc_checking_off(LIBCWD_TSD); delete instance; -#ifdef DEBUGDEBUGTHREADS // Hopefully S_destroy doesn't get called in the thread itself! - assert( instance != &thread_specific_data_tct<TSD>::instance() ); -#endif + LibcwDebugThreads( LIBCWD_ASSERT( instance != &thread_specific_data_tct<TSD>::instance() ) ); set_alloc_checking_on(LIBCWD_TSD); } @@ -815,10 +822,27 @@ // End of Thread Specific Data //=================================================================================================== +extern void fatal_cancellation(void*) throw(); + } // namespace _private_ } // namespace debug } // namespace libcw +#else // !LIBCWD_THREAD_SAFE +#define LIBCWD_DISABLE_CANCEL +#define LIBCWD_DISABLE_CANCEL_NO_BRACE +#define LIBCWD_ENABLE_CANCEL_NO_BRACE +#define LIBCWD_ENABLE_CANCEL +#define LIBCWD_DEFER_CANCEL +#define LIBCWD_DEFER_CANCEL_NO_BRACE +#define LIBCWD_RESTORE_CANCEL_NO_BRACE +#define LIBCWD_RESTORE_CANCEL +#define LIBCWD_DEFER_CLEANUP_PUSH(routine, arg) +#define LIBCWD_CLEANUP_POP_RESTORE(execute) +#define LIBCWD_PUSH_DEFER_TRYLOCK_MUTEX(instance, unlock_routine) +#define LIBCWD_DEFER_PUSH_LOCKMUTEX(instance, unlock_routine) +#define LIBCWD_UNLOCKMUTEX_POP_RESTORE(instance) +#define LIBCWD_DEBUGDEBUG_ASSERT_CANCEL_DEFERRED #endif // LIBCWD_THREAD_SAFE #endif // LIBCW_PRIVATE_THREADING_H Index: src/libcwd/include/raw_write.h diff -u src/libcwd/include/raw_write.h:1.2 src/libcwd/include/raw_write.h:1.3 --- src/libcwd/include/raw_write.h:1.2 Wed Jan 30 20:42:08 2002 +++ src/libcwd/include/raw_write.h Sat Feb 2 20:15:11 2002 @@ -1,5 +1,5 @@ // Generated automatically from sys.ho.in by configure. -// $Header: /cvsroot/l/li/libcw/src/libcwd/include/raw_write.h,v 1.2 2002/01/31 04:42:08 libcw Exp $ +// $Header: /cvsroot/l/li/libcw/src/libcwd/include/raw_write.h,v 1.3 2002/02/03 04:15:11 libcw Exp $ // // Copyright (C) 2001, by // @@ -22,6 +22,11 @@ #include <libcw/debug_config.h> #ifdef DEBUGDEBUG +#ifdef DEBUGDEBUGTHREADS +#define WRITE __libc_write +#else +#define WRITE write +#endif extern "C" ssize_t write(int fd, const void *buf, size_t count) throw(); #ifdef LIBCWD_THREAD_SAFE @@ -39,12 +44,14 @@ do { \ if (1/*::libcw::debug::_private_::WST_ios_base_initialized FIXME: uncomment again*/) { \ LIBCWD_CANCELSTATE_DISABLE \ - ::write(2, "DEBUGDEBUG: ", 12); \ LIBCWD_TSD_DECLARATION \ + LibcwDebugThreads( ++__libcwd_tsd.internal_debugging_code ); \ + ::write(2, "DEBUGDEBUG: ", 12); \ /* __libcwd_lcwc means library_call write counter. Used to avoid the 'scope of for changed' warning. */ \ for (int __libcwd_lcwc = 0; __libcwd_lcwc < __libcwd_tsd.library_call; ++__libcwd_lcwc) \ ::write(2, " ", 4); \ ::libcw::debug::_private_::raw_write << x << '\n'; \ + LibcwDebugThreads( --__libcwd_tsd.internal_debugging_code ); \ LIBCWD_CANCELSTATE_RESTORE \ } \ } while(0) Index: src/libcwd/threading.cc diff -u src/libcwd/threading.cc:1.4 src/libcwd/threading.cc:1.5 --- src/libcwd/threading.cc:1.4 Thu Jan 31 21:21:05 2002 +++ src/libcwd/threading.cc Sat Feb 2 20:15:11 2002 @@ -1,4 +1,4 @@ -// $Header: /cvsroot/l/li/libcw/src/libcwd/threading.cc,v 1.4 2002/02/01 05:21:05 libcw Exp $ +// $Header: /cvsroot/l/li/libcw/src/libcwd/threading.cc,v 1.5 2002/02/03 04:15:11 libcw Exp $ // // Copyright (C) 2001, by // @@ -14,6 +14,7 @@ // #include "sys.h" +#include "cwd_debug.h" #include <libcw/private_threading.h> namespace libcw { @@ -53,6 +54,12 @@ #else // !LIBCWD_THREAD_SAFE TSD_st __libcwd_tsd; #endif // !LIBCWD_THREAD_SAFE + +void fatal_cancellation(void* arg) throw() +{ + char* text = static_cast<char*>(arg); + Dout(dc::core, "Cancelling a thread " << text << ". This is not supported by libcwd, sorry."); +} } // namespace _private_ } // namespace debug ----------------------- End of diff ----------------------- |
From: Carlo W. <li...@us...> - 2002-02-01 15:48:33
|
CVSROOT : /cvsroot/libcw Module : src Commit time: 2002-01-01 15:48:32 UTC Modified files: libcwd/elf32.cc Log message: Bug fix: the .debug_line section can be completely empty. ---------------------- diff included ---------------------- Index: src/libcwd/elf32.cc diff -u src/libcwd/elf32.cc:1.34 src/libcwd/elf32.cc:1.35 --- src/libcwd/elf32.cc:1.34 Wed Jan 30 20:42:08 2002 +++ src/libcwd/elf32.cc Fri Feb 1 07:48:21 2002 @@ -1,4 +1,4 @@ -// $Header: /cvsroot/l/li/libcw/src/libcwd/elf32.cc,v 1.34 2002/01/31 04:42:08 libcw Exp $ +// $Header: /cvsroot/l/li/libcw/src/libcwd/elf32.cc,v 1.35 2002/02/01 15:48:21 libcw Exp $ // // Copyright (C) 2001, by // @@ -1490,7 +1490,7 @@ // doing DWARF in find_nearest_line(). location.set_func_iter(M_function_names.insert(cur_func).first); - do + while( debug_line_ptr < debug_line_ptr_end ) { file = 0; // One less than the `file' mentioned in the documentation. column = 0; @@ -1655,7 +1655,6 @@ } } } - while( debug_line_ptr < debug_line_ptr_end ); LIBCWD_ASSERT( debug_line_ptr == debug_line_ptr_end ); // End state machine code. @@ -1885,7 +1884,6 @@ } M_inside_find_nearest_line = true; #if DEBUGSTABS || DEBUGDWARF - int off = libcw::debug::libcw_do._off; libcw::debug::debug_ct::OnOffState state; Debug( libcw_do.force_on(state) ); libcw::debug::channel_ct::OnOffState state2; ----------------------- End of diff ----------------------- |