Changeset 63 in libcf
- Timestamp:
- 04/09/13 11:20:55 (11 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/cf_debug.h
r62 r63 79 79 80 80 /** 81 * 함수에서 종료81 * 함수에서 리턴 82 82 * 83 83 * @see CF_Debug_LeaveFunction … … 85 85 # define CF_DEBUG_END_FUNCTION \ 86 86 CF_Debug_LeaveFunction () 87 88 /** 89 * 콜스택 을 지정된 파일 포인터로 출력 90 * 91 * @see CF_Debug_PrintCallStack 92 */ 93 # define CF_DEBUG_PRINT_CALLSTACK(__fp) \ 94 CF_Debug_PrintCallStack (__fp) 87 95 88 96 #else // #ifdef _DEBUG … … 93 101 # define CF_DEBUG_BEGIN_FUNCTION 94 102 # define CF_DEBUG_END_FUNCTION 103 # define CF_DEBUG_PRINT_CALLSTACK(__fp) 95 104 #endif // #ifdef _DEBUG 96 105 -
trunk/src/cf_debug.c
r62 r63 414 414 415 415 /** 416 * 함수 진입을 명시 (글로벌 컨텍스트) 417 * 418 * @return 성공 시, CF_OK; 실패 시, 오류 코드 419 * 420 * @param file 파일 경로 421 * @param func 함수 이름 422 * @param line 라인 넘버 423 * 424 * @see CF_Debug_LeaveFunction 425 */ 426 int 427 CF_Debug_EnterFunction (const char * file, 428 const char * func, 429 const int line) 430 { 431 CF_DEBUG_CTX * ctx = (CF_DEBUG_CTX *)gDebugSingleCtx; 432 433 ASSERT_CTX (ctx); 434 435 CF_Mutex_Lock (&ctx->mutex); 436 CF_Debug_CallStackPush (gDebugSingleCtx, file, func, line); 437 CF_Mutex_Unlock (&ctx->mutex); 438 439 return CF_OK; 440 } 441 442 /** 443 * 함수 종료를 명시 (글로벌 컨텍스트) 444 * 445 * @return 성공 시, CF_OK; 실패 시, 오류 코드 446 * 447 * @see CF_Debug_EnterFunction 448 */ 449 int 450 CF_Debug_LeaveFunction (void) 451 { 452 CF_DEBUG_CTX * ctx = (CF_DEBUG_CTX *)gDebugSingleCtx; 453 454 ASSERT_CTX (ctx); 455 456 CF_Mutex_Lock (&ctx->mutex); 457 CF_Debug_CallStackPop (gDebugSingleCtx, NULL); 458 CF_Mutex_Unlock (&ctx->mutex); 459 460 return CF_OK; 461 } 462 463 /** 416 464 * 현재 콜스택을 출력 (글로벌 컨텍스트) 417 465 * … … 428 476 CF_DEBUG_CALLSTACK * callstack = NULL; 429 477 430 if (ctx == NULL) 431 return CF_ERROR_DEBUG_INVALID_CTX; 478 ASSERT_CTX (ctx); 432 479 433 480 for ( callstack = ctx->callstack.caller … … 435 482 ; callstack = callstack->caller) 436 483 { 437 fprintf (fp, "#%-4d %s <%s:%d>\n", 438 iter++, 439 callstack->func, 440 callstack->file, 441 callstack->line); 442 } 443 444 return CF_OK; 445 } 446 447 /** 448 * 함수 진입을 명시 (글로벌 컨텍스트) 449 * 450 * @return 성공 시, CF_OK; 실패 시, 오류 코드 451 * 452 * @param file 파일 경로 453 * @param func 함수 이름 454 * @param line 라인 넘버 455 * 456 * @see CF_Debug_LeaveFunction 457 */ 458 int 459 CF_Debug_EnterFunction (const char * file, 460 const char * func, 461 const int line) 462 { 463 CF_DEBUG_CTX * ctx = (CF_DEBUG_CTX *)gDebugSingleCtx; 464 465 ASSERT_CTX (ctx); 466 467 CF_Mutex_Lock (&ctx->mutex); 468 CF_Debug_CallStackPush (gDebugSingleCtx, file, func, line); 469 CF_Mutex_Unlock (&ctx->mutex); 470 471 return CF_OK; 472 } 473 474 /** 475 * 함수 종료를 명시 (글로벌 컨텍스트) 476 * 477 * @return 성공 시, CF_OK; 실패 시, 오류 코드 478 * 479 * @see CF_Debug_EnterFunction 480 */ 481 int 482 CF_Debug_LeaveFunction (void) 483 { 484 CF_DEBUG_CTX * ctx = (CF_DEBUG_CTX *)gDebugSingleCtx; 485 486 ASSERT_CTX (ctx); 487 488 CF_Mutex_Lock (&ctx->mutex); 489 CF_Debug_CallStackPop (gDebugSingleCtx, NULL); 490 CF_Mutex_Unlock (&ctx->mutex); 491 492 return CF_OK; 493 } 484 fprintf (fp == NULL ? stderr : fp, 485 "#%-4d %s <%s:%d>\n", 486 iter++, 487 callstack->func, 488 callstack->file, 489 callstack->line); 490 } 491 492 return CF_OK; 493 } -
trunk/test/debug.c
r62 r63 12 12 CF_DEBUG_BEGIN_FUNCTION; 13 13 14 CF_D ebug_PrintCallStack(stdout);14 CF_DEBUG_PRINT_CALLSTACK (stdout); 15 15 16 16 CF_DEBUG_END_FUNCTION; -
trunk/test/test.c
r62 r63 29 29 const char * file = "./log.txt"; 30 30 31 int test_log_mt (void * arg); 32 void test_log (const char * message); 33 void test_file (const char * message); 34 void test_callstack3 (void); 35 void test_callstack2 (void); 36 void test_callstack1 (void); 37 int socket_echo_server (void * arg); 38 int socket_echo_client (void * arg); 39 void test_socket (void); 40 41 int main (int argc, char ** argv) 42 { 43 CF_DEBUG_INITIALIZE; 44 CF_DEBUG_BEGIN_FUNCTION; 45 46 // 1 47 CF_DEBUG_PRINT (stderr, " == LOG TEST ==\n"); 48 test_log ("LOG_TEST"); 49 50 // 2 51 CF_DEBUG_PRINT (stderr, " == FILE READ TEST ==\n"); 52 test_file ("FILE_READ_TEST"); 53 54 // 3 55 CF_DEBUG_PRINT (stderr, " == CALLSTACK TEST ==\n"); 56 test_callstack1 (); 57 58 // 4 59 CF_DEBUG_PRINT (stderr, " == MULTI-THREADED SOCKET TEST ==\n"); 60 test_socket (); 61 62 CF_DEBUG_PRINT (stderr, " == END OF TEST ==\n"); 63 64 CF_DEBUG_END_FUNCTION; 65 CF_DEBUG_FINALIZE; 66 67 return 0; 68 } 69 31 70 int test_log_mt (void * arg) 32 71 { … … 157 196 { 158 197 CF_DEBUG_BEGIN_FUNCTION; 159 CF_D ebug_PrintCallStack(stdout);198 CF_DEBUG_PRINT_CALLSTACK (stdout); 160 199 CF_DEBUG_END_FUNCTION; 161 200 } … … 331 370 } 332 371 333 int main (int argc, char ** argv)334 {335 CF_DEBUG_INITIALIZE;336 CF_DEBUG_BEGIN_FUNCTION;337 338 // 1339 CF_DEBUG_PRINT (stderr, " == LOG TEST ==\n");340 test_log ("LOG_TEST");341 342 // 2343 CF_DEBUG_PRINT (stderr, " == FILE READ TEST ==\n");344 test_file ("FILE_READ_TEST");345 346 // 3347 CF_DEBUG_PRINT (stderr, " == CALLSTACK TEST ==\n");348 test_callstack1 ();349 350 // 4351 CF_DEBUG_PRINT (stderr, " == MULTI-THREADED SOCKET TEST ==\n");352 test_socket ();353 354 CF_DEBUG_PRINT (stderr, " == END OF TEST ==\n");355 356 CF_DEBUG_END_FUNCTION;357 CF_DEBUG_FINALIZE;358 359 return 0;360 }361
Note:
See TracChangeset
for help on using the changeset viewer.