Fix a case of broken output if last seen syscall was exit
* defs.h: Rename tcp_last to printing_tcp. Explain what it means.
Remove printtrailer() function.
* process.c (sys_exit): Convert printtrailer() call to "printing_tcp = NULL".
* strace.c: Add new variable printing_tcp.
(cleanup): Convert printtrailer() call to "printing_tcp = NULL".
(trace): Likewise.
(trace): Fix checks for incomplete line - it was working wrongly if last syscall was exit.
(printleader): Set printing_tcp.
(printtrailer): Remove this function.
* syscall.c: Remove tcp_last variable.
(trace_syscall_entering): Don't set printing_tcp, printleader call now does it.
(trace_syscall_exiting): Convert printtrailer() call to "printing_tcp = NULL".
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
diff --git a/syscall.c b/syscall.c
index 9c04cf9..88c9766 100644
--- a/syscall.c
+++ b/syscall.c
@@ -731,8 +731,6 @@
return 0;
}
-struct tcb *tcp_last = NULL;
-
#ifdef LINUX
# if defined(I386)
struct pt_regs i386_regs;
@@ -1724,7 +1722,6 @@
if (res != 1) {
printleader(tcp);
tcp->flags &= ~TCB_REPRINT;
- tcp_last = tcp;
if (scno_good != 1)
tprintf("????" /* anti-trigraph gap */ "(");
else if (!SCNO_IN_RANGE(tcp->scno))
@@ -1844,7 +1841,6 @@
printleader(tcp);
tcp->flags &= ~TCB_REPRINT;
- tcp_last = tcp;
if (!SCNO_IN_RANGE(tcp->scno))
tprintf("syscall_%lu(", tcp->scno);
else
@@ -2382,8 +2378,8 @@
if (res != 1) {
tprints(") ");
tabto();
- tprints("= ? <unavailable>");
- printtrailer();
+ tprints("= ? <unavailable>\n");
+ printing_tcp = NULL;
tcp->flags &= ~TCB_INSYSCALL;
return res;
}
@@ -2530,7 +2526,8 @@
tprintf(" <%ld.%06ld>",
(long) tv.tv_sec, (long) tv.tv_usec);
}
- printtrailer();
+ tprints("\n");
+ printing_tcp = NULL;
dumpio(tcp);
if (fflush(tcp->outf) == EOF)