-
Notifications
You must be signed in to change notification settings - Fork 15.5k
Open
Open
Copy link
Labels
Description
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:
llvm-project/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
Lines 1638 to 1645 in a87f776
| } 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
SBMemoryRegionInfoshould expose thetypefield from gdb-remote packets