From patchwork Fri Nov 4 17:36:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 621381 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp411728pvb; Fri, 4 Nov 2022 10:37:17 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7cDAxs/wWILIe1eudfPHY7YEVkIdb70ectCPRVVEMkETNqk8D3tcV4QJi6ucNiE7YPQA3j X-Received: by 2002:a05:6214:268a:b0:4bb:68c1:8216 with SMTP id gm10-20020a056214268a00b004bb68c18216mr33777346qvb.70.1667583437829; Fri, 04 Nov 2022 10:37:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667583437; cv=none; d=google.com; s=arc-20160816; b=FLyqj0v5ZopTcCTQScWigqXOwEyNF9gqwVHe8ByEnzVeaTnmF3fu+flnb/SNUPSFMk NhqjL5cPEoTUAsEMb2EHnaM4ufMKFc/rXKE7JgJjWF016CHT4eQr4/A2EuSpI7Hf/Bot q4w7UtE9BKIAkmsFxCen+ayVbj9NzKz8DzJ0ROXEbLMPC7YrdGdy6oOBqhgH1mDK9nI3 HdDzTg2XzYpdkHTWHx6eEHPyCSEzxW9DrowGVOjL5bofloNtmdXi+KYurNgwZimjI3ph LFdXoJHqa9eo/EGNC+GelBhGgHzDXzFK5bPqQ7w5OygyOdwzhQYpH25PPOkz9yA+SG9G AwPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ySa/ES1xlmucJALkQqyY4MyTUUQjejtiY/uWInOLY+4=; b=qH0wDksMVCRgUUIzE2OmInJGQbEYpc+8MfDEEiTWnGmCPf3ZiXdqjkaCEWannfQIV1 jkAf+FeSx0AecNoj7rGUk90vb1fTCJDgwmJuM1ebxO2c/n/3sZL7BcooWG7t+b0vM7Tv 14dVjrIqxsqs4cvYfs/ts/2kFXNh4U/TYYK7Q2CQCOkcVaNMRICfl/9dA2qp6Uawy7a8 LJucZpL3VvVp121qNurPeTM4dI5u1hoA/+6vLOKw7q3fEl/gsBGduI3FsJO0fP+EE+7Y n9UW1+bUGsjmke5scMlBxEZaCtaXTdhZ/juEXjbM1EdBRPM4daSe7RvvJ2gjz+Ay0OSq l+Kw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SK6pmIJR; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id jv11-20020a05621429eb00b004bba4ec0df6si2808417qvb.61.2022.11.04.10.37.17 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 04 Nov 2022 10:37:17 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SK6pmIJR; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1or0cc-0000HT-Td; Fri, 04 Nov 2022 13:36:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1or0cb-0000Eh-AZ for qemu-devel@nongnu.org; Fri, 04 Nov 2022 13:36:49 -0400 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1or0cZ-0003vm-Hh for qemu-devel@nongnu.org; Fri, 04 Nov 2022 13:36:48 -0400 Received: by mail-wm1-x331.google.com with SMTP id v124-20020a1cac82000000b003cf7a4ea2caso5858411wme.5 for ; Fri, 04 Nov 2022 10:36:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ySa/ES1xlmucJALkQqyY4MyTUUQjejtiY/uWInOLY+4=; b=SK6pmIJRsk8psOxrmc2Va0Ka7wocLvkL/vtltbKUjsIiyAaTzQzGaFnryr8O50sVR+ oBMt1mrtkQiEukvXmJyWW4ZvsDReaRF11eTMOJjBhaHW3BZ0jVVjn0YWjk9ReaKlCLKA J6pki4HsFSIWAD6xUO2ULqv8CZic3PCzpPLAryOn4U8eVGuhjjntKP9aiHGJTiRDmSX1 zaPi8gt2nT3eRf8/pku+e0RfNq6DQOnEIuEtdMwz/bqInEk7Oj5Pza3JE6QpH4at25d2 rR7m+fthDAuL26QMeuHFKyhFqb0Cr27pJMADItClys10z/e3lQh1KAlCsD32qpPO2omO v7tw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ySa/ES1xlmucJALkQqyY4MyTUUQjejtiY/uWInOLY+4=; b=FuRrSRrWKF83y2LHQO6BXVh3p0r9m71hc9bAaVy1nksH6RFlS09qvWNqh+C0uhTz1r N1ICBfbV792fENCmCbKMzLi/CoUyFeijxRjAievyCwHoQRReYd8FBJlLO07rwcLPHMO/ MCK6tVBRH+44PclsdlslbhhSBoYxEemg2w+nVyNmVcbliZQO0/dvldndWM//kwe4VimU QnWswv9epGJ6kIbHmGaVqVXpzwD+MpJDUnsZCnKkoeMtpgGnLPydnSDSN42hGs+QSFox VVeHkmY/stdsalTBOTjurzEXxLuQpAgVH4FAotQLrao7e1H+DPD5hVOtnWY12HUjPSZt oq0Q== X-Gm-Message-State: ACrzQf1umsSfOQWP/M8wqQyNbGEFNCDvqmBcDujsbhOm7IvFw8qPLfuq kKxvLCGFaIBARvL6LF3Ufzzb1ibD9eC9Dw== X-Received: by 2002:a1c:c901:0:b0:3cf:6fdb:3367 with SMTP id f1-20020a1cc901000000b003cf6fdb3367mr20427783wmb.119.1667583405907; Fri, 04 Nov 2022 10:36:45 -0700 (PDT) Received: from localhost.localdomain ([185.126.107.38]) by smtp.gmail.com with ESMTPSA id m15-20020a056000024f00b002365b759b65sm3747615wrz.86.2022.11.04.10.36.44 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 04 Nov 2022 10:36:45 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Laurent Vivier , Helge Deller , Drew DeVault , =?utf-8?q?Daniel_P_=2E_Berrang=C3=A9?= , =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v5 2/5] linux-user/strace: Extract print_execve_argv() from print_execve() Date: Fri, 4 Nov 2022 18:36:29 +0100 Message-Id: <20221104173632.1052-3-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221104173632.1052-1-philmd@linaro.org> References: <20221104173632.1052-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=philmd@linaro.org; helo=mail-wm1-x331.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Qemu-devel" Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Drew DeVault 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 Message-Id: <20221104081015.706009-1-sir@cmpwn.com> [PMD: Split of bigger patch, filled description, fixed style] Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Laurent Vivier --- 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 25c47f0316..3d11d2f759 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,