From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oa1-x33.google.com (mail-oa1-x33.google.com [IPv6:2001:4860:4864:20::33]) by sourceware.org (Postfix) with ESMTPS id 0B10E3858D37 for ; Fri, 28 Jul 2023 01:01:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0B10E3858D37 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-oa1-x33.google.com with SMTP id 586e51a60fabf-1b055510c9dso1115005fac.0 for ; Thu, 27 Jul 2023 18:01:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1690506102; x=1691110902; h=mime-version:message-id:date:in-reply-to:subject:cc:to:from :user-agent:references:from:to:cc:subject:date:message-id:reply-to; bh=86AtuKKO8jbGlVhGBtVivZ3+dn6yJVKvcFL30sNr4n8=; b=do5Dr6POmqMQ2yCTfDac4mGppcPhP+1deTFVm8wn1DiBrpkjMuDTX6MQ+/6n22U6Pe TQZhykq6CDSExSSIEIkBPq4+6EeTA6EM0A+MN4zJTRkV72S+hv1lCzSUtEalXkF5YkQp G3mlgLIneoVosnreioO8JYTJ3FdExJB9jTgx92E3T7JTLcBJGYfDoxIVwKNXLyA7LuKK oeJMy13MZa2bCvC7LyrxPUDCQou9BX278CG1xBxRMy87AFQLpC03HWNFogF9dqcC7vtw lDYE09uqVL7S4qi7rGqOFZdDUwFNtH8P4Tv5LEzphg4JjrZ8EZjvhCSSp46cS5cmvUdo a7mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690506102; x=1691110902; h=mime-version:message-id:date:in-reply-to:subject:cc:to:from :user-agent:references:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=86AtuKKO8jbGlVhGBtVivZ3+dn6yJVKvcFL30sNr4n8=; b=gq8PLUE35anvAXV55w/7eDMbMtDvmJifBz2Pu3teWc3vp/O4WjidYOcKcqZgZui9pF UEQoG6Wbxci2M31yfwTrIhaSTKxLJ8ypW3RWXJz2vVswMTzurUhvkQoKWm0356tqyUqM 75zR51aWwZjfq7TSinwQWPoHEWHWqsWXo+uwrvrT3Z6rbw7l3CJXsOVWA8Vi5Dzi+dwz Qg4GXLptuxfJoI0karUjE2P/qjypmPsL1PIsdfsT54HRcUff1LbqgebLgnTYBjmlykS7 pFHbFnp+yDhiDxLthGjnAN2/erZGWu0BaZ2JhRgXffv2roVCliaxDoQpsXqAC2x2ATe5 wbuQ== X-Gm-Message-State: ABy/qLbCXWhhHQ6T6WNjEKnEroTFn6oJILGkL6RR2ui0IacNyRJTim6o MLpDCfQXXnjERGxrpeYkusDzHw== X-Google-Smtp-Source: APBJJlHGxhe/vyutwJKxRaGdC8o/TZtwa0MV/P2serGzFSaLntyNlVs6Y/JQsISznGl4FSA2YckJVw== X-Received: by 2002:a05:6870:4708:b0:1bb:9dfd:f4dc with SMTP id b8-20020a056870470800b001bb9dfdf4dcmr1146137oaq.19.1690506101797; Thu, 27 Jul 2023 18:01:41 -0700 (PDT) Received: from localhost ([2804:14d:7e39:8470:b6b2:cb77:8e91:bbbd]) by smtp.gmail.com with ESMTPSA id dv50-20020a056870d8b200b001962e45f0d4sm1255718oab.24.2023.07.27.18.01.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jul 2023 18:01:41 -0700 (PDT) References: <20230630134616.1238105-1-luis.machado@arm.com> <20230630134616.1238105-11-luis.machado@arm.com> User-agent: mu4e 1.10.5; emacs 28.2 From: Thiago Jung Bauermann To: Luis Machado Cc: gdb-patches@sourceware.org Subject: Re: [PATCH v3 10/16] [gdb/aarch64] sme: Fixup sigframe gdbarch when vg/svg changes In-reply-to: <20230630134616.1238105-11-luis.machado@arm.com> Date: Thu, 27 Jul 2023 22:01:38 -0300 Message-ID: <87jzuk7sst.fsf@linaro.org> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Luis Machado via Gdb-patches writes: > case AARCH64_SVE_MAGIC: > { > /* Check if the section is followed by a full SVE dump, and set > sve_regs if it is. */ > gdb_byte buf[4]; > - uint16_t flags; > - > - if (!tdep->has_sve ()) > - break; > > + /* Extract the vector length. */ > if (target_read_memory (section + AARCH64_SVE_CONTEXT_VL_OFFSET, > buf, 2) != 0) > { > + warning (_("Failed to read the vector length from the SVE " > + " signal frame context.")); Extraneous space between "SVE" and "signal". > section += size; > break; > } > case AARCH64_ZA_MAGIC: > { > - if (!tdep->has_sme ()) > - { > - section += size; > - break; > - } > - > /* Check if the section is followed by a full ZA dump, and set > za_state if it is. */ > gdb_byte buf[2]; > > + /* Extract the streaming vector length. */ > if (target_read_memory (section + AARCH64_SVE_CONTEXT_VL_OFFSET, Same comment from the previous patch about using the SME macro instead of the SVE one. > buf, 2) != 0) > { > + warning (_("Failed to read the streaming vector length from " > + " ZA signal frame context.")); Extraneous space between "SVE" and "signal". > section += size; > break; > } > @@ -477,11 +499,49 @@ aarch64_linux_sigframe_init (const struct tramp_frame *self, > if (!extra_found && section > section_end) > break; > } > +} > + > +/* Implement the "init" method of struct tramp_frame. */ > + > +static void > +aarch64_linux_sigframe_init (const struct tramp_frame *self, > + frame_info_ptr this_frame, > + struct trad_frame_cache *this_cache, > + CORE_ADDR func) > +{ > + /* Read the signal context information. */ > + struct aarch64_linux_sigframe signal_frame; > + aarch64_linux_read_signal_frame_info (this_frame, signal_frame); > + > + /* Now we have all the data required to restore the registers from the > + signal frame. */ > + > + /* Restore the general purpose registers. */ > + CORE_ADDR offset > + = signal_frame.sigcontext_address + AARCH64_SIGCONTEXT_XO_OFFSET; You can simplify the above to CORE_ADDR offset = signal_frame.gpr_section; > + for (int i = 0; i < 31; i++) > + { > + trad_frame_set_reg_addr (this_cache, AARCH64_X0_REGNUM + i, offset); > + offset += AARCH64_SIGCONTEXT_REG_SIZE; > + } > + trad_frame_set_reg_addr (this_cache, AARCH64_SP_REGNUM, offset); > + offset += AARCH64_SIGCONTEXT_REG_SIZE; > + trad_frame_set_reg_addr (this_cache, AARCH64_PC_REGNUM, offset); > diff --git a/gdb/tramp-frame.h b/gdb/tramp-frame.h > index fa0241acb2d..563c34ae595 100644 > --- a/gdb/tramp-frame.h > +++ b/gdb/tramp-frame.h > @@ -42,6 +42,13 @@ struct trad_frame_cache; > instruction sequence. */ > #define TRAMP_SENTINEL_INSN ULONGEST_MAX > > +/* Assuming the frame chain: (outer) prev <-> this <-> next (inner); > + use THIS frame, and implicitly the NEXT frame's register unwind > + method, return PREV frame's architecture. */ Maybe s/return/to return/ ? > + > +typedef struct gdbarch *(frame_prev_arch_ftype) (frame_info_ptr this_frame, > + void **this_prologue_cache); > + > struct tramp_frame > { > /* The trampoline's type, some a signal trampolines, some are normal > @@ -75,6 +82,11 @@ struct tramp_frame > int (*validate) (const struct tramp_frame *self, > frame_info_ptr this_frame, > CORE_ADDR *pc); > + > + /* Given the current frame in THIS_FRAME and a frame cache in FRAME_CACHE, > + return the architecture of the previous frame. */ > + struct gdbarch *(*prev_arch) (frame_info_ptr this_frame, > + void **frame_cache); Shouldn't the typedef defined above be used here? > }; -- Thiago