Changeset 51 in libcf for trunk/include/cf_debug.h


Ignore:
Timestamp:
04/02/13 10:23:52 (11 years ago)
Author:
cheese
Message:

#1 change the debugging utiltity to support single context with mutex

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/cf_debug.h

    r50 r51  
    2727
    2828#ifdef _DEBUG
    29 /**
    30  * 디버그 컨텍스트 생성
    31  *
    32  * @see CF_Debug_CreateCtx
    33  */
    34 # define CF_DEBUG_CREATE_CTX()                                      \
    35     CF_Debug_CreateCtx ()
    36 
    37 /**
    38  * 디버그 컨텍스트 해제
    39  *
    40  * @param __ctx 디버그 컨텍스트
    41  *
    42  * @see CF_Debug_DestroyCtx
    43  */
    44 # define CF_DEBUG_DESTROY_CTX(__ctx)                                \
    45     CF_Debug_DestroyCtx (__ctx)
    4629
    4730/**
    4831 * 디버그 메시지를 지정된 파일 포인터로 출력
    4932 *
    50  * @param __fp  파일 포인터. 표준출력(stdout) 및 표준오류(stderr) 사용 가능
    5133 * @param __fmt 포맷 스트링
    5234 * @param ...   가변 인자
     
    6042 * 바이너리 데이터를 디버그 메시지와 함께 지정된 파일 포인터로 출력
    6143 *
    62  * @param __fp  파일 포인터. 표준출력(stdout) 및 표준오류(stderr) 사용 가능
    6344 * @param __bin 바이너리 데이터
    6445 * @param __len 바이너리 길이
     
    7253
    7354/**
    74  * 컨텍스트를 업데이트하고 디버그 메시지를 출력
     55 * 함수에 진입
    7556 *
    76  * @param __ctx 디버그 컨텍스트
    77  * @param __fmt 포맷 스트링
    78  * @param ...   가변 인자
    79  *
    80  * @see CF_Debug_Trace
     57 * @see CF_Debug_EnterFunction
    8158 */
    82 # define CF_DEBUG_TRACE(__ctx,__fmt,...)                            \
    83     CF_Debug_Trace (__ctx,__FILE__,__func__,__LINE__,__fmt,##__VA_ARGS__)
     59# define CF_DEBUG_BEGIN_FUNCTION                                \
     60    CF_Debug_EnterFunction (__FILE__,__func__,__LINE__)
    8461
    8562/**
    86  * 컨텍스트를 업데이트하고 바이너리 데이터를 디버그 메시지와 함께 출력
     63 * 함수에서 종료
    8764 *
    88  * @param __ctx 디버그 컨텍스트
    89  * @param __bin 바이너리 데이터
    90  * @param __len 바이너리 길이
    91  * @param __fmt 포맷 스트링
    92  * @param ...   가변 인자
    93  *
    94  * @see CF_Debug_TraceBin
     65 * @see CF_Debug_LeaveFunction
    9566 */
    96 # define CF_DEBUG_TRACE_BIN(__ctx,__bin,__len,__fmt,...)            \
    97     CF_Debug_TraceBin (__ctx,__FILE__,__func__,__LINE__,__bin,__len,__fmt,##__VA_ARGS__)
     67# define CF_DEBUG_END_FUNCTION                  \
     68    CF_Debug_LeaveFunction ()
    9869
    99 /**
    100  * 컨텍스트에 콜스택 푸시
    101  *
    102  * @param __ctx 디버그 컨텍스트
    103  *
    104  * @see CF_Debug_CallStackPush
    105  */
    106 # define CF_DEBUG_CALLSTACK_PUSH(__ctx)                             \
    107     CF_Debug_CallStackPush (__ctx,__FILE__,__func__,__LINE__)
    108 
    109 /**
    110  * 컨텍스트에서 콜스택 팝
    111  *
    112  * @param __ctx         디버그 컨텍스트
    113  * @param __callstack   콜스택 정보를 가져올 콜스택 데이터 구조체 포인터
    114  *
    115  * @see CF_Debug_CallStackPop, CF_Debug_CallStack
    116  */
    117 # define CF_DEBUG_CALLSTACK_POP(__ctx,__callstack)                  \
    118     CF_Debug_CallStackPop (__ctx,__callstack)
    11970#else // #ifdef _DEBUG
    120 # define CF_DEBUG_CREATE_CTX()                          NULL
    121 # define CF_DEBUG_DESTROY_CTX(__ctx)
    12271# define CF_DEBUG_PRINT(__fp,__fmt,...)
    12372# define CF_DEBUG_PRINT_BIN(__fp,__bin,__len,__fmt,...)
    124 # define CF_DEBUG_TRACE(__ctx,__fmt,...)
    125 # define CF_DEBUG_TRACE_BIN(__ctx,__bin,__len,__fmt,...)
    126 # define CF_DEBUG_CALLSTACK_PUSH(__ctx)
    127 # define CF_DEBUG_CALLSTACK_POP(__ctx,__callstack)      1
     73# define CF_DEBUG_BEGIN_FUNCTION
     74# define CF_DEBUG_END_FUNCTION
    12875#endif // #ifdef _DEBUG
    129 
    130 /** 디버그 컨텍스트 */
    131 typedef void *  CF_Debug_Ctx;
    132 
    133 /** 콜스택 데이터 */
    134 typedef struct cf_debug_callStack {
    135     char    file[NAME_LENGTH + 1];      /**< 파일 이름 */
    136     char    function[NAME_LENGTH + 1];  /**< 함수 이름 */
    137     int     line;                       /**< 라인 넘버 */
    138 } CF_Debug_CallStack;
    13976
    14077#ifdef __cplusplus
    14178extern "C" {
    14279#endif
    143 
    144 CF_EXPORT CF_Debug_Ctx
    145 CF_Debug_CreateCtx      (void);
    146 
    147 CF_EXPORT int
    148 CF_Debug_DestroyCtx     (CF_Debug_Ctx ctx);
    149 
    150 CF_EXPORT int
    151 CF_Debug_SetOutputFD    (CF_Debug_Ctx   ctx,
    152                          int            fd);
    15380
    15481CF_EXPORT int
     
    16996
    17097CF_EXPORT int
    171 CF_Debug_Trace          (CF_Debug_Ctx   ctx,
    172                          const char     * file,
    173                          const char     * func,
    174                          const int      line,
    175                          const char     * fmt, ...);
     98CF_Debug_PrintCallStack (FILE * fp);
    17699
    177100CF_EXPORT int
    178 CF_Debug_TraceBin       (CF_Debug_Ctx           ctx,
    179                          const char             * file,
    180                          const char             * func,
    181                          const int              line,
    182                          const unsigned char    * bin,
    183                          const int              len,
    184                          const char             * fmt, ...);
     101CF_Debug_EnterFunction  (const char * file,
     102                         const char * func,
     103                         const int  line);
    185104
    186105CF_EXPORT int
    187 CF_Debug_CallStackPush  (CF_Debug_Ctx   ctx,
    188                          const char     * file,
    189                          const char     * func,
    190                          const int      line);
    191 
    192 CF_EXPORT int
    193 CF_Debug_CallStackPop   (CF_Debug_Ctx       ctx,
    194                          CF_Debug_CallStack * callstack);
     106CF_Debug_LeaveFunction  (void);
    195107
    196108#ifdef __cplusplus
Note: See TracChangeset for help on using the changeset viewer.