qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Alex Bennée" <alex.bennee@linaro.org>
To: Akihiko Odaki <akihiko.odaki@daynix.com>
Cc: "Mikhail Tyutin" <m.tyutin@yadro.com>,
	"Aleksandr Anenkov" <a.anenkov@yadro.com>,
	qemu-devel@nongnu.org,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>
Subject: Re: [PATCH RESEND v5 12/26] gdbstub: Use GDBFeature for GDBRegisterState
Date: Wed, 30 Aug 2023 15:59:21 +0100	[thread overview]
Message-ID: <87v8cwr2x2.fsf@linaro.org> (raw)
In-Reply-To: <20230818033648.8326-13-akihiko.odaki@daynix.com>


Akihiko Odaki <akihiko.odaki@daynix.com> writes:

> Simplify GDBRegisterState by replacing num_regs and xml members with
> one member that points to GDBFeature.
>
> Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
> ---
>  gdbstub/gdbstub.c | 14 ++++++--------
>  1 file changed, 6 insertions(+), 8 deletions(-)
>
> diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c
> index b62002bc34..ee6b8b98c8 100644
> --- a/gdbstub/gdbstub.c
> +++ b/gdbstub/gdbstub.c
> @@ -47,10 +47,9 @@
>  
>  typedef struct GDBRegisterState {
>      int base_reg;
> -    int num_regs;
>      gdb_get_reg_cb get_reg;
>      gdb_set_reg_cb set_reg;
> -    const char *xml;
> +    const GDBFeature *feature;
>      struct GDBRegisterState *next;
>  } GDBRegisterState;
>  
> @@ -390,7 +389,7 @@ static const char *get_feature_xml(const char *p, const char **newp,
>              pstrcat(buf, buf_sz, "\"/>");
>              for (r = cpu->gdb_regs; r; r = r->next) {
>                  pstrcat(buf, buf_sz, "<xi:include href=\"");
> -                pstrcat(buf, buf_sz, r->xml);
> +                pstrcat(buf, buf_sz, r->feature->xmlname);
>                  pstrcat(buf, buf_sz, "\"/>");
>              }

I should note I've done some cleaning up of the XML code in the gdbstub
so you'll probably want to re-base once the PR has gone in.


>              pstrcat(buf, buf_sz, "</target>");
> @@ -497,7 +496,7 @@ static int gdb_read_register(CPUState *cpu, GByteArray *buf, int reg)
>      }
>  
>      for (r = cpu->gdb_regs; r; r = r->next) {
> -        if (r->base_reg <= reg && reg < r->base_reg + r->num_regs) {
> +        if (r->base_reg <= reg && reg < r->base_reg + r->feature->num_regs) {
>              return r->get_reg(env, buf, reg - r->base_reg);
>          }
>      }
> @@ -515,7 +514,7 @@ static int gdb_write_register(CPUState *cpu, uint8_t *mem_buf, int reg)
>      }
>  
>      for (r = cpu->gdb_regs; r; r = r->next) {
> -        if (r->base_reg <= reg && reg < r->base_reg + r->num_regs) {
> +        if (r->base_reg <= reg && reg < r->base_reg + r->feature->num_regs) {
>              return r->set_reg(env, mem_buf, reg - r->base_reg);
>          }
>      }
> @@ -538,17 +537,16 @@ void gdb_register_coprocessor(CPUState *cpu,
>      p = &cpu->gdb_regs;
>      while (*p) {
>          /* Check for duplicates.  */
> -        if (strcmp((*p)->xml, feature->xmlname) == 0)
> +        if ((*p)->feature == feature)
>              return;
>          p = &(*p)->next;
>      }
>  
>      s = g_new0(GDBRegisterState, 1);
>      s->base_reg = cpu->gdb_num_regs;
> -    s->num_regs = feature->num_regs;
>      s->get_reg = get_reg;
>      s->set_reg = set_reg;
> -    s->xml = feature->xml;
> +    s->feature = feature;
>  
>      /* Add to end of list.  */
>      cpu->gdb_num_regs += feature->num_regs;

Otherwise:

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>

-- 
Alex Bennée
Virtualisation Tech Lead @ Linaro


  reply	other threads:[~2023-08-30 15:00 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-18  3:36 [PATCH RESEND v5 00/26] plugins: Allow to read registers Akihiko Odaki
2023-08-18  3:36 ` [PATCH RESEND v5 01/26] contrib/plugins: Use GRWLock in execlog Akihiko Odaki
2023-08-18  3:36 ` [PATCH RESEND v5 02/26] gdbstub: Introduce GDBFeature structure Akihiko Odaki
2023-08-18  3:36 ` [PATCH RESEND v5 03/26] gdbstub: Add num_regs member to GDBFeature Akihiko Odaki
2023-08-18  3:36 ` [PATCH RESEND v5 04/26] gdbstub: Introduce gdb_find_static_feature() Akihiko Odaki
2023-08-18  3:36 ` [PATCH RESEND v5 05/26] target/arm: Move the reference to arm-core.xml Akihiko Odaki
2023-08-18  3:36 ` [PATCH RESEND v5 06/26] hw/core/cpu: Replace gdb_core_xml_file with gdb_core_feature Akihiko Odaki
2023-08-18  3:36 ` [PATCH RESEND v5 07/26] gdbstub: Introduce GDBFeatureBuilder Akihiko Odaki
2023-08-18  3:36 ` [PATCH RESEND v5 08/26] target/arm: Use GDBFeature for dynamic XML Akihiko Odaki
2023-08-18  3:36 ` [PATCH RESEND v5 09/26] target/ppc: " Akihiko Odaki
2023-08-18  3:36 ` [PATCH RESEND v5 10/26] target/riscv: " Akihiko Odaki
2023-08-18  3:36 ` [PATCH RESEND v5 11/26] gdbstub: Use GDBFeature for gdb_register_coprocessor Akihiko Odaki
2023-08-18  3:36 ` [PATCH RESEND v5 12/26] gdbstub: Use GDBFeature for GDBRegisterState Akihiko Odaki
2023-08-30 14:59   ` Alex Bennée [this message]
2023-08-18  3:36 ` [PATCH RESEND v5 13/26] hw/core/cpu: Return static value with gdb_arch_name() Akihiko Odaki
2023-08-30 15:00   ` Alex Bennée
2023-08-18  3:36 ` [PATCH RESEND v5 14/26] gdbstub: Dynamically allocate target.xml buffer Akihiko Odaki
2023-08-18  3:36 ` [PATCH RESEND v5 15/26] gdbstub: Simplify XML lookup Akihiko Odaki
2023-08-18  3:36 ` [PATCH RESEND v5 16/26] hw/core/cpu: Remove gdb_get_dynamic_xml member Akihiko Odaki
2023-08-18  3:36 ` [PATCH RESEND v5 17/26] gdbstub: Add members to identify registers to GDBFeature Akihiko Odaki
2023-08-18  3:36 ` [PATCH RESEND v5 18/26] target/arm: Remove references to gdb_has_xml Akihiko Odaki
2023-08-30 15:02   ` Alex Bennée
2023-08-18  3:36 ` [PATCH RESEND v5 19/26] target/ppc: " Akihiko Odaki
2023-08-25  9:40   ` Nicholas Piggin
2023-08-18  3:36 ` [PATCH RESEND v5 20/26] gdbstub: Remove gdb_has_xml variable Akihiko Odaki
2023-08-30 15:02   ` Alex Bennée
2023-08-30 20:24     ` Akihiko Odaki
2023-08-18  3:36 ` [PATCH RESEND v5 21/26] gdbstub: Expose functions to read registers Akihiko Odaki
2023-08-18  3:36 ` [PATCH RESEND v5 22/26] cpu: Call plugin hooks only when ready Akihiko Odaki
2023-08-30 15:04   ` Alex Bennée
2023-08-18  3:36 ` [PATCH RESEND v5 23/26] plugins: Allow to read registers Akihiko Odaki
2023-08-18  3:36 ` [PATCH RESEND v5 24/26] contrib/plugins: Allow to log registers Akihiko Odaki
2023-08-30 15:08   ` Alex Bennée
2023-08-30 20:53     ` Akihiko Odaki
2023-09-04 15:30       ` Alex Bennée
2023-09-05  6:51         ` Akihiko Odaki
2023-08-18  3:36 ` [PATCH RESEND v5 25/26] plugins: Support C++ Akihiko Odaki
2023-08-18  3:36 ` [PATCH RESEND v5 26/26] contrib/plugins: Add cc plugin Akihiko Odaki

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=87v8cwr2x2.fsf@linaro.org \
    --to=alex.bennee@linaro.org \
    --cc=a.anenkov@yadro.com \
    --cc=akihiko.odaki@daynix.com \
    --cc=m.tyutin@yadro.com \
    --cc=philmd@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /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).