From: Ian Lance Taylor Date: Fri, 5 Oct 2012 13:44:40 +0000 (+0000) Subject: runtime: Use argv[0] to get executable name for backtrace. X-Git-Tag: misc/gccgo-go1_1_2~394 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=686750d25df6b870f11f7744b2a3f631d998952a;p=thirdparty%2Fgcc.git runtime: Use argv[0] to get executable name for backtrace. From-SVN: r192123 --- diff --git a/libgo/runtime/go-caller.c b/libgo/runtime/go-caller.c index 8d8fe4c87976..843adf6f00dc 100644 --- a/libgo/runtime/go-caller.c +++ b/libgo/runtime/go-caller.c @@ -98,7 +98,12 @@ __go_get_backtrace_state () { runtime_lock (&back_state_lock); if (back_state == NULL) - back_state = backtrace_create_state (NULL, 1, error_callback, NULL); + { + const char *filename; + + filename = (const char *) runtime_progname (); + back_state = backtrace_create_state (filename, 1, error_callback, NULL); + } runtime_unlock (&back_state_lock); return back_state; } diff --git a/libgo/runtime/runtime.c b/libgo/runtime/runtime.c index e0a7925aed11..86115965734a 100644 --- a/libgo/runtime/runtime.c +++ b/libgo/runtime/runtime.c @@ -117,6 +117,12 @@ runtime_args(int32 c, byte **v) runtime_sysargs(c, v); } +byte* +runtime_progname() +{ + return argc == 0 ? nil : argv[0]; +} + void runtime_goargs(void) { diff --git a/libgo/runtime/runtime.h b/libgo/runtime/runtime.h index f96d740fb1ce..74050da9e98c 100644 --- a/libgo/runtime/runtime.h +++ b/libgo/runtime/runtime.h @@ -520,5 +520,6 @@ extern uintptr runtime_stacks_sys; struct backtrace_state; extern struct backtrace_state *__go_get_backtrace_state(void); extern _Bool __go_file_line(uintptr, String*, String*, int *); +extern byte* runtime_progname(); int32 getproccount(void);