summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNobuyoshi Nakada <[email protected]>2023-09-13 15:02:10 +0900
committerNobuyoshi Nakada <[email protected]>2023-09-25 22:57:28 +0900
commitbab01d284c86b39952baaddb15901fd4a15e4151 ()
tree74b3c34a5dce558c8d2ec1ec8002637d15673dab
parentf714448be7613017779d196daa72238b0efffaba (diff)
[Feature #19790] Rename BUGREPORT_PATH as CRASH_REPORT
-rw-r--r--error.c14
-rw-r--r--internal/cmdlineopt.h2
-rw-r--r--man/ruby.110
-rw-r--r--ruby.c18
-rw-r--r--test/ruby/test_rubyoptions.rb26
5 files changed, 35 insertions, 35 deletions
@@ -737,7 +737,7 @@ struct report_expansion {
};
/*
- * Open a bug report file to write. The `RUBY_BUGREPORT_PATH`
* environment variable can be set to define a template that is used
* to name bug report files. The template can contain % specifiers
* which are substituted by the following values when a bug report
@@ -817,7 +817,7 @@ open_report_path(const char *template, char *buf, size_t size, rb_pid_t *pid)
struct report_expansion values = {{0}};
if (!template) return NULL;
- if (0) fprintf(stderr, "RUBY_BUGREPORT_PATH=%s\n", buf);
if (*template == '|') {
char *argv[16], *bufend = buf + size, *p;
int argc;
@@ -839,7 +839,7 @@ 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
@@ -847,8 +847,8 @@ static FILE *
bug_report_file(const char *file, int line, rb_pid_t *pid)
{
char buf[REPORT_BUG_BUFSIZ];
- 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);
@@ -1002,9 +1002,9 @@ bug_report_end(FILE *out, rb_pid_t pid)
} while (0) \
void
-ruby_set_bug_report(const char *template)
{
- bugreport_path = template;
#if RUBY_DEBUG
rb_pid_t pid = -1;
char buf[REPORT_BUG_BUFSIZ];
@@ -28,7 +28,7 @@ typedef struct ruby_cmdline_options {
struct rb_rjit_options rjit;
#endif
- const char *bugreport_path;
signed int sflag: 2;
unsigned int xflag: 1;
@@ -25,7 +25,7 @@
.Op Fl - Ns Bro Cm enable Ns | Ns Cm disable Brc Ns - Ns Ar FEATURE
.Op Fl -dump Ns = Ns Ar target
.Op Fl -verbose
-.Op Fl -bugreport-path Ns = Ns Ar template
.Op Fl -
.Op Ar program_file
.Op Ar argument ...
@@ -471,10 +471,10 @@ If this switch is given, and no script arguments (script file or
.Fl e
options) are present, Ruby quits immediately.
.Pp
-.It Fl -bugreport-path Ns = Ns Ar template
Sets the template of path name to save bug report.
See
-.Ev RUBY_BUGREPORT_PATH
environment variable for details.
.El
.Pp
@@ -654,8 +654,8 @@ default: 262144 or 524288
.El
.Sh BUG REPORT ENVIRONMENT
.Pp
-.Bl -tag -compact -width "RUBY_BUGREPORT_PATH"
-.It Ev RUBY_BUGREPORT_PATH
The template of path name to save bug report.
default: none
.El
@@ -337,7 +337,7 @@ usage(const char *name, int help, int highlight, int columns)
M("--backtrace-limit=num", "", "limit the maximum length of backtrace"),
M("--verbose", "", "turn on verbose mode and disable script from stdin"),
M("--version", "", "print the version number, then exit"),
- M("--bugreport-path=TEMPLATE", "", "template of bug report files"),
M("-y", ", --yydebug", "print log of parser. Backward compatibility is not guaranteed"),
M("--help", "", "show this message, -h for short message"),
};
@@ -899,7 +899,7 @@ moreswitches(const char *s, ruby_cmdline_options_t *opt, int envopt)
ruby_features_t feat = opt->features;
ruby_features_t warn = opt->warn;
long backtrace_length_limit = opt->backtrace_length_limit;
- const char *bugreport_path = opt->bugreport_path;
while (ISSPACE(*s)) s++;
if (!*s) return;
@@ -954,8 +954,8 @@ moreswitches(const char *s, ruby_cmdline_options_t *opt, int envopt)
if (BACKTRACE_LENGTH_LIMIT_VALID_P(backtrace_length_limit)) {
opt->backtrace_length_limit = backtrace_length_limit;
}
- if (bugreport_path) {
- opt->bugreport_path = bugreport_path;
}
ruby_xfree(ptr);
@@ -1467,8 +1467,8 @@ proc_long_options(ruby_cmdline_options_t *opt, const char *s, long argc, char **
opt->backtrace_length_limit = n;
}
}
- else if (is_option_with_arg("bugreport-path", true, true)) {
- opt->bugreport_path = s;
}
else {
rb_raise(rb_eRuntimeError,
@@ -2919,9 +2919,9 @@ ruby_process_options(int argc, char **argv)
iseq = process_options(argc, argv, cmdline_options_init(&opt));
- if (opt.bugreport_path && *opt.bugreport_path) {
- void ruby_set_bug_report(const char *template);
- ruby_set_bug_report(opt.bugreport_path);
}
return (void*)(struct RData*)iseq;
}
@@ -836,8 +836,8 @@ class TestRubyOptions < Test::Unit::TestCase
}
end
- def assert_bugreport_path(path, cmd = nil)
- Dir.mktmpdir("ruby_bugreport") do |dir|
list = SEGVTest::ExpectedStderrList
if cmd
FileUtils.mkpath(File.join(dir, File.dirname(cmd)))
@@ -847,7 +847,7 @@ class TestRubyOptions < Test::Unit::TestCase
else
cmd = ['-e', SEGVTest::KILL_SELF]
end
- status = assert_segv([{"RUBY_BUGREPORT_PATH"=>path}, *cmd], list: [], chdir: dir)
reports = Dir.glob("*.log", File::FNM_DOTMATCH, base: dir)
assert_equal(1, reports.size)
assert_pattern_list(list, File.read(File.join(dir, reports.first)))
@@ -855,39 +855,39 @@ class TestRubyOptions < Test::Unit::TestCase
end
end
- def test_bugreport_path
- assert_bugreport_path("%e.%f.%p.log") do |status, report|
assert_equal("#{File.basename(EnvUtil.rubybin)}.-e.#{status.pid}.log", report)
end
end
- def test_bugreport_path_script
- assert_bugreport_path("%e.%f.%p.log", "bug.rb") do |status, report|
assert_equal("#{File.basename(EnvUtil.rubybin)}.bug.rb.#{status.pid}.log", report)
end
end
- def test_bugreport_path_executable_path
omit if EnvUtil.rubybin.size > 245
- assert_bugreport_path("%E.%p.log") do |status, report|
assert_equal("#{EnvUtil.rubybin.tr('/', '!')}.#{status.pid}.log", report)
end
end
- def test_bugreport_path_script_path
- assert_bugreport_path("%F.%p.log", "test/bug.rb") do |status, report|
assert_equal("test!bug.rb.#{status.pid}.log", report)
end
end
- def test_bugreport_path_pipe
if File.executable?(echo = "/bin/echo")
elsif /mswin|ming/ =~ RUBY_PLATFORM
echo = "echo"
else
omit "/bin/echo not found"
end
- assert_in_out_err([{"RUBY_BUGREPORT_PATH"=>"| #{echo} %e:%f:%p"}], SEGVTest::KILL_SELF,
encoding: "ASCII-8BIT",
**SEGVTest::ExecOptions) do |stdout, stderr, status|
assert_empty(stderr)