llvm-project/lldb
David Spickett 88fdce5be6 [lldb] Remove non address bits from memory read arguments
Addresses on AArch64 can have top byte tags, memory tags and pointer
authentication signatures in the upper bits.

While testing memory tagging I found that memory read couldn't
read a range if the two addresses had different tags. The same
could apply to signed pointers given the right circumstance.

(lldb) memory read mte_buf_alt_tag mte_buf+16
error: end address (0x900fffff7ff8010) must be greater than the start
address (0xa00fffff7ff8000).

Or it would try to read a lot more memory than expected.

(lldb) memory read mte_buf mte_buf_alt_tag+16
error: Normally, 'memory read' will not read over 1024 bytes of data.
error: Please use --force to override this restriction just once.
error: or set target.max-memory-read-size if you will often need a
larger limit.

Fix this by removing non address bits before we calculate the read
range. A test is added for AArch64 Linux that confirms this by using
the top byte ignore feature.

This means that if you do read with a tagged pointer the output
does not include those tags. This is potentially confusing but I think
overall it's better that we don't pretend that we're reading memory
from a range that the process is unable to map.

(lldb) p ptr1
(char *) $4 = 0x3400fffffffff140 "\x80\xf1\xff\xff\xff\xff"
(lldb) p ptr2
(char *) $5 = 0x5600fffffffff140 "\x80\xf1\xff\xff\xff\xff"
(lldb) memory read ptr1 ptr2+16
0xfffffffff140: 80 f1 ff ff ff ff 00 00 38 70 bc f7 ff ff 00 00  ........8p......

Reviewed By: omjavaid, danielkiss

Differential Revision: https://reviews.llvm.org/D103626
2022-01-11 13:24:09 +00:00
..
bindings [lldb] Remove lldbconfig module 2022-01-07 15:58:43 -08:00
cmake [lldb] Use `GNUInstallDirs` to support custom installation dirs. 2021-12-22 00:28:53 +00:00
docs [lldb][docs] Update references to SVN 2022-01-09 13:21:40 -08:00
examples [lldb/plugins] Add arm64(e) support to ScriptedProcess 2021-12-06 16:11:59 -08:00
include/lldb [lldb] fix memory leak in "GetGDBServerRegisterInfoXMLAndProcess" 2022-01-10 14:33:09 -08:00
packages/Python/lldbsuite [lldb/platform-gdb] Clear cached protocol state upon disconnection 2022-01-10 16:27:30 +01:00
resources [lldb] Remove stale LLDB-Info.plist 2021-01-08 10:12:16 -08:00
scripts Prefer /usr/bin/env xxx over /usr/bin/xxx where xxx = perl, python, awk 2021-02-25 11:32:27 +01:00
source [lldb] Remove non address bits from memory read arguments 2022-01-11 13:24:09 +00:00
test [lldb] Remove non address bits from memory read arguments 2022-01-11 13:24:09 +00:00
third_party/Python/module [lldb][NFC] Inclusive language: replace master/slave names for ptys 2021-11-12 10:54:18 -06:00
tools [lldb] Remove lldb-instr 2022-01-10 11:48:16 -08:00
unittests [lldb] Remove reproducer instrumentation 2022-01-09 21:40:55 -08:00
utils [lldb] Match test dependencies name to other LLVM projects. 2021-05-21 00:10:27 -07:00
.clang-format
.clang-tidy [lldb] Replace default bodies of special member functions with = default; 2021-07-02 11:31:16 -07:00
.gitignore
CMakeLists.txt [lldb] Use `GNUInstallDirs` to support custom installation dirs. 2021-12-22 00:28:53 +00:00
CODE_OWNERS.txt
LICENSE.TXT
use_lldb_suite_root.py