diff options
author | Dmitry V. Levin <ldv@strace.io> | 2022-11-27 08:00:00 +0000 |
---|---|---|
committer | Dmitry V. Levin <ldv@strace.io> | 2022-11-27 08:00:00 +0000 |
commit | 9007a0937eb822918dbf167838f25eab276fbe1c (patch) | |
tree | 461e2c5166f1eb80659f0e20d894e054353259ad | |
parent | 657662e1ad7fd3c67a351fcd437cef14f7874897 (diff) | |
download | strace-9007a0937eb822918dbf167838f25eab276fbe1c.tar.gz |
src: introduce tprint_attribute_{begin,end} helpers
* src/print_fields.h (tprint_attribute_begin, tprint_attribute_end):
New inline functions.
* src/print_instruction_pointer.c (print_instruction_pointer): Use them.
* src/print_syscall_number.c (print_syscall_number): Likewise.
* src/secontext.c (selinux_printfdcon, selinux_printfilecon,
selinux_printpidcon): Likewise.
* src/strace.c (printleader): Likewise.
* src/syscall.c (stub_sysent): Update sys_name.
* tests/kill_child.c: Update comment.
* tests/kill_child.test: Update expected output.
-rw-r--r-- | src/print_fields.h | 12 | ||||
-rw-r--r-- | src/print_instruction_pointer.c | 10 | ||||
-rw-r--r-- | src/print_syscall_number.c | 11 | ||||
-rw-r--r-- | src/secontext.c | 12 | ||||
-rw-r--r-- | src/strace.c | 5 | ||||
-rw-r--r-- | src/syscall.c | 6 | ||||
-rw-r--r-- | tests/kill_child.c | 4 | ||||
-rwxr-xr-x | tests/kill_child.test | 4 |
8 files changed, 40 insertions, 24 deletions
diff --git a/src/print_fields.h b/src/print_fields.h index 0a0424cba..e62ee5d1d 100644 --- a/src/print_fields.h +++ b/src/print_fields.h @@ -157,6 +157,18 @@ tprint_indirect_end(void) } static inline void +tprint_attribute_begin(void) +{ + STRACE_PRINTS("["); +} + +static inline void +tprint_attribute_end(void) +{ + STRACE_PRINTS("]"); +} + +static inline void tprint_associated_info_begin(void) { STRACE_PRINTS("<"); diff --git a/src/print_instruction_pointer.c b/src/print_instruction_pointer.c index 8cda63e04..21df7902b 100644 --- a/src/print_instruction_pointer.c +++ b/src/print_instruction_pointer.c @@ -12,14 +12,16 @@ print_instruction_pointer(struct tcb *tcp) { kernel_ulong_t ip; + tprint_attribute_begin(); if (get_instruction_pointer(tcp, &ip)) { tprintf(current_wordsize == 4 - ? "[%08" PRI_klx "]" - : "[%016" PRI_klx "]", ip); + ? "%08" PRI_klx + : "%016" PRI_klx, ip); } else { tprints(current_wordsize == 4 - ? "[????????]" - : "[????????????????]"); + ? "????????" + : "????????????????"); } + tprint_attribute_end(); tprint_space(); } diff --git a/src/print_syscall_number.c b/src/print_syscall_number.c index 1f3357073..7128dda3b 100644 --- a/src/print_syscall_number.c +++ b/src/print_syscall_number.c @@ -10,10 +10,11 @@ void print_syscall_number(struct tcb *tcp) { - if (tcp->true_scno != (kernel_ulong_t) -1) { - tprintf("[%4" PRI_klu "]", tcp->true_scno); - } else { - tprints("[????]"); - } + tprint_attribute_begin(); + if (tcp->true_scno != (kernel_ulong_t) -1) + tprintf("%4" PRI_klu, tcp->true_scno); + else + tprint_unavailable(); + tprint_attribute_end(); tprint_space(); } diff --git a/src/secontext.c b/src/secontext.c index 16256e0b3..f12d224a7 100644 --- a/src/secontext.c +++ b/src/secontext.c @@ -246,9 +246,9 @@ selinux_printfdcon(pid_t pid, int fd) return; tprint_space(); - tprints("["); + tprint_attribute_begin(); print_context(ctx, exp); - tprints("]"); + tprint_attribute_end(); } void @@ -261,9 +261,9 @@ selinux_printfilecon(struct tcb *tcp, const char *path) return; tprint_space(); - tprints("["); + tprint_attribute_begin(); print_context(ctx, exp); - tprints("]"); + tprint_attribute_end(); } void @@ -274,8 +274,8 @@ selinux_printpidcon(struct tcb *tcp) if (selinux_getpidcon(tcp, &ctx) < 0) return; - tprints("["); + tprint_attribute_begin(); print_context(ctx, NULL); - tprints("]"); + tprint_attribute_end(); tprint_space(); } diff --git a/src/strace.c b/src/strace.c index 8059a6d0e..a35aed8eb 100644 --- a/src/strace.c +++ b/src/strace.c @@ -842,13 +842,14 @@ printleader(struct tcb *tcp) else tprintf("%-5u", tcp->pid); } else { - tprintf("[pid %5u", tcp->pid); + tprint_attribute_begin(); + tprintf("pid %5u", tcp->pid); } print_comm_str(tcp->comm, len); if (!print_pid_pfx) - tprints("]"); + tprint_attribute_end(); tprint_space(); } diff --git a/src/syscall.c b/src/syscall.c index 2818a767e..90c4fbd8a 100644 --- a/src/syscall.c +++ b/src/syscall.c @@ -1357,7 +1357,7 @@ const struct_sysent stub_sysent = { .sys_flags = MEMORY_MAPPING_CHANGE, .sen = SEN_printargs, .sys_func = printargs, - .sys_name = "????", + .sys_name = "???", }; /* @@ -1366,7 +1366,7 @@ const struct_sysent stub_sysent = { * out silently" code. * 1: ok, continue in syscall_entering_decode(). * other: error, syscall_entering_decode() should print error indicator - * ("????" etc) and return an appropriate code. + * ("???" etc) and return an appropriate code. */ int get_scno(struct tcb *tcp) @@ -1459,7 +1459,7 @@ static int get_syscall_result_regs(struct tcb *); /* Returns: * 1: ok, continue in syscall_exiting_trace(). * -1: error, syscall_exiting_trace() should print error indicator - * ("????" etc) and bail out. + * ("???" etc) and bail out. */ static int get_syscall_result(struct tcb *tcp) diff --git a/tests/kill_child.c b/tests/kill_child.c index 55b83aba5..47786abeb 100644 --- a/tests/kill_child.c +++ b/tests/kill_child.c @@ -2,9 +2,9 @@ * Check for the corner case that previously lead to segfault * due to an attempt to access unitialised tcp->s_ent. * - * 13994 ????( <unfinished ...> + * 13994 ???( <unfinished ...> * ... - * 13994 <... ???? resumed>) = ? + * 13994 <... ??? resumed>) = ? * * Copyright (c) 2019 The strace developers. * All rights reserved. diff --git a/tests/kill_child.test b/tests/kill_child.test index 312592bd9..1550ed9b7 100755 --- a/tests/kill_child.test +++ b/tests/kill_child.test @@ -22,10 +22,10 @@ while :; do # Printing of "<... SYSCALL resumed>" in strace.c:print_event_exit # used to segfault when the syscall number had not been obtained # on syscall entering. - grep -q '^[1-9][0-9]* <\.\.\. ???? resumed>) \+= ?$' "$LOG" && exit 0 + grep -q '^[1-9][0-9]* <\.\.\. ??? resumed>) \+= ?$' "$LOG" && exit 0 s1="$(date +%s)" if [ "$(($s1-$s0))" -gt "$(($TIMEOUT_DURATION/2))" ]; then - skip_ 'Unable to reproduce <... ???? resumed>' + skip_ 'Unable to reproduce <... ??? resumed>' fi done |