Daily bump.
[gcc.git] / libgo / runtime / go-traceback.c
1 /* go-traceback.c -- stack backtrace for Go.
2
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. */
6
7 #include "config.h"
8
9 #include "runtime.h"
10
11 /* Print a stack trace for the current goroutine. */
12
13 void
14 runtime_traceback ()
15 {
16 Location locbuf[100];
17 int32 c;
18
19 c = runtime_callers (1, locbuf, nelem (locbuf));
20 runtime_printtrace (locbuf, c, true);
21 }
22
23 void
24 runtime_printtrace (Location *locbuf, int32 c, bool current)
25 {
26 int32 i;
27
28 for (i = 0; i < c; ++i)
29 {
30 if (runtime_showframe (locbuf[i].function, current))
31 {
32 runtime_printf ("%S\n", locbuf[i].function);
33 runtime_printf ("\t%S:%D\n", locbuf[i].filename,
34 (int64) locbuf[i].lineno);
35 }
36 }
37 }