Skip to content

debugserver does not expose name: attribute in memory region info #155945

@patryk4815

Description

@patryk4815

On macOS, when querying memory regions via LLDB and debugserver, the name: attribute is often missing from memory region packets.

Currently, debugserver only provides the type: field (e.g., type:malloc-metadata or type:heap), but this information is not accessible via the Python API (SBMemoryRegionInfo has no GetType() method).

In pwndbg we want to display meaningful memory region names/types for the user (e.g., [heap], [stack], [malloc-metadata]).
But since debugserver does not provide name:, and Python cannot access type:, scripts cannot display human-readable memory page names.

(lldb) script
>>> regions = lldb.process.GetMemoryRegions()
# Example packets where type is present but name is missing
<  87> read packet: $start:100020000;size:4000;permissions:r;dirty-pages:100020000;type:malloc-metadata;#00
<  88> read packet: $start:100024000;size:4000;permissions:rw;dirty-pages:100024000;type:malloc-metadata;#00

>>> region = lldb.SBMemoryRegionInfo()
>>> regions.GetMemoryRegionAtIndex(7, region)
True
>>> region.GetName()
None

Expected behavior

  • Debugserver should implement the name: attribute in gdb-remote memory region packets.

  • Debugserver should implement more memory mapping names, eg:

  • relevant place in debugserver:

    std::vector<std::string> MachVMRegion::GetMemoryTypes() const {
    std::vector<std::string> types;
    if (m_data.user_tag == VM_MEMORY_STACK) {
    if (m_data.protection == VM_PROT_NONE) {
    types.push_back("stack-guard");
    } else {
    types.push_back("stack");
    }
    }
    if (m_data.user_tag == VM_MEMORY_MALLOC) {
    if (m_data.protection == VM_PROT_NONE)
    types.push_back("malloc-guard");
    else if (m_data.share_mode == SM_EMPTY)
    types.push_back("malloc-reserved");
    else
    types.push_back("malloc-metadata");
    }
    if (m_data.user_tag == VM_MEMORY_MALLOC_NANO ||
    m_data.user_tag == VM_MEMORY_MALLOC_TINY ||
    m_data.user_tag == VM_MEMORY_MALLOC_SMALL ||
    m_data.user_tag == VM_MEMORY_MALLOC_LARGE ||
    m_data.user_tag == VM_MEMORY_MALLOC_LARGE_REUSED ||
    m_data.user_tag == VM_MEMORY_MALLOC_LARGE_REUSABLE ||
    m_data.user_tag == VM_MEMORY_MALLOC_HUGE ||
    m_data.user_tag == VM_MEMORY_REALLOC ||
    m_data.user_tag == VM_MEMORY_SBRK ||
    m_data.user_tag == VM_MEMORY_SANITIZER) {
    types.push_back("heap");
    if (m_data.user_tag == VM_MEMORY_MALLOC_TINY) {
    types.push_back("malloc-tiny");
    }
    if (m_data.user_tag == VM_MEMORY_MALLOC_LARGE) {
    types.push_back("malloc-large");
    }
    if (m_data.user_tag == VM_MEMORY_MALLOC_SMALL) {
    types.push_back("malloc-small");
    }
    }
    return types;
    }

How it looks like in pwndbg:

In pwndbg we forked lldb, and it looks like this, but our changes are too bad for upstream:
Image

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions