Skip to content

LLDB SBMemoryRegionInfo Python API does not expose type of memory region (macOS) #155692

@patryk4815

Description

@patryk4815

On macOS, when querying memory regions via LLDB’s Python API, the type field returned by gdb-remote packets (e.g., type:malloc-metadata) is not exposed through lldb.SBMemoryRegionInfo.

There is no GetType() method, so scripts cannot access memory region types even though the underlying packets provide this information.

Here type: is parsed:

} else if (name == "type") {
for (llvm::StringRef entry : llvm::split(value, ',')) {
if (entry == "stack")
region_info.SetIsStackMemory(MemoryRegionInfo::eYes);
else if (entry == "heap")
region_info.SetIsStackMemory(MemoryRegionInfo::eNo);
}
} else if (name == "error") {

Example

(lldb) b main
(lldb) log enable gdb-remote all
(lldb) script
>>> regions = lldb.process.GetMemoryRegions()
# Example packets show type field is present
<  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
[0x0000000100024000-0x0000000100028000 RW-]
>>> region.GetType()
Traceback (most recent call last):
  File "<console>", line 1, in <module>
AttributeError: 'SBMemoryRegionInfo' object has no attribute 'GetType'

Expected behavior

  • SBMemoryRegionInfo should expose the type field from gdb-remote packets

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