aboutsummaryrefslogtreecommitdiffstats
path: root/error.c
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2023-08-09 18:25:34 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2023-09-25 22:57:28 +0900
commit70e8a08295114fa3cb112ddb42844889f7f98eb1 (patch)
tree9528a9003ccaebf48858d74fbb0160068c8ca3eb /error.c
parent696f08238bc25a27e4b96c355c26bc0d27738548 (diff)
downloadruby-70e8a08295114fa3cb112ddb42844889f7f98eb1.tar.gz
Add `--bugreport-path` option
It has precedence over the environment variable `RUBY_BUGREPORT_PATH`.
Diffstat (limited to 'error.c')
-rw-r--r--error.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/error.c b/error.c
index a492d1c3e1..4a652bb4ad 100644
--- a/error.c
+++ b/error.c
@@ -839,13 +839,17 @@ open_report_path(const char *template, char *buf, size_t size, rb_pid_t *pid)
return NULL;
}
+static const char *bugreport_path;
+
/* SIGSEGV handler might have a very small stack. Thus we need to use it carefully. */
#define REPORT_BUG_BUFSIZ 256
static FILE *
bug_report_file(const char *file, int line, rb_pid_t *pid)
{
char buf[REPORT_BUG_BUFSIZ];
- FILE *out = open_report_path(getenv("RUBY_BUGREPORT_PATH"), buf, sizeof(buf), pid);
+ const char *report = bugreport_path;
+ if (!report) report = getenv("RUBY_BUGREPORT_PATH");
+ FILE *out = open_report_path(report, buf, sizeof(buf), pid);
int len = err_position_0(buf, sizeof(buf), file, line);
if (out) {
@@ -998,8 +1002,10 @@ bug_report_end(FILE *out, rb_pid_t pid)
} while (0) \
void
-ruby_test_bug_report(const char *template)
+ruby_set_bug_report(const char *template)
{
+ bugreport_path = template;
+#if RUBY_DEBUG
rb_pid_t pid = -1;
char buf[REPORT_BUG_BUFSIZ];
FILE *out = open_report_path(template, buf, sizeof(buf), &pid);
@@ -1008,6 +1014,7 @@ ruby_test_bug_report(const char *template)
fprintf(out, "ruby_test_bug_report: %s", ctime(&t));
finish_report(out, pid);
}
+#endif
}
NORETURN(static void die(void));