Skip to content

Commit 5cf1148

Browse files
gdb/arm: Use new dwarf2 function cache
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. Signed-off-by: Torbjörn SVENSSON <[email protected]> Signed-off-by: Yvan Roux <[email protected]>
1 parent d72ba17 commit 5cf1148

File tree

1 file changed

+65
-32
lines changed

1 file changed

+65
-32
lines changed

gdb/arm-tdep.c

Lines changed: 65 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3965,6 +3965,18 @@ struct frame_base arm_normal_base = {
39653965
arm_normal_frame_base
39663966
};
39673967

3968+
struct arm_dwarf2_prev_register_cache
3969+
{
3970+
/* Cached value of the coresponding stack pointer for the inner frame. */
3971+
CORE_ADDR sp;
3972+
CORE_ADDR msp;
3973+
CORE_ADDR msp_s;
3974+
CORE_ADDR msp_ns;
3975+
CORE_ADDR psp;
3976+
CORE_ADDR psp_s;
3977+
CORE_ADDR psp_ns;
3978+
};
3979+
39683980
static struct value *
39693981
arm_dwarf2_prev_register (frame_info_ptr this_frame, void **this_cache,
39703982
int regnum)
@@ -3973,6 +3985,49 @@ arm_dwarf2_prev_register (frame_info_ptr this_frame, void **this_cache,
39733985
arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (gdbarch);
39743986
CORE_ADDR lr;
39753987
ULONGEST cpsr;
3988+
arm_dwarf2_prev_register_cache *cache
3989+
= ((arm_dwarf2_prev_register_cache *)
3990+
dwarf2_frame_get_fn_data (this_frame, this_cache,
3991+
arm_dwarf2_prev_register));
3992+
3993+
if (!cache)
3994+
{
3995+
const unsigned int size = sizeof (struct arm_dwarf2_prev_register_cache);
3996+
cache = ((arm_dwarf2_prev_register_cache *)
3997+
dwarf2_frame_allocate_fn_data (this_frame, this_cache,
3998+
arm_dwarf2_prev_register, size));
3999+
4000+
if (tdep->have_sec_ext)
4001+
{
4002+
cache->sp
4003+
= get_frame_register_unsigned (this_frame, ARM_SP_REGNUM);
4004+
4005+
cache->msp_s
4006+
= get_frame_register_unsigned (this_frame,
4007+
tdep->m_profile_msp_s_regnum);
4008+
cache->msp_ns
4009+
= get_frame_register_unsigned (this_frame,
4010+
tdep->m_profile_msp_ns_regnum);
4011+
cache->psp_s
4012+
= get_frame_register_unsigned (this_frame,
4013+
tdep->m_profile_psp_s_regnum);
4014+
cache->psp_ns
4015+
= get_frame_register_unsigned (this_frame,
4016+
tdep->m_profile_psp_ns_regnum);
4017+
}
4018+
else if (tdep->is_m)
4019+
{
4020+
cache->sp
4021+
= get_frame_register_unsigned (this_frame, ARM_SP_REGNUM);
4022+
4023+
cache->msp
4024+
= get_frame_register_unsigned (this_frame,
4025+
tdep->m_profile_msp_regnum);
4026+
cache->psp
4027+
= get_frame_register_unsigned (this_frame,
4028+
tdep->m_profile_psp_regnum);
4029+
}
4030+
}
39764031

39774032
if (regnum == ARM_PC_REGNUM)
39784033
{
@@ -4012,51 +4067,29 @@ arm_dwarf2_prev_register (frame_info_ptr this_frame, void **this_cache,
40124067

40134068
if (tdep->have_sec_ext)
40144069
{
4015-
CORE_ADDR sp
4016-
= get_frame_register_unsigned (this_frame, ARM_SP_REGNUM);
4017-
CORE_ADDR msp_s
4018-
= get_frame_register_unsigned (this_frame,
4019-
tdep->m_profile_msp_s_regnum);
4020-
CORE_ADDR msp_ns
4021-
= get_frame_register_unsigned (this_frame,
4022-
tdep->m_profile_msp_ns_regnum);
4023-
CORE_ADDR psp_s
4024-
= get_frame_register_unsigned (this_frame,
4025-
tdep->m_profile_psp_s_regnum);
4026-
CORE_ADDR psp_ns
4027-
= get_frame_register_unsigned (this_frame,
4028-
tdep->m_profile_psp_ns_regnum);
4029-
40304070
bool is_msp = (regnum == tdep->m_profile_msp_regnum)
4031-
&& (msp_s == sp || msp_ns == sp);
4071+
&& (cache->msp_s == cache->sp || cache->msp_ns == cache->sp);
40324072
bool is_msp_s = (regnum == tdep->m_profile_msp_s_regnum)
4033-
&& (msp_s == sp);
4073+
&& (cache->msp_s == cache->sp);
40344074
bool is_msp_ns = (regnum == tdep->m_profile_msp_ns_regnum)
4035-
&& (msp_ns == sp);
4075+
&& (cache->msp_ns == cache->sp);
40364076
bool is_psp = (regnum == tdep->m_profile_psp_regnum)
4037-
&& (psp_s == sp || psp_ns == sp);
4077+
&& (cache->psp_s == cache->sp || cache->psp_ns == cache->sp);
40384078
bool is_psp_s = (regnum == tdep->m_profile_psp_s_regnum)
4039-
&& (psp_s == sp);
4079+
&& (cache->psp_s == cache->sp);
40404080
bool is_psp_ns = (regnum == tdep->m_profile_psp_ns_regnum)
4041-
&& (psp_ns == sp);
4081+
&& (cache->psp_ns == cache->sp);
40424082

40434083
override_with_sp_value = is_msp || is_msp_s || is_msp_ns
40444084
|| is_psp || is_psp_s || is_psp_ns;
40454085

40464086
}
40474087
else if (tdep->is_m)
40484088
{
4049-
CORE_ADDR sp
4050-
= get_frame_register_unsigned (this_frame, ARM_SP_REGNUM);
4051-
CORE_ADDR msp
4052-
= get_frame_register_unsigned (this_frame,
4053-
tdep->m_profile_msp_regnum);
4054-
CORE_ADDR psp
4055-
= get_frame_register_unsigned (this_frame,
4056-
tdep->m_profile_psp_regnum);
4057-
4058-
bool is_msp = (regnum == tdep->m_profile_msp_regnum) && (sp == msp);
4059-
bool is_psp = (regnum == tdep->m_profile_psp_regnum) && (sp == psp);
4089+
bool is_msp = (regnum == tdep->m_profile_msp_regnum)
4090+
&& (cache->sp == cache->msp);
4091+
bool is_psp = (regnum == tdep->m_profile_psp_regnum)
4092+
&& (cache->sp == cache->psp);
40604093

40614094
override_with_sp_value = is_msp || is_psp;
40624095
}

0 commit comments

Comments
 (0)