PR fortran/41387
[official-gcc.git] / libgo / runtime / go-traceback.c
blob7b33cca86815e39a2e8b568b8ecfb3d4bebd5d43
1 /* go-traceback.c -- stack backtrace for Go.
3 Copyright 2012 The Go Authors. All rights reserved.
4 Use of this source code is governed by a BSD-style
5 license that can be found in the LICENSE file. */
7 #include "config.h"
9 #include "runtime.h"
11 /* Print a stack trace for the current goroutine. */
13 void
14 runtime_traceback ()
16 Location locbuf[100];
17 int32 c;
19 c = runtime_callers (1, locbuf, nelem (locbuf), false);
20 runtime_printtrace (locbuf, c, true);
23 void
24 runtime_printtrace (Location *locbuf, int32 c, bool current)
26 int32 i;
28 for (i = 0; i < c; ++i)
30 if (runtime_showframe (locbuf[i].function, current))
32 runtime_printf ("%S\n", locbuf[i].function);
33 runtime_printf ("\t%S:%D\n", locbuf[i].filename,
34 (int64) locbuf[i].lineno);