[Lldb-commits] [PATCH] D134033: [lldb/Plugins] Improve error reporting with reading/writing memory in a Scripted Process (WIP)
Med Ismail Bennani via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Fri Sep 16 06:18:57 PDT 2022
mib added inline comments.
================
Comment at: lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp:186
+ StatusSP status_sp = std::make_shared<Status>(error);
+ PythonObject* sb_error = new PythonObject(ToSWIGWrapper(status_sp));
+
----------------
@labath In order to pass down the `Status&` to python, I create a `StatusSP` (to avoid leaking the `lldb_private::Status` type to python), and turn that into a `python::PyObject` by calling `ToSWIGWrapper`. This is why I moved its declaration to `SWIGPythonBridge.h`.
Finally, the `python::PyObject` is wrapped into another `PythonObject*` so it can be passed to `GetPythonValueFormatString` and `PyObject_CallMethod` in `ScriptedPythonInterface::Dispatch`
I tried to follow the logic explained in 7f09ab0, however, when `ToSWIGWrapper` is called at runtime, it crashes in Python:
```
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x10)
frame #0: 0x00000001056f3c3c Python`PyTuple_New + 212
frame #1: 0x0000000135524720 liblldb.16.0.0git.dylib`SWIG_Python_NewShadowInstance(data=0x00006000011d6340, swig_this=0x0000000105ec5d70) at LLDBWrapPython.cpp:2284:28
* frame #2: 0x0000000135515a00 liblldb.16.0.0git.dylib`SWIG_Python_NewPointerObj(self=0x0000000000000000, ptr=0x0000600001dc4040, type=0x000000014448c140, flags=1) at LLDBWrapPython.cpp:2395:22
frame #3: 0x00000001355157f4 liblldb.16.0.0git.dylib`lldb_private::python::ToSWIGHelper(obj=0x0000600001dc4040, info=0x000000014448c140) at python-swigsafecast.swig:5:29
frame #4: 0x0000000135515e14 liblldb.16.0.0git.dylib`lldb_private::python::ToSWIGWrapper(status_sp=std::__1::shared_ptr<lldb_private::Status>::element_type @ 0x0000600000ac9a18 strong=3 weak=1) at python-swigsafecast.swig:37:10
frame #5: 0x00000001367383c4 liblldb.16.0.0git.dylib`lldb_private::ScriptedProcessPythonInterface::ReadMemoryAtAddress(this=0x00006000011cd2c0, address=8034160640, size=512, error=0x000000016b35c650) at ScriptedProcessPythonInterface.cpp:161:45
```
Am I doing something wrong or maybe I'm missing something ?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D134033/new/
https://reviews.llvm.org/D134033
More information about the lldb-commits
mailing list