how to get all memory maps of debugged process?


does LLDB provide any facilities to retrieve all the memory maps of debugged process from Python script?

on Linux, we can get this from /proc//map, but this is rather mechanical, so if LLDB can get that for me, it would save me from doing that myself.



in case there is no such a facility, how can i get the pid of debugged
process? (so i can use pid to get all the memory maps afterwards)

i looked around, and couldnt find any API that can tell me the pid. any




The lldb_private::Process has:

    virtual Error
    GetMemoryRegionInfo (lldb::addr_t load_addr,
                         MemoryRegionInfo &range_info)
        Error error;
        error.SetErrorString ("Process::GetMemoryRegionInfo() not supported");
        return error;

If this isn't implemented on linux, it would be great to be able to fill it in. The theory being you can start with address zero and use each result in MemoryRegionInfo to figure out what to ask for next. The info returned in MemoryRegionInfo is:

MemoryRegionInfo {
    RangeType m_range;
    OptionalBool m_read;
    OptionalBool m_write;
    OptionalBool m_execute;

So querying at address zero would return a range of 0 - <first valid address> with read/write/execute set to false. Then you can query with "first valid address" to get the next range, etc. This of course would need to be exposed though the public API in SBProcess.

So there isn't anything exposed through the public API now, but it wouldn't be hard to do so with something like:

SBProcess::GetMemoryRegionInfo (
  lldb::addr_t load_addr,
  lldb::addr_t &start_addr,
  lldb::addr_t &end_addr,
  bool &read,
  bool &write,
  bool executable);

Then we would probably want to figure out if we can cache the map results in ProcessLinux based on the mod time of the /proc/<debugged-id>/map file (if that is possible).