diff options
-rw-r--r-- | src/defs.h | 2 | ||||
-rw-r--r-- | src/print_fields.h | 12 | ||||
-rw-r--r-- | src/strace.c | 31 |
3 files changed, 43 insertions, 2 deletions
diff --git a/src/defs.h b/src/defs.h index 3f64e5737..e8a8e6469 100644 --- a/src/defs.h +++ b/src/defs.h @@ -1689,6 +1689,8 @@ extern void tprintf(const char *fmt, ...) ATTRIBUTE_FORMAT((printf, 1, 2)); extern void tprints(const char *str); extern void tprintf_comment(const char *fmt, ...) ATTRIBUTE_FORMAT((printf, 1, 2)); extern void tprints_comment(const char *str); +extern void tprintf_pre_comment(const char *fmt, ...) ATTRIBUTE_FORMAT((printf, 1, 2)); +extern void tprints_pre_comment(const char *str); /* * Staging output for status qualifier. diff --git a/src/print_fields.h b/src/print_fields.h index 8a01d053d..3ae042eab 100644 --- a/src/print_fields.h +++ b/src/print_fields.h @@ -145,6 +145,18 @@ tprint_comment_end(void) } static inline void +tprint_pre_comment_begin(void) +{ + STRACE_PRINTS("/* "); +} + +static inline void +tprint_pre_comment_end(void) +{ + STRACE_PRINTS(" */ "); +} + +static inline void tprint_indirect_begin(void) { STRACE_PRINTS("["); diff --git a/src/strace.c b/src/strace.c index 3f5a00a0a..418d90c9a 100644 --- a/src/strace.c +++ b/src/strace.c @@ -741,8 +741,11 @@ tprints(const char *str) void tprints_comment(const char *const str) { - if (str && *str) - tprintf(" /* %s */", str); + if (str && *str) { + tprint_comment_begin(); + tprints(str); + tprint_comment_end(); + } } void @@ -759,6 +762,30 @@ tprintf_comment(const char *fmt, ...) va_end(args); } +void +tprints_pre_comment(const char *const str) +{ + if (str && *str) { + tprint_pre_comment_begin(); + tprints(str); + tprint_pre_comment_end(); + } +} + +void +tprintf_pre_comment(const char *fmt, ...) +{ + if (!fmt || !*fmt) + return; + + va_list args; + va_start(args, fmt); + tprint_pre_comment_begin(); + tvprintf(fmt, args); + tprint_pre_comment_end(); + va_end(args); +} + static void flush_tcp_output(const struct tcb *const tcp) { |