void runtime_traceback () { Location locbuf[100]; int32 c; c = runtime_callers (1, locbuf, nelem (locbuf)); runtime_printtrace (locbuf, c, true); }
static void gtraceback(G* gp) { Traceback* traceback; traceback = gp->traceback; gp->traceback = nil; traceback->c = runtime_callers(1, traceback->pcbuf, sizeof traceback->pcbuf / sizeof traceback->pcbuf[0]); runtime_gogo(traceback->gp); }
static void mcommoninit(M *m) { m->id = runtime_sched.mcount++; m->fastrand = 0x49f6428aUL + m->id + runtime_cputicks(); if(m->mcache == nil) m->mcache = runtime_allocmcache(); runtime_callers(1, m->createstack, nelem(m->createstack)); // Add to runtime_allm so garbage collector doesn't free m // when it is just in a register or thread-local storage. m->alllink = runtime_allm; // runtime_NumCgoCall() iterates over allm w/o schedlock, // so we need to publish it safely. runtime_atomicstorep(&runtime_allm, m); }
// Called if we receive a SIGPROF signal. void runtime_sigprof() { int32 n; if(prof.fn == nil || prof.hz == 0) return; runtime_lock(&prof); if(prof.fn == nil) { runtime_unlock(&prof); return; } n = runtime_callers(0, prof.pcbuf, nelem(prof.pcbuf)); if(n > 0) prof.fn(prof.pcbuf, n); runtime_unlock(&prof); }
static void ffi_callback (ffi_cif *, void *, void **, void *) __asm__ ("reflect.ffi_callback"); static void ffi_callback (ffi_cif* cif __attribute__ ((unused)), void *results, void **args, void *closure) { Location locs[8]; int n; int i; /* This function is called from some series of FFI closure functions called by a Go function. We want to see whether the caller of the closure functions can recover. Look up the stack and skip the FFI functions. */ n = runtime_callers (1, &locs[0], sizeof locs / sizeof locs[0], true); for (i = 0; i < n; i++) { const byte *name; if (locs[i].function.len == 0) continue; if (locs[i].function.len < 4) break; name = locs[i].function.str; if (name[0] != 'f' || name[1] != 'f' || name[2] != 'i' || name[3] != '_') break; } if (i < n) __go_makefunc_ffi_can_recover (locs + i, n - i);
int Callers (int skip, struct __go_open_array pc) { return runtime_callers (skip, (uintptr *) pc.__values, pc.__count); }