2016-06-25 07:40:35 +08:00
|
|
|
//===-- SWIG Interface for SBMemoryRegionInfo -------------------*- C++ -*-===//
|
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2016-06-25 07:40:35 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
namespace lldb {
|
|
|
|
|
|
|
|
%feature("docstring",
|
|
|
|
"API clients can get information about memory regions in processes."
|
|
|
|
) SBMemoryRegionInfo;
|
|
|
|
|
|
|
|
class SBMemoryRegionInfo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
SBMemoryRegionInfo ();
|
|
|
|
|
|
|
|
SBMemoryRegionInfo (const lldb::SBMemoryRegionInfo &rhs);
|
|
|
|
|
[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 20:25:04 +08:00
|
|
|
SBMemoryRegionInfo::SBMemoryRegionInfo(const char *name, lldb::addr_t begin,
|
|
|
|
lldb::addr_t end, uint32_t permissions, bool mapped, bool stack_memory);
|
|
|
|
|
2016-06-25 07:40:35 +08:00
|
|
|
~SBMemoryRegionInfo ();
|
|
|
|
|
|
|
|
void
|
|
|
|
Clear();
|
|
|
|
|
|
|
|
lldb::addr_t
|
|
|
|
GetRegionBase ();
|
|
|
|
|
|
|
|
lldb::addr_t
|
|
|
|
GetRegionEnd ();
|
|
|
|
|
|
|
|
bool
|
|
|
|
IsReadable ();
|
|
|
|
|
|
|
|
bool
|
|
|
|
IsWritable ();
|
|
|
|
|
|
|
|
bool
|
|
|
|
IsExecutable ();
|
|
|
|
|
2016-07-07 16:21:28 +08:00
|
|
|
bool
|
|
|
|
IsMapped ();
|
|
|
|
|
2018-12-20 23:05:43 +08:00
|
|
|
const char *
|
|
|
|
GetName ();
|
|
|
|
|
2021-06-21 03:19:50 +08:00
|
|
|
%feature("autodoc", "
|
|
|
|
GetRegionEnd(SBMemoryRegionInfo self) -> lldb::addr_t
|
|
|
|
Returns whether this memory region has a list of modified (dirty)
|
|
|
|
pages available or not. When calling GetNumDirtyPages(), you will
|
|
|
|
have 0 returned for both \"dirty page list is not known\" and
|
|
|
|
\"empty dirty page list\" (that is, no modified pages in this
|
|
|
|
memory region). You must use this method to disambiguate.") HasDirtyMemoryPageList;
|
|
|
|
bool
|
|
|
|
HasDirtyMemoryPageList();
|
|
|
|
|
|
|
|
%feature("autodoc", "
|
|
|
|
GetNumDirtyPages(SBMemoryRegionInfo self) -> uint32_t
|
|
|
|
Return the number of dirty (modified) memory pages in this
|
|
|
|
memory region, if available. You must use the
|
|
|
|
SBMemoryRegionInfo::HasDirtyMemoryPageList() method to
|
|
|
|
determine if a dirty memory list is available; it will depend
|
|
|
|
on the target system can provide this information.") GetNumDirtyPages;
|
|
|
|
uint32_t
|
|
|
|
GetNumDirtyPages();
|
|
|
|
|
|
|
|
%feature("autodoc", "
|
|
|
|
GetDirtyPageAddressAtIndex(SBMemoryRegionInfo self, uint32_t idx) -> lldb::addr_t
|
|
|
|
Return the address of a modified, or dirty, page of memory.
|
|
|
|
If the provided index is out of range, or this memory region
|
|
|
|
does not have dirty page information, LLDB_INVALID_ADDRESS
|
|
|
|
is returned.") GetDirtyPageAddressAtIndex;
|
|
|
|
addr_t
|
|
|
|
GetDirtyPageAddressAtIndex(uint32_t idx);
|
|
|
|
|
|
|
|
%feature("autodoc", "
|
|
|
|
GetPageSize(SBMemoryRegionInfo self) -> int
|
|
|
|
Return the size of pages in this memory region. 0 will be returned
|
|
|
|
if this information was unavailable.") GetPageSize();
|
|
|
|
int
|
|
|
|
GetPageSize();
|
|
|
|
|
2016-06-25 07:40:35 +08:00
|
|
|
bool
|
|
|
|
operator == (const lldb::SBMemoryRegionInfo &rhs) const;
|
|
|
|
|
|
|
|
bool
|
|
|
|
operator != (const lldb::SBMemoryRegionInfo &rhs) const;
|
|
|
|
|
|
|
|
bool
|
|
|
|
GetDescription (lldb::SBStream &description);
|
|
|
|
|
2020-01-09 08:13:03 +08:00
|
|
|
STRING_EXTENSION(SBMemoryRegionInfo)
|
2016-06-25 07:40:35 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace lldb
|