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. */
10 #include "go-string.h"
12 /* Print a stack trace for the current goroutine. */
20 c
= runtime_callers (1, pcbuf
, sizeof pcbuf
/ sizeof pcbuf
[0]);
21 runtime_printtrace (pcbuf
, c
);
25 runtime_printtrace (uintptr
*pcbuf
, int32 c
)
29 for (i
= 0; i
< c
; ++i
)
31 struct __go_string fn
;
32 struct __go_string file
;
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
);