From patchwork Mon Feb 27 21:29:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 65710 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7A776385B53E for ; Mon, 27 Feb 2023 21:31:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7A776385B53E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1677533489; bh=VAcGwoQsXPBdqo6g6jvR07kkpBIirPxbhE4LPYHY4aE=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=azFMAmBMG2zm1neUbFv2QaJToUVwxcK6KcppaiS9ETY8h5hIJy3oPFUgKVglWiNP/ p3flaFG8/QUwts6zsRxcJtoTUv85fa3nKD7dxMQrbNOE4dBhPmVFjp5/TLTggC+kEi hj7UXbWix/NrKClAU34mLNWSzza1s0Al5ASd7xAU= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id F387E3858430 for ; Mon, 27 Feb 2023 21:29:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F387E3858430 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-647-FuHSXVFqOJmH3gj58HpFEg-1; Mon, 27 Feb 2023 16:29:43 -0500 X-MC-Unique: FuHSXVFqOJmH3gj58HpFEg-1 Received: by mail-wm1-f71.google.com with SMTP id n27-20020a05600c3b9b00b003e9ca0f4677so3407455wms.8 for ; Mon, 27 Feb 2023 13:29:43 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677533381; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VAcGwoQsXPBdqo6g6jvR07kkpBIirPxbhE4LPYHY4aE=; b=ntxqIqABEVRn7q3CsUGO2fKoMha3tSTvNx7GipKkh6R5fK4k/RW9oeEFm9MzZ3B3ss KNWtjlkPQ+5Dq9APw8MZN2zfu20IC9wcETP1zT8ItNME3l5IFUUIFXSNtay/wq7xoe+O CzTL1eaOhiho3Hi5+QSNXYNcKVEiqwc6vnnEL8PJIaJ+07voyr+WCGqr1Y94UpFvSdwy ou90OKjOYRed4RAA6UFQbo88Z+QFEfCse3fJJZ4Lb6v0jU29iYZ6miCL+KNeTdfeoU5B O0sFUliwGi/u3LAc22KNimEaIgv4a+AnyAyW6CuycWcyDGq/l6C7F78/+mFzKgiO0brM uFSQ== X-Gm-Message-State: AO0yUKUME5INgU75Kp8HYJEQ7Xn7V3/ex8C+MPcERSrC0AgX7OJvnNaU zziIz6sukTQGMw77k2myaCHs3Vdg0SKqQ1nftg1JXrdueLKUqkR+kB5hToGgPbgGZ+B01S1qGtA CHrLhIceQfJGCnpi493rDLVvtqfoHpr5gnIGVIGJqLcooM3wRx5w6YmZ5CDMxYuC5eMXEmDHvph XnDhA= X-Received: by 2002:a05:6000:12c3:b0:2c7:84e:1cfa with SMTP id l3-20020a05600012c300b002c7084e1cfamr408122wrx.40.1677533381568; Mon, 27 Feb 2023 13:29:41 -0800 (PST) X-Google-Smtp-Source: AK7set+6EP38N6REM19CT8XGAMh9uYpYehiFpEvyVN70s21N+1hxUdJTSYVN2pTgOECwF9AKZrOFcg== X-Received: by 2002:a05:6000:12c3:b0:2c7:84e:1cfa with SMTP id l3-20020a05600012c300b002c7084e1cfamr408111wrx.40.1677533381265; Mon, 27 Feb 2023 13:29:41 -0800 (PST) Received: from localhost (95.72.115.87.dyn.plus.net. [87.115.72.95]) by smtp.gmail.com with ESMTPSA id ja18-20020a05600c557200b003eb0d6f48f3sm13229150wmb.27.2023.02.27.13.29.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Feb 2023 13:29:40 -0800 (PST) To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCH 08/13] gdb: remove use of alloca from linux-nat-trad.c Date: Mon, 27 Feb 2023 21:29:21 +0000 Message-Id: X-Mailer: git-send-email 2.25.4 In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Andrew Burgess via Gdb-patches From: Andrew Burgess Reply-To: Andrew Burgess Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" Remove use of alloca from linux-nat-trad.c and replace with gdb::byte_vector. I've compiled for the mips-linux target (which uses this file) to ensure that the file still builds, but I've not tested GDB for a target that uses this file. Still, I'm pretty confident that I've not broken anything with this change. There should be no user visible changes after this commit. --- gdb/linux-nat-trad.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gdb/linux-nat-trad.c b/gdb/linux-nat-trad.c index 8204f3883f5..408d9118766 100644 --- a/gdb/linux-nat-trad.c +++ b/gdb/linux-nat-trad.c @@ -32,7 +32,6 @@ linux_nat_trad_target::fetch_register (struct regcache *regcache, int regnum) struct gdbarch *gdbarch = regcache->arch (); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); CORE_ADDR addr; - gdb_byte *buf; size_t size; pid_t pid; int i; @@ -49,7 +48,8 @@ linux_nat_trad_target::fetch_register (struct regcache *regcache, int regnum) pid = get_ptrace_pid (regcache->ptid ()); size = register_size (gdbarch, regnum); - buf = (gdb_byte *) alloca (size); + gdb::byte_vector buf_storage (size); + gdb_byte *buf = buf_storage.data (); /* Read the register contents from the inferior a chunk at a time. */ for (i = 0; i < size; i += sizeof (PTRACE_TYPE_RET)) @@ -95,7 +95,6 @@ linux_nat_trad_target::store_register (const struct regcache *regcache, enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); CORE_ADDR addr; size_t size; - gdb_byte *buf; pid_t pid; int i; @@ -108,7 +107,8 @@ linux_nat_trad_target::store_register (const struct regcache *regcache, pid = get_ptrace_pid (regcache->ptid ()); size = register_size (gdbarch, regnum); - buf = (gdb_byte *) alloca (size); + gdb::byte_vector buf_storage (size); + gdb_byte *buf = buf_storage.data (); /* Write the register contents into the inferior a chunk at a time. */ regcache->raw_collect (regnum, buf);