From patchwork Wed Aug 30 14:54:06 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: 718583 Delivered-To: patch@linaro.org Received: by 2002:adf:d20a:0:b0:31d:da82:a3b4 with SMTP id j10csp585396wrh; Wed, 30 Aug 2023 07:55:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG1/Zr9WHuVDFZVzPA4dTPTc0qF1mf+v0XZRJoXMFYljU0s2QenBwP+qQDJM5MF0SnlD627 X-Received: by 2002:ac8:7c6:0:b0:410:8bfd:1696 with SMTP id m6-20020ac807c6000000b004108bfd1696mr2045477qth.49.1693407330284; Wed, 30 Aug 2023 07:55:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693407330; cv=none; d=google.com; s=arc-20160816; b=BQGJcZxl3KOzhAglJBq/W7azJoru6/X9PR+j4MD9di5XEDcMSv9thXesTa/pH67ZbW eCY2tJsascUulr97pvXJvV1tWbwMM1INMVME2qRDGFwynMUtd4M/OrndWf0IMtWG8N6s 0zudxMUAXDwuXCpCplnylm8rxTsPRHJ5ct9PEJz2K/J3jtfoaNbH0si7QqMKX1F7Zgph 2ZFGm/m9ZuvU+jfM0FJm5vpAZJ8PganVUvvLperRHk82tY4YSj6Y71XYTOEGza6EX8UG uXIgatuZzuGKSG5gjRA18mFsTHo8P//epcXYXoJvH2Y8Kg63Tnuoy4x6kOqfQTyaCZRT BPqw== 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=FIIWkIImEVUr1vcFkZ9mfJXCWjjR9U+tUkLobigHVPM=; fh=cNBNjIifkXlfYWcC4LzEAnGhDOxvJxHY2iXKqabQbo0=; b=ZRAksAQ9ANtZtEJI0mH9LPQOwK8rY9IRj1UHq2eRHx1EfMyUCiCVTa0eudSOIt26hQ KQPeqj9ksG0bL1xtIny8xrCKAFTONYA7J5VB1SsN5tlPmZiuY/g8PgoTipCgACCsBecu dluHlVIO4pMr1+2OgOFlkH1SNJEUn++oEtuLe1VwcGHTWHwNvA+pvAgI/aEx/ojr3+tS cqLZBON/NaZ2IiiPymRAiQV4JoRe55MOvGIdHv0yP97+6Tg3r8THPOVVkO0U0XZOv6B9 0B9L7RJgtHi1Ix4RcbTdj/m1ThogjDlKUOtV1wHB01LQ2zF2v0r0sleK3OF/cbFtaQxe Jz7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=T7COO35S; 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 eo11-20020a05622a544b00b00410a249beecsi7146514qtb.277.2023.08.30.07.55.30 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 30 Aug 2023 07:55:30 -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=T7COO35S; 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 1qbMaO-0001G9-1k; Wed, 30 Aug 2023 10:54:24 -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 1qbMaK-0001Dq-Hh for qemu-devel@nongnu.org; Wed, 30 Aug 2023 10:54:20 -0400 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qbMaF-0000lH-9L for qemu-devel@nongnu.org; Wed, 30 Aug 2023 10:54:20 -0400 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-40037db2fe7so53705235e9.0 for ; Wed, 30 Aug 2023 07:54:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1693407254; x=1694012054; 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=FIIWkIImEVUr1vcFkZ9mfJXCWjjR9U+tUkLobigHVPM=; b=T7COO35S88ANfT8GnupCiA0KH+UMe9X8yaUpz37HbEqx+43UjLJO7hTTNMeHTJVIjy AUgb7IHyPebTNiwk9H7REK+c2NNZipQJq3NJtZGT3+BASie6ed7QkWGlJcJdWGNVC8tL rOtbDwk5VqcnY3ik8kRYye/Jd5BKjGC3IXKBzPuqGyi30vL5ubdf2ifGIRkQ69G3MnZ1 9UNBFqdZma7ZQ3koFd9uDlD83gyDXIJH133jUkUweRlbghBWUatrppDDPcScxSF3jxW1 uLzfWfn/pBB3e4PHgdylVTEVpkOrjKlUkLokku9dn35B8ML7VfCot4M4VGGr3NkjRs5a TzQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693407254; x=1694012054; 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=FIIWkIImEVUr1vcFkZ9mfJXCWjjR9U+tUkLobigHVPM=; b=NaTtjg20o6zwrrB0tuii5Y9q8TF2bc1WC/3ILL1NTdihxUHLZ6V3Xp0nPPH4oti98y FR61B2CMPOzY/ddJ42o/vzi8ICiXEJ1xc6lR1LOerGrSfrE2Es+CDay+iMWvyyX2/Pps oPVXrMTasaGmjrnZOhPsn0O1OTNs2QJ0YOPipTiyw+K6P/LRDC4POhifEiKwKMvWi2FU 6UYIkWE/u6STI+jifnX3oBn/OhCk0WCPfThGYjD670AzfnUrq5zTHNYm9zqWjNN4pPeE epFIrK6SK+L+abmPy8COFvQkurAmq/MtPHJh7JsMVXIiCROfYRAMou6Mkh3083MEpAnZ 4dFg== X-Gm-Message-State: AOJu0YwKyU96z9BSBn2Sln//CT28RQoODIotHpQ49o07Z72pu051yh7J DifbqvXMvAcoqafP8I7qz9vToQ== X-Received: by 2002:a05:600c:b50:b0:3fe:c7fe:206e with SMTP id k16-20020a05600c0b5000b003fec7fe206emr2253566wmr.16.1693407253709; Wed, 30 Aug 2023 07:54:13 -0700 (PDT) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id n8-20020a7bcbc8000000b00401d8810c8bsm2501252wmi.15.2023.08.30.07.54.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Aug 2023 07:54:12 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id DE1081FFBD; Wed, 30 Aug 2023 15:54:08 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Philipp?= =?utf-8?q?e_Mathieu-Daud=C3=A9?= , Richard Henderson , Peter Maydell , Daniel Henrique Barboza , =?utf-8?q?C=C3=A9dric_Le_G?= =?utf-8?q?oater?= , David Gibson , Greg Kurz , Nicholas Piggin , qemu-arm@nongnu.org (open list:ARM TCG CPUs), qemu-ppc@nongnu.org (open list:PowerPC TCG CPUs) Subject: [PULL 11/12] gdbstub: replace global gdb_has_xml with a function Date: Wed, 30 Aug 2023 15:54:06 +0100 Message-Id: <20230830145407.3064249-12-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230830145407.3064249-1-alex.bennee@linaro.org> References: <20230830145407.3064249-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::330; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x330.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 Try and make the self reported global hack a little less hackish by providing a query function instead. As gdb_has_xml was always set if we negotiated XML we can now use the presence of ->target_xml as the test instead. Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Signed-off-by: Alex Bennée Message-Id: <20230829161528.2707696-12-alex.bennee@linaro.org> diff --git a/gdbstub/internals.h b/gdbstub/internals.h index 4876ebd74f..fee243081f 100644 --- a/gdbstub/internals.h +++ b/gdbstub/internals.h @@ -33,6 +33,7 @@ typedef struct GDBProcess { uint32_t pid; bool attached; + /* If gdb sends qXfer:features:read:target.xml this will be populated */ char *target_xml; } GDBProcess; diff --git a/include/exec/gdbstub.h b/include/exec/gdbstub.h index 7d743fe1e9..0ee39cfdd1 100644 --- a/include/exec/gdbstub.h +++ b/include/exec/gdbstub.h @@ -31,12 +31,12 @@ int gdbserver_start(const char *port_or_device); void gdb_set_stop_cpu(CPUState *cpu); /** - * gdb_has_xml: - * This is an ugly hack to cope with both new and old gdb. - * If gdb sends qXfer:features:read then assume we're talking to a newish - * gdb that understands target descriptions. + * gdb_has_xml() - report of gdb supports modern target descriptions + * + * This will report true if the gdb negotiated qXfer:features:read + * target descriptions. */ -extern bool gdb_has_xml; +bool gdb_has_xml(void); /* in gdbstub-xml.c, generated by scripts/feature_to_c.sh */ extern const char *const xml_builtin[][2]; diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index 729e54139a..fdebfe25ea 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -75,8 +75,6 @@ void gdb_init_gdbserver_state(void) gdbserver_state.sstep_flags &= gdbserver_state.supported_sstep_flags; } -bool gdb_has_xml; - /* writes 2*len+1 bytes in buf */ void gdb_memtohex(GString *buf, const uint8_t *mem, int len) { @@ -351,6 +349,11 @@ static CPUState *gdb_get_cpu(uint32_t pid, uint32_t tid) } } +bool gdb_has_xml(void) +{ + return !!gdb_get_cpu_process(gdbserver_state.g_cpu)->target_xml; +} + static const char *get_feature_xml(const char *p, const char **newp, GDBProcess *process) { @@ -1084,7 +1087,7 @@ static void handle_set_reg(GArray *params, void *user_ctx) { int reg_size; - if (!gdb_has_xml) { + if (!gdb_get_cpu_process(gdbserver_state.g_cpu)->target_xml) { gdb_put_packet(""); return; } @@ -1105,7 +1108,7 @@ static void handle_get_reg(GArray *params, void *user_ctx) { int reg_size; - if (!gdb_has_xml) { + if (!gdb_get_cpu_process(gdbserver_state.g_cpu)->target_xml) { gdb_put_packet(""); return; } @@ -1572,7 +1575,6 @@ static void handle_query_xfer_features(GArray *params, void *user_ctx) return; } - gdb_has_xml = true; p = get_param(params, 0)->data; xml = get_feature_xml(p, &p, process); if (!xml) { diff --git a/gdbstub/softmmu.c b/gdbstub/softmmu.c index f509b7285d..9f0b8b5497 100644 --- a/gdbstub/softmmu.c +++ b/gdbstub/softmmu.c @@ -97,7 +97,6 @@ static void gdb_chr_event(void *opaque, QEMUChrEvent event) vm_stop(RUN_STATE_PAUSED); replay_gdb_attached(); - gdb_has_xml = false; break; default: break; diff --git a/gdbstub/user.c b/gdbstub/user.c index 5b375be1d9..7ab6e5d975 100644 --- a/gdbstub/user.c +++ b/gdbstub/user.c @@ -198,7 +198,6 @@ static void gdb_accept_init(int fd) gdbserver_state.c_cpu = gdb_first_attached_cpu(); gdbserver_state.g_cpu = gdbserver_state.c_cpu; gdbserver_user_state.fd = fd; - gdb_has_xml = false; } static bool gdb_accept_socket(int gdb_fd) diff --git a/target/arm/gdbstub.c b/target/arm/gdbstub.c index f421c5d041..8fc8351df7 100644 --- a/target/arm/gdbstub.c +++ b/target/arm/gdbstub.c @@ -48,7 +48,7 @@ int arm_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) } if (n < 24) { /* FPA registers. */ - if (gdb_has_xml) { + if (gdb_has_xml()) { return 0; } return gdb_get_zeroes(mem_buf, 12); @@ -56,7 +56,7 @@ int arm_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) switch (n) { case 24: /* FPA status register. */ - if (gdb_has_xml) { + if (gdb_has_xml()) { return 0; } return gdb_get_reg32(mem_buf, 0); @@ -102,7 +102,7 @@ int arm_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) } if (n < 24) { /* 16-23 */ /* FPA registers (ignored). */ - if (gdb_has_xml) { + if (gdb_has_xml()) { return 0; } return 12; @@ -110,7 +110,7 @@ int arm_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) switch (n) { case 24: /* FPA status register (ignored). */ - if (gdb_has_xml) { + if (gdb_has_xml()) { return 0; } return 4; diff --git a/target/ppc/gdbstub.c b/target/ppc/gdbstub.c index ca39efdc35..2ad11510bf 100644 --- a/target/ppc/gdbstub.c +++ b/target/ppc/gdbstub.c @@ -56,7 +56,7 @@ static int ppc_gdb_register_len(int n) return sizeof(target_ulong); case 32 ... 63: /* fprs */ - if (gdb_has_xml) { + if (gdb_has_xml()) { return 0; } return 8; @@ -76,7 +76,7 @@ static int ppc_gdb_register_len(int n) return sizeof(target_ulong); case 70: /* fpscr */ - if (gdb_has_xml) { + if (gdb_has_xml()) { return 0; } return sizeof(target_ulong);