From: Akihiko Odaki <akihiko.odaki@daynix.com>
To: "Alex Bennée" <alex.bennee@linaro.org>
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
"Thomas Huth" <thuth@redhat.com>,
"Alexandre Iooss" <erdnaxe@crans.org>,
"Mahmoud Mandour" <ma.mandourr@gmail.com>,
"Eduardo Habkost" <eduardo@habkost.net>,
"Marcel Apfelbaum" <marcel.apfelbaum@gmail.com>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>,
"Yanan Wang" <wangyanan55@huawei.com>,
"Richard Henderson" <richard.henderson@linaro.org>,
"Marc-André Lureau" <marcandre.lureau@redhat.com>,
"Daniel P. Berrangé" <berrange@redhat.com>,
"John Snow" <jsnow@redhat.com>, "Cleber Rosa" <crosa@redhat.com>,
"Peter Maydell" <peter.maydell@linaro.org>,
"Michael Rolnik" <mrolnik@gmail.com>,
"Edgar E. Iglesias" <edgar.iglesias@gmail.com>,
"Brian Cain" <bcain@quicinc.com>,
"Song Gao" <gaosong@loongson.cn>,
"Xiaojuan Yang" <yangxiaojuan@loongson.cn>,
"Laurent Vivier" <laurent@vivier.eu>,
"Aurelien Jarno" <aurelien@aurel32.net>,
"Jiaxun Yang" <jiaxun.yang@flygoat.com>,
"Aleksandar Rikalo" <aleksandar.rikalo@syrmia.com>,
"Chris Wulff" <crwulff@gmail.com>, "Marek Vasut" <marex@denx.de>,
"Stafford Horne" <shorne@gmail.com>,
"Daniel Henrique Barboza" <danielhb413@gmail.com>,
"Cédric Le Goater" <clg@kaod.org>,
"David Gibson" <david@gibson.dropbear.id.au>,
"Greg Kurz" <groug@kaod.org>,
"Nicholas Piggin" <npiggin@gmail.com>,
"Palmer Dabbelt" <palmer@dabbelt.com>,
"Alistair Francis" <alistair.francis@wdc.com>,
"Bin Meng" <bin.meng@windriver.com>,
"Weiwei Li" <liweiwei@iscas.ac.cn>,
"Liu Zhiwei" <zhiwei_liu@linux.alibaba.com>,
"Yoshinori Sato" <ysato@users.sourceforge.jp>,
"David Hildenbrand" <david@redhat.com>,
"Ilya Leoshkevich" <iii@linux.ibm.com>,
"Mark Cave-Ayland" <mark.cave-ayland@ilande.co.uk>,
"Artyom Tarasenko" <atar4qemu@gmail.com>,
"Bastian Koppelmann" <kbastian@mail.uni-paderborn.de>,
"Max Filippov" <jcmvbkbc@gmail.com>,
qemu-devel@nongnu.org, qemu-arm@nongnu.org, qemu-ppc@nongnu.org,
qemu-riscv@nongnu.org, qemu-s390x@nongnu.org
Subject: Re: [RFC PATCH 15/24] target/arm: Fill new members of GDBFeature
Date: Wed, 16 Aug 2023 23:23:06 +0900 [thread overview]
Message-ID: <f41aae27-8538-46b5-93fa-67de41602077@daynix.com> (raw)
In-Reply-To: <87350lr7p8.fsf@linaro.org>
On 2023/08/14 23:56, Alex Bennée wrote:
>
> Akihiko Odaki <akihiko.odaki@daynix.com> writes:
>
>> These members will be used to help plugins to identify registers.
>>
>> Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
>> ---
>> target/arm/gdbstub.c | 46 +++++++++++++++++++++++++++---------------
>> target/arm/gdbstub64.c | 42 +++++++++++++++++++++++++-------------
>> 2 files changed, 58 insertions(+), 30 deletions(-)
>>
>> diff --git a/target/arm/gdbstub.c b/target/arm/gdbstub.c
>> index 100a6eed15..56d24028f6 100644
>> --- a/target/arm/gdbstub.c
>> +++ b/target/arm/gdbstub.c
>> @@ -270,6 +270,7 @@ static void arm_gen_one_feature_sysreg(GString *s,
>> g_string_append_printf(s, " regnum=\"%d\"", regnum);
>> g_string_append_printf(s, " group=\"cp_regs\"/>");
>> dyn_feature->data.cpregs.keys[dyn_feature->desc.num_regs] = ri_key;
>> + ((const char **)dyn_feature->desc.regs)[dyn_feature->desc.num_regs] = ri->name;
>> dyn_feature->desc.num_regs++;
>> }
>>
>> @@ -316,6 +317,8 @@ static GDBFeature *arm_gen_dynamic_sysreg_feature(CPUState *cs, int base_reg)
>> DynamicGDBFeatureInfo *dyn_feature = &cpu->dyn_sysreg_feature;
>> gsize num_regs = g_hash_table_size(cpu->cp_regs);
>>
>> + dyn_feature->desc.name = "org.qemu.gdb.arm.sys.regs";
>> + dyn_feature->desc.regs = g_new(const char *, num_regs);
>
> AIUI this means we now have an array of register names which mirrors the
> names embedded in the XML. This smells like a few steps away from just
> abstracting the whole XML away from the targets and generating them
> inside gdbstub when we need them. As per my stalled attempt I referenced
> earlier.
The abstraction is strictly limited for identifiers. Most plugin should
already have some knowledge of how registers are used. For example, a
plugin that tracks stack frame for RISC-V should know sp is the stack
pointer register. Similarly, a cycle simulator plugin should know how
registers are used in a program. Only identifiers matter in such cases.
I'm definitely *not* in favor of abstracting the whole XML for plugins.
It will be too hard to maintain ABI compatibility when a new attribute
emerges, for example.
>
>
>> dyn_feature->desc.num_regs = 0;
>> dyn_feature->data.cpregs.keys = g_new(uint32_t, num_regs);
>> g_string_printf(s, "<?xml version=\"1.0\"?>");
>> @@ -418,30 +421,34 @@ static int arm_gdb_set_m_systemreg(CPUARMState *env, uint8_t *buf, int reg)
>> }
>>
>> static GDBFeature *arm_gen_dynamic_m_systemreg_feature(CPUState *cs,
>> - int orig_base_reg)
>> + int base_reg)
>> {
>> ARMCPU *cpu = ARM_CPU(cs);
>> CPUARMState *env = &cpu->env;
>> GString *s = g_string_new(NULL);
>> - int base_reg = orig_base_reg;
>> - int i;
>> + const char **regs = g_new(const char *, ARRAY_SIZE(m_sysreg_def));
>> + int i = 0;
>> + int j;
>>
>> g_string_printf(s, "<?xml version=\"1.0\"?>");
>> g_string_append_printf(s, "<!DOCTYPE target SYSTEM \"gdb-target.dtd\">");
>> g_string_append_printf(s, "<feature name=\"org.gnu.gdb.arm.m-system\">\n");
>>
>> - for (i = 0; i < ARRAY_SIZE(m_sysreg_def); i++) {
>> - if (arm_feature(env, m_sysreg_def[i].feature)) {
>> + for (j = 0; j < ARRAY_SIZE(m_sysreg_def); j++) {
>> + if (arm_feature(env, m_sysreg_def[j].feature)) {
>> + regs[i] = m_sysreg_def[j].name;
>> g_string_append_printf(s,
>> "<reg name=\"%s\" bitsize=\"32\" regnum=\"%d\"/>\n",
>> - m_sysreg_def[i].name, base_reg++);
>> + m_sysreg_def[j].name, base_reg + i++);
>> }
>> }
>>
>> g_string_append_printf(s, "</feature>");
>> + cpu->dyn_m_systemreg_feature.desc.name = "org.gnu.gdb.arm.m-system";
>> cpu->dyn_m_systemreg_feature.desc.xmlname = "arm-m-system.xml";
>> cpu->dyn_m_systemreg_feature.desc.xml = g_string_free(s, false);
>> - cpu->dyn_m_systemreg_feature.desc.num_regs = base_reg - orig_base_reg;
>> + cpu->dyn_m_systemreg_feature.desc.regs = regs;
>> + cpu->dyn_m_systemreg_feature.desc.num_regs = i;
>>
>> return &cpu->dyn_m_systemreg_feature.desc;
>> }
>> @@ -462,30 +469,37 @@ static int arm_gdb_set_m_secextreg(CPUARMState *env, uint8_t *buf, int reg)
>> }
>>
>> static GDBFeature *arm_gen_dynamic_m_secextreg_feature(CPUState *cs,
>> - int orig_base_reg)
>> + int base_reg)
>> {
>> ARMCPU *cpu = ARM_CPU(cs);
>> GString *s = g_string_new(NULL);
>> - int base_reg = orig_base_reg;
>> - int i;
>> + const char **regs = g_new(const char *, ARRAY_SIZE(m_sysreg_def) * 2);
>> + int i = 0;
>> + int j;
>>
>> g_string_printf(s, "<?xml version=\"1.0\"?>");
>> g_string_append_printf(s, "<!DOCTYPE target SYSTEM \"gdb-target.dtd\">");
>> g_string_append_printf(s, "<feature name=\"org.gnu.gdb.arm.secext\">\n");
>>
>> - for (i = 0; i < ARRAY_SIZE(m_sysreg_def); i++) {
>> + for (j = 0; j < ARRAY_SIZE(m_sysreg_def); j++) {
>> + regs[i] = g_strconcat(m_sysreg_def[j].name, "_ns", NULL);
>> g_string_append_printf(s,
>> - "<reg name=\"%s_ns\" bitsize=\"32\" regnum=\"%d\"/>\n",
>> - m_sysreg_def[i].name, base_reg++);
>> + "<reg name=\"%s\" bitsize=\"32\" regnum=\"%d\"/>\n",
>> + regs[i], base_reg + i);
>> + i++;
>> + regs[i] = g_strconcat(m_sysreg_def[j].name, "_s", NULL);
>> g_string_append_printf(s,
>> - "<reg name=\"%s_s\" bitsize=\"32\" regnum=\"%d\"/>\n",
>> - m_sysreg_def[i].name, base_reg++);
>> + "<reg name=\"%s\" bitsize=\"32\" regnum=\"%d\"/>\n",
>> + regs[i], base_reg + i);
>> + i++;
>> }
>>
>> g_string_append_printf(s, "</feature>");
>> + cpu->dyn_m_secextreg_feature.desc.name = "org.gnu.gdb.arm.secext";
>> cpu->dyn_m_secextreg_feature.desc.xmlname = "arm-m-secext.xml";
>> cpu->dyn_m_secextreg_feature.desc.xml = g_string_free(s, false);
>> - cpu->dyn_m_secextreg_feature.desc.num_regs = base_reg - orig_base_reg;
>> + cpu->dyn_m_secextreg_feature.desc.regs = regs;
>> + cpu->dyn_m_secextreg_feature.desc.num_regs = i;
>>
>> return &cpu->dyn_m_secextreg_feature.desc;
>> }
>> diff --git a/target/arm/gdbstub64.c b/target/arm/gdbstub64.c
>> index 20483ef9bc..c5ed7c0aa3 100644
>> --- a/target/arm/gdbstub64.c
>> +++ b/target/arm/gdbstub64.c
>> @@ -316,15 +316,21 @@ static void output_vector_union_type(GString *s, int reg_width,
>> g_string_append(s, "</union>");
>> }
>>
>> -GDBFeature *arm_gen_dynamic_svereg_feature(CPUState *cs, int orig_base_reg)
>> +GDBFeature *arm_gen_dynamic_svereg_feature(CPUState *cs, int base_reg)
>> {
>> ARMCPU *cpu = ARM_CPU(cs);
>> GString *s = g_string_new(NULL);
>> DynamicGDBFeatureInfo *info = &cpu->dyn_svereg_feature;
>> + const char **regs;
>> int reg_width = cpu->sve_max_vq * 128;
>> int pred_width = cpu->sve_max_vq * 16;
>> - int base_reg = orig_base_reg;
>> - int i;
>> + int i = 0;
>> + int j;
>> +
>> + info->desc.name = "org.gnu.gdb.aarch64.sve";
>> + info->desc.num_regs = 32 + 16 + 4;
>> + regs = g_new(const char *, info->desc.num_regs);
>> + info->desc.regs = regs;
>>
>> g_string_printf(s, "<?xml version=\"1.0\"?>");
>> g_string_append_printf(s, "<!DOCTYPE target SYSTEM \"gdb-target.dtd\">");
>> @@ -339,44 +345,52 @@ GDBFeature *arm_gen_dynamic_svereg_feature(CPUState *cs, int orig_base_reg)
>> pred_width / 8);
>>
>> /* Define the vector registers. */
>> - for (i = 0; i < 32; i++) {
>> + for (j = 0; j < 32; j++) {
>> + regs[i] = g_strdup_printf("z%d", j);
>> g_string_append_printf(s,
>> - "<reg name=\"z%d\" bitsize=\"%d\""
>> + "<reg name=\"%s\" bitsize=\"%d\""
>> " regnum=\"%d\" type=\"svev\"/>",
>> - i, reg_width, base_reg++);
>> + regs[i], reg_width, base_reg + i);
>> + i++;
>> }
>>
>> /* fpscr & status registers */
>> + regs[i] = "fpsr";
>> g_string_append_printf(s, "<reg name=\"fpsr\" bitsize=\"32\""
>> " regnum=\"%d\" group=\"float\""
>> - " type=\"int\"/>", base_reg++);
>> + " type=\"int\"/>", base_reg + i++);
>> + regs[i] = "fpcr";
>> g_string_append_printf(s, "<reg name=\"fpcr\" bitsize=\"32\""
>> " regnum=\"%d\" group=\"float\""
>> - " type=\"int\"/>", base_reg++);
>> + " type=\"int\"/>", base_reg + i++);
>>
>> /* Define the predicate registers. */
>> - for (i = 0; i < 16; i++) {
>> + for (j = 0; j < 16; j++) {
>> + regs[i] = g_strdup_printf("p%d", j);
>> g_string_append_printf(s,
>> - "<reg name=\"p%d\" bitsize=\"%d\""
>> + "<reg name=\"%s\" bitsize=\"%d\""
>> " regnum=\"%d\" type=\"svep\"/>",
>> - i, pred_width, base_reg++);
>> + regs[i], pred_width, base_reg + i);
>> + i++;
>> }
>> + regs[i] = "ffr";
>> g_string_append_printf(s,
>> "<reg name=\"ffr\" bitsize=\"%d\""
>> " regnum=\"%d\" group=\"vector\""
>> " type=\"svep\"/>",
>> - pred_width, base_reg++);
>> + pred_width, base_reg + i++);
>>
>> /* Define the vector length pseudo-register. */
>> + regs[i] = "vg";
>> g_string_append_printf(s,
>> "<reg name=\"vg\" bitsize=\"64\""
>> " regnum=\"%d\" type=\"int\"/>",
>> - base_reg++);
>> + base_reg + i++);
>>
>> g_string_append_printf(s, "</feature>");
>>
>> info->desc.xmlname = "sve-registers.xml";
>> info->desc.xml = g_string_free(s, false);
>> - info->desc.num_regs = base_reg - orig_base_reg;
>> + assert(info->desc.num_regs == i);
>> return &info->desc;
>> }
>
>
next prev parent reply other threads:[~2023-08-16 14:24 UTC|newest]
Thread overview: 61+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-31 8:43 [RFC PATCH 00/24] plugins: Allow to read registers Akihiko Odaki
2023-07-31 8:43 ` [RFC PATCH 01/24] contrib/plugins: Use GRWLock in execlog Akihiko Odaki
2023-08-14 10:48 ` Alex Bennée
2023-07-31 8:43 ` [RFC PATCH 02/24] gdbstub: Introduce GDBFeature structure Akihiko Odaki
2023-07-31 13:34 ` Philippe Mathieu-Daudé
2023-07-31 13:51 ` Philippe Mathieu-Daudé
2023-08-14 11:33 ` Alex Bennée
2023-07-31 8:43 ` [RFC PATCH 03/24] gdbstub: Add num_regs member to GDBFeature Akihiko Odaki
2023-07-31 13:35 ` Philippe Mathieu-Daudé
2023-08-14 11:44 ` Alex Bennée
2023-07-31 8:43 ` [RFC PATCH 04/24] gdbstub: Introduce gdb_find_static_feature() Akihiko Odaki
2023-07-31 13:52 ` Philippe Mathieu-Daudé
2023-08-14 11:56 ` Alex Bennée
2023-07-31 8:43 ` [RFC PATCH 05/24] target/arm: Move the reference to arm-core.xml Akihiko Odaki
2023-07-31 8:43 ` [RFC PATCH 06/24] hw/core/cpu: Replace gdb_core_xml_file with gdb_core_feature Akihiko Odaki
2023-07-31 13:27 ` Philippe Mathieu-Daudé
2023-07-31 13:37 ` Akihiko Odaki
2023-08-14 11:59 ` Alex Bennée
2023-08-16 13:47 ` Akihiko Odaki
2023-08-16 15:00 ` Alex Bennée
2023-08-16 15:10 ` Akihiko Odaki
2023-08-14 13:19 ` Alex Bennée
2023-07-31 8:43 ` [RFC PATCH 07/24] target/arm: Use GDBFeature for dynamic XML Akihiko Odaki
2023-07-31 13:44 ` Philippe Mathieu-Daudé
2023-07-31 14:00 ` Akihiko Odaki
2023-08-14 13:01 ` Alex Bennée
2023-07-31 8:43 ` [RFC PATCH 08/24] target/ppc: " Akihiko Odaki
2023-07-31 13:45 ` Philippe Mathieu-Daudé
2023-07-31 8:43 ` [RFC PATCH 09/24] target/riscv: " Akihiko Odaki
2023-07-31 13:46 ` Philippe Mathieu-Daudé
2023-07-31 8:43 ` [RFC PATCH 10/24] gdbstub: Use GDBFeature for gdb_register_coprocessor Akihiko Odaki
2023-08-14 13:13 ` Alex Bennée
2023-07-31 8:43 ` [RFC PATCH 11/24] gdbstub: Use GDBFeature for GDBRegisterState Akihiko Odaki
2023-07-31 8:43 ` [RFC PATCH 12/24] gdbstub: Simplify XML lookup Akihiko Odaki
2023-08-14 13:27 ` Alex Bennée
2023-08-16 13:51 ` Akihiko Odaki
2023-07-31 8:43 ` [RFC PATCH 13/24] hw/core/cpu: Remove gdb_get_dynamic_xml member Akihiko Odaki
2023-08-14 13:29 ` Alex Bennée
2023-07-31 8:43 ` [RFC PATCH 14/24] gdbstub: Add members to identify registers to GDBFeature Akihiko Odaki
2023-08-14 13:30 ` Alex Bennée
2023-07-31 8:43 ` [RFC PATCH 15/24] target/arm: Fill new members of GDBFeature Akihiko Odaki
2023-08-14 14:56 ` Alex Bennée
2023-08-16 14:23 ` Akihiko Odaki [this message]
2023-08-16 15:03 ` Alex Bennée
2023-08-16 15:11 ` Akihiko Odaki
2023-07-31 8:43 ` [RFC PATCH 16/24] target/ppc: " Akihiko Odaki
2023-07-31 8:43 ` [RFC PATCH 17/24] target/riscv: " Akihiko Odaki
2023-07-31 8:43 ` [RFC PATCH 18/24] hw/core/cpu: Add a parameter to gdb_read_register/gdb_write_register Akihiko Odaki
2023-07-31 8:43 ` [RFC PATCH 19/24] gdbstub: Hide gdb_has_xml Akihiko Odaki
2023-07-31 8:43 ` [RFC PATCH 20/24] gdbstub: Expose functions to read registers Akihiko Odaki
2023-07-31 8:43 ` [RFC PATCH 21/24] plugins: Allow " Akihiko Odaki
2023-08-14 15:05 ` Alex Bennée
2023-08-16 14:38 ` Akihiko Odaki
2023-07-31 8:43 ` [RFC PATCH 22/24] contrib/plugins: Allow to log registers Akihiko Odaki
2023-08-14 15:21 ` Alex Bennée
2023-08-16 14:59 ` Akihiko Odaki
2023-07-31 8:43 ` [RFC PATCH 23/24] plugins: Support C++ Akihiko Odaki
2023-07-31 8:43 ` [RFC PATCH 24/24] contrib/plugins: Add cc plugin Akihiko Odaki
2023-08-14 15:23 ` Alex Bennée
2023-08-16 15:04 ` Akihiko Odaki
2023-08-14 15:27 ` [RFC PATCH 00/24] plugins: Allow to read registers Alex Bennée
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f41aae27-8538-46b5-93fa-67de41602077@daynix.com \
--to=akihiko.odaki@daynix.com \
--cc=aleksandar.rikalo@syrmia.com \
--cc=alex.bennee@linaro.org \
--cc=alistair.francis@wdc.com \
--cc=atar4qemu@gmail.com \
--cc=aurelien@aurel32.net \
--cc=bcain@quicinc.com \
--cc=berrange@redhat.com \
--cc=bin.meng@windriver.com \
--cc=clg@kaod.org \
--cc=crosa@redhat.com \
--cc=crwulff@gmail.com \
--cc=danielhb413@gmail.com \
--cc=david@gibson.dropbear.id.au \
--cc=david@redhat.com \
--cc=edgar.iglesias@gmail.com \
--cc=eduardo@habkost.net \
--cc=erdnaxe@crans.org \
--cc=gaosong@loongson.cn \
--cc=groug@kaod.org \
--cc=iii@linux.ibm.com \
--cc=jcmvbkbc@gmail.com \
--cc=jiaxun.yang@flygoat.com \
--cc=jsnow@redhat.com \
--cc=kbastian@mail.uni-paderborn.de \
--cc=laurent@vivier.eu \
--cc=liweiwei@iscas.ac.cn \
--cc=ma.mandourr@gmail.com \
--cc=marcandre.lureau@redhat.com \
--cc=marcel.apfelbaum@gmail.com \
--cc=marex@denx.de \
--cc=mark.cave-ayland@ilande.co.uk \
--cc=mrolnik@gmail.com \
--cc=npiggin@gmail.com \
--cc=palmer@dabbelt.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=philmd@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=qemu-riscv@nongnu.org \
--cc=qemu-s390x@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=shorne@gmail.com \
--cc=thuth@redhat.com \
--cc=wangyanan55@huawei.com \
--cc=yangxiaojuan@loongson.cn \
--cc=ysato@users.sourceforge.jp \
--cc=zhiwei_liu@linux.alibaba.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).