From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by sourceware.org (Postfix) with ESMTPS id D11B43858D20 for ; Fri, 4 Feb 2022 08:42:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D11B43858D20 Received: by mail-wr1-x435.google.com with SMTP id s18so9903205wrv.7 for ; Fri, 04 Feb 2022 00:42:00 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=EAAVL3mNOwo8aGwe4aUz/R4GrnhX5SYlQA3CpW/DKIA=; b=U+jh1sQLnPKM87Rz4fOovOwY5/M8l7qCMSZ3RskcKqfebbm7i+u6iscsY7WxggiLR1 yoyXCwpayVFUvnQu3zHpxFDt8bnDQyEtquXD2BqZ+ptrDW3RRXYRoirnUe9E4DADYrMV L89mAeP9TAS1ebxpJInaGzqhXlOs4xA133+TyDSn0mSrWepicJo/+XFlBUD+DR9VnTbX 9p8qrW5VFGBDF/xlpfqNiTDGB4UG/5Yc8smcB4yCgCtPYh9Iwe9kGJL7abb4SW3VGTkt 8cp03ukboILvLQhPknx/I9txrArV78RTMvZ6iaET1YbLYa8YXg6kiP928wJ1xuuLfAnx aGew== X-Gm-Message-State: AOAM532ctlzg6Xh62e6x8w4pHLE8nzQ77n1FDfC53o9WcraZw27kg/qy ju/8SHRpprK0ci2E8wUipUTbk3KARSShgA== X-Google-Smtp-Source: ABdhPJw9GMx64aXAwhXf8ahRIJ8BAApDKyQMI5L8tqS5XRquGJWDCDX0Vmxu/6HDVZviPLTogMB5/w== X-Received: by 2002:adf:f44a:: with SMTP id f10mr1479001wrp.653.1643964119735; Fri, 04 Feb 2022 00:41:59 -0800 (PST) Received: from babel.clyon.hd.free.fr ([2a01:e0a:203:b210:afd3:bde6:6149:fc73]) by smtp.gmail.com with ESMTPSA id y7sm1198617wrr.74.2022.02.04.00.41.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Feb 2022 00:41:59 -0800 (PST) From: christophe.lyon.oss@gmail.com X-Google-Original-From: christophe.lyon@gmail.com To: gdb-patches@sourceware.org Cc: torbjorn.svensson@st.com, Christophe Lyon Subject: [PATCH v3 3/5] gdb/arm: Introduce arm_cache_init Date: Fri, 4 Feb 2022 09:41:49 +0100 Message-Id: <20220204084151.14480-4-christophe.lyon@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220204084151.14480-1-christophe.lyon@gmail.com> References: <20220204084151.14480-1-christophe.lyon@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-10.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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-List-Received-Date: Fri, 04 Feb 2022 08:42:03 -0000 From: Christophe Lyon This patch is a preparation for the rest of the series and adds two arm_cache_init helper functions. It updates every place that updates cache->saved_regs to call the helper instead. Signed-off-by: Torbjorn Svensson Signed-off-by: Christophe Lyon --- gdb/arm-tdep.c | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c index 8533851eceb..18b7c18d3cc 100644 --- a/gdb/arm-tdep.c +++ b/gdb/arm-tdep.c @@ -290,6 +290,23 @@ struct arm_prologue_cache trad_frame_saved_reg *saved_regs; }; +static void +arm_cache_init (struct arm_prologue_cache *cache, struct gdbarch *gdbarch) +{ + cache->framesize = 0; + cache->framereg = 0; + cache->saved_regs = trad_frame_alloc_saved_regs (gdbarch); +} + +static void +arm_cache_init (struct arm_prologue_cache *cache, struct frame_info *frame) +{ + struct gdbarch *gdbarch = get_frame_arch (frame); + cache->prev_sp = get_frame_register_unsigned (frame, ARM_SP_REGNUM); + + arm_cache_init (cache, gdbarch); +} + namespace { /* Abstract class to read ARM instructions from memory. */ @@ -1926,7 +1943,7 @@ arm_make_prologue_cache (struct frame_info *this_frame) CORE_ADDR unwound_fp; cache = FRAME_OBSTACK_ZALLOC (struct arm_prologue_cache); - cache->saved_regs = trad_frame_alloc_saved_regs (this_frame); + arm_cache_init (cache, this_frame); arm_scan_prologue (this_frame, cache); @@ -2392,7 +2409,7 @@ arm_exidx_fill_cache (struct frame_info *this_frame, gdb_byte *entry) struct arm_prologue_cache *cache; cache = FRAME_OBSTACK_ZALLOC (struct arm_prologue_cache); - cache->saved_regs = trad_frame_alloc_saved_regs (this_frame); + arm_cache_init (cache, this_frame); for (;;) { @@ -2786,7 +2803,7 @@ arm_make_epilogue_frame_cache (struct frame_info *this_frame) int reg; cache = FRAME_OBSTACK_ZALLOC (struct arm_prologue_cache); - cache->saved_regs = trad_frame_alloc_saved_regs (this_frame); + arm_cache_init (cache, this_frame); /* Still rely on the offset calculated from prologue. */ arm_scan_prologue (this_frame, cache); @@ -2947,7 +2964,7 @@ arm_make_stub_cache (struct frame_info *this_frame) struct arm_prologue_cache *cache; cache = FRAME_OBSTACK_ZALLOC (struct arm_prologue_cache); - cache->saved_regs = trad_frame_alloc_saved_regs (this_frame); + arm_cache_init (cache, this_frame); cache->prev_sp = get_frame_register_unsigned (this_frame, ARM_SP_REGNUM); @@ -3025,7 +3042,7 @@ arm_m_exception_cache (struct frame_info *this_frame) uint32_t secure_stack_used; cache = FRAME_OBSTACK_ZALLOC (struct arm_prologue_cache); - cache->saved_regs = trad_frame_alloc_saved_regs (this_frame); + arm_cache_init (cache, this_frame); /* ARMv7-M Architecture Reference "B1.5.6 Exception entry behavior" describes which bits in LR that define which stack was used prior @@ -13611,7 +13628,7 @@ arm_analyze_prologue_test () test_arm_instruction_reader mem_reader (insns); arm_prologue_cache cache; - cache.saved_regs = trad_frame_alloc_saved_regs (gdbarch); + arm_cache_init (&cache, gdbarch); arm_analyze_prologue (gdbarch, 0, sizeof (insns) - 1, &cache, mem_reader); } -- 2.25.1