summaryrefslogtreecommitdiff
path: root/mysql-test
diff options
context:
space:
mode:
authorSergey Vojtovich <svoj@mariadb.org>2018-05-20 13:45:29 +0400
committerVladislav Vaintroub <wlad@mariadb.com>2018-05-21 16:34:11 +0000
commit8c55277dcb40eca2da6931cce1030fd82d4b515e (patch)
tree7c5c9b7eca2dd8729d834ed368e60a0cbaf7e4e1 /mysql-test
parent9692f37d290030898ec68d5525c1ecb1f44925f8 (diff)
downloadmariadb-git-8c55277dcb40eca2da6931cce1030fd82d4b515e.tar.gz
Better crash reports on OS X
Symlink core from default location (/cores/core.%P), so that lldb can handle it.
Diffstat (limited to 'mysql-test')
-rw-r--r--mysql-test/lib/My/SafeProcess/safe_process.cc50
1 files changed, 50 insertions, 0 deletions
diff --git a/mysql-test/lib/My/SafeProcess/safe_process.cc b/mysql-test/lib/My/SafeProcess/safe_process.cc
index f8bed800114..2ca43b17698 100644
--- a/mysql-test/lib/My/SafeProcess/safe_process.cc
+++ b/mysql-test/lib/My/SafeProcess/safe_process.cc
@@ -89,6 +89,53 @@ static void die(const char* fmt, ...)
}
+#ifdef __APPLE__
+#include <sys/sysctl.h>
+
+
+/*
+ Eventually we may want to adopt kern.corefile parsing code from
+ https://opensource.apple.com/source/xnu/xnu-3247.1.106/bsd/kern/kern_proc.c
+*/
+
+void handle_core(pid_t pid)
+{
+ char corefile[256];
+ int coredump;
+ size_t corefile_size= sizeof(corefile);
+ size_t coredump_size= sizeof(coredump);
+
+ if (sysctlbyname("kern.coredump", &coredump, &coredump_size, 0, 0) ||
+ sysctlbyname("kern.corefile", corefile, &corefile_size, 0, 0))
+ {
+ message("sysctlbyname failed: %d (%s)", errno, strerror(errno));
+ return;
+ }
+
+ if (!coredump)
+ {
+ message("core dumps disabled, to enable run sudo sysctl kern.coredump=1");
+ return;
+ }
+
+ if (!strncmp(corefile, "/cores/core.%P", corefile_size))
+ {
+ char from[256];
+ char *to= from + 7;
+
+ snprintf(from, sizeof(from), "/cores/core.%u", pid);
+ if (!access(from, R_OK))
+ {
+ if (symlink(from, to))
+ message("symlink failed: %d (%s)", errno, strerror(errno));
+ }
+ }
+}
+#else
+void handle_core(pid_t pid __attribute__((unused))) {}
+#endif
+
+
static int kill_child(bool was_killed)
{
int status= 0;
@@ -112,7 +159,10 @@ static int kill_child(bool was_killed)
}
if (WIFSIGNALED(status))
+ {
message("Child killed by signal: %d", WTERMSIG(status));
+ handle_core(child_pid);
+ }
return exit_code;
}