diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2010-01-26 10:06:53 +0100 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2010-01-26 10:06:53 +0100 |
commit | e4850f2eeb0e4e137b2f9f7f3a63fdf4661fc498 (patch) | |
tree | ea22fc744e2a297bb2422d36b4464382c1587908 /include/log.h | |
parent | b334372ef8a21c54695f80565ff2c27d92efb5f3 (diff) | |
download | ofono-e4850f2eeb0e4e137b2f9f7f3a63fdf4661fc498.tar.bz2 |
Add support for dynamic debug feature
Diffstat (limited to 'include/log.h')
-rw-r--r-- | include/log.h | 18 |
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 } |