source: libcf/trunk/include/cf_debug.h@ 120

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

#1 fix header in debug util

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