| 1 | /*************************************************************************** |
|---|
| 2 | * Copyright (c) 2003-2012, Broadcom Corporation |
|---|
| 3 | * All Rights Reserved |
|---|
| 4 | * Confidential Property of Broadcom Corporation |
|---|
| 5 | * |
|---|
| 6 | * THIS SOFTWARE MAY ONLY BE USED SUBJECT TO AN EXECUTED SOFTWARE LICENSE |
|---|
| 7 | * AGREEMENT BETWEEN THE USER AND BROADCOM. YOU HAVE NO RIGHT TO USE OR |
|---|
| 8 | * EXPLOIT THIS MATERIAL EXCEPT SUBJECT TO THE TERMS OF SUCH AN AGREEMENT. |
|---|
| 9 | * |
|---|
| 10 | * $brcm_Workfile: bdbg.h $ |
|---|
| 11 | * $brcm_Revision: Hydra_Software_Devel/55 $ |
|---|
| 12 | * $brcm_Date: 2/22/12 1:44p $ |
|---|
| 13 | * |
|---|
| 14 | * Module Description: |
|---|
| 15 | * |
|---|
| 16 | * Revision History: |
|---|
| 17 | * |
|---|
| 18 | * $brcm_Log: /magnum/basemodules/dbg/bdbg.h $ |
|---|
| 19 | * |
|---|
| 20 | * Hydra_Software_Devel/55 2/22/12 1:44p erickson |
|---|
| 21 | * SW7425-2130: be consistent on #if, not #ifdef |
|---|
| 22 | * |
|---|
| 23 | * Hydra_Software_Devel/54 2/22/12 12:16p erickson |
|---|
| 24 | * SW7425-2130: fix last checkin |
|---|
| 25 | * |
|---|
| 26 | * Hydra_Software_Devel/53 2/22/12 12:01p erickson |
|---|
| 27 | * SW7425-2130: fix B_REFSW_DEBUG=n mode |
|---|
| 28 | * |
|---|
| 29 | * Hydra_Software_Devel/52 2/21/12 1:59p erickson |
|---|
| 30 | * SW7425-2130: add new DBG options for compact debug mode |
|---|
| 31 | * |
|---|
| 32 | * Hydra_Software_Devel/51 9/2/11 6:23p vsilyaev |
|---|
| 33 | * SW7425-1103: Added BDBG_CWARNING |
|---|
| 34 | * |
|---|
| 35 | * Hydra_Software_Devel/50 6/21/11 11:23a vsilyaev |
|---|
| 36 | * SW7420-1640: Fixed defintion of BDBG_P_INSTANCE_PRINTMSG_PRIV |
|---|
| 37 | * |
|---|
| 38 | * Hydra_Software_Devel/49 6/17/11 11:06a vsilyaev |
|---|
| 39 | * SW7420-1640: Added missing BDBG_P_INSTANCE_PRINTMSG_PRIV |
|---|
| 40 | * |
|---|
| 41 | * Hydra_Software_Devel/48 6/16/11 1:54p vsilyaev |
|---|
| 42 | * SW7425-729: Added missing defines for LOG level |
|---|
| 43 | * |
|---|
| 44 | * Hydra_Software_Devel/47 6/16/11 1:40p vsilyaev |
|---|
| 45 | * SW7425-729,SW7400-3012: Added LOG level |
|---|
| 46 | * |
|---|
| 47 | * Hydra_Software_Devel/46 6/16/11 11:12a vsilyaev |
|---|
| 48 | * SW7420-1640: Streamlined Android |
|---|
| 49 | * |
|---|
| 50 | * Hydra_Software_Devel/45 6/6/11 3:27p vsilyaev |
|---|
| 51 | * SW7405-4477: Routed all debug output through buffer and use external |
|---|
| 52 | * application to extract and print debug output |
|---|
| 53 | * |
|---|
| 54 | * Hydra_Software_Devel/44 4/22/11 7:46p vsilyaev |
|---|
| 55 | * SW7125-918, SW7405-4477: Fixed definitions of the multi module debug |
|---|
| 56 | * output |
|---|
| 57 | * |
|---|
| 58 | * Hydra_Software_Devel/43 4/20/11 10:10a ttrammel |
|---|
| 59 | * SW7420-1640: Merge Android logging into main branch. |
|---|
| 60 | * |
|---|
| 61 | * Hydra_Software_Devel/42 4/13/11 7:00p vsilyaev |
|---|
| 62 | * SW7405-5221: Route BERR_TRACE through the debug log |
|---|
| 63 | * |
|---|
| 64 | * Hydra_Software_Devel/41 1/13/11 3:40p erickson |
|---|
| 65 | * SWDEPRECATED-2425: consolidate BDBG_OBJECT example code |
|---|
| 66 | * |
|---|
| 67 | * Hydra_Software_Devel/40 1/5/11 6:40p vsilyaev |
|---|
| 68 | * SW7405-4477: Changed names to match ones used in the ticket |
|---|
| 69 | * |
|---|
| 70 | * Hydra_Software_Devel/39 1/5/11 6:30p vsilyaev |
|---|
| 71 | * SW7405-4477: Added BDBG_XXX_EXT to support multiple modules in the same |
|---|
| 72 | * compilation unit (C file) |
|---|
| 73 | * |
|---|
| 74 | * Hydra_Software_Devel/38 12/1/10 12:41p vsilyaev |
|---|
| 75 | * SWDEPRECATED-1626: Stricter and safer BDBG_CASSERT |
|---|
| 76 | * |
|---|
| 77 | * Hydra_Software_Devel/37 8/12/10 6:19p ttrammel |
|---|
| 78 | * SW7420-943: Fix NFE merge issue. |
|---|
| 79 | * |
|---|
| 80 | * Hydra_Software_Devel/36 8/12/10 4:39p ttrammel |
|---|
| 81 | * SW7420-943: Merge NFE to main branch. |
|---|
| 82 | * |
|---|
| 83 | * Hydra_Software_Devel/35 7/7/10 11:48a vsilyaev |
|---|
| 84 | * SW7420-867: Moved application level API into the bdbg_app.h |
|---|
| 85 | * |
|---|
| 86 | * Hydra_Software_Devel/34 6/25/10 6:26p jgarrett |
|---|
| 87 | * SW7408-88: Removing implicit global from BDBG_OBJECT_DESTROY |
|---|
| 88 | * |
|---|
| 89 | * Hydra_Software_Devel/33 10/14/09 6:52p vsilyaev |
|---|
| 90 | * SW7405-3211: Use constant pointers in BDBG_Object_Assert |
|---|
| 91 | * |
|---|
| 92 | * Hydra_Software_Devel/32 6/24/09 2:25p mphillip |
|---|
| 93 | * PR54926: Merge DBG extension to /main |
|---|
| 94 | * |
|---|
| 95 | * Hydra_Software_Devel/PR54926/1 5/18/09 6:57p vsilyaev |
|---|
| 96 | * PR 54926: Added interface to capture debug output |
|---|
| 97 | * |
|---|
| 98 | * Hydra_Software_Devel/31 4/8/09 4:23p vsilyaev |
|---|
| 99 | * PR 54015: Don't include bkni_multi.h into the bdbg.h. All thread-aware |
|---|
| 100 | * modules should include explicitly bkni_multi.h |
|---|
| 101 | * |
|---|
| 102 | * Hydra_Software_Devel/30 2/19/09 6:45p vsilyaev |
|---|
| 103 | * PR 52320: Added BDBG_RELEASE macro to unwind module from BDBG |
|---|
| 104 | * |
|---|
| 105 | * Hydra_Software_Devel/29 12/29/08 1:32p erickson |
|---|
| 106 | * PR50746: make BDBG_OBJECT_ASSERT failures more helpful |
|---|
| 107 | * |
|---|
| 108 | * Hydra_Software_Devel/28 7/22/08 12:30p nilesh |
|---|
| 109 | * PR44846: Added support for setting instance levels on a per module |
|---|
| 110 | * basis |
|---|
| 111 | * |
|---|
| 112 | * Hydra_Software_Devel/27 8/15/07 2:25p vsilyaev |
|---|
| 113 | * PR 34089: Optimized executuion speed and code size |
|---|
| 114 | * |
|---|
| 115 | * Hydra_Software_Devel/26 5/4/07 12:14p vsilyaev |
|---|
| 116 | * PR 25469: Added function BDBG_EnumerateAll |
|---|
| 117 | * |
|---|
| 118 | * Hydra_Software_Devel/25 3/26/07 4:53p vsilyaev |
|---|
| 119 | * PR 27425: Fixed use of arguments in the BDBG_OBJECT macros |
|---|
| 120 | * |
|---|
| 121 | * Hydra_Software_Devel/24 1/30/07 11:03a vsilyaev |
|---|
| 122 | * PR 27425: Proofread documentation and expaned BDBG_OBJECT portion |
|---|
| 123 | * |
|---|
| 124 | * Hydra_Software_Devel/23 9/14/06 11:13a jgarrett |
|---|
| 125 | * PR 23982: Adding BDBG_NOP to reduce release-mode warnings |
|---|
| 126 | * |
|---|
| 127 | * Hydra_Software_Devel/22 7/26/06 4:51p vsilyaev |
|---|
| 128 | * PR 22695:Fixed issue with previous commit |
|---|
| 129 | * |
|---|
| 130 | * Hydra_Software_Devel/21 7/25/06 10:42a vsilyaev |
|---|
| 131 | * PR 22695: Pulled the debug output routines into the release build |
|---|
| 132 | * |
|---|
| 133 | * Hydra_Software_Devel/20 7/21/06 11:28a vsilyaev |
|---|
| 134 | * PR 22695: Changes in the BDBG module to make it run-time compatible |
|---|
| 135 | * between debug and release builds |
|---|
| 136 | * |
|---|
| 137 | * Hydra_Software_Devel/19 5/1/06 5:16p vsilyaev |
|---|
| 138 | * PR 21336: PR 21258: Added BDBG_CASSERT, modified BDBG_OBJECT_ID to |
|---|
| 139 | * include semicolon |
|---|
| 140 | * |
|---|
| 141 | * Hydra_Software_Devel/18 4/27/06 10:06a vle |
|---|
| 142 | * PR 21065: rework BDBG_LOCK and BDBG_UNLOCK to be OS specific |
|---|
| 143 | * implementation. |
|---|
| 144 | * |
|---|
| 145 | * Hydra_Software_Devel/17 2/27/06 5:12p vsilyaev |
|---|
| 146 | * PR 19917: Added API to check object types at runtime |
|---|
| 147 | * |
|---|
| 148 | * Hydra_Software_Devel/16 11/29/05 3:14p vle |
|---|
| 149 | * PR18319: add timestamp to debug messages |
|---|
| 150 | * |
|---|
| 151 | * Hydra_Software_Devel/15 10/5/04 7:49p vsilyaev |
|---|
| 152 | * PR 12726: Fixed warnings generated in the Release build. |
|---|
| 153 | * |
|---|
| 154 | * Hydra_Software_Devel/14 6/17/04 3:20p erickson |
|---|
| 155 | * PR11135: fixed type in release build of BDBG_GetModuleLevel |
|---|
| 156 | * |
|---|
| 157 | * Hydra_Software_Devel/13 12/29/03 11:24a vsilyaev |
|---|
| 158 | * PR 9131: Added implementation note for the redirecting debug output |
|---|
| 159 | * into the file. |
|---|
| 160 | * |
|---|
| 161 | * Hydra_Software_Devel/12 11/26/03 3:40p vsilyaev |
|---|
| 162 | * When code compiled by GNU C, declare bdbg_module as unused variable |
|---|
| 163 | * (fixed warning issue). |
|---|
| 164 | * |
|---|
| 165 | * Hydra_Software_Devel/11 11/13/03 1:53p vsilyaev |
|---|
| 166 | * Added Trace level to use by BDBG_ENTER and BDBG_LEAVE. |
|---|
| 167 | * |
|---|
| 168 | * Hydra_Software_Devel/10 11/13/03 9:33a vsilyaev |
|---|
| 169 | * Tag malloced and statically allocated memory, so only malloced will be |
|---|
| 170 | * free'ed at UnInit time. |
|---|
| 171 | * |
|---|
| 172 | * Hydra_Software_Devel/9 11/12/03 2:22p vsilyaev |
|---|
| 173 | * Use statically alllocated data for internal structures, it solves |
|---|
| 174 | * dilemma of malloc and interrupt. |
|---|
| 175 | * |
|---|
| 176 | * Hydra_Software_Devel/8 8/19/03 10:37a vsilyaev |
|---|
| 177 | * Use verbose initialiization for module to prevent warnings. |
|---|
| 178 | * |
|---|
| 179 | * Hydra_Software_Devel/7 4/1/03 9:42a vsilyaev |
|---|
| 180 | * Fixed release version of the debug interface. |
|---|
| 181 | * |
|---|
| 182 | * Hydra_Software_Devel/6 3/20/03 12:43p erickson |
|---|
| 183 | * removed dulicate BDBG_Instance decl |
|---|
| 184 | * |
|---|
| 185 | * Hydra_Software_Devel/5 3/12/03 6:33p vsilyaev |
|---|
| 186 | * Added description for BDBG_ASSERT macro and module overview. |
|---|
| 187 | * |
|---|
| 188 | * Hydra_Software_Devel/4 3/12/03 4:39p vsilyaev |
|---|
| 189 | * Added comments for the auto documentation tool. |
|---|
| 190 | * |
|---|
| 191 | * Hydra_Software_Devel/3 3/10/03 6:36p vsilyaev |
|---|
| 192 | * Uses extern "C" { } brackets. |
|---|
| 193 | * |
|---|
| 194 | * Hydra_Software_Devel/2 3/10/03 10:43a vsilyaev |
|---|
| 195 | * Integration with berr.h |
|---|
| 196 | * |
|---|
| 197 | * Hydra_Software_Devel/1 3/10/03 10:03a vsilyaev |
|---|
| 198 | * O/S inspecific part of the debug interface. |
|---|
| 199 | * |
|---|
| 200 | ***************************************************************************/ |
|---|
| 201 | |
|---|
| 202 | #ifndef BDBG_H |
|---|
| 203 | #define BDBG_H |
|---|
| 204 | |
|---|
| 205 | #if defined B_REFSW_ANDROID && !defined __KERNEL__ |
|---|
| 206 | #define LOG_TAG "NEXUS" |
|---|
| 207 | #include <cutils/log.h> |
|---|
| 208 | #endif |
|---|
| 209 | |
|---|
| 210 | #include "blst_slist.h" |
|---|
| 211 | |
|---|
| 212 | #ifdef __cplusplus |
|---|
| 213 | extern "C" { |
|---|
| 214 | #endif |
|---|
| 215 | |
|---|
| 216 | |
|---|
| 217 | #define ALCO 1 |
|---|
| 218 | //#define AOV_DISABLE_DBG |
|---|
| 219 | |
|---|
| 220 | #if 0 |
|---|
| 221 | #define AOV_DBG_PRINT(x) printf("%15s@%5d:%25s ", __FILE__,__LINE__,__FUNCTION__);printf x;printf("\n") |
|---|
| 222 | #define AOV_DBG_PRINT1() printf("*** %15s@%5d:%25s ***\n", __FILE__,__LINE__,__FUNCTION__) |
|---|
| 223 | #define AOV_DBG_PRINT2() printf("\n\n!!! %15s@%5d:%25s !!!\n\n",__FILE__,__LINE__,__FUNCTION__) |
|---|
| 224 | #else |
|---|
| 225 | #define AOV_DBG_PRINT(x) printf("%15s@%5d:%25s ", strrchr(__FILE__,'/')? strrchr(__FILE__,'/')+1 : __FILE__,__LINE__,__FUNCTION__);printf x;printf("\n") |
|---|
| 226 | #define AOV_DBG_PRINT1() printf("*** %15s@%5d:%25s ***\n", strrchr(__FILE__,'/')? strrchr(__FILE__,'/')+1 : __FILE__,__LINE__,__FUNCTION__) |
|---|
| 227 | #define AOV_DBG_PRINT2() printf("\n\n!!! %15s@%5d:%25s !!!\n\n",strrchr(__FILE__,'/')? strrchr(__FILE__,'/')+1 : __FILE__,__LINE__,__FUNCTION__) |
|---|
| 228 | #define AOV_DBG_PRINT3(x) printf("\n\n\n%15s@%5d:%25s", strrchr(__FILE__,'/')? strrchr(__FILE__,'/')+1 : __FILE__,__LINE__,__FUNCTION__);printf x;printf("\n\n\n") |
|---|
| 229 | |
|---|
| 230 | #define aov_dbg_print(x) printf("%15s@%5d:%25s ", strrchr(__FILE__,'/')? strrchr(__FILE__,'/')+1 : __FILE__,__LINE__,__FUNCTION__);printf x;printf("\n") |
|---|
| 231 | #define aov_dbg_print1() printf("*** %15s@%5d:%25s ***\n", strrchr(__FILE__,'/')? strrchr(__FILE__,'/')+1 : __FILE__,__LINE__,__FUNCTION__) |
|---|
| 232 | #define aov_dbg_print2() printf("\n\n!!! %15s@%5d:%25s !!!\n\n",strrchr(__FILE__,'/')? strrchr(__FILE__,'/')+1 : __FILE__,__LINE__,__FUNCTION__) |
|---|
| 233 | #define aov_dbg_print3(x) printf("\n\n\n%15s@%5d:%25s", strrchr(__FILE__,'/')? strrchr(__FILE__,'/')+1 : __FILE__,__LINE__,__FUNCTION__);printf x;printf("\n\n\n") |
|---|
| 234 | |
|---|
| 235 | #endif |
|---|
| 236 | |
|---|
| 237 | /*================== Module Overview ===================================== |
|---|
| 238 | This Debug Interface provides console output according to pre-defined levels |
|---|
| 239 | with compile-time and run-time control. |
|---|
| 240 | |
|---|
| 241 | Defined macros: |
|---|
| 242 | o BDBG_MODULE - register module and allow using the rest of the BDBG_ macros. |
|---|
| 243 | o BDBG_MSG, BDBG_WRN, BDBG_ERR - message output with 'Message', 'Warning' and 'Error' levels. |
|---|
| 244 | o BDBG_ASSERT - evaluate expression (condition) and fail if it's false. |
|---|
| 245 | |
|---|
| 246 | To activate debug build BDBG_DEBUG_BUILD macro should be defined to 1, |
|---|
| 247 | i.e. -DBDBG_DEBUG_BUILD=1 . |
|---|
| 248 | |
|---|
| 249 | Implementation note: |
|---|
| 250 | During impementation of this interface for a given plaform, it should be |
|---|
| 251 | noted, that debug messages shall use a different output channel than a normal |
|---|
| 252 | output from the system. For example in Posix like systems it would be |
|---|
| 253 | a good choice to use stderr for the debug messages. In such a case the |
|---|
| 254 | following command could be used to redirect debug messages into a file: |
|---|
| 255 | application 2>debug_file |
|---|
| 256 | |
|---|
| 257 | A second feature of this debug interface is the BDBG_OBJECT code. These macros provide |
|---|
| 258 | a means to create a unique object type, add that object to a structure, and assert |
|---|
| 259 | when given a pointer to an object that should be of that type but isn't. This is |
|---|
| 260 | analogous to the old unix "magic" values. A structure element would be initialized |
|---|
| 261 | to this unique magic value at creation time and be checked each time that structure was |
|---|
| 262 | used to ensure that it is a valid type. The element would be erased when the structure |
|---|
| 263 | was destroyed to ensure that the element wasn't used after it had been destroyed. |
|---|
| 264 | |
|---|
| 265 | Defined macros: |
|---|
| 266 | o BDBG_OBJECT_ID, BDBG_OBJECT_ID_DECLARE - register object and allow using the rest of the BDBG_OBJECT_ macros. |
|---|
| 267 | o BDBG_OBJECT - allocate storage in a structure for the "magic" values. |
|---|
| 268 | o BDBG_OBJECT_INIT, BDBG_OBJECT_DESTROY, BDBG_OBJECT_SET, BDBG_OBJECT_UNSET - update the object. |
|---|
| 269 | o BDBG_OBJECT_ASSERT - assert when the object isn't the expected type. |
|---|
| 270 | ========================================================================*/ |
|---|
| 271 | |
|---|
| 272 | /* Runtime debug level */ |
|---|
| 273 | typedef enum { |
|---|
| 274 | BDBG_P_eUnknown=0, /* special level that is used to indicate that file wasn't registered */ |
|---|
| 275 | BDBG_eTrace, /* Trace level */ |
|---|
| 276 | BDBG_eMsg, /* Message level */ |
|---|
| 277 | BDBG_eWrn, /* Warning level */ |
|---|
| 278 | BDBG_eErr, /* Error level */ |
|---|
| 279 | BDBG_eLog, /* Log level */ |
|---|
| 280 | BDBG_P_eLastEntry |
|---|
| 281 | } BDBG_Level; |
|---|
| 282 | |
|---|
| 283 | typedef void *BDBG_Instance; |
|---|
| 284 | |
|---|
| 285 | /*************************************************************************** |
|---|
| 286 | Summary: |
|---|
| 287 | Initialize the debug interface before being used. |
|---|
| 288 | |
|---|
| 289 | Description: StandardProgrammingEnvironment |
|---|
| 290 | Initializes the debug interface. You must call this before making any |
|---|
| 291 | other kernel interface call. |
|---|
| 292 | |
|---|
| 293 | Input: |
|---|
| 294 | <none> |
|---|
| 295 | |
|---|
| 296 | Returns: |
|---|
| 297 | BERR_SUCCESS - The debug interface successfully initialized. |
|---|
| 298 | ****************************************************************************/ |
|---|
| 299 | BERR_Code BDBG_Init(void); |
|---|
| 300 | |
|---|
| 301 | /*************************************************************************** |
|---|
| 302 | Summary: |
|---|
| 303 | Releases resources allocated by the debug interface. |
|---|
| 304 | |
|---|
| 305 | Description: |
|---|
| 306 | Cleans up the debug interface interface. No debug interface calls can be made after this. |
|---|
| 307 | |
|---|
| 308 | Input: |
|---|
| 309 | <none> |
|---|
| 310 | |
|---|
| 311 | Returns: |
|---|
| 312 | <none> |
|---|
| 313 | ****************************************************************************/ |
|---|
| 314 | void BDBG_Uninit(void); |
|---|
| 315 | |
|---|
| 316 | typedef struct BDBG_DebugModuleFile *BDBG_pDebugModuleFile; |
|---|
| 317 | |
|---|
| 318 | #define BDBG_P_FILE_INITIALIZER(module) { BDBG_P_eUnknown, BDBG_P_eUnknown, false, {NULL}, #module, NULL} |
|---|
| 319 | |
|---|
| 320 | typedef enum BDBG_ModulePrintKind { |
|---|
| 321 | BDBG_ModulePrintKind_eHeader, /* header only */ |
|---|
| 322 | BDBG_ModulePrintKind_eBody, /* body only */ |
|---|
| 323 | BDBG_ModulePrintKind_eHeaderAndBody, /* entire output - header and body */ |
|---|
| 324 | BDBG_ModulePrintKind_eString /* just a string */ |
|---|
| 325 | } BDBG_ModulePrintKind; |
|---|
| 326 | |
|---|
| 327 | typedef struct BDBG_DebugModuleFile BDBG_DebugModuleFile; |
|---|
| 328 | |
|---|
| 329 | typedef void (*BDBG_DebugModule_Print)( |
|---|
| 330 | BDBG_ModulePrintKind kind, /* type of the output */ |
|---|
| 331 | BDBG_Level level, /* level of the debug output */ |
|---|
| 332 | const BDBG_DebugModuleFile *module, /* pointer to the debug module */ |
|---|
| 333 | const char *fmt, /* format */ |
|---|
| 334 | va_list ap /* variable list of arguments */ |
|---|
| 335 | ); |
|---|
| 336 | |
|---|
| 337 | struct BDBG_DebugModuleFile { |
|---|
| 338 | int8_t level; /* current level for this module */ |
|---|
| 339 | uint8_t module_level; /* actual level for module */ |
|---|
| 340 | bool module_alloc; /* true if module was instantiated by API call, e.g. BDBG_SetModuleLevel */ |
|---|
| 341 | BLST_S_ENTRY(BDBG_DebugModuleFile) link; /* pointer that links all modules */ |
|---|
| 342 | const char *name; /* name of the module */ |
|---|
| 343 | BDBG_DebugModule_Print module_print; |
|---|
| 344 | }; |
|---|
| 345 | |
|---|
| 346 | |
|---|
| 347 | struct bdbg_obj |
|---|
| 348 | { |
|---|
| 349 | const char *bdbg_obj_id; |
|---|
| 350 | }; |
|---|
| 351 | |
|---|
| 352 | |
|---|
| 353 | #if BDBG_DEBUG_BUILD |
|---|
| 354 | |
|---|
| 355 | #if 0 |
|---|
| 356 | /*************************************************************************** |
|---|
| 357 | Summary: |
|---|
| 358 | Registers software for the debug interface. |
|---|
| 359 | |
|---|
| 360 | Description: |
|---|
| 361 | This macro is used to register software module in the system. If module is used in several |
|---|
| 362 | C files each file should be registered with the same module name. Every modules that uses |
|---|
| 363 | BDBG_XXX macros should use BDBG_MODULE after '#include' statement. |
|---|
| 364 | |
|---|
| 365 | Example: |
|---|
| 366 | #include "bstd.h" |
|---|
| 367 | BDBG_MODULE(some_module) |
|---|
| 368 | |
|---|
| 369 | Input: |
|---|
| 370 | <none> |
|---|
| 371 | |
|---|
| 372 | Returns: |
|---|
| 373 | <none> |
|---|
| 374 | ****************************************************************************/ |
|---|
| 375 | #define BDBG_MODULE(module) |
|---|
| 376 | |
|---|
| 377 | /*************************************************************************** |
|---|
| 378 | Summary: |
|---|
| 379 | Registers software for the debug interface. |
|---|
| 380 | |
|---|
| 381 | Description: |
|---|
| 382 | This macro is used to register another software module in the same compilation unit. If module is used in several |
|---|
| 383 | C files each file should be registered with the same module name. Every modules that uses |
|---|
| 384 | BDBG_MODULE_XXX macros should use BDBG_FILE_MODULE after '#include' statement. |
|---|
| 385 | |
|---|
| 386 | Example: |
|---|
| 387 | #include "bstd.h" |
|---|
| 388 | BDBG_FILE_MODULE(another_module) |
|---|
| 389 | |
|---|
| 390 | Input: |
|---|
| 391 | <none> |
|---|
| 392 | |
|---|
| 393 | Returns: |
|---|
| 394 | <none> |
|---|
| 395 | ****************************************************************************/ |
|---|
| 396 | #define BDBG_FILE_MODULE(module) |
|---|
| 397 | |
|---|
| 398 | /*************************************************************************** |
|---|
| 399 | Summary: |
|---|
| 400 | Prints out message. |
|---|
| 401 | |
|---|
| 402 | Description: |
|---|
| 403 | If either module or system debug level is set to the 'Message' level this macro will print message |
|---|
| 404 | on the debug output. Message can have a printf style format string but should not include an 'end |
|---|
| 405 | of line' symbol ("\n") as one will be added. |
|---|
| 406 | |
|---|
| 407 | Note: |
|---|
| 408 | Text will not be displayed regardless of the error level on Release builds. |
|---|
| 409 | |
|---|
| 410 | See Also: |
|---|
| 411 | BDBG_SetLevel, BDBG_SetModuleLevel |
|---|
| 412 | |
|---|
| 413 | Example: |
|---|
| 414 | BDBG_MSG(("Counter value %d", counter)); |
|---|
| 415 | |
|---|
| 416 | Input: |
|---|
| 417 | format - message to print |
|---|
| 418 | |
|---|
| 419 | Returns: |
|---|
| 420 | <none> |
|---|
| 421 | ****************************************************************************/ |
|---|
| 422 | #define BDBG_MSG(format) |
|---|
| 423 | |
|---|
| 424 | /*************************************************************************** |
|---|
| 425 | Summary: |
|---|
| 426 | Prints out message. |
|---|
| 427 | |
|---|
| 428 | Description: |
|---|
| 429 | If either module or system debug level is set to the 'Message' level this macro will print message |
|---|
| 430 | on the debug output. Message can have a printf style format string but should not include an 'end |
|---|
| 431 | of line' symbol ("\n") as one will be added. |
|---|
| 432 | |
|---|
| 433 | Note: |
|---|
| 434 | Text will not be displayed regardless of the error level on Release builds. |
|---|
| 435 | |
|---|
| 436 | See Also: |
|---|
| 437 | BDBG_SetLevel, BDBG_SetModuleLevel |
|---|
| 438 | |
|---|
| 439 | Example: |
|---|
| 440 | BDBG_MODULE_MSG(module,("Counter value %d", counter)); |
|---|
| 441 | |
|---|
| 442 | Input: |
|---|
| 443 | format - message to print |
|---|
| 444 | |
|---|
| 445 | Returns: |
|---|
| 446 | <none> |
|---|
| 447 | ****************************************************************************/ |
|---|
| 448 | #define BDBG_MODULE_MSG(format) |
|---|
| 449 | |
|---|
| 450 | /*************************************************************************** |
|---|
| 451 | Summary: |
|---|
| 452 | Prints out message. |
|---|
| 453 | |
|---|
| 454 | Description: |
|---|
| 455 | If either module or system debug level is set to the 'Message' or 'Warning' level this macro will |
|---|
| 456 | print the message on the debug output. Message can have a printf style format string but should |
|---|
| 457 | not include an 'end of line' symbol ("\n") as one will be added. |
|---|
| 458 | |
|---|
| 459 | Note: |
|---|
| 460 | Text will not be displayed regardless of the error level on Release builds. |
|---|
| 461 | |
|---|
| 462 | See Also: |
|---|
| 463 | BDBG_SetLevel, BDBG_SetModuleLevel |
|---|
| 464 | |
|---|
| 465 | Example: |
|---|
| 466 | BDBG_WRN(("Counter value %d greater then %d", counter, 10)); |
|---|
| 467 | |
|---|
| 468 | Input: |
|---|
| 469 | format - message to print |
|---|
| 470 | |
|---|
| 471 | Returns: |
|---|
| 472 | <none> |
|---|
| 473 | ****************************************************************************/ |
|---|
| 474 | #define BDBG_WRN(format) |
|---|
| 475 | |
|---|
| 476 | /*************************************************************************** |
|---|
| 477 | Summary: |
|---|
| 478 | Prints out message. |
|---|
| 479 | |
|---|
| 480 | Description: |
|---|
| 481 | If either module or system debug level is set to the 'Message' or 'Warning' level this macro will |
|---|
| 482 | print the message on the debug output. Message can have a printf style format string but should |
|---|
| 483 | not include an 'end of line' symbol ("\n") as one will be added. |
|---|
| 484 | |
|---|
| 485 | Note: |
|---|
| 486 | Text will not be displayed regardless of the error level on Release builds. |
|---|
| 487 | |
|---|
| 488 | See Also: |
|---|
| 489 | BDBG_SetLevel, BDBG_SetModuleLevel |
|---|
| 490 | |
|---|
| 491 | Example: |
|---|
| 492 | BDBG_MODULE_WRN(module,("Counter value %d greater then %d", counter, 10)); |
|---|
| 493 | |
|---|
| 494 | Input: |
|---|
| 495 | format - message to print |
|---|
| 496 | |
|---|
| 497 | Returns: |
|---|
| 498 | <none> |
|---|
| 499 | ****************************************************************************/ |
|---|
| 500 | #define BDBG_MODULE_WRN(format) |
|---|
| 501 | |
|---|
| 502 | |
|---|
| 503 | |
|---|
| 504 | /*************************************************************************** |
|---|
| 505 | Summary: |
|---|
| 506 | Prints out message. |
|---|
| 507 | |
|---|
| 508 | Description: |
|---|
| 509 | This macro prints the message on the debug output. Message can have a printf style format string |
|---|
| 510 | but should not include an 'end of line' symbol ("\n") as one will be added. |
|---|
| 511 | |
|---|
| 512 | Note: |
|---|
| 513 | Text will not be displayed regardless of the error level on Release builds. |
|---|
| 514 | |
|---|
| 515 | Example: |
|---|
| 516 | BDBG_ERR(("Counter value %d negative", counter)); |
|---|
| 517 | |
|---|
| 518 | Input: |
|---|
| 519 | format - message to print |
|---|
| 520 | |
|---|
| 521 | Returns: |
|---|
| 522 | <none> |
|---|
| 523 | ****************************************************************************/ |
|---|
| 524 | #define BDBG_ERR(format) |
|---|
| 525 | |
|---|
| 526 | /*************************************************************************** |
|---|
| 527 | Summary: |
|---|
| 528 | Prints out message. |
|---|
| 529 | |
|---|
| 530 | Description: |
|---|
| 531 | This macro prints the message on the debug output. Message can have a printf style format string |
|---|
| 532 | but should not include an 'end of line' symbol ("\n") as one will be added. |
|---|
| 533 | |
|---|
| 534 | Note: |
|---|
| 535 | Text will not be displayed regardless of the error level on Release builds. |
|---|
| 536 | |
|---|
| 537 | Example: |
|---|
| 538 | BDBG_ERR(module,("Counter value %d negative", counter)); |
|---|
| 539 | |
|---|
| 540 | Input: |
|---|
| 541 | format - message to print |
|---|
| 542 | |
|---|
| 543 | Returns: |
|---|
| 544 | <none> |
|---|
| 545 | ****************************************************************************/ |
|---|
| 546 | #define BDBG_MODULE_ERR(module,format) |
|---|
| 547 | |
|---|
| 548 | |
|---|
| 549 | /*************************************************************************** |
|---|
| 550 | Summary: |
|---|
| 551 | Test conditions. |
|---|
| 552 | |
|---|
| 553 | Description: |
|---|
| 554 | Evaluates expression and if result is false, prints out message including |
|---|
| 555 | textual presentation of the expression, file name and line number where assert |
|---|
| 556 | occured and then call function BKNI_Fail. The exact behaviour of fail is |
|---|
| 557 | implementation specific. Usually it traps to the debugger, generate stack trace and/or core dump. |
|---|
| 558 | |
|---|
| 559 | Note: |
|---|
| 560 | Expression inside BDBG_ASSERT does not evaluated for release builds, therefore expressions |
|---|
| 561 | in the BDBG_ASSERT macro shall be free of side effects. |
|---|
| 562 | |
|---|
| 563 | See Also: |
|---|
| 564 | BKNI_Fail, BDBG_CASSERT |
|---|
| 565 | |
|---|
| 566 | Example: |
|---|
| 567 | BDBG_ASSERT(counter>0); |
|---|
| 568 | |
|---|
| 569 | Input: |
|---|
| 570 | expr - the expression to evaluate |
|---|
| 571 | |
|---|
| 572 | Returns: |
|---|
| 573 | <none> |
|---|
| 574 | ****************************************************************************/ |
|---|
| 575 | #define BDBG_ASSERT(expr) |
|---|
| 576 | |
|---|
| 577 | |
|---|
| 578 | /*************************************************************************** |
|---|
| 579 | Summary: |
|---|
| 580 | Test conditions at compile time. |
|---|
| 581 | |
|---|
| 582 | Description: |
|---|
| 583 | Evaluates expression at compile time and if result is false, compile process terminates. |
|---|
| 584 | The exact behaviour of compile error is implementation specific, usually it causes the compiler |
|---|
| 585 | to generate an error about duplicate case values. |
|---|
| 586 | |
|---|
| 587 | Note: |
|---|
| 588 | Expression inside BDBG_CASSERT shall be reducable to the boolean constant at compile time |
|---|
| 589 | in the BDBG_ASSER macro shall be free of side effects. |
|---|
| 590 | |
|---|
| 591 | See Also: |
|---|
| 592 | BKNI_ASSERT |
|---|
| 593 | BDBG_CWARNING |
|---|
| 594 | |
|---|
| 595 | Example: |
|---|
| 596 | BDBG_CASSERT(sizeof(int)==4); // compilation fails if size of the 'int' type if different from 4 |
|---|
| 597 | |
|---|
| 598 | Input: |
|---|
| 599 | expr - the expression to evaluate |
|---|
| 600 | |
|---|
| 601 | Returns: |
|---|
| 602 | <none> |
|---|
| 603 | ****************************************************************************/ |
|---|
| 604 | #define BDBG_CASSERT(expr) |
|---|
| 605 | |
|---|
| 606 | /*************************************************************************** |
|---|
| 607 | Summary: |
|---|
| 608 | Test conditions at compile time. |
|---|
| 609 | |
|---|
| 610 | Description: |
|---|
| 611 | Evaluates expression at compile time and if result is false, compile process generates a warning. |
|---|
| 612 | The exact behaviour of compile warning is implementation specific, usually it causes the compiler |
|---|
| 613 | to generate an warning about division to zero. |
|---|
| 614 | |
|---|
| 615 | Note: |
|---|
| 616 | Expression inside BDBG_CASSERT shall be reducable to the boolean constant at compile time |
|---|
| 617 | in the BDBG_ASSER macro shall be free of side effects. |
|---|
| 618 | |
|---|
| 619 | See Also: |
|---|
| 620 | BDBG_CASSERT |
|---|
| 621 | |
|---|
| 622 | Example: |
|---|
| 623 | BDBG_WARNING(sizeof(int)==4); // compilation fails if size of the 'int' type if different from 4 |
|---|
| 624 | |
|---|
| 625 | Input: |
|---|
| 626 | expr - the expression to evaluate |
|---|
| 627 | |
|---|
| 628 | Returns: |
|---|
| 629 | <none> |
|---|
| 630 | ****************************************************************************/ |
|---|
| 631 | #define BDBG_CWARNING(expr) |
|---|
| 632 | |
|---|
| 633 | |
|---|
| 634 | /*************************************************************************** |
|---|
| 635 | Summary: |
|---|
| 636 | Prints out message. |
|---|
| 637 | |
|---|
| 638 | Description: |
|---|
| 639 | If either instance, module, or system debug level is set to the 'Message' level this macro will print |
|---|
| 640 | the message on the debug output. The message can have a printf style format string but should not |
|---|
| 641 | include and 'end of line' character ("\n") as one will be added. |
|---|
| 642 | |
|---|
| 643 | See Also: |
|---|
| 644 | BDBG_SetLevel, BDBG_SetModuleLevel, BDBG_SetInstanceLevel |
|---|
| 645 | |
|---|
| 646 | Example: |
|---|
| 647 | BDBG_INSTANCE_MSG(obj, ("Obj's counter value %d", obj->counter)); |
|---|
| 648 | |
|---|
| 649 | Input: |
|---|
| 650 | instance - the module instance |
|---|
| 651 | format - message to print |
|---|
| 652 | |
|---|
| 653 | Returns: |
|---|
| 654 | <none> |
|---|
| 655 | ****************************************************************************/ |
|---|
| 656 | #define BDBG_INSTANCE_MSG(instance, format) |
|---|
| 657 | |
|---|
| 658 | |
|---|
| 659 | /*************************************************************************** |
|---|
| 660 | Summary: |
|---|
| 661 | Prints out message. |
|---|
| 662 | |
|---|
| 663 | Description: |
|---|
| 664 | If either instance, module, or system debug level is set to the 'Message' or 'Warning' level this macro |
|---|
| 665 | will print the message on the debug output. The message can have a printf style format string but should |
|---|
| 666 | not include an 'end of line' character ("\n") as one will be added. |
|---|
| 667 | |
|---|
| 668 | See Also: |
|---|
| 669 | BDBG_SetLevel, BDBG_SetModuleLevel, BDBG_SetInstanceLevel |
|---|
| 670 | |
|---|
| 671 | Example: |
|---|
| 672 | BDBG_INSTANCE_WRN(obj, ("Counter value %d greater then %d", obj->counter, 10)); |
|---|
| 673 | |
|---|
| 674 | Input: |
|---|
| 675 | instance - the module instance |
|---|
| 676 | format - message to print |
|---|
| 677 | |
|---|
| 678 | Returns: |
|---|
| 679 | <none> |
|---|
| 680 | ****************************************************************************/ |
|---|
| 681 | #define BDBG_INSTANCE_WRN(instance, format) |
|---|
| 682 | |
|---|
| 683 | |
|---|
| 684 | /*************************************************************************** |
|---|
| 685 | Summary: |
|---|
| 686 | Prints out message. |
|---|
| 687 | |
|---|
| 688 | Description: |
|---|
| 689 | This macro prints the message on the debug output. Message can have a printf style format string |
|---|
| 690 | but should not include an 'end of line' character ("\n") as one will be added. |
|---|
| 691 | |
|---|
| 692 | Example: |
|---|
| 693 | BDBG_INSTANCE_ERR(obj, ("Counter value %d negative", obj->counter)); |
|---|
| 694 | |
|---|
| 695 | Input: |
|---|
| 696 | instance - the module instance |
|---|
| 697 | format - message to print |
|---|
| 698 | |
|---|
| 699 | Returns: |
|---|
| 700 | <none> |
|---|
| 701 | ****************************************************************************/ |
|---|
| 702 | #define BDBG_INSTANCE_ERR(instance, format) |
|---|
| 703 | |
|---|
| 704 | |
|---|
| 705 | /*************************************************************************** |
|---|
| 706 | Summary: |
|---|
| 707 | Prints out message. |
|---|
| 708 | |
|---|
| 709 | Description: |
|---|
| 710 | If either module or system debug level is set to the 'Trace' level this macro will print the |
|---|
| 711 | message that function 'function' entered. |
|---|
| 712 | |
|---|
| 713 | See Also: |
|---|
| 714 | BDBG_SetLevel, BDBG_SetModuleLevel |
|---|
| 715 | |
|---|
| 716 | Example: |
|---|
| 717 | BDBG_ENTER(BFOO_DoBar); |
|---|
| 718 | |
|---|
| 719 | Input: |
|---|
| 720 | function - function name |
|---|
| 721 | |
|---|
| 722 | Returns: |
|---|
| 723 | <none> |
|---|
| 724 | ****************************************************************************/ |
|---|
| 725 | #define BDBG_ENTER(function) |
|---|
| 726 | |
|---|
| 727 | |
|---|
| 728 | /*************************************************************************** |
|---|
| 729 | Summary: |
|---|
| 730 | Prints out message. |
|---|
| 731 | |
|---|
| 732 | Description: |
|---|
| 733 | If either module or system debug level is set to the 'Trace' level this macro will print the |
|---|
| 734 | message that function 'function' exited. |
|---|
| 735 | |
|---|
| 736 | See Also: |
|---|
| 737 | BDBG_SetLevel, BDBG_SetModuleLevel |
|---|
| 738 | |
|---|
| 739 | Example: |
|---|
| 740 | BDBG_LEAVE(BFOO_DoBar); |
|---|
| 741 | |
|---|
| 742 | Input: |
|---|
| 743 | function - function name |
|---|
| 744 | |
|---|
| 745 | Returns: |
|---|
| 746 | <none> |
|---|
| 747 | ****************************************************************************/ |
|---|
| 748 | #define BDBG_LEAVE(function) |
|---|
| 749 | |
|---|
| 750 | |
|---|
| 751 | /*************************************************************************** |
|---|
| 752 | Summary: |
|---|
| 753 | Registers instance |
|---|
| 754 | |
|---|
| 755 | Description: |
|---|
| 756 | This macro registers an intance for the debug interface. An 'Instance' is any pointer like object. |
|---|
| 757 | Only registered instances should be passed to other debug interface API. |
|---|
| 758 | |
|---|
| 759 | See Also: |
|---|
| 760 | BDBG_SetInstanceLevel, BDBG_INSTANCE_MSG, BDBG_INSTANCE_WRN, BDBG_INSTANCE_ERR |
|---|
| 761 | |
|---|
| 762 | Example: |
|---|
| 763 | BDBG_REGISTER_INSTANCE(obj); |
|---|
| 764 | |
|---|
| 765 | Input: |
|---|
| 766 | instance - the module instance |
|---|
| 767 | |
|---|
| 768 | Returns: |
|---|
| 769 | BERR_SUCCESS - instance has been registered |
|---|
| 770 | ****************************************************************************/ |
|---|
| 771 | #define BDBG_REGISTER_INSTANCE(instance) |
|---|
| 772 | |
|---|
| 773 | |
|---|
| 774 | /*************************************************************************** |
|---|
| 775 | Summary: |
|---|
| 776 | Unregisters instance |
|---|
| 777 | |
|---|
| 778 | Description: |
|---|
| 779 | This macro releases resources allocated for this instance. |
|---|
| 780 | |
|---|
| 781 | See Also: |
|---|
| 782 | BDBG_REGISTER_INSTANCE |
|---|
| 783 | |
|---|
| 784 | Example: |
|---|
| 785 | BDBG_UNREGISTER_INSTANCE(obj); |
|---|
| 786 | |
|---|
| 787 | Input: |
|---|
| 788 | instance - the module instance |
|---|
| 789 | |
|---|
| 790 | Returns: |
|---|
| 791 | BERR_SUCCESS - instance has been unregistered |
|---|
| 792 | ****************************************************************************/ |
|---|
| 793 | #define BDBG_UNREGISTER_INSTANCE(instance) |
|---|
| 794 | |
|---|
| 795 | /*************************************************************************** |
|---|
| 796 | Summary: |
|---|
| 797 | Releases resources |
|---|
| 798 | |
|---|
| 799 | Description: |
|---|
| 800 | This macro releases resources allocated for the file(module) which used this macro. |
|---|
| 801 | |
|---|
| 802 | Example: |
|---|
| 803 | BDBG_RELEASE(); |
|---|
| 804 | |
|---|
| 805 | ****************************************************************************/ |
|---|
| 806 | #define BDBG_RELEASE() |
|---|
| 807 | |
|---|
| 808 | |
|---|
| 809 | /*************************************************************************** |
|---|
| 810 | Summary: |
|---|
| 811 | Creates object type id |
|---|
| 812 | |
|---|
| 813 | Description: |
|---|
| 814 | This macro creates the object type id, that to use to check the object type. |
|---|
| 815 | This macro shall be used in the 'C' file. |
|---|
| 816 | Only one id with the given object type (name) can exist in the system. |
|---|
| 817 | |
|---|
| 818 | Example: |
|---|
| 819 | // this shows a non-opaque struct object_type. |
|---|
| 820 | // if struct object_type is private (e.g. opaque handle), then all this code should be in the implementation file. |
|---|
| 821 | |
|---|
| 822 | // header file |
|---|
| 823 | BDBG_OBJECT_ID_DECLARE(object_type); |
|---|
| 824 | struct object_type { |
|---|
| 825 | BDBG_OBJECT(object_type) |
|---|
| 826 | unsigned x; |
|---|
| 827 | } |
|---|
| 828 | |
|---|
| 829 | // implementation file |
|---|
| 830 | BDBG_OBJECT_ID(object_type); |
|---|
| 831 | |
|---|
| 832 | object_type *open_object() { |
|---|
| 833 | object_type *obj = malloc(sizeof(*obj)); |
|---|
| 834 | memset(obj, 0, sizeof(*obj)); |
|---|
| 835 | BDBG_OBJECT_SET(obj, object_type); |
|---|
| 836 | obj->x = 1; |
|---|
| 837 | return obj; |
|---|
| 838 | } |
|---|
| 839 | void use_object(object_type *obj) { |
|---|
| 840 | BDBG_OBJECT_ASSERT(obj, object_type); |
|---|
| 841 | obj->x = 2; |
|---|
| 842 | } |
|---|
| 843 | void close_object(object_type *obj) { |
|---|
| 844 | BDBG_OBJECT_ASSERT(obj, object_type); |
|---|
| 845 | obj->x = 3; |
|---|
| 846 | BDBG_OBJECT_DESTROY(obj, object_type); |
|---|
| 847 | free(obj); |
|---|
| 848 | } |
|---|
| 849 | |
|---|
| 850 | See Also: |
|---|
| 851 | BDBG_OBJECT_INIT, BDBG_OBJECT_ASSERT |
|---|
| 852 | |
|---|
| 853 | Input: |
|---|
| 854 | name - object type |
|---|
| 855 | |
|---|
| 856 | Returns: |
|---|
| 857 | <none> |
|---|
| 858 | ****************************************************************************/ |
|---|
| 859 | #define BDBG_OBJECT_ID(name) |
|---|
| 860 | |
|---|
| 861 | |
|---|
| 862 | /*************************************************************************** |
|---|
| 863 | Summary: |
|---|
| 864 | Declares object type id |
|---|
| 865 | |
|---|
| 866 | Description: |
|---|
| 867 | This macro forward declares the object type id. |
|---|
| 868 | Usually this is used in an H file if its necessary to share the same object ID |
|---|
| 869 | across multiple C files. |
|---|
| 870 | |
|---|
| 871 | Example: |
|---|
| 872 | see example for BDBG_OBJECT_ID |
|---|
| 873 | |
|---|
| 874 | See Also: |
|---|
| 875 | BDBG_OBJECT_ID, BDBG_OBJECT_INIT, BDBG_OBJECT_ASSERT |
|---|
| 876 | |
|---|
| 877 | Input: |
|---|
| 878 | name - object type |
|---|
| 879 | |
|---|
| 880 | Returns: |
|---|
| 881 | <none> |
|---|
| 882 | ****************************************************************************/ |
|---|
| 883 | #define BDBG_OBJECT_ID_DECLARE(name) |
|---|
| 884 | |
|---|
| 885 | |
|---|
| 886 | /*************************************************************************** |
|---|
| 887 | Summary: |
|---|
| 888 | Adds module id to structure |
|---|
| 889 | |
|---|
| 890 | Description: |
|---|
| 891 | This macro is used to add module id to a structure. |
|---|
| 892 | This needs to be initialized or set before it can be used in an assert test. |
|---|
| 893 | |
|---|
| 894 | Note: |
|---|
| 895 | A semi-colon should not be used with this macro as some compilers will generate |
|---|
| 896 | an error when creating a release build and the macro is removed. |
|---|
| 897 | |
|---|
| 898 | Example: |
|---|
| 899 | see example for BDBG_OBJECT_ID |
|---|
| 900 | |
|---|
| 901 | See Also: |
|---|
| 902 | BDBG_OBJECT_ID, BDBG_OBJECT_INIT, BDBG_OBJECT_SET, BDBG_OBJECT_ASSERT |
|---|
| 903 | |
|---|
| 904 | Input: |
|---|
| 905 | name - object type |
|---|
| 906 | |
|---|
| 907 | Returns: |
|---|
| 908 | <none> |
|---|
| 909 | ****************************************************************************/ |
|---|
| 910 | #define BDBG_OBJECT(name) |
|---|
| 911 | |
|---|
| 912 | |
|---|
| 913 | /*************************************************************************** |
|---|
| 914 | Summary: |
|---|
| 915 | Initializes object |
|---|
| 916 | |
|---|
| 917 | Description: |
|---|
| 918 | This macro is used to initialize pointer and sets the module id. |
|---|
| 919 | Initialization code fills memory, equal to size of the object, with a random pattern. |
|---|
| 920 | |
|---|
| 921 | Example: |
|---|
| 922 | see example for BDBG_OBJECT_ID. compare with: |
|---|
| 923 | |
|---|
| 924 | object_type *open_object() { |
|---|
| 925 | object_type *obj = malloc(sizeof(*obj)); |
|---|
| 926 | BDBG_OBJECT_INIT(obj, object_type); |
|---|
| 927 | obj->x = 1; |
|---|
| 928 | return obj; |
|---|
| 929 | } |
|---|
| 930 | |
|---|
| 931 | See Also: |
|---|
| 932 | BDBG_OBJECT_ID, BDBG_OBJECT_DESTROY, BDBG_OBJECT_ASSERT |
|---|
| 933 | |
|---|
| 934 | Input: |
|---|
| 935 | ptr - pointer to the object |
|---|
| 936 | name - object type |
|---|
| 937 | |
|---|
| 938 | Returns: |
|---|
| 939 | <none> |
|---|
| 940 | ****************************************************************************/ |
|---|
| 941 | #define BDBG_OBJECT_INIT(ptr,name) |
|---|
| 942 | |
|---|
| 943 | |
|---|
| 944 | /*************************************************************************** |
|---|
| 945 | Summary: |
|---|
| 946 | Destroys object |
|---|
| 947 | |
|---|
| 948 | Description: |
|---|
| 949 | This macro is used to destroy object and remove the type tag. Using this |
|---|
| 950 | macro fills memory, equal to size of the object, with a random pattern. |
|---|
| 951 | The assert test will fail if pointer to object is used after its destroyed. |
|---|
| 952 | |
|---|
| 953 | Example: |
|---|
| 954 | see example for BDBG_OBJECT_ID |
|---|
| 955 | |
|---|
| 956 | See Also: |
|---|
| 957 | BDBG_OBJECT_ID, BDBG_OBJECT_INIT, BDBG_OBJECT_ASSERT |
|---|
| 958 | |
|---|
| 959 | Input: |
|---|
| 960 | ptr - pointer to the object |
|---|
| 961 | name - object type |
|---|
| 962 | |
|---|
| 963 | Returns: |
|---|
| 964 | <none> |
|---|
| 965 | ****************************************************************************/ |
|---|
| 966 | #define BDBG_OBJECT_DESTROY(ptr,name) |
|---|
| 967 | |
|---|
| 968 | |
|---|
| 969 | /*************************************************************************** |
|---|
| 970 | Summary: |
|---|
| 971 | Sets the object tag |
|---|
| 972 | |
|---|
| 973 | Description: |
|---|
| 974 | This macro is used tag pointer with a specific tag. |
|---|
| 975 | |
|---|
| 976 | Example: |
|---|
| 977 | see example for BDBG_OBJECT_ID |
|---|
| 978 | |
|---|
| 979 | See Also: |
|---|
| 980 | BDBG_OBJECT_ID, BDBG_OBJECT_UNSET, BDBG_OBJECT_ASSERT |
|---|
| 981 | |
|---|
| 982 | Input: |
|---|
| 983 | ptr - pointer to the object |
|---|
| 984 | name - object type |
|---|
| 985 | |
|---|
| 986 | Returns: |
|---|
| 987 | <none> |
|---|
| 988 | ****************************************************************************/ |
|---|
| 989 | #define BDBG_OBJECT_SET(ptr,name) |
|---|
| 990 | |
|---|
| 991 | |
|---|
| 992 | /*************************************************************************** |
|---|
| 993 | Summary: |
|---|
| 994 | Removes the object tag |
|---|
| 995 | |
|---|
| 996 | Description: |
|---|
| 997 | This macro is used remove tag from the pointer. |
|---|
| 998 | |
|---|
| 999 | Example: |
|---|
| 1000 | see example for BDBG_OBJECT_ID |
|---|
| 1001 | BDBG_OBJECT_UNSET is an alternative to BDBG_OBJECT_DESTROY. |
|---|
| 1002 | |
|---|
| 1003 | BDBG_OBJECT_ID(object_type); |
|---|
| 1004 | struct some *p = malloc(sizeof(struct some)); |
|---|
| 1005 | BDBG_OBJECT_UNSET(p, object_type); |
|---|
| 1006 | |
|---|
| 1007 | See Also: |
|---|
| 1008 | BDBG_OBJECT_ID, BDBG_OBJECT_INIT, BDBG_OBJECT_SET, BDBG_OBJECT_ASSERT |
|---|
| 1009 | |
|---|
| 1010 | Input: |
|---|
| 1011 | ptr - pointer to the object |
|---|
| 1012 | name - object type |
|---|
| 1013 | |
|---|
| 1014 | Returns: |
|---|
| 1015 | <none> |
|---|
| 1016 | ****************************************************************************/ |
|---|
| 1017 | #define BDBG_OBJECT_UNSET(ptr,name) |
|---|
| 1018 | |
|---|
| 1019 | |
|---|
| 1020 | /*************************************************************************** |
|---|
| 1021 | Summary: |
|---|
| 1022 | Validates a pointer and type of the pointer |
|---|
| 1023 | |
|---|
| 1024 | Description: |
|---|
| 1025 | This macro is used validates that pointer is tagged with a specific object type. |
|---|
| 1026 | The pointer must be valid in order for this macro to succeed. If pointer doesn't |
|---|
| 1027 | match the expected type, this macro will cause a software assert. |
|---|
| 1028 | |
|---|
| 1029 | Example: |
|---|
| 1030 | see example for BDBG_OBJECT_ID |
|---|
| 1031 | |
|---|
| 1032 | See Also: |
|---|
| 1033 | BDBG_OBJECT_ID, BDBG_OBJECT_INIT, BDBG_OBJECT_SET |
|---|
| 1034 | |
|---|
| 1035 | Input: |
|---|
| 1036 | ptr - pointer to the object |
|---|
| 1037 | name - object type |
|---|
| 1038 | |
|---|
| 1039 | Returns: |
|---|
| 1040 | <none> |
|---|
| 1041 | ****************************************************************************/ |
|---|
| 1042 | #define BDBG_OBJECT_ASSERT(ptr,name) |
|---|
| 1043 | |
|---|
| 1044 | |
|---|
| 1045 | #define BDBG_OBJECT_INIT_INST(ptr,name,inst) |
|---|
| 1046 | #define BDBG_OBJECT_SET_INST(ptr,name,inst) |
|---|
| 1047 | #define BDBG_OBJECT_TEST_INST(ptr,name,inst) |
|---|
| 1048 | |
|---|
| 1049 | #endif /* 0 */ |
|---|
| 1050 | |
|---|
| 1051 | |
|---|
| 1052 | #ifdef __GNUC__ |
|---|
| 1053 | #define BDBG_MODULE(module) static BDBG_DebugModuleFile __attribute__ ((__unused__)) b_dbg_module = BDBG_P_FILE_INITIALIZER(module) |
|---|
| 1054 | #define BDBG_FILE_MODULE(module) static BDBG_DebugModuleFile __attribute__ ((__unused__)) b_dbg_module_##module = BDBG_P_FILE_INITIALIZER(module) |
|---|
| 1055 | #else |
|---|
| 1056 | #define BDBG_MODULE(module) static BDBG_DebugModuleFile b_dbg_module = BDBG_P_FILE_INITIALIZER(module) |
|---|
| 1057 | #define BDBG_FILE_MODULE(module) static BDBG_DebugModuleFile b_dbg_module_##module = BDBG_P_FILE_INITIALIZER(module) |
|---|
| 1058 | #endif |
|---|
| 1059 | |
|---|
| 1060 | #if defined(__STDC_VERSION__) |
|---|
| 1061 | # if __STDC_VERSION__ == 199901L |
|---|
| 1062 | # define BDBG_P_UNWRAP(...) __VA_ARGS__ |
|---|
| 1063 | # endif |
|---|
| 1064 | #endif |
|---|
| 1065 | #if !defined(BDBG_P_UNWRAP) && defined(__KERNEL__) |
|---|
| 1066 | # define BDBG_P_UNWRAP(args...) args |
|---|
| 1067 | #endif |
|---|
| 1068 | |
|---|
| 1069 | |
|---|
| 1070 | #if defined B_REFSW_ANDROID && !defined __KERNEL__ |
|---|
| 1071 | # define BDBG_P_PRINTMSG_PRIV(module, lvl, fmt) do { if(lvl==BDBG_eErr) {LOGE fmt;} else if(lvl==BDBG_eWrn) {LOGW fmt;} else {LOGV fmt;} } while(0) |
|---|
| 1072 | # if defined(BDBG_P_UNWRAP) |
|---|
| 1073 | # define BDBG_P_INSTANCE_PRINTMSG_PRIV(module, lvl, instance, fmt) (void)BDBG_P_InstTestAndPrint((lvl), &module, (instance), BDBG_P_UNWRAP fmt) |
|---|
| 1074 | # else |
|---|
| 1075 | # define BDBG_P_INSTANCE_PRINTMSG_PRIV(module, lvl, instance, fmt) ((BDBG_P_InstTestAndPrint((lvl), &module, (instance), NULL))? BDBG_P_PrintWithNewLine fmt:(void)0) |
|---|
| 1076 | # endif |
|---|
| 1077 | #elif defined(BDBG_P_UNWRAP) |
|---|
| 1078 | # define BDBG_P_PRINTMSG_PRIV(module,lvl, fmt) (((lvl) >= module.level)? (void)BDBG_P_TestAndPrint((lvl), &module, BDBG_P_UNWRAP fmt) : (void)0) |
|---|
| 1079 | # define BDBG_P_INSTANCE_PRINTMSG_PRIV(module, lvl, instance, fmt) (void)BDBG_P_InstTestAndPrint((lvl), &module, (instance), BDBG_P_UNWRAP fmt) |
|---|
| 1080 | #else |
|---|
| 1081 | # define BDBG_P_PRINTMSG_PRIV(module, lvl, fmt) ((((lvl) >= module.level) && BDBG_P_TestAndPrint((lvl), &module, NULL)) ? BDBG_P_PrintWithNewLine fmt:(void)0) |
|---|
| 1082 | # define BDBG_P_INSTANCE_PRINTMSG_PRIV(module, lvl, instance, fmt) ((BDBG_P_InstTestAndPrint((lvl), &module, (instance), NULL))? BDBG_P_PrintWithNewLine fmt:(void)0) |
|---|
| 1083 | #endif |
|---|
| 1084 | |
|---|
| 1085 | #define BDBG_P_PRINTMSG(lvl, fmt) BDBG_P_PRINTMSG_PRIV(b_dbg_module, lvl, fmt) |
|---|
| 1086 | #define BDBG_P_MODULE_PRINTMSG(module, lvl, fmt) BDBG_P_PRINTMSG_PRIV(b_dbg_module_##module, lvl, fmt) |
|---|
| 1087 | #define BDBG_P_INSTANCE_PRINTMSG(lvl, instance, fmt) BDBG_P_INSTANCE_PRINTMSG_PRIV(b_dbg_module, lvl, instance, fmt) |
|---|
| 1088 | #define BDBG_P_MODULE_INSTANCE_PRINTMSG(module, lvl, instance, fmt) BDBG_P_INSTANCE_PRINTMSG_PRIV(b_dbg_module_##module, lvl, instance, fmt) |
|---|
| 1089 | |
|---|
| 1090 | #define BDBG_REGISTER_INSTANCE(handle) BDBG_P_RegisterInstance(handle, &b_dbg_module) |
|---|
| 1091 | #define BDBG_UNREGISTER_INSTANCE(handle) BDBG_P_UnRegisterInstance(handle, &b_dbg_module) |
|---|
| 1092 | #define BDBG_RELEASE() BDBG_P_Release(&b_dbg_module) |
|---|
| 1093 | |
|---|
| 1094 | #define BDBG_MODULE_REGISTER_INSTANCE(module, handle) BDBG_P_RegisterInstance(handle, &b_dbg_module_##module) |
|---|
| 1095 | #define BDBG_MODULE_UNREGISTER_INSTANCE(module, handle) BDBG_P_UnRegisterInstance(handle, &b_dbg_module_##module) |
|---|
| 1096 | #define BDBG_MODULE_RELEASE(module) BDBG_P_Release(&b_dbg_module__#module) |
|---|
| 1097 | |
|---|
| 1098 | #if B_REFSW_DEBUG_COMPACT_ASSERT |
|---|
| 1099 | #define BDBG_ASSERT(expr) (expr) ? (void) 0 : BDBG_P_AssertFailed(NULL, __FILE__, __LINE__) |
|---|
| 1100 | #else |
|---|
| 1101 | #define BDBG_ASSERT(expr) (expr) ? (void) 0 : BDBG_P_AssertFailed(#expr, __FILE__, __LINE__) |
|---|
| 1102 | #endif |
|---|
| 1103 | #define BDBG_CASSERT(expr) do switch(0){case 0: case (expr):;} while(0) |
|---|
| 1104 | #define BDBG_CWARNING(expr) do {if(0){int unused = 1/(expr);unused++;}} while(0) |
|---|
| 1105 | |
|---|
| 1106 | |
|---|
| 1107 | #define BDBG_OBJECT_ID(name) const char bdbg_id__##name[]= "#" #name |
|---|
| 1108 | #define BDBG_OBJECT_ID_DECLARE(name) extern const char bdbg_id__##name[] |
|---|
| 1109 | #define BDBG_OBJECT(name) struct bdbg_obj bdbg_object_##name; |
|---|
| 1110 | #define BDBG_OBJECT_INIT(ptr,name) BDBG_Object_Init((ptr),sizeof(*(ptr)),&(ptr)->bdbg_object_##name, bdbg_id__##name) |
|---|
| 1111 | #define BDBG_OBJECT_DESTROY(ptr,name) BDBG_Object_Init((ptr),sizeof(*(ptr)),&(ptr)->bdbg_object_##name, NULL) |
|---|
| 1112 | |
|---|
| 1113 | |
|---|
| 1114 | #define BDBG_OBJECT_SET(ptr,name) (ptr)->bdbg_object_##name.bdbg_obj_id=bdbg_id__##name |
|---|
| 1115 | #define BDBG_OBJECT_UNSET(ptr,name) (ptr)->bdbg_object_##name.bdbg_obj_id=NULL |
|---|
| 1116 | |
|---|
| 1117 | void BDBG_Object_Assert(const void *ptr, size_t size, const struct bdbg_obj *obj, const char *id, const char *file, unsigned line); |
|---|
| 1118 | #define BDBG_OBJECT_ASSERT(ptr,name) (((ptr) && (ptr)->bdbg_object_##name.bdbg_obj_id==bdbg_id__##name)? (void) 0 : BDBG_Object_Assert(ptr, sizeof(*ptr), &(ptr)->bdbg_object_##name, bdbg_id__##name, __FILE__, __LINE__)) |
|---|
| 1119 | |
|---|
| 1120 | #define BDBG_OBJECT_INIT_INST(ptr,name,inst) BDBG_Object_Init(ptr,sizeof(*(ptr)),&(ptr)->bdbg_object_##name,bdbg_id__##name+(unsigned)(inst)) |
|---|
| 1121 | #define BDBG_OBJECT_SET_INST(ptr,name,inst) (ptr)->bdbg_object_##name.bdbg_obj_id=(bdbg_id__##name + (unsigned)(inst)) |
|---|
| 1122 | #define BDBG_OBJECT_ASSERT_INST(ptr,name,inst) BDBG_ASSERT((ptr)->bdbg_object_##name.bdbg_obj_id==&bdbg_id__##name+(unsigned)(inst)) |
|---|
| 1123 | |
|---|
| 1124 | void BDBG_Object_Init(void *ptr, size_t size, struct bdbg_obj *obj, const char *id); |
|---|
| 1125 | |
|---|
| 1126 | bool BDBG_P_TestAndPrint(BDBG_Level level, BDBG_pDebugModuleFile dbg_module, const char *fmt, ...); |
|---|
| 1127 | bool BDBG_P_InstTestAndPrint(BDBG_Level level, BDBG_pDebugModuleFile dbg_module, BDBG_Instance handle, const char *fmt, ...); |
|---|
| 1128 | void BDBG_P_RegisterInstance(BDBG_Instance handle, BDBG_pDebugModuleFile dbg_module); |
|---|
| 1129 | void BDBG_P_UnRegisterInstance(BDBG_Instance handle, BDBG_pDebugModuleFile dbg_module); |
|---|
| 1130 | void BDBG_P_PrintWithNewLine(const char *fmt, ...); |
|---|
| 1131 | void BDBG_P_Release(BDBG_pDebugModuleFile dbg_module); |
|---|
| 1132 | |
|---|
| 1133 | void BDBG_EnterFunction(BDBG_pDebugModuleFile dbg_module, const char *function); |
|---|
| 1134 | void BDBG_LeaveFunction(BDBG_pDebugModuleFile dbg_module, const char *function); |
|---|
| 1135 | |
|---|
| 1136 | |
|---|
| 1137 | #else /* BDBG_DEBUG_BUILD */ |
|---|
| 1138 | /* stubs */ |
|---|
| 1139 | |
|---|
| 1140 | #define BDBG_MODULE(module) extern int bdbg_unused |
|---|
| 1141 | #define BDBG_FILE_MODULE(module) extern int bdbg_unused |
|---|
| 1142 | |
|---|
| 1143 | #define BDBG_RELEASE() BDBG_NOP() |
|---|
| 1144 | #define BDBG_MODULE_RELEASE(module) BDBG_NOP() |
|---|
| 1145 | |
|---|
| 1146 | #define BDBG_REGISTER_INSTANCE(instance) |
|---|
| 1147 | #define BDBG_MODULE_REGISTER_INSTANCE(module,instance) |
|---|
| 1148 | #define BDBG_UNREGISTER_INSTANCE(instance) |
|---|
| 1149 | #define BDBG_MODULE_UNREGISTER_INSTANCE(module,instance) |
|---|
| 1150 | |
|---|
| 1151 | #define BDBG_ASSERT(expr) BDBG_NOP() |
|---|
| 1152 | #define BDBG_CASSERT(expr) |
|---|
| 1153 | #define BDBG_CWARNING(expr) |
|---|
| 1154 | |
|---|
| 1155 | |
|---|
| 1156 | #define BDBG_OBJECT_ID(name) extern const char bdbg_id_unused_##name |
|---|
| 1157 | #define BDBG_OBJECT_ID_DECLARE(name) extern const char bdbg_id_unused_decl_##name |
|---|
| 1158 | #define BDBG_OBJECT(name) |
|---|
| 1159 | #define BDBG_OBJECT_INIT(ptr,name) (void)ptr |
|---|
| 1160 | #define BDBG_OBJECT_DESTROY(ptr,name) (void)ptr |
|---|
| 1161 | #define BDBG_OBJECT_SET(ptr,name) (void)ptr |
|---|
| 1162 | #define BDBG_OBJECT_UNSET(ptr,name) (void)ptr |
|---|
| 1163 | #define BDBG_OBJECT_ASSERT(ptr,name) (void)ptr |
|---|
| 1164 | #define BDBG_OBJECT_INIT_INST(ptr,name,inst) (void)ptr |
|---|
| 1165 | #define BDBG_OBJECT_SET_INST(ptr,name,inst) (void)ptr |
|---|
| 1166 | #define BDBG_OBJECT_TEST_INST(ptr,name,inst) (void)ptr |
|---|
| 1167 | #define BDBG_OBJECT_ASSERT_INST(ptr,name,inst) (void)ptr |
|---|
| 1168 | |
|---|
| 1169 | /* if not BDBG_DEBUG_BUILD, force these macros to be defined. |
|---|
| 1170 | they can be used to avoid unused code warnings. */ |
|---|
| 1171 | #ifndef BDBG_NO_MSG |
|---|
| 1172 | #define BDBG_NO_MSG 1 |
|---|
| 1173 | #endif |
|---|
| 1174 | #ifndef BDBG_NO_WRN |
|---|
| 1175 | #define BDBG_NO_WRN 1 |
|---|
| 1176 | #endif |
|---|
| 1177 | #ifndef BDBG_NO_LOG |
|---|
| 1178 | #define BDBG_NO_LOG 1 |
|---|
| 1179 | #endif |
|---|
| 1180 | #endif /* BDBG_DEBUG_BUILD */ |
|---|
| 1181 | |
|---|
| 1182 | #if BDBG_NO_MSG |
|---|
| 1183 | #define BDBG_ENTER(function) BDBG_NOP() |
|---|
| 1184 | #define BDBG_MODULE_ENTER(module,function) BDBG_NOP() |
|---|
| 1185 | #define BDBG_LEAVE(function) BDBG_NOP() |
|---|
| 1186 | #define BDBG_MODULE_LEAVE(module,function) BDBG_NOP() |
|---|
| 1187 | #define BDBG_MSG(format) BDBG_NOP() |
|---|
| 1188 | #define BDBG_MODULE_MSG(module, format) BDBG_NOP() |
|---|
| 1189 | #define BDBG_INSTANCE_MSG(instance, format) BDBG_NOP() |
|---|
| 1190 | #define BDBG_MODULE_INSTANCE_MSG(module, instance, format) BDBG_NOP() |
|---|
| 1191 | #else |
|---|
| 1192 | #define BDBG_ENTER(function) ((BDBG_eTrace >= b_dbg_module.level)? BDBG_EnterFunction(&b_dbg_module, #function) : (void)0) |
|---|
| 1193 | #define BDBG_MODULE_ENTER(module, function) ((BDBG_eTrace >= b_dbg_module_##module.level)? BDBG_EnterFunction(&b_dbg_module_##module, #function) : (void)0) |
|---|
| 1194 | #define BDBG_LEAVE(function) ((BDBG_eTrace >= b_dbg_module.level)? BDBG_LeaveFunction(&b_dbg_module, #function) : (void)0) |
|---|
| 1195 | #define BDBG_MODULE_LEAVE(module, function) ((BDBG_eTrace >= b_dbg_module_##module.level)? BDBG_LeaveFunction(&b_dbg_module_##module, #function) : (void)0) |
|---|
| 1196 | #define BDBG_MSG(format) BDBG_P_PRINTMSG(BDBG_eMsg, format) |
|---|
| 1197 | #define BDBG_MODULE_MSG(module, format) BDBG_P_MODULE_PRINTMSG(module, BDBG_eMsg, format) |
|---|
| 1198 | #define BDBG_INSTANCE_MSG(instance, format) BDBG_P_INSTANCE_PRINTMSG(BDBG_eMsg, instance, format) |
|---|
| 1199 | #define BDBG_MODULE_INSTANCE_MSG(module, instance, format) BDBG_P_MODULE_INSTANCE_PRINTMSG(module, BDBG_eMsg, instance, format) |
|---|
| 1200 | #endif |
|---|
| 1201 | |
|---|
| 1202 | #if BDBG_NO_WRN |
|---|
| 1203 | #define BDBG_WRN(format) BDBG_NOP() |
|---|
| 1204 | #define BDBG_MODULE_WRN(module,format) BDBG_NOP() |
|---|
| 1205 | #define BDBG_INSTANCE_WRN(instance, format) BDBG_NOP() |
|---|
| 1206 | #define BDBG_MODULE_INSTANCE_WRN(module,instance, format) BDBG_NOP() |
|---|
| 1207 | #else |
|---|
| 1208 | #define BDBG_WRN(format) BDBG_P_PRINTMSG(BDBG_eWrn, format) |
|---|
| 1209 | #define BDBG_MODULE_WRN(module,format) BDBG_P_MODULE_PRINTMSG(module, BDBG_eWrn, format) |
|---|
| 1210 | #define BDBG_INSTANCE_WRN(instance, format) BDBG_P_INSTANCE_PRINTMSG(BDBG_eWrn, instance, format) |
|---|
| 1211 | #define BDBG_MODULE_INSTANCE_WRN(module, instance, format) BDBG_P_MODULE_INSTANCE_PRINTMSG(module, BDBG_eWrn, instance, format) |
|---|
| 1212 | #endif |
|---|
| 1213 | |
|---|
| 1214 | #if BDBG_DEBUG_BUILD |
|---|
| 1215 | #if B_REFSW_DEBUG_COMPACT_ERR |
|---|
| 1216 | #define BDBG_ERR(format) BDBG_P_PrintString("### Error at %s:%d\n", __FILE__, __LINE__) |
|---|
| 1217 | #define BDBG_MODULE_ERR(module,format) BDBG_ERR(format) |
|---|
| 1218 | #define BDBG_INSTANCE_ERR(instance, format) BDBG_ERR(format) |
|---|
| 1219 | #define BDBG_MODULE_INSTANCE_ERR(module, instance, format) BDBG_ERR(format) |
|---|
| 1220 | #else |
|---|
| 1221 | #define BDBG_ERR(format) BDBG_P_PRINTMSG(BDBG_eErr, format) |
|---|
| 1222 | #define BDBG_MODULE_ERR(module,format) BDBG_P_MODULE_PRINTMSG(module,BDBG_eErr, format) |
|---|
| 1223 | #define BDBG_INSTANCE_ERR(instance, format) BDBG_P_INSTANCE_PRINTMSG(BDBG_eErr, instance, format) |
|---|
| 1224 | #define BDBG_MODULE_INSTANCE_ERR(module, instance, format) BDBG_P_MODULE_INSTANCE_PRINTMSG(module,BDBG_eErr, instance, format) |
|---|
| 1225 | #endif |
|---|
| 1226 | #else |
|---|
| 1227 | #define BDBG_ERR(format) BDBG_NOP() |
|---|
| 1228 | #define BDBG_MODULE_ERR(module,format) BDBG_NOP() |
|---|
| 1229 | #define BDBG_INSTANCE_ERR(instance, format) BDBG_NOP() |
|---|
| 1230 | #define BDBG_MODULE_INSTANCE_ERR(module, instance, format) BDBG_NOP() |
|---|
| 1231 | #endif |
|---|
| 1232 | |
|---|
| 1233 | #if BDBG_NO_LOG |
|---|
| 1234 | #define BDBG_LOG(format) BDBG_NOP() |
|---|
| 1235 | #define BDBG_MODULE_LOG(module,format) BDBG_NOP() |
|---|
| 1236 | #define BDBG_INSTANCE_LOG(instance, format) BDBG_NOP() |
|---|
| 1237 | #define BDBG_MODULE_INSTANCE_LOG(module, instance, format) BDBG_NOP() |
|---|
| 1238 | #else |
|---|
| 1239 | #define BDBG_LOG(format) BDBG_P_PRINTMSG(BDBG_eLog, format) |
|---|
| 1240 | #define BDBG_MODULE_LOG(module,format) BDBG_P_MODULE_PRINTMSG(module,BDBG_eLog, format) |
|---|
| 1241 | #define BDBG_INSTANCE_LOG(instance, format) BDBG_P_INSTANCE_PRINTMSG(BDBG_eLog, instance, format) |
|---|
| 1242 | #define BDBG_MODULE_INSTANCE_LOG(module, instance, format) BDBG_P_MODULE_INSTANCE_PRINTMSG(module,BDBG_eLog, instance, format) |
|---|
| 1243 | #endif |
|---|
| 1244 | |
|---|
| 1245 | #ifdef __cplusplus |
|---|
| 1246 | } |
|---|
| 1247 | #endif |
|---|
| 1248 | #include "bdbg_app.h" |
|---|
| 1249 | #include "bdbg_priv.h" |
|---|
| 1250 | |
|---|
| 1251 | #endif /* BDBG_H */ |
|---|