public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH, rs6000] Add ppc64*_gnu_triplet_regexp methods.
@ 2021-07-27 15:36 will schmidt
  2021-07-28 22:04 ` Lancelot SIX
  2021-07-29 19:42 ` Tom Tromey
  0 siblings, 2 replies; 6+ messages in thread
From: will schmidt @ 2021-07-27 15:36 UTC (permalink / raw)
  To: gdb-patches; +Cc: Ulrich Weigand, Alan Modra, rogerio, Carl E. Love

[PATCH, rs6000] Add ppc64*_gnu_triplet_regexp methods.
    
Hi,
  Add methods to set the target triplet so we can
find the proper gcc when our gcc is named of
the form powerpc64{le}-<foo>-gcc or ppc64{le}-<foo>-gcc.

This helps allow the gdb-compile support to function
for the powerpc targets.

OK for trunk?
Thanks
-Will

gdb/Changelog:
yyyy-mm-dd  Will Schmidt  <will_schmidt@vnet.ibm.com>

	* gdb/ppc-linux-tdep.c (ppc64le_gnu_triplet_regexp): New
	function to set triplet.
	(ppc64_gnu_triplet_regexp): Same.
	(ppc_linux_init_abi): Conditionally call to set the
	ppc64 or ppc64le triplets.

diff --git a/gdb/ppc-linux-tdep.c b/gdb/ppc-linux-tdep.c
index 1e94922f25a..de3e026a72b 100644
--- a/gdb/ppc-linux-tdep.c
+++ b/gdb/ppc-linux-tdep.c
@@ -1971,10 +1971,34 @@ ppc_floatformat_for_type (struct gdbarch *gdbarch,
     }
 
   return default_floatformat_for_type (gdbarch, name, len);
 }
 
+/* Specify the powerpc64le target triplet.
+   This can be variations of
+	ppc64le-{distro}-linux-gcc
+   and
+	powerpc64le-{distro}-linux-gcc
+   */
+static const char *
+ppc64le_gnu_triplet_regexp (struct gdbarch *gdbarch)
+{
+        return "p(ower)*pc64le?";
+}
+
+/* Specify the powerpc64 target triplet.
+   This can be variations of
+	ppc64-{distro}-linux-gcc
+   and
+	powerpc64-{distro}-linux-gcc
+   */
+static const char *
+ppc64_gnu_triplet_regexp (struct gdbarch *gdbarch)
+{
+        return "p(ower)*pc64?";
+}
+
 static void
 ppc_linux_init_abi (struct gdbarch_info info,
 		    struct gdbarch *gdbarch)
 {
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
@@ -2101,10 +2125,15 @@ ppc_linux_init_abi (struct gdbarch_info info,
       /* BFD target for core files.  */
       if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_LITTLE)
 	set_gdbarch_gcore_bfd_target (gdbarch, "elf64-powerpcle");
       else
 	set_gdbarch_gcore_bfd_target (gdbarch, "elf64-powerpc");
+     /* Set compiler triplet.  */
+      if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_LITTLE)
+          set_gdbarch_gnu_triplet_regexp (gdbarch, ppc64le_gnu_triplet_regexp);
+      else
+          set_gdbarch_gnu_triplet_regexp (gdbarch, ppc64_gnu_triplet_regexp);
     }
 
   set_gdbarch_core_read_description (gdbarch, ppc_linux_core_read_description);
   set_gdbarch_iterate_over_regset_sections (gdbarch,
 					    ppc_linux_iterate_over_regset_sections);


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH, rs6000] Add ppc64*_gnu_triplet_regexp methods.
  2021-07-27 15:36 [PATCH, rs6000] Add ppc64*_gnu_triplet_regexp methods will schmidt
@ 2021-07-28 22:04 ` Lancelot SIX
  2021-07-29 19:42 ` Tom Tromey
  1 sibling, 0 replies; 6+ messages in thread
From: Lancelot SIX @ 2021-07-28 22:04 UTC (permalink / raw)
  To: will schmidt; +Cc: gdb-patches, Ulrich Weigand, rogerio, Alan Modra

> +/* Specify the powerpc64le target triplet.
> +   This can be variations of
> +	ppc64le-{distro}-linux-gcc
> +   and
> +	powerpc64le-{distro}-linux-gcc
> +   */
> +static const char *
> +ppc64le_gnu_triplet_regexp (struct gdbarch *gdbarch)
> +{
> +        return "p(ower)*pc64le?";
> +}
> +
> +/* Specify the powerpc64 target triplet.
> +   This can be variations of
> +	ppc64-{distro}-linux-gcc
> +   and
> +	powerpc64-{distro}-linux-gcc
> +   */
> +static const char *
> +ppc64_gnu_triplet_regexp (struct gdbarch *gdbarch)
> +{
> +        return "p(ower)*pc64?";
> +}
> +

