Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Shahab Vahedi <shahab.vahedi@gmail.com>
To: Simon Marchi <simark@simark.ca>
Cc: gdb-patches@sourceware.org, Shahab Vahedi <shahab@synopsys.com>,
	Tom Tromey <tom@tromey.com>,
	Anton Kolesov <anton.kolesov@synopsys.com>,
	Francois Bedard <fbedard@synopsys.com>
Subject: Re: [PATCH v3 1/3] arc: Add ARCv2 XML target along with refactoring
Date: Wed, 22 Jul 2020 16:33:45 +0200	[thread overview]
Message-ID: <20200722143345.GC10630@gmail.com> (raw)
In-Reply-To: <0731a886-0896-0776-11a9-94f44810eb75@simark.ca>

On Wed, Jul 22, 2020 at 09:49:48AM -0400, Simon Marchi wrote:
> On 2020-07-22 9:36 a.m., Shahab Vahedi wrote:
> > On Thu, Jul 16, 2020 at 09:28:50AM -0400, Simon Marchi wrote:
> >> On 2020-07-15 4:35 p.m., Shahab Vahedi wrote:
> >> When I search for `arc_gdbarch_features_init` in that patch I don't find anything...
> > 
> > You're correct. I have it in my local branch. The patch that uses it is going
> > to be submitted very soon. I hope you don't mind if it remains like this.
> 
> Let's just make it static in this patch, and make in non-static again in your future
> patch, it's not a big change.

Will do.
> 
> >> The code in GDB constructing an arc_gdbarch_features will use the BFD to determine
> >> these two values, whereas the code in GDBserver will use something else (usually
> >> looking at the current process' properties).
> >>
> >> In fact, the constructor is optional, you could just build a arc_gdbarch_features
> >> using aggregate initialization and return it from that function:
> >>
> >>   arc_gdbarch_features features {reg_size, isa};
> >>
> >> It doesn't really matter.  I just happen to prefer the constructor method, because
> >> that makes it so you can't "forget" a field and it ensures it can never be in an
> >> uninitialized state.
> > 
> > I see now. Actually, I have usecases to not initialize it immediately,
> > but in a few lines of code.
> 
> I'd be curious to see.  Because instead of declaring it immediately, you can keep
> the fields separate until you initialize it:
> 
>   int reg_size;
>   enum arc_isa isa;
> 
>   if (something)
>     {
>       reg_size = 8;
>       isa = foo;
>     }
>   else
>     {
>       reg_size = 4;
>       isa = bar;
>     }
> 
>   arc_gdbarch_features features (reg_size, isa);
> 
> I think this is good, because the day you add a third axis to arc_gdbarch_features,
> that code will not build and you'll be forced to updated it (you can't forget it).
> 
> Whereas with:
> 
>   arc_gdbarch_features features;
> 
>   if (something)
>     {
>       features.reg_size = 8;
>       features.isa = foo;
>     }
>   else
>     {
>       features.reg_size = 4;
>       features.isa = bar;
>     }
> 
> It's possible to forget.
> 
> But maybe you have a different use case in mind?

These are the 2 usecases I have:

gdb/arc-tdep.c
--------------
static bool
arc_tdesc_init (struct gdbarch_info info, ...)
{
  const struct target_desc *tdesc_loc = info.target_desc;

  if (!tdesc_has_registers (tdesc_loc))
    {
      arc_gdbarch_features features;
      arc_gdbarch_features_init (features, info.abfd,
                                 info.bfd_arch_info->mach);
      tdesc_loc = arc_lookup_target_description (features);
    }
  ...
}

gdb/arc-linux-tdep.c
--------------------
static const struct target_desc *
arc_linux_core_read_description (struct gdbarch *gdbarch,
                                 struct target_ops *target,
                                 bfd *abfd)
{
  arc_gdbarch_features features;
  arc_gdbarch_features_init (features, abfd,
           gdbarch_bfd_arch_info (gdbarch)->mach);
  return arc_lookup_target_description (features);
}

While I totally understand your point, I don't want to unroll the
logic of "arc_gdbarch_features_init ()" to the same level that
"features" is declared. Ideally, I should have a constructor
with the same signature as "arc_gdbarch_features_init ()", but
that is not possible because compilation of gdbserver will go
awry when there is mention of ELF data in "gdb/arch/arc.h".

