blob: 30a5ed91c447fa86887257daf01d8ba38c836c55 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
/* go-traceback.c -- stack backtrace for Go.
Copyright 2012 The Go Authors. All rights reserved.
Use of this source code is governed by a BSD-style
license that can be found in the LICENSE file. */
#include "config.h"
#include "runtime.h"
/* Print a stack trace for the current goroutine. */
void
runtime_traceback ()
{
uintptr pcbuf[100];
int32 c;
c = runtime_callers (1, pcbuf, sizeof pcbuf / sizeof pcbuf[0]);
runtime_printtrace (pcbuf, c, true);
}
void
runtime_printtrace (uintptr *pcbuf, int32 c, bool current)
{
int32 i;
for (i = 0; i < c; ++i)
{
String fn;
String file;
intgo line;
if (__go_file_line (pcbuf[i], &fn, &file, &line)
&& runtime_showframe (fn, current))
{
runtime_printf ("%S\n", fn);
runtime_printf ("\t%S:%D\n", file, (int64) line);
}
}
}
|