|
From: Carlo W. <li...@us...> - 2002-02-21 02:05:46
|
CVSROOT : /cvsroot/libcw
Module : src
Commit time: 2002-01-21 02:05:42 UTC
Modified files:
libcwd/NEWS libcwd/bfd.cc libcwd/configure.in libcwd/debug.cc
libcwd/debugmalloc.cc libcwd/demangle3.cc libcwd/elf32.cc
libcwd/threading.cc libcwd/wrapcnclpnts.cc
libcwd/documentation/allocated_memory_overview.dox
libcwd/documentation/magic.dox
libcwd/documentation/memory_leak_checking.dox
libcwd/documentation/doxygen-examples/markers.cc
libcwd/documentation/tutorial/tut6.m4
libcwd/documentation/tutorial/tut7.in
libcwd/include/private_debug_stack.inl libcwd/include/raw_write.h
libcwd/include/raw_write.inl libcwd/include/libcw/class_alloc.h
libcwd/include/libcw/class_channel_set.h
libcwd/include/libcw/class_debug.h
libcwd/include/libcw/class_debug.inl
libcwd/include/libcw/class_location.inl
libcwd/include/libcw/debug.h
libcwd/include/libcw/debug_config.ho.in
libcwd/include/libcw/debugmalloc.h
libcwd/include/libcw/enum_memblk_types.h
libcwd/include/libcw/macro_AllocTag.h
libcwd/include/libcw/macro_ForAllDebugChannels.h
libcwd/include/libcw/macro_ForAllDebugObjects.h
libcwd/include/libcw/macro_Libcwd_macros.h
libcwd/include/libcw/private_allocator.h
libcwd/include/libcw/private_set_alloc_checking.h
libcwd/include/libcw/private_struct_TSD.h
libcwd/include/libcw/private_threading.h
libcwd/include/libcw/struct_debug_tsd.h libcwd/tests/allocator.cc
libcwd/tests/dout_alloc.cc libcwd/tests/hello_world.cc
libcwd/tests/syslog.cc libcwd/tests/threads.cc
libcwd/tests/threads3.cc libcwd/tests/threads4.cc
libcwd/testsuite/libcwd.nodebug/nodebug.cc
libcwd/testsuite/libcwd.tst/alloctag.cc
libcwd/testsuite/libcwd.tst/bfd.cc
libcwd/testsuite/libcwd.tst/continued.cc
libcwd/testsuite/libcwd.tst/dc.cc
libcwd/testsuite/libcwd.tst/dlopen.cc
libcwd/testsuite/libcwd.tst/do.cc
libcwd/testsuite/libcwd.tst/flush.cc
libcwd/testsuite/libcwd.tst/leak.cc
libcwd/testsuite/libcwd.tst/lockable_auto_ptr.cc
libcwd/testsuite/libcwd.tst/magic.cc
libcwd/testsuite/libcwd.tst/marker.cc
libcwd/testsuite/libcwd.tst/test_delete.cc
libcwd/utils/exec_prog.cc
Removed files:
libcwd/example-project/macrotest.cc
Log message:
Renamed all configuration macros and defined them to 0 or 1.
---------------------- diff included ----------------------
Index: src/libcwd/NEWS
diff -u src/libcwd/NEWS:1.74 src/libcwd/NEWS:1.75
--- src/libcwd/NEWS:1.74 Tue Feb 19 19:55:51 2002
+++ src/libcwd/NEWS Wed Feb 20 18:05:30 2002
@@ -1,5 +1,70 @@
libcwd-0.99.18
+ API changes:
+
+ All macros related to the configure options used have been
+ renamed and are no longer either defined or undefined, but
+ rather defined to 1 or 0 respectively. The advantage of
+ that is that it allows the compiler to warn you when you
+ made a typo in a macro name.
+ This means that you will have to use #if macro_name
+ instead of #ifdef macro_name of course.
+ The names have changed as follows:
+ Locations:
+ DEBUGUSEBFD --> CWDEBUG_LOCATION
+ Memory allocation debugging:
+ DEBUGMALLOC --> CWDEBUG_ALLOC
+ DEBUGMAGICMALLOC --> CWDEBUG_MAGIC
+ DEBUGMARKER --> CWDEBUG_MARKER
+ Debugging libcwd itself:
+ DEBUGDEBUG --> CWDEBUG_DEBUG
+ DEBUGDEBUGOUTPUT --> CWDEBUG_DEBUGOUTPUT
+ DEBUGDEBUGMALLOC --> CWDEBUG_DEBUGM
+ DEBUGDEBUGTHREADS --> CWDEBUG_DEBUGT
+ The rationaly is that for a configure option
+ --enable-libcwd-xxx, the macro name is now CWDEBUG_XXX.
+ You are advised to automate the replacements of the
+ macros (use find and grep and reg.exp replaces);
+ The following substitutions are suggested (only
+ given for one of the macros):
+ :%s/defined(DEBUGDEBUG)/CWDEBUG_DEBUG/g
+ :%s/#ifdef DEBUGDEBUG /#if CWDEBUG_DEBUG /
+ :%s/#ifdef DEBUGDEBUG$/#if CWDEBUG_DEBUG/
+ :%s/#ifndef DEBUGDEBUG /#if !CWDEBUG_DEBUG /
+ :%s/#ifndef DEBUGDEBUG$/#if !CWDEBUG_DEBUG /
+ :%s%// DEBUGDEBUG$%// CWDEBUG_DEBUG%
+ :%s%// !DEBUGDEBUG$%// !CWDEBUG_DEBUG%
+ After that you still have to check if other instances
+ are left.
+
+ MACRO OVERVIEW:
+ Most macros now either start with LIBCWD_, LIBCW_, CWDEBUG_
+ or Libcw. The macros that start with LIBCW should not
+ be used. The macros that start with CWDEBUG_ are either
+ 0 or 1 and should be used as #if CWDEBUG_XXX ...
+ CWDEBUG itself is still defined or undefined and should
+ be used as #ifdef CWDEBUG ...
+ The macros that start with Libcw are the more general
+ cases of Dout, DoutFatal and Debug (they are LibcwDebug,
+ LibcwDebugThreads, LibcwDout, LibcwDoutFatal, LibcwDoutFatalScopeBegin,
+ LibcwDoutFatalScopeEnd, LibcwDoutFatalStream, LibcwDoutScopeBegin,
+ LibcwDoutScopeEnd and LibcwDoutStream). You are allowed to
+ use those to customize things.
+ The macros that do not start with one of those four prefixes
+ are part of the libcwd API (and should also be defined in
+ your custom debug.h):
+ Debug, Dout, DoutFatal
+ : see documentation/html/debug_8h.html
+ DEBUGCHANNELS : see documentation/html/group__chapter__custom__debug__h.html
+ ForAllDebugChannels and ForAllDebugObjects
+ : see documentation/html/group__group__special.html
+ AllocTag, AllocTag1, AllocTag2, AllocTag_dynamic_description and NEW
+ : see documentation/html/group__group__annotation.html
+ When you don't have __libc_malloc (glibc *does* have that):
+ malloc, calloc, realloc, free, strdup, wcsdup and RegisterExternalAlloc.
+ These are always defined because there is no accessible __libc_dlopen :/.
+ dlclose, dlopen : In order to catch those when used.
+
libcwd-0.99.17
A tutorial on debugging threaded applications was added.
Index: src/libcwd/bfd.cc
diff -u src/libcwd/bfd.cc:1.105 src/libcwd/bfd.cc:1.106
--- src/libcwd/bfd.cc:1.105 Tue Feb 19 19:55:51 2002
+++ src/libcwd/bfd.cc Wed Feb 20 18:05:30 2002
@@ -1,4 +1,4 @@
-// $Header: /cvsroot/l/li/libcw/src/libcwd/bfd.cc,v 1.105 2002/02/20 03:55:51 libcw Exp $
+// $Header: /cvsroot/l/li/libcw/src/libcwd/bfd.cc,v 1.106 2002/02/21 02:05:30 libcw Exp $
//
// Copyright (C) 2000 - 2002, by
//
@@ -11,10 +11,10 @@
// packaging of this file.
//
-#undef DEBUGDEBUGBFD // Define to add debug code for this file.
+#undef LIBCWD_DEBUGBFD // Define to add debug code for this file.
#include <libcw/debug_config.h>
-#ifdef DEBUGUSEBFD
+#if CWDEBUG_LOCATION
#include "sys.h"
#include <unistd.h>
@@ -44,7 +44,7 @@
#endif
#include <cstdio> // Needed for vsnprintf.
#include <algorithm>
-#ifdef DEBUGDEBUGBFD
+#ifdef LIBCWD_DEBUGBFD
#include <iomanip>
#endif
#include "cwd_debug.h"
@@ -54,16 +54,16 @@
#undef dlclose
#endif
#include "exec_prog.h"
-#ifdef DEBUGUSEGNULIBBFD
+#if CWDEBUG_LIBBFD
#if defined(BFD64) && !BFD_HOST_64BIT_LONG && defined(__GLIBCPP__) && !defined(_GLIBCPP_USE_LONG_LONG)
// libbfd is compiled with 64bit support on a 32bit host, but libstdc++ is not compiled with support
// for `long long'. If you run into this error (and you insist on use libbfd) then either recompile
// libstdc++ with support for `long long' or recompile libbfd without 64bit support.
#error "Incompatible libbfd and libstdc++ (see comments in source code)."
#endif
-#else // !DEBUGUSEGNULIBBFD
+#else // !CWDEBUG_LIBBFD
#include "elf32.h"
-#endif // !DEBUGUSEGNULIBBFD
+#endif // !CWDEBUG_LIBBFD
#ifdef LIBCWD_THREAD_SAFE
using libcw::debug::_private_::rwlock_tct;
@@ -121,7 +121,7 @@
// Local stuff
namespace cwbfd {
-#ifndef DEBUGUSEGNULIBBFD
+#if !CWDEBUG_LIBBFD
//----------------------------------------------------------------------------------------
// Interface Adaptor
@@ -151,7 +151,7 @@
//----------------------------------------------------------------------------------------
-#endif // !DEBUGUSEGNULIBBFD
+#endif // !CWDEBUG_LIBBFD
// cwbfd::
void error_handler(char const* format, ...)
@@ -355,7 +355,7 @@
// cwbfd::
object_file_ct::object_file_ct(char const* filename, void* base) : lbase(base)
{
-#ifdef DEBUGDEBUGMALLOC
+#if CWDEBUG_DEBUGM
{
LIBCWD_TSD_DECLARATION
LIBCWD_ASSERT( __libcwd_tsd.internal );
@@ -363,7 +363,7 @@
#endif
abfd = bfd_openr(filename, NULL);
-#ifdef DEBUGUSEGNULIBBFD
+#if CWDEBUG_LIBBFD
if (!abfd)
DoutFatal(dc::bfd, "bfd_openr: " << bfd_errmsg(bfd_get_error()));
abfd->cacheable = bfd_tttrue;
@@ -375,13 +375,13 @@
if (bfd_check_format(abfd, bfd_archive))
{
bfd_close(abfd);
-#ifdef DEBUGUSEGNULIBBFD
+#if CWDEBUG_LIBBFD
DoutFatal(dc::bfd, filename << ": can not get addresses from archive: " << bfd_errmsg(bfd_get_error()));
#else
DoutFatal(dc::bfd, filename << ": can not get addresses from archive.");
#endif
}
-#ifdef DEBUGUSEGNULIBBFD
+#if CWDEBUG_LIBBFD
char** matching;
if (!bfd_check_format_matches(abfd, bfd_object, &matching))
{
@@ -404,7 +404,7 @@
}
long storage_needed = bfd_get_symtab_upper_bound (abfd);
-#ifdef DEBUGUSEGNULIBBFD
+#if CWDEBUG_LIBBFD
if (storage_needed < 0)
DoutFatal(dc::bfd, "bfd_get_symtab_upper_bound: " << bfd_errmsg(bfd_get_error()));
#else
@@ -420,14 +420,14 @@
symbol_table = (asymbol**) malloc(storage_needed);
number_of_symbols = bfd_canonicalize_symtab(abfd, symbol_table);
-#ifdef DEBUGUSEGNULIBBFD
+#if CWDEBUG_LIBBFD
if (number_of_symbols < 0)
DoutFatal(dc::bfd, "bfd_canonicalize_symtab: " << bfd_errmsg(bfd_get_error()));
#endif
if (number_of_symbols > 0)
{
-#ifndef DEBUGUSEGNULIBBFD
+#if !CWDEBUG_LIBBFD
size_t s_end_vma = abfd->M_s_end_vma;
#else
size_t s_end_vma = 0;
@@ -458,7 +458,7 @@
else
++s;
}
-#endif // DEBUGUSEGNULIBBFD
+#endif // CWDEBUG_LIBBFD
if (!s_end_vma && number_of_symbols > 0)
Dout(dc::warning, "Cannot find symbol _end");
@@ -609,7 +609,7 @@
// cwbfd::
object_file_ct::~object_file_ct()
{
-#if defined(LIBCWD_THREAD_SAFE) && defined(DEBUGDEBUG)
+#if defined(LIBCWD_THREAD_SAFE) && CWDEBUG_DEBUG
LIBCWD_ASSERT( _private_::is_locked(object_files_instance) );
#endif
object_files_ct::iterator iter(find(NEEDS_WRITE_LOCK_object_files().begin(), NEEDS_WRITE_LOCK_object_files().end(), this));
@@ -878,7 +878,7 @@
return 0;
}
-#ifdef DEBUGDEBUGBFD
+#ifdef LIBCWD_DEBUGBFD
// cwbfd::
void dump_object_file_symbols(object_file_ct const* object_file)
{
@@ -918,7 +918,7 @@
if (object_file->get_number_of_symbols() > 0)
{
Dout(dc::finish, "done (" << std::dec << object_file->get_number_of_symbols() << " symbols)");
-#ifdef DEBUGDEBUGBFD
+#ifdef LIBCWD_DEBUGBFD
dump_object_file_symbols(object_file);
#endif
}
@@ -945,14 +945,14 @@
// MT: We assume this is called before reaching main().
// Therefore, no synchronisation is required.
-#if defined(DEBUGDEBUG) && defined(LIBCWD_THREAD_SAFE)
+#if CWDEBUG_DEBUG && defined(LIBCWD_THREAD_SAFE)
if (_private_::WST_multi_threaded)
core_dump();
#endif
LIBCWD_TSD_DECLARATION
-#if defined(DEBUGDEBUG) && defined(DEBUGMALLOC)
+#if CWDEBUG_DEBUG && CWDEBUG_ALLOC
LIBCWD_ASSERT( !__libcwd_tsd.internal );
#endif
@@ -960,7 +960,7 @@
// Start INTERNAL!
set_alloc_checking_off(LIBCWD_TSD);
-#ifdef DEBUGMALLOC
+#if CWDEBUG_ALLOC
// Initialize the malloc library if not done yet.
init_debugmalloc();
#endif
@@ -978,7 +978,7 @@
// write lock because this function is Single Threaded.
new (&NEEDS_WRITE_LOCK_object_files()) object_files_ct;
-#ifdef DEBUGUSEGNULIBBFD
+#if CWDEBUG_LIBBFD
bfd_init();
#endif
@@ -993,11 +993,11 @@
{
LIBCWD_TSD_DECLARATION
set_alloc_checking_off(LIBCWD_TSD);
-#if defined(DEBUGDEBUG) && defined(LIBCWD_THREAD_SAFE)
+#if CWDEBUG_DEBUG && defined(LIBCWD_THREAD_SAFE)
_private_::WST_multi_threaded = false; // `fullpath' is static and will only be destroyed from exit().
#endif
delete value;
-#if defined(DEBUGDEBUG) && defined(LIBCWD_THREAD_SAFE)
+#if CWDEBUG_DEBUG && defined(LIBCWD_THREAD_SAFE)
_private_::WST_multi_threaded = true; // Make sure we catch other global strings (in order to avoid a static destructor ordering fiasco).
#endif
set_alloc_checking_on(LIBCWD_TSD);
@@ -1007,7 +1007,7 @@
ST_get_full_path_to_executable(*fullpath.value);
*fullpath.value += '\0'; // Make string null terminated so we can use data().
-#ifdef DEBUGUSEGNULIBBFD
+#if CWDEBUG_LIBBFD
bfd_set_error_program_name(fullpath.value->data() + fullpath.value->find_last_of('/') + 1);
bfd_set_error_handler(error_handler);
#endif
@@ -1064,7 +1064,7 @@
WST_initialized = true; // MT: Safe, this function is Single Threaded.
-#ifdef DEBUGDEBUGBFD
+#ifdef LIBCWD_DEBUGBFD
LIBCWD_DEFER_CANCEL
BFD_ACQUIRE_READ_LOCK
// Dump all symbols
@@ -1249,7 +1249,7 @@
LIBCWD_ASSERT( object_file->get_bfd() == abfd );
LIBCWD_DEFER_CANCEL
set_alloc_checking_off(LIBCWD_TSD);
-#ifdef DEBUGUSEGNULIBBFD
+#if CWDEBUG_LIBBFD
bfd_find_nearest_line(abfd, const_cast<asection*>(sect), const_cast<asymbol**>(object_file->get_symbol_table()),
(char*)addr - (char*)object_file->get_lbase() - sect->vma, &file, &M_func, &M_line);
#else
@@ -1529,4 +1529,4 @@
#endif // LIBCWD_DLOPEN_DEFINED
-#endif // !DEBUGUSEBFD
+#endif // !CWDEBUG_LOCATION
Index: src/libcwd/configure.in
diff -u src/libcwd/configure.in:1.106 src/libcwd/configure.in:1.107
--- src/libcwd/configure.in:1.106 Mon Feb 18 19:18:30 2002
+++ src/libcwd/configure.in Wed Feb 20 18:05:31 2002
@@ -1,5 +1,5 @@
dnl Process this file with autoconf to produce a configure script.
-AC_REVISION($Revision: 1.106 $)dnl
+AC_REVISION($Revision: 1.107 $)dnl
dnl General intialization of `autoconf' varaibles.
dnl Ensure that the directory specified with --srcdir was correct
@@ -200,24 +200,24 @@
AC_SUBST([CXXCPP_FINGER_PRINT])
dnl Configuration defines of debug_config.h
-AC_SUBST(CW_CONFIG_DEBUGMALLOC)
-CW_CONFIG_DEBUGMALLOC=undef
-AC_SUBST(CW_CONFIG_DEBUGMAGICMALLOC)
-CW_CONFIG_DEBUGMAGICMALLOC=undef
-AC_SUBST(CW_CONFIG_DEBUGUSEBFD)
-CW_CONFIG_DEBUGUSEBFD=undef
-AC_SUBST(CW_CONFIG_DEBUGUSEGNULIBBFD)
-CW_CONFIG_DEBUGUSEGNULIBBFD=undef
-AC_SUBST(CW_CONFIG_DEBUGDEBUG)
-CW_CONFIG_DEBUGDEBUG=undef
-AC_SUBST(CW_CONFIG_DEBUGDEBUGOUTPUT)
-CW_CONFIG_DEBUGDEBUGOUTPUT=undef
-AC_SUBST(CW_CONFIG_DEBUGDEBUGMALLOC)
-CW_CONFIG_DEBUGDEBUGMALLOC=undef
-AC_SUBST(CW_CONFIG_DEBUGDEBUGTHREADS)
-CW_CONFIG_DEBUGDEBUGTHREADS=undef
-AC_SUBST(CW_CONFIG_DEBUGMARKER)
-CW_CONFIG_DEBUGMARKER=undef
+AC_SUBST(CW_CONFIG_ALLOC)
+CW_CONFIG_ALLOC=0
+AC_SUBST(CW_CONFIG_MAGIC)
+CW_CONFIG_MAGIC=0
+AC_SUBST(CW_CONFIG_LOCATION)
+CW_CONFIG_LOCATION=0
+AC_SUBST(CW_CONFIG_LIBBFD)
+CW_CONFIG_LIBBFD=0
+AC_SUBST(CW_CONFIG_DEBUG)
+CW_CONFIG_DEBUG=0
+AC_SUBST(CW_CONFIG_DEBUGOUTPUT)
+CW_CONFIG_DEBUGOUTPUT=0
+AC_SUBST(CW_CONFIG_DEBUGM)
+CW_CONFIG_DEBUGM=0
+AC_SUBST(CW_CONFIG_DEBUGT)
+CW_CONFIG_DEBUGT=0
+AC_SUBST(CW_CONFIG_MARKER)
+CW_CONFIG_MARKER=0
AC_SUBST(CW_CONFIG_HAVE___LIBC_MALLOC)
CW_CONFIG_HAVE___LIBC_MALLOC=undef
AC_SUBST(CW_CONFIG_HAVE__LIBC_MALLOC)
@@ -231,11 +231,11 @@
AC_SUBST(libcwd_config_threading)
if test "$libcwd_config_alloc" = yes; then
- CW_CONFIG_DEBUGMALLOC=define
+ CW_CONFIG_ALLOC=1
fi
if test "$libcwd_config_magic" = yes; then
- CW_CONFIG_DEBUGMAGICMALLOC=define
+ CW_CONFIG_MAGIC=1
fi
dnl Set language requirements for the tests below.
@@ -250,7 +250,7 @@
[AC_CHECK_LIB(dl, dlopen, [LIBS="-ldl $LIBS"; AC_DEFINE_UNQUOTED(HAVE_DLOPEN)
CW_CONFIG_HAVE_DLOPEN=define])])
-CW_CONFIG_DEBUGUSEBFD=define
+CW_CONFIG_LOCATION=1
fi
@@ -310,7 +310,7 @@
dnl If we succeeded so far, then enable DEBUGUSEGNULIBBFD
if test "$ac_cv_lib_bfd_bfd_set_start_address" != "no" -o "set+$cw_cv_lib_bfd_bfd_set_start_address_with_intl" = "set+yes"; then
AC_CHECK_HEADER(bfd.h,
- [CW_CONFIG_DEBUGUSEGNULIBBFD=define
+ [CW_CONFIG_LIBBFD=1
AC_MSG_WARN([
* You used --enable-libcwd-libbfd: The license of libbfd (GPL) forbids to link
@@ -392,23 +392,23 @@
CW_SYS_BUILTIN_RETURN_ADDRESS_OFFSET
if test "$libcwd_config_debug" = yes; then
- CW_CONFIG_DEBUGDEBUG=define
+ CW_CONFIG_DEBUG=1
fi
if test "$libcwd_config_debug_output" = yes; then
- CW_CONFIG_DEBUGDEBUGOUTPUT=define
+ CW_CONFIG_DEBUGOUTPUT=1
fi
if test "$libcwd_config_debugm" = yes; then
- CW_CONFIG_DEBUGDEBUGMALLOC=define
+ CW_CONFIG_DEBUGM=1
fi
if test "$libcwd_config_debugt" = yes; then
- CW_CONFIG_DEBUGDEBUGTHREADS=define
+ CW_CONFIG_DEBUGT=1
fi
if test "$libcwd_config_marker" = yes; then
- CW_CONFIG_DEBUGMARKER=define
+ CW_CONFIG_MARKER=1
fi
dnl Checks for header files.
Index: src/libcwd/debug.cc
diff -u src/libcwd/debug.cc:1.74 src/libcwd/debug.cc:1.75
--- src/libcwd/debug.cc:1.74 Sun Feb 17 22:08:05 2002
+++ src/libcwd/debug.cc Wed Feb 20 18:05:31 2002
@@ -1,4 +1,4 @@
-// $Header: /cvsroot/l/li/libcw/src/libcwd/debug.cc,v 1.74 2002/02/18 06:08:05 libcw Exp $
+// $Header: /cvsroot/l/li/libcw/src/libcwd/debug.cc,v 1.75 2002/02/21 02:05:31 libcw Exp $
//
// Copyright (C) 2000 - 2002, by
//
@@ -14,12 +14,12 @@
#include "sys.h"
#include <libcw/debug_config.h>
-#if (__GNUC__ >= 3 || __GNUC_MINOR__ >= 97) && defined(LIBCWD_THREAD_SAFE) && defined(DEBUGMALLOC)
+#if (__GNUC__ >= 3 || __GNUC_MINOR__ >= 97) && defined(LIBCWD_THREAD_SAFE) && CWDEBUG_ALLOC
// This has to be very early (must not have been included elsewhere already).
#define private public // Ugly, I know.
#include <bits/stl_alloc.h>
#undef private
-#endif // (__GNUC__ >= 3 || __GNUC_MINOR__ >= 97) && defined(LIBCWD_THREAD_SAFE) && defined(DEBUGMALLOC)
+#endif // (__GNUC__ >= 3 || __GNUC_MINOR__ >= 97) && defined(LIBCWD_THREAD_SAFE) && CWDEBUG_ALLOC
#include <errno.h>
#include <iostream>
@@ -69,7 +69,7 @@
namespace _private_ {
-#if (__GNUC__ >= 3 || __GNUC_MINOR__ >= 97) && defined(LIBCWD_THREAD_SAFE) && defined(DEBUGMALLOC)
+#if (__GNUC__ >= 3 || __GNUC_MINOR__ >= 97) && defined(LIBCWD_THREAD_SAFE) && CWDEBUG_ALLOC
// The following tries to take the "node allocator" lock -- the lock of the
// default allocator for threaded applications. The parameter is the value to
// return when no lock exist. This should probably be implemented as a macro
@@ -96,7 +96,7 @@
#endif
__gthread_mutex_unlock(&std::__default_alloc_template<true, 0>::_S_node_allocator_lock._M_lock);
}
-#endif // (__GNUC__ >= 3 || __GNUC_MINOR__ >= 97) && defined(LIBCWD_THREAD_SAFE) && defined(DEBUGMALLOC)
+#endif // (__GNUC__ >= 3 || __GNUC_MINOR__ >= 97) && defined(LIBCWD_THREAD_SAFE) && CWDEBUG_ALLOC
} // namespace _private_
@@ -114,19 +114,19 @@
public:
#ifdef LIBCWD_THREAD_SAFE
void writeto(std::ostream* os, _private_::lock_interface_base_ct* mutex LIBCWD_COMMA_TSD_PARAM, debug_ct&
-#ifdef DEBUGMALLOC
+#if CWDEBUG_ALLOC
debug_object
#endif
)
#else
void writeto(std::ostream* os LIBCWD_COMMA_TSD_PARAM, debug_ct&
-#ifdef DEBUGMALLOC
+#if CWDEBUG_ALLOC
debug_object
#endif
)
#endif // LIBCWD_THREAD_SAFE
{
-#if (__GNUC__ >= 3 || __GNUC_MINOR__ >= 97) && defined(LIBCWD_THREAD_SAFE) && defined(DEBUGMALLOC)
+#if (__GNUC__ >= 3 || __GNUC_MINOR__ >= 97) && defined(LIBCWD_THREAD_SAFE) && CWDEBUG_ALLOC
typedef debug_message_st* msgbuf_t;
msgbuf_t msgbuf;
// Queue the message when the default (STL) allocator is locked and it could be that we
@@ -155,12 +155,12 @@
msgbuf = (msgbuf_t)malloc(curlen + extra_size);
free_msgbuf = true;
}
-#if (__GNUC__ >= 3 || __GNUC_MINOR__ >= 97) && defined(LIBCWD_THREAD_SAFE) && defined(DEBUGMALLOC)
+#if (__GNUC__ >= 3 || __GNUC_MINOR__ >= 97) && defined(LIBCWD_THREAD_SAFE) && CWDEBUG_ALLOC
rdbuf()->sgetn(msgbuf->buf, curlen);
#else
rdbuf()->sgetn(msgbuf, curlen);
#endif
-#ifdef DEBUGMALLOC
+#if CWDEBUG_ALLOC
// Writing to the final std::ostream (ie std::cerr) must be non-internal!
// LIBCWD_DISABLE_CANCEL/LIBCWD_ENABLE_CANCEL must be done non-internal too.
int saved_internal = __libcwd_tsd.internal;
@@ -183,7 +183,7 @@
}
}
#endif // !LIBCWD_THREAD_SAFE
-#if (__GNUC__ >= 3 || __GNUC_MINOR__ >= 97) && defined(LIBCWD_THREAD_SAFE) && defined(DEBUGMALLOC)
+#if (__GNUC__ >= 3 || __GNUC_MINOR__ >= 97) && defined(LIBCWD_THREAD_SAFE) && CWDEBUG_ALLOC
if (queue_msg) // Inside a call to malloc and possibly owning lock of std::__default_alloc_template<true, 0>?
{
// We don't write debug output to the final ostream when inside malloc and std::__default_alloc_template<true, 0> is locked.
@@ -219,15 +219,15 @@
// Then write the new message.
os->write(msgbuf->buf, curlen);
}
-#else // !(defined(DEBUGMALLOC) && defined(LIBCWD_THREAD_SAFE))
+#else // !(CWDEBUG_ALLOC && defined(LIBCWD_THREAD_SAFE))
os->write(msgbuf, curlen);
-#endif // !DEBUGMALLOC
+#endif // !CWDEBUG_ALLOC
#ifdef LIBCWD_THREAD_SAFE
if (mutex)
mutex->unlock();
LIBCWD_ENABLE_CANCEL
#endif // !LIBCWD_THREAD_SAFE
-#ifdef DEBUGMALLOC
+#if CWDEBUG_ALLOC
--LIBCWD_DO_TSD_MEMBER_OFF(libcw_do);
--__libcwd_tsd.library_call;
__libcwd_tsd.internal = saved_internal;
@@ -379,7 +379,7 @@
}
}
-#ifdef DEBUGUSEBFD
+#if CWDEBUG_LOCATION
namespace cwbfd { extern bool ST_init(void); }
#endif
@@ -389,7 +389,7 @@
if (ST_already_called)
return;
ST_already_called = true;
-#ifdef DEBUGMALLOC
+#if CWDEBUG_ALLOC
init_debugmalloc();
#endif
#ifdef LIBCWD_THREAD_SAFE
@@ -406,7 +406,7 @@
channels::dc::malloc.NS_initialize("MALLOC");
channels::dc::continued.NS_initialize(continued_maskbit);
channels::dc::finish.NS_initialize(finish_maskbit);
-#ifdef DEBUGUSEBFD
+#if CWDEBUG_LOCATION
channels::dc::bfd.NS_initialize("BFD");
#endif
// What the heck, initialize all other debug channels too
@@ -446,10 +446,10 @@
}
#endif
-#ifdef DEBUGUSEBFD
+#if CWDEBUG_LOCATION
cwbfd::ST_init(); // Initialize BFD code.
#endif
-#if defined(DEBUGDEBUG) && !defined(DEBUGDEBUGOUTPUT)
+#if CWDEBUG_DEBUG && !CWDEBUG_DEBUGOUTPUT
// Force allocation of a __cxa_eh_globals struct in libsupc++.
(void)std::uncaught_exception();
#endif
@@ -509,7 +509,7 @@
if (!WNS_debug_objects) // MT: `WNS_debug_objects' is only false when this object is still Non_Shared.
{
DEBUGDEBUG_CERR( "_debug_objects == NULL; initializing it" );
-#ifdef DEBUGMALLOC
+#if CWDEBUG_ALLOC
// It is possible that malloc is not initialized yet.
init_debugmalloc();
#endif
@@ -534,7 +534,7 @@
if (!WNS_debug_objects) // MT: `WNS_debug_objects' is only false when this object is still Non_Shared.
{
DEBUGDEBUG_CERR( "_debug_objects == NULL; initializing it" );
-#ifdef DEBUGMALLOC
+#if CWDEBUG_ALLOC
// It is possible that malloc is not initialized yet.
init_debugmalloc();
#endif
@@ -563,7 +563,7 @@
} // namespace _private_
-#ifdef DEBUGDEBUG
+#if CWDEBUG_DEBUG
static long WST_debug_object_init_magic = 0;
static void init_debug_object_init_magic(void)
@@ -765,7 +765,7 @@
void debug_tsd_st::start(debug_ct& debug_object, channel_set_data_st& channel_set LIBCWD_COMMA_TSD_PARAM)
{
-#ifdef DEBUGDEBUG
+#if CWDEBUG_DEBUG
#ifdef LIBCWD_THREAD_SAFE
// Initialisation of the TSD part should be done from LIBCWD_TSD_DECLARATION inside Dout et al.
LIBCWD_ASSERT( tsd_initialized );
@@ -803,7 +803,7 @@
debug_object.M_mutex->unlock();
#endif
char const* channame = (channel_set.mask & finish_maskbit) ? "finish" : "continued";
-#ifdef DEBUGUSEBFD
+#if CWDEBUG_LOCATION
DoutFatal(dc::core, "Using `dc::" << channame << "' in " <<
debug::location_ct((char*)__builtin_return_address(0) + builtin_return_address_offset) <<
" without (first using) a matching `continued_cf'.");
@@ -812,7 +812,7 @@
"' without (first using) a matching `continued_cf'.");
#endif
}
-#ifdef DEBUGDEBUG
+#if CWDEBUG_DEBUG
// MT: current != _private_::WST_dummy_laf, otherwise we didn't pass the previous if.
LIBCWD_ASSERT( current != reinterpret_cast<laf_ct*>(_private_::WST_dummy_laf) );
#endif
@@ -829,7 +829,7 @@
// Is this an interrupting debug output (in the middle of a continued debug output)?
if ((current->mask & continued_cf_maskbit) && unfinished_expected)
{
-#ifdef DEBUGDEBUG
+#if CWDEBUG_DEBUG
// MT: if current == _private_::WST_dummy_laf then
// (current->mask & continued_cf_maskbit) is false and this if is skipped.
LIBCWD_ASSERT( current != reinterpret_cast<laf_ct*>(_private_::WST_dummy_laf) );
@@ -889,7 +889,7 @@
write_whitespace_to(*current_oss, margin.size());
else
current_oss->write(margin.c_str(), margin.size());
-#ifndef DEBUGDEBUGOUTPUT
+#if !CWDEBUG_DEBUGOUTPUT
if (!(channel_set.mask & nolabel_cf))
#endif
{
@@ -918,7 +918,7 @@
void debug_tsd_st::finish(debug_ct& debug_object, channel_set_data_st& channel_set LIBCWD_COMMA_TSD_PARAM)
{
-#ifdef DEBUGDEBUG
+#if CWDEBUG_DEBUG
LIBCWD_ASSERT( current != reinterpret_cast<laf_ct*>(_private_::WST_dummy_laf) );
#endif
std::ostream* target_os = (current->mask & cerr_cf) ? &std::cerr : debug_object.real_os;
@@ -1028,7 +1028,7 @@
{
current = reinterpret_cast<laf_ct*>(_private_::WST_dummy_laf); // Used (MT: read-only!) in next debug_ct::start().
DEBUGDEBUG_CERR( "current = " << (void*)current );
-#ifdef DEBUGDEBUG
+#if CWDEBUG_DEBUG
current_oss = NULL;
DEBUGDEBUG_CERR( "current_oss = " << (void*)current_oss );
#endif
@@ -1066,7 +1066,7 @@
M_mutex = NULL;
#endif
-#ifdef DEBUGDEBUG
+#if CWDEBUG_DEBUG
if (!WST_debug_object_init_magic)
init_debug_object_init_magic();
init_magic = WST_debug_object_init_magic;
@@ -1092,7 +1092,7 @@
new (_private_::WST_dummy_laf) laf_ct(0, channels::dc::debug.get_label(), 0); // Leaks 24 bytes of memory
#ifdef LIBCWD_THREAD_SAFE
WNS_index = S_index_count++;
-#ifdef DEBUGDEBUGTHREADS
+#if CWDEBUG_DEBUGT
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 );
@@ -1101,7 +1101,7 @@
tsd.init();
set_alloc_checking_on(LIBCWD_TSD);
-#ifdef DEBUGDEBUGOUTPUT
+#if CWDEBUG_DEBUGOUTPUT
LIBCWD_TSD_MEMBER_OFF = -1; // Print as much debug output as possible right away.
#else
LIBCWD_TSD_MEMBER_OFF = 0; // Don't print debug output till the REAL initialization of the debug system
@@ -1119,7 +1119,7 @@
void debug_tsd_st::init(void)
{
-#ifdef DEBUGDEBUGMALLOC
+#if CWDEBUG_DEBUGM
LIBCWD_TSD_DECLARATION
LIBCWD_ASSERT( __libcwd_tsd.internal );
#endif
@@ -1130,7 +1130,7 @@
// current.mask needs to be 0 to avoid a crash in start():
current = reinterpret_cast<laf_ct*>(_private_::WST_dummy_laf);
DEBUGDEBUG_CERR( "current = " << (void*)current );
-#ifdef DEBUGDEBUG
+#if CWDEBUG_DEBUG
current_oss = NULL;
DEBUGDEBUG_CERR( "current_oss = " << (void*)current_oss );
#endif
@@ -1139,7 +1139,7 @@
margin.NS_internal_init("", 0);
marker.NS_internal_init(": ", 2);
-#ifdef DEBUGDEBUGOUTPUT
+#if CWDEBUG_DEBUGOUTPUT
first_time = true;
#endif
off_count = 0;
@@ -1436,7 +1436,7 @@
continued_channel_set_st& channel_set_st::operator|(continued_cf_nt)
{
-#ifdef DEBUGDEBUG
+#if CWDEBUG_DEBUG
DEBUGDEBUG_CERR( "continued_cf detected" );
if (!do_tsd_ptr || !do_tsd_ptr->tsd_initialized)
{
@@ -1462,7 +1462,7 @@
continued_channel_set_st& channel_set_bootstrap_st::operator|(continued_channel_ct const& cdc)
{
-#ifdef DEBUGDEBUG
+#if CWDEBUG_DEBUG
if ((cdc.get_maskbit() & continued_maskbit))
DEBUGDEBUG_CERR( "dc::continued detected" );
else
@@ -1496,7 +1496,7 @@
channel_set_st& channel_set_bootstrap_st::operator|(fatal_channel_ct const&)
{
-#ifdef DEBUGUSEBFD
+#if CWDEBUG_LOCATION
DoutFatal(dc::fatal, location_ct((char*)__builtin_return_address(0) + libcw::debug::builtin_return_address_offset) <<
" : Don't use Dout together with dc::core or dc::fatal! Use DoutFatal instead.");
#else
@@ -1507,7 +1507,7 @@
channel_set_st& channel_set_bootstrap_st::operator&(channel_ct const&)
{
-#ifdef DEBUGUSEBFD
+#if CWDEBUG_LOCATION
DoutFatal(dc::fatal, location_ct((char*)__builtin_return_address(0) + libcw::debug::builtin_return_address_offset) <<
" : Use dc::core or dc::fatal together with DoutFatal.");
#else
@@ -1520,10 +1520,10 @@
void assert_fail(char const* expr, char const* file, int line, char const* function)
{
-#ifdef DEBUGDEBUG
+#if CWDEBUG_DEBUG
LIBCWD_TSD_DECLARATION
if (__libcwd_tsd.recursive_assert
-#ifdef DEBUGDEBUGMALLOC
+#if CWDEBUG_DEBUGM
|| __libcwd_tsd.inside_malloc_or_free
#endif
)
@@ -1534,7 +1534,7 @@
core_dump();
}
__libcwd_tsd.recursive_assert = true;
-#ifdef DEBUGDEBUGTHREADS
+#if CWDEBUG_DEBUGT
__libcwd_tsd.internal_debugging_code = true;
#endif
#endif
@@ -1548,7 +1548,7 @@
NS_init();
LIBCWD_TSD_DECLARATION
state._off = LIBCWD_TSD_MEMBER_OFF;
-#ifdef DEBUGDEBUGOUTPUT
+#if CWDEBUG_DEBUGOUTPUT
state.first_time = LIBCWD_TSD_MEMBER(first_time);
#endif
LIBCWD_TSD_MEMBER_OFF = -1; // Turn object on.
@@ -1557,7 +1557,7 @@
void debug_ct::restore(debug_ct::OnOffState const& state)
{
LIBCWD_TSD_DECLARATION
-#ifdef DEBUGDEBUGOUTPUT
+#if CWDEBUG_DEBUGOUTPUT
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
Index: src/libcwd/debugmalloc.cc
diff -u src/libcwd/debugmalloc.cc:1.85 src/libcwd/debugmalloc.cc:1.86
--- src/libcwd/debugmalloc.cc:1.85 Tue Feb 19 19:55:51 2002
+++ src/libcwd/debugmalloc.cc Wed Feb 20 18:05:31 2002
@@ -1,4 +1,4 @@
-// $Header: /cvsroot/l/li/libcw/src/libcwd/debugmalloc.cc,v 1.85 2002/02/20 03:55:51 libcw Exp $
+// $Header: /cvsroot/l/li/libcw/src/libcwd/debugmalloc.cc,v 1.86 2002/02/21 02:05:31 libcw Exp $
//
// Copyright (C) 2000 - 2002, by
//
@@ -119,11 +119,11 @@
// For internal use.
//
-#define DEBUGMALLOC_INTERNAL
+#define LIBCWD_DEBUGMALLOC_INTERNAL
#include "sys.h"
#include <libcw/debug_config.h>
-#if defined(DEBUGMALLOC) || defined(LIBCW_DOXYGEN)
+#if CWDEBUG_ALLOC || defined(LIBCW_DOXYGEN)
#include <cstring>
#include <string>
@@ -246,7 +246,7 @@
} // namespace debug
} // namespace libcw
-#ifdef DEBUGDEBUGMALLOC
+#if CWDEBUG_DEBUGM
#define DEBUGDEBUG_DoutInternal_MARKER DEBUGDEBUG_CERR( "DoutInternal at " << __FILE__ << ':' << __LINE__ )
#define DEBUGDEBUG_DoutFatalInternal_MARKER DEBUGDEBUG_CERR( "DoutFatalInternal at " << __FILE__ << ':' << __LINE__ )
#define DEBUGDEBUG_ELSE_DoutInternal(data) else DEBUGDEBUG_CERR( "library_call == " << __libcwd_tsd.library_call << "; DoutInternal skipped for: " << data );
@@ -376,7 +376,7 @@
bool inside_ios_base_Init_Init(void) // Single Threaded function.
{
LIBCWD_TSD_DECLARATION
-#ifdef DEBUGDEBUGMALLOC
+#if CWDEBUG_DEBUGM
LIBCWD_ASSERT( __libcwd_tsd.internal == 0 );
#endif
#ifndef _GLIBCPP_USE_WCHAR_T
@@ -394,7 +394,7 @@
}
#endif // __GLIBCPP__
-#ifdef DEBUGDEBUGMALLOC
+#if CWDEBUG_DEBUGM
// _private_::
void set_alloc_checking_off(LIBCWD_TSD_PARAM)
{
@@ -438,7 +438,7 @@
from_free, // memblk_type_malloc
from_free, // memblk_type_realloc
error, // memblk_type_freed
-#ifdef DEBUGMARKER
+#if CWDEBUG_MARKER
from_delete, // memblk_type_marker
error, // memblk_type_deleted_marker
#endif
@@ -475,7 +475,7 @@
case memblk_type_freed:
os << "memblk_type_freed";
break;
-#ifdef DEBUGMARKER
+#if CWDEBUG_MARKER
case memblk_type_marker:
os << "memblk_type_marker";
break;
@@ -515,7 +515,7 @@
case memblk_type_realloc:
os.write("realloc ", 10);
break;
-#ifdef DEBUGMARKER
+#if CWDEBUG_MARKER
case memblk_type_marker:
os.write("(MARKER) ", 10);
break;
@@ -534,7 +534,7 @@
}
}
-#ifdef DEBUGDEBUGMALLOC
+#if CWDEBUG_DEBUGM
_private_::raw_write_nt const& operator<<(_private_::raw_write_nt const& raw_write, memblk_key_ct const& data)
{
write(2, "<memblk_key_ct>", 15);
@@ -556,7 +556,7 @@
// a list, therefore we have to implement our own list (prev/next pointers).
class dm_alloc_ct : public alloc_ct {
-#ifdef DEBUGMARKER
+#if CWDEBUG_MARKER
friend class marker_ct;
friend void move_outside(marker_ct* marker, void const* ptr);
#endif
@@ -586,7 +586,7 @@
++memblks;
}
// Constructor: Add `node' at the start of `list'
-#ifdef DEBUGDEBUGMALLOC
+#if CWDEBUG_DEBUGM
dm_alloc_ct(dm_alloc_ct const& __dummy) : alloc_ct(__dummy) { LIBCWD_TSD_DECLARATION DoutFatalInternal( dc::fatal, "Calling dm_alloc_ct::dm_alloc_ct(dm_alloc_ct const&)" ); }
// No copy constructor allowed.
#endif
@@ -652,7 +652,7 @@
{ return a_start > b.end() || (a_start == b.end() && b.size() > 0); }
bool operator==(memblk_key_ct b) const
{
-#ifdef DEBUGDEBUGMALLOC
+#if CWDEBUG_DEBUGM
{
LIBCWD_TSD_DECLARATION
LIBCWD_ASSERT( __libcwd_tsd.internal );
@@ -664,7 +664,7 @@
void printOn(std::ostream& os) const;
friend inline std::ostream& operator<<(std::ostream& os, memblk_key_ct const& memblk) { memblk.printOn(os); return os; }
friend inline _private_::no_alloc_ostream_ct& operator<<(_private_::no_alloc_ostream_ct& os, memblk_key_ct const& memblk) { memblk.printOn(os.M_os); return os; }
-#ifdef DEBUGDEBUGMALLOC
+#if CWDEBUG_DEBUGM
static bool selftest(void);
// Returns true is the self test FAILED.
#endif
@@ -673,7 +673,7 @@
};
class memblk_info_ct {
-#ifdef DEBUGMARKER
+#if CWDEBUG_MARKER
friend class marker_ct;
friend void move_outside(marker_ct* marker, void const* ptr);
#endif
@@ -765,7 +765,7 @@
inline bool dm_alloc_ct::is_deleted(void) const
{
return (a_memblk_type == memblk_type_deleted ||
-#ifdef DEBUGMARKER
+#if CWDEBUG_MARKER
a_memblk_type == memblk_type_deleted_marker ||
#endif
a_memblk_type == memblk_type_freed);
@@ -773,7 +773,7 @@
dm_alloc_ct::~dm_alloc_ct() // MT-safe: write lock is set.
{
-#ifdef DEBUGDEBUGMALLOC
+#if CWDEBUG_DEBUGM
{
LIBCWD_TSD_DECLARATION
LIBCWD_ASSERT( __libcwd_tsd.internal );
@@ -799,7 +799,7 @@
}
#if __GNUC__ == 2 && __GNUC_MINOR__ < 96
-#ifdef DEBUGUSEBFD
+#if CWDEBUG_LOCATION
// Bug work around.
inline std::ostream& operator<<(std::ostream& os, smanip<int> const& smanip)
{
@@ -815,19 +815,19 @@
extern void demangle_symbol(char const* in, _private_::internal_string& out);
-#ifdef DEBUGUSEBFD
+#if CWDEBUG_LOCATION
struct dm_location_ct : public location_ct {
void print_on(std::ostream& os) const;
friend _private_::no_alloc_ostream_ct& operator<<(_private_::no_alloc_ostream_ct& os, dm_location_ct const& data);
-#ifdef DEBUGDEBUGOUTPUT
+#if CWDEBUG_DEBUGOUTPUT
friend _private_::raw_write_nt const& operator<<(_private_::raw_write_nt const& os, dm_location_ct const& data);
#endif
};
-#endif // DEBUGUSEBFD
+#endif // CWDEBUG_LOCATION
static char const* const twentyfive_spaces_c = " ";
-#ifdef DEBUGUSEBFD
+#if CWDEBUG_LOCATION
_private_::no_alloc_ostream_ct& operator<<(_private_::no_alloc_ostream_ct& os, dm_location_ct const& data)
{
size_t len = strlen(data.M_filename);
@@ -847,7 +847,7 @@
return os;
}
-#ifdef DEBUGDEBUGOUTPUT
+#if CWDEBUG_DEBUGOUTPUT
_private_::raw_write_nt const& operator<<(_private_::raw_write_nt const& raw_write, dm_location_ct const& data)
{
size_t len = strlen(data.M_filename);
@@ -866,15 +866,15 @@
write(2, twentyfive_spaces_c, cnt);
return raw_write;
}
-#endif // DEBUGDEBUGOUTPUT
-#endif // DEBUGUSEBFD
+#endif // CWDEBUG_DEBUGOUTPUT
+#endif // CWDEBUG_LOCATION
void dm_alloc_ct::print_description(LIBCWD_TSD_PARAM) const
{
-#ifdef DEBUGDEBUGMALLOC
+#if CWDEBUG_DEBUGM
LIBCWD_ASSERT( !__libcwd_tsd.internal && !__libcwd_tsd.library_call );
#endif
-#ifdef DEBUGUSEBFD
+#if CWDEBUG_LOCATION
if (M_location.is_known())
DoutInternal(dc::continued, *static_cast<dm_location_ct const*>(&M_location));
else if (M_location.mangled_function_name() != unknown_function_c)
@@ -893,7 +893,7 @@
DoutInternal( dc::continued, twentyfive_spaces_c );
#endif
-#ifdef DEBUGMARKER
+#if CWDEBUG_MARKER
if (a_memblk_type == memblk_type_marker || a_memblk_type == memblk_type_deleted_marker)
DoutInternal( dc::continued, "<marker>;" );
else
@@ -992,13 +992,13 @@
void memblk_info_ct::erase(LIBCWD_TSD_PARAM)
{
-#ifdef DEBUGDEBUGMALLOC
+#if CWDEBUG_DEBUGM
LIBCWD_ASSERT( __libcwd_tsd.internal );
#endif
dm_alloc_ct* ap = a_alloc_node.get();
-#ifdef DEBUGDEBUGMALLOC
+#if CWDEBUG_DEBUGM
if (ap)
- LIBCWD_DEBUGM_CERR( "DEBUGDEBUGMALLOC: memblk_info_ct::erase for " << ap->start() );
+ LIBCWD_DEBUGM_CERR( "CWDEBUG_DEBUGM: memblk_info_ct::erase for " << ap->start() );
#endif
if (ap && ap->next_list())
{
@@ -1017,7 +1017,7 @@
case memblk_type_external:
new_flag = memblk_type_freed;
break;
-#ifdef DEBUGMARKER
+#if CWDEBUG_MARKER
case memblk_type_marker:
new_flag = memblk_type_deleted_marker;
break;
@@ -1033,7 +1033,7 @@
}
-#ifdef DEBUGMAGICMALLOC
+#if CWDEBUG_MAGIC
size_t const INTERNAL_MAGIC_NEW_BEGIN = 0x7af45b1c;
size_t const INTERNAL_MAGIC_NEW_END = 0x3b9f018a;
@@ -1137,7 +1137,7 @@
return ") with a corrupt second magic number (buffer overrun?)!";
}
-#endif // DEBUGMAGICMALLOC
+#endif // CWDEBUG_MAGIC
//=============================================================================
//
@@ -1158,30 +1158,30 @@
#define SIZE_PLUS_FOUR(s) ((s) + sizeof(size_t))
# endif
-#ifdef DEBUGUSEBFD
-#if defined(DEBUGDEBUGMALLOC) && defined(DEBUGDEBUGOUTPUT)
+#if CWDEBUG_LOCATION
+#if CWDEBUG_DEBUGM && CWDEBUG_DEBUGOUTPUT
static void* internal_malloc(size_t size, memblk_types_nt flag, void* call_addr LIBCWD_COMMA_TSD_PARAM, int saved_marker)
#else
static void* internal_malloc(size_t size, memblk_types_nt flag, void* call_addr LIBCWD_COMMA_TSD_PARAM)
#endif
-#else // !DEBUGUSEBFD
-#if defined(DEBUGDEBUGMALLOC) && defined(DEBUGDEBUGOUTPUT)
+#else // !CWDEBUG_LOCATION
+#if CWDEBUG_DEBUGM && CWDEBUG_DEBUGOUTPUT
static void* internal_malloc(size_t size, memblk_types_nt flag LIBCWD_COMMA_TSD_PARAM, int saved_marker)
#else
static void* internal_malloc(size_t size, memblk_types_nt flag LIBCWD_COMMA_TSD_PARAM)
#endif
-#endif // !DEBUGUSEBFD
+#endif // !CWDEBUG_LOCATION
{
if (WST_initialization_state <= 0) // Only true prior to initialization of std::ios_base::Init.
{
-#ifdef DEBUGDEBUG
+#if CWDEBUG_DEBUG
bool continued_debug_output = (__libcwd_tsd.library_call == 0 && LIBCWD_DO_TSD_MEMBER_OFF(libcw_do) < 0);
#endif
init_debugmalloc();
-#ifdef DEBUGDEBUG
+#if CWDEBUG_DEBUG
// 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
+ // Initialization of libcwd with CWDEBUG_DEBUG set 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_OFF(libcw_do) < 0))
DoutInternal( dc_malloc|continued_cf, "internal_malloc(" << size << ", " << flag << ") = " );
@@ -1189,13 +1189,13 @@
}
register void* mptr;
-#ifndef DEBUGMAGICMALLOC
+#if !CWDEBUG_MAGIC
if (!(mptr = __libc_malloc(size)))
#else
if ((mptr = static_cast<char*>(__libc_malloc(SIZE_PLUS_TWELVE(size))) + 2 * sizeof(size_t)) == (void*)(2 * sizeof(size_t)))
#endif
{
-#if defined(DEBUGDEBUGMALLOC) && defined(DEBUGDEBUGOUTPUT)
+#if CWDEBUG_DEBUGM && CWDEBUG_DEBUGOUTPUT
DoutInternal( dc::finish, "NULL [" << saved_marker << ']' );
#else
DoutInternal( dc::finish, "NULL" );
@@ -1204,7 +1204,7 @@
return NULL; // A fatal error should occur directly after this
}
-#ifdef DEBUGUSEBFD
+#if CWDEBUG_LOCATION
if (__libcwd_tsd.library_call++)
++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);
@@ -1212,7 +1212,7 @@
--LIBCWD_DO_TSD_MEMBER_OFF(libcw_do);
#endif
-#ifdef DEBUGDEBUGMALLOC
+#if CWDEBUG_DEBUGM
bool error;
#endif
memblk_info_ct* memblk_info;
@@ -1227,7 +1227,7 @@
std::pair<memblk_map_ct::iterator, bool> const&
iter(memblk_map_write->insert(memblk_ct(memblk_key_ct(mptr, size), memblk_info_ct(mptr, size, flag))));
memblk_info = &(*iter.first).second;
-#ifdef DEBUGDEBUGMALLOC
+#if CWDEBUG_DEBUGM
error = !iter.second;
#endif
RELEASE_WRITE_LOCK
@@ -1237,18 +1237,18 @@
LIBCWD_RESTORE_CANCEL
-#ifdef DEBUGDEBUGMALLOC
+#if CWDEBUG_DEBUGM
// MT-safe: iter points to an element that is garanteed unique to this thread (we just allocated it).
if (error)
DoutFatalInternal( dc::core, "memblk_map corrupt: Newly allocated block collides with existing memblk!" );
#endif
memblk_info->lock(); // Lock ownership (doesn't call malloc).
-#ifdef DEBUGUSEBFD
+#if CWDEBUG_LOCATION
memblk_info->get_alloc_node()->location_reference().move(loc);
#endif
-#if defined(DEBUGDEBUGMALLOC) && defined(DEBUGDEBUGOUTPUT)
+#if CWDEBUG_DEBUGM && CWDEBUG_DEBUGOUTPUT
DoutInternal( dc::finish, (void*)(mptr) << " [" << saved_marker << ']' );
#else
DoutInternal( dc::finish, (void*)(mptr) );
@@ -1258,34 +1258,34 @@
static void internal_free(void* ptr, deallocated_from_nt from LIBCWD_COMMA_TSD_PARAM)
{
-#ifdef DEBUGDEBUGMALLOC
+#if CWDEBUG_DEBUGM
// We can't use `assert' here, because that can call malloc.
if (__libcwd_tsd.inside_malloc_or_free > __libcwd_tsd.library_call && !__libcwd_tsd.internal)
{
- LIBCWD_DEBUGM_CERR("DEBUGDEBUGMALLOC: debugmalloc.cc:" << __LINE__ - 2 << ": " << __PRETTY_FUNCTION__ << ": Assertion `__libcwd_tsd.inside_malloc_or_free <= __libcwd_tsd.library_call || __libcwd_tsd.internal' failed.");
+ LIBCWD_DEBUGM_CERR("CWDEBUG_DEBUGM: debugmalloc.cc:" << __LINE__ - 2 << ": " << __PRETTY_FUNCTION__ << ": Assertion `__libcwd_tsd.inside_malloc_or_free <= __libcwd_tsd.library_call || __libcwd_tsd.internal' failed.");
core_dump();
}
#endif
-#if defined(DEBUGDEBUGMALLOC) && defined(__GLIBCPP__) && !defined(LIBCWD_USE_EXTERNAL_C_LINKAGE_FOR_MALLOC)
+#if CWDEBUG_DEBUGM && defined(__GLIBCPP__) && !defined(LIBCWD_USE_EXTERNAL_C_LINKAGE_FOR_MALLOC)
LIBCWD_ASSERT( _private_::WST_ios_base_initialized || __libcwd_tsd.internal );
#endif
if (__libcwd_tsd.internal)
{
-#if defined(DEBUGDEBUGMALLOC) && defined(DEBUGDEBUGOUTPUT)
+#if CWDEBUG_DEBUGM && CWDEBUG_DEBUGOUTPUT
if (from == from_delete)
{
- LIBCWD_DEBUGM_CERR( "DEBUGDEBUGMALLOC: Internal `delete(" << ptr << ")' [" << ++__libcwd_tsd.marker << ']' );
+ LIBCWD_DEBUGM_CERR( "CWDEBUG_DEBUGM: Internal `delete(" << ptr << ")' [" << ++__libcwd_tsd.marker << ']' );
}
else if (from == from_delete_array)
{
- LIBCWD_DEBUGM_CERR( "DEBUGDEBUGMALLOC: Internal `delete[](" << ptr << ")' [" << ++__libcwd_tsd.marker << ']' );
+ LIBCWD_DEBUGM_CERR( "CWDEBUG_DEBUGM: Internal `delete[](" << ptr << ")' [" << ++__libcwd_tsd.marker << ']' );
}
else
{
- LIBCWD_DEBUGM_CERR( "DEBUGDEBUGMALLOC: Internal `free(" << ptr << ")' [" << ++__libcwd_tsd.marker << ']' );
+ LIBCWD_DEBUGM_CERR( "CWDEBUG_DEBUGM: Internal `free(" << ptr << ")' [" << ++__libcwd_tsd.marker << ']' );
}
-#endif // DEBUGDEBUGMALLOC
-#ifdef DEBUGMAGICMALLOC
+#endif // CWDEBUG_DEBUGM
+#if CWDEBUG_MAGIC
if (!ptr)
return;
ptr = static_cast<size_t*>(ptr) - 2;
@@ -1312,7 +1312,7 @@
}
((size_t*)ptr)[0] ^= (size_t)-1;
((size_t*)(static_cast<char*>(ptr) + SIZE_PLUS_TWELVE(((size_t*)ptr)[1])))[-1] ^= (size_t)-1;
-#endif // DEBUGMAGICMALLOC
+#endif // CWDEBUG_MAGIC
__libc_free(ptr);
return;
} // internal
@@ -1320,7 +1320,7 @@
++__libcwd_tsd.inside_malloc_or_free;
if (!ptr)
{
-#if defined(DEBUGDEBUGMALLOC) && defined(DEBUGDEBUGOUTPUT)
+#if CWDEBUG_DEBUGM && CWDEBUG_DEBUGOUTPUT
DoutInternal( dc_malloc, "Trying to free NULL - ignored [" << ++__libcwd_tsd.marker << "]." );
#else
DoutInternal( dc_malloc, "Trying to free NULL - ignored." );
@@ -1336,7 +1336,7 @@
{
RELEASE_READ_LOCK
LIBCWD_RESTORE_CANCEL_NO_BRACE
-#ifdef DEBUGMAGICMALLOC
+#if CWDEBUG_MAGIC
if (((size_t*)ptr)[-2] == INTERNAL_MAGIC_NEW_BEGIN ||
((size_t*)ptr)[-2] == INTERNAL_MAGIC_NEW_ARRAY_BEGIN ||
((size_t*)ptr)[-2] == INTERNAL_MAGIC_MALLOC_BEGIN)
@@ -1360,7 +1360,7 @@
<< ptr << ((from == from_free) ? ") " : " ") );
if (channels::dc_malloc.is_on())
(*iter).second.print_description(LIBCWD_TSD);
-#if defined(DEBUGDEBUGMALLOC) && defined(DEBUGDEBUGOUTPUT)
+#if CWDEBUG_DEBUGM && CWDEBUG_DEBUGOUTPUT
DoutInternal( dc::continued, " [" << ++__libcwd_tsd.marker << "] " );
#else
DoutInternal( dc::continued, ' ' );
@@ -1403,7 +1403,7 @@
DEBUGDEBUG_CERR( "__libcwd_free: internal == " << __libcwd_tsd.internal << "; setting it to 1." );
__libcwd_tsd.internal = 1;
-#ifdef DEBUGMAGICMALLOC
+#if CWDEBUG_MAGIC
bool has_alloc_node = (*iter).second.has_alloc_node(); // Needed for diagnostic message below.
#endif
@@ -1421,7 +1421,7 @@
LIBCWD_RESTORE_CANCEL_NO_BRACE
-#ifdef DEBUGMAGICMALLOC
+#if CWDEBUG_MAGIC
if (f == memblk_type_external)
__libc_free(ptr);
else
@@ -1448,9 +1448,9 @@
((size_t*)(static_cast<char*>(ptr) + SIZE_PLUS_FOUR(((size_t*)ptr)[-1])))[-1] ^= (size_t)-1;
__libc_free(static_cast<size_t*>(ptr) - 2); // Free memory block
}
-#else // !DEBUGMAGICMALLOC
+#else // !CWDEBUG_MAGIC
__libc_free(ptr); // Free memory block
-#endif // !DEBUGMAGICMALLOC
+#endif // !CWDEBUG_MAGIC
if (visible)
DoutInternal( dc::finish, "" );
@@ -1575,8 +1575,8 @@
* \brief List all current allocations to a given %debug object.
* \ingroup group_overview
*
- * With both, \link enable_libcwd_debugm DEBUGMALLOC \endlink and
- * \link enable_libcwd_debug DEBUGDEBUG \endlink defined, it is possible
+ * With both, \link enable_libcwd_debugm CWDEBUG_ALLOC \endlink and
+ * \link enable_libcwd_debug CWDEBUG_DEBUG \endlink set to 1, it is possible
* to write the \ref group_overview "overview of allocated memory" to
* a \ref group_debug_object "Debug Object".
* The syntax to do this is:
@@ -1590,7 +1590,7 @@
*/
void list_allocations_on(debug_ct& debug_object)
{
-#ifdef DEBUGDEBUGMALLOC
+#if CWDEBUG_DEBUGM
{
LIBCWD_TSD_DECLARATION
LIBCWD_ASSERT( !__libcwd_tsd.inside_malloc_or_free && !__libcwd_tsd.internal );
@@ -1651,7 +1651,7 @@
void make_invisible(void const* ptr)
{
LIBCWD_TSD_DECLARATION
-#ifdef DEBUGDEBUGMALLOC
+#if CWDEBUG_DEBUGM
LIBCWD_ASSERT( !__libcwd_tsd.internal );
#endif
LIBCWD_DEFER_CANCEL
@@ -1694,7 +1694,7 @@
void make_all_allocations_invisible_except(void const* ptr)
{
LIBCWD_TSD_DECLARATION
-#ifdef DEBUGDEBUGMALLOC
+#if CWDEBUG_DEBUGM
LIBCWD_ASSERT( !__libcwd_tsd.internal );
#endif
LIBCWD_DEFER_CANCEL
@@ -1736,22 +1736,22 @@
}
#undef CALL_ADDRESS
-#ifdef DEBUGUSEBFD
+#if CWDEBUG_LOCATION
#define CALL_ADDRESS , reinterpret_cast<char*>(__builtin_return_address(0)) + builtin_return_address_offset
#else
#define CALL_ADDRESS
#endif
#undef SAVEDMARKER
-#if defined(DEBUGDEBUGMALLOC) && defined(DEBUGDEBUGOUTPUT)
+#if CWDEBUG_DEBUGM && CWDEBUG_DEBUGOUTPUT
#define SAVEDMARKER , saved_marker
#else
#define SAVEDMARKER
#endif
-#ifdef DEBUGMARKER
+#if CWDEBUG_MARKER
void marker_ct::register_marker(char const* label)
{
-#ifdef DEBUGDEBUGMALLOC
+#if CWDEBUG_DEBUGM
LIBCWD_TSD_DECLARATION
LIBCWD_ASSERT( !__libcwd_tsd.inside_malloc_or_free && !__libcwd_tsd.internal );
#endif
@@ -1773,7 +1773,7 @@
LIBCWD_RESTORE_CANCEL
if (error)
DoutFatal( dc::core, "Use 'new' for libcw::debug::marker_ct" );
-#if defined(DEBUGDEBUGMALLOC) && defined(DEBUGDEBUGOUTPUT)
+#if CWDEBUG_DEBUGM && CWDEBUG_DEBUGOUTPUT
Debug( list_allocations_on(libcw_do) );
#endif
}
@@ -1783,7 +1783,7 @@
*/
marker_ct::~marker_ct(void)
{
-#ifdef DEBUGDEBUGMALLOC
+#if CWDEBUG_DEBUGM
LIBCWD_TSD_DECLARATION
LIBCWD_ASSERT( !__libcwd_tsd.inside_malloc_or_free && !__libcwd_tsd.internal );
#endif
@@ -1828,7 +1828,7 @@
*/
void move_outside(marker_ct* marker, void const* ptr)
{
-#ifdef DEBUGDEBUGMALLOC
+#if CWDEBUG_DEBUGM
LIBCWD_TSD_DECLARATION
LIBCWD_ASSERT( !__libcwd_tsd.inside_malloc_or_free && !__libcwd_tsd.internal );
#endif
@@ -1895,7 +1895,7 @@
RELEASE_READ_LOCK
LIBCWD_RESTORE_CANCEL_NO_BRACE
}
-#endif // DEBUGMARKER
+#endif // CWDEBUG_MARKER
/**
* \brief Find information about a memory allocation.
@@ -1926,7 +1926,7 @@
*/
alloc_ct const* find_alloc(void const* ptr)
{
-#ifdef DEBUGDEBUGMALLOC
+#if CWDEBUG_DEBUGM
LIBCWD_TSD_DECLARATION
LIBCWD_ASSERT( !__libcwd_tsd.inside_malloc_or_free && !__libcwd_tsd.internal );
#endif
@@ -1946,7 +1946,7 @@
// Self tests:
//
-#ifdef DEBUGDEBUGMALLOC
+#if CWDEBUG_DEBUGM
bool memblk_key_ct::selftest(void)
{
@@ -2025,7 +2025,7 @@
return false;
}
-#endif // DEBUGDEBUGMALLOC
+#endif // CWDEBUG_DEBUGM
#ifndef LIBCWD_USE_EXTERNAL_C_LINKAGE_FOR_MALLOC
@@ -2045,10 +2045,10 @@
void register_external_allocation(void const* mptr, size_t size)
{
LIBCWD_TSD_DECLARATION
-#ifdef DEBUGDEBUGMALLOC
+#if CWDEBUG_DEBUGM
LIBCWD_ASSERT( !__libcwd_tsd.inside_malloc_or_free && !__libcwd_tsd.internal );
#endif
-#if defined(DEBUGDEBUGMALLOC) && defined(__GLIBCPP__)
+#if CWDEBUG_DEBUGM && defined(__GLIBCPP__)
LIBCWD_ASSERT( _private_::WST_ios_base_initialized );
#endif
if (__libcwd_tsd.internal)
@@ -2066,7 +2066,7 @@
__libcwd_tsd.internal = 0;
}
-#ifdef DEBUGUSEBFD
+#if CWDEBUG_LOCATION
if (__libcwd_tsd.library_call++)
++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);
@@ -2094,7 +2094,7 @@
memblk_info_ct& memblk_info((*iter.first).second);
memblk_info.lock(); // Lock ownership (doesn't call malloc).
-#ifdef DEBUGUSEBFD
+#if CWDEBUG_LOCATION
memblk_info.get_alloc_node()->location_reference().move(loc);
#endif
--__libcwd_tsd.inside_malloc_or_free;
@@ -2126,7 +2126,7 @@
// malloc(3) and calloc(3) replacements:
//
-#if (__GNUC__ >= 3 || __GNUC_MINOR__ >= 97) && defined(LIBCWD_THREAD_SAFE) && defined(DEBUGDEBUG)
+#if (__GNUC__ >= 3 || __GNUC_MINOR__ >= 97) && defined(LIBCWD_THREAD_SAFE) && CWDEBUG_DEBUG
#define UNLOCK if (locked) _private_::allocator_unlock();
#else
#define UNLOCK
@@ -2135,54 +2135,54 @@
void* __libcwd_malloc(size_t size)
{
LIBCWD_TSD_DECLARATION
-#ifdef DEBUGDEBUGMALLOC
+#if CWDEBUG_DEBUGM
// We can't use `assert' here, because that can call malloc.
if (__libcwd_tsd.inside_malloc_or_free > __libcwd_tsd.library_call && !__libcwd_tsd.internal)
{
- FATALDEBUGDEBUG_CERR("DEBUGDEBUGMALLOC: debugmalloc.cc:" << __LINE__ - 2 << ": " << __PRETTY_FUNCTION__ << ": Assertion `__libcwd_tsd.inside_malloc_or_free <= __libcwd_tsd.library_call || __libcwd_tsd.internal' failed.");
+ FATALDEBUGDEBUG_CERR("CWDEBUG_DEBUGM: debugmalloc.cc:" << __LINE__ - 2 << ": " << __PRETTY_FUNCTION__ << ": Assertion `__libcwd_tsd.inside_malloc_or_free <= __libcwd_tsd.library_call || __libcwd_tsd.internal' failed.");
core_dump();
}
-#ifdef DEBUGDEBUGOUTPUT
+#if CWDEBUG_DEBUGOUTPUT
int saved_marker = ++__libcwd_tsd.marker;
#endif
#endif
-#if defined(DEBUGDEBUGMALLOC) && defined(__GLIBCPP__) && !defined(LIBCWD_USE_EXTERNAL_C_LINKAGE_FOR_MALLOC)
+#if CWDEBUG_DEBUGM && defined(__GLIBCPP__) && !defined(LIBCWD_USE_EXTERNAL_C_LINKAGE_FOR_MALLOC)
LIBCWD_ASSERT( _private_::WST_ios_base_initialized || __libcwd_tsd.internal );
#endif
if (__libcwd_tsd.internal)
{
- LIBCWD_DEBUGM_CERR( "DEBUGDEBUGMALLOC: Internal: Entering `__libcwd_malloc(" << size << ")' [" << saved_marker << ']' );
+ LIBCWD_DEBUGM_CERR( "CWDEBUG_DEBUGM: Internal: Entering `__libcwd_malloc(" << size << ")' [" << saved_marker << ']' );
-#if !defined(DEBUGDEBUGMALLOC) && !defined(DEBUGMAGICMALLOC)
+#if !CWDEBUG_DEBUGM && !CWDEBUG_MAGIC
return __libc_malloc(size);
-#else // defined(DEBUGDEBUGMALLOC) || defined(DEBUGMAGICMALLOC)
+#else // CWDEBUG_DEBUGM || CWDEBUG_MAGIC
-#ifndef DEBUGMAGICMALLOC
+#if !CWDEBUG_MAGIC
void* ptr = __libc_malloc(size);
- LIBCWD_DEBUGM_CERR( "DEBUGDEBUGMALLOC: Internal: Leaving `__libcwd_malloc': " << ptr << " [" << saved_marker << ']' );
+ LIBCWD_DEBUGM_CERR( "CWDEBUG_DEBUGM: Internal: Leaving `__libcwd_malloc': " << ptr << " [" << saved_marker << ']' );
return ptr;
-#else // DEBUGMAGICMALLOC
+#else // CWDEBUG_MAGIC
void* ptr = __libc_malloc(SIZE_PLUS_TWELVE(size));
if (!ptr)
return NULL;
((size_t*)ptr)[0] = INTERNAL_MAGIC_MALLOC_BEGIN;
((size_t*)ptr)[1] = size;
((size_t*)(static_cast<char*>(ptr) + SIZE_PLUS_TWELVE(size)))[-1] = INTERNAL_MAGIC_MALLOC_END;
- LIBCWD_DEBUGM_CERR( "DEBUGDEBUGMALLOC: Internal: Leaving `__libcwd_malloc': " << static_cast<size_t*>(ptr) + 2 << " [" << saved_marker << ']' );
+ LIBCWD_DEBUGM_CERR( "CWDEBUG_DEBUGM: Internal: Leaving `__libcwd_malloc': " << static_cast<size_t*>(ptr) + 2 << " [" << saved_marker << ']' );
return static_cast<size_t*>(ptr) + 2;
-#endif // DEBUGMAGICMALLOC
+#endif // CWDEBUG_MAGIC
-#endif // defined(DEBUGDEBUGMALLOC) || defined(DEBUGMAGICMALLOC)
+#endif // CWDEBUG_DEBUGM || CWDEBUG_MAGIC
} // internal
++__libcwd_tsd.inside_malloc_or_free;
-#if defined(DEBUGDEBUGMALLOC) && defined(DEBUGDEBUGOUTPUT)
+#if CWDEBUG_DEBUGM && CWDEBUG_DEBUGOUTPUT
DoutInternal( dc_malloc|continued_cf, "malloc(" << size << ") = [" << saved_marker << ']' );
#else
DoutInternal( dc_malloc|continued_cf, "malloc(" << size << ") = " );
#endif
void* ptr = internal_malloc(size, memblk_type_malloc CALL_ADDRESS LIBCWD_COMMA_TSD SAVEDMARKER);
-#ifdef DEBUGMAGICMALLOC
+#if CWDEBUG_MAGIC
if (ptr)
{
((size_t*)ptr)[-2] = MAGIC_MALLOC_BEGIN;
@@ -2197,33 +2197,33 @@
void* __libcwd_calloc(size_t nmemb, size_t size)
{
LIBCWD_TSD_DECLARATION
-#ifdef DEBUGDEBUGMALLOC
+#if CWDEBUG_DEBUGM
// We can't use `assert' here, because that can call malloc.
if (__libcwd_tsd.inside_malloc_or_free > __libcwd_tsd.library_call && !__libcwd_tsd.internal)
{
- LIBCWD_DEBUGM_CERR("DEBUGDEBUGMALLOC: debugmalloc.cc:" << __LINE__ - 2 << ": " << __PRETTY_FUNCTION__ << ": Assertion `__libcwd_tsd.inside_malloc_or_free <= __libcwd_tsd.library_call || __libcwd_tsd.internal' failed.");
+ LIBCWD_DEBUGM_CERR("CWDEBUG_DEBUGM: debugmalloc.cc:" << __LINE__ - 2 << ": " << __PRETTY_FUNCTION__ << ": Assertion `__libcwd_tsd.inside_malloc_or_free <= __libcwd_tsd.library_call || __libcwd_tsd.internal' failed.");
core_dump();
}
-#ifdef DEBUGDEBUGOUTPUT
+#if CWDEBUG_DEBUGOUTPUT
int saved_marker = ++__libcwd_tsd.marker;
#endif
#endif
-#if defined(DEBUGDEBUGMALLOC) && defined(__GLIBCPP__) && !defined(LIBCWD_USE_EXTERNAL_C_LINKAGE_FOR_MALLOC)
+#if CWDEBUG_DEBUGM && defined(__GLIBCPP__) && !defined(LIBCWD_USE_EXTERNAL_C_LINKAGE_FOR_MALLOC)
LIBCWD_ASSERT( _private_::WST_ios_base_initialized || __libcwd_tsd.internal );
#endif
if (__libcwd_tsd.internal)
{
- LIBCWD_DEBUGM_CERR( "DEBUGDEBUGMALLOC: Internal: Entering `__libcwd_calloc(" << nmemb << ", " << size << ")' [" << saved_marker << ']' );
+ LIBCWD_DEBUGM_CERR( "CWDEBUG_DEBUGM: Internal: Entering `__libcwd_calloc(" << nmemb << ", " << size << ")' [" << saved_marker << ']' );
-#if !defined(DEBUGDEBUGMALLOC) && !defined(DEBUGMAGICMALLOC)
+#if !CWDEBUG_DEBUGM && !CWDEBUG_MAGIC
return __libc_calloc(nmemb, size);
-#else // defined(DEBUGDEBUGMALLOC) || defined(DEBUGMAGICMALLOC)
+#else // CWDEBUG_DEBUGM || CWDEBUG_MAGIC
-#ifndef DEBUGMAGICMALLOC
+#if !CWDEBUG_MAGIC
void* ptr = __libc_calloc(nmemb, size);
- LIBCWD_DEBUGM_CERR( "DEBUGDEBUGMALLOC: Internal: Leaving `__libcwd_calloc': " << ptr << " [" << saved_marker << ']' );
+ LIBCWD_DEBUGM_CERR( "CWDEBUG_DEBUGM: Internal: Leaving `__libcwd_calloc': " << ptr << " [" << saved_marker << ']' );
return ptr;
-#else // DEBUGMAGICMALLOC
+#else // CWDEBUG_MAGIC
void* ptr = __libc_malloc(SIZE_PLUS_TWELVE(nmemb * size));
if (!ptr)
return NULL;
@@ -2231,15 +2231,15 @@
((size_t*)ptr)[0] = INTERNAL_MAGIC_MALLOC_BEGIN;
((size_t*)ptr)[1] = nmemb * size;
((size_t*)(static_cast<char*>(ptr) + SIZE_PLUS_TWELVE(nmemb * size)))[-1] = INTERNAL_MAGIC_MALLOC_END;
- LIBCWD_DEBUGM_CERR( "DEBUGDEBUGMALLOC: Internal: Leaving `__libcwd_calloc': " << static_cast<size_t*>(ptr) + 2 << " [" << saved_marker << ']' );
+ LIBCWD_DEBUGM_CERR( "CWDEBUG_DEBUGM: Internal: Leaving `__libcwd_calloc': " << static_cast<size_t*>(ptr) + 2 << " [" << saved_marker << ']' );
return static_cast<size_t*>(ptr) + 2;
-#endif // DEBUGMAGICMALLOC
+#endif // CWDEBUG_MAGIC
-#endif // defined(DEBUGDEBUGMALLOC) || defined(DEBUGMAGICMALLOC)
+#endif // CWDEBUG_DEBUGM || CWDEBUG_MAGIC
} // internal
++__libcwd_tsd.inside_malloc_or_free;
-#if defined(DEBUGDEBUGMALLOC) && defined(DEBUGDEBUGOUTPUT)
+#if CWDEBUG_DEBUGM && CWDEBUG_DEBUGOUTPUT
DoutInternal( dc_malloc|continued_cf, "calloc(" << nmemb << ", " << size << ") = [" << saved_marker << ']' );
#else
DoutInternal( dc_malloc|continued_cf, "calloc(" << nmemb << ", " << size << ") = " );
@@ -2248,7 +2248,7 @@
size *= nmemb;
if ((ptr = internal_malloc(size, memblk_type_malloc CALL_ADDRESS LIBCWD_COMMA_TSD SAVEDMARKER)))
memset(ptr, 0, size);
-#ifdef DEBUGMAGICMALLOC
+#if CWDEBUG_MAGIC
if (ptr)
{
((size_t*)ptr)[-2] = MAGIC_MALLOC_BEGIN;
@@ -2270,33 +2270,33 @@
void* __libcwd_realloc(void* ptr, size_t size)
{
LIBCWD_TSD_DECLARATION
-#ifdef DEBUGDEBUGMALLOC
+#if CWDEBUG_DEBUGM
// We can't use `assert' here, because that can call malloc.
if (__libcwd_tsd.inside_malloc_or_free > __libcwd_tsd.library_call && !__libcwd_tsd.internal)
{
- LIBCWD_DEBUGM_CERR("DEBUGDEBUGMALLOC: debugmalloc.cc:" << __LINE__ - 2 << ": " << __PRETTY_FUNCTION__ << ": Assertion `__libcwd_tsd.inside_malloc_or_free <= __libcwd_tsd.library_call || __libcwd_tsd.internal' failed.");
+ LIBCWD_DEBUGM_CERR("CWDEBUG_DEBUGM: debugmalloc.cc:" << __LINE__ - 2 << ": " << __PRETTY_FUNCTION__ << ": Assertion `__libcwd_tsd.inside_malloc_or_free <= __libcwd_tsd.library_call || __libcwd_tsd.internal' failed.");
core_dump();
}
-#ifdef DEBUGDEBUGOUTPUT
+#if CWDEBUG_DEBUGOUTPUT
int saved_marker = ++__libcwd_tsd.marker;
#endif
#endif
-#if defined(DEBUGDEBUGMALLOC) && defined(__GLIBCPP__) && !defined(LIBCWD_USE_EXTERNAL_C_LINKAGE_FOR_MALLOC)
+#if CWDEBUG_DEBUGM && defined(__GLIBCPP__) && !defined(LIBCWD_USE_EXTERNAL_C_LINKAGE_FOR_MALLOC)
LIBCWD_ASSERT( _private_::WST_ios_base_initialized || __libcwd_tsd.internal );
#endif
if (__libcwd_tsd.internal)
{
- LIBCWD_DEBUGM_CERR( "DEBUGDEBUGMALLOC: Internal: Entering `__libcwd_realloc(" << ptr << ", " << size << ")' [" << saved_marker << ']' );
+ LIBCWD_DEBUGM_CERR( "CWDEBUG_DEBUGM: Internal: Entering `__libcwd_realloc(" << ptr << ", " << size << ")' [" << saved_marker << ']' );
-#if !defined(DEBUGDEBUGMALLOC) && !defined(DEBUGMAGICMALLOC)
+#if !CWDEBUG_DEBUGM && !CWDEBUG_MAGIC
return __libc_realloc(ptr, size);
-#else // defined(DEBUGDEBUGMALLOC) || defined(DEBUGMAGICMALLOC)
+#else // CWDEBUG_DEBUGM || CWDEBUG_MAGIC
-#ifndef DEBUGMAGICMALLOC
+#if !CWDEBUG_MAGIC
void* ptr1 = __libc_realloc(ptr, size);
- LIBCWD_DEBUGM_CERR( "DEBUGDEBUGMALLOC: Internal: Leaving `__libcwd_realloc': " << ptr1 << " [" << saved_marker << ']' );
+ LIBCWD_DEBUGM_CERR( "CWDEBUG_DEBUGM: Internal: Leaving `__libcwd_realloc': " << ptr1 << " [" << saved_marker << ']' );
return ptr1;
-#else // DEBUGMAGICMALLOC
+#else // CWDEBUG_MAGIC
void* ptr1;
if (ptr)
{
@@ -2307,7 +2307,7 @@
if (size == 0)
{
__libc_free(ptr);
- LIBCWD_DEBUGM_CERR( "DEBUGDEBUGMALLOC: Internal: Leaving `__libcwd_realloc': NULL [" << saved_marker << ']' );
+ LIBCWD_DEBUGM_CERR( "CWDEBUG_DEBUGM: Internal: Leaving `__libcwd_realloc': NULL [" << saved_marker << ']' );
return NULL;
}
ptr1 = __libc_realloc(ptr, SIZE_PLUS_TWELVE(size));
@@ -2317,15 +2317,15 @@
((size_t*)ptr1)[0] = INTERNAL_MAGIC_MALLOC_BEGIN;
((size_t*)ptr1)[1] = size;
((size_t*)(static_cast<char*>(ptr1) + SIZE_PLUS_TWELVE(size...
[truncated message content] |