Skip to content

Commit 9bef315

Browse files
authored
Merge pull request #7104 from medismailben/stable/20221013
2 parents c8ca153 + 25f07c1 commit 9bef315

File tree

97 files changed

+2391
-1306
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+2391
-1306
lines changed

lldb/bindings/lua/lua-wrapper.swig

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
template <typename T> void PushSBClass(lua_State * L, T * obj);
44

55
// This function is called from Lua::CallBreakpointCallback
6-
llvm::Expected<bool> lldb_private::LLDBSwigLuaBreakpointCallbackFunction(
6+
llvm::Expected<bool>
7+
lldb_private::lua::SWIGBridge::LLDBSwigLuaBreakpointCallbackFunction(
78
lua_State * L, lldb::StackFrameSP stop_frame_sp,
89
lldb::BreakpointLocationSP bp_loc_sp,
910
const StructuredDataImpl &extra_args_impl) {
@@ -41,7 +42,8 @@ llvm::Expected<bool> lldb_private::LLDBSwigLuaBreakpointCallbackFunction(
4142
}
4243

4344
// This function is called from Lua::CallWatchpointCallback
44-
llvm::Expected<bool> lldb_private::LLDBSwigLuaWatchpointCallbackFunction(
45+
llvm::Expected<bool>
46+
lldb_private::lua::SWIGBridge::LLDBSwigLuaWatchpointCallbackFunction(
4547
lua_State * L, lldb::StackFrameSP stop_frame_sp, lldb::WatchpointSP wp_sp) {
4648
lldb::SBFrame sb_frame(stop_frame_sp);
4749
lldb::SBWatchpoint sb_wp(wp_sp);

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
}

lldb/bindings/python/python-typemaps.swig

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,29 @@ template <> bool SetNumberFromPyObject<double>(double &number, PyObject *obj) {
384384
$1 = $1 || PyCallable_Check(reinterpret_cast<PyObject *>($input));
385385
}
386386

387+
// For lldb::SBDebuggerDestroyCallback
388+
%typemap(in) (lldb::SBDebuggerDestroyCallback destroy_callback, void *baton) {
389+
if (!($input == Py_None ||
390+
PyCallable_Check(reinterpret_cast<PyObject *>($input)))) {
391+
PyErr_SetString(PyExc_TypeError, "Need a callable object or None!");
392+
SWIG_fail;
393+
}
394+
395+
// FIXME (filcab): We can't currently check if our callback is already
396+
// LLDBSwigPythonCallPythonSBDebuggerTerminateCallback (to DECREF the previous
397+
// baton) nor can we just remove all traces of a callback, if we want to
398+
// revert to a file logging mechanism.
399+
400+
// Don't lose the callback reference
401+
Py_INCREF($input);
402+
$1 = LLDBSwigPythonCallPythonSBDebuggerTerminateCallback;
403+
$2 = $input;
404+
}
405+
406+
%typemap(typecheck) (lldb::SBDebuggerDestroyCallback destroy_callback, void *baton) {
407+
$1 = $input == Py_None;
408+
$1 = $1 || PyCallable_Check(reinterpret_cast<PyObject *>($input));
409+
}
387410

388411
%typemap(in) lldb::FileSP {
389412
PythonFile py_file(PyRefType::Borrowed, $input);

0 commit comments

Comments
 (0)