From patchwork Mon Feb 18 21:56:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 31514 Received: (qmail 18778 invoked by alias); 18 Feb 2019 21:56:31 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 18762 invoked by uid 89); 18 Feb 2019 21:56:31 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=H*RU:sk:host86-, Hx-spam-relays-external:sk:host86-, H*r:sk:host86-, gdbtypesc X-HELO: mail-wm1-f67.google.com Received: from mail-wm1-f67.google.com (HELO mail-wm1-f67.google.com) (209.85.128.67) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 18 Feb 2019 21:56:30 +0000 Received: by mail-wm1-f67.google.com with SMTP id y15so565837wma.0 for ; Mon, 18 Feb 2019 13:56:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=from:to:cc:subject:date:message-id; bh=9AMITJUpBggFJbcst4/Dlb9m4si5U72oJSYbMRVMf2Q=; b=eYoDWr8pVRwyi8n7PMeefg5dAK3+jnAVYbqxgPK6xvMMzPuVOOwwfwrcFHSYYWSmjy BUXaLBLTG3DVaJ7uDk5GaRr5u4tGZOXQOm8apMTe2Gck47ExT/ShXoTxG15spCOHMNCt k3ikx5x7oeAhgFv9KaAhLChA0otXCo+3MqRYsDugGdRkUoyMpjaz1aM2CBYm+TJyG4zA mieNoBL/ZlAP6QNMUx1E0uH20W5MNtFo6kb6zpfTdd/VVRznJFEFtUDve9YV+WY1ZwOR lkevDbRt0LF90nodgcRgavb773a/NXmlHqJQNfOllYXrsuPAyQbNfvCqaZegZj8DmrXE jmeg== Return-Path: Received: from localhost (host86-135-139-200.range86-135.btcentralplus.com. [86.135.139.200]) by smtp.gmail.com with ESMTPSA id b4sm1119079wmj.3.2019.02.18.13.56.26 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Feb 2019 13:56:26 -0800 (PST) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCH] gdb: Allow gdbarch to override alignment for method and member pointers Date: Mon, 18 Feb 2019 21:56:23 +0000 Message-Id: <20190218215623.26529-1-andrew.burgess@embecosm.com> X-IsSubscribed: yes 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;