diff --git a/src/libCom/osi/os/solaris/osdBackTrace.c b/src/libCom/osi/os/solaris/osdBackTrace.c new file mode 100644 index 000000000..b1f4ce609 --- /dev/null +++ b/src/libCom/osi/os/solaris/osdBackTrace.c @@ -0,0 +1,42 @@ +/* + * Copyright: Stanford University / SLAC National Laboratory. + * + * EPICS BASE is distributed subject to a Software License Agreement found + * in file LICENSE that is included with this distribution. + * + * Author: Till Straumann , 2011 + */ + +#include + +#define epicsExportSharedSymbols +#include "epicsStackTracePvt.h" + +struct wlk { + void **buf; + int max; + int cur; +}; + + +static int +walker(uintptr_t addr, int sig, void *arg) +{ +struct wlk *w_p = arg; + if ( w_p->cur < w_p->max ) + w_p->buf[w_p->cur++] = (void*)addr; + return 0; +} + +int epicsBackTrace(void **buf, int buf_sz) +{ +ucontext_t u; +struct wlk d; + d.buf = buf; + d.max = buf_sz; + d.cur = 0; + if ( getcontext(&u) ) + return -1; + walkcontext( &u, walker, &d ); + return d.cur; +}