From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1585) id 1BE7338476D8; Tue, 31 Jan 2023 14:32:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1BE7338476D8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1675175558; bh=Y6z9HCxRUAlrAYt9HG9uNhwGOw6nOjBJJwkuD5WU13o=; h=From:To:Subject:Date:From; b=roCuf4k19We30ekU1xLGLMn6t4PRF2ZJwOW+qVFu+yr6a27TYntT4Xsaxi3V70B0i hC7p699Ap2mXRUajtb6CX+GYqiSHuUOw5ll+rHlvUScDAwuxKqNqnN08IwR+N8i38h Qs+d2/4S0Cdt5Qn07Y2ApXWZXXSUORzMsIUeTyYs= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Luis Machado To: gdb-cvs@sourceware.org Subject: [binutils-gdb/gdb-13-branch] gdb/arm: Use new dwarf2 function cache X-Act-Checkin: binutils-gdb X-Git-Author: =?utf-8?q?Torbj=C3=B6rn_SVENSSON?= X-Git-Refname: refs/heads/gdb-13-branch X-Git-Oldrev: 2d36c9404e360126551fef20f3f79f5a56f6ad8b X-Git-Newrev: 7944d457903af4ba966df2a48aa6a2582b823b55 Message-Id: <20230131143238.1BE7338476D8@sourceware.org> Date: Tue, 31 Jan 2023 14:32:38 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D7944d457903a= f4ba966df2a48aa6a2582b823b55 commit 7944d457903af4ba966df2a48aa6a2582b823b55 Author: Torbj=C3=B6rn SVENSSON Date: Thu Nov 17 12:18:20 2022 +0100 gdb/arm: Use new dwarf2 function cache =20 This patch resolves the performance issue reported in pr/29738 by caching the values for the stack pointers for the inner frame. By doing so, the impact can be reduced to checking the state and returning the appropriate value. =20 Signed-off-by: Torbj=C3=B6rn SVENSSON Signed-off-by: Yvan Roux Diff: --- gdb/arm-tdep.c | 97 +++++++++++++++++++++++++++++++++++++++---------------= ---- 1 file changed, 65 insertions(+), 32 deletions(-) diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c index 18463d0f945..58b9c5f4bd8 100644 --- a/gdb/arm-tdep.c +++ b/gdb/arm-tdep.c @@ -3964,6 +3964,18 @@ struct frame_base arm_normal_base =3D { arm_normal_frame_base }; =20 +struct arm_dwarf2_prev_register_cache +{ + /* Cached value of the coresponding stack pointer for the inner frame. = */ + CORE_ADDR sp; + CORE_ADDR msp; + CORE_ADDR msp_s; + CORE_ADDR msp_ns; + CORE_ADDR psp; + CORE_ADDR psp_s; + CORE_ADDR psp_ns; +}; + static struct value * arm_dwarf2_prev_register (frame_info_ptr this_frame, void **this_cache, int regnum) @@ -3972,6 +3984,49 @@ arm_dwarf2_prev_register (frame_info_ptr this_frame,= void **this_cache, arm_gdbarch_tdep *tdep =3D gdbarch_tdep (gdbarch); CORE_ADDR lr; ULONGEST cpsr; + arm_dwarf2_prev_register_cache *cache + =3D ((arm_dwarf2_prev_register_cache *) + dwarf2_frame_get_fn_data (this_frame, this_cache, + arm_dwarf2_prev_register)); + + if (!cache) + { + const unsigned int size =3D sizeof (struct arm_dwarf2_prev_register_= cache); + cache =3D ((arm_dwarf2_prev_register_cache *) + dwarf2_frame_allocate_fn_data (this_frame, this_cache, + arm_dwarf2_prev_register, size)); + + if (tdep->have_sec_ext) + { + cache->sp + =3D get_frame_register_unsigned (this_frame, ARM_SP_REGNUM); + + cache->msp_s + =3D get_frame_register_unsigned (this_frame, + tdep->m_profile_msp_s_regnum); + cache->msp_ns + =3D get_frame_register_unsigned (this_frame, + tdep->m_profile_msp_ns_regnum); + cache->psp_s + =3D get_frame_register_unsigned (this_frame, + tdep->m_profile_psp_s_regnum); + cache->psp_ns + =3D get_frame_register_unsigned (this_frame, + tdep->m_profile_psp_ns_regnum); + } + else if (tdep->is_m) + { + cache->sp + =3D get_frame_register_unsigned (this_frame, ARM_SP_REGNUM); + + cache->msp + =3D get_frame_register_unsigned (this_frame, + tdep->m_profile_msp_regnum); + cache->psp + =3D get_frame_register_unsigned (this_frame, + tdep->m_profile_psp_regnum); + } + } =20 if (regnum =3D=3D ARM_PC_REGNUM) { @@ -4011,33 +4066,18 @@ arm_dwarf2_prev_register (frame_info_ptr this_frame= , void **this_cache, =20 if (tdep->have_sec_ext) { - CORE_ADDR sp - =3D get_frame_register_unsigned (this_frame, ARM_SP_REGNUM); - CORE_ADDR msp_s - =3D get_frame_register_unsigned (this_frame, - tdep->m_profile_msp_s_regnum); - CORE_ADDR msp_ns - =3D get_frame_register_unsigned (this_frame, - tdep->m_profile_msp_ns_regnum); - CORE_ADDR psp_s - =3D get_frame_register_unsigned (this_frame, - tdep->m_profile_psp_s_regnum); - CORE_ADDR psp_ns - =3D get_frame_register_unsigned (this_frame, - tdep->m_profile_psp_ns_regnum); - bool is_msp =3D (regnum =3D=3D tdep->m_profile_msp_regnum) - && (msp_s =3D=3D sp || msp_ns =3D=3D sp); + && (cache->msp_s =3D=3D cache->sp || cache->msp_ns =3D=3D cache->sp); bool is_msp_s =3D (regnum =3D=3D tdep->m_profile_msp_s_regnum) - && (msp_s =3D=3D sp); + && (cache->msp_s =3D=3D cache->sp); bool is_msp_ns =3D (regnum =3D=3D tdep->m_profile_msp_ns_regnum) - && (msp_ns =3D=3D sp); + && (cache->msp_ns =3D=3D cache->sp); bool is_psp =3D (regnum =3D=3D tdep->m_profile_psp_regnum) - && (psp_s =3D=3D sp || psp_ns =3D=3D sp); + && (cache->psp_s =3D=3D cache->sp || cache->psp_ns =3D=3D cache->sp); bool is_psp_s =3D (regnum =3D=3D tdep->m_profile_psp_s_regnum) - && (psp_s =3D=3D sp); + && (cache->psp_s =3D=3D cache->sp); bool is_psp_ns =3D (regnum =3D=3D tdep->m_profile_psp_ns_regnum) - && (psp_ns =3D=3D sp); + && (cache->psp_ns =3D=3D cache->sp); =20 override_with_sp_value =3D is_msp || is_msp_s || is_msp_ns || is_psp || is_psp_s || is_psp_ns; @@ -4045,17 +4085,10 @@ arm_dwarf2_prev_register (frame_info_ptr this_frame= , void **this_cache, } else if (tdep->is_m) { - CORE_ADDR sp - =3D get_frame_register_unsigned (this_frame, ARM_SP_REGNUM); - CORE_ADDR msp - =3D get_frame_register_unsigned (this_frame, - tdep->m_profile_msp_regnum); - CORE_ADDR psp - =3D get_frame_register_unsigned (this_frame, - tdep->m_profile_psp_regnum); - - bool is_msp =3D (regnum =3D=3D tdep->m_profile_msp_regnum) && (sp =3D= =3D msp); - bool is_psp =3D (regnum =3D=3D tdep->m_profile_psp_regnum) && (sp =3D= =3D psp); + bool is_msp =3D (regnum =3D=3D tdep->m_profile_msp_regnum) + && (cache->sp =3D=3D cache->msp); + bool is_psp =3D (regnum =3D=3D tdep->m_profile_psp_regnum) + && (cache->sp =3D=3D cache->psp); =20 override_with_sp_value =3D is_msp || is_psp; }