Debug Mode Lite
Jonathan Wakely
jwakely.gcc@gmail.com
Mon Jun 16 07:33:00 GMT 2014
On 16 June 2014 08:30, Jonathan Wakely wrote:
> I think we should enable _GLIBCXX_ASSERT checks under more conditions,
> e.g. if the user defines _GLIBCXX_DEBUG_LITE, to enable all low-cost
> debug checks that have no ABI impact, such as range checks in vectors,
> non-null checks dereferencing smart pointers.
>
> The full _GLIBCXX_DEBUG mode alters too much and requires rebuilding
> all relevant objects.
>
> A lot of our existing _GLIBCXX_ASSERT checks are cheap anyway, the
> ones that aren't should be moved to a new macro that's only enable by
> the full _GLIBCXX_DEBUG macro. There are some interesting additional
> checks in the Google svn branch that should be turned on by the "lite"
> mode.
>
> (Please suggest a better name, I hate the word "Lite" :-)
Here's a patch to show what I mean (this isn't tested and doesn't
disable any more expensive checks).
-------------- next part --------------
commit 706b545f5f4c067260d1412a7820badc9b380c13
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Thu Jun 12 22:28:30 2014 +0100
Enable _GLIBCXX_ASSERT for LITE
diff --git a/libstdc++-v3/include/bits/c++config b/libstdc++-v3/include/bits/c++config
index ff6afc8..1a7f793 100644
--- a/libstdc++-v3/include/bits/c++config
+++ b/libstdc++-v3/include/bits/c++config
@@ -361,7 +361,8 @@ namespace std
#endif
// Assert.
-#if !defined(_GLIBCXX_DEBUG) && !defined(_GLIBCXX_PARALLEL)
+#if !defined(_GLIBCXX_DEBUG) && !defined(_GLIBCXX_PARALLEL) \
+ && !defined(_GLIBCXX_DEBUG_LITE)
# define __glibcxx_assert(_Condition)
#else
namespace std
diff --git a/libstdc++-v3/include/debug/debug.h b/libstdc++-v3/include/debug/debug.h
index 1b37471..733d98e 100644
--- a/libstdc++-v3/include/debug/debug.h
+++ b/libstdc++-v3/include/debug/debug.h
@@ -58,7 +58,12 @@ namespace __gnu_debug
#ifndef _GLIBCXX_DEBUG
-# define _GLIBCXX_DEBUG_ASSERT(_Condition)
+# ifdef _GLIBCXX_DEBUG_LITE
+# define _GLIBCXX_DEBUG_ASSERT(_Condition) __glibcxx_assert(_Condition)
+# else
+# define _GLIBCXX_DEBUG_ASSERT(_Condition)
+# endif
+
# define _GLIBCXX_DEBUG_PEDASSERT(_Condition)
# define _GLIBCXX_DEBUG_ONLY(_Statement) ;
# define __glibcxx_requires_cond(_Cond,_Msg)
More information about the Libstdc++
mailing list