llvm-project/lldb/source
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
..
API [lldb] Remove LLDB_RECORD_DUMMY_* macros 2022-01-10 12:05:54 -08:00
Breakpoint Fix bugprone argument comments. 2022-01-09 12:21:02 -08:00
Commands [lldb] Remove non address bits from memory read arguments 2022-01-11 13:24:09 +00:00
Core [lldb] Create a property to store the REPL language 2022-01-05 15:03:46 -08:00
DataFormatters [lldb] Remove summary for signed char * 2022-01-06 19:52:24 +01:00
Expression Fix bugprone argument comments. 2022-01-09 12:21:02 -08:00
Host [lldb] fix memory leak in "GetGDBServerRegisterInfoXMLAndProcess" 2022-01-10 14:33:09 -08:00
Initialization [lldb] Make lldbVersion a full fledged library 2021-12-08 15:14:34 -08:00
Interpreter [lldb] Compute fully qualified command names in FindCommandsForApropos 2022-01-09 12:11:32 -08:00
Plugins [lldb/qemu] Implement GetMmapArgumentList 2022-01-11 14:08:03 +01:00
Symbol Use true/false instead of 1/0 (NFC) 2022-01-09 12:21:06 -08:00
Target Use true/false instead of 1/0 (NFC) 2022-01-09 12:21:06 -08:00
Utility [lldb] Remove reproducer instrumentation 2022-01-09 21:40:55 -08:00
Version [lldb] Use LLDB_VERSION_STRING instead of CLANG_VERSION_STRING 2021-12-13 16:58:39 -08:00
CMakeLists.txt [lldb] Make lldbVersion a full fledged library 2021-12-08 15:14:34 -08:00