From patchwork Mon Mar 17 14:28:12 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 874160 Delivered-To: patch@linaro.org Received: by 2002:a5d:4308:0:b0:38f:210b:807b with SMTP id h8csp2021932wrq; Mon, 17 Mar 2025 07:29:52 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCW/0URSSvj/dZpAiVmodv/ykMLeLtTJgD4N3bxSP74VHjRefBFBu0/utD2GNkqcYEEV5KtVVQ==@linaro.org X-Google-Smtp-Source: AGHT+IGp2ka5osHlhUHq5JpLHt7AapaRzSNYAg1S2hfX7Is67ngRnwtEtjFtRoMNMr3iCn/vuyOF X-Received: by 2002:a05:6102:3046:b0:4bb:e14a:9451 with SMTP id ada2fe7eead31-4c4d91d131cmr55019137.20.1742221792486; Mon, 17 Mar 2025 07:29:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1742221792; cv=none; d=google.com; s=arc-20240605; b=VHIivpOh+/LROtDIiOtWdPsbco4PV6P+yoRHSN/WUCyO5BOCCDgqMQo5H6Xg44VOti D3RAff1xu1trJj/EBWIdrJ2feESBd4CZSVQpFImmQRgzHltgUcdsAORd0tHKy+lpRdyy 9lxMECrqfzOaCZw1XQ5Qe4iohP9f84LRPYQI8rRdA0jj7zkmqiT7dF5EUBzkiGhVAAhk l2dfgzVWnFCZvpP1X3SI81GrYu6Q+t2MXTDuhQPVr1nos2cWsq/TA0L3gMBy58XVn9CK tpqfcmsw8yGktf2E5EiQohpm5uP4QXCcEg4BoEJqs3/vnpg96q2srRoaTA0ClGGgTRdj nvog== 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:to:from :dkim-signature; bh=+SwrrX67kenI+BYFfzChB1e3tHX2NRLJrXjCUBc/EtU=; fh=34d4cTVHPJRW7WcACnICyvWwHj3qLEXyoxZ4nMSL9Ik=; b=MD1QSFtAip6bt/XhqUXDNT2GCb0xwbMk3as4MI9NasFg+ENL08CpgmOwEA2M8GoCEV jJxqBvMYRyeCemcQYXwusdYTkPRNnqEB84NorBf0ynMA2j0x/UV2zP71rSODkFVnPWAu ginCwPzjrjIOyCaMi3JjzJz125iCFA9ps1sSo+u0D34rJY3kJNkmWKXBoIhaXYPl647c J1WI7MzCZcn/NdnbMFisEnu9hXhkdMFc2qquTSm7uiKrZ//5Hyaw4XDM8CaqjeAAnf3P FhDtMSgby6AEpoLYPX7MZVao6uPEY0kpMSYSuPsXAZBwHcIoMSjVENmmIRPDPaIqtrQZ hMsw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NaaUKEXZ; 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 ada2fe7eead31-4c374a7efddsi2444959137.232.2025.03.17.07.29.52 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 17 Mar 2025 07:29:52 -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=NaaUKEXZ; 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 1tuBSD-0000da-Ra; Mon, 17 Mar 2025 10:28:34 -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 1tuBS7-0000Yx-TN for qemu-devel@nongnu.org; Mon, 17 Mar 2025 10:28:28 -0400 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 1tuBS4-00018P-Qv for qemu-devel@nongnu.org; Mon, 17 Mar 2025 10:28:27 -0400 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-43cf3192f3bso23338305e9.1 for ; Mon, 17 Mar 2025 07:28:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1742221703; x=1742826503; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=+SwrrX67kenI+BYFfzChB1e3tHX2NRLJrXjCUBc/EtU=; b=NaaUKEXZCPw0AG4v7+OB3EqnKQESV3Yi/XxS8n+cigLg9qEMeRKtON8s1rqQrceGRX jM0r6tOiXJLrDBrVDSXs/sLymbbp8isKMPYWs/rJ00uMNBTVgguf/FSlKsjTRzUBse++ IZEO4Svtl/Kf/jxEIONwx+Q0SHxyoX9QjXF3oXjXTwFtzwMLXtV56d+WVxicPBUjNvZY RqIwoYpt/ElzST+4Tq6gM4rVHAAg+8vsNyJ+Hfm5DYaz3TUDBZSy0o45poR/+yyF2Ba0 S0rKodHHv2xit7ZhQCoCUnuhXLrpiucyjhTth/umYHyqA90h7GJB/HbpLY8yZkD8aRAq 5lyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742221703; x=1742826503; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+SwrrX67kenI+BYFfzChB1e3tHX2NRLJrXjCUBc/EtU=; b=eu1g7brn+S3GPuIMsufcsSX/S85m9W5Bsr8YMjQ26GbMOpy9gTLEWRrZZXhFFCxbHj 2jY5ra44TpjpvuYH0g6FauVZv+V6R9EHld7zhA/tLBSpMQXnwG7lEJ6mQRKshTN6bYRx 2s5yqb8iECv1G19xPzSwzCuNRJlIEZy35m9w2wHiTjpewQb/vPjmZmz95kiVijpdV461 oBLCmIrk1AkRA4QiFIscWIimz2WfXCgIEjJyHc2s1/fvTv9rOYYiefR9WnsT7QPxkS2V PJD3mDruJ6brUrEOmiNKF0AbCqPb3mv6hnWdJxhu0smPIqp9g11bFd86Qaf1xaxJGnsX Yz8g== X-Forwarded-Encrypted: i=1; AJvYcCUwLhvlff95DWhUlCcxuLj+W7nfpEwGOvIv0p1ORGMR4+mbe9QjARFEnPot7Qilm8RTi2oN4o5joNYp@nongnu.org X-Gm-Message-State: AOJu0YyF9OoJYU604uEWkqeStNt4tsdPHapkzO0acJrH6YlcycPnI+o9 YD1IKY9j+cpEUkCOZXS0Hzwj0QsX1VqRAvzGf0ulCIJpmbHZQ6CEQaDmtEyYrfk= X-Gm-Gg: ASbGncvmiZmyPDh64QedVMBoOkPOW1PLOiPco9ppXk3mS7uLWU+X1Uwj++bf4abf0IF zuRASRr3M3HfGK0DY0S10mMExLvi90Cymotz4Zf7koAEgkHkZ6OBCg+rH/iDCznt+2lsDoQIWFV A72r23mT5c5FnlCdzzggSho2itkNjoAGAX1yUfn/R7HNp0qL5opSAK0gk07Ww2ckb5wpewD7vDV 4UpRNlL1qfQlPcpb+v3y0aJ0KUwWlSKNvHggt3Qu/I//n1KP9lDG6VOA8wkT2iYoeRH8MDMFj7t 3MaOIp4a/XxzonI45OBSCbCmn4TE65c2XRtHkq+/YAwW503NJRo= X-Received: by 2002:a05:600c:3b8b:b0:43c:f895:cb4e with SMTP id 5b1f17b1804b1-43d1ecb13camr135691515e9.17.1742221703155; Mon, 17 Mar 2025 07:28:23 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43d1fe60ad4sm107914985e9.29.2025.03.17.07.28.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Mar 2025 07:28:22 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH for-10.1 2/9] gdbstub: Allow gdb_core_xml_file to be set at runtime Date: Mon, 17 Mar 2025 14:28:12 +0000 Message-ID: <20250317142819.900029-3-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250317142819.900029-1-peter.maydell@linaro.org> References: <20250317142819.900029-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32b; envelope-from=peter.maydell@linaro.org; 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, 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 Currently the CPUClass:gdb_core_xml_file setting is a simple 'const char *' which the CPU class must set to a fixed string. Allow the CPU class to instead set a new method gdb_get_core_xml_file() which returns this string. This will allow Arm CPUs to use different XML files for AArch32 vs AArch64 without having to have an extra AArch64-specific class type purely to give somewhere to set cc->gdb_core_xml_file differently. Signed-off-by: Peter Maydell Acked-by: Alex Bennée --- include/hw/core/cpu.h | 5 +++++ gdbstub/gdbstub.c | 23 +++++++++++++++++++---- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index 5873ee5998f..140d8a0bd79 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -132,6 +132,10 @@ struct SysemuCPUOps; * @gdb_num_core_regs: Number of core registers accessible to GDB or 0 to infer * from @gdb_core_xml_file. * @gdb_core_xml_file: File name for core registers GDB XML description. + * @gdb_get_core_xml_file: Optional callback that returns the file name for + * the core registers GDB XML description. The returned value is expected to + * be a simple constant string: the caller will not g_free() it. If this + * is NULL then @gdb_core_xml_file will be used instead. * @gdb_stop_before_watchpoint: Indicates whether GDB expects the CPU to stop * before the insn which triggers a watchpoint rather than after it. * @gdb_arch_name: Optional callback that returns the architecture name known @@ -167,6 +171,7 @@ struct CPUClass { const char *gdb_core_xml_file; const gchar * (*gdb_arch_name)(CPUState *cpu); + const char * (*gdb_get_core_xml_file)(CPUState *cpu); void (*disas_set_info)(CPUState *cpu, disassemble_info *info); diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index 282e13e163f..565f6b33a90 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -565,15 +565,30 @@ static void gdb_register_feature(CPUState *cpu, int base_reg, g_array_append_val(cpu->gdb_regs, s); } +static const char *gdb_get_core_xml_file(CPUState *cpu) +{ + CPUClass *cc = cpu->cc; + + /* + * The CPU class can provide the XML filename via a method, + * or as a simple fixed string field. + */ + if (cc->gdb_get_core_xml_file) { + return cc->gdb_get_core_xml_file(cpu); + } + return cc->gdb_core_xml_file; +} + void gdb_init_cpu(CPUState *cpu) { CPUClass *cc = cpu->cc; const GDBFeature *feature; + const char *xmlfile = gdb_get_core_xml_file(cpu); cpu->gdb_regs = g_array_new(false, false, sizeof(GDBRegisterState)); - if (cc->gdb_core_xml_file) { - feature = gdb_find_static_feature(cc->gdb_core_xml_file); + if (xmlfile) { + feature = gdb_find_static_feature(xmlfile); gdb_register_feature(cpu, 0, cc->gdb_read_register, cc->gdb_write_register, feature); @@ -1644,7 +1659,7 @@ void gdb_extend_qsupported_features(char *qflags) static void handle_query_supported(GArray *params, void *user_ctx) { g_string_printf(gdbserver_state.str_buf, "PacketSize=%x", MAX_PACKET_LENGTH); - if (first_cpu->cc->gdb_core_xml_file) { + if (gdb_get_core_xml_file(first_cpu)) { g_string_append(gdbserver_state.str_buf, ";qXfer:features:read+"); } @@ -1701,7 +1716,7 @@ static void handle_query_xfer_features(GArray *params, void *user_ctx) } process = gdb_get_cpu_process(gdbserver_state.g_cpu); - if (!gdbserver_state.g_cpu->cc->gdb_core_xml_file) { + if (!gdb_get_core_xml_file(gdbserver_state.g_cpu)) { gdb_put_packet(""); return; }