Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Anton Kolesov <Anton.Kolesov@synopsys.com>
To: Tom Tromey <tom@tromey.com>,
	"gdb-patches@sourceware.org"	<gdb-patches@sourceware.org>
Cc: Claudiu Zissulescu <Claudiu.Zissulescu@synopsys.com>
Subject: RE: [RFA 6/6] Remove long_long_align_bit gdbarch attribute
Date: Tue, 24 Apr 2018 17:17:00 -0000	[thread overview]
Message-ID: <39A54937CC95F24AA2F794E2D2B66B1358A23CD3@DE02WEMBXB.internal.synopsys.com> (raw)
In-Reply-To: <20180424152222.8053-7-tom@tromey.com>

> First, arc-tdep.c claimed that long long alignment was 32 bits, but gcc's arc.h
> says:
> 
>     #define ADJUST_FIELD_ALIGN(FIELD, TYPE, COMPUTED) \
>     (TYPE_MODE (strip_array_types (TYPE)) == DFmode \
>      ? MIN ((COMPUTED), 32) : (COMPUTED))
> 
> Here, DFmode means "double".  So, I've implemented arc_type_align
> according to this.  I do not have a good way to test this.
> 
> diff --git a/gdb/arc-tdep.c b/gdb/arc-tdep.c index b0d51addd3..86cf522443
> 100644
> --- a/gdb/arc-tdep.c
> +++ b/gdb/arc-tdep.c
> @@ -1957,6 +1957,19 @@ arc_tdesc_init (struct gdbarch_info info, const
> struct target_desc **tdesc,
>    return TRUE;
>  }
> 
> +/* Implement the type_align gdbarch function.  */
> +
> +static ULONGEST
> +arc_type_align (struct gdbarch *gdbarch, struct type *type) {
> +  type = check_typedef (type);
> +
> +  if (TYPE_CODE (type) == TYPE_CODE_FLT && TYPE_LENGTH (type) == 8)
> +    return 4;
> +
> +  return TYPE_LENGTH (type);
> +}
> +

Hi Tom,

If I read this correctly, then it would set 4 byte alignment only to 8 byte
floating point type? That doesn't look right, because on ARC there is never
more than 4 byte alignment for any data type. GCC arc.h has:

    #define BIGGEST_ALIGNMENT 32

According to comments it used to be 64, but was changed to 32 at some
undefined point in the past.

I would have implemented this as:

static ULONGEST
arc_type_align (struct gdbarch *gdbarch, struct type *type) {
  type = check_typedef (type);
  return std::min<ULONGEST>(4, TYPE_LENGTH (type));
}

Anton


  parent reply	other threads:[~2018-04-24 17:17 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-24 15:22 [RFA 0/6] Teach gdb about type alignment Tom Tromey
2018-04-24 15:22 ` [RFA 1/6] Add initial type alignment support Tom Tromey
2018-04-24 19:16   ` Pedro Alves
2018-04-24 20:23     ` Tom Tromey
2018-04-24 15:22 ` [RFA 5/6] Remove rust_type_alignment Tom Tromey
2018-04-24 15:22 ` [RFA 6/6] Remove long_long_align_bit gdbarch attribute Tom Tromey
2018-04-24 15:24   ` Tom Tromey
2018-04-24 17:17   ` Anton Kolesov [this message]
2018-04-26 20:56     ` Tom Tromey
2018-04-24 15:22 ` [RFA 2/6] Handle alignof and _Alignof Tom Tromey
2018-04-24 17:04   ` Eli Zaretskii
2018-04-24 19:17   ` Pedro Alves
2018-04-24 20:23     ` Tom Tromey
2018-04-27 18:02       ` Pedro Alves
2018-04-27 20:53         ` Tom Tromey
2018-04-30 16:46         ` Tom Tromey
2018-04-26 20:45     ` Tom Tromey
2018-04-27 18:05       ` Pedro Alves
2018-04-26 20:54     ` Tom Tromey
2018-04-24 15:22 ` [RFA 3/6] Reindent type_object_getset in py-type.c Tom Tromey
2018-04-24 15:22 ` [RFA 4/6] Expose type alignment on gdb.Type Tom Tromey
2018-04-24 16:59   ` Eli Zaretskii

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=39A54937CC95F24AA2F794E2D2B66B1358A23CD3@DE02WEMBXB.internal.synopsys.com \
    --to=anton.kolesov@synopsys.com \
    --cc=Claudiu.Zissulescu@synopsys.com \
    --cc=gdb-patches@sourceware.org \
    --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