public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] gdb: Allow gdbarch to override alignment for method and member pointers
@ 2019-02-18 21:56 Andrew Burgess
  2019-02-18 23:08 ` Tom Tromey
  0 siblings, 1 reply; 2+ messages in thread
From: Andrew Burgess @ 2019-02-18 21:56 UTC (permalink / raw)
  To: gdb-patches; +Cc: Andrew Burgess

The code in type_align (gdbtypes.c) currently hard-codes the rules for
aligning method and member pointers.  It would seem better to forward
these types through the gdbarch hook, so that an architecture could
override the alignment of these types if needed.

Only 3 architectures currently override the gdbarch alignment hook,
these are arc, i386, and nio2.

For arc and nios the alignment rules are that alignment is the minimum
of 4-bytes and the type length.  As pointers are 4-bytes on these
targets, then (assuming method and members pointers are also 4-bytes)
there should be no change to the alignment after this patch.

For i386 the gdbarch alignment hook overrides for some INT and FLOAT
types only.  For method and member pointers we align on the type size
still, so there should be no change to the alignment after this patch.

I tested this on x86-64 GNU Linux with no regressions.

gdb/ChangeLog:

	* gdbtypes.c (type_align): Allow alignment of TYPE_CODE_METHODPTR
	and TYPE_CODE_MEMBERPTR to be overridden by the gdbarch.
---
 gdb/ChangeLog  | 5 +++++
 gdb/gdbtypes.c | 7 ++-----
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index 675878337b3..0d293393dae 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -3011,6 +3011,8 @@ type_align (struct type *type)
     case TYPE_CODE_CHAR:
     case TYPE_CODE_BOOL:
     case TYPE_CODE_DECFLOAT:
+    case TYPE_CODE_METHODPTR:
+    case TYPE_CODE_MEMBERPTR:
       {
 	struct gdbarch *arch = get_type_arch (type);
 	align = gdbarch_type_align (arch, type);
@@ -3053,11 +3055,6 @@ type_align (struct type *type)
 	 anyway.  */
       break;
 
-    case TYPE_CODE_METHODPTR:
-    case TYPE_CODE_MEMBERPTR:
-      align = type_length_units (type);
-      break;
-
     case TYPE_CODE_VOID:
       align = 1;
       break;
-- 
2.14.5

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

* Re: [PATCH] gdb: Allow gdbarch to override alignment for method and member pointers
  2019-02-18 21:56 [PATCH] gdb: Allow gdbarch to override alignment for method and member pointers Andrew Burgess
@ 2019-02-18 23:08 ` Tom Tromey
  0 siblings, 0 replies; 2+ messages in thread
From: Tom Tromey @ 2019-02-18 23:08 UTC (permalink / raw)
  To: Andrew Burgess; +Cc: gdb-patches

>>>>> "Andrew" == Andrew Burgess <andrew.burgess@embecosm.com> writes:

Andrew> gdb/ChangeLog:
Andrew> 	* gdbtypes.c (type_align): Allow alignment of TYPE_CODE_METHODPTR
Andrew> 	and TYPE_CODE_MEMBERPTR to be overridden by the gdbarch.

This looks good to me.  Thanks for doing this.

Tom

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

end of thread, other threads:[~2019-02-18 23:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-18 21:56 [PATCH] gdb: Allow gdbarch to override alignment for method and member pointers Andrew Burgess
2019-02-18 23:08 ` Tom Tromey

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).