📄 trace.h
字号:
/************************************************************************@author Julian Bromwich@date April 20, 2004This allows runtime tracing of function calls.Example output: ==> get_policy_from_sanode() in spd_get_policy.c:1737 ==> get_policy_from_proto_port_container() in spd_get_policy.c:695 ==> get_policy_from_proto_dport_node() in spd_get_policy.c:743 ==> get_policy_from_proto_sport_node() in spd_get_policy.c:789 <== get_policy_from_proto_sport_node() [Failed here] in spd_get_policy.c:820 <== get_policy_from_proto_dport_node() [] in spd_get_policy.c:778 <== get_policy_from_proto_port_container() [This is interesting] in spd_get_policy.c:728 <== get_policy_from_sanode() [] in spd_get_policy.c:1789Instructions for use:Instrument the files you are interested in tracing in the following way:Add this to the top: #include "trace.h"Put this at the begining of every function: TRACE_ENTER();Put this just before every return point of each function: TRACE_EXIT(""); or TRACE_EXIT("Some arbitrary string can go here and is display as [My message]");Compile with the following flag: ADDED_CFLAGS+="-D__WRN_DEF_TRACE__"At run-time, tracing is enabled this way:-> ipsecTraceOn=1;...and disabled this way:-> ipsecTraceOn=0;*************************************************************************/#if !defined (__TRACE_H__)#define __TRACE_H__#ifdef __WRN_DEF_TRACE__#warning Compiling with trace enabledchar *traceIndent ( int adjust );extern int ipsecTraceOn;#define TRACE_ENTER() \ if (ipsecTraceOn) { \ printf("%s==> %s() in %s:%d\n", traceIndent(2), __FUNCTION__, __FILE__, __LINE__); \ }#define TRACE_EXIT(USER_STRING) \ if (ipsecTraceOn) { \ printf("%s<== %s() [%s] in %s:%d\n", traceIndent(-2), __FUNCTION__, USER_STRING, __FILE__, __LINE__); \ }#define TRACE_DEBUG(USER_STRING) \ if (ipsecTraceOn) { \ printf("%s=== %s() [%s] in %s:%d\n", traceIndent(0), __FUNCTION__, USER_STRING, __FILE__, __LINE__); \ }#else#define TRACE_ENTER()#define TRACE_EXIT(USER_STRING)#define TRACE_DEBUG(USER_STRING)#endif /* __WRN_DEF_TRACE__ */#endif /* __TRACE_H__*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -