Skip to content

Commit 0949043

Browse files
committed
Revert "[lldb] Return *const* UnwindPlan pointers from FuncUnwinders (#133247)"
This reverts commit d7afafd. Caused remote Linux to Linux buildbot failure https://lab.llvm.org/buildbot/#/builders/195/builds/7046.
1 parent 6f324bd commit 0949043

File tree

7 files changed

+250
-247
lines changed

7 files changed

+250
-247
lines changed

lldb/include/lldb/Symbol/FuncUnwinders.h

Lines changed: 37 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,18 @@ class FuncUnwinders {
3636

3737
~FuncUnwinders();
3838

39-
std::shared_ptr<const UnwindPlan> GetUnwindPlanAtCallSite(Target &target,
40-
Thread &thread);
39+
lldb::UnwindPlanSP GetUnwindPlanAtCallSite(Target &target, Thread &thread);
4140

42-
std::shared_ptr<const UnwindPlan>
43-
GetUnwindPlanAtNonCallSite(Target &target, lldb_private::Thread &thread);
41+
lldb::UnwindPlanSP GetUnwindPlanAtNonCallSite(Target &target,
42+
lldb_private::Thread &thread);
4443

45-
std::shared_ptr<const UnwindPlan>
46-
GetUnwindPlanFastUnwind(Target &target, lldb_private::Thread &thread);
44+
lldb::UnwindPlanSP GetUnwindPlanFastUnwind(Target &target,
45+
lldb_private::Thread &thread);
4746

48-
std::shared_ptr<const UnwindPlan>
47+
lldb::UnwindPlanSP
4948
GetUnwindPlanArchitectureDefault(lldb_private::Thread &thread);
5049

51-
std::shared_ptr<const UnwindPlan>
50+
lldb::UnwindPlanSP
5251
GetUnwindPlanArchitectureDefaultAtFunctionEntry(lldb_private::Thread &thread);
5352

5453
Address &GetFirstNonPrologueInsn(Target &target);
@@ -78,34 +77,32 @@ class FuncUnwinders {
7877
// used. Instead, clients should ask for the *behavior* they are looking for,
7978
// using one of the above UnwindPlan retrieval methods.
8079

81-
std::shared_ptr<const UnwindPlan> GetAssemblyUnwindPlan(Target &target,
82-
Thread &thread);
80+
lldb::UnwindPlanSP GetAssemblyUnwindPlan(Target &target, Thread &thread);
8381

84-
std::shared_ptr<const UnwindPlan> GetObjectFileUnwindPlan(Target &target);
82+
lldb::UnwindPlanSP GetObjectFileUnwindPlan(Target &target);
8583

86-
std::shared_ptr<const UnwindPlan>
87-
GetObjectFileAugmentedUnwindPlan(Target &target, Thread &thread);
84+
lldb::UnwindPlanSP GetObjectFileAugmentedUnwindPlan(Target &target,
85+
Thread &thread);
8886

89-
std::shared_ptr<const UnwindPlan> GetEHFrameUnwindPlan(Target &target);
87+
lldb::UnwindPlanSP GetEHFrameUnwindPlan(Target &target);
9088

91-
std::shared_ptr<const UnwindPlan>
92-
GetEHFrameAugmentedUnwindPlan(Target &target, Thread &thread);
89+
lldb::UnwindPlanSP GetEHFrameAugmentedUnwindPlan(Target &target,
90+
Thread &thread);
9391

94-
std::shared_ptr<const UnwindPlan> GetDebugFrameUnwindPlan(Target &target);
92+
lldb::UnwindPlanSP GetDebugFrameUnwindPlan(Target &target);
9593

96-
std::shared_ptr<const UnwindPlan>
97-
GetDebugFrameAugmentedUnwindPlan(Target &target, Thread &thread);
94+
lldb::UnwindPlanSP GetDebugFrameAugmentedUnwindPlan(Target &target,
95+
Thread &thread);
9896

99-
std::shared_ptr<const UnwindPlan> GetCompactUnwindUnwindPlan(Target &target);
97+
lldb::UnwindPlanSP GetCompactUnwindUnwindPlan(Target &target);
10098

101-
std::shared_ptr<const UnwindPlan> GetArmUnwindUnwindPlan(Target &target);
99+
lldb::UnwindPlanSP GetArmUnwindUnwindPlan(Target &target);
102100

103-
std::shared_ptr<const UnwindPlan> GetSymbolFileUnwindPlan(Thread &thread);
101+
lldb::UnwindPlanSP GetSymbolFileUnwindPlan(Thread &thread);
104102

105-
std::shared_ptr<const UnwindPlan> GetArchDefaultUnwindPlan(Thread &thread);
103+
lldb::UnwindPlanSP GetArchDefaultUnwindPlan(Thread &thread);
106104

107-
std::shared_ptr<const UnwindPlan>
108-
GetArchDefaultAtFuncEntryUnwindPlan(Thread &thread);
105+
lldb::UnwindPlanSP GetArchDefaultAtFuncEntryUnwindPlan(Thread &thread);
109106

110107
private:
111108
lldb::UnwindAssemblySP GetUnwindAssemblyProfiler(Target &target);
@@ -116,8 +113,7 @@ class FuncUnwinders {
116113
// unwind rule for the pc, and LazyBoolCalculate if it was unable to
117114
// determine this for some reason.
118115
lldb_private::LazyBool CompareUnwindPlansForIdenticalInitialPCLocation(
119-
Thread &thread, const std::shared_ptr<const UnwindPlan> &a,
120-
const std::shared_ptr<const UnwindPlan> &b);
116+
Thread &thread, const lldb::UnwindPlanSP &a, const lldb::UnwindPlanSP &b);
121117

122118
UnwindTable &m_unwind_table;
123119

@@ -133,22 +129,22 @@ class FuncUnwinders {
133129

134130
std::recursive_mutex m_mutex;
135131

136-
std::shared_ptr<const UnwindPlan> m_unwind_plan_assembly_sp;
137-
std::shared_ptr<const UnwindPlan> m_unwind_plan_object_file_sp;
138-
std::shared_ptr<const UnwindPlan> m_unwind_plan_eh_frame_sp;
139-
std::shared_ptr<const UnwindPlan> m_unwind_plan_debug_frame_sp;
132+
lldb::UnwindPlanSP m_unwind_plan_assembly_sp;
133+
lldb::UnwindPlanSP m_unwind_plan_object_file_sp;
134+
lldb::UnwindPlanSP m_unwind_plan_eh_frame_sp;
135+
lldb::UnwindPlanSP m_unwind_plan_debug_frame_sp;
140136

141137
// augmented by assembly inspection so it's valid everywhere
142-
std::shared_ptr<const UnwindPlan> m_unwind_plan_object_file_augmented_sp;
143-
std::shared_ptr<const UnwindPlan> m_unwind_plan_eh_frame_augmented_sp;
144-
std::shared_ptr<const UnwindPlan> m_unwind_plan_debug_frame_augmented_sp;
145-
146-
std::vector<std::shared_ptr<const UnwindPlan>> m_unwind_plan_compact_unwind;
147-
std::shared_ptr<const UnwindPlan> m_unwind_plan_arm_unwind_sp;
148-
std::shared_ptr<const UnwindPlan> m_unwind_plan_symbol_file_sp;
149-
std::shared_ptr<const UnwindPlan> m_unwind_plan_fast_sp;
150-
std::shared_ptr<const UnwindPlan> m_unwind_plan_arch_default_sp;
151-
std::shared_ptr<const UnwindPlan> m_unwind_plan_arch_default_at_func_entry_sp;
138+
lldb::UnwindPlanSP m_unwind_plan_object_file_augmented_sp;
139+
lldb::UnwindPlanSP m_unwind_plan_eh_frame_augmented_sp;
140+
lldb::UnwindPlanSP m_unwind_plan_debug_frame_augmented_sp;
141+
142+
std::vector<lldb::UnwindPlanSP> m_unwind_plan_compact_unwind;
143+
lldb::UnwindPlanSP m_unwind_plan_arm_unwind_sp;
144+
lldb::UnwindPlanSP m_unwind_plan_symbol_file_sp;
145+
lldb::UnwindPlanSP m_unwind_plan_fast_sp;
146+
lldb::UnwindPlanSP m_unwind_plan_arch_default_sp;
147+
lldb::UnwindPlanSP m_unwind_plan_arch_default_at_func_entry_sp;
152148

153149
// Fetching the UnwindPlans can be expensive - if we've already attempted to
154150
// get one & failed, don't try again.

lldb/include/lldb/Symbol/UnwindPlan.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ class UnwindPlan {
482482
m_return_addr_register = regnum;
483483
}
484484

485-
uint32_t GetReturnAddressRegister() const { return m_return_addr_register; }
485+
uint32_t GetReturnAddressRegister() { return m_return_addr_register; }
486486

487487
uint32_t GetInitialCFARegister() const {
488488
if (m_row_list.empty())
@@ -497,7 +497,7 @@ class UnwindPlan {
497497
m_plan_valid_ranges = std::move(ranges);
498498
}
499499

500-
bool PlanValidAtAddress(Address addr) const;
500+
bool PlanValidAtAddress(Address addr);
501501

502502
bool IsValidRowIndex(uint32_t idx) const;
503503

lldb/include/lldb/Target/RegisterContextUnwind.h

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,7 @@ class RegisterContextUnwind : public lldb_private::RegisterContext {
127127

128128
/// Check if the given unwind plan indicates a signal trap handler, and
129129
/// update frame type and symbol context if so.
130-
void PropagateTrapHandlerFlagFromUnwindPlan(
131-
std::shared_ptr<const UnwindPlan> unwind_plan);
130+
void PropagateTrapHandlerFlagFromUnwindPlan(lldb::UnwindPlanSP unwind_plan);
132131

133132
// Provide a location for where THIS function saved the CALLER's register
134133
// value
@@ -195,17 +194,16 @@ class RegisterContextUnwind : public lldb_private::RegisterContext {
195194
const UnwindPlan::Row::FAValue &fa,
196195
lldb::addr_t &address);
197196

198-
std::shared_ptr<const UnwindPlan> GetFastUnwindPlanForFrame();
197+
lldb::UnwindPlanSP GetFastUnwindPlanForFrame();
199198

200-
std::shared_ptr<const UnwindPlan> GetFullUnwindPlanForFrame();
199+
lldb::UnwindPlanSP GetFullUnwindPlanForFrame();
201200

202201
void UnwindLogMsg(const char *fmt, ...) __attribute__((format(printf, 2, 3)));
203202

204203
void UnwindLogMsgVerbose(const char *fmt, ...)
205204
__attribute__((format(printf, 2, 3)));
206205

207-
bool IsUnwindPlanValidForCurrentPC(
208-
std::shared_ptr<const UnwindPlan> unwind_plan_sp);
206+
bool IsUnwindPlanValidForCurrentPC(lldb::UnwindPlanSP unwind_plan_sp);
209207

210208
lldb::addr_t GetReturnAddressHint(int32_t plan_offset);
211209

@@ -217,9 +215,9 @@ class RegisterContextUnwind : public lldb_private::RegisterContext {
217215
// i.e. where THIS frame saved them
218216
///
219217

220-
std::shared_ptr<const UnwindPlan> m_fast_unwind_plan_sp; // may be NULL
221-
std::shared_ptr<const UnwindPlan> m_full_unwind_plan_sp;
222-
std::shared_ptr<const UnwindPlan> m_fallback_unwind_plan_sp; // may be NULL
218+
lldb::UnwindPlanSP m_fast_unwind_plan_sp; // may be NULL
219+
lldb::UnwindPlanSP m_full_unwind_plan_sp;
220+
lldb::UnwindPlanSP m_fallback_unwind_plan_sp; // may be NULL
223221

224222
bool m_all_registers_available; // Can we retrieve all regs or just
225223
// nonvolatile regs?

lldb/source/Commands/CommandObjectTarget.cpp

Lines changed: 57 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -3641,78 +3641,85 @@ class CommandObjectTargetModulesShowUnwind : public CommandObjectParsed {
36413641

36423642
result.GetOutputStream().Printf("\n");
36433643

3644-
if (std::shared_ptr<const UnwindPlan> plan_sp =
3645-
func_unwinders_sp->GetUnwindPlanAtNonCallSite(*target, *thread)) {
3644+
UnwindPlanSP non_callsite_unwind_plan =
3645+
func_unwinders_sp->GetUnwindPlanAtNonCallSite(*target, *thread);
3646+
if (non_callsite_unwind_plan) {
36463647
result.GetOutputStream().Printf(
36473648
"Asynchronous (not restricted to call-sites) UnwindPlan is '%s'\n",
3648-
plan_sp->GetSourceName().AsCString());
3649+
non_callsite_unwind_plan->GetSourceName().AsCString());
36493650
}
3650-
if (std::shared_ptr<const UnwindPlan> plan_sp =
3651-
func_unwinders_sp->GetUnwindPlanAtCallSite(*target, *thread)) {
3651+
UnwindPlanSP callsite_unwind_plan =
3652+
func_unwinders_sp->GetUnwindPlanAtCallSite(*target, *thread);
3653+
if (callsite_unwind_plan) {
36523654
result.GetOutputStream().Printf(
36533655
"Synchronous (restricted to call-sites) UnwindPlan is '%s'\n",
3654-
plan_sp->GetSourceName().AsCString());
3656+
callsite_unwind_plan->GetSourceName().AsCString());
36553657
}
3656-
if (std::shared_ptr<const UnwindPlan> plan_sp =
3657-
func_unwinders_sp->GetUnwindPlanFastUnwind(*target, *thread)) {
3658-
result.GetOutputStream().Printf("Fast UnwindPlan is '%s'\n",
3659-
plan_sp->GetSourceName().AsCString());
3658+
UnwindPlanSP fast_unwind_plan =
3659+
func_unwinders_sp->GetUnwindPlanFastUnwind(*target, *thread);
3660+
if (fast_unwind_plan) {
3661+
result.GetOutputStream().Printf(
3662+
"Fast UnwindPlan is '%s'\n",
3663+
fast_unwind_plan->GetSourceName().AsCString());
36603664
}
36613665

36623666
result.GetOutputStream().Printf("\n");
36633667

3664-
if (std::shared_ptr<const UnwindPlan> plan_sp =
3665-
func_unwinders_sp->GetAssemblyUnwindPlan(*target, *thread)) {
3668+
UnwindPlanSP assembly_sp =
3669+
func_unwinders_sp->GetAssemblyUnwindPlan(*target, *thread);
3670+
if (assembly_sp) {
36663671
result.GetOutputStream().Printf(
36673672
"Assembly language inspection UnwindPlan:\n");
3668-
plan_sp->Dump(result.GetOutputStream(), thread.get(),
3669-
LLDB_INVALID_ADDRESS);
3673+
assembly_sp->Dump(result.GetOutputStream(), thread.get(),
3674+
LLDB_INVALID_ADDRESS);
36703675
result.GetOutputStream().Printf("\n");
36713676
}
36723677

3673-
if (std::shared_ptr<const UnwindPlan> plan_sp =
3674-
func_unwinders_sp->GetObjectFileUnwindPlan(*target)) {
3678+
UnwindPlanSP of_unwind_sp =
3679+
func_unwinders_sp->GetObjectFileUnwindPlan(*target);
3680+
if (of_unwind_sp) {
36753681
result.GetOutputStream().Printf("object file UnwindPlan:\n");
3676-
plan_sp->Dump(result.GetOutputStream(), thread.get(),
3677-
LLDB_INVALID_ADDRESS);
3682+
of_unwind_sp->Dump(result.GetOutputStream(), thread.get(),
3683+
LLDB_INVALID_ADDRESS);
36783684
result.GetOutputStream().Printf("\n");
36793685
}
36803686

3681-
if (std::shared_ptr<const UnwindPlan> plan_sp =
3682-
func_unwinders_sp->GetObjectFileAugmentedUnwindPlan(*target,
3683-
*thread)) {
3687+
UnwindPlanSP of_unwind_augmented_sp =
3688+
func_unwinders_sp->GetObjectFileAugmentedUnwindPlan(*target, *thread);
3689+
if (of_unwind_augmented_sp) {
36843690
result.GetOutputStream().Printf("object file augmented UnwindPlan:\n");
3685-
plan_sp->Dump(result.GetOutputStream(), thread.get(),
3686-
LLDB_INVALID_ADDRESS);
3691+
of_unwind_augmented_sp->Dump(result.GetOutputStream(), thread.get(),
3692+
LLDB_INVALID_ADDRESS);
36873693
result.GetOutputStream().Printf("\n");
36883694
}
36893695

3690-
if (std::shared_ptr<const UnwindPlan> plan_sp =
3691-
func_unwinders_sp->GetEHFrameUnwindPlan(*target)) {
3696+
UnwindPlanSP ehframe_sp =
3697+
func_unwinders_sp->GetEHFrameUnwindPlan(*target);
3698+
if (ehframe_sp) {
36923699
result.GetOutputStream().Printf("eh_frame UnwindPlan:\n");
3693-
plan_sp->Dump(result.GetOutputStream(), thread.get(),
3694-
LLDB_INVALID_ADDRESS);
3700+
ehframe_sp->Dump(result.GetOutputStream(), thread.get(),
3701+
LLDB_INVALID_ADDRESS);
36953702
result.GetOutputStream().Printf("\n");
36963703
}
36973704

3698-
if (std::shared_ptr<const UnwindPlan> plan_sp =
3699-
func_unwinders_sp->GetEHFrameAugmentedUnwindPlan(*target,
3700-
*thread)) {
3705+
UnwindPlanSP ehframe_augmented_sp =
3706+
func_unwinders_sp->GetEHFrameAugmentedUnwindPlan(*target, *thread);
3707+
if (ehframe_augmented_sp) {
37013708
result.GetOutputStream().Printf("eh_frame augmented UnwindPlan:\n");
3702-
plan_sp->Dump(result.GetOutputStream(), thread.get(),
3703-
LLDB_INVALID_ADDRESS);
3709+
ehframe_augmented_sp->Dump(result.GetOutputStream(), thread.get(),
3710+
LLDB_INVALID_ADDRESS);
37043711
result.GetOutputStream().Printf("\n");
37053712
}
37063713

3707-
if (std::shared_ptr<const UnwindPlan> plan_sp =
3714+
if (UnwindPlanSP plan_sp =
37083715
func_unwinders_sp->GetDebugFrameUnwindPlan(*target)) {
37093716
result.GetOutputStream().Printf("debug_frame UnwindPlan:\n");
37103717
plan_sp->Dump(result.GetOutputStream(), thread.get(),
37113718
LLDB_INVALID_ADDRESS);
37123719
result.GetOutputStream().Printf("\n");
37133720
}
37143721

3715-
if (std::shared_ptr<const UnwindPlan> plan_sp =
3722+
if (UnwindPlanSP plan_sp =
37163723
func_unwinders_sp->GetDebugFrameAugmentedUnwindPlan(*target,
37173724
*thread)) {
37183725
result.GetOutputStream().Printf("debug_frame augmented UnwindPlan:\n");
@@ -3721,35 +3728,36 @@ class CommandObjectTargetModulesShowUnwind : public CommandObjectParsed {
37213728
result.GetOutputStream().Printf("\n");
37223729
}
37233730

3724-
if (std::shared_ptr<const UnwindPlan> plan_sp =
3725-
func_unwinders_sp->GetArmUnwindUnwindPlan(*target)) {
3731+
UnwindPlanSP arm_unwind_sp =
3732+
func_unwinders_sp->GetArmUnwindUnwindPlan(*target);
3733+
if (arm_unwind_sp) {
37263734
result.GetOutputStream().Printf("ARM.exidx unwind UnwindPlan:\n");
3727-
plan_sp->Dump(result.GetOutputStream(), thread.get(),
3728-
LLDB_INVALID_ADDRESS);
3735+
arm_unwind_sp->Dump(result.GetOutputStream(), thread.get(),
3736+
LLDB_INVALID_ADDRESS);
37293737
result.GetOutputStream().Printf("\n");
37303738
}
37313739

3732-
if (std::shared_ptr<const UnwindPlan> plan_sp =
3740+
if (UnwindPlanSP symfile_plan_sp =
37333741
func_unwinders_sp->GetSymbolFileUnwindPlan(*thread)) {
37343742
result.GetOutputStream().Printf("Symbol file UnwindPlan:\n");
3735-
plan_sp->Dump(result.GetOutputStream(), thread.get(),
3736-
LLDB_INVALID_ADDRESS);
3743+
symfile_plan_sp->Dump(result.GetOutputStream(), thread.get(),
3744+
LLDB_INVALID_ADDRESS);
37373745
result.GetOutputStream().Printf("\n");
37383746
}
37393747

3740-
if (std::shared_ptr<const UnwindPlan> plan_sp =
3741-
func_unwinders_sp->GetCompactUnwindUnwindPlan(*target)) {
3748+
UnwindPlanSP compact_unwind_sp =
3749+
func_unwinders_sp->GetCompactUnwindUnwindPlan(*target);
3750+
if (compact_unwind_sp) {
37423751
result.GetOutputStream().Printf("Compact unwind UnwindPlan:\n");
3743-
plan_sp->Dump(result.GetOutputStream(), thread.get(),
3744-
LLDB_INVALID_ADDRESS);
3752+
compact_unwind_sp->Dump(result.GetOutputStream(), thread.get(),
3753+
LLDB_INVALID_ADDRESS);
37453754
result.GetOutputStream().Printf("\n");
37463755
}
37473756

3748-
if (std::shared_ptr<const UnwindPlan> plan_sp =
3749-
func_unwinders_sp->GetUnwindPlanFastUnwind(*target, *thread)) {
3757+
if (fast_unwind_plan) {
37503758
result.GetOutputStream().Printf("Fast UnwindPlan:\n");
3751-
plan_sp->Dump(result.GetOutputStream(), thread.get(),
3752-
LLDB_INVALID_ADDRESS);
3759+
fast_unwind_plan->Dump(result.GetOutputStream(), thread.get(),
3760+
LLDB_INVALID_ADDRESS);
37533761
result.GetOutputStream().Printf("\n");
37543762
}
37553763

0 commit comments

Comments
 (0)