OpenClovis Logo

clDebugApi.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2002-2012 OpenClovis Solutions Inc. All Rights Reserved.
3  *
4  * This file is available under a commercial license from the
5  * copyright holder or the GNU General Public License Version 2.0.
6  *
7  * The source code for this program is not published or otherwise
8  * divested of its trade secrets, irrespective of what has been
9  * deposited with the U.S. Copyright office.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * General Public License for more details.
15  *
16  * For more information, see the file COPYING provided with this
17  * material.
18  */
19 /*******************************************************************************
20 * ModuleName : debug
21 * File : clDebugApi.h
22 *******************************************************************************/
23 
24 /*******************************************************************************
25 * Description :
26 * This This module contains common DEBUG definitions
27 ******************************************************************************/
28 
41 #ifndef _CL_DEBUG_API_H_
42 #define _CL_DEBUG_API_H_
43 
44 #ifdef __cplusplus
45 extern "C" {
46 #endif
47 
48 #include <clCommon.h>
49 #include <clDebugErrors.h>
50 #include <clHandleApi.h>
51 #include <clLogApi.h>
52 #include <clRmdIpi.h>
53 #ifndef __KERNEL__
54 #include <stdio.h>
55 #include <unistd.h>
56 #include <time.h>
57 #endif
58 
59 #ifdef SOLARIS_BUILD
60 #include <ucontext.h>
61 #include <stdlib.h>
62 #include <string.h>
63 int backtrace(void **buffer, int count);
64 char **backtrace_symbols(void *const *array, int size);
65 void backtrace_symbols_fd(void *const *array, int size, int fd);
66 #endif /* SOLARIS_BUILD */
67 
68 /******************************************************************************
69  * Constant and Macro Definitions
70  *****************************************************************************/
71 
80 #define CL_DEBUG_CRITICAL 3
81 
85 #define CL_DEBUG_ERROR 4
86 
90 #define CL_DEBUG_WARN 5
91 
95 #define CL_DEBUG_INFO 7
96 
100 #define CL_DEBUG_TRACE 0xc
101 
107 #if !defined(CL_DEBUG_LEVEL_THRESHOLD)
108 #define CL_DEBUG_LEVEL_THRESHOLD CL_DEBUG_ERROR
109 #endif
110 
117 #ifndef CL_DEBUG
118 #define CL_DEBUG
119 #endif
120 
121 #ifdef CL_DEBUG
122 #ifndef __KERNEL__
123 #include <clEoApi.h>
124 #include <clDbg.h>
125 
126 #define CL_DEBUG_SP(...) __VA_ARGS__
127 
128 
129 enum
130  {
131  clDebugTimeStrMaxLen = 128
132  };
133 
134 #define CL_DEBUG_PRINT(x,y) \
135  do \
136  {\
137  char __str[256]; \
138  if(x <= CL_DEBUG_LEVEL_THRESHOLD) \
139  {\
140  snprintf(__str,256,CL_DEBUG_SP y); \
141  clLog((ClLogSeverityT)x, CL_LOG_AREA_UNSPECIFIED, CL_LOG_CONTEXT_UNSPECIFIED,\
142  __str);\
143  }\
144  if (1) \
145  { \
146  snprintf(__str,256,CL_DEBUG_SP y); \
147  clDbgMsg((int)getpid(),__FILE__, __LINE__, __FUNCTION__,x,__str); \
148  } \
149  }while (0)
150 
151 #define CL_DEBUG_PRINT_CONSOLE(x,y) \
152  do \
153  { \
154  char __str[256]; \
155  if(x <= CL_DEBUG_LEVEL_THRESHOLD) \
156  { \
157  snprintf(__str,256,CL_DEBUG_SP y); \
158  clLogConsole((ClLogSeverityT)x, CL_LOG_AREA_UNSPECIFIED, CL_LOG_CONTEXT_UNSPECIFIED, \
159  __str); \
160  } \
161  if (1) \
162  { \
163  snprintf(__str,256,CL_DEBUG_SP y); \
164  clDbgMsg((int)getpid(),__FILE__, __LINE__, __FUNCTION__,x,__str); \
165  } \
166  }while (0)
167 
168 #else /* __KERNEL__ */
169 
170 #define CL_DEBUG_PRINT(x,y) \
171  do \
172  { \
173  if(x <= CL_DEBUG_LEVEL_THRESHOLD) \
174  {\
175  printk("file:%s,func:%s,line:%d: ", __FILE__, __FUNCTION__, __LINE__);\
176  printk y; \
177  }\
178  }while (0)
179 
180 #define CL_DEBUG_PRINT_CONSOLE CL_DEBUG_PRINT
181 
182 #endif
183 
184 #else /* CL_DEBUG */
185 #define CL_DEBUG_PRINT(x,y)
186 #define CL_DEBUG_PRINT_CONSOLE(x, y)
187 #endif
188 
192 #define CL_FUNC_ENTER()
193 
194 
198 #define CL_FUNC_EXIT()
199 
200 
204 #ifndef __KERNEL__
205 #include <assert.h>
206 #define CL_ASSERT(expr) do { if (clDbgPauseOnCodeError&&(!(expr))) clDbgCodeError(0,("Assertion failed")); else assert((expr)); } while(0)
207 #endif /* __KERNEL__ */
208 
209 struct clEoExecutionObj;
210 
214 #define CL_DEBUG_COMP_PROMPT_LEN 15
215 
216 
220 #define CL_DEBUG_COMP_NAME_LEN 128
221 
222 
226 #define CL_DEBUG_FUNC_NAME_LEN 41
227 
231 #define CL_DEBUG_FUNC_HELP_LEN 201
232 
239 
243  ClUint32T argc,
244 
248  ClCharT** argv,
249 
253  ClCharT** ret);
254 
258 typedef struct ClDebugFuncEntryT
259 {
264 
269 
275 
279 typedef struct ClDebugModEntryT {
280 
284  char modName[80];
285 
289  char modPrompt[20];
290 
295  char help[80];
297 
301 typedef ClPtrT ClDebugPrintHandleT;
302 
303 /*****************************************************************************
304  * Debug APIs
305  *****************************************************************************/
306 
329  CL_IN ClCharT *nprompt /*this string is incorporated into the debug CLI prompt*/);
330 
331 
356 
357 
358 
383 
409  ClRcT clDebugPromptSet(CL_IN const ClCharT *pCompPrompt);
410 
435  CL_IN ClUint32T funcArrayLen,
436  CL_OUT ClHandleT *phDebugReg);
437 
438 
439 
464 ClRcT clDebugDeregister(CL_IN ClHandleT hReg);
465 
489 ClRcT clDebugPrintInitialize(CL_OUT ClDebugPrintHandleT* msg /*handle for printing*/);
490 
491 
517 ClRcT clDebugPrint(CL_INOUT ClDebugPrintHandleT msg,
518  CL_IN const char* fmtStr,
519  ...) CL_PRINTF_FORMAT(2, 3);
520 
521 
547 ClRcT clDebugPrintFinalize(CL_IN ClDebugPrintHandleT* msg,
548  CL_OUT char** buf);
549 
550 
573 ClRcT clDebugPrintDestroy(CL_INOUT ClDebugPrintHandleT* msg);
574 
598 
599 ClRcT clDebugResponseSend(ClRmdResponseContextHandleT responseHandle,
600  ClBufferHandleT *pOutMsgHandle,
601  ClCharT *respBuffer,
602  ClRcT retCode);
603 ClRcT clDebugResponseDefer(ClRmdResponseContextHandleT *pResponseHandle, ClBufferHandleT *pOutMsgHandle);
604 
605 #ifdef __cplusplus
606 }
607 #endif
608 
609 #endif /* _CL_DEBUG_API_H_ */
610 

Generated on Tue Jan 10 10:29:15 PST 2012 for OpenClovis SDK using Doxygen