[lldb-dev] how to get all memory maps of debugged process?

Greg Clayton gclayton at apple.com
Mon Feb 3 11:46:41 PST 2014


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:

void
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).

Greg

On Feb 1, 2014, at 12:45 AM, Jun Koi <junkoi2004 at gmail.com> wrote:

> hi,
> 
> 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/<debugged-id>/map, but this is rather mechanical, so if LLDB can get that for me, it would save me from doing that myself.
> 
> 
> thanks,
> Jun
> _______________________________________________
> lldb-dev mailing list
> lldb-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev




More information about the lldb-dev mailing list