source: git/omalloc/omRet2Info.h @ e70e45

spielwiese
Last change on this file since e70e45 was e70e45, checked in by Olaf Bachmann <obachman@…>, 24 years ago
* re-added files git-svn-id: file:///usr/local/Singular/svn/trunk@4521 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 2.8 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: omRet2Info.h,v 1.3 2000-08-14 12:26:49 obachman Exp $
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[100]; /* if you change these numbers, alos change */
16  char  file[100]; /* 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 -- functions
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);
39int omPrintCurrentBackTrace(FILE* fd);
40
41int omFilterRetInfo_i(omRetInfo info, int max, int i);
42
43#define omFilterRetInfo(info, max, cond)        \
44do                                              \
45{                                               \
46  int _max = max;                               \
47  int _i = max -1;                              \
48  while (_i > 0)                                \
49  {                                             \
50    void* addr_i = info[_i].addr;               \
51    char* file_i = info[_i].file;               \
52    char* func_i = info[_i].func;               \
53    int   line_i = info[_i].line;               \
54                                                \
55    if (cond)                                   \
56      max = omFilterRetInfo_i(info, max, _i);   \
57    _i--;                                       \
58  }                                             \
59}                                               \
60while (0)
61
62
63/*BEGINPRIVATE*/
64int _omPrintBackTrace(void** bt, int max, FILE* fd, OM_FLR_DECL);
65int _omPrintCurrentBackTrace(FILE* fd, OM_FLR_DECL);
66/*ENDPRIVATE*/
67
68#else /* OM_NDEBUG */
69#define omPrintRetInfo(i, max, fd, fmt) ((void)0)
70#define omBackTrace_2_RetInfo(bt, i, m) ((void)0)
71#define omInitRet_2_Info(a)             ((void)0)
72#define omPrintBackTrace(bt,max,fd)     ((void)0)
73#define omPrintCurrentBackTrace(fd)     ((void)0)
74#define omFilterRetInfo_i(info,max,i)   ((void)0)
75#define omFilterRetInfo(info, max, cond)((void)0)
76#endif /* ! OM_NDEBUG */
77
78#endif /* OM_RET_2_INFO_H */
Note: See TracBrowser for help on using the repository browser.