* decl.c (get_atexit_node): Remove dead code.
[official-gcc.git] / libgo / runtime / go-traceback.c
blobc1571a378640b59fc55f3bb74eec11bba37505eb
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"
10 #include "go-string.h"
12 /* Print a stack trace for the current goroutine. */
14 void
15 runtime_traceback ()
17 uintptr pcbuf[100];
18 int32 c;
20 c = runtime_callers (1, pcbuf, sizeof pcbuf / sizeof pcbuf[0]);
21 runtime_printtrace (pcbuf, c);
24 void
25 runtime_printtrace (uintptr *pcbuf, int32 c)
27 int32 i;
29 for (i = 0; i < c; ++i)
31 struct __go_string fn;
32 struct __go_string file;
33 int line;
35 if (__go_file_line (pcbuf[i], &fn, &file, &line)
36 && runtime_showframe (fn.__data))
38 runtime_printf ("%S\n", fn);
39 runtime_printf ("\t%S:%d\n", file, line);