[Lldb-commits] [PATCH] D105182: [lldb] Add "memory tag write" command

David Spickett via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Wed Jun 30 04:06:59 PDT 2021


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

This adds a new command for writing memory tags.
It is based on the existing "memory write" command.

Syntax: memory tag write <address-expression> <value> [<value> [...]]
(where "value" is a tag value)

(lldb) memory tag write mte_buf 1 2
(lldb) memory tag read mte_buf mte_buf+32
Logical tag: 0x0
Allocation tags:
[0xfffff7ff9000, 0xfffff7ff9010): 0x1
[0xfffff7ff9010, 0xfffff7ff9020): 0x2

The range you are writing to will be calculated by
aligning the address down to a granule boundary then
adding as many granules as there are tags.

(a repeating mode with an end address will be in a follow
up patch)

This is why "memory tag write" uses GetMemoryTagManagerForGranules.
In contrast to "memory tag read" which knows the end of the
range from its arguments.

The command does all the usual argument validation:

- Address must evaluate
- You must supply at least one tag value (though lldb-server would just treat that as a nop anyway)
- Those tag values must be valid for your tagging scheme (e.g. for MTE the value must be > 0 and < 0xf)
- The calculated range must be memory tagged

That last error will show you the final range, not just
the start address you gave the command.

(lldb) memory tag write mte_buf_2+page_size-16 6
(lldb) memory tag write mte_buf_2+page_size-16 6 7
error: Address range 0xfffff7ffaff0:0xfffff7ffb010 is not in a memory tagged region

(note that we do not check if the region is writeable
since lldb can write to it anyway)

The read and write tag tests have been merged into
a single set of "tag access" tests as their test programs would
have been almost identical.
(also I have renamed some of the buffers to better
show what each one is used for)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D105182

Files:
  lldb/source/Commands/CommandObjectMemoryTag.cpp
  lldb/test/API/functionalities/memory/tag/TestMemoryTag.py
  lldb/test/API/linux/aarch64/mte_tag_access/Makefile
  lldb/test/API/linux/aarch64/mte_tag_access/TestAArch64LinuxMTEMemoryTagAccess.py
  lldb/test/API/linux/aarch64/mte_tag_access/main.c
  lldb/test/API/linux/aarch64/mte_tag_read/Makefile
  lldb/test/API/linux/aarch64/mte_tag_read/TestAArch64LinuxMTEMemoryTagRead.py
  lldb/test/API/linux/aarch64/mte_tag_read/main.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D105182.355501.patch
Type: text/x-patch
Size: 24794 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20210630/8ac6d6d0/attachment-0001.bin>


More information about the lldb-commits mailing list