source: git/omalloc/omRet2Info.h @ bee06d

spielwiese
Last change on this file since bee06d was 341696, checked in by Hans Schönemann <hannes@…>, 14 years ago
Adding Id property to all files git-svn-id: file:///usr/local/Singular/svn/trunk@12231 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 2.9 KB
Line 
1/*******************************************************************
2 *  File:    omAddr2Info.h
3 *  Purpose: translation of return addr to RetInfo
4 *  Author:  obachman (Olaf Bachmann)
5 *  Created: 11/99
6 *  Version: $Id$
7 *******************************************************************/
8#ifndef OM_RET_2_INFO_H
9#define OM_RET_2_INFO_H
10
11
12struct omRetInfo_s
13{
14  void* addr;
15  char  func[200]; /* if you change these numbers, alos change */
16  char  file[200]; /* the fscanf statement in BackTrace_2_RetInfo */
17  int   line;
18};
19
20/* print to fd array of max RetInfo's and use fmt as format string for one RetInfo.
21   The following conversions are recognized:
22    %i -- number of return addr
23    %p -- address (in hex)
24    %F -- function name with arguments (for C++, only)
25    %N -- funtion name without arguments
26    %f -- file
27    %l -- line
28    %L -- file:line
29   return how many lines were printed */
30#ifndef OM_NDEBUG
31int omPrintRetInfo(omRetInfo info, int max, FILE *fd, const char* fmt);
32/* translate array of max BackTrace addresses into array of max RetInfos
33   return how many were translated */
34int omBackTrace_2_RetInfo(void** bt, omRetInfo info, int max);
35
36/* call with argv[0] to enable RetInfo translations */
37void omInitRet_2_Info(const char* argv0);
38
39int omPrintBackTrace(void** bt, int max, FILE* fd);
40#define omPrintCurrentBackTrace(fd) omPrintCurrentBackTraceMax(fd, 1000)
41int omPrintCurrentBackTraceMax(FILE* fd, int max);
42
43int omFilterRetInfo_i(omRetInfo info, int max, int i);
44
45#define omFilterRetInfo(info, max, cond)        \
46do                                              \
47{                                               \
48  int _max = max;                               \
49  int _i = max -1;                              \
50  while (_i > 0)                                \
51  {                                             \
52    void* addr_i = info[_i].addr;               \
53    char* file_i = info[_i].file;               \
54    char* func_i = info[_i].func;               \
55    int   line_i = info[_i].line;               \
56                                                \
57    if (cond)                                   \
58      max = omFilterRetInfo_i(info, max, _i);   \
59    _i--;                                       \
60  }                                             \
61}                                               \
62while (0)
63
64
65/*BEGINPRIVATE*/
66int _omPrintBackTrace(void** bt, int max, FILE* fd , OM_FLR_DECL);
67int _omPrintCurrentBackTrace(FILE* fd , OM_FLR_DECL);
68/*ENDPRIVATE*/
69
70#else /* OM_NDEBUG */
71#define omPrintRetInfo(i, max, fd, fmt) ((void)0)
72#define omBackTrace_2_RetInfo(bt, i, m) ((void)0)
73#define omInitRet_2_Info(a)             ((void)0)
74#define omPrintBackTrace(bt,max,fd)     ((void)0)
75#define omPrintCurrentBackTrace(fd)     ((void)0)
76#define omPrintCurrentBackTraceMax(fd,max) ((void)0)
77#define omFilterRetInfo_i(info,max,i)   ((void)0)
78#define omFilterRetInfo(info, max, cond)((void)0)
79#endif /* ! OM_NDEBUG */
80
81#endif /* OM_RET_2_INFO_H */
Note: See TracBrowser for help on using the repository browser.