[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 07/18] linux-user: Add an api to print enumareted argument values
From: |
Laurent Vivier |
Subject: |
[PULL 07/18] linux-user: Add an api to print enumareted argument values with strace |
Date: |
Fri, 28 Aug 2020 15:37:42 +0200 |
From: Filip Bozuta <Filip.Bozuta@syrmia.com>
This patch introduces a type 'struct enums' and function 'print_enums()'
that can be used to print enumerated argument values of some syscalls
in strace. This can be used in future strace implementations.
Also, macros 'ENUM_GENERIC()', 'ENUM_TARGET()' and 'ENUM_END', are
introduced to enable automatic generation of aproppriate enumarated
values and their repsective string representations (these macros are
exactly the same as 'FLAG_GENERIC()', 'FLAG_TARGET()' and 'FLAG_END').
Future patches are planned to modify all existing print functions in
'strace.c' that print arguments of syscalls with enumerated values to
use this new api.
Signed-off-by: Filip Bozuta <Filip.Bozuta@syrmia.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20200811164553.27713-5-Filip.Bozuta@syrmia.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
linux-user/strace.c | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/linux-user/strace.c b/linux-user/strace.c
index 4ac54ecffe9c..d0731b888d29 100644
--- a/linux-user/strace.c
+++ b/linux-user/strace.c
@@ -52,9 +52,23 @@ struct flags {
/* end of flags array */
#define FLAG_END { 0, NULL }
+/* Structure used to translate enumerated values into strings */
+struct enums {
+ abi_long e_value; /* enum value */
+ const char *e_string; /* stringified enum */
+};
+
+/* common enums for all architectures */
+#define ENUM_GENERIC(name) { name, #name }
+/* target specific enums */
+#define ENUM_TARGET(name) { TARGET_ ## name, #name }
+/* end of enums array */
+#define ENUM_END { 0, NULL }
+
UNUSED static const char *get_comma(int);
UNUSED static void print_pointer(abi_long, int);
UNUSED static void print_flags(const struct flags *, abi_long, int);
+UNUSED static void print_enums(const struct enums *, abi_long, int);
UNUSED static void print_at_dirfd(abi_long, int);
UNUSED static void print_file_mode(abi_long, int);
UNUSED static void print_open_flags(abi_long, int);
@@ -1252,6 +1266,23 @@ print_flags(const struct flags *f, abi_long flags, int
last)
}
}
+static void
+print_enums(const struct enums *e, abi_long enum_arg, int last)
+{
+ for (; e->e_string != NULL; e++) {
+ if (e->e_value == enum_arg) {
+ qemu_log("%s", e->e_string);
+ break;
+ }
+ }
+
+ if (e->e_string == NULL) {
+ qemu_log("%#x", (unsigned int)enum_arg);
+ }
+
+ qemu_log("%s", get_comma(last));
+}
+
static void
print_at_dirfd(abi_long dirfd, int last)
{
--
2.26.2
- [PULL 12/18] linux-user: detect mismatched ELF ABI in qemu-mips[n32][el], (continued)
- [PULL 12/18] linux-user: detect mismatched ELF ABI in qemu-mips[n32][el], Laurent Vivier, 2020/08/27
- [PULL 15/18] linux-user: Add support for 'mq_timedsend_time64()' and 'mq_timedreceive_time64()', Laurent Vivier, 2020/08/27
- [PULL 11/18] linux-user: Add strace support for printing arguments for ioctls used for terminals and serial lines, Laurent Vivier, 2020/08/27
- [PULL 16/18] linux-user: Add support for 'clock_nanosleep_time64()' and 'clock_adjtime64()', Laurent Vivier, 2020/08/27
- [PULL 10/18] linux-user: Add missing termbits types and values definitions, Laurent Vivier, 2020/08/27
- [PULL 13/18] linux-user: Fix 'mq_timedsend()' and 'mq_timedreceive()', Laurent Vivier, 2020/08/27
- [PULL 18/18] linux-user: Add support for utimensat_time64() and semtimedop_time64(), Laurent Vivier, 2020/08/27
- Re: [PULL 00/18] Linux user for 5.2 patches, Peter Maydell, 2020/08/28
- [PULL 00/18] Linux user for 5.2 patches, Laurent Vivier, 2020/08/28
- [PULL 07/18] linux-user: Add an api to print enumareted argument values with strace,
Laurent Vivier <=
- [PULL 04/18] linux-user: Make cpu_env accessible in strace.c, Laurent Vivier, 2020/08/28
- [PULL 01/18] linux-user: Fix 'semop()' and 'semtimedop()' implementation, Laurent Vivier, 2020/08/28
- [PULL 02/18] linux-user: Fix 'clock_nanosleep()' implementation, Laurent Vivier, 2020/08/28
- [PULL 09/18] linux-user: Add generic 'termbits.h' for some archs, Laurent Vivier, 2020/08/28
- [PULL 06/18] linux-user: Add strace support for printing arguments of syscalls used to lock and unlock memory, Laurent Vivier, 2020/08/28
- [PULL 03/18] linux-user: syscall: ioctls: support DRM_IOCTL_I915_GETPARAM, Laurent Vivier, 2020/08/28
- [PULL 08/18] linux-user: Add strace support for printing arguments of some clock and time functions, Laurent Vivier, 2020/08/28
- [PULL 05/18] linux-user: Add strace support for printing arguments of truncate()/ftruncate() and getsid(), Laurent Vivier, 2020/08/28
- [PULL 17/18] linux-user: Add support for 'rt_sigtimedwait_time64()' and 'sched_rr_get_interval_time64()', Laurent Vivier, 2020/08/28
- [PULL 12/18] linux-user: detect mismatched ELF ABI in qemu-mips[n32][el], Laurent Vivier, 2020/08/28