Hi,

It looks like that the first '*' in both of your regex says that 'ower'
can be matched any number of time.  With this, something like
'powerowerpc64' will match.  You should replace them with '?' (which
stands for “match 0 or 1 time”).

Also, the last '?' of your says that the last char is optional, and
should probably be removed.

With that given into account, I think your patterns should look
something like:

- "p(ower)?pc64le"
- "p(ower)?pc64"

I think that a '-' is appended right after this so there should not be
an issue with the second pattern matching for 'ppc64le'.  If there is an
issue here, it should be possible to append '(?!l)' (which means “not
followed by a 'l'”), but I am not sure if this is supported by the regex
library used by GDB.

(I have not tested those, but they should work with pretty much any
regex library).

Best,
Lancelot.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH, rs6000] Add ppc64*_gnu_triplet_regexp methods.
  2021-07-27 15:36 [PATCH, rs6000] Add ppc64*_gnu_triplet_regexp methods will schmidt
  2021-07-28 22:04 ` Lancelot SIX
@ 2021-07-29 19:42 ` Tom Tromey
  2021-08-03 18:35   ` will schmidt
  2021-08-05 20:43   ` [PATCH, rs6000] [V2] " will schmidt
  1 sibling, 2 replies; 6+ messages in thread
From: Tom Tromey @ 2021-07-29 19:42 UTC (permalink / raw)
  To: will schmidt via Gdb-patches
  Cc: will schmidt, Ulrich Weigand, rogerio, Alan Modra

>>>>> ">" == will schmidt via Gdb-patches <gdb-patches@sourceware.org> writes:

>> [PATCH, rs6000] Add ppc64*_gnu_triplet_regexp methods.
>> Hi,
>>   Add methods to set the target triplet so we can
>> find the proper gcc when our gcc is named of
>> the form powerpc64{le}-<foo>-gcc or ppc64{le}-<foo>-gcc.

Hi.  Thank you for the patch.
I have a few nits, nothing too serious.

>> gdb/Changelog:
>> yyyy-mm-dd  Will Schmidt  <will_schmidt@vnet.ibm.com>

>> 	* gdb/ppc-linux-tdep.c (ppc64le_gnu_triplet_regexp): New
>> 	function to set triplet.
>> 	(ppc64_gnu_triplet_regexp): Same.
>> 	(ppc_linux_init_abi): Conditionally call to set the
>> 	ppc64 or ppc64le triplets.

ChangeLog entries aren't needed any more.

