[all-commits] [llvm/llvm-project] 6a7a2e: [lldb] Add "memory tag write" command

David Spickett via All-commits all-commits at lists.llvm.org
Wed Jul 28 02:13:06 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 6a7a2ee8161da84d9a58a88b497b0b47c8df99f3
      https://github.com/llvm/llvm-project/commit/6a7a2ee8161da84d9a58a88b497b0b47c8df99f3
  Author: David Spickett <david.spickett at linaro.org>
  Date:   2021-07-28 (Wed, 28 Jul 2021)

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

  Log Message:
  -----------
  [lldb] Add "memory tag write" command

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 MakeTaggedRange but has
some extra steps to get this specific behaviour.

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)

Reviewed By: omjavaid

Differential Revision: https://reviews.llvm.org/D105182




More information about the All-commits mailing list