summaryrefslogtreecommitdiff
path: root/debian/patches/trans-crash-add-verbose.patch
blob: c4e44e6aa25f10c7c2f9fede03600691f4e69a64 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
From e13184e7cb12538ea6197bcde52a59e80fc41332 Mon Sep 17 00:00:00 2001
From: Justus Winter <4winter@informatik.uni-hamburg.de>
Date: Fri, 12 Sep 2014 20:52:30 +0200
Subject: [PATCH] trans/crash: add --verbose

Verbosely log application crashes to stderr.

* trans/crash.c (verbose): New variable.
(S_crash_dump_task): Verbosely log application crashes to stderr.
(options): Add --verbose.
(parse_opt): Parse --verbose.
---
 trans/crash.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/trans/crash.c b/trans/crash.c
index 4a59d45..1778f08 100644
--- a/trans/crash.c
+++ b/trans/crash.c
@@ -70,6 +70,7 @@ enum crash_action
 #define CRASH_ORPHANS_DEFAULT	crash_corefile
 
 static enum crash_action crash_how, crash_orphans_how;
+static int verbose;
 
 
 /* This is defined in ../exec/elfcore.c, or we could have
@@ -175,6 +176,24 @@ S_crash_dump_task (mach_port_t port,
 	}
     }
 
+  if (verbose)
+    {
+      pid_t pid;
+      char *args;
+      size_t args_len;
+      err = proc_task2pid (procserver, task, &pid);
+
+      if (! err)
+	err = proc_getprocargs (procserver, pid, &args, &args_len);
+
+      if (! err)
+	{
+	  error (0, 0, "%s(%d) received signal %d: %s",
+		 args, pid, signo, strsignal (signo));
+	  vm_deallocate (mach_task_self (), (vm_address_t) args, args_len);
+	}
+    }
+
   switch (how)
     {
     default:			/* NOTREACHED */
@@ -439,6 +458,7 @@ static const struct argp_option options[] =
   {0,0,0,0,"These options specify the disposition of a crashing process:", 1},
   {"action",	'a', "ACTION",	0, "Action taken on crashing processes", 1},
   {"orphan-action", 'O', "ACTION", 0, "Action taken on crashing orphans", 1},
+  {"verbose", 'v', NULL, 0, "Log crashes to stderr", 1},
 
   {0,0,0,0,"These options are synonyms for --action=OPTION:", 2},
   {"suspend",	's', 0,		0, "Suspend the process", 2},
@@ -489,6 +509,7 @@ parse_opt (int opt, char *arg, struct argp_state *state)
     case 's': crash_how = crash_suspend;	break;
     case 'k': crash_how = crash_kill;		break;
     case 'c': crash_how = crash_corefile;	break;
+    case 'v': verbose = 1;			break;
 
     case ARGP_KEY_SUCCESS:
       if (crash_orphans_how == crash_unspecified)
@@ -531,6 +552,9 @@ trivfs_append_args (struct trivfs_control *fsys,
       err = argz_add (argz, argz_len, opt);
     }
 
+  if (!err && verbose)
+    err = argz_add (argz, argz_len, "--verbose");
+
   return err;
 }
 
-- 
2.1.0