llvm-project/lldb/examples
Med Ismail Bennani a758c9f720 [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 14:54:07 +02:00
..
customization Python 2/3 compat: StringIO 2019-03-25 15:23:34 +00:00
darwin/heap_find [lldb] Update shebang in heap.py and crashlog.py 2021-07-02 15:33:57 -07:00
functions [NFC] Remove ASCII lines from comments 2019-04-10 20:48:55 +00:00
interposing/darwin/fd_interposing [lldb] NFC remove DISALLOW_COPY_AND_ASSIGN 2020-06-02 13:23:53 -04:00
lookup [NFC] Remove ASCII lines from comments 2019-04-10 20:48:55 +00:00
plugins/commands
python [lldb/Plugins] Add memory region support in ScriptedProcess 2021-10-08 14:54:07 +02:00
scripting Python 2/3 compatibility: from __future__ import print_function 2019-03-21 18:27:40 +00:00
summaries Python 2/3 compat: str vs basestring 2019-03-25 15:21:29 +00:00
synthetic [lldb] Fix gnu_libstdcpp's update methods 2021-05-26 14:52:38 -07:00
test [lldb] Remove LLDB session dir and just store test traces in the respective test build directory 2020-12-04 11:43:10 +01:00