[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[hurd] 01/02: crash-logging.patch: dump information on process crash.
From: |
Samuel Thibault |
Subject: |
[hurd] 01/02: crash-logging.patch: dump information on process crash. |
Date: |
Tue, 23 Feb 2016 21:58:02 +0000 |
This is an automated email from the git hooks/post-receive script.
sthibault pushed a commit to branch master
in repository hurd.
commit 619b347392f378366974e546fe163ded897a845a
Author: Samuel Thibault <address@hidden>
Date: Tue Feb 23 01:16:52 2016 +0000
crash-logging.patch: dump information on process crash.
---
debian/changelog | 1 +
debian/patches/crash-logging.patch | 160 +++++++++++++++++++++++++++++++++++++
debian/patches/series | 1 +
3 files changed, 162 insertions(+)
diff --git a/debian/changelog b/debian/changelog
index 88af870..3fe2e68 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -3,6 +3,7 @@ hurd (1:0.7.git20160214-3) UNRELEASED; urgency=medium
* patches/mtab-siglost.patch: Replace with upstream patches/mount-nostd.patch
to fix mtab crash, but also d-i ISO mount hang.
* hurd-udeb.install.in: Install udeb's exec.static to /boot for d-i.
+ * patches/crash-logging.patch: New patch to dump information on process
crash.
-- Samuel Thibault <address@hidden> Mon, 22 Feb 2016 19:14:25 +0000
diff --git a/debian/patches/crash-logging.patch
b/debian/patches/crash-logging.patch
new file mode 100644
index 0000000..b7c2755
--- /dev/null
+++ b/debian/patches/crash-logging.patch
@@ -0,0 +1,160 @@
+xxx crash logging works
+
+---
+ hurd/paths.h | 1 +
+ trans/crash.c | 116 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ 2 files changed, 117 insertions(+)
+
+Index: hurd-debian/hurd/paths.h
+===================================================================
+--- hurd-debian.orig/hurd/paths.h
++++ hurd-debian/hurd/paths.h
+@@ -54,6 +54,7 @@ the Free Software Foundation, 675 Mass A
+ #define _HURD_IFSOCK _HURD "ifsock" /* S_IFSOCK */
+
+ /* Symbolic names for all non-essential translators. */
++#define _HURD_CRASH _HURD "crash"
+ #define _HURD_MTAB _HURD "mtab"
+
+ #endif /* hurd/paths.h */
+Index: hurd-debian/trans/crash.c
+===================================================================
+--- hurd-debian.orig/trans/crash.c
++++ hurd-debian/trans/crash.c
+@@ -24,6 +24,7 @@
+ #include <hurd.h>
+ #include <fcntl.h>
+ #include <hurd/trivfs.h>
++#include <hurd/paths.h>
+ #include <sys/wait.h>
+ #include <error.h>
+ #include <argp.h>
+@@ -141,6 +142,119 @@ stop_pgrp (process_t userproc, mach_port
+ munmap (pids, numpids);
+ }
+
++void mach_print(const char *);
++
++#ifndef EXTERNAL_MACH_PRINT
++asm (".global mach_print;"
++ " mach_print:;"
++ " mov $0xffffffe2, %eax;"
++ " lcall $0x7, $0x0;"
++ " ret;");
++#endif /* EXTERNAL_MACH_PRINT */
++
++#include <mach/thread_status.h>
++
++error_t
++get_pcs (task_t task, char **pcs)
++{
++ error_t err;
++ thread_t *threads;
++ size_t i, nthreads;
++
++#ifdef i386_THREAD_STATE
++ struct i386_thread_state state;
++ mach_msg_type_number_t count = i386_THREAD_STATE_COUNT;
++ int flavor = i386_THREAD_STATE;
++
++ err = task_threads (task, &threads, &nthreads);
++ if (err)
++ return err;
++
++ *pcs = NULL;
++ for (i = 0; i < nthreads; i++)
++ {
++ char *old = *pcs;
++ err = thread_get_state (threads[i], flavor,
++ (thread_state_t) &state, &count);
++ if (err)
++ return err;
++
++ if (old)
++ asprintf (pcs, "%s, 0x%x", old, state.eip);
++ else
++ asprintf (pcs, "0x%x", state.eip);
++
++ free (old);
++ err = mach_port_deallocate (mach_task_self (), threads[i]);
++ assert_perror (err);
++ }
++#else
++ *pcs = strdup ("architecture not supported");
++#endif
++ return 0;
++}
++
++error_t
++log_crash (task_t task,
++ int signo, integer_t sigcode, int sigerror,
++ natural_t exc, natural_t code, natural_t subcode,
++ enum crash_action how)
++{
++ error_t err;
++ pid_t pid;
++ char argz_buf[128], *argz = argz_buf;
++ size_t argz_len = sizeof argz;
++ char *msg;
++ char *how_msg;
++ char *pcs;
++
++ switch (how)
++ {
++ case crash_suspend:
++ how_msg = "suspending task";
++ break;
++ case crash_kill:
++ how_msg = "killing task";
++ break;
++ case crash_corefile:
++ how_msg = "writing core file";
++ break;
++ default:
++ assert (! "reached");
++ }
++
++ err = proc_task2pid (procserver, task, &pid);
++ if (err)
++ return err;
++
++ err = proc_getprocargs (procserver, pid, &argz, &argz_len);
++ if (err)
++ return err;
++
++ err = get_pcs (task, &pcs);
++ if (err)
++ return err;
++
++ argz_stringify (argz, argz_len, ' ');
++ asprintf (&msg, "%s: %s(%d) crashed, signal {no:%d, code:%d, error:%d}, "
++ "exception {%d, code:%d, subcode:%d}, PCs: {%s}, %s.\n",
++ _HURD_CRASH, argz, pid,
++ signo, sigcode, sigerror,
++ exc, code, subcode,
++ pcs,
++ how_msg);
++ if (argz != argz_buf)
++ vm_deallocate (mach_task_self (), argz, argz_len);
++ free (pcs);
++ if (! msg)
++ return ENOMEM;
++
++ fprintf (stderr, "%s", msg);
++ mach_print (msg);
++ free (msg);
++
++ return 0;
++}
+
+ kern_return_t
+ S_crash_dump_task (mach_port_t port,
+@@ -174,6 +288,8 @@ S_crash_dump_task (mach_port_t port,
+ }
+ }
+
++ log_crash (task, signo, sigcode, sigerror, exc, code, subcode, how);
++
+ switch (how)
+ {
+ default: /* NOTREACHED */
diff --git a/debian/patches/series b/debian/patches/series
index 13fc978..e719daf 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -25,3 +25,4 @@ dl_origin.patch
cross-link.patch
procfs-compatible
mount-nostd.patch
+crash-logging.patch
--
Alioth's /usr/local/bin/git-commit-notice on
/srv/git.debian.org/git/pkg-hurd/hurd.git