2012-05-17 07:30:25 +02:00
|
|
|
/* 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"
|
|
|
|
|
2012-05-24 23:07:18 +02:00
|
|
|
/* Print a stack trace for the current goroutine. */
|
|
|
|
|
|
|
|
void
|
|
|
|
runtime_traceback ()
|
2012-05-17 07:30:25 +02:00
|
|
|
{
|
2012-05-24 23:07:18 +02:00
|
|
|
uintptr pcbuf[100];
|
|
|
|
int32 c;
|
2012-05-17 07:30:25 +02:00
|
|
|
|
2012-05-24 23:07:18 +02:00
|
|
|
c = runtime_callers (1, pcbuf, sizeof pcbuf / sizeof pcbuf[0]);
|
2013-01-30 02:37:13 +01:00
|
|
|
runtime_printtrace (pcbuf, c, true);
|
2012-05-17 07:30:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-01-30 02:37:13 +01:00
|
|
|
runtime_printtrace (uintptr *pcbuf, int32 c, bool current)
|
2012-05-17 07:30:25 +02:00
|
|
|
{
|
2012-05-24 23:07:18 +02:00
|
|
|
int32 i;
|
2012-05-17 07:30:25 +02:00
|
|
|
|
2012-05-24 23:07:18 +02:00
|
|
|
for (i = 0; i < c; ++i)
|
|
|
|
{
|
2012-11-01 04:02:13 +01:00
|
|
|
String fn;
|
|
|
|
String file;
|
2012-11-06 19:28:21 +01:00
|
|
|
intgo line;
|
2012-05-24 23:07:18 +02:00
|
|
|
|
|
|
|
if (__go_file_line (pcbuf[i], &fn, &file, &line)
|
2013-01-30 02:37:13 +01:00
|
|
|
&& runtime_showframe (fn, current))
|
2012-05-24 23:07:18 +02:00
|
|
|
{
|
2012-06-07 08:34:52 +02:00
|
|
|
runtime_printf ("%S\n", fn);
|
2012-11-06 19:28:21 +01:00
|
|
|
runtime_printf ("\t%S:%D\n", file, (int64) line);
|
2012-05-24 23:07:18 +02:00
|
|
|
}
|
|
|
|
}
|
2012-05-17 07:30:25 +02:00
|
|
|
}
|