From nobody Mon Mar 2 08:51:01 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1772403952; cv=none; d=zohomail.com; s=zohoarc; b=c7HbEraI8X9+qrAMivDN3ZG12tRxOkVada0D9ytInj+17qw62hJwmMzjTtF/NgNzsSTe8Rwk9cMQik7OZ6p1guIoL7fg5RZR3B8DIAMixsFhFRRZnjRxv7IRjSbM3cKSeRGkdwenWvrI3Gp2zk94MAOcu2Dc+aC3M9+4bCn+wKA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772403952; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=fwGhUDJm3nLm1RfDvQ6EYdXYf68EBpwYdfuRzXBmWrY=; b=fCQddgIY8Zrape8895+pVoK6tPoCRQ8swBqRDbQDRDpvZgj/zrwDmxfXW7CDd3yez3spUkXLLRrSc77DIBWw/CR3nR7bvl+e/em8VcA3Q0RVyKVfwY/SiqNyA+BNGAw1VkMeyZyYO8NSYVbn0of6OG7w5wYt5DNLfN3EriZzGz8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772403952694217.2440228009906; Sun, 1 Mar 2026 14:25:52 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vwpDt-0002F0-1N; Sun, 01 Mar 2026 17:25:13 -0500 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 1vwpDq-0002EG-Sh for qemu-devel@nongnu.org; Sun, 01 Mar 2026 17:25:10 -0500 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vwpDp-0002K9-38 for qemu-devel@nongnu.org; Sun, 01 Mar 2026 17:25:10 -0500 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-483703e4b08so32571455e9.1 for ; Sun, 01 Mar 2026 14:25:08 -0800 (PST) Received: from tuf-gaming ([158.173.157.82]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-483c3b770e7sm261779655e9.9.2026.03.01.14.25.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Mar 2026 14:25:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1772403907; x=1773008707; darn=nongnu.org; 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=fwGhUDJm3nLm1RfDvQ6EYdXYf68EBpwYdfuRzXBmWrY=; b=ngg7h89XRWWhDES6vqSq1LqV/bA30uMgu9MK8TVY0K0/fbmsqYLo9mIHIeRuHKVdUn q6rhi0NQ4FwsVbMSMQGTzqadVNw0feo9q7cvY61rEZK9vqzauW/M5ZtHpXFbgRqxPsOz j1rDT23b6clvCOrQVZF3daKX8njSu/OcqTf+uY/Vp0DN/wqdBNkbcJUNm5XuvT2tPNJD VT50X2vUA43jA0v/dK3Y+lC2CTUniZ3K5JP5JjKDlvQa5XYtOBPYzHuz2e0/PRc0cUQd P0qKSdUrBWazbUTtmGvuyMeZ0c0Uhs6HdE6Jguu6fz49jhA6wAMbCkCTinR3PmmGUdGl BZDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772403907; x=1773008707; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=fwGhUDJm3nLm1RfDvQ6EYdXYf68EBpwYdfuRzXBmWrY=; b=kP5YN7NQgBvpYESzwD5SDH6dXftZD7oALaeE1C3b3xdpJv1NRreIhfmnGweUv2Wj8W QI4fQHFN6CUjVsWNw0ZNyJNttsE4tLHp0kZuPasN70pvyqi+mAdOkj5uoFT1ogGjnlSU 7j5XGR9Tk2uQ/it5dmRmsCPjo3Y+xGCxEdvEwVDq1KTu9rXZpLx1fhI/7oaxVHWHHuZU xt38xMtCwcADtK/k7pG2uoq3rtJxjljCV3vMDmh0t71ISYlAF84+en19817zHdV4GYIu Y0UqfL0xuqNWESfdvNWJZjJqvqw2fC6SsOQR3I4QOaZhKYOmN1/ipoNfGLVst/7rIX66 JuRQ== X-Gm-Message-State: AOJu0YwmIUhOVaAMBbX3Oy2pJRIZibpLGMz8JoCRBuKbxUoYKXGizNNY rb3ezeEUH95NGjFL4LnaXQcCDM4G6SHFlwgdLFE9Td1AWnv9bdkwcEqyMb3chw== X-Gm-Gg: ATEYQzze7t+Q2WQbqQ6xdiT3uQYf5V32QuDLjwD1YlnzjFyiEltI1Mxc88o7NHOgN3a urKeM8fw9GdixVzAD/HlzBg79PeuN5l96WEVM/NclJQ0UOkrRRTBp18Q9Z3iBT4iYTrn3YfPAKh w7QLbmZSE/QXO/3Sj47HN/bqTGaylsXzLtfSQ1J5ZqWHDdDdFM44levgAPp55Qsowus7i8oPjN4 EHXPBqqjrHslxUMagcele8GqLo41j8RGKrdyI9TDTIOUwErsTsVLUHn8CqsLxeIc6FnYoRxKxxn 9LC/srXlnggPcEsKHYmM141kdobF/7f02E2bdKitTaJRS5nrgPanOwgxqmn/GZlYLZgLCiT80fN TWE7PUkzeGi7k6/YZyL2LHqDNwhb2bm+ScEP9grE7LeWntn4xDd9EQNMe3RdrgQUMFxEYlAY/35 tirV0a6IT5HS1Vvb+XFYTtVV6teRMWxbr/3ZY/qUE= X-Received: by 2002:a05:600c:8b5b:b0:481:a662:b3f3 with SMTP id 5b1f17b1804b1-483c990c263mr203763715e9.7.1772403907014; Sun, 01 Mar 2026 14:25:07 -0800 (PST) From: =?UTF-8?q?Jean-Christian=20C=C3=8ERSTEA?= To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, jean-christian.cirstea@tuta.com, deller@gmx.de, =?UTF-8?q?Jean-Christian=20C=C3=8ERSTEA?= Subject: [PATCH v2] linux-user/strace: fix printing of file offsets Date: Mon, 2 Mar 2026 00:25:00 +0200 Message-ID: <20260301222500.215320-1-jean.christian.cirstea@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32b; envelope-from=jean.christian.cirstea@gmail.com; helo=mail-wm1-x32b.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, FREEMAIL_FROM=0.001, 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1772403954647158500 Previously, 64-bit file offsets (loff_t) were printed using `print_raw_para= m()` function, which led to silent truncation of the upper part. This commit fix= es this issue by adding two helper functions: 1. print_file_offset32(): prints 32-bit file offsets (off_t) 2. print_file_offset64(): prints 64-bit file offsets (loff_t) Signed-off-by: Jean-Christian C=C3=8ERSTEA Reviewed-by: Helge Deller --- Changelog v2: 1. Make `print_file_offset32()` static. 2. Use `last` parameter in `print_file_offset32()`. 3. Rename `low` and `high` parameters of `print_file_offset64()` to `word0`, `word1` respectively 4. Convert `last` to bool for `print_file_offset[32,64]()` 5. Use `PRId64` instead of `PRIu64` for `print_file_offset64()` 6. Fix `print__llseek()` linux-user/strace.c | 43 +++++++++++++++++++++++++++++++------------ 1 file changed, 31 insertions(+), 12 deletions(-) diff --git a/linux-user/strace.c b/linux-user/strace.c index 758c5d32b6..285fc987f5 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -85,6 +85,10 @@ 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); +UNUSED static void print_file_offset32(abi_long offset, bool last); +UNUSED static void print_file_offset64(abi_long word0, + abi_long word1, + bool last); UNUSED static void print_syscall_prologue(const struct syscallname *); UNUSED static void print_syscall_epilogue(const struct syscallname *); UNUSED static void print_string(abi_long, int); @@ -1664,6 +1668,20 @@ print_open_flags(abi_long flags, int last) print_flags(open_flags, flags, last); } =20 +/* Prints 32-bit file offset (off_t) */ +static void +print_file_offset32(abi_long offset, bool last) +{ + print_raw_param(TARGET_ABI_FMT_ld, offset, last); +} + +/* Prints 64-bit file offset (loff_t) */ +static void +print_file_offset64(abi_long word0, abi_long word1, bool last) +{ + print_raw_param64("%" PRId64, target_offset64(word0, word1), last); +} + static void print_syscall_prologue(const struct syscallname *sc) { @@ -2187,11 +2205,13 @@ print_fallocate(CPUArchState *cpu_env, const struct= syscallname *name, print_raw_param("%d", arg0, 0); print_flags(falloc_flags, arg1, 0); #if TARGET_ABI_BITS =3D=3D 32 - print_raw_param("%" PRIu64, target_offset64(arg2, arg3), 0); - print_raw_param("%" PRIu64, target_offset64(arg4, arg5), 1); + /* On 32-bit targets, two registers are used for `loff_t` */ + print_file_offset64(arg2, arg3, false); + print_file_offset64(arg4, arg5, true); #else - print_raw_param(TARGET_ABI_FMT_ld, arg2, 0); - print_raw_param(TARGET_ABI_FMT_ld, arg3, 1); + /* On 64-bit targets, one register is used for `loff_t` */ + print_file_offset64(arg2, 0, false); + print_file_offset64(arg3, 0, true); #endif print_syscall_epilogue(name); } @@ -2597,8 +2617,7 @@ print__llseek(CPUArchState *cpu_env, const struct sys= callname *name, const char *whence =3D "UNKNOWN"; print_syscall_prologue(name); print_raw_param("%d", arg0, 0); - print_raw_param("%ld", arg1, 0); - print_raw_param("%ld", arg2, 0); + print_file_offset64(arg1, arg2, false); print_pointer(arg3, 0); switch(arg4) { case SEEK_SET: whence =3D "SEEK_SET"; break; @@ -2619,7 +2638,7 @@ print_lseek(CPUArchState *cpu_env, const struct sysca= llname *name, { print_syscall_prologue(name); print_raw_param("%d", arg0, 0); - print_raw_param(TARGET_ABI_FMT_ld, arg1, 0); + print_file_offset32(arg1, false); switch (arg2) { case SEEK_SET: qemu_log("SEEK_SET"); break; @@ -2650,7 +2669,7 @@ print_truncate(CPUArchState *cpu_env, const struct sy= scallname *name, { print_syscall_prologue(name); print_string(arg0, 0); - print_raw_param(TARGET_ABI_FMT_ld, arg1, 1); + print_file_offset32(arg1, true); print_syscall_epilogue(name); } #endif @@ -2667,7 +2686,7 @@ print_truncate64(CPUArchState *cpu_env, const struct = syscallname *name, arg1 =3D arg2; arg2 =3D arg3; } - print_raw_param("%" PRIu64, target_offset64(arg1, arg2), 1); + print_file_offset64(arg1, arg2, true); print_syscall_epilogue(name); } #endif @@ -2684,7 +2703,7 @@ print_ftruncate64(CPUArchState *cpu_env, const struct= syscallname *name, arg1 =3D arg2; arg2 =3D arg3; } - print_raw_param("%" PRIu64, target_offset64(arg1, arg2), 1); + print_file_offset64(arg1, arg2, true); print_syscall_epilogue(name); } #endif @@ -3239,7 +3258,7 @@ print_stat(CPUArchState *cpu_env, const struct syscal= lname *name, print_syscall_epilogue(name); } #define print_lstat print_stat -#define print_stat64 print_stat +#define print_stat64 print_stat #define print_lstat64 print_stat #endif =20 @@ -4228,7 +4247,7 @@ print_pread64(CPUArchState *cpu_env, const struct sys= callname *name, print_raw_param("%d", arg0, 0); print_pointer(arg1, 0); print_raw_param("%d", arg2, 0); - print_raw_param("%" PRIu64, target_offset64(arg3, arg4), 1); + print_file_offset64(arg3, arg4, true); print_syscall_epilogue(name); } #endif --=20 2.51.0