summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorschodet2010-01-20 17:05:39 +0000
committerschodet2010-01-20 17:05:39 +0000
commit47412fba99ff58a28f9df7f28ff876efbd6630ca (patch)
treeab1296a84bd2cddce5b76431e6b9e5e651aa7e87
parent5e5c0d21112f0377885e04c419cf5e096b0c6f3e (diff)
cesar/lib/dbg: add terse debug variant
If CONFIG_DEBUG_TERSE is enabled, less information is output to gain code space. git-svn-id: svn+ssh://pessac/svn/cesar/trunk@6638 017c9cb6-072f-447c-8318-d5b54f68fe89
-rw-r--r--cesar/lib/Config1
-rw-r--r--cesar/lib/dbg.h59
-rw-r--r--cesar/lib/src/dbg.c6
3 files changed, 48 insertions, 18 deletions
diff --git a/cesar/lib/Config b/cesar/lib/Config
index 518e10416e..d4b2ec6c71 100644
--- a/cesar/lib/Config
+++ b/cesar/lib/Config
@@ -1,5 +1,6 @@
CONFIG_DEBUG = y
CONFIG_DEBUG_CLAIM = y
+CONFIG_DEBUG_TERSE = n
CONFIG_DEBUG_MORE = n
CONFIG_DEBUG_FATAL_CATCH = n
CONFIG_BLAME = n
diff --git a/cesar/lib/dbg.h b/cesar/lib/dbg.h
index 858e41d45e..e3fa337cb9 100644
--- a/cesar/lib/dbg.h
+++ b/cesar/lib/dbg.h
@@ -23,6 +23,11 @@
* If activated, costly debugs are activated. */
#define DEBUG_MORE CONFIG_DEBUG_MORE
+/** Blaming cannot be terse. */
+#if CONFIG_DEBUG_TERSE && CONFIG_BLAME
+# error "CONFIG_DEBUG_TERSE and CONFIG_BLAME are not compatibles"
+#endif
+
#if DEBUG && CONFIG_DEBUG_FATAL_CATCH
# include "lib/try.h"
#endif
@@ -203,39 +208,50 @@
# define dbg_blame_default_ dbg_assert_default__
# endif
+# if !CONFIG_DEBUG_TERSE
+# define dbg_assert_fail_ dbg_assert_fail
+# define dbg_assert_print_fail_(fmt, file, line, function, rest...) \
+ dbg_assert_print_fail (DBG_ASSERT_FMT_ fmt, file, line, \
+ function, ## rest)
+# else
+# define dbg_assert_fail_(message, file, line, function) \
+ dbg_assert_fail_terse (file ":" #line ": assertion failure: " message)
+# define dbg_assert_print_fail_(fmt, file, line, function, rest...) \
+ dbg_assert_fail_terse (file ":" #line ": assertion failure: " fmt)
+# endif
+
# define dbg_void__(args...) ((void) 0)
# define dbg_assert__(expr, exprs) \
- ((void) ((expr) ? 0 : (dbg_assert_fail (exprs, __FILE__, __LINE__, \
- __PRETTY_FUNCTION__), 0)))
+ ((void) ((expr) ? 0 : (dbg_assert_fail_ (exprs, __FILE__, __LINE__, \
+ __PRETTY_FUNCTION__), 0)))
# define dbg_assert_ptr__(ptr, ptrs) \
((void) ((ptr && ptr != INVALID_PTR) ? 0 : \
- (dbg_assert_fail ("@" ptrs, __FILE__, __LINE__, \
- __PRETTY_FUNCTION__), 0)))
+ (dbg_assert_fail_ ("@" ptrs, __FILE__, __LINE__, \
+ __PRETTY_FUNCTION__), 0)))
# define dbg_assert_print__(expr, fmt, rest...) \
- ((void) ((expr) ? 0 : (dbg_assert_print_fail (DBG_ASSERT_FMT_ fmt, \
- __FILE__, __LINE__, \
- __PRETTY_FUNCTION__, \
- ##rest), 0)))
+ ((void) ((expr) ? 0 : (dbg_assert_print_fail_ (fmt, __FILE__, __LINE__, \
+ __PRETTY_FUNCTION__ \
+ , ##rest)), 0))
# define dbg_assert_perror__(expr, exprs) \
((void) ((expr) ? 0 : (dbg_assert_perror_fail (exprs, __FILE__, __LINE__, \
__PRETTY_FUNCTION__), 0)))
# define dbg_assert_default__() \
- dbg_assert_fail ("unexpected default case", __FILE__, __LINE__, \
- __PRETTY_FUNCTION__)
+ dbg_assert_fail_ ("unexpected default case", __FILE__, __LINE__, \
+ __PRETTY_FUNCTION__)
# define dbg_blame__(expr, exprs) \
- ((void) ((expr) ? 0 : (dbg_assert_fail (exprs, _fl_, \
- __PRETTY_FUNCTION__), 0)))
+ ((void) ((expr) ? 0 : (dbg_assert_fail_ (exprs, _fl_, \
+ __PRETTY_FUNCTION__), 0)))
# define dbg_blame_ptr__(ptr, ptrs) \
((void) ((ptr && ptr != INVALID_PTR) ? 0 : \
- (dbg_assert_fail ("@" ptrs, _fl_, __PRETTY_FUNCTION__), 0)))
+ (dbg_assert_fail_ ("@" ptrs, _fl_, __PRETTY_FUNCTION__), 0)))
# define dbg_blame_print__(expr, fmt, rest...) \
- ((void) ((expr) ? 0 : (dbg_assert_print_fail (DBG_ASSERT_FMT_ fmt, \
- _fl_, __PRETTY_FUNCTION__, \
- ##rest), 0)))
+ ((void) ((expr) ? 0 : (dbg_assert_print_fail_ (fmt, _fl_, \
+ __PRETTY_FUNCTION__ \
+ , ##rest), 0)))
# define dbg_blame_default__() \
- dbg_assert_fail ("unexpected default case", _fl_, \
- __PRETTY_FUNCTION__)
+ dbg_assert_fail_ ("unexpected default case", _fl_, \
+ __PRETTY_FUNCTION__)
#else /* !DEBUG */
@@ -390,6 +406,13 @@ dbg_assert_fail (const char *assertion, const char *file, uint line,
const char *function) __attribute__ ((__noreturn__));
/**
+ * Called on assertion failure, terse version.
+ * \param message message text
+ */
+void
+dbg_assert_fail_terse (const char *message) __attribute__ ((__noreturn__));
+
+/**
* Called on assertion failure with more information on failure.
* \param fmt printf-like format string
*/
diff --git a/cesar/lib/src/dbg.c b/cesar/lib/src/dbg.c
index 5bd2b41e95..caa3945ac6 100644
--- a/cesar/lib/src/dbg.c
+++ b/cesar/lib/src/dbg.c
@@ -37,6 +37,12 @@ dbg_assert_fail (const char *assertion, const char *file, uint line,
}
void
+dbg_assert_fail_terse (const char *message)
+{
+ dbg_fatal ("%s", message);
+}
+
+void
dbg_assert_print_fail (const char *fmt, ...)
{
va_list ap;