From patchwork Sat Apr 27 14:31:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 32437 Received: (qmail 24289 invoked by alias); 27 Apr 2019 14:31:42 -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 24240 invoked by uid 89); 27 Apr 2019 14:31:42 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-17.9 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.1 spammy=vec_safe_push, regcache, pass_on_stack X-HELO: gateway33.websitewelcome.com Received: from gateway33.websitewelcome.com (HELO gateway33.websitewelcome.com) (192.185.146.21) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 27 Apr 2019 14:31:40 +0000 Received: from cm16.websitewelcome.com (cm16.websitewelcome.com [100.42.49.19]) by gateway33.websitewelcome.com (Postfix) with ESMTP id E5D557C0F27 for ; Sat, 27 Apr 2019 09:31:37 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id KOMbhqQzN4FKpKOMbhHj2X; Sat, 27 Apr 2019 09:31:37 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=wDvtptizkNcawiIpil/jPuzbWs6j2lxlu8KOPT3UJ4I=; b=mPcV/+W+Uo9h+EIZio/ayzbtxF dwA/x9mSb3OgPMIayKQSyiVgLhI4eX8ChiQUKiWpCSwY4R24iN5YNI3x+K/3losFX5RZvbJ+bTFuP CLAPevB4nVaJO0Yj/K4gxW5Ln; Received: from 97-122-168-123.hlrn.qwest.net ([97.122.168.123]:49568 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.91) (envelope-from ) id 1hKOMb-0011yo-O7; Sat, 27 Apr 2019 09:31:37 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 2/2] Remove a VEC from aarch64-tdep.c Date: Sat, 27 Apr 2019 08:31:34 -0600 Message-Id: <20190427143134.14048-3-tom@tromey.com> In-Reply-To: <20190427143134.14048-1-tom@tromey.com> References: <20190427143134.14048-1-tom@tromey.com> This removes a VEC from aarch64-tdep.c, replacing it with a std::vector. gdb/ChangeLog 2019-04-27 Tom Tromey * aarch64-tdep.c (stack_item_t): Remove typedef and DEF_VEC. (struct aarch64_call_info): Add initializers. : Now a std::vector. (pass_on_stack, aarch64_push_dummy_call): Update. --- gdb/ChangeLog | 7 +++++++ gdb/aarch64-tdep.c | 36 +++++++++++++++--------------------- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c index f8b4fa4c974..2c8c6a1bdc3 100644 --- a/gdb/aarch64-tdep.c +++ b/gdb/aarch64-tdep.c @@ -1206,7 +1206,7 @@ aarch64_execute_dwarf_cfa_vendor_op (struct gdbarch *gdbarch, gdb_byte op, /* When arguments must be pushed onto the stack, they go on in reverse order. The code below implements a FILO (stack) to do this. */ -typedef struct +struct stack_item_t { /* Value to pass on stack. It can be NULL if this item is for stack padding. */ @@ -1214,9 +1214,7 @@ typedef struct /* Size in bytes of value to pass on stack. */ int len; -} stack_item_t; - -DEF_VEC_O (stack_item_t); +}; /* Implement the gdbarch type alignment method, overrides the generic alignment algorithm for anything that is aarch64 specific. */ @@ -1392,22 +1390,22 @@ aapcs_is_vfp_call_or_return_candidate (struct type *type, int *count, struct aarch64_call_info { /* the current argument number. */ - unsigned argnum; + unsigned argnum = 0; /* The next general purpose register number, equivalent to NGRN as described in the AArch64 Procedure Call Standard. */ - unsigned ngrn; + unsigned ngrn = 0; /* The next SIMD and floating point register number, equivalent to NSRN as described in the AArch64 Procedure Call Standard. */ - unsigned nsrn; + unsigned nsrn = 0; /* The next stacked argument address, equivalent to NSAA as described in the AArch64 Procedure Call Standard. */ - unsigned nsaa; + unsigned nsaa = 0; /* Stack item vector. */ - VEC(stack_item_t) *si; + std::vector si; }; /* Pass a value in a sequence of consecutive X registers. The caller @@ -1521,7 +1519,7 @@ pass_on_stack (struct aarch64_call_info *info, struct type *type, item.len = len; item.data = buf; - VEC_safe_push (stack_item_t, info->si, &item); + info->si.push_back (item); info->nsaa += len; if (info->nsaa & (align - 1)) @@ -1532,7 +1530,7 @@ pass_on_stack (struct aarch64_call_info *info, struct type *type, item.len = pad; item.data = NULL; - VEC_safe_push (stack_item_t, info->si, &item); + info->si.push_back (item); info->nsaa += pad; } } @@ -1632,8 +1630,6 @@ aarch64_push_dummy_call (struct gdbarch *gdbarch, struct value *function, int argnum; struct aarch64_call_info info; - memset (&info, 0, sizeof (info)); - /* We need to know what the type of the called function is in order to determine the number of named/anonymous arguments for the actual argument placement, and the return type in order to handle @@ -1762,18 +1758,16 @@ aarch64_push_dummy_call (struct gdbarch *gdbarch, struct value *function, if (info.nsaa & 15) sp -= 16 - (info.nsaa & 15); - while (!VEC_empty (stack_item_t, info.si)) + while (!info.si.empty ()) { - stack_item_t *si = VEC_last (stack_item_t, info.si); + const stack_item_t &si = info.si.back (); - sp -= si->len; - if (si->data != NULL) - write_memory (sp, si->data, si->len); - VEC_pop (stack_item_t, info.si); + sp -= si.len; + if (si.data != NULL) + write_memory (sp, si.data, si.len); + info.si.pop_back (); } - VEC_free (stack_item_t, info.si); - /* Finally, update the SP register. */ regcache_cooked_write_unsigned (regcache, AARCH64_SP_REGNUM, sp);