Skip to content

Commit 70cd633

Browse files
committed
gdb: Allow gdbarch to override alignment for method and member pointers
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.
1 parent 040b3e9 commit 70cd633

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

gdb/ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
2019-02-18 Andrew Burgess <[email protected]>
2+
3+
* gdbtypes.c (type_align): Allow alignment of TYPE_CODE_METHODPTR
4+
and TYPE_CODE_MEMBERPTR to be overridden by the gdbarch.
5+
16
2019-02-18 Philippe Waroquiers <[email protected]>
27

38
* ada-task.c (_initialize_tasks): Use 'with_cleanup' register

gdb/gdbtypes.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3011,6 +3011,8 @@ type_align (struct type *type)
30113011
case TYPE_CODE_CHAR:
30123012
case TYPE_CODE_BOOL:
30133013
case TYPE_CODE_DECFLOAT:
3014+
case TYPE_CODE_METHODPTR:
3015+
case TYPE_CODE_MEMBERPTR:
30143016
{
30153017
struct gdbarch *arch = get_type_arch (type);
30163018
align = gdbarch_type_align (arch, type);
@@ -3053,11 +3055,6 @@ type_align (struct type *type)
30533055
anyway. */
30543056
break;
30553057

3056-
case TYPE_CODE_METHODPTR:
3057-
case TYPE_CODE_MEMBERPTR:
3058-
align = type_length_units (type);
3059-
break;
3060-
30613058
case TYPE_CODE_VOID:
30623059
align = 1;
30633060
break;

0 commit comments

Comments
 (0)