Changeset 109 in libcf for trunk/src/cf_debug.c


Ignore:
Timestamp:
06/04/13 14:25:10 (11 years ago)
Author:
cheese
Message:

#1 add typical data structure algorithms (linked-list / queue / stak) and rename symbol for context of each modules

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/cf_debug.c

    r107 r109  
    2525        return CF_ERROR_DEBUG_INVALID_CTX
    2626
    27 /**
    28  * 디버그 컨텍스트
    29  *
    30  * @remark change from public to private
    31  */
     27/** 디버그 컨텍스트 (Opaque) */
    3228typedef void *  CF_Debug_Ctx;
    3329
    34 /* *
    35  * 콜스택 데이터
    36  *
    37  * @remark change from public to private
    38  */
     30/** 콜스택 인터페이스 */
    3931typedef struct cf_debug_callStack {
    4032    char    file[NAME_LENGTH + 1];      /* *< 파일 이름 */
     
    4335} CF_Debug_CallStack;
    4436
     37/** 콜스택 컨텍스트 */
    4538typedef struct __cf_debug_callstack__
    4639{
     
    5245
    5346    struct __cf_debug_callstack__   * caller;
    54 } S_CF_DEBUG_CALLSTACK, CF_DEBUG_CALLSTACK;
    55 
     47} CF_DEBUG_CALLSTACK;
     48
     49/** 디버그 컨텍스트 (CF_Debug_Ctx의 구현) */
    5650typedef struct __cf_debug_ctx__
    5751{
    58     char        file[NAME_LENGTH + 1];
    59     char        func[NAME_LENGTH + 1];
    60     int         line;
    61 
    62     CF_Mutex    mutex;
     52    int             fd;
     53    CF_Mutex_Ctx    mutex;
    6354
    6455    CF_DEBUG_CALLSTACK  callstack;
    65 } S_CF_DEBUG_CTX, CF_DEBUG_CTX;
     56} CF_DEBUG_CTX;
    6657
    6758CF_Debug_Ctx    gDebugSingleCtx = NULL;
    68 
    69 static int
    70 CF_Debug_Local_UpdateCtx (CF_Debug_Ctx  ctx,
    71                           const char    * file,
    72                           const char    * func,
    73                           const int     line)
    74 {
    75     CF_DEBUG_CTX * context = (CF_DEBUG_CTX *) ctx;
    76 
    77     ASSERT_CTX (ctx);
    78 
    79     strncpy (context->file, file, strlen (file));
    80     strncpy (context->func, func, strlen (func));
    81     context->line = line;
    82 
    83     return CF_OK;
    84 }
    8559
    8660static int
     
    232206    context->callstack.caller = push;
    233207
    234     CF_Debug_Local_UpdateCtx (ctx, file, func, line);
    235 
    236208    return CF_OK;
    237209}
     
    294266        return CF_ERROR_DEBUG_PEEK_CALLSTACK;
    295267
    296     memset (context->file, 0x00, sizeof (context->file));
    297     memset (context->func, 0x00, sizeof (context->func));
    298     context->line = 0;
    299 
    300     /* restore current context */
    301     if (pop->caller != NULL)
    302     {
    303         CF_Debug_Local_UpdateCtx (ctx,
    304                                   pop->caller->file,
    305                                   pop->caller->func,
    306                                   pop->caller->line);
    307     }
    308 
    309268    context->callstack.caller = pop->caller;
    310269    free (pop);
     
    333292
    334293    if (context->mutex)
    335         CF_Mutex_Destory (&context->mutex);
     294        CF_Mutex_DestoryCtx (&context->mutex);
    336295
    337296    free (context);
     
    357316        if (context == NULL)
    358317        {
    359             result = CF_ERROR_DEBUG_ALLOCATE_CTX;
     318            result = CF_ERROR_DEBUG_CREATE_CTX;
    360319            TRY_BREAK;
    361320        }
    362321
    363         result = CF_Mutex_Create (&context->mutex);
     322        result = CF_Mutex_CreateCtx (&context->mutex);
    364323        if (result < 0)
    365324        {
Note: See TracChangeset for help on using the changeset viewer.