[Lldb-commits] [PATCH] D107140: [lldb] Show memory tags in memory read output

David Spickett via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Fri Jul 30 02:25:23 PDT 2021


DavidSpickett created this revision.
Herald added subscribers: mgrang, mgorny.
DavidSpickett requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

This extends DumpDataExtractor to also print memory
tags if called with an execution context on a target
that has memory tagging.

(lldb) memory read mte_buf mte_buf+32 -f "x" -s8
0x900fffff7ff8000: 0x0000000000000000 0x0000000000000000 (tag: 0x0)
0x900fffff7ff8010: 0x0000000000000000 0x0000000000000000 (tag: 0x1)

Tags are printed on the end of each line, if that
line has any tags associated with it. Meaning that
untagged memory output is unchanged.

Tags are printed based on the granule(s) of memory that
a line covers. So you may have lines with 1 tag, with many
tags, no tags or partially tagged lines.

There are no special alignment requirements, simply
use "memory read" as usual. All alignment is handled
in DumpDataExtractor.

In the case of partially tagged lines, untagged granules
will show "<no tag>" so that the ordering is obvious.
For example, a line that covers 2 granules where the first
is not tagged:

(lldb) memory read mte_buf-16 mte_buf+16 -l32 -f"x"
0x900fffff7ff7ff0: 0x00000000 <...> (tags: <no tag> 0x0)

The tags are read from a new class MemoryTagMap which
is a sparse map of tag read results.

Using the new tag manager method MakeTaggedRanges you
can get all the sub-ranges of a larger range, that
have memory tagging.

Then loop over these calling ReadMemoryTags, insert them
into the map and request as needed when printing memory dumps.

The tag map is populated once in DumpDataExtractor and re-used
for each subsequently printed line (or recursive call of
DumpDataExtractor, which some formats do).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D107140

Files:
  lldb/include/lldb/Target/MemoryTagManager.h
  lldb/include/lldb/Target/Process.h
  lldb/include/lldb/Utility/MemoryTagMap.h
  lldb/source/Core/DumpDataExtractor.cpp
  lldb/source/Plugins/Process/Utility/MemoryTagManagerAArch64MTE.cpp
  lldb/source/Plugins/Process/Utility/MemoryTagManagerAArch64MTE.h
  lldb/source/Utility/CMakeLists.txt
  lldb/source/Utility/MemoryTagMap.cpp
  lldb/test/API/linux/aarch64/mte_tag_access/TestAArch64LinuxMTEMemoryTagAccess.py
  lldb/unittests/Process/Utility/MemoryTagManagerAArch64MTETest.cpp
  lldb/unittests/Utility/CMakeLists.txt
  lldb/unittests/Utility/MemoryTagMapTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D107140.363001.patch
Type: text/x-patch
Size: 35318 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20210730/729c9bda/attachment-0001.bin>


More information about the lldb-commits mailing list