summaryrefslogtreecommitdiff
path: root/lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
AgeCommit message (Collapse)Author
2022-01-24[lldb/Interpreter] Make `ScriptedInterface::ErrorWithMessage` static (NFC)Med Ismail Bennani
This patch changes the `ScriptedInterface::ErrorWithMessage` method to make it `static` which makes it easier to call. The patch also updates its various call sites to reflect this change. Differential Revision: https://reviews.llvm.org/D117374 Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2022-01-24[lldb/Plugins] Fix ScriptedThread IndexID reportingMed Ismail Bennani
When listing all the Scripted Threads of a ScriptedProcess, we can see that all have the thread index set to 1. This is caused by the lldb_private::Thread constructor, which sets the m_index_id member using the provided thread id `tid`. Because the call to the super constructor is done before instantiating the `ScriptedThreadInterface`, lldb can't fetch the thread id from the script instance, so it uses `LLDB_INVALID_THREAD_ID` instead. To mitigate this, this patch takes advantage of the `ScriptedThread::Create` fallible constructor idiom to defer calling the `ScriptedThread` constructor (and the `Thread` super constructor with it), until we can fetch a valid thread id `tid` from the `ScriptedThreadInterface`. rdar://87432065 Differential Revision: https://reviews.llvm.org/D117076 Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2022-01-24[lldb/Plugins] Enrich ScriptedThreads Stop Reasons with ExceptionsMed Ismail Bennani
This patch adds Exceptions to the list of supported stop reasons for Scripted Threads. The main motivation for this is that breakpoints are triggered as a special exception class on ARM platforms, so adding it as a stop reason allows the ScriptedProcess to selected the ScriptedThread that stopped at a breakpoint (or crashed :p). rdar://87430376 Differential Revision: https://reviews.llvm.org/D117074 Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2022-01-24[lldb/Plugins] Add support of multiple ScriptedThreads in a ScriptedProcessMed Ismail Bennani
This patch adds support of multiple Scripted Threads in a ScriptedProcess. This is done by fetching the Scripted Threads info dictionary at every ScriptedProcess::DoUpdateThreadList and iterate over each element to create a new ScriptedThread using the object instance, if it was not already available. This patch also adds the ability to pass a pointer of a script interpreter object instance to initialize a ScriptedInterface instead of having to call the script object initializer in the ScriptedInterface constructor. This is used to instantiate the ScriptedThreadInterface from the ScriptedThread constructor, to be able to perform call on that script interpreter object instance. Finally, the patch also updates the scripted process test to check for multiple threads. rdar://84507704 Differential Revision: https://reviews.llvm.org/D117071 Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2021-12-06[lldb/plugins] Add arm64(e) support to ScriptedProcessMed Ismail Bennani
This patch adds support for arm64(e) targets to ScriptedProcess, by providing the `DynamicRegisterInfo` to the base `lldb.ScriptedThread` class. This allows create and debugging ScriptedProcess on Apple Silicon hardware as well as Apple mobile devices. It also replace the C++ asserts on `ScriptedThread::GetDynamicRegisterInfo` by some error logging, re-enables `TestScriptedProcess` for arm64 Darwin platforms and adds a new invalid Scripted Thread test. rdar://85892451 Differential Revision: https://reviews.llvm.org/D114923 Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2021-11-26Revert "Reland "[lldb] Remove non address bits when looking up memory regions""David Spickett
This reverts commit fac3f20de55769d028bd92220e74f22fa57dd4b2. I found this has broken how we detect the last memory region in GetMemoryRegions/"memory region" command. When you're debugging an AArch64 system with pointer authentication, the ABI plugin will remove the top bit from the end address of the last user mapped area. (lldb) [0x0000fffffffdf000-0x0001000000000000) rw- [stack] ABI plugin removes anything above the 48th bit (48 bit virtual addresses by default on AArch64, leaving an address of 0. (lldb) [0x0000000000000000-0x0000000000400000) --- You get back a mapping for 0 and get into an infinite loop.
2021-11-11[lldb/Plugins] Refactor ScriptedThread register context creationMed Ismail Bennani
This patch changes the ScriptedThread class to create the register context when Process::RefreshStateAfterStop is called rather than doing it in the thread constructor. This is required to update the thread state for execution control. Differential Revision: https://reviews.llvm.org/D112167 Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2021-11-10[lldb] Fix Scripted ProcessLaunchInfo Argument nullptr derefMed Ismail Bennani
This patch adds a new `StructuredData::Dictionary` constructor that takes a `StructuredData::ObjectSP` as an argument. This is used to pass the opaque_ptr from the `SBStructuredData` used to initialize a ScriptedProecss, to the `ProcessLaunchInfo` class. This also updates `SBLaunchInfo::SetScriptedProcessDictionary` to reflect the formentionned changes which solves the nullptr deref. Differential Revision: https://reviews.llvm.org/D112107 Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2021-11-03Reland "[lldb] Remove non address bits when looking up memory regions"David Spickett
This reverts commit 5fbcf677347e38718461496d9e9e184a7a30c3fb. ProcessDebugger is used in ProcessWindows and NativeProcessWindows. I thought I was simplifying things by renaming to DoGetMemoryRegionInfo in ProcessDebugger but the Native process side expects "GetMemoryRegionInfo". Follow the pattern that WriteMemory uses. So: * ProcessWindows::DoGetMemoryRegioninfo calls ProcessDebugger::GetMemoryRegionInfo * NativeProcessWindows::GetMemoryRegionInfo does the same
2021-11-03Revert "[lldb] Remove non address bits when looking up memory regions"David Spickett
This reverts commit 6f5ce43b433706c3ae5c37022d6c0964b6bfadf8 due to build failure on Windows.
2021-11-03[lldb] Remove non address bits when looking up memory regionsDavid Spickett
On AArch64 we have various things using the non address bits of pointers. This means when you lookup their containing region you won't find it if you don't remove them. This changes Process GetMemoryRegionInfo to a non virtual method that uses the current ABI plugin to remove those bits. Then it calls DoGetMemoryRegionInfo. That function does the actual work and is virtual to be overriden by Process implementations. A test case is added that runs on AArch64 Linux using the top byte ignore feature. Reviewed By: omjavaid Differential Revision: https://reviews.llvm.org/D102757
2021-10-28[lldb] Remove ConstString from Process, ScriptInterpreter and StructuredData ↵Pavel Labath
plugin names
2021-10-18[lldb] Return StringRef from PluginInterface::GetPluginNamePavel Labath
There is no reason why this function should be returning a ConstString. While modifying these files, I also fixed several instances where GetPluginName and GetPluginNameStatic were returning different strings. I am not changing the return type of GetPluginNameStatic in this patch, as that would necessitate additional changes, and this patch is big enough as it is. Differential Revision: https://reviews.llvm.org/D111877
2021-10-08[lldb/Plugins] Replace platform-specific macro with LLVM_PRETTY_FUNCTION (NFC)Med Ismail Bennani
This patch refactors Scripted Process and Scripted Thread related classes to use LLVM_PRETTY_FUNCTION instead of the compiler macro. Differential Revision: https://reviews.llvm.org/D111452 Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2021-10-08[lldb/Plugins] Add memory region support in ScriptedProcessMed Ismail Bennani
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[lldb/Plugins] Add support for ScriptedThread in ScriptedProcessMed Ismail Bennani
This patch introduces the `ScriptedThread` class with its python interface. When used with `ScriptedProcess`, `ScriptedThreaad` can provide various information such as the thread state, stop reason or even its register context. This can be used to reconstruct the program stack frames using lldb's unwinder. rdar://74503836 Differential Revision: https://reviews.llvm.org/D107585 Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2021-09-13[lldb] Remove PluginInterface::GetPluginVersionPavel Labath
In all these years, we haven't found a use for this function (it has zero callers). Lets just remove the boilerplate. Differential Revision: https://reviews.llvm.org/D109600
2021-09-03[lldb/Plugins] Introduce Scripted Interface FactoryMed Ismail Bennani
This patch splits the previous `ScriptedProcessPythonInterface` into multiple specific classes: 1. The `ScriptedInterface` abstract class that carries the interface instance object and its virtual pure abstract creation method. 2. The `ScriptedPythonInterface` that holds a generic `Dispatch` method that can be used by various interfaces to call python methods and also keeps a reference to the Python Script Interpreter instance. 3. The `ScriptedProcessInterface` that describes the base Scripted Process model with all the methods used in the underlying script. All these components are used to refactor the `ScriptedProcessPythonInterface` class, making it more modular. This patch is also a requirement for the upcoming work on `ScriptedThread`. Differential Revision: https://reviews.llvm.org/D107521 Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2021-07-22[lldb/Plugins] Add ScriptedProcess Process PluginMed Ismail Bennani
This patch introduces Scripted Processes to lldb. The goal, here, is to be able to attach in the debugger to fake processes that are backed by script files (in Python, Lua, Swift, etc ...) and inspect them statically. Scripted Processes can be used in cooperative multithreading environments like the XNU Kernel or other real-time operating systems, but it can also help us improve the debugger testing infrastructure by writting synthetic tests that simulates hard-to-reproduce process/thread states. Although ScriptedProcess is not feature-complete at the moment, it has basic execution capabilities and will improve in the following patches. rdar://65508855 Differential Revision: https://reviews.llvm.org/D100384 Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2021-03-24Revert "[lldb/Plugins] Add ScriptedProcess Process Plugin"Med Ismail Bennani
Reverting commit b09d44b6ae0901865a0d4b2a0cf797c3cd34eeeb, since it breaks the windows bots: https://lab.llvm.org/buildbot/#/builders/83/builds/4993 It seems to crash the `TestIRMemoryMapWindows.test` test.
2021-03-24[NFC][LLDB] Removing extra semicolons to silence -Wc++98-compat-extra-semi ↵Shafik Yaghmour
diagnostics
2021-03-24[lldb/Plugins] Add ScriptedProcess Process PluginMed Ismail Bennani
This patch introduces Scripted Processes to lldb. The goal, here, is to be able to attach in the debugger to fake processes that are backed by script files (in Python, Lua, Swift, etc ...) and inspect them statically. Scripted Processes can be used in cooperative multithreading environments like the XNU Kernel or other real-time operating systems, but it can also help us improve the debugger testing infrastructure by writting synthetic tests that simulates hard-to-reproduce process/thread states. Although ScriptedProcess is not feature-complete at the moment, it has basic execution capabilities and will improve in the following patches. rdar://65508855 Differential Revision: https://reviews.llvm.org/D95713 Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2021-03-24Revert "[lldb/Plugins] Add ScriptedProcess Process Plugin"David Zarzycki
This reverts commit dd391e1ef762d79f86112dc2480a89c9be066ce1. This patch causes 17 LLDB test regressions on Fedora 33 (x86-64).
2021-03-23[NFC][LLDB] Removing extra semicolons to silence -Wc++98-compat-extra-semi ↵Shafik Yaghmour
diagnostics
2021-03-23[lldb/Plugins] Add ScriptedProcess Process PluginMed Ismail Bennani
This patch introduces Scripted Processes to lldb. The goal, here, is to be able to attach in the debugger to fake processes that are backed by script files (in Python, Lua, Swift, etc ...) and inspect them statically. Scripted Processes can be used in cooperative multithreading environments like the XNU Kernel or other real-time operating systems, but it can also help us improve the debugger testing infrastructure by writting synthetic tests that simulates hard-to-reproduce process/thread states. Although ScriptedProcess is not feature-complete at the moment, it has basic execution capabilities and will improve in the following patches. rdar://65508855 Differential Revision: https://reviews.llvm.org/D95713 Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2021-03-01[lldb] Revert ScriptedProcess patchesMed Ismail Bennani
This patch reverts the following commits: - 5a9c34918bb1526b7e8c29aa5e4fb8d8e27e27b4 - 46796762afe76496ec4dd900f64d0cf4cdc30e99 - 2cff3dec1171188ce04ab1a4373cc1885ab97be1 - 182f0d1a34419445bb19d67581d6ac1afc98b7fa - d62a53aaf1d38a55d1affbd3a30d564a4e9d3171 Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2021-03-01[lldb/Plugins] Add ScriptedProcess Process PluginMed Ismail Bennani
This patch introduces Scripted Processes to lldb. The goal, here, is to be able to attach in the debugger to fake processes that are backed by script files (in Python, Lua, Swift, etc ...) and inspect them statically. Scripted Processes can be used in cooperative multithreading environments like the XNU Kernel or other real-time operating systems, but it can also help us improve the debugger testing infrastructure by writting synthetic tests that simulates hard-to-reproduce process/thread states. Although ScriptedProcess is not feature-complete at the moment, it has basic execution capabilities and will improve in the following patches. rdar://65508855 Differential Revision: https://reviews.llvm.org/D95713 Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>