From nobody Fri Dec 19 19:18:40 2025 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 ARC-Seal: i=1; a=rsa-sha256; t=1693717624; cv=none; d=zohomail.com; s=zohoarc; b=BB+v9RL8YSDuioI5OOvVsRqMtA+u5PJzqtDtiGtrKKkBbUHgyvMeYuhMcnu8e8fjr+Ln7bfiAONCBEdZv1p+s0XVw57vMXDoxAUuR3jT0c12zwXeZUE/u54a+a7oTFwwsq4OpBqUNfQXSnmrHEPbUUMjtB5uILvvslSzck+2o2s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693717624; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject; bh=roTMe45HmgofN3+MiGETn4+wzF2HiB60U2BiLq2radc=; b=O6U2qz3pV9xZ6QVXAAD0XnoGKvSojUM3Rl0ZC5wDpxQdAr+d+547hK2WpDxcOON3h8tkowZAdDtULz8ty0vlmrvEPHYteEn3y2XVfECRw/jBqBFjlnKENs5fopGVniFv1ozz1F5wytvG5vU5U/rrdGbh9WHcn1UfjbH2CofSFPQ= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1693717624196526.843330637778; Sat, 2 Sep 2023 22:07:04 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qcfIv-0004Qk-3y; Sun, 03 Sep 2023 01:05:45 -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 1qcfHg-0002pI-OA for qemu-devel@nongnu.org; Sun, 03 Sep 2023 01:04:28 -0400 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qcfHe-0001ly-Bb for qemu-devel@nongnu.org; Sun, 03 Sep 2023 01:04:28 -0400 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1c0bae4da38so2170425ad.0 for ; Sat, 02 Sep 2023 22:04:26 -0700 (PDT) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:78d2:b862:10a7:d486]) by smtp.gmail.com with ESMTPSA id l11-20020a170902f68b00b001b8af7f632asm5324835plg.176.2023.09.02.22.04.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Sep 2023 22:04:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1693717465; x=1694322265; 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=roTMe45HmgofN3+MiGETn4+wzF2HiB60U2BiLq2radc=; b=tND6qTCMIDzQsdW27MJYhvLI8mg0X7XN1IVwL15k6a3Lnbims3r1ct8AoV0LUhOI0a cNIvpDnBAmBHhAIWZsq9Pz7mMVRqsXWgsQPdV/N9BwH57XHuXF90nWHNtG80P8zawdby 9NhGT9d0pHPkdqz1LtG4hxwn9Jq2QdRX9aFXVxTjRqeBmel6RAwnztA6E3uxf3+f1gz2 h8XyjUU41x4cnhPhy2lMdVPu0vPN/zv6jqQd1EWQSodC1Cu68ckuqKe3tpNEBlwioDV+ T6v6KU4PbeeIfSiq72QGgLEtFKYzCTuDZmxTQGJKxnF+eSFvw4lnYlkhFc9eKx04CBUB F/dw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693717465; x=1694322265; 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=roTMe45HmgofN3+MiGETn4+wzF2HiB60U2BiLq2radc=; b=W31tszST706ZY7fvyT1rZ49xsbDlarMnSkfuppAHyjBDPlygqS2XEVdDtmq0ov8L6s U9CSPYXsDX+wYFfA5XKsdG7LiCZMV27CPxPxlqSIMrv+2oxReAgGjU1YLKIT0XIrNVJq gElJGzxX5GQFQnnz7njt7YKEo9GQWZvYx1kwPPNCuZVJHu4ONIYaK6uJ1wv6hZTAIRFW 7ozZVaEECty+khW9YmbwWUgkWXsmt1+QA6U+8bvA11JTLSSLwqPPVNWZAX4/yDgSvz0c m3KxDr2cTeNCGPZwQycVJFuNjZ1iUIGPdSmIFonChVbBMVXMnxRtpfS3CvyEB1YLXbED bBgg== X-Gm-Message-State: AOJu0YwFht7N5GPpDFKtWbUDcC6rVMOWC8ZIeR1rsP3l0DDE4NLK1IrB TLe/B5xnx64aIraPeTzd7gzo7T5BbAyZkme/H2s= X-Google-Smtp-Source: AGHT+IHl24W9GXfRGd9q78L1R+DJ2mv+sKQxx37+u9t5i0eRQgInPB7JZncCqOZBnf2Hg2ShkYp/JA== X-Received: by 2002:a17:903:110d:b0:1c1:e818:1e76 with SMTP id n13-20020a170903110d00b001c1e8181e76mr8603173plh.6.1693717464978; Sat, 02 Sep 2023 22:04:24 -0700 (PDT) From: Akihiko Odaki To: Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Mikhail Tyutin , Aleksandr Anenkov , qemu-devel@nongnu.org, Akihiko Odaki , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v6 13/18] gdbstub: Expose functions to read registers Date: Sun, 3 Sep 2023 14:03:21 +0900 Message-ID: <20230903050338.35256-14-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230903050338.35256-1-akihiko.odaki@daynix.com> References: <20230903050338.35256-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 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: none client-ip=2607:f8b0:4864:20::635; envelope-from=akihiko.odaki@daynix.com; helo=mail-pl1-x635.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1693717625402100003 Content-Type: text/plain; charset="utf-8" gdb_foreach_feature() enumerates features that are useful to identify registers. gdb_read_register() actually reads registers. Signed-off-by: Akihiko Odaki --- include/exec/gdbstub.h | 6 ++++++ gdbstub/gdbstub.c | 20 +++++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/include/exec/gdbstub.h b/include/exec/gdbstub.h index 5bfaaa0306..cb6b3b17bd 100644 --- a/include/exec/gdbstub.h +++ b/include/exec/gdbstub.h @@ -59,6 +59,12 @@ void gdb_feature_builder_end(const GDBFeatureBuilder *bu= ilder); =20 const GDBFeature *gdb_find_static_feature(const char *xmlname); =20 +void gdb_foreach_feature(CPUState *cpu, + void (* callback)(void *, const GDBFeature *, int= ), + void *opaque); + +int gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); + void gdb_set_stop_cpu(CPUState *cpu); =20 /* in gdbstub-xml.c, generated by scripts/feature_to_c.py */ diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index 9217fc7900..215d5d4fa5 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -483,7 +483,25 @@ const GDBFeature *gdb_find_static_feature(const char *= xmlname) g_assert_not_reached(); } =20 -static int gdb_read_register(CPUState *cpu, GByteArray *buf, int reg) +void gdb_foreach_feature(CPUState *cpu, + void (* callback)(void *, const GDBFeature *, int= ), + void *opaque) +{ + CPUClass *cc =3D CPU_GET_CLASS(cpu); + GDBRegisterState *r; + + if (!cc->gdb_core_feature) { + return; + } + + callback(opaque, cc->gdb_core_feature, 0); + + for (r =3D cpu->gdb_regs; r; r =3D r->next) { + callback(opaque, r->feature, r->base_reg); + } +} + +int gdb_read_register(CPUState *cpu, GByteArray *buf, int reg) { CPUClass *cc =3D CPU_GET_CLASS(cpu); CPUArchState *env =3D cpu->env_ptr; --=20 2.42.0