This is Unofficial EPICS BASE Doxygen Site
epicsStackTrace.h File Reference
#include "libComAPI.h"
+ Include dependency graph for epicsStackTrace.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define EPICS_STACKTRACE_ADDRESSES   (1<<0)
 
#define EPICS_STACKTRACE_DYN_SYMBOLS   (1<<1)
 
#define EPICS_STACKTRACE_GBL_SYMBOLS   (1<<2)
 
#define EPICS_STACKTRACE_LCL_SYMBOLS   (1<<3)
 

Functions

LIBCOM_API void epicsStackTrace (void)
 
LIBCOM_API int epicsStackTraceGetFeatures (void)
 

Macro Definition Documentation

#define EPICS_STACKTRACE_ADDRESSES   (1<<0)

Definition at line 25 of file epicsStackTrace.h.

#define EPICS_STACKTRACE_DYN_SYMBOLS   (1<<1)

Definition at line 28 of file epicsStackTrace.h.

#define EPICS_STACKTRACE_GBL_SYMBOLS   (1<<2)

Definition at line 31 of file epicsStackTrace.h.

#define EPICS_STACKTRACE_LCL_SYMBOLS   (1<<3)

Definition at line 34 of file epicsStackTrace.h.

Function Documentation

LIBCOM_API void epicsStackTrace ( void  )

Definition at line 62 of file epicsStackTrace.c.

63 {
64 void **buf;
65 int i,n;
66 epicsSymbol sym;
67 
68  if ( 0 == epicsStackTraceGetFeatures() ) {
69  /* unsupported on this platform */
70  return;
71  }
72 
73  if ( ! (buf = malloc(sizeof(*buf) * MAXDEPTH))) {
74  free(buf);
75  errlogPrintf("epicsStackTrace(): not enough memory for backtrace\n");
76  return;
77  }
78 
79  n = epicsBackTrace(buf, MAXDEPTH);
80 
81  if ( n > 0 ) {
82 
83  stackTraceLock();
84 
85  errlogPrintf("Dumping a stack trace of thread '%s':\n", epicsThreadGetNameSelf());
86 
87  errlogFlush();
88 
89  for ( i=0; i<n; i++ ) {
90  if ( 0 == epicsFindAddr(buf[i], &sym) )
91  dumpInfo(buf[i], &sym);
92  else
93  dumpInfo(buf[i], 0);
94  }
95 
96  errlogFlush();
97 
98  stackTraceUnlock();
99 
100  }
101 
102  free(buf);
103 }
void errlogFlush(void)
Definition: errlog.c:529
int i
Definition: scan.c:967
LIBCOM_API int epicsFindAddr(void *addr, epicsSymbol *sym_p)
Definition: osdFindAddr.c:20
LIBCOM_API const char *epicsStdCall epicsThreadGetNameSelf(void)
Definition: osdThread.c:846
int epicsStackTraceGetFeatures()
#define MAXDEPTH
int errlogPrintf(const char *pFormat,...)
Definition: errlog.c:105
LIBCOM_API int epicsBackTrace(void **buf, int buf_sz)
LIBCOM_API int epicsStackTraceGetFeatures ( void  )

Definition at line 105 of file epicsStackTrace.c.

106 {
107 void *test[2];
108 
109 static int initflag = 10; /* init to a value larger than the test snapshot */
110 
111  /* don't bother about epicsOnce -- if there should be a race and
112  * the detection code is executed multiple times that is no big deal.
113  */
114  if ( 10 == initflag ) {
115  initflag = epicsBackTrace(test, sizeof(test)/sizeof(test[0]));
116  }
117 
118  if ( initflag <= 0 )
119  return 0; /* backtrace doesn't work or is not supported */
120 
122 }
#define EPICS_STACKTRACE_ADDRESSES
LIBCOM_API int epicsFindAddrGetFeatures()
Definition: osdFindAddr.c:37
LIBCOM_API int epicsBackTrace(void **buf, int buf_sz)