public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@polymtl.ca>
To: John Darrington <john@darrington.wattle.id.au>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH 1/3] gdb: Added builtin types for 24 bit integers.
Date: Fri, 24 Aug 2018 15:09:00 -0000	[thread overview]
Message-ID: <0f42f2a6bd5c76d40242043ca8b65cf3@polymtl.ca> (raw)
In-Reply-To: <20180824061125.7vjvlopdx4bstg4l@jocasta.intra>

[-- Attachment #1: Type: text/plain, Size: 2804 bytes --]

On 2018-08-24 02:11, John Darrington wrote:
> On Thu, Aug 23, 2018 at 04:35:25PM -0400, Simon Marchi wrote:
> 
>      It is clear now, but somebody doing a git blame to know why 24-bit
>      integer types were added would only find the patch that adds them 
> by
>      itself and wonder who uses that.  A little message like
> 
>        This patch adds 24-bit integer types, used when debugging on the 
> S12Z
>      architecture (added by a later patch in this series).
> 
>      clears that up.  That might looks a bit silly, but I think it 
> helps in
>      the long run.
> 
> I fully agree with you.   I've worked on other projects however had a
> different opinion - they insisted that the checkin comment NOT contain
> any rationale for the change, instead it should just summarize what
> changed.  I find that rather pointless but anyway ....

Well, if you look at our commit history, you'll see we like to be 
verbose :).

>      > It seems that up till now there has been no 24 bit targets, so 
> the
>      > other
>      > two patches as some necessary things to make that possible.
> 
>      Thanks.  Coming back to the code of the patch, I was wondering if 
> these
>      24-bit types are useful or even relevant for any other 
> architecture.
> 
> There most certainly are plenty of 24 bit architectures  especially in 
> the
> embedded world  - just apparently none that gdb currently supports :(
> 
>      Would it work if you only defined the types for s12z 
> architectures,
>      storing the reference in the gdbarch_tdep object?
> 
> My first reaction is that it probably *could* be made to work, but not
> in an elegant fashion.   Somehow I'd have to avoid that gdb ever calls 
> the
> read_encoded_value function.

I'm not sure I understand.  I was only talking about the definition of 
the int24_t and uint24_t types, not the handling of DW_EH_PE_udata3.  
 From what I read, the C99 standard mandates that the 8, 16, 32 and 64 
variants of the intX_t/uintX_t types exist.  Other types (with other 
values of X) would be extensions.  That's why I thought it would make 
sense to define that in the s12z-specific gdbarches only.  In the end I 
don't really mind, but it just looks like the "clean" way to do it and 
doesn't seem really more difficult.  Can you see if the attached diff 
(applied on top of your series) work for you?

And as far as I understand, this is disconnected from the handling of 
DW_EH_PE_udata3.

> I do concede that  adding DW_EH_PE_udata3 might be problematic since
> it's not part of the dwarf standard.  An alternative might be to rework
> the read_encoded_value function to not rely on the dwarf enums (all it
> really cares about is the size of the target's address space.

I'll take a look at that patch (2/3) separately and reply to it.

Simon

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Move-builtin_uint24_t-type-to-s12z-tdep.c.patch --]
[-- Type: text/x-diff; name=0001-Move-builtin_uint24_t-type-to-s12z-tdep.c.patch, Size: 2813 bytes --]

From e0902733a29726ba107c41980bdbd8500261c852 Mon Sep 17 00:00:00 2001
From: Simon Marchi <simon.marchi@ericsson.com>
Date: Fri, 24 Aug 2018 11:03:45 -0400
Subject: [PATCH] Move builtin_uint24_t type to s12z-tdep.c

---
 gdb/gdbtypes.c  |  4 ----
 gdb/gdbtypes.h  |  2 --
 gdb/s12z-tdep.c | 16 +++++++++++-----
 3 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index 05bf7b1..65b1211 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -5402,10 +5402,6 @@ gdbtypes_post_init (struct gdbarch *gdbarch)
     = arch_integer_type (gdbarch, 16, 0, "int16_t");
   builtin_type->builtin_uint16
     = arch_integer_type (gdbarch, 16, 1, "uint16_t");
-  builtin_type->builtin_int24
-    = arch_integer_type (gdbarch, 24, 0, "int24_t");
-  builtin_type->builtin_uint24
-    = arch_integer_type (gdbarch, 24, 1, "uint24_t");
   builtin_type->builtin_int32
     = arch_integer_type (gdbarch, 32, 0, "int32_t");
   builtin_type->builtin_uint32
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index eb7c365..14059ab 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -1611,8 +1611,6 @@ struct builtin_type
   struct type *builtin_uint8;
   struct type *builtin_int16;
   struct type *builtin_uint16;
-  struct type *builtin_int24;
-  struct type *builtin_uint24;
   struct type *builtin_int32;
   struct type *builtin_uint32;
   struct type *builtin_int64;
diff --git a/gdb/s12z-tdep.c b/gdb/s12z-tdep.c
index 5169025..48af422 100644
--- a/gdb/s12z-tdep.c
+++ b/gdb/s12z-tdep.c
@@ -76,6 +76,11 @@ static const int reg_perm[N_PHYSICAL_REGISTERS] =
    REG_CCW
   };
 
