From a124e7bd22445ce90fc39419268d1b27e74ffd45 Mon Sep 17 00:00:00 2001 From: bernard Date: Wed, 24 Jul 2013 07:33:48 +0800 Subject: add initialization debug code --- include/rtdebug.h | 4 ++++ include/rtdef.h | 16 ++++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/rtdebug.h b/include/rtdebug.h index adcea8a8bf..ebf85d6dba 100644 --- a/include/rtdebug.h +++ b/include/rtdebug.h @@ -63,6 +63,10 @@ #define RT_DEBUG_IPC 0 #endif +#ifndef RT_DEBUG_INIT +#define RT_DEBUG_INIT 0 +#endif + /* Turn on this to enable context check */ #ifndef RT_DEBUG_CONTEXT_CHECK #define RT_DEBUG_CONTEXT_CHECK 1 diff --git a/include/rtdef.h b/include/rtdef.h index 1d64ae54f4..a3d13bfc44 100644 --- a/include/rtdef.h +++ b/include/rtdef.h @@ -181,8 +181,20 @@ typedef int (*init_fn_t)(void); #ifdef _MSC_VER /* we do not support MS VC++ compiler */ #define INIT_EXPORT(fn, level) #else - #define INIT_EXPORT(fn, level) \ - const init_fn_t __rt_init_##fn SECTION(".rti_fn."level) = fn + #if RT_DEBUG_INIT + struct rt_init_desc + { + const char* fn_name; + const init_fn_t fn; + }; + #define INIT_EXPORT(fn, level) \ + const char __rti_##fn##_name[] = #fn; \ + const struct rt_init_desc __rt_init_desc_##fn SECTION(".rti_fn."level) = \ + { __rti_##fn##_name, fn}; + #else + #define INIT_EXPORT(fn, level) \ + const init_fn_t __rt_init_##fn SECTION(".rti_fn."level) = fn + #endif #endif #else #define INIT_EXPORT(fn, level) -- cgit v1.3.1