Changeset 9 in libcf
- Timestamp:
- 01/30/13 17:39:07 (11 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/cf_debug.h
r8 r9 9 9 #define CF_ERROR_DEBUG_INVALID_CTX CF_ERROR_DEBUG - 1 10 10 #define CF_ERROR_DEBUG_SET_OUTPUT_FD CF_ERROR_DEBUG - 2 11 #define CF_ERROR_DEBUG_INVALID_ARGS CF_ERROR_DEBUG - 3 12 #define CF_ERROR_DEBUG_PUSH_CALLSTACK CF_ERROR_DEBUG - 4 13 #define CF_ERROR_DEBUG_POP_CALLSTACK CF_ERROR_DEBUG - 5 11 #define CF_ERROR_DEBUG_PUSH_CALLSTACK CF_ERROR_DEBUG - 3 12 #define CF_ERROR_DEBUG_POP_CALLSTACK CF_ERROR_DEBUG - 4 14 13 15 14 #ifdef _WIN32 … … 23 22 CF_Debug_Trace (__ctx,__bin,__len,__fmt,##__VA_ARGS__) 24 23 # define CF_DEBUG_CALLSTACK_PUSH(__ctx) \ 25 CF_Debug_CallstackPush (__ctx,__ func__,__LINE__)24 CF_Debug_CallstackPush (__ctx,__FILE__,__func__,__LINE__) 26 25 # define CF_DEBUG_CALLSTACK_POP \ 27 26 CF_Debug_CallstackPop … … 67 66 CF_EXPORT int 68 67 CF_Debug_CallStackPush (CF_Debug_Ctx ctx, 68 const char * file, 69 69 const char * func, 70 70 const int line); -
trunk/src/cf_debug.c
r8 r9 9 9 #include <ctype.h> 10 10 #include <stdarg.h> 11 #include <string.h> 11 12 12 13 #ifdef _WIN32 … … 28 29 typedef struct __cf_debug_callstack__ 29 30 { 31 char file[NAME_LENGTH + 1]; 30 32 char func[NAME_LENGTH + 1]; 31 33 int line; … … 187 189 int 188 190 CF_Debug_CallStackPush (CF_Debug_Ctx ctx, 191 const char * file, 189 192 const char * func, 190 193 const int line) … … 199 202 return CF_ERROR_DEBUG_PUSH_CALLSTACK; 200 203 204 /* push to callstack */ 205 sprintf (push->file, "%s", file); 201 206 sprintf (push->func, "%s", func); 202 207 push->line = line; 203 208 push->caller = context->callstack.caller; 204 205 209 context->callstack.caller = push; 210 211 /* set current context */ 212 sprintf (context->file, "%s", file); 213 sprintf (context->func, "%s", func); 214 context->line = line; 206 215 207 216 return CF_OK; … … 216 225 217 226 CHECK_INVALID_CTX (ctx); 218 219 if (callstack == NULL)220 return CF_ERROR_DEBUG_INVALID_ARGS;221 227 222 228 pop = context->callstack.caller; … … 224 230 return CF_ERROR_DEBUG_POP_CALLSTACK; 225 231 226 sprintf (callstack->function, "%s", pop->func); 227 callstack->line = pop->line; 228 229 context->callstack.caller = pop->caller; 232 if (callstack != NULL) 233 { 234 sprintf (callstack->function, "%s", pop->func); 235 callstack->line = pop->line; 236 } 237 238 memset (context->file, 0x00, sizeof (context->file)); 239 memset (context->func, 0x00, sizeof (context->func)); 240 context->line = 0; 241 242 /* restore current context */ 243 if (pop->caller != NULL) 244 { 245 sprintf (context->file, "%s", pop->caller->file); 246 sprintf (context->func, "%s", pop->caller->func); 247 context->line = pop->caller->line; 248 context->callstack.caller = pop->caller; 249 } 250 230 251 free (pop); 231 252
Note:
See TracChangeset
for help on using the changeset viewer.