+struct gdbarch_tdep
+{
+  type *builtin_uint24;
+};
+
 static const char *
 s12z_register_name (struct gdbarch *gdbarch, int regnum)
 {
@@ -138,7 +143,10 @@ s12z_register_type (struct gdbarch *gdbarch, int reg_nr)
     case 2:
       return builtin_type (gdbarch)->builtin_uint16;
     case 3:
-      return builtin_type (gdbarch)->builtin_uint24;
+      {
+	struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+	return tdep->builtin_uint24;
+      }
     case 4:
       return builtin_type (gdbarch)->builtin_uint32;
     default:
@@ -347,10 +355,6 @@ constexpr gdb_byte s12z_break_insn[] = {0x00};
 
 typedef BP_MANIPULATION (s12z_break_insn) s12z_breakpoint;
 
-struct gdbarch_tdep
-{
-};
-
 static struct gdbarch *
 s12z_gdbarch_init (struct gdbarch_info info,
                     struct gdbarch_list *arches)
@@ -358,6 +362,8 @@ s12z_gdbarch_init (struct gdbarch_info info,
   struct gdbarch_tdep *tdep = (struct gdbarch_tdep *) xmalloc (sizeof *tdep);
   struct gdbarch *gdbarch = gdbarch_alloc (&info, tdep);
 
+  tdep->builtin_uint24 = arch_integer_type (gdbarch, 24, 1, "uint24_t");
+
   /* Target data types.  */
   set_gdbarch_short_bit (gdbarch, 16);
   set_gdbarch_int_bit (gdbarch, 16);
-- 
2.7.4


  reply	other threads:[~2018-08-24 15:09 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-23 17:35 John Darrington
2018-08-23 17:35 ` [PATCH 2/3] GDB: Add support for 24 bit addresses John Darrington
2018-08-24 20:34   ` Simon Marchi
2018-08-25  4:56     ` John Darrington
2018-08-23 17:35 ` [PATCH 3/3] GDB: New target s12z John Darrington
2018-08-23 17:56   ` Eli Zaretskii
2018-08-26 17:19   ` Simon Marchi
2018-08-26 17:41     ` John Darrington
2018-08-26 18:16       ` Simon Marchi
2018-08-26 22:55         ` Simon Marchi
2018-08-27  6:30           ` John Darrington
2018-08-27 12:54             ` Simon Marchi
2018-08-28 15:35         ` Tom Tromey
2018-08-23 17:55 ` [PATCH 1/3] gdb: Added builtin types for 24 bit integers Eli Zaretskii
2018-08-23 19:41 ` Simon Marchi
2018-08-23 20:04   ` John Darrington
2018-08-23 20:35     ` Simon Marchi
2018-08-24  6:11       ` John Darrington
2018-08-24 15:09         ` Simon Marchi [this message]
2018-08-24 15:29           ` John Darrington
2018-08-24 20:37             ` Simon Marchi

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=0f42f2a6bd5c76d40242043ca8b65cf3@polymtl.ca \
    --to=simon.marchi@polymtl.ca \
    --cc=gdb-patches@sourceware.org \
    --cc=john@darrington.wattle.id.au \
    /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 read-only IMAP folder(s) and NNTP newsgroup(s).