16#include "omDerivedConfig.h"
22#define MAXPATHLEN 1024
30#ifndef OM_MAX_BACKTRACE_DEPTH
31#define OM_MAX_BACKTRACE_DEPTH 16
48 int i=0,
j=0, filled = 0;
51 memset(
info, 0,
max*
sizeof(omRetInfo_t));
63#if defined(HAVE_POPEN) && defined(OM_PROG_ADDR2LINE)
86 while ((filled <
j) &&
87 (fscanf(pipe,
"%200[^\n]\n%200[^:]:%d\n",
info[filled].func,
info[filled].file, &(
info[filled].line)) == 3))
89 if (*
info[filled].func !=
'?' && *
info[filled].file !=
'?' &&
info[filled].line > 0)
112 if (fmt[
l] ==
'p') fprintf(
fd,
"%p",
info[
i].addr);
113 else if (fmt[
l] ==
'f') fprintf(
fd,
"%-20s", (*
info[
i].file !=
'\0' ?
info[
i].file :
"??"));
114 else if (fmt[
l] ==
'F') fprintf(
fd,
"%-20s", (*
info[
i].func !=
'\0' ?
info[
i].func :
"??"));
115 else if (fmt[
l] ==
'l') fprintf(
fd,
"%d",
info[
i].line);
116 else if (fmt[
l] ==
'N')
118 if (*
info[
i].func !=
'\0')
120 char*
found = (
char*) strchr(
info[
i].func,
'(');
122 fprintf(
fd,
"%-20s",
info[
i].func);
126 fprintf(
fd,
"%-20s",
"??");
128 else if (fmt[
l] ==
'L')
130 int n = fprintf(
fd,
"%s:%d", (*
info[
i].func !=
'\0' ?
info[
i].file :
"??"),
info[
i].line);
131 if (n < 20) fprintf(
fd,
"%*s", 20-n,
" ");
133 else if (fmt[
l] ==
'i') fprintf(
fd,
"%d",
i);
159#ifdef OM_PRINT_RETURN_ADDRESS
172 if (
max <= 0)
return 0;
220#ifdef OM_TRACK_RETURN
224#ifndef OM_INTERNAL_DEBUG
227#ifdef OM_TRACK_RETURN
231#ifdef OM_TRACK_FILE_LINE
237#if defined(OM_TRACK_RETURN) && defined(OM_TRACK_FILE_LINE)
238 if (r !=
NULL &&
info[0].addr == r &&
l > 0 &&
f != 0)
240 strcpy(
info[0].file,
f);
249#ifdef OM_TRACK_FILE_LINE
250 fprintf(
fd,
" %s:%d",
f,
l);
252#ifdef OM_TRACK_RETURN
253 fprintf(
fd,
" ra=%p", r);
256#ifndef OM_INTERNAL_DEBUG
261#ifdef OM_PRINT_RETURN_ADDRESS
static int max(int a, int b)
#define omGetBackTrace(bt, s, max)
int omPrintRetInfo(omRetInfo info, int max, FILE *fd, const char *fmt)
int omBackTrace_2_RetInfo(void **bt, omRetInfo info, int max)
int _omPrintBackTrace(void **bt, int max, FILE *fd, OM_FLR_DECL)
int _omPrintCurrentBackTrace(FILE *fd, OM_FLR_DECL)
static char om_this_prog[MAXPATHLEN]
int omFilterRetInfo_i(omRetInfo info, int max, int i)
int omPrintBackTrace(void **bt, int max, FILE *fd)
#define OM_MAX_BACKTRACE_DEPTH
#define omFilterRetInfo(info, max, cond)
#define omPrintCurrentBackTraceMax(A, B)
#define omInitRet_2_Info(argv0)