[PATCH 1/6] Add functions for disabling tprint* functions temporary
Masatake YAMATO
yamato at redhat.com
Thu Mar 10 12:01:01 UTC 2022
In preparation of using elsewhere.
* src/strace.c (disable_tprint,enable_tprint): New functions.
* src/defs.h (disable_tprint,enable_tprint): Declare them.
Signed-off-by: Masatake YAMATO <yamato at redhat.com>
---
src/defs.h | 3 +++
src/strace.c | 14 ++++++++++++++
2 files changed, 17 insertions(+)
diff --git a/src/defs.h b/src/defs.h
index addd85962..d3d769be6 100644
--- a/src/defs.h
+++ b/src/defs.h
@@ -1655,6 +1655,9 @@ 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 *disable_tprint(void);
+extern void enable_tprint(void *tprint_state);
+
/*
* Staging output for status qualifier.
*/
diff --git a/src/strace.c b/src/strace.c
index 6e4f8221f..f146656ce 100644
--- a/src/strace.c
+++ b/src/strace.c
@@ -714,6 +714,20 @@ tprintf(const char *fmt, ...)
# define fputs_unlocked fputs
#endif
+void *
+disable_tprint(void)
+{
+ void *r = current_tcp;
+ current_tcp = NULL;
+ return r;
+}
+
+void
+enable_tprint(void *tprint_state)
+{
+ current_tcp = tprint_state;
+}
+
void
tprints(const char *str)
{
--
2.35.1
More information about the Strace-devel
mailing list