diff options
| author | David Spickett <david.spickett@linaro.org> | 2021-11-03 12:10:40 +0000 |
|---|---|---|
| committer | David Spickett <david.spickett@linaro.org> | 2022-01-11 13:24:09 +0000 |
| commit | 88fdce5be696c7ef992cffce9da9ec6895a1abfc (patch) | |
| tree | 4f505f68d7db02845ca8eac739d3cc597b8ce753 /lldb/source/Commands/CommandObjectMemory.cpp | |
| parent | dbb8d086377ba3a81e44c471840bdbd982c00a35 (diff) | |
[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
Diffstat (limited to 'lldb/source/Commands/CommandObjectMemory.cpp')
| -rw-r--r-- | lldb/source/Commands/CommandObjectMemory.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lldb/source/Commands/CommandObjectMemory.cpp b/lldb/source/Commands/CommandObjectMemory.cpp index 9df42f36fafd..e59cd8028998 100644 --- a/lldb/source/Commands/CommandObjectMemory.cpp +++ b/lldb/source/Commands/CommandObjectMemory.cpp @@ -23,6 +23,7 @@ #include "lldb/Interpreter/Options.h" #include "lldb/Symbol/SymbolFile.h" #include "lldb/Symbol/TypeList.h" +#include "lldb/Target/ABI.h" #include "lldb/Target/Language.h" #include "lldb/Target/MemoryHistory.h" #include "lldb/Target/MemoryRegionInfo.h" @@ -590,9 +591,16 @@ protected: return false; } + ABISP abi = m_exe_ctx.GetProcessPtr()->GetABI(); + if (abi) + addr = abi->FixDataAddress(addr); + if (argc == 2) { lldb::addr_t end_addr = OptionArgParser::ToAddress( &m_exe_ctx, command[1].ref(), LLDB_INVALID_ADDRESS, nullptr); + if (end_addr != LLDB_INVALID_ADDRESS && abi) + end_addr = abi->FixDataAddress(end_addr); + if (end_addr == LLDB_INVALID_ADDRESS) { result.AppendError("invalid end address expression."); result.AppendError(error.AsCString()); |
