From patchwork Wed Jan 22 09:30:26 2025 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: 859149 Delivered-To: patch@linaro.org Received: by 2002:adf:f78a:0:b0:385:e875:8a9e with SMTP id q10csp244854wrp; Wed, 22 Jan 2025 01:33:38 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXXqQG4m8H91+W+oiZL5F+l0cS9S83d1lSfs761QBXrRpyuQmv6ers9mMJy8XzcIGety1cDQg==@linaro.org X-Google-Smtp-Source: AGHT+IE28AJXNoLo9PoKaxWktKEYcgxXdtjE/azY/5/U5gQvn5YGbjGLkrIjc/YuklG1h2yj+Q+U X-Received: by 2002:a05:6214:590a:b0:6d3:65ad:5cf9 with SMTP id 6a1803df08f44-6e1b217d2e4mr319619686d6.15.1737538417886; Wed, 22 Jan 2025 01:33:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1737538417; cv=none; d=google.com; s=arc-20240605; b=KrOUbdKW9Igg+NncHhvEXzzcYDE5rmimLt8zU8qqYStDiKYyUbnH4N6cTeR8hv6sHP 9jzyx5xC97DWeviERVbMF/9rgpGgAseKvAbF6S/lpSm/jD5/C6p049Ld2YIYzMAjFixu 75hi6N1IOqtC7mBw/6d4WrhScZJd7syDl/nkOKMtKbcbuL/h4z4TONQmef0qy+QxYOiL 7JckTdQ/vMxuncbjil0RDVgG2pFw65RynIIHnABK61JSiZIDbw/A0Bl2bEsGcZMcGB+2 wcZLKjkTmaJA6N87YPYEttfh8LKkhOFuBjaSw3+8ypZCKGAKiJyJSrjp0GoMtb4ZACtM cAZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=oNGgwti16N0RaYgdrpqIsRq0rprgvC+KnfZZxJFop+c=; fh=Brec4ZYd5wGCfOwL/9Q1OxqxWlcx8jJnKse3UD0zpBM=; b=BgEgeoAhyJYBVgZpUQh6O8zDjaxTvpsQQSnRgKw/X43zErfvYBcXnDrvvOQST/gn/H x/yov9U8jSExrqP6Lc8XVbdHK8X91cv7bKDpOKWvX0KHy8uRIOGLD8venXpWAU9edls7 tEennorA+brSr035qeK9BINpTppu2oQeG6OEXMLrJXk+olNZuvuiAHwZ32uCu5b3oHUr DR/Ffy2eNwmLJC8nZ04wXx6sUIYjQ6PdobCg5SfWg8spXdocylQp4sgN+z6cVbMUlYXB BnTtg/HsYiMpHtmUG222U9ykixwL+fMg8gzD7h0XR/fcjYwax3QXnejS7k0ogBhLMote M2og==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kuPihQ+j; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6e1afbfafdesi147688456d6.82.2025.01.22.01.33.37 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 22 Jan 2025 01:33:37 -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=kuPihQ+j; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1taX4q-0001uZ-LR; Wed, 22 Jan 2025 04:31:12 -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 1taX4p-0001no-0s for qemu-devel@nongnu.org; Wed, 22 Jan 2025 04:31:11 -0500 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1taX4n-0003JN-37 for qemu-devel@nongnu.org; Wed, 22 Jan 2025 04:31:10 -0500 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-43618283dedso68312065e9.3 for ; Wed, 22 Jan 2025 01:31:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1737538267; x=1738143067; 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=oNGgwti16N0RaYgdrpqIsRq0rprgvC+KnfZZxJFop+c=; b=kuPihQ+jR1gPK2UJ5o4uSVFxKd8szyWW6+hgzm/NbfV8EjIXgQZzsy7NUt0TSIsoNq AnCdhNgfQODnQTax462AxdH6Fzv5lOXFB0ry5RP7IhbB7UI3qVeGAdaJnHoBwTlML/zx kdEVoCywx3SurXSinoFbPPu7qf/y1cEpdLdX0QGgYCQotp52OTyZ1RiHsTnxmu1nzcYQ wxknbMQezYYG13BbyBxkJ00fatrXHch7ppOErsAWPsrH9vwaA+npVWdXxm2dmukMeqoz +sKfHdD+sgWUETi3Kvc9Do1pui9O88UTQn2g68+rQwhfq/62ptleNVjJwSnCQ2rVz1Cu fFFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737538267; x=1738143067; 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=oNGgwti16N0RaYgdrpqIsRq0rprgvC+KnfZZxJFop+c=; b=SQTB/ZINvU2nYhUGSwZGysBKUQab9N/NfbXKIzpc8IuzpY9HhHzDCMKumRZYdDsjTk x8onswo36BwZSd1yVTDmAva18drysD4mZ5N0wnINA1ZGISyk3iGbSEqYJcrBkn57LbdK 7p5KrgsnQTTDe+IQlThtYsJxw4D1dZqD/DGAruxi78CdCbRugOWh4Vps0CVKf4Xc+OUj 49f6E3tUjXnFn8zP85X3Wiq1ePIIon/82jAzI8dkNjjIbpVylOAeO6jX7PY5VNtpsCCI IfJZh1re7GZrwpPYUnP8z4+L//mHkA1H8jvvIkC/KM3SY90Dgi9V+NTMEJ3eWU2i9/fJ 1BcA== X-Gm-Message-State: AOJu0YyJnWzWIJlLjuHfS6bDOL44lPJByzFNwc6eH5t09IFwYMKeKNfb clDuUdATELh3Lg3l6upOjg0GlLud4UGURMQjVpekSi990+hB4F+iJgV4YOY6vTPFzyokY7famI4 UIeY= X-Gm-Gg: ASbGnctZDpHeSdVvBeMxUFEF00siQEIjoLPqMrb6y2wbDi7TklTtZ9pBf6Zl6NVVto5 zo80r2nDbMVh1T/+Ff6SqyVmCUtNwI2pEOnZUwbG6ay/2jns9FnPdiiwI1R7xYkjCOIJv4xi/kN aT6bagreDAoicKw1qfOloZZeMV/7mz9UjIevWDtFwyIxsElAr12A3WR3gVtFMMMufa59CjHmVic K3U8R3uRuAv6ZaR1BjpIt1uD33CuTo9M/y/JGsZo58oCTjkcxflupfvD58gYby5i1hc53tLjoVF GpNQ4bTmnSAjfo+VXPyP6KxZYf+UqAkrBW2719pq3sd5 X-Received: by 2002:a05:600c:468d:b0:434:a75b:5f59 with SMTP id 5b1f17b1804b1-438913bdb19mr175725585e9.3.1737538267345; Wed, 22 Jan 2025 01:31:07 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-438b31afaf8sm17294715e9.21.2025.01.22.01.31.06 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 22 Jan 2025 01:31:06 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Richard Henderson , =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Philippe_M?= =?utf-8?q?athieu-Daud=C3=A9?= Subject: [PATCH v2 08/10] gdbstub: Prefer cached CpuClass over CPU_GET_CLASS() macro Date: Wed, 22 Jan 2025 10:30:26 +0100 Message-ID: <20250122093028.52416-9-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250122093028.52416-1-philmd@linaro.org> References: <20250122093028.52416-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=philmd@linaro.org; helo=mail-wm1-x329.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=unavailable 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 CpuState caches its CPUClass since commit 6fbdff87062 ("cpu: cache CPUClass in CPUState for hot code paths"), use it. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- gdbstub/gdbstub.c | 26 +++++++++----------------- gdbstub/system.c | 7 ++----- gdbstub/user-target.c | 6 ++---- gdbstub/user.c | 7 ++----- 4 files changed, 15 insertions(+), 31 deletions(-) diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index e366df12d4a..282e13e163f 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -354,7 +354,6 @@ static const char *get_feature_xml(const char *p, const char **newp, GDBProcess *process) { CPUState *cpu = gdb_get_first_cpu_in_process(process); - CPUClass *cc = CPU_GET_CLASS(cpu); GDBRegisterState *r; size_t len; @@ -377,11 +376,11 @@ static const char *get_feature_xml(const char *p, const char **newp, "" "")); - if (cc->gdb_arch_name) { + if (cpu->cc->gdb_arch_name) { g_ptr_array_add( xml, g_markup_printf_escaped("%s", - cc->gdb_arch_name(cpu))); + cpu->cc->gdb_arch_name(cpu))); } for (guint i = 0; i < cpu->gdb_regs->len; i++) { r = &g_array_index(cpu->gdb_regs, GDBRegisterState, i); @@ -520,11 +519,10 @@ GArray *gdb_get_register_list(CPUState *cpu) int gdb_read_register(CPUState *cpu, GByteArray *buf, int reg) { - CPUClass *cc = CPU_GET_CLASS(cpu); GDBRegisterState *r; - if (reg < cc->gdb_num_core_regs) { - return cc->gdb_read_register(cpu, buf, reg); + if (reg < cpu->cc->gdb_num_core_regs) { + return cpu->cc->gdb_read_register(cpu, buf, reg); } for (guint i = 0; i < cpu->gdb_regs->len; i++) { @@ -538,11 +536,10 @@ int gdb_read_register(CPUState *cpu, GByteArray *buf, int reg) static int gdb_write_register(CPUState *cpu, uint8_t *mem_buf, int reg) { - CPUClass *cc = CPU_GET_CLASS(cpu); GDBRegisterState *r; - if (reg < cc->gdb_num_core_regs) { - return cc->gdb_write_register(cpu, mem_buf, reg); + if (reg < cpu->cc->gdb_num_core_regs) { + return cpu->cc->gdb_write_register(cpu, mem_buf, reg); } for (guint i = 0; i < cpu->gdb_regs->len; i++) { @@ -570,7 +567,7 @@ static void gdb_register_feature(CPUState *cpu, int base_reg, void gdb_init_cpu(CPUState *cpu) { - CPUClass *cc = CPU_GET_CLASS(cpu); + CPUClass *cc = cpu->cc; const GDBFeature *feature; cpu->gdb_regs = g_array_new(false, false, sizeof(GDBRegisterState)); @@ -1646,11 +1643,8 @@ void gdb_extend_qsupported_features(char *qflags) static void handle_query_supported(GArray *params, void *user_ctx) { - CPUClass *cc; - g_string_printf(gdbserver_state.str_buf, "PacketSize=%x", MAX_PACKET_LENGTH); - cc = CPU_GET_CLASS(first_cpu); - if (cc->gdb_core_xml_file) { + if (first_cpu->cc->gdb_core_xml_file) { g_string_append(gdbserver_state.str_buf, ";qXfer:features:read+"); } @@ -1697,7 +1691,6 @@ static void handle_query_supported(GArray *params, void *user_ctx) static void handle_query_xfer_features(GArray *params, void *user_ctx) { GDBProcess *process; - CPUClass *cc; unsigned long len, total_len, addr; const char *xml; const char *p; @@ -1708,8 +1701,7 @@ static void handle_query_xfer_features(GArray *params, void *user_ctx) } process = gdb_get_cpu_process(gdbserver_state.g_cpu); - cc = CPU_GET_CLASS(gdbserver_state.g_cpu); - if (!cc->gdb_core_xml_file) { + if (!gdbserver_state.g_cpu->cc->gdb_core_xml_file) { gdb_put_packet(""); return; } diff --git a/gdbstub/system.c b/gdbstub/system.c index 8ce79fa88cf..215a2c5dcad 100644 --- a/gdbstub/system.c +++ b/gdbstub/system.c @@ -452,8 +452,6 @@ static int phy_memory_mode; int gdb_target_memory_rw_debug(CPUState *cpu, hwaddr addr, uint8_t *buf, int len, bool is_write) { - CPUClass *cc; - if (phy_memory_mode) { if (is_write) { cpu_physical_memory_write(addr, buf, len); @@ -463,9 +461,8 @@ int gdb_target_memory_rw_debug(CPUState *cpu, hwaddr addr, return 0; } - cc = CPU_GET_CLASS(cpu); - if (cc->memory_rw_debug) { - return cc->memory_rw_debug(cpu, addr, buf, len, is_write); + if (cpu->cc->memory_rw_debug) { + return cpu->cc->memory_rw_debug(cpu, addr, buf, len, is_write); } return cpu_memory_rw_debug(cpu, addr, buf, len, is_write); diff --git a/gdbstub/user-target.c b/gdbstub/user-target.c index 22bf4008c0f..355b1901b4f 100644 --- a/gdbstub/user-target.c +++ b/gdbstub/user-target.c @@ -233,10 +233,8 @@ void gdb_handle_query_offsets(GArray *params, void *user_ctx) static inline int target_memory_rw_debug(CPUState *cpu, target_ulong addr, uint8_t *buf, int len, bool is_write) { - CPUClass *cc; - cc = CPU_GET_CLASS(cpu); - if (cc->memory_rw_debug) { - return cc->memory_rw_debug(cpu, addr, buf, len, is_write); + if (cpu->cc->memory_rw_debug) { + return cpu->cc->memory_rw_debug(cpu, addr, buf, len, is_write); } return cpu_memory_rw_debug(cpu, addr, buf, len, is_write); } diff --git a/gdbstub/user.c b/gdbstub/user.c index c2bdfc3d491..375f7f80653 100644 --- a/gdbstub/user.c +++ b/gdbstub/user.c @@ -665,11 +665,8 @@ int gdb_continue_partial(char *newstates) int gdb_target_memory_rw_debug(CPUState *cpu, hwaddr addr, uint8_t *buf, int len, bool is_write) { - CPUClass *cc; - - cc = CPU_GET_CLASS(cpu); - if (cc->memory_rw_debug) { - return cc->memory_rw_debug(cpu, addr, buf, len, is_write); + if (cpu->cc->memory_rw_debug) { + return cpu->cc->memory_rw_debug(cpu, addr, buf, len, is_write); } return cpu_memory_rw_debug(cpu, addr, buf, len, is_write); }