From: Laurent Vivier <laurent@vivier.eu>
To: qemu-devel@nongnu.org
Cc: "Drew DeVault" <sir@cmpwn.com>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>,
"Laurent Vivier" <laurent@vivier.eu>
Subject: [PULL 02/22] linux-user/strace: Extract print_execve_argv() from print_execve()
Date: Sat, 4 Feb 2023 17:08:10 +0100 [thread overview]
Message-ID: <20230204160830.193093-3-laurent@vivier.eu> (raw)
In-Reply-To: <20230204160830.193093-1-laurent@vivier.eu>
From: Drew DeVault <sir@cmpwn.com>
In order to add print_execveat() which re-use common code from
print_execve(), extract print_execve_argv() from it.
Signed-off-by: Drew DeVault <sir@cmpwn.com>
Message-Id: <20221104081015.706009-1-sir@cmpwn.com>
[PMD: Split of bigger patch, filled description, fixed style]
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20221104173632.1052-3-philmd@linaro.org>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
linux-user/strace.c | 71 +++++++++++++++++++++++++--------------------
1 file changed, 39 insertions(+), 32 deletions(-)
diff --git a/linux-user/strace.c b/linux-user/strace.c
index 25c47f03160d..3d11d2f75978 100644
--- a/linux-user/strace.c
+++ b/linux-user/strace.c
@@ -616,38 +616,6 @@ print_semctl(CPUArchState *cpu_env, const struct syscallname *name,
}
#endif
-static void
-print_execve(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg1, abi_long arg2, abi_long arg3,
- abi_long arg4, abi_long arg5, abi_long arg6)
-{
- abi_ulong arg_ptr_addr;
- char *s;
-
- if (!(s = lock_user_string(arg1)))
- return;
- qemu_log("%s(\"%s\",{", name->name, s);
- unlock_user(s, arg1, 0);
-
- for (arg_ptr_addr = arg2; ; arg_ptr_addr += sizeof(abi_ulong)) {
- abi_ulong *arg_ptr, arg_addr;
-
- arg_ptr = lock_user(VERIFY_READ, arg_ptr_addr, sizeof(abi_ulong), 1);
- if (!arg_ptr)
- return;
- arg_addr = tswapal(*arg_ptr);
- unlock_user(arg_ptr, arg_ptr_addr, 0);
- if (!arg_addr)
- break;
- if ((s = lock_user_string(arg_addr))) {
- qemu_log("\"%s\",", s);
- unlock_user(s, arg_addr, 0);
- }
- }
-
- qemu_log("NULL})");
-}
-
#ifdef TARGET_NR_ipc
static void
print_ipc(CPUArchState *cpu_env, const struct syscallname *name,
@@ -1969,6 +1937,45 @@ print_execv(CPUArchState *cpu_env, const struct syscallname *name,
}
#endif
+static void
+print_execve_argv(abi_long argv, int last)
+{
+ abi_ulong arg_ptr_addr;
+ char *s;
+
+ qemu_log("{");
+ for (arg_ptr_addr = argv; ; arg_ptr_addr += sizeof(abi_ulong)) {
+ abi_ulong *arg_ptr, arg_addr;
+
+ arg_ptr = lock_user(VERIFY_READ, arg_ptr_addr, sizeof(abi_ulong), 1);
+ if (!arg_ptr) {
+ return;
+ }
+ arg_addr = tswapal(*arg_ptr);
+ unlock_user(arg_ptr, arg_ptr_addr, 0);
+ if (!arg_addr) {
+ break;
+ }
+ s = lock_user_string(arg_addr);
+ if (s) {
+ qemu_log("\"%s\",", s);
+ unlock_user(s, arg_addr, 0);
+ }
+ }
+ qemu_log("NULL}%s", get_comma(last));
+}
+
+static void
+print_execve(CPUArchState *cpu_env, const struct syscallname *name,
+ abi_long arg1, abi_long arg2, abi_long arg3,
+ abi_long arg4, abi_long arg5, abi_long arg6)
+{
+ print_syscall_prologue(name);
+ print_string(arg1, 0);
+ print_execve_argv(arg2, 1);
+ print_syscall_epilogue(name);
+}
+
#if defined(TARGET_NR_faccessat) || defined(TARGET_NR_faccessat2)
static void
print_faccessat(CPUArchState *cpu_env, const struct syscallname *name,
--
2.39.1
next prev parent reply other threads:[~2023-02-04 16:11 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-04 16:08 [PULL 00/22] Linux user for 8.0 patches Laurent Vivier
2023-02-04 16:08 ` [PULL 01/22] linux-user/strace: Constify struct flags Laurent Vivier
2023-02-04 16:08 ` Laurent Vivier [this message]
2023-02-04 16:08 ` [PULL 03/22] linux-user/strace: Add output for execveat() syscall Laurent Vivier
2023-02-04 16:08 ` [PULL 04/22] linux-user/syscall: Extract do_execve() from do_syscall1() Laurent Vivier
2023-02-04 16:08 ` [PULL 05/22] linux-user/syscall: Implement execveat() Laurent Vivier
2023-02-04 16:08 ` [PULL 06/22] linux-user: Add missing MAP_HUGETLB and MAP_STACK flags in strace Laurent Vivier
2023-02-04 16:08 ` [PULL 07/22] linux-user: un-parent OBJECT(cpu) when closing thread Laurent Vivier
2023-02-04 16:08 ` [PULL 08/22] linux-user: fix strace build w/out munlockall Laurent Vivier
2023-02-04 16:08 ` [PULL 09/22] linux-user: add more netlink protocol constants Laurent Vivier
2023-02-04 16:08 ` [PULL 10/22] Revert "linux-user: add more compat ioctl definitions" Laurent Vivier
2023-02-04 16:08 ` [PULL 11/22] Revert "linux-user: fix compat with glibc >= 2.36 sys/mount.h" Laurent Vivier
2023-02-04 16:08 ` [PULL 12/22] linux-user: Add strace output for clock_getres_time64() and futex_time64() Laurent Vivier
2023-02-04 16:08 ` [PULL 13/22] linux-user: Improve strace output of getgroups() and setgroups() Laurent Vivier
2023-02-04 16:08 ` [PULL 14/22] linux-user: move target_flat.h to target subdirs Laurent Vivier
2023-02-04 16:08 ` [PULL 15/22] linux-user: Fix SO_ERROR return code of getsockopt() Laurent Vivier
2023-02-04 16:08 ` [PULL 16/22] linux-user: Fix /proc/cpuinfo output for hppa Laurent Vivier
2023-02-04 16:08 ` [PULL 17/22] linux-user: Improve strace output of personality() and sysinfo() Laurent Vivier
2023-02-04 16:08 ` [PULL 18/22] linux-user: Add emulation for MADV_WIPEONFORK and MADV_KEEPONFORK in madvise() Laurent Vivier
2023-02-04 16:08 ` [PULL 19/22] linux-user: Show 4th argument of rt_sigprocmask() in strace Laurent Vivier
2023-02-04 16:08 ` [PULL 20/22] linux-user: Enhance strace output for various syscalls Laurent Vivier
2023-02-04 16:08 ` [PULL 21/22] linux-user: Implement SOL_ALG encryption support Laurent Vivier
2023-02-04 16:08 ` [PULL 22/22] linux-user: Allow sendmsg() without IOV Laurent Vivier
2023-02-04 19:12 ` [PULL 00/22] Linux user for 8.0 patches Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230204160830.193093-3-laurent@vivier.eu \
--to=laurent@vivier.eu \
--cc=philmd@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=sir@cmpwn.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).