mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
merge revision(s) 57317,57318:
error.c: moved * error.c (preface_dump, postscript_dump): moved from rb_vm_bugreport to place the last important message at the very last after [NOTE]. error.c: moved * error.c (preface_dump, postscript_dump): CrashReporter directory was used before Mac OS X 10.6. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_4@57858 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
9ba7e9d484
commit
1fc88012eb
4 changed files with 88 additions and 72 deletions
83
error.c
83
error.c
|
@ -24,6 +24,10 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined __APPLE__
|
||||||
|
# include <AvailabilityMacros.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef EXIT_SUCCESS
|
#ifndef EXIT_SUCCESS
|
||||||
#define EXIT_SUCCESS 0
|
#define EXIT_SUCCESS 0
|
||||||
#endif
|
#endif
|
||||||
|
@ -336,6 +340,80 @@ bug_report_file(const char *file, int line)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FUNC_MINIMIZED(static void bug_important_message(FILE *out, const char *const msg, size_t len));
|
||||||
|
|
||||||
|
static void
|
||||||
|
bug_important_message(FILE *out, const char *const msg, size_t len)
|
||||||
|
{
|
||||||
|
const char *const endmsg = msg + len;
|
||||||
|
const char *p = msg;
|
||||||
|
|
||||||
|
if (!len) return;
|
||||||
|
if (isatty(fileno(out))) {
|
||||||
|
static const char red[] = "\033[;31;1;7m";
|
||||||
|
static const char green[] = "\033[;32;7m";
|
||||||
|
static const char reset[] = "\033[m";
|
||||||
|
const char *e = strchr(p, '\n');
|
||||||
|
const int w = (int)(e - p);
|
||||||
|
do {
|
||||||
|
int i = (int)(e - p);
|
||||||
|
fputs(*p == ' ' ? green : red, out);
|
||||||
|
fwrite(p, 1, e - p, out);
|
||||||
|
for (; i < w; ++i) fputc(' ', out);
|
||||||
|
fputs(reset, out);
|
||||||
|
fputc('\n', out);
|
||||||
|
} while ((p = e + 1) < endmsg && (e = strchr(p, '\n')) != 0 && e > p + 1);
|
||||||
|
}
|
||||||
|
fwrite(p, 1, endmsg - p, out);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
preface_dump(FILE *out)
|
||||||
|
{
|
||||||
|
#if defined __APPLE__
|
||||||
|
static const char msg[] = ""
|
||||||
|
"-- Crash Report log information "
|
||||||
|
"--------------------------------------------\n"
|
||||||
|
" See Crash Report log file under the one of following:\n"
|
||||||
|
# if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_6
|
||||||
|
" * ~/Library/Logs/CrashReporter\n"
|
||||||
|
" * /Library/Logs/CrashReporter\n"
|
||||||
|
# endif
|
||||||
|
" * ~/Library/Logs/DiagnosticReports\n"
|
||||||
|
" * /Library/Logs/DiagnosticReports\n"
|
||||||
|
" for more details.\n"
|
||||||
|
"Don't forget to include the above Crash Report log file in bug reports.\n"
|
||||||
|
"\n";
|
||||||
|
const size_t msglen = sizeof(msg) - 1;
|
||||||
|
#else
|
||||||
|
const char *msg = NULL;
|
||||||
|
const size_t msglen = 0;
|
||||||
|
#endif
|
||||||
|
bug_important_message(out, msg, msglen);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
postscript_dump(FILE *out)
|
||||||
|
{
|
||||||
|
#if defined __APPLE__
|
||||||
|
static const char msg[] = ""
|
||||||
|
"[IMPORTANT]"
|
||||||
|
/*" ------------------------------------------------"*/
|
||||||
|
"\n""Don't forget to include the Crash Report log file under\n"
|
||||||
|
# if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_6
|
||||||
|
"CrashReporter or "
|
||||||
|
# endif
|
||||||
|
"DiagnosticReports directory in bug reports.\n"
|
||||||
|
/*"------------------------------------------------------------\n"*/
|
||||||
|
"\n";
|
||||||
|
const size_t msglen = sizeof(msg) - 1;
|
||||||
|
#else
|
||||||
|
const char *msg = NULL;
|
||||||
|
const size_t msglen = 0;
|
||||||
|
#endif
|
||||||
|
bug_important_message(out, msg, msglen);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
bug_report_begin_valist(FILE *out, const char *fmt, va_list args)
|
bug_report_begin_valist(FILE *out, const char *fmt, va_list args)
|
||||||
{
|
{
|
||||||
|
@ -346,6 +424,7 @@ bug_report_begin_valist(FILE *out, const char *fmt, va_list args)
|
||||||
fputs(buf, out);
|
fputs(buf, out);
|
||||||
snprintf(buf, sizeof(buf), "\n%s\n\n", ruby_description);
|
snprintf(buf, sizeof(buf), "\n%s\n\n", ruby_description);
|
||||||
fputs(buf, out);
|
fputs(buf, out);
|
||||||
|
preface_dump(out);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define bug_report_begin(out, fmt) do { \
|
#define bug_report_begin(out, fmt) do { \
|
||||||
|
@ -366,7 +445,8 @@ bug_report_end(FILE *out)
|
||||||
(*reporter->func)(out, reporter->data);
|
(*reporter->func)(out, reporter->data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fprintf(out, REPORTBUG_MSG);
|
fputs(REPORTBUG_MSG, out);
|
||||||
|
postscript_dump(out);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define report_bug(file, line, fmt, ctx) do { \
|
#define report_bug(file, line, fmt, ctx) do { \
|
||||||
|
@ -487,6 +567,7 @@ rb_assert_failure(const char *file, int line, const char *name, const char *expr
|
||||||
fprintf(out, "Assertion Failed: %s:%d:", file, line);
|
fprintf(out, "Assertion Failed: %s:%d:", file, line);
|
||||||
if (name) fprintf(out, "%s:", name);
|
if (name) fprintf(out, "%s:", name);
|
||||||
fprintf(out, "%s\n%s\n\n", expr, ruby_description);
|
fprintf(out, "%s\n%s\n\n", expr, ruby_description);
|
||||||
|
preface_dump(out);
|
||||||
rb_vm_bugreport(NULL);
|
rb_vm_bugreport(NULL);
|
||||||
bug_report_end(out);
|
bug_report_end(out);
|
||||||
die();
|
die();
|
||||||
|
|
|
@ -587,6 +587,11 @@ class TestRubyOptions < Test::Unit::TestCase
|
||||||
(?:.*\n)?
|
(?:.*\n)?
|
||||||
For\sdetails:\shttp:\/\/.*\.ruby-lang\.org/.*\n
|
For\sdetails:\shttp:\/\/.*\.ruby-lang\.org/.*\n
|
||||||
\n
|
\n
|
||||||
|
(?:
|
||||||
|
\[IMPORTANT\]\n
|
||||||
|
(?:.+\n)+
|
||||||
|
\n
|
||||||
|
)?
|
||||||
)x,
|
)x,
|
||||||
]
|
]
|
||||||
ExpectedStderrList << additional if additional
|
ExpectedStderrList << additional if additional
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#define RUBY_VERSION "2.4.0"
|
#define RUBY_VERSION "2.4.0"
|
||||||
#define RUBY_RELEASE_DATE "2017-03-12"
|
#define RUBY_RELEASE_DATE "2017-03-12"
|
||||||
#define RUBY_PATCHLEVEL 23
|
#define RUBY_PATCHLEVEL 24
|
||||||
|
|
||||||
#define RUBY_RELEASE_YEAR 2017
|
#define RUBY_RELEASE_YEAR 2017
|
||||||
#define RUBY_RELEASE_MONTH 3
|
#define RUBY_RELEASE_MONTH 3
|
||||||
|
|
70
vm_dump.c
70
vm_dump.c
|
@ -922,72 +922,6 @@ rb_dump_machine_register(const ucontext_t *ctx)
|
||||||
# define rb_dump_machine_register(ctx) ((void)0)
|
# define rb_dump_machine_register(ctx) ((void)0)
|
||||||
#endif /* HAVE_PRINT_MACHINE_REGISTERS */
|
#endif /* HAVE_PRINT_MACHINE_REGISTERS */
|
||||||
|
|
||||||
FUNC_MINIMIZED(static void bug_important_message(FILE *out, const char *const msg, size_t len));
|
|
||||||
|
|
||||||
static void
|
|
||||||
bug_important_message(FILE *out, const char *const msg, size_t len)
|
|
||||||
{
|
|
||||||
const char *const endmsg = msg + len;
|
|
||||||
const char *p = msg;
|
|
||||||
|
|
||||||
if (!len) return;
|
|
||||||
if (isatty(fileno(out))) {
|
|
||||||
static const char red[] = "\033[;31;1;7m";
|
|
||||||
static const char green[] = "\033[;32;7m";
|
|
||||||
static const char reset[] = "\033[m";
|
|
||||||
const char *e = strchr(p, '\n');
|
|
||||||
const int w = (int)(e - p);
|
|
||||||
do {
|
|
||||||
int i = (int)(e - p);
|
|
||||||
fputs(*p == ' ' ? green : red, out);
|
|
||||||
fwrite(p, 1, e - p, out);
|
|
||||||
for (; i < w; ++i) fputc(' ', out);
|
|
||||||
fputs(reset, out);
|
|
||||||
fputc('\n', out);
|
|
||||||
} while ((p = e + 1) < endmsg && (e = strchr(p, '\n')) != 0 && e > p + 1);
|
|
||||||
}
|
|
||||||
fwrite(p, 1, endmsg - p, out);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
preface_dump(void)
|
|
||||||
{
|
|
||||||
#if defined __APPLE__
|
|
||||||
static const char msg[] = ""
|
|
||||||
"-- Crash Report log information "
|
|
||||||
"--------------------------------------------\n"
|
|
||||||
" See Crash Report log file under the one of following:\n"
|
|
||||||
" * ~/Library/Logs/CrashReporter\n"
|
|
||||||
" * /Library/Logs/CrashReporter\n"
|
|
||||||
" * ~/Library/Logs/DiagnosticReports\n"
|
|
||||||
" * /Library/Logs/DiagnosticReports\n"
|
|
||||||
" for more details.\n"
|
|
||||||
"Don't forget to include the above Crash Report log file in bug reports.\n"
|
|
||||||
"\n";
|
|
||||||
const size_t msglen = sizeof(msg) - 1;
|
|
||||||
#else
|
|
||||||
const char *msg = NULL;
|
|
||||||
const size_t msglen = 0;
|
|
||||||
#endif
|
|
||||||
bug_important_message(stderr, msg, msglen);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
postscript_dump(void)
|
|
||||||
{
|
|
||||||
#if defined __APPLE__
|
|
||||||
static const char msg[] = ""
|
|
||||||
"[IMPORTANT]\n"
|
|
||||||
"Don't forget to include the Crash Report log file in bug reports.\n"
|
|
||||||
"\n";
|
|
||||||
const size_t msglen = sizeof(msg) - 1;
|
|
||||||
#else
|
|
||||||
const char *msg = NULL;
|
|
||||||
const size_t msglen = 0;
|
|
||||||
#endif
|
|
||||||
bug_important_message(stderr, msg, msglen);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
rb_vm_bugreport(const void *ctx)
|
rb_vm_bugreport(const void *ctx)
|
||||||
{
|
{
|
||||||
|
@ -1001,8 +935,6 @@ rb_vm_bugreport(const void *ctx)
|
||||||
#endif
|
#endif
|
||||||
const rb_vm_t *const vm = GET_VM();
|
const rb_vm_t *const vm = GET_VM();
|
||||||
|
|
||||||
preface_dump();
|
|
||||||
|
|
||||||
if (vm) {
|
if (vm) {
|
||||||
SDR();
|
SDR();
|
||||||
rb_backtrace_print_as_bugreport();
|
rb_backtrace_print_as_bugreport();
|
||||||
|
@ -1109,6 +1041,4 @@ rb_vm_bugreport(const void *ctx)
|
||||||
}
|
}
|
||||||
#endif /* __FreeBSD__ */
|
#endif /* __FreeBSD__ */
|
||||||
}
|
}
|
||||||
|
|
||||||
postscript_dump();
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue