summaryrefslogtreecommitdiffstats
path: root/include/log.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/log.h')
-rw-r--r--include/log.h18
1 files changed, 17 insertions, 1 deletions
diff --git a/include/log.h b/include/log.h
index 67014ad3..d1fef7b6 100644
--- a/include/log.h
+++ b/include/log.h
@@ -41,6 +41,14 @@ extern void ofono_error(const char *format, ...)
extern void ofono_debug(const char *format, ...)
__attribute__((format(printf, 1, 2)));
+struct ofono_debug_desc {
+ const char *name;
+ const char *file;
+#define OFONO_DEBUG_FLAG_DEFAULT (0)
+#define OFONO_DEBUG_FLAG_PRINT (1 << 0)
+ unsigned int flags;
+} __attribute__((aligned(8)));
+
/**
* DBG:
* @fmt: format string
@@ -49,7 +57,15 @@ extern void ofono_debug(const char *format, ...)
* Simple macro around ofono_debug() which also include the function
* name it is called in.
*/
-#define DBG(fmt, arg...) ofono_debug("%s:%s() " fmt, __FILE__, __FUNCTION__ , ## arg)
+#define DBG(fmt, arg...) do { \
+ static struct ofono_debug_desc __ofono_debug_desc \
+ __attribute__((used, section("__debug"), aligned(8))) = { \
+ .file = __FILE__, .flags = OFONO_DEBUG_FLAG_DEFAULT, \
+ }; \
+ if (__ofono_debug_desc.flags & OFONO_DEBUG_FLAG_PRINT) \
+ ofono_debug("%s:%s() " fmt, \
+ __FILE__, __FUNCTION__ , ## arg); \
+} while (0)
#ifdef __cplusplus
}