Skip to content

Commit 0c51553

Browse files
committed
[lldb] Mark most SBAPI methods involving private types as protected or private
Many SB classes have public constructors or methods involving types that are private. Some are more obvious (e.g. containing lldb_private in the name) than others (lldb::FooSP is usually std::shared_pointer<lldb_private::Foo>). This commit explicitly does not address FileSP, so I'm leaving that one alone for now. Some of these were for other SB classes to use and should have been made protected/private with a friend class entry added. Some of these were public for some of the swig python helpers to use. I put all of those functions into a class and made them static methods. The relevant SB classes mark that class as a friend so they can access those private/protected members. I've also removed an outdated SBStructuredData test (can you guess which constructor it was using?) and updated the other relevant tests. Differential Revision: https://reviews.llvm.org/D150157 Signed-off-by: Med Ismail Bennani <[email protected]>
1 parent 0508fda commit 0c51553

38 files changed

+772
-449
lines changed

lldb/bindings/python/python-swigsafecast.swig

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,113 +5,117 @@ PythonObject ToSWIGHelper(void *obj, swig_type_info *info) {
55
return {PyRefType::Owned, SWIG_NewPointerObj(obj, info, SWIG_POINTER_OWN)};
66
}
77

8-
PythonObject ToSWIGWrapper(std::unique_ptr<lldb::SBValue> value_sb) {
8+
PythonObject SWIGBridge::ToSWIGWrapper(std::unique_ptr<lldb::SBValue> value_sb) {
99
return ToSWIGHelper(value_sb.release(), SWIGTYPE_p_lldb__SBValue);
1010
}
1111

12-
PythonObject ToSWIGWrapper(lldb::ValueObjectSP value_sp) {
13-
return ToSWIGWrapper(std::make_unique<lldb::SBValue>(std::move(value_sp)));
12+
PythonObject SWIGBridge::ToSWIGWrapper(lldb::ValueObjectSP value_sp) {
13+
return ToSWIGWrapper(std::unique_ptr<lldb::SBValue>(new lldb::SBValue(value_sp)));
1414
}
1515

16-
PythonObject ToSWIGWrapper(lldb::TargetSP target_sp) {
16+
PythonObject SWIGBridge::ToSWIGWrapper(lldb::TargetSP target_sp) {
1717
return ToSWIGHelper(new lldb::SBTarget(std::move(target_sp)),
1818
SWIGTYPE_p_lldb__SBTarget);
1919
}
2020

21-
PythonObject ToSWIGWrapper(lldb::ProcessSP process_sp) {
21+
PythonObject SWIGBridge::ToSWIGWrapper(lldb::ProcessSP process_sp) {
2222
return ToSWIGHelper(new lldb::SBProcess(std::move(process_sp)),
2323
SWIGTYPE_p_lldb__SBProcess);
2424
}
2525

26-
PythonObject ToSWIGWrapper(lldb::ThreadPlanSP thread_plan_sp) {
26+
PythonObject SWIGBridge::ToSWIGWrapper(lldb::ThreadPlanSP thread_plan_sp) {
2727
return ToSWIGHelper(new lldb::SBThreadPlan(std::move(thread_plan_sp)),
2828
SWIGTYPE_p_lldb__SBThreadPlan);
2929
}
3030

31-
PythonObject ToSWIGWrapper(lldb::BreakpointSP breakpoint_sp) {
31+
PythonObject SWIGBridge::ToSWIGWrapper(lldb::BreakpointSP breakpoint_sp) {
3232
return ToSWIGHelper(new lldb::SBBreakpoint(std::move(breakpoint_sp)),
3333
SWIGTYPE_p_lldb__SBBreakpoint);
3434
}
3535

36-
PythonObject ToSWIGWrapper(const Status& status) {
36+
PythonObject SWIGBridge::ToSWIGWrapper(const Status& status) {
3737
return ToSWIGHelper(new lldb::SBError(status), SWIGTYPE_p_lldb__SBError);
3838
}
3939

40-
PythonObject ToSWIGWrapper(std::unique_ptr<lldb::SBStream> stream_sb) {
40+
PythonObject SWIGBridge::ToSWIGWrapper(std::unique_ptr<lldb::SBStream> stream_sb) {
4141
return ToSWIGHelper(stream_sb.release(), SWIGTYPE_p_lldb__SBStream);
4242
}
4343

44-
PythonObject ToSWIGWrapper(std::unique_ptr<lldb::SBStructuredData> data_sb) {
44+
PythonObject SWIGBridge::ToSWIGWrapper(std::unique_ptr<lldb::SBStructuredData> data_sb) {
4545
return ToSWIGHelper(data_sb.release(), SWIGTYPE_p_lldb__SBStructuredData);
4646
}
4747

48-
PythonObject ToSWIGWrapper(const StructuredDataImpl &data_impl) {
49-
return ToSWIGWrapper(std::make_unique<lldb::SBStructuredData>(data_impl));
48+
PythonObject SWIGBridge::ToSWIGWrapper(const StructuredDataImpl &data_impl) {
49+
return ToSWIGWrapper(std::unique_ptr<lldb::SBStructuredData>(new lldb::SBStructuredData(data_impl)));
5050
}
5151

52-
PythonObject ToSWIGWrapper(lldb::ThreadSP thread_sp) {
52+
PythonObject SWIGBridge::ToSWIGWrapper(lldb::ThreadSP thread_sp) {
5353
return ToSWIGHelper(new lldb::SBThread(std::move(thread_sp)),
5454
SWIGTYPE_p_lldb__SBThread);
5555
}
5656

57-
PythonObject ToSWIGWrapper(lldb::StackFrameSP frame_sp) {
57+
PythonObject SWIGBridge::ToSWIGWrapper(lldb::StackFrameSP frame_sp) {
5858
return ToSWIGHelper(new lldb::SBFrame(std::move(frame_sp)),
5959
SWIGTYPE_p_lldb__SBFrame);
6060
}
6161

62-
PythonObject ToSWIGWrapper(lldb::DebuggerSP debugger_sp) {
62+
PythonObject SWIGBridge::ToSWIGWrapper(lldb::DebuggerSP debugger_sp) {
6363
return ToSWIGHelper(new lldb::SBDebugger(std::move(debugger_sp)),
6464
SWIGTYPE_p_lldb__SBDebugger);
6565
}
6666

67-
PythonObject ToSWIGWrapper(lldb::WatchpointSP watchpoint_sp) {
67+
PythonObject SWIGBridge::ToSWIGWrapper(lldb::WatchpointSP watchpoint_sp) {
6868
return ToSWIGHelper(new lldb::SBWatchpoint(std::move(watchpoint_sp)),
6969
SWIGTYPE_p_lldb__SBWatchpoint);
7070
}
7171

72-
PythonObject ToSWIGWrapper(lldb::BreakpointLocationSP bp_loc_sp) {
72+
PythonObject SWIGBridge::ToSWIGWrapper(lldb::BreakpointLocationSP bp_loc_sp) {
7373
return ToSWIGHelper(new lldb::SBBreakpointLocation(std::move(bp_loc_sp)),
7474
SWIGTYPE_p_lldb__SBBreakpointLocation);
7575
}
7676

77-
PythonObject ToSWIGWrapper(lldb::ExecutionContextRefSP ctx_sp) {
77+
PythonObject SWIGBridge::ToSWIGWrapper(lldb::ExecutionContextRefSP ctx_sp) {
7878
return ToSWIGHelper(new lldb::SBExecutionContext(std::move(ctx_sp)),
7979
SWIGTYPE_p_lldb__SBExecutionContext);
8080
}
8181

82-
PythonObject ToSWIGWrapper(const TypeSummaryOptions &summary_options) {
82+
PythonObject SWIGBridge::ToSWIGWrapper(lldb::TypeImplSP type_impl_sp) {
83+
return ToSWIGHelper(new lldb::SBType(type_impl_sp), SWIGTYPE_p_lldb__SBType);
84+
}
85+
86+
PythonObject SWIGBridge::ToSWIGWrapper(const TypeSummaryOptions &summary_options) {
8387
return ToSWIGHelper(new lldb::SBTypeSummaryOptions(summary_options),
8488
SWIGTYPE_p_lldb__SBTypeSummaryOptions);
8589
}
8690

87-
PythonObject ToSWIGWrapper(const SymbolContext &sym_ctx) {
91+
PythonObject SWIGBridge::ToSWIGWrapper(const SymbolContext &sym_ctx) {
8892
return ToSWIGHelper(new lldb::SBSymbolContext(sym_ctx),
8993
SWIGTYPE_p_lldb__SBSymbolContext);
9094
}
9195

92-
PythonObject ToSWIGWrapper(lldb::ProcessLaunchInfoSP launch_info_sp) {
96+
PythonObject SWIGBridge::ToSWIGWrapper(lldb::ProcessLaunchInfoSP launch_info_sp) {
9397
return ToSWIGHelper(new lldb::ProcessLaunchInfoSP(std::move(launch_info_sp)),
9498
SWIGTYPE_p_lldb__SBLaunchInfo);
9599
}
96100

97-
PythonObject ToSWIGWrapper(lldb::ProcessAttachInfoSP attach_info_sp) {
101+
PythonObject SWIGBridge::ToSWIGWrapper(lldb::ProcessAttachInfoSP attach_info_sp) {
98102
return ToSWIGHelper(new lldb::ProcessAttachInfoSP(std::move(attach_info_sp)),
99103
SWIGTYPE_p_lldb__SBAttachInfo);
100104
}
101105

102-
PythonObject ToSWIGWrapper(lldb::DataExtractorSP data_sp) {
106+
PythonObject SWIGBridge::ToSWIGWrapper(lldb::DataExtractorSP data_sp) {
103107
return ToSWIGHelper(new lldb::DataExtractorSP(std::move(data_sp)),
104108
SWIGTYPE_p_lldb__SBData);
105109
}
106110

107111
ScopedPythonObject<lldb::SBCommandReturnObject>
108-
ToSWIGWrapper(CommandReturnObject &cmd_retobj) {
112+
SWIGBridge::ToSWIGWrapper(CommandReturnObject &cmd_retobj) {
109113
return ScopedPythonObject<lldb::SBCommandReturnObject>(
110114
new lldb::SBCommandReturnObject(cmd_retobj),
111115
SWIGTYPE_p_lldb__SBCommandReturnObject);
112116
}
113117

114-
ScopedPythonObject<lldb::SBEvent> ToSWIGWrapper(Event *event) {
118+
ScopedPythonObject<lldb::SBEvent> SWIGBridge::ToSWIGWrapper(Event *event) {
115119
return ScopedPythonObject<lldb::SBEvent>(new lldb::SBEvent(event),
116120
SWIGTYPE_p_lldb__SBEvent);
117121
}

0 commit comments

Comments
 (0)