From patchwork Tue Mar 7 21:21:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 659862 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp2608224wrb; Tue, 7 Mar 2023 13:30:28 -0800 (PST) X-Google-Smtp-Source: AK7set+oTnbo1CW1Ses66L/6GtLcrJvxgo78uP4WhO41XMpeYQR++c/3B/9GwMAbbei9khbDdDaU X-Received: by 2002:ac8:5b84:0:b0:3bf:d48e:26c4 with SMTP id a4-20020ac85b84000000b003bfd48e26c4mr25637822qta.39.1678224628365; Tue, 07 Mar 2023 13:30:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678224628; cv=none; d=google.com; s=arc-20160816; b=0MkqgIbBvn+2f9Xo3aJdnLOTUtzdXN7eeElXYejSzOcUcSQ3rjBTLCQIRsmsg4tAHP oaKGuZjI+HUsvGHRWK2/4DrBuO6ENk1zqkN2M8fnfaSgJJpxdNYObY6B0gVzp0DdExAQ bfXukASYconMy6L1Ug834x7XHNY0q8O4cewM1VYaSEcyiizExAWijhzUjIzPvHlelWZk /Ij7H9YDSc6VD40xVI3Ep42f1SOM6nnG8zTstAst6KQpjoVdK25Za+Y9Wb3ubTlK8d2h 4tuNGe+LuUy+SIuO+RRhCaWR+MGqJWgLEVjZj3LGQkqSjnB7n1/4InBx5MZbe3FrS+rM j+Hw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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=RFnVylggrOveF5TL9UqBJAa3Obk9uRQsQNg6W7LMavU=; b=zzCC4Q/L8ChFsG5q8b7x8RpzlyzCkSmuL0a5ZK2DENqqwY+okcdO3wx+c8WOTix3M/ fu66gHXdmkAkf2iKKVYjuBRS0rYXXDsWI8Pw2Sh9TKkZqdI3Cz3/cJjGJ7Dao6p6qaJw YEA6J7BW/Etw2zz2rWwsKv1om0/ttniBtM+2vG1iKdv5G1mXuXk+O9jfTiKRmYDyxWtV ql390fi2osD9F3GSx6gg7kiZeOeqaK9qp2bnjWItOAY1Ty6JzvH7bjtVUlPby3MqNMAb DDJ8OMnsiHAwxTdzLbxxDtPysr4a9REAXAo1ggLg7Rpe6X4Brfcxk6QUjFwJ76p4b0G0 uThw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ajwaVXPT; 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 v3-20020a05622a188300b003c03c5a015asi1682818qtc.621.2023.03.07.13.30.28 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 07 Mar 2023 13:30:28 -0800 (PST) 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=ajwaVXPT; 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 1pZesF-0004lM-T6; Tue, 07 Mar 2023 16:29:31 -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 1pZesD-0004k7-IS for qemu-devel@nongnu.org; Tue, 07 Mar 2023 16:29:29 -0500 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pZesA-0000wf-Uc for qemu-devel@nongnu.org; Tue, 07 Mar 2023 16:29:29 -0500 Received: by mail-wr1-x42c.google.com with SMTP id f11so13513097wrv.8 for ; Tue, 07 Mar 2023 13:29:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1678224565; 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=RFnVylggrOveF5TL9UqBJAa3Obk9uRQsQNg6W7LMavU=; b=ajwaVXPTDXDf9yGrGniWwTaVimiBz5bCkqIj+VBKed1lQnPqXKHrclJsXcjinKCHHC 7W3oquYqr8gErKZBrp1LoLv2FP4X2sJz6Kkf26AZ5yGGqtP3cITrgLvUb07TsGi2mv8S wUGP85IqGPbt9p2ziBkauYZDjWxUhOGUBfLJSp1mlzdJqSRAYcJ3WHtsJR8VZBkGyNKC IEZb+0WUsE9JQhBmmuG6/KkrxQYd8IxLBGoxQdbatnW/QISLtEOLDhK1G5PhTHlWCt2o T8xHxyJ2uDB3MwdqJ31t481eKWKpuklUF1gLBogtdvFf2Ji38hXZKfjCH7PgezqpnNPP Cykw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678224565; 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=RFnVylggrOveF5TL9UqBJAa3Obk9uRQsQNg6W7LMavU=; b=AIJF3E1hQ5MLQT8UKX6T1sGur3hcXB5/gpdv4Js8gnfy3FapdTZkuggx3dYdL1+vo+ lO28UN69SfprAd8m42maiEbwOANUMKGak7wFmAnMRZ5jRNcr0ZoaP0xyvPWYzty04Qqe yuz1pb/laMfWUq/1C/jg6gwEdyZe53Hx1yjZuQbRm0HifJjlHpOwbRC6xVKE+wZTEOI+ XVchVUgfqMbUzUoaKAd4Fgm3tTHcEG0wMFucaYosSwA9GWmM/f/urcBvAyaUXW9S1OI4 TCzAn89QVVsiOgVENIWUR1TLxpvDfEQKjH8/PRBSDLnyjGfoPY+6W/2/14fLqbAPAxR+ AlPw== X-Gm-Message-State: AO0yUKVd52SiY1pbMVCzwGeoTH3z+GbF04zM46ahCocltmFadhyX56l7 YFCMAk5679FFS/bVVPsyvNVGTA== X-Received: by 2002:a5d:4892:0:b0:2c9:640f:635b with SMTP id g18-20020a5d4892000000b002c9640f635bmr8797017wrq.56.1678224565175; Tue, 07 Mar 2023 13:29:25 -0800 (PST) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id x9-20020a5d60c9000000b002c70d97af78sm13232934wrt.85.2023.03.07.13.29.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Mar 2023 13:29:24 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 271D71FFD4; Tue, 7 Mar 2023 21:21:43 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= , =?utf-8?q?Alex_Benn=C3=A9e?= Subject: [PULL 27/30] gdbstub: Adjust gdb_do_syscall to only use uint32_t and uint64_t Date: Tue, 7 Mar 2023 21:21:36 +0000 Message-Id: <20230307212139.883112-28-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230307212139.883112-1-alex.bennee@linaro.org> References: <20230307212139.883112-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42c; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42c.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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Richard Henderson Pass %x as uint32_t and %lx as uint64_t; pass the address of %s as uint64_t and the length as uint32_t. Add casts in semihosting/syscalls.c from target_ulong to uint64_t; add casts from int to uint32_t for clarity. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Alex Bennée Message-Id: <20230303025805.625589-28-richard.henderson@linaro.org> diff --git a/gdbstub/syscalls.c b/gdbstub/syscalls.c index fdc68e452a..9f479010b1 100644 --- a/gdbstub/syscalls.c +++ b/gdbstub/syscalls.c @@ -110,14 +110,14 @@ void gdb_do_syscall(gdb_syscall_complete_cb cb, const char *fmt, ...) *(p++) = 'F'; while (*fmt) { if (*fmt == '%') { - target_ulong addr; uint64_t i64; + uint32_t i32; fmt++; switch (*fmt++) { case 'x': - addr = va_arg(va, target_ulong); - p += snprintf(p, p_end - p, TARGET_FMT_lx, addr); + i32 = va_arg(va, uint32_t); + p += snprintf(p, p_end - p, "%" PRIx32, i32); break; case 'l': if (*(fmt++) != 'x') { @@ -127,9 +127,9 @@ void gdb_do_syscall(gdb_syscall_complete_cb cb, const char *fmt, ...) p += snprintf(p, p_end - p, "%" PRIx64, i64); break; case 's': - addr = va_arg(va, target_ulong); - p += snprintf(p, p_end - p, TARGET_FMT_lx "/%x", - addr, va_arg(va, int)); + i64 = va_arg(va, uint64_t); + i32 = va_arg(va, uint32_t); + p += snprintf(p, p_end - p, "%" PRIx64 "/%x" PRIx32, i64, i32); break; default: bad_format: diff --git a/semihosting/syscalls.c b/semihosting/syscalls.c index 42080ffdda..68899ebb1c 100644 --- a/semihosting/syscalls.c +++ b/semihosting/syscalls.c @@ -139,46 +139,48 @@ static void gdb_open(CPUState *cs, gdb_syscall_complete_cb complete, gdb_open_complete = complete; gdb_do_syscall(gdb_open_cb, "open,%s,%x,%x", - fname, len, (target_ulong)gdb_flags, (target_ulong)mode); + (uint64_t)fname, (uint32_t)len, + (uint32_t)gdb_flags, (uint32_t)mode); } static void gdb_close(CPUState *cs, gdb_syscall_complete_cb complete, GuestFD *gf) { - gdb_do_syscall(complete, "close,%x", (target_ulong)gf->hostfd); + gdb_do_syscall(complete, "close,%x", (uint32_t)gf->hostfd); } static void gdb_read(CPUState *cs, gdb_syscall_complete_cb complete, GuestFD *gf, target_ulong buf, target_ulong len) { - gdb_do_syscall(complete, "read,%x,%x,%x", - (target_ulong)gf->hostfd, buf, len); + gdb_do_syscall(complete, "read,%x,%lx,%lx", + (uint32_t)gf->hostfd, (uint64_t)buf, (uint64_t)len); } static void gdb_write(CPUState *cs, gdb_syscall_complete_cb complete, GuestFD *gf, target_ulong buf, target_ulong len) { - gdb_do_syscall(complete, "write,%x,%x,%x", - (target_ulong)gf->hostfd, buf, len); + gdb_do_syscall(complete, "write,%x,%lx,%lx", + (uint32_t)gf->hostfd, (uint64_t)buf, (uint64_t)len); } static void gdb_lseek(CPUState *cs, gdb_syscall_complete_cb complete, GuestFD *gf, int64_t off, int gdb_whence) { gdb_do_syscall(complete, "lseek,%x,%lx,%x", - (target_ulong)gf->hostfd, off, (target_ulong)gdb_whence); + (uint32_t)gf->hostfd, off, (uint32_t)gdb_whence); } static void gdb_isatty(CPUState *cs, gdb_syscall_complete_cb complete, GuestFD *gf) { - gdb_do_syscall(complete, "isatty,%x", (target_ulong)gf->hostfd); + gdb_do_syscall(complete, "isatty,%x", (uint32_t)gf->hostfd); } static void gdb_fstat(CPUState *cs, gdb_syscall_complete_cb complete, GuestFD *gf, target_ulong addr) { - gdb_do_syscall(complete, "fstat,%x,%x", (target_ulong)gf->hostfd, addr); + gdb_do_syscall(complete, "fstat,%x,%lx", + (uint32_t)gf->hostfd, (uint64_t)addr); } static void gdb_stat(CPUState *cs, gdb_syscall_complete_cb complete, @@ -191,7 +193,8 @@ static void gdb_stat(CPUState *cs, gdb_syscall_complete_cb complete, return; } - gdb_do_syscall(complete, "stat,%s,%x", fname, len, addr); + gdb_do_syscall(complete, "stat,%s,%lx", + (uint64_t)fname, (uint32_t)len, (uint64_t)addr); } static void gdb_remove(CPUState *cs, gdb_syscall_complete_cb complete, @@ -203,7 +206,7 @@ static void gdb_remove(CPUState *cs, gdb_syscall_complete_cb complete, return; } - gdb_do_syscall(complete, "unlink,%s", fname, len); + gdb_do_syscall(complete, "unlink,%s", (uint64_t)fname, (uint32_t)len); } static void gdb_rename(CPUState *cs, gdb_syscall_complete_cb complete, @@ -223,7 +226,9 @@ static void gdb_rename(CPUState *cs, gdb_syscall_complete_cb complete, return; } - gdb_do_syscall(complete, "rename,%s,%s", oname, olen, nname, nlen); + gdb_do_syscall(complete, "rename,%s,%s", + (uint64_t)oname, (uint32_t)olen, + (uint64_t)nname, (uint32_t)nlen); } static void gdb_system(CPUState *cs, gdb_syscall_complete_cb complete, @@ -235,13 +240,14 @@ static void gdb_system(CPUState *cs, gdb_syscall_complete_cb complete, return; } - gdb_do_syscall(complete, "system,%s", cmd, len); + gdb_do_syscall(complete, "system,%s", (uint64_t)cmd, (uint32_t)len); } static void gdb_gettimeofday(CPUState *cs, gdb_syscall_complete_cb complete, target_ulong tv_addr, target_ulong tz_addr) { - gdb_do_syscall(complete, "gettimeofday,%x,%x", tv_addr, tz_addr); + gdb_do_syscall(complete, "gettimeofday,%lx,%lx", + (uint64_t)tv_addr, (uint64_t)tz_addr); } /*