diff options
author | Peter Collingbourne <pcc@google.com> | 2020-07-20 15:08:52 -0700 |
---|---|---|
committer | Peter Collingbourne <pcc@google.com> | 2020-07-21 19:05:16 -0700 |
commit | fe8997aff88d2a40f3194040aafd3cce3e451d08 (patch) | |
tree | 475eb0f4b64b0e5ad00acf3b1786532fab1719bb /debuggerd/libdebuggerd/utility.cpp | |
parent | b1fcedb92804f166918e8a02ba9098e453be0139 (diff) |
Include memory tags in memory dump output.
Tags appear in the addresses printed in the memory dump, which seems
like a reasonable place to put them because tagged addresses will
also appear in other places in the tombstone, such as registers and
the fault address.
Bug: 135772972
Change-Id: I52da338347ff6b7503cf5ac80763c540695dc061
Diffstat (limited to 'debuggerd/libdebuggerd/utility.cpp')
-rw-r--r-- | debuggerd/libdebuggerd/utility.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/debuggerd/libdebuggerd/utility.cpp b/debuggerd/libdebuggerd/utility.cpp index d2554aeb7..c8032eb90 100644 --- a/debuggerd/libdebuggerd/utility.cpp +++ b/debuggerd/libdebuggerd/utility.cpp @@ -129,8 +129,9 @@ void _VLOG(log_t* log, enum logtype ltype, const char* fmt, va_list ap) { #define MEMORY_BYTES_PER_LINE 16 void dump_memory(log_t* log, unwindstack::Memory* memory, uint64_t addr, const std::string& label) { - // Align the address to sizeof(long) and start 32 bytes before the address. - addr &= ~(sizeof(long) - 1); + // Align the address to the number of bytes per line to avoid confusing memory tag output if + // memory is tagged and we start from a misaligned address. Start 32 bytes before the address. + addr &= ~(MEMORY_BYTES_PER_LINE - 1); if (addr >= 4128) { addr -= 32; } @@ -204,8 +205,13 @@ void dump_memory(log_t* log, unwindstack::Memory* memory, uint64_t addr, const s size_t current = 0; size_t total_bytes = start + bytes; for (size_t line = 0; line < MEMORY_BYTES_TO_DUMP / MEMORY_BYTES_PER_LINE; line++) { + uint64_t tagged_addr = addr; + long tag = memory->ReadTag(addr); + if (tag >= 0) { + tagged_addr |= static_cast<uint64_t>(tag) << 56; + } std::string logline; - android::base::StringAppendF(&logline, " %" PRIPTR, addr); + android::base::StringAppendF(&logline, " %" PRIPTR, tagged_addr); addr += MEMORY_BYTES_PER_LINE; std::string ascii; |