зеркало из https://github.com/github/ruby.git
vm_dump.c: postscript_dump
* vm_dump.c (postscript_dump): mention crash report log twice because important. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57315 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
6ca3028eec
Коммит
d569c0c546
69
vm_dump.c
69
vm_dump.c
|
@ -922,6 +922,33 @@ rb_dump_machine_register(const ucontext_t *ctx)
|
|||
# define rb_dump_machine_register(ctx) ((void)0)
|
||||
#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)
|
||||
{
|
||||
|
@ -937,26 +964,28 @@ preface_dump(void)
|
|||
" for more details.\n"
|
||||
"Don't forget to include the above Crash Report log file in bug reports.\n"
|
||||
"\n";
|
||||
const char *const endmsg = msg + sizeof(msg) - 1;
|
||||
const char *p = msg;
|
||||
#define RED "\033[;31;1;7m"
|
||||
#define GREEN "\033[;32;7m"
|
||||
#define RESET "\033[m"
|
||||
|
||||
if (isatty(fileno(stderr))) {
|
||||
const char *e = strchr(p, '\n');
|
||||
const int w = (int)(e - p);
|
||||
do {
|
||||
int i = (int)(e - p);
|
||||
fputs(*p == ' ' ? GREEN : RED, stderr);
|
||||
fwrite(p, 1, e - p, stderr);
|
||||
for (; i < w; ++i) fputc(' ', stderr);
|
||||
fputs(RESET, stderr);
|
||||
fputc('\n', stderr);
|
||||
} while ((p = e + 1) < endmsg && (e = strchr(p, '\n')) != 0 && e > p + 1);
|
||||
}
|
||||
fwrite(p, 1, endmsg - p, stderr);
|
||||
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
|
||||
|
@ -1080,4 +1109,6 @@ rb_vm_bugreport(const void *ctx)
|
|||
}
|
||||
#endif /* __FreeBSD__ */
|
||||
}
|
||||
|
||||
postscript_dump();
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче