Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[lldb] Cherry-picks from upstream #7104

Merged
merged 13 commits into from
Jul 28, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[lldb] Mark most SBAPI methods involving private types as protected o…
…r 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 <ismail@bennani.ma>
  • Loading branch information
medismailben committed Jul 27, 2023
commit 0c51553f48357952298c776abbc530e6bbe8de02
54 changes: 29 additions & 25 deletions lldb/bindings/python/python-swigsafecast.swig
Original file line number Diff line number Diff line change
Expand Up @@ -5,113 +5,117 @@ PythonObject ToSWIGHelper(void *obj, swig_type_info *info) {
return {PyRefType::Owned, SWIG_NewPointerObj(obj, info, SWIG_POINTER_OWN)};
}

PythonObject ToSWIGWrapper(std::unique_ptr<lldb::SBValue> value_sb) {
PythonObject SWIGBridge::ToSWIGWrapper(std::unique_ptr<lldb::SBValue> value_sb) {
return ToSWIGHelper(value_sb.release(), SWIGTYPE_p_lldb__SBValue);
}

PythonObject ToSWIGWrapper(lldb::ValueObjectSP value_sp) {
return ToSWIGWrapper(std::make_unique<lldb::SBValue>(std::move(value_sp)));
PythonObject SWIGBridge::ToSWIGWrapper(lldb::ValueObjectSP value_sp) {
return ToSWIGWrapper(std::unique_ptr<lldb::SBValue>(new lldb::SBValue(value_sp)));
}

PythonObject ToSWIGWrapper(lldb::TargetSP target_sp) {
PythonObject SWIGBridge::ToSWIGWrapper(lldb::TargetSP target_sp) {
return ToSWIGHelper(new lldb::SBTarget(std::move(target_sp)),
SWIGTYPE_p_lldb__SBTarget);
}

PythonObject ToSWIGWrapper(lldb::ProcessSP process_sp) {
PythonObject SWIGBridge::ToSWIGWrapper(lldb::ProcessSP process_sp) {
return ToSWIGHelper(new lldb::SBProcess(std::move(process_sp)),
SWIGTYPE_p_lldb__SBProcess);
}

PythonObject ToSWIGWrapper(lldb::ThreadPlanSP thread_plan_sp) {
PythonObject SWIGBridge::ToSWIGWrapper(lldb::ThreadPlanSP thread_plan_sp) {
return ToSWIGHelper(new lldb::SBThreadPlan(std::move(thread_plan_sp)),
SWIGTYPE_p_lldb__SBThreadPlan);
}

PythonObject ToSWIGWrapper(lldb::BreakpointSP breakpoint_sp) {
PythonObject SWIGBridge::ToSWIGWrapper(lldb::BreakpointSP breakpoint_sp) {
return ToSWIGHelper(new lldb::SBBreakpoint(std::move(breakpoint_sp)),
SWIGTYPE_p_lldb__SBBreakpoint);
}

PythonObject ToSWIGWrapper(const Status& status) {
PythonObject SWIGBridge::ToSWIGWrapper(const Status& status) {
return ToSWIGHelper(new lldb::SBError(status), SWIGTYPE_p_lldb__SBError);
}

PythonObject ToSWIGWrapper(std::unique_ptr<lldb::SBStream> stream_sb) {
PythonObject SWIGBridge::ToSWIGWrapper(std::unique_ptr<lldb::SBStream> stream_sb) {
return ToSWIGHelper(stream_sb.release(), SWIGTYPE_p_lldb__SBStream);
}

PythonObject ToSWIGWrapper(std::unique_ptr<lldb::SBStructuredData> data_sb) {
PythonObject SWIGBridge::ToSWIGWrapper(std::unique_ptr<lldb::SBStructuredData> data_sb) {
return ToSWIGHelper(data_sb.release(), SWIGTYPE_p_lldb__SBStructuredData);
}

PythonObject ToSWIGWrapper(const StructuredDataImpl &data_impl) {
return ToSWIGWrapper(std::make_unique<lldb::SBStructuredData>(data_impl));
PythonObject SWIGBridge::ToSWIGWrapper(const StructuredDataImpl &data_impl) {
return ToSWIGWrapper(std::unique_ptr<lldb::SBStructuredData>(new lldb::SBStructuredData(data_impl)));
}

PythonObject ToSWIGWrapper(lldb::ThreadSP thread_sp) {
PythonObject SWIGBridge::ToSWIGWrapper(lldb::ThreadSP thread_sp) {
return ToSWIGHelper(new lldb::SBThread(std::move(thread_sp)),
SWIGTYPE_p_lldb__SBThread);
}

PythonObject ToSWIGWrapper(lldb::StackFrameSP frame_sp) {
PythonObject SWIGBridge::ToSWIGWrapper(lldb::StackFrameSP frame_sp) {
return ToSWIGHelper(new lldb::SBFrame(std::move(frame_sp)),
SWIGTYPE_p_lldb__SBFrame);
}

PythonObject ToSWIGWrapper(lldb::DebuggerSP debugger_sp) {
PythonObject SWIGBridge::ToSWIGWrapper(lldb::DebuggerSP debugger_sp) {
return ToSWIGHelper(new lldb::SBDebugger(std::move(debugger_sp)),
SWIGTYPE_p_lldb__SBDebugger);
}

PythonObject ToSWIGWrapper(lldb::WatchpointSP watchpoint_sp) {
PythonObject SWIGBridge::ToSWIGWrapper(lldb::WatchpointSP watchpoint_sp) {
return ToSWIGHelper(new lldb::SBWatchpoint(std::move(watchpoint_sp)),
SWIGTYPE_p_lldb__SBWatchpoint);
}

PythonObject ToSWIGWrapper(lldb::BreakpointLocationSP bp_loc_sp) {
PythonObject SWIGBridge::ToSWIGWrapper(lldb::BreakpointLocationSP bp_loc_sp) {
return ToSWIGHelper(new lldb::SBBreakpointLocation(std::move(bp_loc_sp)),
SWIGTYPE_p_lldb__SBBreakpointLocation);
}

PythonObject ToSWIGWrapper(lldb::ExecutionContextRefSP ctx_sp) {
PythonObject SWIGBridge::ToSWIGWrapper(lldb::ExecutionContextRefSP ctx_sp) {
return ToSWIGHelper(new lldb::SBExecutionContext(std::move(ctx_sp)),
SWIGTYPE_p_lldb__SBExecutionContext);
}

PythonObject ToSWIGWrapper(const TypeSummaryOptions &summary_options) {
PythonObject SWIGBridge::ToSWIGWrapper(lldb::TypeImplSP type_impl_sp) {
return ToSWIGHelper(new lldb::SBType(type_impl_sp), SWIGTYPE_p_lldb__SBType);
}

PythonObject SWIGBridge::ToSWIGWrapper(const TypeSummaryOptions &summary_options) {
return ToSWIGHelper(new lldb::SBTypeSummaryOptions(summary_options),
SWIGTYPE_p_lldb__SBTypeSummaryOptions);
}

PythonObject ToSWIGWrapper(const SymbolContext &sym_ctx) {
PythonObject SWIGBridge::ToSWIGWrapper(const SymbolContext &sym_ctx) {
return ToSWIGHelper(new lldb::SBSymbolContext(sym_ctx),
SWIGTYPE_p_lldb__SBSymbolContext);
}

PythonObject ToSWIGWrapper(lldb::ProcessLaunchInfoSP launch_info_sp) {
PythonObject SWIGBridge::ToSWIGWrapper(lldb::ProcessLaunchInfoSP launch_info_sp) {
return ToSWIGHelper(new lldb::ProcessLaunchInfoSP(std::move(launch_info_sp)),
SWIGTYPE_p_lldb__SBLaunchInfo);
}

PythonObject ToSWIGWrapper(lldb::ProcessAttachInfoSP attach_info_sp) {
PythonObject SWIGBridge::ToSWIGWrapper(lldb::ProcessAttachInfoSP attach_info_sp) {
return ToSWIGHelper(new lldb::ProcessAttachInfoSP(std::move(attach_info_sp)),
SWIGTYPE_p_lldb__SBAttachInfo);
}

PythonObject ToSWIGWrapper(lldb::DataExtractorSP data_sp) {
PythonObject SWIGBridge::ToSWIGWrapper(lldb::DataExtractorSP data_sp) {
return ToSWIGHelper(new lldb::DataExtractorSP(std::move(data_sp)),
SWIGTYPE_p_lldb__SBData);
}

ScopedPythonObject<lldb::SBCommandReturnObject>
ToSWIGWrapper(CommandReturnObject &cmd_retobj) {
SWIGBridge::ToSWIGWrapper(CommandReturnObject &cmd_retobj) {
return ScopedPythonObject<lldb::SBCommandReturnObject>(
new lldb::SBCommandReturnObject(cmd_retobj),
SWIGTYPE_p_lldb__SBCommandReturnObject);
}

ScopedPythonObject<lldb::SBEvent> ToSWIGWrapper(Event *event) {
ScopedPythonObject<lldb::SBEvent> SWIGBridge::ToSWIGWrapper(Event *event) {
return ScopedPythonObject<lldb::SBEvent>(new lldb::SBEvent(event),
SWIGTYPE_p_lldb__SBEvent);
}
Expand Down
Loading