[GSOC 2014][PATCH 7/7] JSON: Add support for '+++' signals
Zhu YangMin
zym0017d at gmail.com
Mon Jul 21 14:35:29 UTC 2014
There are only 3 kind of '+++' signals in strace.
Note: Currently do NOT support the '<unfinished...>/<resumed>' in
JSON format. And this will make the those JSON lines invalid(or you can
just ignore these lines). Need to find a way to solve this problem.
* process.c(sys_exit): slightly reformat the code.
* syscall.c(trace_syscall_exiting): slightly reformat the code.
* strace.c(printleader, trace):
Add support for 'superseded', 'killed' and 'exited' signals.
---
process.c | 2 +-
strace.c | 26 ++++++++++++++++++++++----
syscall.c | 5 ++---
3 files changed, 25 insertions(+), 8 deletions(-)
diff --git a/process.c b/process.c
index 93678ad..8b4b1b8 100644
--- a/process.c
+++ b/process.c
@@ -261,7 +261,7 @@ sys_exit(struct tcb *tcp)
tprintf("%ld) ", tcp->u_arg[0]);
tabto();
tprintf("= %s\n", "?");
- json_event(JSON_ARG, JSON_ARGS_END, JSON_SEPA, JSON_RET, JSON_CALL_END ,JSON_NEWLINE);
+ json_event(JSON_ARG, JSON_ARGS_END, JSON_SEPA, JSON_RET, JSON_CALL_END, JSON_NEWLINE);
line_ended();
return 0;
}
diff --git a/strace.c b/strace.c
index deb636b..b973823 100644
--- a/strace.c
+++ b/strace.c
@@ -627,6 +627,7 @@ printleader(struct tcb *tcp)
* didn't finish ("SIGKILL nuked us after syscall entry" etc).
*/
tprints(" <unfinished ...>\n");
+ json_event(JSON_NEWLINE);
printing_tcp->curcol = 0;
}
}
@@ -2249,7 +2250,12 @@ trace(void)
tcp->pid = pid;
if (cflag != CFLAG_ONLY_STATS) {
printleader(tcp);
- tprintf("+++ superseded by execve in pid %lu +++\n", old_pid);
+ tprintf("+++ %s %s %lu +++\n", "superseded", "by execve in pid", old_pid);
+ json_event(
+ JSON_SIGNAL_BEGIN, JSON_SEPA,
+ JSON_DESC, JSON_SEPA,
+ JSON_AUXSTR, JSON_SEPA,
+ JSON_SIGCODE, JSON_SIGNAL_END, JSON_NEWLINE);
line_ended();
tcp->flags |= TCB_REPRINT;
}
@@ -2278,12 +2284,23 @@ trace(void)
) {
printleader(tcp);
#ifdef WCOREDUMP
- tprintf("+++ killed by %s %s+++\n",
+ tprintf("+++ %s by %s %s+++\n",
+ "killed",
signame(WTERMSIG(status)),
WCOREDUMP(status) ? "(core dumped) " : "");
+ json_event(
+ JSON_SIGNAL_BEGIN, JSON_SEPA,
+ JSON_DESC, JSON_SEPA,
+ JSON_AUXSTR, JSON_SEPA,
+ JSON_SIGCODE, JSON_SIGNAL_END, JSON_NEWLINE);
#else
- tprintf("+++ killed by %s +++\n",
+ tprintf("+++ %s by %s +++\n",
+ "killed",
signame(WTERMSIG(status)));
+ json_event(
+ JSON_SIGNAL_BEGIN, JSON_SEPA,
+ JSON_DESC, JSON_SEPA,
+ JSON_SIGCODE, JSON_SIGNAL_END, JSON_NEWLINE);
#endif
line_ended();
}
@@ -2296,7 +2313,8 @@ trace(void)
if (cflag != CFLAG_ONLY_STATS &&
qflag < 2) {
printleader(tcp);
- tprintf("+++ exited with %d +++\n", WEXITSTATUS(status));
+ tprintf("+++ %s with %d +++\n", "exited", WEXITSTATUS(status));
+ json_event(JSON_SIGNAL_BEGIN, JSON_SEPA, JSON_DESC, JSON_SEPA, JSON_SIGCODE, JSON_SIGNAL_END, JSON_NEWLINE);
line_ended();
}
droptcb(tcp);
diff --git a/syscall.c b/syscall.c
index 19e0b6e..ff951e6 100644
--- a/syscall.c
+++ b/syscall.c
@@ -2580,8 +2580,7 @@ trace_syscall_exiting(struct tcb *tcp)
tprintf(") = %s <%s>\n", "?", "unavailable");
json_event(JSON_ARGS_END, JSON_SEPA,
JSON_RET, JSON_SEPA,
- JSON_DESC,
- JSON_CALL_END , JSON_NEWLINE);
+ JSON_DESC, JSON_CALL_END, JSON_NEWLINE);
tabto();
line_ended();
tcp->flags &= ~TCB_INSYSCALL;
@@ -2754,7 +2753,7 @@ trace_syscall_exiting(struct tcb *tcp)
(long) tv.tv_sec, (long) tv.tv_usec);
}
tprints("\n");
- json_event(JSON_CALL_END , JSON_NEWLINE);
+ json_event(JSON_CALL_END, JSON_NEWLINE);
dumpio(tcp);
line_ended();
--
1.9.1
More information about the Strace-devel
mailing list