My Project
Loading...
Searching...
No Matches
omRet2Info.h
Go to the documentation of this file.
1/*******************************************************************
2 * File: omAddr2Info.h
3 * Purpose: translation of return addr to RetInfo
4 * Author: obachman (Olaf Bachmann)
5 * Created: 11/99
6 *******************************************************************/
7#ifndef OM_RET_2_INFO_H
8#define OM_RET_2_INFO_H
9
10
12{
13 void* addr;
14 char func[200]; /* if you change these numbers, alos change */
15 char file[200]; /* the fscanf statement in BackTrace_2_RetInfo */
16 int line;
17};
18
19/* print to fd array of max RetInfo's and use fmt as format string for one RetInfo.
20 The following conversions are recognized:
21 %i -- number of return addr
22 %p -- address (in hex)
23 %F -- function name with arguments (for C++, only)
24 %N -- funtion name without arguments
25 %f -- file
26 %l -- line
27 %L -- file:line
28 return how many lines were printed */
29#ifndef OM_NDEBUG
30int omPrintRetInfo(omRetInfo info, int max, FILE *fd, const char* fmt);
31/* translate array of max BackTrace addresses into array of max RetInfos
32 return how many were translated */
33int omBackTrace_2_RetInfo(void** bt, omRetInfo info, int max);
34
35/* call with argv[0] to enable RetInfo translations */
36void omInitRet_2_Info(const char* argv0);
37
38int omPrintBackTrace(void** bt, int max, FILE* fd);
39#define omPrintCurrentBackTrace(fd) omPrintCurrentBackTraceMax(fd, 1000)
40int omPrintCurrentBackTraceMax(FILE* fd, int max);
41
42int omFilterRetInfo_i(omRetInfo info, int max, int i);
43
44#define omFilterRetInfo(info, max, cond) \
45do \
46{ \
47 int _max = max; \
48 int _i = max -1; \
49 while (_i > 0) \
50 { \
51 void* addr_i = info[_i].addr; \
52 char* file_i = info[_i].file; \
53 char* func_i = info[_i].func; \
54 int line_i = info[_i].line; \
55 \
56 if (cond) \
57 max = omFilterRetInfo_i(info, max, _i); \
58 _i--; \
59 } \
60} \
61while (0)
62
63
64/*BEGINPRIVATE*/
65int _omPrintBackTrace(void** bt, int max, FILE* fd , OM_FLR_DECL);
66int _omPrintCurrentBackTrace(FILE* fd , OM_FLR_DECL);
67/*ENDPRIVATE*/
68
69#else /* OM_NDEBUG */
70#define omPrintRetInfo(i, max, fd, fmt) do {} while (0)
71#define omBackTrace_2_RetInfo(bt, i, m) do {} while (0)
72#define omInitRet_2_Info(a) do {} while (0)
73#define omPrintBackTrace(bt,max,fd) do {} while (0)
74#define omPrintCurrentBackTrace(fd) do {} while (0)
75#define omPrintCurrentBackTraceMax(fd,max) do {} while (0)
76#define omFilterRetInfo_i(info,max,i) do {} while (0)
77#define omFilterRetInfo(info, max, cond)do {} while (0)
78#endif /* ! OM_NDEBUG */
79
80#endif /* OM_RET_2_INFO_H */
int i
Definition: cfEzgcd.cc:132
static int max(int a, int b)
Definition: fast_mult.cc:264
#define info
Definition: libparse.cc:1256
int omPrintRetInfo(omRetInfo info, int max, FILE *fd, const char *fmt)
Definition: omRet2Info.c:99
int omBackTrace_2_RetInfo(void **bt, omRetInfo info, int max)
Definition: omRet2Info.c:46
int _omPrintBackTrace(void **bt, int max, FILE *fd, OM_FLR_DECL)
Definition: omRet2Info.c:200
int _omPrintCurrentBackTrace(FILE *fd, OM_FLR_DECL)
Definition: omRet2Info.c:270
void * addr
Definition: omRet2Info.h:13
int omFilterRetInfo_i(omRetInfo info, int max, int i)
Definition: omRet2Info.c:181
int omPrintBackTrace(void **bt, int max, FILE *fd)
Definition: omRet2Info.c:150
char file[200]
Definition: omRet2Info.h:15
char func[200]
Definition: omRet2Info.h:14
omRetInfo_t * omRetInfo
Definition: omStructs.h:34
int status int fd
Definition: si_signals.h:59
#define omPrintCurrentBackTraceMax(A, B)
Definition: xalloc.h:265
#define omInitRet_2_Info(argv0)
Definition: xalloc.h:274