>> +static const char *
>> +ppc64le_gnu_triplet_regexp (struct gdbarch *gdbarch)
>> +{
>> +        return "p(ower)*pc64le?";

Indentation looks off.
Also I would use "?" rather than "*" in this regexp.
And, is the "e" really optional?  Seems a bit weird.

>> +static const char *
>> +ppc64_gnu_triplet_regexp (struct gdbarch *gdbarch)
>> +{
>> +        return "p(ower)*pc64?";

Same comments.

>> +     /* Set compiler triplet.  */
>> +      if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_LITTLE)
>> +          set_gdbarch_gnu_triplet_regexp (gdbarch, ppc64le_gnu_triplet_regexp);
>> +      else
>> +          set_gdbarch_gnu_triplet_regexp (gdbarch, ppc64_gnu_triplet_regexp);

Indentation looks off here as well.

Tom

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH, rs6000] Add ppc64*_gnu_triplet_regexp methods.
  2021-07-29 19:42 ` Tom Tromey
@ 2021-08-03 18:35   ` will schmidt
  2021-08-05 20:43   ` [PATCH, rs6000] [V2] " will schmidt
  1 sibling, 0 replies; 6+ messages in thread
From: will schmidt @ 2021-08-03 18:35 UTC (permalink / raw)
  To: Tom Tromey, will schmidt via Gdb-patches
  Cc: Ulrich Weigand, rogerio, Alan Modra

On Thu, 2021-07-29 at 13:42 -0600, Tom Tromey wrote:
> > > > > > ">" == will schmidt via Gdb-patches <
> > > > > > gdb-patches@sourceware.org> writes:
> > > [PATCH, rs6000] Add ppc64*_gnu_triplet_regexp methods.
> > > Hi,
> > >   Add methods to set the target triplet so we can
> > > find the proper gcc when our gcc is named of
> > > the form powerpc64{le}-<foo>-gcc or ppc64{le}-<foo>-gcc.
> 
> Hi.  Thank you for the patch.
> I have a few nits, nothing too serious.
> 
> > > gdb/Changelog:
> > > yyyy-mm-dd  Will Schmidt  <will_schmidt@vnet.ibm.com>
> > > 	* gdb/ppc-linux-tdep.c (ppc64le_gnu_triplet_regexp): New
> > > 	function to set triplet.
> > > 	(ppc64_gnu_triplet_regexp): Same.
> > > 	(ppc_linux_init_abi): Conditionally call to set the
> > > 	ppc64 or ppc64le triplets.
> 
> ChangeLog entries aren't needed any more.

ok.  :-)
> 
> > > +static const char *
> > > +ppc64le_gnu_triplet_regexp (struct gdbarch *gdbarch)
> > > +{
> > > +        return "p(ower)*pc64le?";
> 
> Indentation looks off.

Ok.  I'm usually careful with whitespace, but I may have
hosed something up when pasting into the email.  I'll double-check.

> Also I would use "?" rather than "*" in this regexp.
> And, is the "e" really optional?  Seems a bit weird.

Correct, the 'e' is not optional.  My bad.  

Thanks for the review.  I'll refresh, retest, repost.

Thanks
-Will

> 
> > > +static const char *
> > > +ppc64_gnu_triplet_regexp (struct gdbarch *gdbarch)
> > > +{
> > > +        return "p(ower)*pc64?";
> 
> Same comments.
> 
> > > +     /* Set compiler triplet.  */
> > > +      if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_LITTLE)
> > > +          set_gdbarch_gnu_triplet_regexp (gdbarch,
> > > ppc64le_gnu_triplet_regexp);
> > > +      else
> > > +          set_gdbarch_gnu_triplet_regexp (gdbarch,
> > > ppc64_gnu_triplet_regexp);
> 
> Indentation looks off here as well.
> 
> Tom


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH, rs6000] [V2] Add ppc64*_gnu_triplet_regexp methods.
  2021-07-29 19:42 ` Tom Tromey
  2021-08-03 18:35   ` will schmidt
@ 2021-08-05 20:43   ` will schmidt
  2021-08-16 12:14     ` Ulrich Weigand
  1 sibling, 1 reply; 6+ messages in thread
From: will schmidt @ 2021-08-05 20:43 UTC (permalink / raw)
  To: Tom Tromey, will schmidt via Gdb-patches
  Cc: Ulrich Weigand, rogerio, Alan Modra

[gdb] [rs6000] Add ppc64*_gnu_triplet_regexp methods.
    
Hi,

V2, updated per feedback, thanks Tom and Lancelot for the
review comments.   Fixed up the regex strings, corrected
indentation and whitespace issues.

  Add methods to set the target triplet so we can
find the proper gcc when our gcc is named of
the form powerpc64{le}-<foo>-gcc or ppc64{le}-<foo>-gcc.
    
OK for trunk?
Thanks
-Will

diff --git a/gdb/ppc-linux-tdep.c b/gdb/ppc-linux-tdep.c
index 1e94922f25a..6c88d896a2d 100644
--- a/gdb/ppc-linux-tdep.c
+++ b/gdb/ppc-linux-tdep.c
@@ -1971,10 +1971,34 @@ ppc_floatformat_for_type (struct gdbarch *gdbarch,
     }
 
   return default_floatformat_for_type (gdbarch, name, len);
 }
 
+/* Specify the powerpc64le target triplet.
+   This can be variations of
+	ppc64le-{distro}-linux-gcc
+   and
+	powerpc64le-{distro}-linux-gcc.  */
+
+static const char *
+ppc64le_gnu_triplet_regexp (struct gdbarch *gdbarch)
+{
+  return "p(ower)?pc64le";
+}
+
+/* Specify the powerpc64 target triplet.
+   This can be variations of
+	ppc64-{distro}-linux-gcc
+   and
+	powerpc64-{distro}-linux-gcc.  */
+
+static const char *
+ppc64_gnu_triplet_regexp (struct gdbarch *gdbarch)
+{
+  return "p(ower)?pc64";
+}
+
 static void
 ppc_linux_init_abi (struct gdbarch_info info,
 		    struct gdbarch *gdbarch)
 {
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
@@ -2101,10 +2125,15 @@ ppc_linux_init_abi (struct gdbarch_info info,
       /* BFD target for core files.  */
       if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_LITTLE)
 	set_gdbarch_gcore_bfd_target (gdbarch, "elf64-powerpcle");
       else
 	set_gdbarch_gcore_bfd_target (gdbarch, "elf64-powerpc");
+     /* Set compiler triplet.  */
+      if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_LITTLE)
+	set_gdbarch_gnu_triplet_regexp (gdbarch, ppc64le_gnu_triplet_regexp);
+      else
+	set_gdbarch_gnu_triplet_regexp (gdbarch, ppc64_gnu_triplet_regexp);
     }
 
   set_gdbarch_core_read_description (gdbarch, ppc_linux_core_read_description);
   set_gdbarch_iterate_over_regset_sections (gdbarch,
 					    ppc_linux_iterate_over_regset_sections);


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH, rs6000] [V2] Add ppc64*_gnu_triplet_regexp methods.
  2021-08-05 20:43   ` [PATCH, rs6000] [V2] " will schmidt
