Clean up usage of 32 bit/64 bit checks.
Rather than have to create a number of #if defines for the memory dumping parts of the tombstone, create a single function to generate these strings for the memory tests. Make CrasherTest.smoke use a regex that passes on 32 bit and 64 bit. Make the tests page size agnostic. Bug: 339017792 Test: Treehugger. Test: Ran 32 bit and 64 bit versions of tests on a real device. Test: Ran on the aosp_cf_x86_64_phone_pgagnostic-trunk_staging-userdebug Change-Id: If9365061b85de23b00a1bf947d85923cde06c068
This commit is contained in:
parent
eba4057e94
commit
2f77c2a516
2 changed files with 107 additions and 198 deletions
|
@ -332,12 +332,7 @@ TEST_F(CrasherTest, smoke) {
|
|||
|
||||
std::string result;
|
||||
ConsumeFd(std::move(output_fd), &result);
|
||||
#ifdef __LP64__
|
||||
ASSERT_MATCH(result,
|
||||
R"(signal 11 \(SIGSEGV\), code 1 \(SEGV_MAPERR\), fault addr 0x000000000000dead)");
|
||||
#else
|
||||
ASSERT_MATCH(result, R"(signal 11 \(SIGSEGV\), code 1 \(SEGV_MAPERR\), fault addr 0x0000dead)");
|
||||
#endif
|
||||
ASSERT_MATCH(result, R"(signal 11 \(SIGSEGV\), code 1 \(SEGV_MAPERR\), fault addr 0x0+dead)");
|
||||
|
||||
if (mte_supported()) {
|
||||
// Test that the default TAGGED_ADDR_CTRL value is set.
|
||||
|
@ -1829,10 +1824,14 @@ GwpAsanTestParameters gwp_asan_tests[] = {
|
|||
"Use After Free, 0 bytes into a 7-byte allocation"},
|
||||
{/* alloc_size */ 15, /* free_before_access */ true, /* access_offset */ 1,
|
||||
"Use After Free, 1 byte into a 15-byte allocation"},
|
||||
{/* alloc_size */ 4096, /* free_before_access */ false, /* access_offset */ 4098,
|
||||
"Buffer Overflow, 2 bytes right of a 4096-byte allocation"},
|
||||
{/* alloc_size */ 4096, /* free_before_access */ false, /* access_offset */ -1,
|
||||
"Buffer Underflow, 1 byte left of a 4096-byte allocation"},
|
||||
{/* alloc_size */ static_cast<size_t>(getpagesize()), /* free_before_access */ false,
|
||||
/* access_offset */ getpagesize() + 2,
|
||||
android::base::StringPrintf("Buffer Overflow, 2 bytes right of a %d-byte allocation",
|
||||
getpagesize())},
|
||||
{/* alloc_size */ static_cast<size_t>(getpagesize()), /* free_before_access */ false,
|
||||
/* access_offset */ -1,
|
||||
android::base::StringPrintf("Buffer Underflow, 1 byte left of a %d-byte allocation",
|
||||
getpagesize())},
|
||||
};
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
|
@ -2977,30 +2976,34 @@ TEST_F(CrasherTest, verify_map_format) {
|
|||
std::string match_str;
|
||||
// Verify none.
|
||||
match_str = android::base::StringPrintf(
|
||||
" %s-%s --- 0 1000\\n",
|
||||
" %s-%s --- 0 %x\\n",
|
||||
format_map_pointer(reinterpret_cast<uintptr_t>(none_map)).c_str(),
|
||||
format_map_pointer(reinterpret_cast<uintptr_t>(none_map) + getpagesize() - 1).c_str());
|
||||
format_map_pointer(reinterpret_cast<uintptr_t>(none_map) + getpagesize() - 1).c_str(),
|
||||
getpagesize());
|
||||
ASSERT_MATCH(result, match_str);
|
||||
|
||||
// Verify read-only.
|
||||
match_str = android::base::StringPrintf(
|
||||
" %s-%s r-- 0 1000\\n",
|
||||
" %s-%s r-- 0 %x\\n",
|
||||
format_map_pointer(reinterpret_cast<uintptr_t>(r_map)).c_str(),
|
||||
format_map_pointer(reinterpret_cast<uintptr_t>(r_map) + getpagesize() - 1).c_str());
|
||||
format_map_pointer(reinterpret_cast<uintptr_t>(r_map) + getpagesize() - 1).c_str(),
|
||||
getpagesize());
|
||||
ASSERT_MATCH(result, match_str);
|
||||
|
||||
// Verify write-only.
|
||||
match_str = android::base::StringPrintf(
|
||||
" %s-%s -w- 0 1000\\n",
|
||||
" %s-%s -w- 0 %x\\n",
|
||||
format_map_pointer(reinterpret_cast<uintptr_t>(w_map)).c_str(),
|
||||
format_map_pointer(reinterpret_cast<uintptr_t>(w_map) + getpagesize() - 1).c_str());
|
||||
format_map_pointer(reinterpret_cast<uintptr_t>(w_map) + getpagesize() - 1).c_str(),
|
||||
getpagesize());
|
||||
ASSERT_MATCH(result, match_str);
|
||||
|
||||
// Verify exec-only.
|
||||
match_str = android::base::StringPrintf(
|
||||
" %s-%s --x 0 1000\\n",
|
||||
" %s-%s --x 0 %x\\n",
|
||||
format_map_pointer(reinterpret_cast<uintptr_t>(x_map)).c_str(),
|
||||
format_map_pointer(reinterpret_cast<uintptr_t>(x_map) + getpagesize() - 1).c_str());
|
||||
format_map_pointer(reinterpret_cast<uintptr_t>(x_map) + getpagesize() - 1).c_str(),
|
||||
getpagesize());
|
||||
ASSERT_MATCH(result, match_str);
|
||||
|
||||
// Verify file map with non-zero offset and a name.
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
#include <string>
|
||||
|
||||
#include <android-base/file.h>
|
||||
#include <android-base/logging.h>
|
||||
#include <android-base/stringprintf.h>
|
||||
#include <gtest/gtest.h>
|
||||
#include <unwindstack/Memory.h>
|
||||
|
||||
|
@ -27,61 +29,64 @@
|
|||
|
||||
#include "log_fake.h"
|
||||
|
||||
const char g_expected_full_dump[] =
|
||||
"\nmemory near r1:\n"
|
||||
#if defined(__LP64__)
|
||||
" 0000000012345650 0706050403020100 0f0e0d0c0b0a0908 ................\n"
|
||||
" 0000000012345660 1716151413121110 1f1e1d1c1b1a1918 ................\n"
|
||||
" 0000000012345670 2726252423222120 2f2e2d2c2b2a2928 !\"#$%&'()*+,-./\n"
|
||||
" 0000000012345680 3736353433323130 3f3e3d3c3b3a3938 0123456789:;<=>?\n"
|
||||
" 0000000012345690 4746454443424140 4f4e4d4c4b4a4948 @ABCDEFGHIJKLMNO\n"
|
||||
" 00000000123456a0 5756555453525150 5f5e5d5c5b5a5958 PQRSTUVWXYZ[\\]^_\n"
|
||||
" 00000000123456b0 6766656463626160 6f6e6d6c6b6a6968 `abcdefghijklmno\n"
|
||||
" 00000000123456c0 7776757473727170 7f7e7d7c7b7a7978 pqrstuvwxyz{|}~.\n"
|
||||
" 00000000123456d0 8786858483828180 8f8e8d8c8b8a8988 ................\n"
|
||||
" 00000000123456e0 9796959493929190 9f9e9d9c9b9a9998 ................\n"
|
||||
" 00000000123456f0 a7a6a5a4a3a2a1a0 afaeadacabaaa9a8 ................\n"
|
||||
" 0000000012345700 b7b6b5b4b3b2b1b0 bfbebdbcbbbab9b8 ................\n"
|
||||
" 0000000012345710 c7c6c5c4c3c2c1c0 cfcecdcccbcac9c8 ................\n"
|
||||
" 0000000012345720 d7d6d5d4d3d2d1d0 dfdedddcdbdad9d8 ................\n"
|
||||
" 0000000012345730 e7e6e5e4e3e2e1e0 efeeedecebeae9e8 ................\n"
|
||||
" 0000000012345740 f7f6f5f4f3f2f1f0 fffefdfcfbfaf9f8 ................\n";
|
||||
#else
|
||||
" 12345650 03020100 07060504 0b0a0908 0f0e0d0c ................\n"
|
||||
" 12345660 13121110 17161514 1b1a1918 1f1e1d1c ................\n"
|
||||
" 12345670 23222120 27262524 2b2a2928 2f2e2d2c !\"#$%&'()*+,-./\n"
|
||||
" 12345680 33323130 37363534 3b3a3938 3f3e3d3c 0123456789:;<=>?\n"
|
||||
" 12345690 43424140 47464544 4b4a4948 4f4e4d4c @ABCDEFGHIJKLMNO\n"
|
||||
" 123456a0 53525150 57565554 5b5a5958 5f5e5d5c PQRSTUVWXYZ[\\]^_\n"
|
||||
" 123456b0 63626160 67666564 6b6a6968 6f6e6d6c `abcdefghijklmno\n"
|
||||
" 123456c0 73727170 77767574 7b7a7978 7f7e7d7c pqrstuvwxyz{|}~.\n"
|
||||
" 123456d0 83828180 87868584 8b8a8988 8f8e8d8c ................\n"
|
||||
" 123456e0 93929190 97969594 9b9a9998 9f9e9d9c ................\n"
|
||||
" 123456f0 a3a2a1a0 a7a6a5a4 abaaa9a8 afaeadac ................\n"
|
||||
" 12345700 b3b2b1b0 b7b6b5b4 bbbab9b8 bfbebdbc ................\n"
|
||||
" 12345710 c3c2c1c0 c7c6c5c4 cbcac9c8 cfcecdcc ................\n"
|
||||
" 12345720 d3d2d1d0 d7d6d5d4 dbdad9d8 dfdedddc ................\n"
|
||||
" 12345730 e3e2e1e0 e7e6e5e4 ebeae9e8 efeeedec ................\n"
|
||||
" 12345740 f3f2f1f0 f7f6f5f4 fbfaf9f8 fffefdfc ................\n";
|
||||
#endif
|
||||
std::string GetMemoryString(uintptr_t addr, const std::vector<uint64_t>& data) {
|
||||
// Must be even number of data values.
|
||||
CHECK((data.size() & 1) == 0);
|
||||
|
||||
const char g_expected_partial_dump[] = \
|
||||
"\nmemory near pc:\n"
|
||||
std::string str;
|
||||
for (size_t i = 0; i < data.size(); i += 2) {
|
||||
str += " ";
|
||||
std::string ascii_str = "";
|
||||
for (size_t j = 0; j < 2; j++) {
|
||||
for (size_t k = 0; k < 8; k++) {
|
||||
uint8_t c = (data[i + j] >> (k * 8)) & 0xff;
|
||||
if (c >= 0x20 && c < 0x7f) {
|
||||
ascii_str += c;
|
||||
} else {
|
||||
ascii_str += '.';
|
||||
}
|
||||
}
|
||||
}
|
||||
#if defined(__LP64__)
|
||||
" 00000000123455e0 0706050403020100 0f0e0d0c0b0a0908 ................\n"
|
||||
" 00000000123455f0 1716151413121110 1f1e1d1c1b1a1918 ................\n"
|
||||
" 0000000012345600 2726252423222120 2f2e2d2c2b2a2928 !\"#$%&'()*+,-./\n"
|
||||
" 0000000012345610 3736353433323130 3f3e3d3c3b3a3938 0123456789:;<=>?\n"
|
||||
" 0000000012345620 4746454443424140 4f4e4d4c4b4a4948 @ABCDEFGHIJKLMNO\n"
|
||||
" 0000000012345630 5756555453525150 5f5e5d5c5b5a5958 PQRSTUVWXYZ[\\]^_\n";
|
||||
str += android::base::StringPrintf("%016zx %016zx %016zx ", addr, data[i], data[i + 1]);
|
||||
#else
|
||||
" 123455e0 03020100 07060504 0b0a0908 0f0e0d0c ................\n"
|
||||
" 123455f0 13121110 17161514 1b1a1918 1f1e1d1c ................\n"
|
||||
" 12345600 23222120 27262524 2b2a2928 2f2e2d2c !\"#$%&'()*+,-./\n"
|
||||
" 12345610 33323130 37363534 3b3a3938 3f3e3d3c 0123456789:;<=>?\n"
|
||||
" 12345620 43424140 47464544 4b4a4948 4f4e4d4c @ABCDEFGHIJKLMNO\n"
|
||||
" 12345630 53525150 57565554 5b5a5958 5f5e5d5c PQRSTUVWXYZ[\\]^_\n";
|
||||
str += android::base::StringPrintf(
|
||||
"%08zx %08zx %08zx %08zx %08zx ", addr, static_cast<uintptr_t>(data[i] & 0xffffffff),
|
||||
static_cast<uintptr_t>(data[i] >> 32), static_cast<uintptr_t>(data[i + 1] & 0xffffffff),
|
||||
static_cast<uintptr_t>(data[i + 1] >> 32));
|
||||
#endif
|
||||
str += ascii_str + "\n";
|
||||
addr += 0x10;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
const std::vector<uint64_t>& GetDefaultData() {
|
||||
static std::vector<uint64_t> data(
|
||||
{0x0706050403020100UL, 0x0f0e0d0c0b0a0908UL, 0x1716151413121110UL, 0x1f1e1d1c1b1a1918UL,
|
||||
0x2726252423222120UL, 0x2f2e2d2c2b2a2928UL, 0x3736353433323130UL, 0x3f3e3d3c3b3a3938UL,
|
||||
0x4746454443424140UL, 0x4f4e4d4c4b4a4948UL, 0x5756555453525150UL, 0x5f5e5d5c5b5a5958UL,
|
||||
0x6766656463626160UL, 0x6f6e6d6c6b6a6968UL, 0x7776757473727170UL, 0x7f7e7d7c7b7a7978UL,
|
||||
0x8786858483828180UL, 0x8f8e8d8c8b8a8988UL, 0x9796959493929190UL, 0x9f9e9d9c9b9a9998UL,
|
||||
0xa7a6a5a4a3a2a1a0UL, 0xafaeadacabaaa9a8UL, 0xb7b6b5b4b3b2b1b0UL, 0xbfbebdbcbbbab9b8UL,
|
||||
0xc7c6c5c4c3c2c1c0UL, 0xcfcecdcccbcac9c8UL, 0xd7d6d5d4d3d2d1d0UL, 0xdfdedddcdbdad9d8UL,
|
||||
0xe7e6e5e4e3e2e1e0UL, 0xefeeedecebeae9e8UL, 0xf7f6f5f4f3f2f1f0UL, 0xfffefdfcfbfaf9f8UL});
|
||||
return data;
|
||||
}
|
||||
|
||||
std::string GetFullDumpString() {
|
||||
std::string str = "\nmemory near r1:\n";
|
||||
str += GetMemoryString(0x12345650U, GetDefaultData());
|
||||
return str;
|
||||
}
|
||||
|
||||
std::string GetPartialDumpString() {
|
||||
std::string str = "\nmemory near pc:\n";
|
||||
std::vector<uint64_t> data = GetDefaultData();
|
||||
data.resize(12);
|
||||
str += GetMemoryString(0x123455e0U, data);
|
||||
return str;
|
||||
}
|
||||
|
||||
class MemoryMock : public unwindstack::Memory {
|
||||
public:
|
||||
|
@ -189,7 +194,7 @@ TEST_F(DumpMemoryTest, aligned_addr) {
|
|||
std::string tombstone_contents;
|
||||
ASSERT_TRUE(lseek(log_.tfd, 0, SEEK_SET) == 0);
|
||||
ASSERT_TRUE(android::base::ReadFdToString(log_.tfd, &tombstone_contents));
|
||||
ASSERT_STREQ(g_expected_full_dump, tombstone_contents.c_str());
|
||||
ASSERT_EQ(GetFullDumpString(), tombstone_contents);
|
||||
|
||||
// Verify that the log buf is empty, and no error messages.
|
||||
ASSERT_STREQ("", getFakeLogBuf().c_str());
|
||||
|
@ -209,7 +214,7 @@ TEST_F(DumpMemoryTest, partial_read) {
|
|||
std::string tombstone_contents;
|
||||
ASSERT_TRUE(lseek(log_.tfd, 0, SEEK_SET) == 0);
|
||||
ASSERT_TRUE(android::base::ReadFdToString(log_.tfd, &tombstone_contents));
|
||||
ASSERT_STREQ(g_expected_full_dump, tombstone_contents.c_str());
|
||||
ASSERT_EQ(GetFullDumpString(), tombstone_contents);
|
||||
|
||||
// Verify that the log buf is empty, and no error messages.
|
||||
ASSERT_STREQ("", getFakeLogBuf().c_str());
|
||||
|
@ -228,7 +233,7 @@ TEST_F(DumpMemoryTest, unaligned_addr) {
|
|||
std::string tombstone_contents;
|
||||
ASSERT_TRUE(lseek(log_.tfd, 0, SEEK_SET) == 0);
|
||||
ASSERT_TRUE(android::base::ReadFdToString(log_.tfd, &tombstone_contents));
|
||||
ASSERT_STREQ(g_expected_full_dump, tombstone_contents.c_str());
|
||||
ASSERT_EQ(GetFullDumpString(), tombstone_contents);
|
||||
|
||||
// Verify that the log buf is empty, and no error messages.
|
||||
ASSERT_STREQ("", getFakeLogBuf().c_str());
|
||||
|
@ -260,7 +265,7 @@ TEST_F(DumpMemoryTest, memory_partially_unreadable) {
|
|||
std::string tombstone_contents;
|
||||
ASSERT_TRUE(lseek(log_.tfd, 0, SEEK_SET) == 0);
|
||||
ASSERT_TRUE(android::base::ReadFdToString(log_.tfd, &tombstone_contents));
|
||||
ASSERT_STREQ(g_expected_partial_dump, tombstone_contents.c_str());
|
||||
ASSERT_EQ(GetPartialDumpString(), tombstone_contents);
|
||||
|
||||
// Verify that the log buf is empty, and no error messages.
|
||||
ASSERT_STREQ("", getFakeLogBuf().c_str());
|
||||
|
@ -280,7 +285,7 @@ TEST_F(DumpMemoryTest, memory_partially_unreadable_unaligned_return) {
|
|||
std::string tombstone_contents;
|
||||
ASSERT_TRUE(lseek(log_.tfd, 0, SEEK_SET) == 0);
|
||||
ASSERT_TRUE(android::base::ReadFdToString(log_.tfd, &tombstone_contents));
|
||||
ASSERT_STREQ(g_expected_partial_dump, tombstone_contents.c_str());
|
||||
ASSERT_EQ(GetPartialDumpString(), tombstone_contents);
|
||||
|
||||
#if defined(__LP64__)
|
||||
ASSERT_STREQ("6 DEBUG Bytes read 102, is not a multiple of 8\n", getFakeLogPrint().c_str());
|
||||
|
@ -305,7 +310,7 @@ TEST_F(DumpMemoryTest, memory_partially_unreadable_two_unaligned_reads) {
|
|||
std::string tombstone_contents;
|
||||
ASSERT_TRUE(lseek(log_.tfd, 0, SEEK_SET) == 0);
|
||||
ASSERT_TRUE(android::base::ReadFdToString(log_.tfd, &tombstone_contents));
|
||||
ASSERT_STREQ(g_expected_partial_dump, tombstone_contents.c_str());
|
||||
ASSERT_EQ(GetPartialDumpString(), tombstone_contents);
|
||||
|
||||
#if defined(__LP64__)
|
||||
ASSERT_STREQ("6 DEBUG Bytes read 45, is not a multiple of 8\n"
|
||||
|
@ -331,44 +336,9 @@ TEST_F(DumpMemoryTest, address_low_fence) {
|
|||
std::string tombstone_contents;
|
||||
ASSERT_TRUE(lseek(log_.tfd, 0, SEEK_SET) == 0);
|
||||
ASSERT_TRUE(android::base::ReadFdToString(log_.tfd, &tombstone_contents));
|
||||
const char* expected_dump = \
|
||||
"\nmemory near r1:\n"
|
||||
#if defined(__LP64__)
|
||||
" 0000000000001000 0000000000000000 0000000000000000 ................\n"
|
||||
" 0000000000001010 0000000000000000 0000000000000000 ................\n"
|
||||
" 0000000000001020 0000000000000000 0000000000000000 ................\n"
|
||||
" 0000000000001030 0000000000000000 0000000000000000 ................\n"
|
||||
" 0000000000001040 0000000000000000 0000000000000000 ................\n"
|
||||
" 0000000000001050 0000000000000000 0000000000000000 ................\n"
|
||||
" 0000000000001060 0000000000000000 0000000000000000 ................\n"
|
||||
" 0000000000001070 0000000000000000 0000000000000000 ................\n"
|
||||
" 0000000000001080 0000000000000000 0000000000000000 ................\n"
|
||||
" 0000000000001090 0000000000000000 0000000000000000 ................\n"
|
||||
" 00000000000010a0 0000000000000000 0000000000000000 ................\n"
|
||||
" 00000000000010b0 0000000000000000 0000000000000000 ................\n"
|
||||
" 00000000000010c0 0000000000000000 0000000000000000 ................\n"
|
||||
" 00000000000010d0 0000000000000000 0000000000000000 ................\n"
|
||||
" 00000000000010e0 0000000000000000 0000000000000000 ................\n"
|
||||
" 00000000000010f0 0000000000000000 0000000000000000 ................\n";
|
||||
#else
|
||||
" 00001000 00000000 00000000 00000000 00000000 ................\n"
|
||||
" 00001010 00000000 00000000 00000000 00000000 ................\n"
|
||||
" 00001020 00000000 00000000 00000000 00000000 ................\n"
|
||||
" 00001030 00000000 00000000 00000000 00000000 ................\n"
|
||||
" 00001040 00000000 00000000 00000000 00000000 ................\n"
|
||||
" 00001050 00000000 00000000 00000000 00000000 ................\n"
|
||||
" 00001060 00000000 00000000 00000000 00000000 ................\n"
|
||||
" 00001070 00000000 00000000 00000000 00000000 ................\n"
|
||||
" 00001080 00000000 00000000 00000000 00000000 ................\n"
|
||||
" 00001090 00000000 00000000 00000000 00000000 ................\n"
|
||||
" 000010a0 00000000 00000000 00000000 00000000 ................\n"
|
||||
" 000010b0 00000000 00000000 00000000 00000000 ................\n"
|
||||
" 000010c0 00000000 00000000 00000000 00000000 ................\n"
|
||||
" 000010d0 00000000 00000000 00000000 00000000 ................\n"
|
||||
" 000010e0 00000000 00000000 00000000 00000000 ................\n"
|
||||
" 000010f0 00000000 00000000 00000000 00000000 ................\n";
|
||||
#endif
|
||||
ASSERT_STREQ(expected_dump, tombstone_contents.c_str());
|
||||
std::string expected_dump = "\nmemory near r1:\n";
|
||||
expected_dump += GetMemoryString(0x1000, std::vector<uint64_t>(32, 0UL));
|
||||
ASSERT_EQ(expected_dump, tombstone_contents);
|
||||
|
||||
// Verify that the log buf is empty, and no error messages.
|
||||
ASSERT_STREQ("", getFakeLogBuf().c_str());
|
||||
|
@ -414,61 +384,17 @@ TEST_F(DumpMemoryTest, memory_address_nearly_too_high) {
|
|||
std::string tombstone_contents;
|
||||
ASSERT_TRUE(lseek(log_.tfd, 0, SEEK_SET) == 0);
|
||||
ASSERT_TRUE(android::base::ReadFdToString(log_.tfd, &tombstone_contents));
|
||||
const char* expected_dump = \
|
||||
"\nmemory near r4:\n"
|
||||
std::string expected_dump = "\nmemory near r4:\n";
|
||||
uintptr_t addr;
|
||||
#if defined(__aarch64__)
|
||||
" 00ffffffffffff00 0706050403020100 0f0e0d0c0b0a0908 ................\n"
|
||||
" 00ffffffffffff10 1716151413121110 1f1e1d1c1b1a1918 ................\n"
|
||||
" 00ffffffffffff20 2726252423222120 2f2e2d2c2b2a2928 !\"#$%&'()*+,-./\n"
|
||||
" 00ffffffffffff30 3736353433323130 3f3e3d3c3b3a3938 0123456789:;<=>?\n"
|
||||
" 00ffffffffffff40 4746454443424140 4f4e4d4c4b4a4948 @ABCDEFGHIJKLMNO\n"
|
||||
" 00ffffffffffff50 5756555453525150 5f5e5d5c5b5a5958 PQRSTUVWXYZ[\\]^_\n"
|
||||
" 00ffffffffffff60 6766656463626160 6f6e6d6c6b6a6968 `abcdefghijklmno\n"
|
||||
" 00ffffffffffff70 7776757473727170 7f7e7d7c7b7a7978 pqrstuvwxyz{|}~.\n"
|
||||
" 00ffffffffffff80 8786858483828180 8f8e8d8c8b8a8988 ................\n"
|
||||
" 00ffffffffffff90 9796959493929190 9f9e9d9c9b9a9998 ................\n"
|
||||
" 00ffffffffffffa0 a7a6a5a4a3a2a1a0 afaeadacabaaa9a8 ................\n"
|
||||
" 00ffffffffffffb0 b7b6b5b4b3b2b1b0 bfbebdbcbbbab9b8 ................\n"
|
||||
" 00ffffffffffffc0 c7c6c5c4c3c2c1c0 cfcecdcccbcac9c8 ................\n"
|
||||
" 00ffffffffffffd0 d7d6d5d4d3d2d1d0 dfdedddcdbdad9d8 ................\n"
|
||||
" 00ffffffffffffe0 e7e6e5e4e3e2e1e0 efeeedecebeae9e8 ................\n"
|
||||
" 00fffffffffffff0 f7f6f5f4f3f2f1f0 fffefdfcfbfaf9f8 ................\n";
|
||||
addr = 0x00ffffffffffff00UL;
|
||||
#elif defined(__LP64__)
|
||||
" ffffffffffffff00 0706050403020100 0f0e0d0c0b0a0908 ................\n"
|
||||
" ffffffffffffff10 1716151413121110 1f1e1d1c1b1a1918 ................\n"
|
||||
" ffffffffffffff20 2726252423222120 2f2e2d2c2b2a2928 !\"#$%&'()*+,-./\n"
|
||||
" ffffffffffffff30 3736353433323130 3f3e3d3c3b3a3938 0123456789:;<=>?\n"
|
||||
" ffffffffffffff40 4746454443424140 4f4e4d4c4b4a4948 @ABCDEFGHIJKLMNO\n"
|
||||
" ffffffffffffff50 5756555453525150 5f5e5d5c5b5a5958 PQRSTUVWXYZ[\\]^_\n"
|
||||
" ffffffffffffff60 6766656463626160 6f6e6d6c6b6a6968 `abcdefghijklmno\n"
|
||||
" ffffffffffffff70 7776757473727170 7f7e7d7c7b7a7978 pqrstuvwxyz{|}~.\n"
|
||||
" ffffffffffffff80 8786858483828180 8f8e8d8c8b8a8988 ................\n"
|
||||
" ffffffffffffff90 9796959493929190 9f9e9d9c9b9a9998 ................\n"
|
||||
" ffffffffffffffa0 a7a6a5a4a3a2a1a0 afaeadacabaaa9a8 ................\n"
|
||||
" ffffffffffffffb0 b7b6b5b4b3b2b1b0 bfbebdbcbbbab9b8 ................\n"
|
||||
" ffffffffffffffc0 c7c6c5c4c3c2c1c0 cfcecdcccbcac9c8 ................\n"
|
||||
" ffffffffffffffd0 d7d6d5d4d3d2d1d0 dfdedddcdbdad9d8 ................\n"
|
||||
" ffffffffffffffe0 e7e6e5e4e3e2e1e0 efeeedecebeae9e8 ................\n"
|
||||
" fffffffffffffff0 f7f6f5f4f3f2f1f0 fffefdfcfbfaf9f8 ................\n";
|
||||
addr = 0xffffffffffffff00UL;
|
||||
#else
|
||||
" ffffff00 03020100 07060504 0b0a0908 0f0e0d0c ................\n"
|
||||
" ffffff10 13121110 17161514 1b1a1918 1f1e1d1c ................\n"
|
||||
" ffffff20 23222120 27262524 2b2a2928 2f2e2d2c !\"#$%&'()*+,-./\n"
|
||||
" ffffff30 33323130 37363534 3b3a3938 3f3e3d3c 0123456789:;<=>?\n"
|
||||
" ffffff40 43424140 47464544 4b4a4948 4f4e4d4c @ABCDEFGHIJKLMNO\n"
|
||||
" ffffff50 53525150 57565554 5b5a5958 5f5e5d5c PQRSTUVWXYZ[\\]^_\n"
|
||||
" ffffff60 63626160 67666564 6b6a6968 6f6e6d6c `abcdefghijklmno\n"
|
||||
" ffffff70 73727170 77767574 7b7a7978 7f7e7d7c pqrstuvwxyz{|}~.\n"
|
||||
" ffffff80 83828180 87868584 8b8a8988 8f8e8d8c ................\n"
|
||||
" ffffff90 93929190 97969594 9b9a9998 9f9e9d9c ................\n"
|
||||
" ffffffa0 a3a2a1a0 a7a6a5a4 abaaa9a8 afaeadac ................\n"
|
||||
" ffffffb0 b3b2b1b0 b7b6b5b4 bbbab9b8 bfbebdbc ................\n"
|
||||
" ffffffc0 c3c2c1c0 c7c6c5c4 cbcac9c8 cfcecdcc ................\n"
|
||||
" ffffffd0 d3d2d1d0 d7d6d5d4 dbdad9d8 dfdedddc ................\n"
|
||||
" ffffffe0 e3e2e1e0 e7e6e5e4 ebeae9e8 efeeedec ................\n"
|
||||
" fffffff0 f3f2f1f0 f7f6f5f4 fbfaf9f8 fffefdfc ................\n";
|
||||
addr = 0xffffff00UL;
|
||||
#endif
|
||||
ASSERT_STREQ(expected_dump, tombstone_contents.c_str());
|
||||
expected_dump += GetMemoryString(addr, GetDefaultData());
|
||||
ASSERT_EQ(expected_dump, tombstone_contents);
|
||||
|
||||
// Verify that the log buf is empty, and no error messages.
|
||||
ASSERT_STREQ("", getFakeLogBuf().c_str());
|
||||
|
@ -490,30 +416,15 @@ TEST_F(DumpMemoryTest, first_read_empty) {
|
|||
std::string tombstone_contents;
|
||||
ASSERT_TRUE(lseek(log_.tfd, 0, SEEK_SET) == 0);
|
||||
ASSERT_TRUE(android::base::ReadFdToString(log_.tfd, &tombstone_contents));
|
||||
const char* expected_dump = \
|
||||
"\nmemory near r4:\n"
|
||||
#if defined(__LP64__)
|
||||
R"( 0000000010001000 8786858483828180 8f8e8d8c8b8a8988 ................
|
||||
0000000010001010 9796959493929190 9f9e9d9c9b9a9998 ................
|
||||
0000000010001020 a7a6a5a4a3a2a1a0 afaeadacabaaa9a8 ................
|
||||
0000000010001030 b7b6b5b4b3b2b1b0 bfbebdbcbbbab9b8 ................
|
||||
0000000010001040 c7c6c5c4c3c2c1c0 cfcecdcccbcac9c8 ................
|
||||
0000000010001050 d7d6d5d4d3d2d1d0 dfdedddcdbdad9d8 ................
|
||||
0000000010001060 e7e6e5e4e3e2e1e0 efeeedecebeae9e8 ................
|
||||
0000000010001070 f7f6f5f4f3f2f1f0 fffefdfcfbfaf9f8 ................
|
||||
)";
|
||||
#else
|
||||
R"( 10001000 83828180 87868584 8b8a8988 8f8e8d8c ................
|
||||
10001010 93929190 97969594 9b9a9998 9f9e9d9c ................
|
||||
10001020 a3a2a1a0 a7a6a5a4 abaaa9a8 afaeadac ................
|
||||
10001030 b3b2b1b0 b7b6b5b4 bbbab9b8 bfbebdbc ................
|
||||
10001040 c3c2c1c0 c7c6c5c4 cbcac9c8 cfcecdcc ................
|
||||
10001050 d3d2d1d0 d7d6d5d4 dbdad9d8 dfdedddc ................
|
||||
10001060 e3e2e1e0 e7e6e5e4 ebeae9e8 efeeedec ................
|
||||
10001070 f3f2f1f0 f7f6f5f4 fbfaf9f8 fffefdfc ................
|
||||
)";
|
||||
#endif
|
||||
ASSERT_STREQ(expected_dump, tombstone_contents.c_str());
|
||||
std::string expected_dump = "\nmemory near r4:\n";
|
||||
expected_dump += GetMemoryString(
|
||||
0x10000000 + page_size,
|
||||
std::vector<uint64_t>{
|
||||
0x8786858483828180UL, 0x8f8e8d8c8b8a8988UL, 0x9796959493929190UL, 0x9f9e9d9c9b9a9998UL,
|
||||
0xa7a6a5a4a3a2a1a0UL, 0xafaeadacabaaa9a8UL, 0xb7b6b5b4b3b2b1b0UL, 0xbfbebdbcbbbab9b8UL,
|
||||
0xc7c6c5c4c3c2c1c0UL, 0xcfcecdcccbcac9c8UL, 0xd7d6d5d4d3d2d1d0UL, 0xdfdedddcdbdad9d8UL,
|
||||
0xe7e6e5e4e3e2e1e0UL, 0xefeeedecebeae9e8UL, 0xf7f6f5f4f3f2f1f0UL, 0xfffefdfcfbfaf9f8UL});
|
||||
ASSERT_EQ(expected_dump, tombstone_contents);
|
||||
|
||||
// Verify that the log buf is empty, and no error messages.
|
||||
ASSERT_STREQ("", getFakeLogBuf().c_str());
|
||||
|
@ -535,16 +446,11 @@ TEST_F(DumpMemoryTest, first_read_empty_second_read_stops) {
|
|||
std::string tombstone_contents;
|
||||
ASSERT_TRUE(lseek(log_.tfd, 0, SEEK_SET) == 0);
|
||||
ASSERT_TRUE(android::base::ReadFdToString(log_.tfd, &tombstone_contents));
|
||||
const char* expected_dump = \
|
||||
"\nmemory near r4:\n"
|
||||
#if defined(__LP64__)
|
||||
" 0000000010001000 c7c6c5c4c3c2c1c0 cfcecdcccbcac9c8 ................\n"
|
||||
" 0000000010001010 d7d6d5d4d3d2d1d0 dfdedddcdbdad9d8 ................\n";
|
||||
#else
|
||||
" 10001000 c3c2c1c0 c7c6c5c4 cbcac9c8 cfcecdcc ................\n"
|
||||
" 10001010 d3d2d1d0 d7d6d5d4 dbdad9d8 dfdedddc ................\n";
|
||||
#endif
|
||||
ASSERT_STREQ(expected_dump, tombstone_contents.c_str());
|
||||
std::string expected_dump = "\nmemory near r4:\n";
|
||||
expected_dump += GetMemoryString(
|
||||
0x10000000 + page_size, std::vector<uint64_t>{0xc7c6c5c4c3c2c1c0UL, 0xcfcecdcccbcac9c8UL,
|
||||
0xd7d6d5d4d3d2d1d0UL, 0xdfdedddcdbdad9d8UL});
|
||||
ASSERT_EQ(expected_dump, tombstone_contents);
|
||||
|
||||
// Verify that the log buf is empty, and no error messages.
|
||||
ASSERT_STREQ("", getFakeLogBuf().c_str());
|
||||
|
|
Loading…
Reference in a new issue