source: libcf/trunk/include/cf_debug.h

Last change on this file was 128, checked in by cheese, 11 years ago

#1 add bitwise util from ARIA of chevalier

File size: 2.9 KB
RevLine 
[6]1/**
[128]2 * \file cf_debug.h
[26]3 *
[128]4 * \author myusgun <myusgun@gmail.com>
5 *
[119]6 * \brief 디버그 유틸
[116]7 *
[119]8 * \remarks
[26]9 * 디버그 함수를 직접 호출하지 않고 정의된 매크로를 사용하면,
10 * Preprocessor에 _DEBUG가 정의되어 있는 경우에 만
11 * 디버그 코드가 동작하도록 할 수 있음 <br />
[66]12 * 디버그 메시지는 stdout 및 stderr 등의 파일 포인터 출력을 지원함
[34]13 *
[119]14 * \example debug.c
[6]15 */
16#ifndef __CF_DEBUG_H__
17#define __CF_DEBUG_H__
18
19#include "cf_base.h"
[128]20#include "cf_type.h"
[6]21
[16]22#include <stdio.h>
[66]23#include <stddef.h>
[16]24
[26]25/** Windows 함수 이름 매크로 재정의 */
[50]26#if defined(_WIN32) || defined(_WIN64)
[6]27# define __func__ __FUNCTION__
28#endif
29
30#ifdef _DEBUG
[25]31
[26]32/**
33 * 디버그 메시지를 지정된 파일 포인터로 출력
34 *
[120]35 * \param __fp 출력할 파일 포인터
[119]36 * \param __fmt 포맷 스트링
37 * \param ... 가변 인자
[26]38 */
[64]39# define CF_DEBUG_PRINT(__fp,__fmt,...) \
[16]40 CF_Debug_Print (__fp,__FILE__,__func__,__LINE__,__fmt,##__VA_ARGS__)
[25]41
[26]42/**
43 * 바이너리 데이터를 디버그 메시지와 함께 지정된 파일 포인터로 출력
44 *
[120]45 * \param __fp 출력할 파일 포인터
[119]46 * \param __bin 바이너리 데이터
47 * \param __len 바이너리 길이
48 * \param __fmt 포맷 스트링
49 * \param ... 가변 인자
[26]50 */
[64]51# define CF_DEBUG_PRINT_BIN(__fp,__bin,__len,__fmt,...) \
[16]52 CF_Debug_PrintBin (__fp,__FILE__,__func__,__LINE__,__bin,__len,__fmt,##__VA_ARGS__)
[25]53
[120]54/** 디버깅 모듈 초기화 */
[64]55# define CF_DEBUG_INITIALIZE \
[62]56 CF_Debug_Initialize ()
57
[120]58/** 디버깅 모듈 해제 */
[64]59# define CF_DEBUG_FINALIZE \
[62]60 CF_Debug_Finalize ()
61
[120]62/** 함수에 진입 */
[64]63# define CF_DEBUG_BEGIN_FUNCTION \
[51]64 CF_Debug_EnterFunction (__FILE__,__func__,__LINE__)
[25]65
[120]66/** 함수에서 리턴 */
[64]67# define CF_DEBUG_END_FUNCTION \
[51]68 CF_Debug_LeaveFunction ()
[25]69
[120]70/** 콜스택 을 지정된 파일 포인터로 출력 */
[64]71# define CF_DEBUG_PRINT_CALLSTACK(__fp) \
[63]72 CF_Debug_PrintCallStack (__fp)
73
[6]74#else // #ifdef _DEBUG
[25]75# define CF_DEBUG_PRINT(__fp,__fmt,...)
76# define CF_DEBUG_PRINT_BIN(__fp,__bin,__len,__fmt,...)
[62]77# define CF_DEBUG_INITIALIZE
78# define CF_DEBUG_FINALIZE
[51]79# define CF_DEBUG_BEGIN_FUNCTION
80# define CF_DEBUG_END_FUNCTION
[63]81# define CF_DEBUG_PRINT_CALLSTACK(__fp)
[6]82#endif // #ifdef _DEBUG
83
84#ifdef __cplusplus
85extern "C" {
86#endif
87
88CF_EXPORT int
[16]89CF_Debug_Print (FILE * fp,
90 const char * file,
91 const char * func,
92 const int line,
93 const char * fmt, ...);
94
[26]95CF_EXPORT int
[128]96CF_Debug_PrintBin (FILE * fp,
97 const char * file,
98 const char * func,
99 const int line,
100 const cf_byte * bin,
101 const size_t len,
102 const char * fmt, ...);
[16]103
104CF_EXPORT int
[62]105CF_Debug_Initialize (void);
106
107CF_EXPORT int
108CF_Debug_Finalize (void);
109
110CF_EXPORT int
[51]111CF_Debug_PrintCallStack (FILE * fp);
[6]112
113CF_EXPORT int
[51]114CF_Debug_EnterFunction (const char * file,
115 const char * func,
116 const int line);
[6]117
118CF_EXPORT int
[51]119CF_Debug_LeaveFunction (void);
[6]120
[10]121#ifdef __cplusplus
122}
123#endif
124
[6]125#endif // #ifndef __CF_DEBUG_H__
Note: See TracBrowser for help on using the repository browser.