To have a complete overview, in a soon-to-be-submitted patch
you're going to see that "features" is initialized like:

gdbserver/linux-arc-low.cc
--------------------------
static const struct target_desc *
arc_linux_read_description (void)
{
  struct target_desc *tdesc;
  arc_gdbarch_features features = {4, ARC_ISA_NONE};
#ifdef __ARC700__
  features.isa = ARC_ISA_ARCV1;
#else
  features.isa = ARC_ISA_ARCV2;
#endif
  tdesc = arc_create_target_description (features);
  ...
}

Cheers,
Shahab


  reply	other threads:[~2020-07-22 14:33 UTC|newest]

Thread overview: 86+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-26 12:52 [PATCH 0/4] arc: Add GNU/Linux support Shahab Vahedi
2020-03-26 12:52 ` [PATCH 1/4] arc: Add XML target features for Linux targets Shahab Vahedi
2020-04-24 13:46   ` Tom Tromey
2020-03-26 12:52 ` [PATCH 2/4] arc: Recognize registers available on " Shahab Vahedi
2020-04-24 13:50   ` Tom Tromey
2020-03-26 12:52 ` [PATCH 3/4] arc: Add GNU/Linux support for ARC Shahab Vahedi
2020-04-24 14:00   ` Tom Tromey
2020-03-26 12:52 ` [PATCH 4/4] arc: Add arc-*-linux regformats Shahab Vahedi
2020-04-24 14:01   ` Tom Tromey
2020-04-06  9:13 ` [PING][PATCH 0/4] arc: Add GNU/Linux support Shahab Vahedi
2020-04-20 16:51 ` [PING^2][PATCH " Shahab Vahedi
2020-04-28 16:04 ` [PATCH v2 " Shahab Vahedi
2020-04-28 16:04   ` [PATCH v2 1/4] arc: Add XML target features for Linux targets Shahab Vahedi
2020-05-14 14:49     ` Simon Marchi
2020-04-28 16:04   ` [PATCH v2 2/4] arc: Recognize registers available on " Shahab Vahedi
2020-04-28 16:56     ` Eli Zaretskii
2020-05-14 15:01     ` Simon Marchi
2020-06-17 15:46       ` Shahab Vahedi
2020-07-13 15:48         ` Simon Marchi
2020-07-14  9:05           ` Shahab Vahedi
2020-04-28 16:04   ` [PATCH v2 3/4] arc: Add GNU/Linux support for ARC Shahab Vahedi
2020-05-14 15:09     ` Simon Marchi
2020-06-15 23:13       ` Shahab Vahedi
2020-06-16  0:58         ` Simon Marchi
2020-04-28 16:04   ` [PATCH v2 4/4] arc: Add arc-*-linux regformats Shahab Vahedi
2020-05-14 15:12     ` Simon Marchi
2020-06-15 23:37       ` Shahab Vahedi
2020-06-16  2:08         ` Simon Marchi
2020-05-14 11:43   ` [PATCH v2 0/4] arc: Add GNU/Linux support Shahab Vahedi
2020-07-13 15:45   ` [PATCH v3 0/3] " Shahab Vahedi
2020-07-13 15:45     ` [PATCH v3 1/3] arc: Add ARCv2 XML target along with refactoring Shahab Vahedi
2020-07-15  2:52       ` Simon Marchi
2020-07-15 20:35         ` Shahab Vahedi
2020-07-15 21:23           ` Christian Biesinger
2020-07-16  1:59             ` Simon Marchi
2020-07-16 13:28           ` Simon Marchi
2020-07-22 13:36             ` Shahab Vahedi
2020-07-22 13:49               ` Simon Marchi
2020-07-22 14:33                 ` Shahab Vahedi [this message]
2020-07-22 14:54                   ` Simon Marchi
2020-07-13 15:45     ` [PATCH v3 2/3] arc: Add hardware loop detection Shahab Vahedi
2020-07-15  2:55       ` Simon Marchi
2020-07-13 15:45     ` [PATCH v3 3/3] arc: Add GNU/Linux support for ARC Shahab Vahedi
2020-07-15  3:03       ` Simon Marchi
2020-07-23 19:35     ` [PATCH v4 0/3] arc: Add GNU/Linux support Shahab Vahedi
2020-07-23 19:35       ` [PATCH v4 1/3] arc: Add ARCv2 XML target along with refactoring Shahab Vahedi
2020-07-30 23:34         ` Simon Marchi
2020-07-23 19:35       ` [PATCH v4 2/3] arc: Add hardware loop detection Shahab Vahedi
2020-08-01 14:53         ` Simon Marchi
2020-07-23 19:35       ` [PATCH v4 3/3] arc: Add GNU/Linux support for ARC Shahab Vahedi
2020-08-01 15:01         ` Simon Marchi
2020-08-01 23:31       ` [PATCH v4 0/3] arc: Add GNU/Linux support Simon Marchi
2020-08-04  7:59         ` Shahab Vahedi
2020-08-04 12:42           ` Simon Marchi
2020-08-04  8:57 ` [PATCH v5 0/4] " Shahab Vahedi
2020-08-04  8:57   ` [PATCH v5 1/4] arc: Add ARCv2 XML target along with refactoring Shahab Vahedi
2020-08-04 13:08     ` Simon Marchi
2020-08-04 13:18       ` Shahab Vahedi
2020-08-04 13:20         ` Simon Marchi
2020-08-04 14:12           ` Shahab Vahedi
2020-08-04  8:57   ` [PATCH v5 2/4] arc: Add inclusion of "gdbarch.h" in "arc-tdep.h" Shahab Vahedi
2020-08-04  8:57   ` [PATCH v5 3/4] arc: Add hardware loop detection Shahab Vahedi
2020-08-04 14:28     ` Eli Zaretskii
2020-08-04 16:17       ` Shahab Vahedi
2020-08-04 16:42         ` Eli Zaretskii
2020-08-04 18:15           ` Shahab Vahedi
2020-08-04  8:57   ` [PATCH v5 4/4] arc: Add GNU/Linux support for ARC Shahab Vahedi
2020-08-04 12:49   ` [PATCH v5 0/4] arc: Add GNU/Linux support Simon Marchi
2020-08-04 13:05     ` Shahab Vahedi
2020-08-05 11:09 ` [PATCH v6 " Shahab Vahedi
2020-08-05 11:09   ` [PATCH v6 1/4] arc: Add ARCv2 XML target along with refactoring Shahab Vahedi
2020-08-05 14:31     ` Eli Zaretskii
2020-08-21 16:16     ` Simon Marchi
2020-08-24 20:14       ` Shahab Vahedi
2020-08-05 11:09   ` [PATCH v6 2/4] arc: Add inclusion of "gdbarch.h" in "arc-tdep.h" Shahab Vahedi
2020-08-05 11:09   ` [PATCH v6 3/4] arc: Add hardware loop detection Shahab Vahedi
2020-08-05 11:09   ` [PATCH v6 4/4] arc: Add GNU/Linux support for ARC Shahab Vahedi
2020-08-17  8:07   ` [PATCH v6 0/4] arc: Add GNU/Linux support Shahab Vahedi
2020-08-17 14:12     ` Eli Zaretskii
2020-08-25 15:47 ` [PUSHED " Shahab Vahedi
2020-08-25 15:47   ` [PUSHED 1/4] arc: Add ARCv2 XML target along with refactoring Shahab Vahedi
2020-08-25 16:00     ` Eli Zaretskii
2020-08-25 15:47   ` [PUSHED 2/4] arc: Add inclusion of "gdbarch.h" in "arc-tdep.h" Shahab Vahedi
2020-08-25 15:47   ` [PUSHED 3/4] arc: Add hardware loop detection Shahab Vahedi
2020-08-25 15:58     ` Eli Zaretskii
2020-08-25 15:47   ` [PUSHED 4/4] arc: Add GNU/Linux support for ARC Shahab Vahedi

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=20200722143345.GC10630@gmail.com \
    --to=shahab.vahedi@gmail.com \
    --cc=anton.kolesov@synopsys.com \
    --cc=fbedard@synopsys.com \
    --cc=gdb-patches@sourceware.org \
    --cc=shahab@synopsys.com \
    --cc=simark@simark.ca \
    --cc=tom@tromey.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