2013-09-25 10:37:32 +00:00
|
|
|
%header %{
|
|
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
class PyErr_Cleaner {
|
2013-09-25 10:37:32 +00:00
|
|
|
public:
|
2021-12-14 17:20:23 +01:00
|
|
|
PyErr_Cleaner(bool print = false) : m_print(print) {}
|
2015-03-14 08:06:56 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
~PyErr_Cleaner() {
|
|
|
|
|
if (PyErr_Occurred()) {
|
|
|
|
|
if (m_print && !PyErr_ExceptionMatches(PyExc_SystemExit))
|
|
|
|
|
PyErr_Print();
|
|
|
|
|
PyErr_Clear();
|
2013-09-25 10:37:32 +00:00
|
|
|
}
|
2021-12-14 17:20:23 +01:00
|
|
|
}
|
2015-03-14 08:06:56 +00:00
|
|
|
|
2013-09-25 10:37:32 +00:00
|
|
|
private:
|
2021-12-14 17:20:23 +01:00
|
|
|
bool m_print;
|
2013-09-25 10:37:32 +00:00
|
|
|
};
|
|
|
|
|
|
2023-05-08 16:31:27 -07:00
|
|
|
llvm::Expected<bool> lldb_private::python::SWIGBridge::LLDBSwigPythonBreakpointCallbackFunction(
|
2021-12-14 17:20:23 +01:00
|
|
|
const char *python_function_name, const char *session_dictionary_name,
|
|
|
|
|
const lldb::StackFrameSP &frame_sp,
|
|
|
|
|
const lldb::BreakpointLocationSP &bp_loc_sp,
|
|
|
|
|
const lldb_private::StructuredDataImpl &args_impl) {
|
|
|
|
|
using namespace llvm;
|
|
|
|
|
|
|
|
|
|
lldb::SBBreakpointLocation sb_bp_loc(bp_loc_sp);
|
|
|
|
|
|
|
|
|
|
PyErr_Cleaner py_err_cleaner(true);
|
|
|
|
|
auto dict = PythonModule::MainModule().ResolveName<PythonDictionary>(
|
|
|
|
|
session_dictionary_name);
|
|
|
|
|
auto pfunc = PythonObject::ResolveNameWithDictionary<PythonCallable>(
|
|
|
|
|
python_function_name, dict);
|
|
|
|
|
|
|
|
|
|
unsigned max_positional_args;
|
|
|
|
|
if (auto arg_info = pfunc.GetArgInfo())
|
|
|
|
|
max_positional_args = arg_info.get().max_positional_args;
|
|
|
|
|
else
|
|
|
|
|
return arg_info.takeError();
|
|
|
|
|
|
2023-05-08 16:31:27 -07:00
|
|
|
PythonObject frame_arg = SWIGBridge::ToSWIGWrapper(frame_sp);
|
|
|
|
|
PythonObject bp_loc_arg = SWIGBridge::ToSWIGWrapper(bp_loc_sp);
|
2021-12-14 17:20:23 +01:00
|
|
|
|
2021-12-17 13:02:21 +01:00
|
|
|
auto result =
|
|
|
|
|
max_positional_args < 4
|
|
|
|
|
? pfunc.Call(frame_arg, bp_loc_arg, dict)
|
2023-05-08 16:31:27 -07:00
|
|
|
: pfunc.Call(frame_arg, bp_loc_arg, SWIGBridge::ToSWIGWrapper(args_impl), dict);
|
2021-12-14 17:20:23 +01:00
|
|
|
|
|
|
|
|
if (!result)
|
|
|
|
|
return result.takeError();
|
|
|
|
|
|
|
|
|
|
// Only False counts as false!
|
|
|
|
|
return result.get().get() != Py_False;
|
2013-09-25 10:37:32 +00:00
|
|
|
}
|
|
|
|
|
|
2021-11-22 16:32:44 +01:00
|
|
|
// resolve a dotted Python name in the form
|
|
|
|
|
// foo.bar.baz.Foobar to an actual Python object
|
|
|
|
|
// if pmodule is NULL, the __main__ module will be used
|
|
|
|
|
// as the starting point for the search
|
2021-03-10 12:48:05 -08:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
// This function is called by
|
|
|
|
|
// lldb_private::ScriptInterpreterPython::BreakpointCallbackFunction(...) and is
|
|
|
|
|
// used when a script command is attached to a breakpoint for execution.
|
2021-11-22 16:32:44 +01:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
// This function is called by
|
|
|
|
|
// lldb_private::ScriptInterpreterPython::WatchpointCallbackFunction(...) and is
|
|
|
|
|
// used when a script command is attached to a watchpoint for execution.
|
2013-09-25 10:37:32 +00:00
|
|
|
|
2023-05-08 16:31:27 -07:00
|
|
|
bool lldb_private::python::SWIGBridge::LLDBSwigPythonWatchpointCallbackFunction(
|
2021-12-14 17:20:23 +01:00
|
|
|
const char *python_function_name, const char *session_dictionary_name,
|
|
|
|
|
const lldb::StackFrameSP &frame_sp, const lldb::WatchpointSP &wp_sp) {
|
2013-09-25 10:37:32 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
bool stop_at_watchpoint = true;
|
2015-03-14 08:06:56 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
PyErr_Cleaner py_err_cleaner(true);
|
2015-03-14 08:06:56 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
auto dict = PythonModule::MainModule().ResolveName<PythonDictionary>(
|
|
|
|
|
session_dictionary_name);
|
|
|
|
|
auto pfunc = PythonObject::ResolveNameWithDictionary<PythonCallable>(
|
|
|
|
|
python_function_name, dict);
|
2015-03-14 08:06:56 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
if (!pfunc.IsAllocated())
|
|
|
|
|
return stop_at_watchpoint;
|
2015-03-14 08:06:56 +00:00
|
|
|
|
2021-12-17 13:02:21 +01:00
|
|
|
PythonObject result =
|
2023-05-08 16:31:27 -07:00
|
|
|
pfunc(SWIGBridge::ToSWIGWrapper(frame_sp), SWIGBridge::ToSWIGWrapper(wp_sp), dict);
|
2015-03-14 08:06:56 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
if (result.get() == Py_False)
|
|
|
|
|
stop_at_watchpoint = false;
|
2015-03-14 08:06:56 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
return stop_at_watchpoint;
|
2013-09-25 10:37:32 +00:00
|
|
|
}
|
|
|
|
|
|
2022-10-11 00:44:06 -07:00
|
|
|
// This function is called by
|
|
|
|
|
// ScriptInterpreterPython::FormatterMatchingCallbackFunction and it's used when
|
|
|
|
|
// a data formatter provides the name of a callback to inspect a candidate type
|
|
|
|
|
// before considering a match.
|
2023-05-08 16:31:27 -07:00
|
|
|
bool lldb_private::python::SWIGBridge::LLDBSwigPythonFormatterCallbackFunction(
|
2022-10-11 00:44:06 -07:00
|
|
|
const char *python_function_name, const char *session_dictionary_name,
|
|
|
|
|
lldb::TypeImplSP type_impl_sp) {
|
|
|
|
|
|
|
|
|
|
PyErr_Cleaner py_err_cleaner(true);
|
|
|
|
|
|
|
|
|
|
auto dict = PythonModule::MainModule().ResolveName<PythonDictionary>(
|
|
|
|
|
session_dictionary_name);
|
|
|
|
|
auto pfunc = PythonObject::ResolveNameWithDictionary<PythonCallable>(
|
|
|
|
|
python_function_name, dict);
|
|
|
|
|
|
|
|
|
|
if (!pfunc.IsAllocated())
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
PythonObject result =
|
2023-05-08 16:31:27 -07:00
|
|
|
pfunc(SWIGBridge::ToSWIGWrapper(type_impl_sp), dict);
|
2022-10-11 00:44:06 -07:00
|
|
|
|
|
|
|
|
// Only if everything goes okay and the function returns True we'll consider
|
|
|
|
|
// it a match.
|
|
|
|
|
return result.get() == Py_True;
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-08 16:31:27 -07:00
|
|
|
bool lldb_private::python::SWIGBridge::LLDBSwigPythonCallTypeScript(
|
2021-12-14 17:20:23 +01:00
|
|
|
const char *python_function_name, const void *session_dictionary,
|
|
|
|
|
const lldb::ValueObjectSP &valobj_sp, void **pyfunct_wrapper,
|
|
|
|
|
const lldb::TypeSummaryOptionsSP &options_sp, std::string &retval) {
|
2013-09-25 10:37:32 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
retval.clear();
|
2013-09-25 10:37:32 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
if (!python_function_name || !session_dictionary)
|
|
|
|
|
return false;
|
2013-09-25 10:37:32 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
PyObject *pfunc_impl = nullptr;
|
2015-03-14 08:06:56 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
if (pyfunct_wrapper && *pyfunct_wrapper &&
|
|
|
|
|
PyFunction_Check(*pyfunct_wrapper)) {
|
|
|
|
|
pfunc_impl = (PyObject *)(*pyfunct_wrapper);
|
|
|
|
|
if (pfunc_impl->ob_refcnt == 1) {
|
|
|
|
|
Py_XDECREF(pfunc_impl);
|
|
|
|
|
pfunc_impl = NULL;
|
2013-09-25 10:37:32 +00:00
|
|
|
}
|
2021-12-14 17:20:23 +01:00
|
|
|
}
|
2013-09-25 10:37:32 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
PyObject *py_dict = (PyObject *)session_dictionary;
|
|
|
|
|
if (!PythonDictionary::Check(py_dict))
|
|
|
|
|
return true;
|
2015-03-14 08:06:56 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
PythonDictionary dict(PyRefType::Borrowed, py_dict);
|
2013-12-26 07:21:41 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
PyErr_Cleaner pyerr_cleanup(true); // show Python errors
|
2015-03-14 08:06:56 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
PythonCallable pfunc(PyRefType::Borrowed, pfunc_impl);
|
2015-11-12 16:23:16 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
if (!pfunc.IsAllocated()) {
|
|
|
|
|
pfunc = PythonObject::ResolveNameWithDictionary<PythonCallable>(
|
|
|
|
|
python_function_name, dict);
|
2015-11-12 16:23:16 +00:00
|
|
|
if (!pfunc.IsAllocated())
|
2021-12-14 17:20:23 +01:00
|
|
|
return false;
|
2014-11-22 00:02:47 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
if (pyfunct_wrapper) {
|
|
|
|
|
*pyfunct_wrapper = pfunc.get();
|
|
|
|
|
Py_XINCREF(pfunc.get());
|
2019-10-19 07:05:39 +00:00
|
|
|
}
|
2021-12-14 17:20:23 +01:00
|
|
|
}
|
2019-10-19 07:05:39 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
PythonObject result;
|
|
|
|
|
auto argc = pfunc.GetArgInfo();
|
|
|
|
|
if (!argc) {
|
|
|
|
|
llvm::consumeError(argc.takeError());
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2019-10-19 07:05:39 +00:00
|
|
|
|
2023-05-08 16:31:27 -07:00
|
|
|
PythonObject value_arg = SWIGBridge::ToSWIGWrapper(valobj_sp);
|
2015-11-11 19:42:35 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
if (argc.get().max_positional_args < 3)
|
|
|
|
|
result = pfunc(value_arg, dict);
|
|
|
|
|
else
|
2023-05-08 16:31:27 -07:00
|
|
|
result = pfunc(value_arg, dict, SWIGBridge::ToSWIGWrapper(*options_sp));
|
2015-11-11 19:42:35 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
retval = result.Str().GetString().str();
|
|
|
|
|
|
|
|
|
|
return true;
|
2013-09-25 10:37:32 +00:00
|
|
|
}
|
|
|
|
|
|
2023-05-08 16:31:27 -07:00
|
|
|
PythonObject lldb_private::python::SWIGBridge::LLDBSwigPythonCreateSyntheticProvider(
|
2021-12-14 17:20:23 +01:00
|
|
|
const char *python_class_name, const char *session_dictionary_name,
|
|
|
|
|
const lldb::ValueObjectSP &valobj_sp) {
|
|
|
|
|
if (python_class_name == NULL || python_class_name[0] == '\0' ||
|
|
|
|
|
!session_dictionary_name)
|
2022-01-17 11:29:35 +01:00
|
|
|
return PythonObject();
|
2013-09-25 10:37:32 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
PyErr_Cleaner py_err_cleaner(true);
|
2015-11-12 16:23:16 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
auto dict = PythonModule::MainModule().ResolveName<PythonDictionary>(
|
|
|
|
|
session_dictionary_name);
|
|
|
|
|
auto pfunc = PythonObject::ResolveNameWithDictionary<PythonCallable>(
|
|
|
|
|
python_class_name, dict);
|
2015-11-12 16:23:16 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
if (!pfunc.IsAllocated())
|
2022-01-17 11:29:35 +01:00
|
|
|
return PythonObject();
|
2015-11-12 16:23:16 +00:00
|
|
|
|
2023-05-08 16:31:27 -07:00
|
|
|
auto sb_value = std::unique_ptr<lldb::SBValue>(new lldb::SBValue(valobj_sp));
|
2021-12-14 17:20:23 +01:00
|
|
|
sb_value->SetPreferSyntheticValue(false);
|
2013-09-25 10:37:32 +00:00
|
|
|
|
2023-05-08 16:31:27 -07:00
|
|
|
PythonObject val_arg = SWIGBridge::ToSWIGWrapper(std::move(sb_value));
|
2021-12-14 17:20:23 +01:00
|
|
|
if (!val_arg.IsAllocated())
|
2022-01-17 11:29:35 +01:00
|
|
|
return PythonObject();
|
2015-03-14 08:06:56 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
PythonObject result = pfunc(val_arg, dict);
|
2015-03-14 08:06:56 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
if (result.IsAllocated())
|
2022-01-17 11:29:35 +01:00
|
|
|
return result;
|
2015-03-14 08:06:56 +00:00
|
|
|
|
2022-01-17 11:29:35 +01:00
|
|
|
return PythonObject();
|
2013-09-25 10:37:32 +00:00
|
|
|
}
|
|
|
|
|
|
2023-05-08 16:31:27 -07:00
|
|
|
PythonObject lldb_private::python::SWIGBridge::LLDBSwigPythonCreateCommandObject(
|
2021-12-14 17:20:23 +01:00
|
|
|
const char *python_class_name, const char *session_dictionary_name,
|
2021-11-18 08:11:34 +01:00
|
|
|
lldb::DebuggerSP debugger_sp) {
|
2021-12-14 17:20:23 +01:00
|
|
|
if (python_class_name == NULL || python_class_name[0] == '\0' ||
|
|
|
|
|
!session_dictionary_name)
|
2022-01-17 11:29:35 +01:00
|
|
|
return PythonObject();
|
2015-03-13 02:20:41 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
PyErr_Cleaner py_err_cleaner(true);
|
|
|
|
|
auto dict = PythonModule::MainModule().ResolveName<PythonDictionary>(
|
|
|
|
|
session_dictionary_name);
|
|
|
|
|
auto pfunc = PythonObject::ResolveNameWithDictionary<PythonCallable>(
|
|
|
|
|
python_class_name, dict);
|
2015-03-14 08:06:56 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
if (!pfunc.IsAllocated())
|
2022-01-17 11:29:35 +01:00
|
|
|
return PythonObject();
|
2015-03-14 08:06:56 +00:00
|
|
|
|
2023-05-08 16:31:27 -07:00
|
|
|
return pfunc(SWIGBridge::ToSWIGWrapper(std::move(debugger_sp)), dict);
|
2015-03-13 02:20:41 +00:00
|
|
|
}
|
|
|
|
|
|
2023-05-08 16:31:27 -07:00
|
|
|
PythonObject lldb_private::python::SWIGBridge::LLDBSwigPythonCreateScriptedBreakpointResolver(
|
[lldb] Fix [some] leaks in python bindings
Using an lldb_private object in the bindings involves three steps
- wrapping the object in it's lldb::SB variant
- using swig to convert/wrap that to a PyObject
- wrapping *that* in a lldb_private::python::PythonObject
Our SBTypeToSWIGWrapper was only handling the middle part. This doesn't
just result in increased boilerplate in the callers, but is also a
functionality problem, as it's very hard to get the lifetime of of all
of these objects right. Most of the callers are creating the SB object
(step 1) on the stack, which means that we end up with dangling python
objects after the function terminates. Most of the time this isn't a
problem, because the python code does not need to persist the objects.
However, there are legitimate cases where they can do it (and even if
the use case is not completely legitimate, crashing is not the best
response to that).
For this reason, some of our code creates the SB object on the heap, but
it has another problem -- it never gets cleaned up.
This patch begins to add a new function (ToSWIGWrapper), which does all
of the three steps, while properly taking care of ownership. In the
first step, I have converted most of the leaky code (except for
SBStructuredData, which needs a bit more work).
Differential Revision: https://reviews.llvm.org/D114259
2021-11-18 21:27:27 +01:00
|
|
|
const char *python_class_name, const char *session_dictionary_name,
|
2021-11-25 14:01:41 +01:00
|
|
|
const StructuredDataImpl &args_impl,
|
[lldb] Fix [some] leaks in python bindings
Using an lldb_private object in the bindings involves three steps
- wrapping the object in it's lldb::SB variant
- using swig to convert/wrap that to a PyObject
- wrapping *that* in a lldb_private::python::PythonObject
Our SBTypeToSWIGWrapper was only handling the middle part. This doesn't
just result in increased boilerplate in the callers, but is also a
functionality problem, as it's very hard to get the lifetime of of all
of these objects right. Most of the callers are creating the SB object
(step 1) on the stack, which means that we end up with dangling python
objects after the function terminates. Most of the time this isn't a
problem, because the python code does not need to persist the objects.
However, there are legitimate cases where they can do it (and even if
the use case is not completely legitimate, crashing is not the best
response to that).
For this reason, some of our code creates the SB object on the heap, but
it has another problem -- it never gets cleaned up.
This patch begins to add a new function (ToSWIGWrapper), which does all
of the three steps, while properly taking care of ownership. In the
first step, I have converted most of the leaky code (except for
SBStructuredData, which needs a bit more work).
Differential Revision: https://reviews.llvm.org/D114259
2021-11-18 21:27:27 +01:00
|
|
|
const lldb::BreakpointSP &breakpoint_sp) {
|
|
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
if (python_class_name == NULL || python_class_name[0] == '\0' ||
|
|
|
|
|
!session_dictionary_name)
|
2022-01-17 11:29:35 +01:00
|
|
|
return PythonObject();
|
2018-09-13 21:35:32 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
PyErr_Cleaner py_err_cleaner(true);
|
2018-09-13 21:35:32 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
auto dict = PythonModule::MainModule().ResolveName<PythonDictionary>(
|
|
|
|
|
session_dictionary_name);
|
|
|
|
|
auto pfunc = PythonObject::ResolveNameWithDictionary<PythonCallable>(
|
|
|
|
|
python_class_name, dict);
|
2018-09-13 21:35:32 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
if (!pfunc.IsAllocated())
|
2022-01-17 11:29:35 +01:00
|
|
|
return PythonObject();
|
2018-09-13 21:35:32 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
PythonObject result =
|
2023-05-08 16:31:27 -07:00
|
|
|
pfunc(SWIGBridge::ToSWIGWrapper(breakpoint_sp), SWIGBridge::ToSWIGWrapper(args_impl), dict);
|
2021-12-14 17:20:23 +01:00
|
|
|
// FIXME: At this point we should check that the class we found supports all
|
|
|
|
|
// the methods that we need.
|
2018-09-13 21:35:32 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
if (result.IsAllocated()) {
|
|
|
|
|
// Check that __callback__ is defined:
|
|
|
|
|
auto callback_func = result.ResolveName<PythonCallable>("__callback__");
|
|
|
|
|
if (callback_func.IsAllocated())
|
2022-01-17 11:29:35 +01:00
|
|
|
return result;
|
2021-12-14 17:20:23 +01:00
|
|
|
}
|
2022-01-17 11:29:35 +01:00
|
|
|
return PythonObject();
|
2021-12-14 17:20:23 +01:00
|
|
|
}
|
2018-09-13 21:35:32 +00:00
|
|
|
|
2023-05-08 16:31:27 -07:00
|
|
|
unsigned int lldb_private::python::SWIGBridge::LLDBSwigPythonCallBreakpointResolver(
|
2021-12-14 17:20:23 +01:00
|
|
|
void *implementor, const char *method_name,
|
|
|
|
|
lldb_private::SymbolContext *sym_ctx) {
|
|
|
|
|
PyErr_Cleaner py_err_cleaner(false);
|
|
|
|
|
PythonObject self(PyRefType::Borrowed, static_cast<PyObject *>(implementor));
|
|
|
|
|
auto pfunc = self.ResolveName<PythonCallable>(method_name);
|
|
|
|
|
|
|
|
|
|
if (!pfunc.IsAllocated())
|
|
|
|
|
return 0;
|
|
|
|
|
|
2023-05-08 16:31:27 -07:00
|
|
|
PythonObject result = sym_ctx ? pfunc(SWIGBridge::ToSWIGWrapper(*sym_ctx)) : pfunc();
|
2021-12-14 17:20:23 +01:00
|
|
|
|
|
|
|
|
if (PyErr_Occurred()) {
|
|
|
|
|
PyErr_Print();
|
|
|
|
|
PyErr_Clear();
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// The callback will return a bool, but we're need to also return ints
|
|
|
|
|
// so we're squirrelling the bool through as an int... And if you return
|
|
|
|
|
// nothing, we'll continue.
|
|
|
|
|
if (strcmp(method_name, "__callback__") == 0) {
|
|
|
|
|
if (result.get() == Py_False)
|
|
|
|
|
return 0;
|
|
|
|
|
else
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
2018-09-13 21:35:32 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
long long ret_val = unwrapOrSetPythonException(As<long long>(result));
|
2020-04-23 04:35:30 +05:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
if (PyErr_Occurred()) {
|
|
|
|
|
PyErr_Print();
|
|
|
|
|
PyErr_Clear();
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2018-09-13 21:35:32 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
return ret_val;
|
2018-09-13 21:35:32 +00:00
|
|
|
}
|
|
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
// wrapper that calls an optional instance member of an object taking no
|
|
|
|
|
// arguments
|
|
|
|
|
static PyObject *LLDBSwigPython_CallOptionalMember(
|
|
|
|
|
PyObject * implementor, char *callee_name,
|
|
|
|
|
PyObject *ret_if_not_found = Py_None, bool *was_found = NULL) {
|
|
|
|
|
PyErr_Cleaner py_err_cleaner(false);
|
2013-09-25 10:37:32 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
PythonObject self(PyRefType::Borrowed, static_cast<PyObject *>(implementor));
|
|
|
|
|
auto pfunc = self.ResolveName<PythonCallable>(callee_name);
|
2019-10-27 14:30:56 -07:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
if (!pfunc.IsAllocated()) {
|
|
|
|
|
if (was_found)
|
|
|
|
|
*was_found = false;
|
|
|
|
|
Py_XINCREF(ret_if_not_found);
|
|
|
|
|
return ret_if_not_found;
|
|
|
|
|
}
|
2020-04-23 04:35:30 +05:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
if (was_found)
|
|
|
|
|
*was_found = true;
|
2015-03-14 08:06:56 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
PythonObject result = pfunc();
|
|
|
|
|
return result.release();
|
|
|
|
|
}
|
2015-10-21 19:28:08 +00:00
|
|
|
|
2023-05-08 16:31:27 -07:00
|
|
|
size_t lldb_private::python::SWIGBridge::LLDBSwigPython_CalculateNumChildren(PyObject * implementor,
|
2021-12-14 17:20:23 +01:00
|
|
|
uint32_t max) {
|
|
|
|
|
PythonObject self(PyRefType::Borrowed, implementor);
|
|
|
|
|
auto pfunc = self.ResolveName<PythonCallable>("num_children");
|
|
|
|
|
|
|
|
|
|
if (!pfunc.IsAllocated())
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
auto arg_info = pfunc.GetArgInfo();
|
|
|
|
|
if (!arg_info) {
|
|
|
|
|
llvm::consumeError(arg_info.takeError());
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
size_t ret_val;
|
|
|
|
|
if (arg_info.get().max_positional_args < 1)
|
|
|
|
|
ret_val = unwrapOrSetPythonException(As<long long>(pfunc.Call()));
|
|
|
|
|
else
|
|
|
|
|
ret_val = unwrapOrSetPythonException(
|
|
|
|
|
As<long long>(pfunc.Call(PythonInteger(max))));
|
|
|
|
|
|
|
|
|
|
if (PyErr_Occurred()) {
|
|
|
|
|
PyErr_Print();
|
|
|
|
|
PyErr_Clear();
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (arg_info.get().max_positional_args < 1)
|
|
|
|
|
ret_val = std::min(ret_val, static_cast<size_t>(max));
|
|
|
|
|
|
|
|
|
|
return ret_val;
|
2013-09-25 10:37:32 +00:00
|
|
|
}
|
|
|
|
|
|
2023-05-08 16:31:27 -07:00
|
|
|
PyObject *lldb_private::python::SWIGBridge::LLDBSwigPython_GetChildAtIndex(PyObject * implementor,
|
2021-12-14 17:20:23 +01:00
|
|
|
uint32_t idx) {
|
|
|
|
|
PyErr_Cleaner py_err_cleaner(true);
|
2015-03-14 08:06:56 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
PythonObject self(PyRefType::Borrowed, implementor);
|
|
|
|
|
auto pfunc = self.ResolveName<PythonCallable>("get_child_at_index");
|
2015-03-14 08:06:56 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
if (!pfunc.IsAllocated())
|
|
|
|
|
return nullptr;
|
2015-03-14 08:06:56 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
PythonObject result = pfunc(PythonInteger(idx));
|
2015-03-14 08:06:56 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
if (!result.IsAllocated())
|
|
|
|
|
return nullptr;
|
2015-03-14 08:06:56 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
lldb::SBValue *sbvalue_ptr = nullptr;
|
|
|
|
|
if (SWIG_ConvertPtr(result.get(), (void **)&sbvalue_ptr,
|
|
|
|
|
SWIGTYPE_p_lldb__SBValue, 0) == -1)
|
|
|
|
|
return nullptr;
|
2015-03-14 08:06:56 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
if (sbvalue_ptr == nullptr)
|
|
|
|
|
return nullptr;
|
2015-03-14 08:06:56 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
return result.release();
|
2013-09-25 10:37:32 +00:00
|
|
|
}
|
|
|
|
|
|
2023-05-08 16:31:27 -07:00
|
|
|
int lldb_private::python::SWIGBridge::LLDBSwigPython_GetIndexOfChildWithName(
|
2021-12-14 17:20:23 +01:00
|
|
|
PyObject * implementor, const char *child_name) {
|
|
|
|
|
PyErr_Cleaner py_err_cleaner(true);
|
2015-03-14 08:06:56 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
PythonObject self(PyRefType::Borrowed, implementor);
|
|
|
|
|
auto pfunc = self.ResolveName<PythonCallable>("get_child_index");
|
2015-03-14 08:06:56 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
if (!pfunc.IsAllocated())
|
|
|
|
|
return UINT32_MAX;
|
2015-03-14 08:06:56 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
llvm::Expected<PythonObject> result = pfunc.Call(PythonString(child_name));
|
2015-03-14 08:06:56 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
long long retval =
|
|
|
|
|
unwrapOrSetPythonException(As<long long>(std::move(result)));
|
2015-03-14 08:06:56 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
if (PyErr_Occurred()) {
|
|
|
|
|
PyErr_Clear(); // FIXME print this? do something else
|
|
|
|
|
return UINT32_MAX;
|
|
|
|
|
}
|
2013-09-25 10:37:32 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
if (retval >= 0)
|
|
|
|
|
return (uint32_t)retval;
|
2015-03-14 08:06:56 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
return UINT32_MAX;
|
2013-09-25 10:37:32 +00:00
|
|
|
}
|
|
|
|
|
|
2023-05-08 16:31:27 -07:00
|
|
|
bool lldb_private::python::SWIGBridge::LLDBSwigPython_UpdateSynthProviderInstance(PyObject *
|
2021-12-14 17:20:23 +01:00
|
|
|
implementor) {
|
|
|
|
|
bool ret_val = false;
|
2013-09-25 10:37:32 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
static char callee_name[] = "update";
|
2013-09-25 10:37:32 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
PyObject *py_return =
|
|
|
|
|
LLDBSwigPython_CallOptionalMember(implementor, callee_name);
|
2013-09-25 10:37:32 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
if (py_return == Py_True)
|
|
|
|
|
ret_val = true;
|
2013-09-25 10:37:32 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
Py_XDECREF(py_return);
|
2015-03-14 08:06:56 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
return ret_val;
|
2013-09-25 10:37:32 +00:00
|
|
|
}
|
|
|
|
|
|
2023-05-08 16:31:27 -07:00
|
|
|
bool lldb_private::python::SWIGBridge::LLDBSwigPython_MightHaveChildrenSynthProviderInstance(
|
2021-12-14 17:20:23 +01:00
|
|
|
PyObject * implementor) {
|
|
|
|
|
bool ret_val = false;
|
2013-09-25 10:37:32 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
static char callee_name[] = "has_children";
|
2013-09-25 10:37:32 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
PyObject *py_return =
|
|
|
|
|
LLDBSwigPython_CallOptionalMember(implementor, callee_name, Py_True);
|
2013-09-25 10:37:32 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
if (py_return == Py_True)
|
|
|
|
|
ret_val = true;
|
2013-09-25 10:37:32 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
Py_XDECREF(py_return);
|
2015-03-14 08:06:56 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
return ret_val;
|
2013-09-25 10:37:32 +00:00
|
|
|
}
|
|
|
|
|
|
2023-05-08 16:31:27 -07:00
|
|
|
PyObject *lldb_private::python::SWIGBridge::LLDBSwigPython_GetValueSynthProviderInstance(
|
2021-12-14 17:20:23 +01:00
|
|
|
PyObject * implementor) {
|
|
|
|
|
PyObject *ret_val = nullptr;
|
Extend synthetic children to produce synthetic values (as in, those that GetValueAsUnsigned(), GetValueAsCString() would return)
The way to do this is to write a synthetic child provider for your type, and have it vend the (optional) get_value function.
If get_value is defined, and it returns a valid SBValue, that SBValue's value (as in lldb_private::Value) will be used as the synthetic ValueObject's Value
The rationale for doing things this way is twofold:
- there are many possible ways to define a "value" (SBData, a Python number, ...) but SBValue seems general enough as a thing that stores a "value", so we just trade values that way and that keeps our currency trivial
- we could introduce a new level of layering (ValueObjectSyntheticValue), a new kind of formatter (synthetic value producer), but that would complicate the model (can I have a dynamic with no synthetic children but synthetic value? synthetic value with synthetic children but no dynamic?), and I really couldn't see much benefit to be reaped from this added complexity in the matrix
On the other hand, just defining a synthetic child provider with a get_value but returning no actual children is easy enough that it's not a significant road-block to adoption of this feature
Comes with a test case
llvm-svn: 219330
2014-10-08 18:27:36 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
static char callee_name[] = "get_value";
|
Extend synthetic children to produce synthetic values (as in, those that GetValueAsUnsigned(), GetValueAsCString() would return)
The way to do this is to write a synthetic child provider for your type, and have it vend the (optional) get_value function.
If get_value is defined, and it returns a valid SBValue, that SBValue's value (as in lldb_private::Value) will be used as the synthetic ValueObject's Value
The rationale for doing things this way is twofold:
- there are many possible ways to define a "value" (SBData, a Python number, ...) but SBValue seems general enough as a thing that stores a "value", so we just trade values that way and that keeps our currency trivial
- we could introduce a new level of layering (ValueObjectSyntheticValue), a new kind of formatter (synthetic value producer), but that would complicate the model (can I have a dynamic with no synthetic children but synthetic value? synthetic value with synthetic children but no dynamic?), and I really couldn't see much benefit to be reaped from this added complexity in the matrix
On the other hand, just defining a synthetic child provider with a get_value but returning no actual children is easy enough that it's not a significant road-block to adoption of this feature
Comes with a test case
llvm-svn: 219330
2014-10-08 18:27:36 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
PyObject *py_return =
|
|
|
|
|
LLDBSwigPython_CallOptionalMember(implementor, callee_name, Py_None);
|
Extend synthetic children to produce synthetic values (as in, those that GetValueAsUnsigned(), GetValueAsCString() would return)
The way to do this is to write a synthetic child provider for your type, and have it vend the (optional) get_value function.
If get_value is defined, and it returns a valid SBValue, that SBValue's value (as in lldb_private::Value) will be used as the synthetic ValueObject's Value
The rationale for doing things this way is twofold:
- there are many possible ways to define a "value" (SBData, a Python number, ...) but SBValue seems general enough as a thing that stores a "value", so we just trade values that way and that keeps our currency trivial
- we could introduce a new level of layering (ValueObjectSyntheticValue), a new kind of formatter (synthetic value producer), but that would complicate the model (can I have a dynamic with no synthetic children but synthetic value? synthetic value with synthetic children but no dynamic?), and I really couldn't see much benefit to be reaped from this added complexity in the matrix
On the other hand, just defining a synthetic child provider with a get_value but returning no actual children is easy enough that it's not a significant road-block to adoption of this feature
Comes with a test case
llvm-svn: 219330
2014-10-08 18:27:36 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
if (py_return == Py_None || py_return == nullptr)
|
|
|
|
|
ret_val = nullptr;
|
Extend synthetic children to produce synthetic values (as in, those that GetValueAsUnsigned(), GetValueAsCString() would return)
The way to do this is to write a synthetic child provider for your type, and have it vend the (optional) get_value function.
If get_value is defined, and it returns a valid SBValue, that SBValue's value (as in lldb_private::Value) will be used as the synthetic ValueObject's Value
The rationale for doing things this way is twofold:
- there are many possible ways to define a "value" (SBData, a Python number, ...) but SBValue seems general enough as a thing that stores a "value", so we just trade values that way and that keeps our currency trivial
- we could introduce a new level of layering (ValueObjectSyntheticValue), a new kind of formatter (synthetic value producer), but that would complicate the model (can I have a dynamic with no synthetic children but synthetic value? synthetic value with synthetic children but no dynamic?), and I really couldn't see much benefit to be reaped from this added complexity in the matrix
On the other hand, just defining a synthetic child provider with a get_value but returning no actual children is easy enough that it's not a significant road-block to adoption of this feature
Comes with a test case
llvm-svn: 219330
2014-10-08 18:27:36 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
lldb::SBValue *sbvalue_ptr = NULL;
|
2015-03-14 08:06:56 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
if (SWIG_ConvertPtr(py_return, (void **)&sbvalue_ptr,
|
|
|
|
|
SWIGTYPE_p_lldb__SBValue, 0) == -1)
|
|
|
|
|
ret_val = nullptr;
|
|
|
|
|
else if (sbvalue_ptr == NULL)
|
|
|
|
|
ret_val = nullptr;
|
|
|
|
|
else
|
|
|
|
|
ret_val = py_return;
|
Extend synthetic children to produce synthetic values (as in, those that GetValueAsUnsigned(), GetValueAsCString() would return)
The way to do this is to write a synthetic child provider for your type, and have it vend the (optional) get_value function.
If get_value is defined, and it returns a valid SBValue, that SBValue's value (as in lldb_private::Value) will be used as the synthetic ValueObject's Value
The rationale for doing things this way is twofold:
- there are many possible ways to define a "value" (SBData, a Python number, ...) but SBValue seems general enough as a thing that stores a "value", so we just trade values that way and that keeps our currency trivial
- we could introduce a new level of layering (ValueObjectSyntheticValue), a new kind of formatter (synthetic value producer), but that would complicate the model (can I have a dynamic with no synthetic children but synthetic value? synthetic value with synthetic children but no dynamic?), and I really couldn't see much benefit to be reaped from this added complexity in the matrix
On the other hand, just defining a synthetic child provider with a get_value but returning no actual children is easy enough that it's not a significant road-block to adoption of this feature
Comes with a test case
llvm-svn: 219330
2014-10-08 18:27:36 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
Py_XDECREF(py_return);
|
|
|
|
|
return ret_val;
|
Extend synthetic children to produce synthetic values (as in, those that GetValueAsUnsigned(), GetValueAsCString() would return)
The way to do this is to write a synthetic child provider for your type, and have it vend the (optional) get_value function.
If get_value is defined, and it returns a valid SBValue, that SBValue's value (as in lldb_private::Value) will be used as the synthetic ValueObject's Value
The rationale for doing things this way is twofold:
- there are many possible ways to define a "value" (SBData, a Python number, ...) but SBValue seems general enough as a thing that stores a "value", so we just trade values that way and that keeps our currency trivial
- we could introduce a new level of layering (ValueObjectSyntheticValue), a new kind of formatter (synthetic value producer), but that would complicate the model (can I have a dynamic with no synthetic children but synthetic value? synthetic value with synthetic children but no dynamic?), and I really couldn't see much benefit to be reaped from this added complexity in the matrix
On the other hand, just defining a synthetic child provider with a get_value but returning no actual children is easy enough that it's not a significant road-block to adoption of this feature
Comes with a test case
llvm-svn: 219330
2014-10-08 18:27:36 +00:00
|
|
|
}
|
|
|
|
|
|
2023-05-08 16:31:27 -07:00
|
|
|
void *lldb_private::python::LLDBSWIGPython_CastPyObjectToSBData(PyObject * data) {
|
2021-12-14 17:20:23 +01:00
|
|
|
lldb::SBData *sb_ptr = nullptr;
|
2021-03-23 16:22:18 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
int valid_cast =
|
|
|
|
|
SWIG_ConvertPtr(data, (void **)&sb_ptr, SWIGTYPE_p_lldb__SBData, 0);
|
2021-03-23 16:22:18 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
if (valid_cast == -1)
|
|
|
|
|
return NULL;
|
2021-03-23 16:22:18 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
return sb_ptr;
|
2021-03-23 16:22:18 +00:00
|
|
|
}
|
|
|
|
|
|
2023-05-08 16:31:27 -07:00
|
|
|
void *lldb_private::python::LLDBSWIGPython_CastPyObjectToSBBreakpoint(PyObject * data) {
|
2023-04-25 15:03:15 -07:00
|
|
|
lldb::SBBreakpoint *sb_ptr = nullptr;
|
|
|
|
|
|
|
|
|
|
int valid_cast =
|
|
|
|
|
SWIG_ConvertPtr(data, (void **)&sb_ptr, SWIGTYPE_p_lldb__SBBreakpoint, 0);
|
|
|
|
|
|
|
|
|
|
if (valid_cast == -1)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
return sb_ptr;
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-08 16:31:27 -07:00
|
|
|
void *lldb_private::python::LLDBSWIGPython_CastPyObjectToSBAttachInfo(PyObject * data) {
|
2023-03-03 15:17:59 -08:00
|
|
|
lldb::SBAttachInfo *sb_ptr = nullptr;
|
|
|
|
|
|
|
|
|
|
int valid_cast =
|
|
|
|
|
SWIG_ConvertPtr(data, (void **)&sb_ptr, SWIGTYPE_p_lldb__SBAttachInfo, 0);
|
|
|
|
|
|
|
|
|
|
if (valid_cast == -1)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
return sb_ptr;
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-08 16:31:27 -07:00
|
|
|
void *lldb_private::python::LLDBSWIGPython_CastPyObjectToSBLaunchInfo(PyObject * data) {
|
2023-03-03 15:17:59 -08:00
|
|
|
lldb::SBLaunchInfo *sb_ptr = nullptr;
|
|
|
|
|
|
|
|
|
|
int valid_cast =
|
|
|
|
|
SWIG_ConvertPtr(data, (void **)&sb_ptr, SWIGTYPE_p_lldb__SBLaunchInfo, 0);
|
|
|
|
|
|
|
|
|
|
if (valid_cast == -1)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
return sb_ptr;
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-08 16:31:27 -07:00
|
|
|
void *lldb_private::python::LLDBSWIGPython_CastPyObjectToSBError(PyObject * data) {
|
2021-12-14 17:20:23 +01:00
|
|
|
lldb::SBError *sb_ptr = nullptr;
|
2021-03-23 16:22:18 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
int valid_cast =
|
|
|
|
|
SWIG_ConvertPtr(data, (void **)&sb_ptr, SWIGTYPE_p_lldb__SBError, 0);
|
2021-03-23 16:22:18 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
if (valid_cast == -1)
|
|
|
|
|
return NULL;
|
2021-03-23 16:22:18 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
return sb_ptr;
|
2021-03-23 16:22:18 +00:00
|
|
|
}
|
|
|
|
|
|
2024-06-27 01:45:30 -07:00
|
|
|
void *lldb_private::python::LLDBSWIGPython_CastPyObjectToSBEvent(PyObject * data) {
|
|
|
|
|
lldb::SBEvent *sb_ptr = nullptr;
|
|
|
|
|
|
|
|
|
|
int valid_cast =
|
|
|
|
|
SWIG_ConvertPtr(data, (void **)&sb_ptr, SWIGTYPE_p_lldb__SBEvent, 0);
|
|
|
|
|
|
|
|
|
|
if (valid_cast == -1)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
return sb_ptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void *lldb_private::python::LLDBSWIGPython_CastPyObjectToSBStream(PyObject * data) {
|
|
|
|
|
lldb::SBStream *sb_ptr = nullptr;
|
|
|
|
|
|
|
|
|
|
int valid_cast =
|
|
|
|
|
SWIG_ConvertPtr(data, (void **)&sb_ptr, SWIGTYPE_p_lldb__SBStream, 0);
|
|
|
|
|
|
|
|
|
|
if (valid_cast == -1)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
return sb_ptr;
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-08 16:31:27 -07:00
|
|
|
void *lldb_private::python::LLDBSWIGPython_CastPyObjectToSBValue(PyObject * data) {
|
2021-12-14 17:20:23 +01:00
|
|
|
lldb::SBValue *sb_ptr = NULL;
|
2021-03-23 16:22:18 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
int valid_cast =
|
|
|
|
|
SWIG_ConvertPtr(data, (void **)&sb_ptr, SWIGTYPE_p_lldb__SBValue, 0);
|
2013-09-25 10:37:32 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
if (valid_cast == -1)
|
|
|
|
|
return NULL;
|
2013-09-25 10:37:32 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
return sb_ptr;
|
2013-09-25 10:37:32 +00:00
|
|
|
}
|
|
|
|
|
|
2023-05-08 16:31:27 -07:00
|
|
|
void *lldb_private::python::LLDBSWIGPython_CastPyObjectToSBMemoryRegionInfo(PyObject *
|
2021-12-14 17:20:23 +01:00
|
|
|
data) {
|
|
|
|
|
lldb::SBMemoryRegionInfo *sb_ptr = NULL;
|
[lldb/Plugins] Add memory region support in ScriptedProcess
This patch adds support for memory regions in Scripted Processes.
This is necessary to read the stack memory region in order to
reconstruct each stackframe of the program.
In order to do so, this patch makes some changes to the SBAPI, namely:
- Add a new constructor for `SBMemoryRegionInfo` that takes arguments
such as the memory region name, address range, permissions ...
This is used when reading memory at some address to compute the offset
in the binary blob provided by the user.
- Add a `GetMemoryRegionContainingAddress` method to `SBMemoryRegionInfoList`
to simplify the access to a specific memory region.
With these changes, lldb is now able to unwind the stack and reconstruct
each frame. On top of that, reloading the target module at offset 0 allows
lldb to symbolicate the `ScriptedProcess` using debug info, similarly to an
ordinary Process.
To test this, I wrote a simple program with multiple function calls, ran it in
lldb, stopped at a leaf function and read the registers values and copied
the stack memory into a binary file. These are then used in the python script.
Differential Revision: https://reviews.llvm.org/D108953
Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2021-10-08 12:25:04 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
int valid_cast = SWIG_ConvertPtr(data, (void **)&sb_ptr,
|
|
|
|
|
SWIGTYPE_p_lldb__SBMemoryRegionInfo, 0);
|
[lldb/Plugins] Add memory region support in ScriptedProcess
This patch adds support for memory regions in Scripted Processes.
This is necessary to read the stack memory region in order to
reconstruct each stackframe of the program.
In order to do so, this patch makes some changes to the SBAPI, namely:
- Add a new constructor for `SBMemoryRegionInfo` that takes arguments
such as the memory region name, address range, permissions ...
This is used when reading memory at some address to compute the offset
in the binary blob provided by the user.
- Add a `GetMemoryRegionContainingAddress` method to `SBMemoryRegionInfoList`
to simplify the access to a specific memory region.
With these changes, lldb is now able to unwind the stack and reconstruct
each frame. On top of that, reloading the target module at offset 0 allows
lldb to symbolicate the `ScriptedProcess` using debug info, similarly to an
ordinary Process.
To test this, I wrote a simple program with multiple function calls, ran it in
lldb, stopped at a leaf function and read the registers values and copied
the stack memory into a binary file. These are then used in the python script.
Differential Revision: https://reviews.llvm.org/D108953
Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2021-10-08 12:25:04 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
if (valid_cast == -1)
|
|
|
|
|
return NULL;
|
[lldb/Plugins] Add memory region support in ScriptedProcess
This patch adds support for memory regions in Scripted Processes.
This is necessary to read the stack memory region in order to
reconstruct each stackframe of the program.
In order to do so, this patch makes some changes to the SBAPI, namely:
- Add a new constructor for `SBMemoryRegionInfo` that takes arguments
such as the memory region name, address range, permissions ...
This is used when reading memory at some address to compute the offset
in the binary blob provided by the user.
- Add a `GetMemoryRegionContainingAddress` method to `SBMemoryRegionInfoList`
to simplify the access to a specific memory region.
With these changes, lldb is now able to unwind the stack and reconstruct
each frame. On top of that, reloading the target module at offset 0 allows
lldb to symbolicate the `ScriptedProcess` using debug info, similarly to an
ordinary Process.
To test this, I wrote a simple program with multiple function calls, ran it in
lldb, stopped at a leaf function and read the registers values and copied
the stack memory into a binary file. These are then used in the python script.
Differential Revision: https://reviews.llvm.org/D108953
Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2021-10-08 12:25:04 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
return sb_ptr;
|
[lldb/Plugins] Add memory region support in ScriptedProcess
This patch adds support for memory regions in Scripted Processes.
This is necessary to read the stack memory region in order to
reconstruct each stackframe of the program.
In order to do so, this patch makes some changes to the SBAPI, namely:
- Add a new constructor for `SBMemoryRegionInfo` that takes arguments
such as the memory region name, address range, permissions ...
This is used when reading memory at some address to compute the offset
in the binary blob provided by the user.
- Add a `GetMemoryRegionContainingAddress` method to `SBMemoryRegionInfoList`
to simplify the access to a specific memory region.
With these changes, lldb is now able to unwind the stack and reconstruct
each frame. On top of that, reloading the target module at offset 0 allows
lldb to symbolicate the `ScriptedProcess` using debug info, similarly to an
ordinary Process.
To test this, I wrote a simple program with multiple function calls, ran it in
lldb, stopped at a leaf function and read the registers values and copied
the stack memory into a binary file. These are then used in the python script.
Differential Revision: https://reviews.llvm.org/D108953
Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2021-10-08 12:25:04 +00:00
|
|
|
}
|
|
|
|
|
|
2024-09-20 16:55:47 -07:00
|
|
|
void *lldb_private::python::LLDBSWIGPython_CastPyObjectToSBExecutionContext(PyObject *
|
|
|
|
|
data) {
|
|
|
|
|
lldb::SBExecutionContext *sb_ptr = NULL;
|
|
|
|
|
|
|
|
|
|
int valid_cast = SWIG_ConvertPtr(data, (void **)&sb_ptr,
|
|
|
|
|
SWIGTYPE_p_lldb__SBExecutionContext, 0);
|
|
|
|
|
|
|
|
|
|
if (valid_cast == -1)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
return sb_ptr;
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-08 16:31:27 -07:00
|
|
|
bool lldb_private::python::SWIGBridge::LLDBSwigPythonCallCommand(
|
2021-12-14 17:20:23 +01:00
|
|
|
const char *python_function_name, const char *session_dictionary_name,
|
2021-11-18 08:11:34 +01:00
|
|
|
lldb::DebuggerSP debugger, const char *args,
|
2021-12-14 17:20:23 +01:00
|
|
|
lldb_private::CommandReturnObject &cmd_retobj,
|
|
|
|
|
lldb::ExecutionContextRefSP exe_ctx_ref_sp) {
|
|
|
|
|
|
|
|
|
|
PyErr_Cleaner py_err_cleaner(true);
|
|
|
|
|
auto dict = PythonModule::MainModule().ResolveName<PythonDictionary>(
|
|
|
|
|
session_dictionary_name);
|
|
|
|
|
auto pfunc = PythonObject::ResolveNameWithDictionary<PythonCallable>(
|
|
|
|
|
python_function_name, dict);
|
|
|
|
|
|
|
|
|
|
if (!pfunc.IsAllocated())
|
|
|
|
|
return false;
|
2015-03-14 08:06:56 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
auto argc = pfunc.GetArgInfo();
|
|
|
|
|
if (!argc) {
|
|
|
|
|
llvm::consumeError(argc.takeError());
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2023-05-08 16:31:27 -07:00
|
|
|
PythonObject debugger_arg = SWIGBridge::ToSWIGWrapper(std::move(debugger));
|
|
|
|
|
auto cmd_retobj_arg = SWIGBridge::ToSWIGWrapper(cmd_retobj);
|
2021-12-14 17:20:23 +01:00
|
|
|
|
|
|
|
|
if (argc.get().max_positional_args < 5u)
|
2021-12-20 14:36:27 +01:00
|
|
|
pfunc(debugger_arg, PythonString(args), cmd_retobj_arg.obj(), dict);
|
2021-12-14 17:20:23 +01:00
|
|
|
else
|
2021-12-17 13:02:21 +01:00
|
|
|
pfunc(debugger_arg, PythonString(args),
|
2023-05-08 16:31:27 -07:00
|
|
|
SWIGBridge::ToSWIGWrapper(std::move(exe_ctx_ref_sp)), cmd_retobj_arg.obj(), dict);
|
2021-12-14 17:20:23 +01:00
|
|
|
|
|
|
|
|
return true;
|
2013-09-25 10:37:32 +00:00
|
|
|
}
|
|
|
|
|
|
2023-05-08 16:31:27 -07:00
|
|
|
bool lldb_private::python::SWIGBridge::LLDBSwigPythonCallCommandObject(
|
2021-11-18 08:11:34 +01:00
|
|
|
PyObject *implementor, lldb::DebuggerSP debugger, const char *args,
|
2021-12-14 17:20:23 +01:00
|
|
|
lldb_private::CommandReturnObject &cmd_retobj,
|
|
|
|
|
lldb::ExecutionContextRefSP exe_ctx_ref_sp) {
|
2015-03-13 02:20:41 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
PyErr_Cleaner py_err_cleaner(true);
|
2015-03-14 08:06:56 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
PythonObject self(PyRefType::Borrowed, implementor);
|
|
|
|
|
auto pfunc = self.ResolveName<PythonCallable>("__call__");
|
2015-03-13 02:20:41 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
if (!pfunc.IsAllocated())
|
|
|
|
|
return false;
|
2015-03-13 02:20:41 +00:00
|
|
|
|
2023-05-08 16:31:27 -07:00
|
|
|
auto cmd_retobj_arg = SWIGBridge::ToSWIGWrapper(cmd_retobj);
|
2015-03-14 08:06:56 +00:00
|
|
|
|
2023-05-08 16:31:27 -07:00
|
|
|
pfunc(SWIGBridge::ToSWIGWrapper(std::move(debugger)), PythonString(args),
|
|
|
|
|
SWIGBridge::ToSWIGWrapper(exe_ctx_ref_sp), cmd_retobj_arg.obj());
|
2015-03-14 08:06:56 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
return true;
|
2015-03-13 02:20:41 +00:00
|
|
|
}
|
|
|
|
|
|
2024-07-03 10:39:34 -07:00
|
|
|
std::optional<std::string>
|
|
|
|
|
lldb_private::python::SWIGBridge::LLDBSwigPythonGetRepeatCommandForScriptedCommand(PyObject *implementor,
|
|
|
|
|
std::string &command) {
|
|
|
|
|
PyErr_Cleaner py_err_cleaner(true);
|
|
|
|
|
|
|
|
|
|
PythonObject self(PyRefType::Borrowed, implementor);
|
|
|
|
|
auto pfunc = self.ResolveName<PythonCallable>("get_repeat_command");
|
|
|
|
|
// If not implemented, repeat the exact command.
|
|
|
|
|
if (!pfunc.IsAllocated())
|
|
|
|
|
return std::nullopt;
|
|
|
|
|
|
|
|
|
|
PythonString command_str(command);
|
|
|
|
|
PythonObject result = pfunc(command_str);
|
|
|
|
|
|
|
|
|
|
// A return of None is the equivalent of nullopt - means repeat
|
|
|
|
|
// the command as is:
|
|
|
|
|
if (result.IsNone())
|
|
|
|
|
return std::nullopt;
|
|
|
|
|
|
|
|
|
|
return result.Str().GetString().str();
|
|
|
|
|
}
|
|
|
|
|
|
2024-09-24 10:00:00 -07:00
|
|
|
StructuredData::DictionarySP
|
|
|
|
|
lldb_private::python::SWIGBridge::LLDBSwigPythonHandleArgumentCompletionForScriptedCommand(PyObject *implementor,
|
|
|
|
|
std::vector<llvm::StringRef> &args_vec, size_t args_pos, size_t pos_in_arg) {
|
|
|
|
|
|
|
|
|
|
PyErr_Cleaner py_err_cleaner(true);
|
|
|
|
|
|
|
|
|
|
PythonObject self(PyRefType::Borrowed, implementor);
|
|
|
|
|
auto pfunc = self.ResolveName<PythonCallable>("handle_argument_completion");
|
|
|
|
|
// If this isn't implemented, return an empty dict to signal falling back to default completion:
|
|
|
|
|
if (!pfunc.IsAllocated())
|
|
|
|
|
return {};
|
|
|
|
|
|
|
|
|
|
PythonList args_list(PyInitialValue::Empty);
|
|
|
|
|
for (auto elem : args_vec)
|
|
|
|
|
args_list.AppendItem(PythonString(elem));
|
|
|
|
|
|
|
|
|
|
PythonObject result = pfunc(args_list, PythonInteger(args_pos), PythonInteger(pos_in_arg));
|
|
|
|
|
// Returning None means do the ordinary completion
|
|
|
|
|
if (result.IsNone())
|
|
|
|
|
return {};
|
|
|
|
|
|
|
|
|
|
// Convert the return dictionary to a DictionarySP.
|
|
|
|
|
StructuredData::ObjectSP result_obj_sp = result.CreateStructuredObject();
|
|
|
|
|
if (!result_obj_sp)
|
|
|
|
|
return {};
|
|
|
|
|
|
|
|
|
|
StructuredData::DictionarySP dict_sp(new StructuredData::Dictionary(result_obj_sp));
|
|
|
|
|
if (dict_sp->GetType() == lldb::eStructuredDataTypeInvalid)
|
|
|
|
|
return {};
|
|
|
|
|
return dict_sp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StructuredData::DictionarySP
|
|
|
|
|
lldb_private::python::SWIGBridge::LLDBSwigPythonHandleOptionArgumentCompletionForScriptedCommand(PyObject *implementor,
|
|
|
|
|
llvm::StringRef &long_option, size_t pos_in_arg) {
|
|
|
|
|
|
|
|
|
|
PyErr_Cleaner py_err_cleaner(true);
|
|
|
|
|
|
|
|
|
|
PythonObject self(PyRefType::Borrowed, implementor);
|
|
|
|
|
auto pfunc = self.ResolveName<PythonCallable>("handle_option_argument_completion");
|
|
|
|
|
// If this isn't implemented, return an empty dict to signal falling back to default completion:
|
|
|
|
|
if (!pfunc.IsAllocated())
|
|
|
|
|
return {};
|
|
|
|
|
|
|
|
|
|
PythonObject result = pfunc(PythonString(long_option), PythonInteger(pos_in_arg));
|
|
|
|
|
// Returning None means do the ordinary completion
|
|
|
|
|
if (result.IsNone())
|
|
|
|
|
return {};
|
|
|
|
|
|
|
|
|
|
// Returning a boolean:
|
|
|
|
|
// True means the completion was handled, but there were no completions
|
|
|
|
|
// False means that the completion was not handled, again, do the ordinary completion:
|
|
|
|
|
if (result.GetObjectType() == PyObjectType::Boolean) {
|
|
|
|
|
if (!result.IsTrue())
|
|
|
|
|
return {};
|
|
|
|
|
// Make up a completion dictionary with the right element:
|
|
|
|
|
StructuredData::DictionarySP dict_sp(new StructuredData::Dictionary());
|
|
|
|
|
dict_sp->AddBooleanItem("no-completion", true);
|
|
|
|
|
return dict_sp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Convert the return dictionary to a DictionarySP.
|
|
|
|
|
StructuredData::ObjectSP result_obj_sp = result.CreateStructuredObject();
|
|
|
|
|
if (!result_obj_sp)
|
|
|
|
|
return {};
|
|
|
|
|
|
|
|
|
|
StructuredData::DictionarySP dict_sp(new StructuredData::Dictionary(result_obj_sp));
|
|
|
|
|
if (dict_sp->GetType() == lldb::eStructuredDataTypeInvalid)
|
|
|
|
|
return {};
|
|
|
|
|
return dict_sp;
|
|
|
|
|
}
|
|
|
|
|
|
Add the ability to define a Python based command that uses CommandObjectParsed (#70734)
This allows you to specify options and arguments and their definitions
and then have lldb handle the completions, help, etc. in the same way
that lldb does for its parsed commands internally.
This feature has some design considerations as well as the code, so I've
also set up an RFC, but I did this one first and will put the RFC
address in here once I've pushed it...
Note, the lldb "ParsedCommand interface" doesn't actually do all the
work that it should. For instance, saying the type of an option that has
a completer doesn't automatically hook up the completer, and ditto for
argument values. We also do almost no work to verify that the arguments
match their definition, or do auto-completion for them. This patch
allows you to make a command that's bug-for-bug compatible with built-in
ones, but I didn't want to stall it on getting the auto-command checking
to work all the way correctly.
As an overall design note, my primary goal here was to make an interface
that worked well in the script language. For that I needed, for
instance, to have a property-based way to get all the option values that
were specified. It was much more convenient to do that by making a
fairly bare-bones C interface to define the options and arguments of a
command, and set their values, and then wrap that in a Python class
(installed along with the other bits of the lldb python module) which
you can then derive from to make your new command. This approach will
also make it easier to experiment.
See the file test_commands.py in the test case for examples of how this
works.
2024-02-13 11:09:47 -08:00
|
|
|
#include "lldb/Interpreter/CommandReturnObject.h"
|
|
|
|
|
|
|
|
|
|
bool lldb_private::python::SWIGBridge::LLDBSwigPythonCallParsedCommandObject(
|
|
|
|
|
PyObject *implementor, lldb::DebuggerSP debugger, lldb_private::StructuredDataImpl &args_impl,
|
|
|
|
|
lldb_private::CommandReturnObject &cmd_retobj,
|
|
|
|
|
lldb::ExecutionContextRefSP exe_ctx_ref_sp) {
|
|
|
|
|
|
|
|
|
|
PyErr_Cleaner py_err_cleaner(true);
|
|
|
|
|
|
|
|
|
|
PythonObject self(PyRefType::Borrowed, implementor);
|
|
|
|
|
auto pfunc = self.ResolveName<PythonCallable>("__call__");
|
|
|
|
|
|
|
|
|
|
if (!pfunc.IsAllocated()) {
|
|
|
|
|
cmd_retobj.AppendError("Could not find '__call__' method in implementation class");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pfunc(SWIGBridge::ToSWIGWrapper(std::move(debugger)), SWIGBridge::ToSWIGWrapper(args_impl),
|
|
|
|
|
SWIGBridge::ToSWIGWrapper(exe_ctx_ref_sp), SWIGBridge::ToSWIGWrapper(cmd_retobj).obj());
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-08 16:31:27 -07:00
|
|
|
PythonObject lldb_private::python::SWIGBridge::LLDBSWIGPythonCreateOSPlugin(
|
2021-12-14 17:20:23 +01:00
|
|
|
const char *python_class_name, const char *session_dictionary_name,
|
|
|
|
|
const lldb::ProcessSP &process_sp) {
|
|
|
|
|
if (python_class_name == NULL || python_class_name[0] == '\0' ||
|
|
|
|
|
!session_dictionary_name)
|
2022-01-17 11:29:35 +01:00
|
|
|
return PythonObject();
|
2013-09-25 10:37:32 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
PyErr_Cleaner py_err_cleaner(true);
|
2015-03-14 08:06:56 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
auto dict = PythonModule::MainModule().ResolveName<PythonDictionary>(
|
|
|
|
|
session_dictionary_name);
|
|
|
|
|
auto pfunc = PythonObject::ResolveNameWithDictionary<PythonCallable>(
|
|
|
|
|
python_class_name, dict);
|
2015-03-14 08:06:56 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
if (!pfunc.IsAllocated())
|
2022-01-17 11:29:35 +01:00
|
|
|
return PythonObject();
|
2015-03-14 08:06:56 +00:00
|
|
|
|
2023-05-08 16:31:27 -07:00
|
|
|
return pfunc(SWIGBridge::ToSWIGWrapper(process_sp));
|
2013-09-25 10:37:32 +00:00
|
|
|
}
|
|
|
|
|
|
2023-05-08 16:31:27 -07:00
|
|
|
PythonObject lldb_private::python::SWIGBridge::LLDBSWIGPython_CreateFrameRecognizer(
|
2021-12-14 17:20:23 +01:00
|
|
|
const char *python_class_name, const char *session_dictionary_name) {
|
|
|
|
|
if (python_class_name == NULL || python_class_name[0] == '\0' ||
|
|
|
|
|
!session_dictionary_name)
|
2022-01-17 11:29:35 +01:00
|
|
|
return PythonObject();
|
2018-10-31 04:00:22 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
PyErr_Cleaner py_err_cleaner(true);
|
2018-10-31 04:00:22 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
auto dict = PythonModule::MainModule().ResolveName<PythonDictionary>(
|
|
|
|
|
session_dictionary_name);
|
|
|
|
|
auto pfunc = PythonObject::ResolveNameWithDictionary<PythonCallable>(
|
|
|
|
|
python_class_name, dict);
|
2018-10-31 04:00:22 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
if (!pfunc.IsAllocated())
|
2022-01-17 11:29:35 +01:00
|
|
|
return PythonObject();
|
2018-10-31 04:00:22 +00:00
|
|
|
|
2022-01-17 11:29:35 +01:00
|
|
|
return pfunc();
|
2018-10-31 04:00:22 +00:00
|
|
|
}
|
|
|
|
|
|
2023-05-08 16:31:27 -07:00
|
|
|
PyObject *lldb_private::python::SWIGBridge::LLDBSwigPython_GetRecognizedArguments(
|
2024-08-23 09:55:47 -07:00
|
|
|
PyObject *implementor, const lldb::StackFrameSP &frame_sp) {
|
2021-12-14 17:20:23 +01:00
|
|
|
static char callee_name[] = "get_recognized_arguments";
|
2018-10-31 04:00:22 +00:00
|
|
|
|
2023-05-08 16:31:27 -07:00
|
|
|
PythonObject arg = SWIGBridge::ToSWIGWrapper(frame_sp);
|
2018-10-31 04:00:22 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
PythonString str(callee_name);
|
|
|
|
|
PyObject *result =
|
2021-12-20 09:57:29 +01:00
|
|
|
PyObject_CallMethodObjArgs(implementor, str.get(), arg.get(), NULL);
|
2021-12-14 17:20:23 +01:00
|
|
|
return result;
|
2018-10-31 04:00:22 +00:00
|
|
|
}
|
2024-08-23 09:55:47 -07:00
|
|
|
|
|
|
|
|
bool lldb_private::python::SWIGBridge::LLDBSwigPython_ShouldHide(
|
|
|
|
|
PyObject *implementor, const lldb::StackFrameSP &frame_sp) {
|
|
|
|
|
static char callee_name[] = "should_hide";
|
|
|
|
|
|
|
|
|
|
PythonObject arg = SWIGBridge::ToSWIGWrapper(frame_sp);
|
|
|
|
|
|
|
|
|
|
PythonString str(callee_name);
|
|
|
|
|
|
|
|
|
|
PyObject *result =
|
|
|
|
|
PyObject_CallMethodObjArgs(implementor, str.get(), arg.get(), NULL);
|
|
|
|
|
bool ret_val = result ? PyObject_IsTrue(result) : false;
|
|
|
|
|
Py_XDECREF(result);
|
|
|
|
|
|
2024-08-23 09:56:09 -07:00
|
|
|
return ret_val;
|
2024-08-23 09:55:47 -07:00
|
|
|
}
|
2018-10-31 04:00:22 +00:00
|
|
|
|
2023-05-08 16:31:27 -07:00
|
|
|
void *lldb_private::python::SWIGBridge::LLDBSWIGPython_GetDynamicSetting(
|
2021-12-14 17:20:23 +01:00
|
|
|
void *module, const char *setting, const lldb::TargetSP &target_sp) {
|
|
|
|
|
if (!module || !setting)
|
|
|
|
|
Py_RETURN_NONE;
|
2013-10-14 21:39:38 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
PyErr_Cleaner py_err_cleaner(true);
|
|
|
|
|
PythonObject py_module(PyRefType::Borrowed, (PyObject *)module);
|
|
|
|
|
auto pfunc = py_module.ResolveName<PythonCallable>("get_dynamic_setting");
|
2015-03-14 08:06:56 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
if (!pfunc.IsAllocated())
|
|
|
|
|
Py_RETURN_NONE;
|
2015-03-14 08:06:56 +00:00
|
|
|
|
2023-05-08 16:31:27 -07:00
|
|
|
auto result = pfunc(SWIGBridge::ToSWIGWrapper(target_sp), PythonString(setting));
|
2015-03-14 08:06:56 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
return result.release();
|
2013-10-14 21:39:38 +00:00
|
|
|
}
|
|
|
|
|
|
2023-05-08 16:31:27 -07:00
|
|
|
bool lldb_private::python::SWIGBridge::LLDBSWIGPythonRunScriptKeywordProcess(
|
[lldb] Fix [some] leaks in python bindings
Using an lldb_private object in the bindings involves three steps
- wrapping the object in it's lldb::SB variant
- using swig to convert/wrap that to a PyObject
- wrapping *that* in a lldb_private::python::PythonObject
Our SBTypeToSWIGWrapper was only handling the middle part. This doesn't
just result in increased boilerplate in the callers, but is also a
functionality problem, as it's very hard to get the lifetime of of all
of these objects right. Most of the callers are creating the SB object
(step 1) on the stack, which means that we end up with dangling python
objects after the function terminates. Most of the time this isn't a
problem, because the python code does not need to persist the objects.
However, there are legitimate cases where they can do it (and even if
the use case is not completely legitimate, crashing is not the best
response to that).
For this reason, some of our code creates the SB object on the heap, but
it has another problem -- it never gets cleaned up.
This patch begins to add a new function (ToSWIGWrapper), which does all
of the three steps, while properly taking care of ownership. In the
first step, I have converted most of the leaky code (except for
SBStructuredData, which needs a bit more work).
Differential Revision: https://reviews.llvm.org/D114259
2021-11-18 21:27:27 +01:00
|
|
|
const char *python_function_name, const char *session_dictionary_name,
|
|
|
|
|
const lldb::ProcessSP &process, std::string &output) {
|
2013-09-25 10:37:32 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
if (python_function_name == NULL || python_function_name[0] == '\0' ||
|
|
|
|
|
!session_dictionary_name)
|
|
|
|
|
return false;
|
2013-09-25 10:37:32 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
PyErr_Cleaner py_err_cleaner(true);
|
2015-03-14 08:06:56 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
auto dict = PythonModule::MainModule().ResolveName<PythonDictionary>(
|
|
|
|
|
session_dictionary_name);
|
|
|
|
|
auto pfunc = PythonObject::ResolveNameWithDictionary<PythonCallable>(
|
|
|
|
|
python_function_name, dict);
|
2015-03-14 08:06:56 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
if (!pfunc.IsAllocated())
|
|
|
|
|
return false;
|
2015-03-14 08:06:56 +00:00
|
|
|
|
2023-05-08 16:31:27 -07:00
|
|
|
auto result = pfunc(SWIGBridge::ToSWIGWrapper(process), dict);
|
2015-03-14 08:06:56 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
output = result.Str().GetString().str();
|
2015-03-14 08:06:56 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
return true;
|
2013-09-25 10:37:32 +00:00
|
|
|
}
|
|
|
|
|
|
2023-05-08 16:31:27 -07:00
|
|
|
std::optional<std::string> lldb_private::python::SWIGBridge::LLDBSWIGPythonRunScriptKeywordThread(
|
2021-12-14 17:20:23 +01:00
|
|
|
const char *python_function_name, const char *session_dictionary_name,
|
2021-11-18 08:11:34 +01:00
|
|
|
lldb::ThreadSP thread) {
|
2021-12-14 17:20:23 +01:00
|
|
|
if (python_function_name == NULL || python_function_name[0] == '\0' ||
|
|
|
|
|
!session_dictionary_name)
|
2022-12-05 22:43:53 -08:00
|
|
|
return std::nullopt;
|
2015-03-14 08:06:56 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
PyErr_Cleaner py_err_cleaner(true);
|
2015-03-14 08:06:56 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
auto dict = PythonModule::MainModule().ResolveName<PythonDictionary>(
|
|
|
|
|
session_dictionary_name);
|
|
|
|
|
auto pfunc = PythonObject::ResolveNameWithDictionary<PythonCallable>(
|
|
|
|
|
python_function_name, dict);
|
2015-03-14 08:06:56 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
if (!pfunc.IsAllocated())
|
2022-12-05 22:43:53 -08:00
|
|
|
return std::nullopt;
|
2015-03-14 08:06:56 +00:00
|
|
|
|
2023-05-08 16:31:27 -07:00
|
|
|
auto result = pfunc(SWIGBridge::ToSWIGWrapper(std::move(thread)), dict);
|
2015-03-14 08:06:56 +00:00
|
|
|
|
2021-11-18 08:11:34 +01:00
|
|
|
return result.Str().GetString().str();
|
2013-09-25 10:37:32 +00:00
|
|
|
}
|
|
|
|
|
|
2023-05-08 16:31:27 -07:00
|
|
|
bool lldb_private::python::SWIGBridge::LLDBSWIGPythonRunScriptKeywordTarget(
|
[lldb] Fix [some] leaks in python bindings
Using an lldb_private object in the bindings involves three steps
- wrapping the object in it's lldb::SB variant
- using swig to convert/wrap that to a PyObject
- wrapping *that* in a lldb_private::python::PythonObject
Our SBTypeToSWIGWrapper was only handling the middle part. This doesn't
just result in increased boilerplate in the callers, but is also a
functionality problem, as it's very hard to get the lifetime of of all
of these objects right. Most of the callers are creating the SB object
(step 1) on the stack, which means that we end up with dangling python
objects after the function terminates. Most of the time this isn't a
problem, because the python code does not need to persist the objects.
However, there are legitimate cases where they can do it (and even if
the use case is not completely legitimate, crashing is not the best
response to that).
For this reason, some of our code creates the SB object on the heap, but
it has another problem -- it never gets cleaned up.
This patch begins to add a new function (ToSWIGWrapper), which does all
of the three steps, while properly taking care of ownership. In the
first step, I have converted most of the leaky code (except for
SBStructuredData, which needs a bit more work).
Differential Revision: https://reviews.llvm.org/D114259
2021-11-18 21:27:27 +01:00
|
|
|
const char *python_function_name, const char *session_dictionary_name,
|
|
|
|
|
const lldb::TargetSP &target, std::string &output) {
|
2013-09-25 10:37:32 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
if (python_function_name == NULL || python_function_name[0] == '\0' ||
|
|
|
|
|
!session_dictionary_name)
|
|
|
|
|
return false;
|
2015-03-14 08:06:56 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
PyErr_Cleaner py_err_cleaner(true);
|
2015-03-14 08:06:56 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
auto dict = PythonModule::MainModule().ResolveName<PythonDictionary>(
|
|
|
|
|
session_dictionary_name);
|
|
|
|
|
auto pfunc = PythonObject::ResolveNameWithDictionary<PythonCallable>(
|
|
|
|
|
python_function_name, dict);
|
2015-03-14 08:06:56 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
if (!pfunc.IsAllocated())
|
|
|
|
|
return false;
|
2015-03-14 08:06:56 +00:00
|
|
|
|
2023-05-08 16:31:27 -07:00
|
|
|
auto result = pfunc(SWIGBridge::ToSWIGWrapper(target), dict);
|
2015-03-14 08:06:56 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
output = result.Str().GetString().str();
|
2015-11-13 01:24:25 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
return true;
|
2013-09-25 10:37:32 +00:00
|
|
|
}
|
|
|
|
|
|
2023-05-08 16:31:27 -07:00
|
|
|
std::optional<std::string> lldb_private::python::SWIGBridge::LLDBSWIGPythonRunScriptKeywordFrame(
|
2021-12-14 17:20:23 +01:00
|
|
|
const char *python_function_name, const char *session_dictionary_name,
|
2021-11-18 08:11:34 +01:00
|
|
|
lldb::StackFrameSP frame) {
|
2021-12-14 17:20:23 +01:00
|
|
|
if (python_function_name == NULL || python_function_name[0] == '\0' ||
|
|
|
|
|
!session_dictionary_name)
|
2022-12-05 22:43:53 -08:00
|
|
|
return std::nullopt;
|
2015-03-14 08:06:56 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
PyErr_Cleaner py_err_cleaner(true);
|
2015-03-14 08:06:56 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
auto dict = PythonModule::MainModule().ResolveName<PythonDictionary>(
|
|
|
|
|
session_dictionary_name);
|
|
|
|
|
auto pfunc = PythonObject::ResolveNameWithDictionary<PythonCallable>(
|
|
|
|
|
python_function_name, dict);
|
2015-03-14 08:06:56 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
if (!pfunc.IsAllocated())
|
2022-12-05 22:43:53 -08:00
|
|
|
return std::nullopt;
|
2015-03-14 08:06:56 +00:00
|
|
|
|
2023-05-08 16:31:27 -07:00
|
|
|
auto result = pfunc(SWIGBridge::ToSWIGWrapper(std::move(frame)), dict);
|
2015-03-14 08:06:56 +00:00
|
|
|
|
2021-11-18 08:11:34 +01:00
|
|
|
return result.Str().GetString().str();
|
2014-10-28 21:07:00 +00:00
|
|
|
}
|
|
|
|
|
|
2023-05-08 16:31:27 -07:00
|
|
|
bool lldb_private::python::SWIGBridge::LLDBSWIGPythonRunScriptKeywordValue(
|
[lldb] Fix [some] leaks in python bindings
Using an lldb_private object in the bindings involves three steps
- wrapping the object in it's lldb::SB variant
- using swig to convert/wrap that to a PyObject
- wrapping *that* in a lldb_private::python::PythonObject
Our SBTypeToSWIGWrapper was only handling the middle part. This doesn't
just result in increased boilerplate in the callers, but is also a
functionality problem, as it's very hard to get the lifetime of of all
of these objects right. Most of the callers are creating the SB object
(step 1) on the stack, which means that we end up with dangling python
objects after the function terminates. Most of the time this isn't a
problem, because the python code does not need to persist the objects.
However, there are legitimate cases where they can do it (and even if
the use case is not completely legitimate, crashing is not the best
response to that).
For this reason, some of our code creates the SB object on the heap, but
it has another problem -- it never gets cleaned up.
This patch begins to add a new function (ToSWIGWrapper), which does all
of the three steps, while properly taking care of ownership. In the
first step, I have converted most of the leaky code (except for
SBStructuredData, which needs a bit more work).
Differential Revision: https://reviews.llvm.org/D114259
2021-11-18 21:27:27 +01:00
|
|
|
const char *python_function_name, const char *session_dictionary_name,
|
|
|
|
|
const lldb::ValueObjectSP &value, std::string &output) {
|
2014-10-28 21:07:00 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
if (python_function_name == NULL || python_function_name[0] == '\0' ||
|
|
|
|
|
!session_dictionary_name)
|
|
|
|
|
return false;
|
2015-03-14 08:06:56 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
PyErr_Cleaner py_err_cleaner(true);
|
2015-03-14 08:06:56 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
auto dict = PythonModule::MainModule().ResolveName<PythonDictionary>(
|
|
|
|
|
session_dictionary_name);
|
|
|
|
|
auto pfunc = PythonObject::ResolveNameWithDictionary<PythonCallable>(
|
|
|
|
|
python_function_name, dict);
|
2015-03-14 08:06:56 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
if (!pfunc.IsAllocated())
|
|
|
|
|
return false;
|
2015-03-14 08:06:56 +00:00
|
|
|
|
2023-05-08 16:31:27 -07:00
|
|
|
auto result = pfunc(SWIGBridge::ToSWIGWrapper(value), dict);
|
2015-03-14 08:06:56 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
output = result.Str().GetString().str();
|
2015-03-14 08:06:56 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
return true;
|
2013-09-25 10:37:32 +00:00
|
|
|
}
|
|
|
|
|
|
2023-05-08 16:31:27 -07:00
|
|
|
bool lldb_private::python::SWIGBridge::LLDBSwigPythonCallModuleInit(
|
2021-12-14 17:20:23 +01:00
|
|
|
const char *python_module_name, const char *session_dictionary_name,
|
2021-11-18 08:11:34 +01:00
|
|
|
lldb::DebuggerSP debugger) {
|
2021-12-14 17:20:23 +01:00
|
|
|
std::string python_function_name_string = python_module_name;
|
|
|
|
|
python_function_name_string += ".__lldb_init_module";
|
|
|
|
|
const char *python_function_name = python_function_name_string.c_str();
|
2015-03-14 08:06:56 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
PyErr_Cleaner py_err_cleaner(true);
|
2015-03-14 08:06:56 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
auto dict = PythonModule::MainModule().ResolveName<PythonDictionary>(
|
|
|
|
|
session_dictionary_name);
|
|
|
|
|
auto pfunc = PythonObject::ResolveNameWithDictionary<PythonCallable>(
|
|
|
|
|
python_function_name, dict);
|
2015-03-14 08:06:56 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
// This method is optional and need not exist. So if we don't find it,
|
|
|
|
|
// it's actually a success, not a failure.
|
|
|
|
|
if (!pfunc.IsAllocated())
|
|
|
|
|
return true;
|
2015-03-14 08:06:56 +00:00
|
|
|
|
2023-05-08 16:31:27 -07:00
|
|
|
pfunc(SWIGBridge::ToSWIGWrapper(std::move(debugger)), dict);
|
2015-03-14 08:06:56 +00:00
|
|
|
|
2021-12-14 17:20:23 +01:00
|
|
|
return true;
|
2013-09-25 10:37:32 +00:00
|
|
|
}
|
2015-03-14 08:06:56 +00:00
|
|
|
|
2023-05-08 16:31:27 -07:00
|
|
|
lldb::ValueObjectSP lldb_private::python::SWIGBridge::LLDBSWIGPython_GetValueObjectSPFromSBValue(
|
2021-12-14 17:20:23 +01:00
|
|
|
void *data) {
|
|
|
|
|
lldb::ValueObjectSP valobj_sp;
|
|
|
|
|
if (data) {
|
|
|
|
|
lldb::SBValue *sb_ptr = (lldb::SBValue *)data;
|
|
|
|
|
valobj_sp = sb_ptr->GetSP();
|
|
|
|
|
}
|
|
|
|
|
return valobj_sp;
|
2013-09-25 10:37:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// For the LogOutputCallback functions
|
2021-12-14 17:20:23 +01:00
|
|
|
static void LLDBSwigPythonCallPythonLogOutputCallback(const char *str,
|
|
|
|
|
void *baton) {
|
|
|
|
|
if (baton != Py_None) {
|
|
|
|
|
SWIG_PYTHON_THREAD_BEGIN_BLOCK;
|
|
|
|
|
PyObject *result = PyObject_CallFunction(
|
|
|
|
|
reinterpret_cast<PyObject *>(baton), const_cast<char *>("s"), str);
|
|
|
|
|
Py_XDECREF(result);
|
|
|
|
|
SWIG_PYTHON_THREAD_END_BLOCK;
|
|
|
|
|
}
|
2013-09-25 10:37:32 +00:00
|
|
|
}
|
2023-02-03 17:09:09 -08:00
|
|
|
|
|
|
|
|
// For DebuggerTerminateCallback functions
|
|
|
|
|
static void LLDBSwigPythonCallPythonSBDebuggerTerminateCallback(lldb::user_id_t debugger_id,
|
|
|
|
|
void *baton) {
|
|
|
|
|
if (baton != Py_None) {
|
|
|
|
|
SWIG_PYTHON_THREAD_BEGIN_BLOCK;
|
|
|
|
|
PyObject *result = PyObject_CallFunction(
|
|
|
|
|
reinterpret_cast<PyObject *>(baton), const_cast<char *>("l"), debugger_id);
|
|
|
|
|
Py_XDECREF(result);
|
|
|
|
|
SWIG_PYTHON_THREAD_END_BLOCK;
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-06-23 21:28:04 -07:00
|
|
|
|
2024-06-11 16:41:31 -07:00
|
|
|
static bool LLDBSwigPythonCallPythonSBCommandInterpreterSetCommandOverrideCallback(void *baton, const char **argv) {
|
|
|
|
|
bool ret_val = false;
|
|
|
|
|
if (baton != Py_None) {
|
|
|
|
|
SWIG_PYTHON_THREAD_BEGIN_BLOCK;
|
|
|
|
|
// Create a PyList of items since we're going to pass it to the callback as a tuple
|
|
|
|
|
// of arguments.
|
|
|
|
|
PyObject *py_argv = PyList_New(0);
|
|
|
|
|
for (const char **arg = argv; arg && *arg; arg++) {
|
|
|
|
|
std::string arg_string = *arg;
|
|
|
|
|
PyObject *py_string = PyUnicode_FromStringAndSize(arg_string.c_str(), arg_string.size());
|
|
|
|
|
PyList_Append(py_argv, py_string);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PyObject *result = PyObject_CallObject(
|
|
|
|
|
reinterpret_cast<PyObject *>(baton), PyList_AsTuple(py_argv));
|
|
|
|
|
ret_val = result ? PyObject_IsTrue(result) : false;
|
|
|
|
|
Py_XDECREF(result);
|
|
|
|
|
SWIG_PYTHON_THREAD_END_BLOCK;
|
|
|
|
|
}
|
|
|
|
|
return ret_val;
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-23 21:28:04 -07:00
|
|
|
static SBError LLDBSwigPythonCallLocateModuleCallback(
|
|
|
|
|
void *callback_baton, const SBModuleSpec &module_spec_sb,
|
|
|
|
|
SBFileSpec &module_file_spec_sb, SBFileSpec &symbol_file_spec_sb) {
|
|
|
|
|
SWIG_Python_Thread_Block swig_thread_block;
|
|
|
|
|
|
|
|
|
|
PyErr_Cleaner py_err_cleaner(true);
|
|
|
|
|
PythonObject module_spec_arg = SWIGBridge::ToSWIGWrapper(
|
2023-07-13 19:22:45 -07:00
|
|
|
std::make_unique<SBModuleSpec>(module_spec_sb));
|
2023-06-23 21:28:04 -07:00
|
|
|
PythonObject module_file_spec_arg = SWIGBridge::ToSWIGWrapper(
|
2023-07-13 19:22:45 -07:00
|
|
|
std::make_unique<SBFileSpec>(module_file_spec_sb));
|
2023-06-23 21:28:04 -07:00
|
|
|
PythonObject symbol_file_spec_arg = SWIGBridge::ToSWIGWrapper(
|
2023-07-13 19:22:45 -07:00
|
|
|
std::make_unique<SBFileSpec>(symbol_file_spec_sb));
|
2023-06-23 21:28:04 -07:00
|
|
|
|
|
|
|
|
PythonCallable callable =
|
|
|
|
|
Retain<PythonCallable>(reinterpret_cast<PyObject *>(callback_baton));
|
|
|
|
|
if (!callable.IsValid()) {
|
|
|
|
|
return SBError("The callback callable is not valid.");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PythonObject result = callable(module_spec_arg, module_file_spec_arg,
|
|
|
|
|
symbol_file_spec_arg);
|
|
|
|
|
|
|
|
|
|
if (!result.IsAllocated())
|
|
|
|
|
return SBError("No result.");
|
|
|
|
|
lldb::SBError *sb_error_ptr = nullptr;
|
|
|
|
|
if (SWIG_ConvertPtr(result.get(), (void **)&sb_error_ptr,
|
|
|
|
|
SWIGTYPE_p_lldb__SBError, 0) == -1) {
|
|
|
|
|
return SBError("Result is not SBError.");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (sb_error_ptr->Success()) {
|
|
|
|
|
lldb::SBFileSpec *sb_module_file_spec_ptr = nullptr;
|
|
|
|
|
if (SWIG_ConvertPtr(module_file_spec_arg.get(),
|
|
|
|
|
(void **)&sb_module_file_spec_ptr,
|
|
|
|
|
SWIGTYPE_p_lldb__SBFileSpec, 0) == -1)
|
|
|
|
|
return SBError("module_file_spec is not SBFileSpec.");
|
|
|
|
|
|
|
|
|
|
lldb::SBFileSpec *sb_symbol_file_spec_ptr = nullptr;
|
|
|
|
|
if (SWIG_ConvertPtr(symbol_file_spec_arg.get(),
|
|
|
|
|
(void **)&sb_symbol_file_spec_ptr,
|
|
|
|
|
SWIGTYPE_p_lldb__SBFileSpec, 0) == -1)
|
|
|
|
|
return SBError("symbol_file_spec is not SBFileSpec.");
|
|
|
|
|
|
|
|
|
|
module_file_spec_sb = *sb_module_file_spec_ptr;
|
|
|
|
|
symbol_file_spec_sb = *sb_symbol_file_spec_ptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return *sb_error_ptr;
|
|
|
|
|
}
|
2013-09-25 10:37:32 +00:00
|
|
|
%}
|