@ 2021-08-16 12:14     ` Ulrich Weigand
  0 siblings, 0 replies; 6+ messages in thread
From: Ulrich Weigand @ 2021-08-16 12:14 UTC (permalink / raw)
  To: will schmidt
  Cc: Alan Modra, will schmidt via Gdb-patches, rogerio, Tom Tromey



"will schmidt" <will_schmidt@vnet.ibm.com> wrote on 05.08.2021 22:43:06:

> diff --git a/gdb/ppc-linux-tdep.c b/gdb/ppc-linux-tdep.c
> index 1e94922f25a..6c88d896a2d 100644
> --- a/gdb/ppc-linux-tdep.c
> +++ b/gdb/ppc-linux-tdep.c
> @@ -1971,10 +1971,34 @@ ppc_floatformat_for_type (struct gdbarch
*gdbarch,
>      }
>
>    return default_floatformat_for_type (gdbarch, name, len);
>  }
>
> +/* Specify the powerpc64le target triplet.
> +   This can be variations of
> +   ppc64le-{distro}-linux-gcc
> +   and
> +   powerpc64le-{distro}-linux-gcc.  */
> +
> +static const char *
> +ppc64le_gnu_triplet_regexp (struct gdbarch *gdbarch)
> +{
> +  return "p(ower)?pc64le";
> +}
> +
> +/* Specify the powerpc64 target triplet.
> +   This can be variations of
> +   ppc64-{distro}-linux-gcc
> +   and
> +   powerpc64-{distro}-linux-gcc.  */
> +
> +static const char *
> +ppc64_gnu_triplet_regexp (struct gdbarch *gdbarch)
> +{
> +  return "p(ower)?pc64";
> +}
> +
>  static void
>  ppc_linux_init_abi (struct gdbarch_info info,
>            struct gdbarch *gdbarch)
>  {
>    struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
> @@ -2101,10 +2125,15 @@ ppc_linux_init_abi (struct gdbarch_info info,
>        /* BFD target for core files.  */
>        if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_LITTLE)
>     set_gdbarch_gcore_bfd_target (gdbarch, "elf64-powerpcle");
>        else
>     set_gdbarch_gcore_bfd_target (gdbarch, "elf64-powerpc");
> +     /* Set compiler triplet.  */
> +      if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_LITTLE)
> +   set_gdbarch_gnu_triplet_regexp (gdbarch, ppc64le_gnu_triplet_regexp);
> +      else
> +   set_gdbarch_gnu_triplet_regexp (gdbarch, ppc64_gnu_triplet_regexp);
>      }
>
>    set_gdbarch_core_read_description (gdbarch,
> ppc_linux_core_read_description);
>    set_gdbarch_iterate_over_regset_sections (gdbarch,
>                     ppc_linux_iterate_over_regset_sections);
>


This is OK.

Thanks,
Ulrich


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-08-16 12:14 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-27 15:36 [PATCH, rs6000] Add ppc64*_gnu_triplet_regexp methods will schmidt
2021-07-28 22:04 ` Lancelot SIX
2021-07-29 19:42 ` Tom Tromey
2021-08-03 18:35   ` will schmidt
2021-08-05 20:43   ` [PATCH, rs6000] [V2] " will schmidt
2021-08-16 12:14     ` Ulrich Weigand

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 read-only IMAP folder(s) and NNTP newsgroup(s).