mirror of
https://git.suyu.dev/suyu/breakpad.git
synced 2026-02-19 08:42:59 +00:00
Allow adding extra memory regions to minidump on linux/windows
A=Bill McCloskey <wmccloskey@mozilla.com> R=ted at https://bugzilla.mozilla.org/show_bug.cgi?id=662646 git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@989 4c0a9323-5329-0410-9bdc-e9ce6186880e
This commit is contained in:
46
src/client/windows/unittests/exception_handler_test.cc
Normal file → Executable file
46
src/client/windows/unittests/exception_handler_test.cc
Normal file → Executable file
@@ -374,4 +374,50 @@ TEST_F(ExceptionHandlerTest, WriteMinidumpTest) {
|
||||
//TODO(ted): more comprehensive tests...
|
||||
}
|
||||
|
||||
TEST_F(ExceptionHandlerTest, AdditionalMemory) {
|
||||
SYSTEM_INFO si;
|
||||
GetSystemInfo(&si);
|
||||
const u_int32_t kMemorySize = si.dwPageSize;
|
||||
// Get some heap memory.
|
||||
u_int8_t* memory = new u_int8_t[kMemorySize];
|
||||
const uintptr_t kMemoryAddress = reinterpret_cast<uintptr_t>(memory);
|
||||
ASSERT_TRUE(memory);
|
||||
// Stick some data into the memory so the contents can be verified.
|
||||
for (unsigned int i = 0; i < kMemorySize; ++i) {
|
||||
memory[i] = i % 255;
|
||||
}
|
||||
|
||||
ExceptionHandler handler(temp_path_,
|
||||
NULL,
|
||||
DumpCallback,
|
||||
NULL,
|
||||
ExceptionHandler::HANDLER_ALL);
|
||||
// Add the memory region to the list of memory to be included.
|
||||
handler.RegisterAppMemory(memory, kMemorySize);
|
||||
ASSERT_TRUE(handler.WriteMinidump());
|
||||
ASSERT_FALSE(dump_file.empty());
|
||||
|
||||
string minidump_filename;
|
||||
ASSERT_TRUE(WindowsStringUtils::safe_wcstombs(dump_file,
|
||||
&minidump_filename));
|
||||
|
||||
// Read the minidump. Ensure that the memory region is present
|
||||
Minidump minidump(minidump_filename);
|
||||
ASSERT_TRUE(minidump.Read());
|
||||
|
||||
MinidumpMemoryList* dump_memory_list = minidump.GetMemoryList();
|
||||
ASSERT_TRUE(dump_memory_list);
|
||||
const MinidumpMemoryRegion* region =
|
||||
dump_memory_list->GetMemoryRegionForAddress(kMemoryAddress);
|
||||
ASSERT_TRUE(region);
|
||||
|
||||
EXPECT_EQ(kMemoryAddress, region->GetBase());
|
||||
EXPECT_EQ(kMemorySize, region->GetSize());
|
||||
|
||||
// Verify memory contents.
|
||||
EXPECT_EQ(0, memcmp(region->GetMemory(), memory, kMemorySize));
|
||||
|
||||
delete[] memory;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
Reference in New Issue
Block a user