зеркало из https://github.com/github/ruby.git
[Feature #19790] Rename BUGREPORT_PATH as CRASH_REPORT
This commit is contained in:
Родитель
f714448be7
Коммит
bab01d284c
14
error.c
14
error.c
|
@ -737,7 +737,7 @@ struct report_expansion {
|
|||
};
|
||||
|
||||
/*
|
||||
* Open a bug report file to write. The `RUBY_BUGREPORT_PATH`
|
||||
* Open a bug report file to write. The `RUBY_CRASH_REPORT`
|
||||
* 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 (0) fprintf(stderr, "RUBY_CRASH_REPORT=%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;
|
||||
static const char *crash_report;
|
||||
|
||||
/* 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");
|
||||
const char *report = crash_report;
|
||||
if (!report) report = getenv("RUBY_CRASH_REPORT");
|
||||
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)
|
||||
ruby_set_crash_report(const char *template)
|
||||
{
|
||||
bugreport_path = template;
|
||||
crash_report = 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;
|
||||
const char *crash_report;
|
||||
|
||||
signed int sflag: 2;
|
||||
unsigned int xflag: 1;
|
||||
|
|
10
man/ruby.1
10
man/ruby.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 -crash-report 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
|
||||
.It Fl -crash-report Ns = Ns Ar template
|
||||
Sets the template of path name to save bug report.
|
||||
See
|
||||
.Ev RUBY_BUGREPORT_PATH
|
||||
.Ev RUBY_CRASH_REPORT
|
||||
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
|
||||
.Bl -tag -compact -width "RUBY_CRASH_REPORT"
|
||||
.It Ev RUBY_CRASH_REPORT
|
||||
The template of path name to save bug report.
|
||||
default: none
|
||||
.El
|
||||
|
|
18
ruby.c
18
ruby.c
|
@ -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("--crash-report=TEMPLATE", "", "template of crash 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;
|
||||
const char *crash_report = opt->crash_report;
|
||||
|
||||
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;
|
||||
if (crash_report) {
|
||||
opt->crash_report = crash_report;
|
||||
}
|
||||
|
||||
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 if (is_option_with_arg("crash-report", true, true)) {
|
||||
opt->crash_report = 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);
|
||||
if (opt.crash_report && *opt.crash_report) {
|
||||
void ruby_set_crash_report(const char *template);
|
||||
ruby_set_crash_report(opt.crash_report);
|
||||
}
|
||||
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|
|
||||
def assert_crash_report(path, cmd = nil)
|
||||
Dir.mktmpdir("ruby_crash_report") 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)
|
||||
status = assert_segv([{"RUBY_CRASH_REPORT"=>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|
|
||||
def test_crash_report
|
||||
assert_crash_report("%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|
|
||||
def test_crash_report_script
|
||||
assert_crash_report("%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
|
||||
def test_crash_report_executable_path
|
||||
omit if EnvUtil.rubybin.size > 245
|
||||
assert_bugreport_path("%E.%p.log") do |status, report|
|
||||
assert_crash_report("%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|
|
||||
def test_crash_report_script_path
|
||||
assert_crash_report("%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
|
||||
def test_crash_report_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,
|
||||
assert_in_out_err([{"RUBY_CRASH_REPORT"=>"| #{echo} %e:%f:%p"}], SEGVTest::KILL_SELF,
|
||||
encoding: "ASCII-8BIT",
|
||||
**SEGVTest::ExecOptions) do |stdout, stderr, status|
|
||||
assert_empty(stderr)
|
||||
|
|
Загрузка…
Ссылка в новой задаче