From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 40656 invoked by alias); 12 Apr 2019 23:25:50 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 40601 invoked by uid 89); 12 Apr 2019 23:25:49 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.6 required=5.0 tests=AWL,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.1 spammy= X-HELO: mail-wm1-f66.google.com Received: from mail-wm1-f66.google.com (HELO mail-wm1-f66.google.com) (209.85.128.66) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 12 Apr 2019 23:25:47 +0000 Received: by mail-wm1-f66.google.com with SMTP id h18so12811167wml.1 for ; Fri, 12 Apr 2019 16:25:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=RW+7uYSamUnmj5w6ilcUEU7354RditaKy7ichsEBJNo=; b=Lt9K9yQV2xbESDB9CYReEsTX/pnGhfGx0we/wVPONMqYpXdPGwcdkFdoMd3FhnEK0W nnsSowW7Hfu3jtZpqExFWq4OqWGlmgh5MltopdZfJkRK46m5GtgahTDAU+go0x89XvwL YL5+6KasR9+4jyK61RhTOjaJs8piLRJvusEfHA+W+5SqTobXglp6ra7Ilaf+1swadSzV XcsB1YumdY4vwEerB6dxFT/Gr4enE9PoWLCzRjwVTQJE1882nMASbD3m5FxtEItvU0aU FCkwULrXN0SIkZ3HPwVsjY0M/8NVkbm1b0PA4ofGG5qJck31xlFUb4B3Yrx3l76hPyRt YNVQ== Return-Path: Received: from localhost (host86-164-133-98.range86-164.btcentralplus.com. [86.164.133.98]) by smtp.gmail.com with ESMTPSA id f128sm10699530wme.28.2019.04.12.16.25.44 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 12 Apr 2019 16:25:44 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: alan.hayward@arm.com, Andrew Burgess Subject: [PATCH 3/3] gdb/nds32: Use type_align instead of nds32_type_align Date: Fri, 12 Apr 2019 23:25:00 -0000 Message-Id: <6e5973aace6c35e5edfd75ce7b268f44b7bd42a2.1555111225.git.andrew.burgess@embecosm.com> In-Reply-To: References: In-Reply-To: References: X-IsSubscribed: yes X-SW-Source: 2019-04/txt/msg00237.txt.bz2 The general type_align method should be a suitable alternative to nds32_type_align, so switch to use that. The only change this will introduce is related to static fields in a struct or union, the existing code doesn't take account of static fields when computing the alignment for structs of unions, though this is probably a bug - which would probably be exposed by the test case gdb.cp/many-args.exp, though I don't have any way to test this target right now. gdb/ChangeLog: * nds32-tdep.c (nds32_type_align): Delete. (nds32_push_dummy_call): Use type_align instead. --- gdb/ChangeLog | 5 +++++ gdb/nds32-tdep.c | 49 ++----------------------------------------------- 2 files changed, 7 insertions(+), 47 deletions(-) diff --git a/gdb/nds32-tdep.c b/gdb/nds32-tdep.c index 801b2dadcae..d3481e2000b 100644 --- a/gdb/nds32-tdep.c +++ b/gdb/nds32-tdep.c @@ -1439,51 +1439,6 @@ nds32_check_calling_use_fpr (struct type *type) return typecode == TYPE_CODE_FLT; } -/* Return the alignment (in bytes) of the given type. */ - -static int -nds32_type_align (struct type *type) -{ - int n; - int align; - int falign; - - type = check_typedef (type); - switch (TYPE_CODE (type)) - { - default: - /* Should never happen. */ - internal_error (__FILE__, __LINE__, _("unknown type alignment")); - return 4; - - case TYPE_CODE_PTR: - case TYPE_CODE_ENUM: - case TYPE_CODE_INT: - case TYPE_CODE_FLT: - case TYPE_CODE_SET: - case TYPE_CODE_RANGE: - case TYPE_CODE_REF: - case TYPE_CODE_CHAR: - case TYPE_CODE_BOOL: - return TYPE_LENGTH (type); - - case TYPE_CODE_ARRAY: - case TYPE_CODE_COMPLEX: - return nds32_type_align (TYPE_TARGET_TYPE (type)); - - case TYPE_CODE_STRUCT: - case TYPE_CODE_UNION: - align = 1; - for (n = 0; n < TYPE_NFIELDS (type); n++) - { - falign = nds32_type_align (TYPE_FIELD_TYPE (type, n)); - if (falign > align) - align = falign; - } - return align; - } -} - /* Implement the "push_dummy_call" gdbarch method. */ static CORE_ADDR @@ -1522,7 +1477,7 @@ nds32_push_dummy_call (struct gdbarch *gdbarch, struct value *function, for (i = 0; i < nargs; i++) { struct type *type = value_type (args[i]); - int align = nds32_type_align (type); + int align = type_align (type); /* If align is zero, it may be an empty struct. Just ignore the argument of empty struct. */ @@ -1548,7 +1503,7 @@ nds32_push_dummy_call (struct gdbarch *gdbarch, struct value *function, type = value_type (args[i]); calling_use_fpr = nds32_check_calling_use_fpr (type); len = TYPE_LENGTH (type); - align = nds32_type_align (type); + align = type_align (type); val = value_contents (args[i]); /* The size of a composite type larger than 4 bytes will be rounded -- 2.14.5