From 7f68bb4fefa5c851c9878ebbbac007658a999134 Mon Sep 17 00:00:00 2001 From: Eugene Syromyatnikov Date: Tue, 29 Jan 2019 13:54:23 +0100 Subject: [PATCH] Merge "<... resumed>" printing Apparently, it was slightly different with no apparent reason. Use a single routine to print this message now. * defs.h (print_syscall_resume): New function declaration. * strace.c (print_event_exit): Replace open-coding of "<... resumed>" message printing with a print_syscall_resume() call. * syscall.c (syscall_exiting_trace): Likewise. (print_syscall_resume): New function. * tests/threads-execve.c: Update expected output. --- defs.h | 2 ++ strace.c | 7 +------ syscall.c | 35 +++++++++++++++++++++-------------- tests/threads-execve.c | 2 +- 4 files changed, 25 insertions(+), 21 deletions(-) diff --git a/defs.h b/defs.h index f8db6124..1f231d34 100644 --- a/defs.h +++ b/defs.h @@ -427,6 +427,8 @@ extern bool get_instruction_pointer(struct tcb *, kernel_ulong_t *); extern bool get_stack_pointer(struct tcb *, kernel_ulong_t *); extern void print_instruction_pointer(struct tcb *); +extern void print_syscall_resume(struct tcb *tcp); + extern int syscall_entering_decode(struct tcb *); extern int syscall_entering_trace(struct tcb *, unsigned int *); extern void syscall_entering_finish(struct tcb *, int); diff --git a/strace.c b/strace.c index cdaafa87..6413297f 100644 --- a/strace.c +++ b/strace.c @@ -2181,12 +2181,7 @@ print_event_exit(struct tcb *tcp) set_current_tcp(tcp); } - if ((followfork < 2 && printing_tcp != tcp) - || (tcp->flags & TCB_REPRINT)) { - tcp->flags &= ~TCB_REPRINT; - printleader(tcp); - tprintf("<... %s resumed>", tcp->s_ent->sys_name); - } + print_syscall_resume(tcp); if (!(tcp->sys_func_rval & RVAL_DECODED)) { /* diff --git a/syscall.c b/syscall.c index 51fcc721..d770e861 100644 --- a/syscall.c +++ b/syscall.c @@ -688,19 +688,9 @@ syscall_exiting_decode(struct tcb *tcp, struct timespec *pts) return get_syscall_result(tcp); } -int -syscall_exiting_trace(struct tcb *tcp, struct timespec *ts, int res) +void +print_syscall_resume(struct tcb *tcp) { - if (syscall_tampered(tcp) || inject_delay_exit(tcp)) - tamper_with_syscall_exiting(tcp); - - if (cflag) { - count_syscall(tcp, ts); - if (cflag == CFLAG_ONLY_STATS) { - return 0; - } - } - /* If not in -ff mode, and printing_tcp != tcp, * then the log currently does not end with output * of _our syscall entry_, but with something else. @@ -710,11 +700,28 @@ syscall_exiting_trace(struct tcb *tcp, struct timespec *ts, int res) * "strace -ff -oLOG test/threaded_execve" corner case. * It's the only case when -ff mode needs reprinting. */ - if ((followfork < 2 && printing_tcp != tcp) || (tcp->flags & TCB_REPRINT)) { + if ((followfork < 2 && printing_tcp != tcp) + || (tcp->flags & TCB_REPRINT)) { tcp->flags &= ~TCB_REPRINT; printleader(tcp); - tprintf("<... %s resumed> ", tcp->s_ent->sys_name); + tprintf("<... %s resumed>", tcp->s_ent->sys_name); + } +} + +int +syscall_exiting_trace(struct tcb *tcp, struct timespec *ts, int res) +{ + if (syscall_tampered(tcp) || inject_delay_exit(tcp)) + tamper_with_syscall_exiting(tcp); + + if (cflag) { + count_syscall(tcp, ts); + if (cflag == CFLAG_ONLY_STATS) { + return 0; + } } + + print_syscall_resume(tcp); printing_tcp = tcp; tcp->s_prev_ent = NULL; diff --git a/tests/threads-execve.c b/tests/threads-execve.c index 8921201f..ec81722b 100644 --- a/tests/threads-execve.c +++ b/tests/threads-execve.c @@ -141,7 +141,7 @@ thread(void *arg) } printf("%-5d +++ superseded by execve in pid %u +++\n" - "%-5d <... execve resumed> ) = 0\n", + "%-5d <... execve resumed>) = 0\n", leader, tid, leader); -- 2.40.0