Adjust MD_CONTEXT_CPU_MASK to reflect reality, fix some code so it can handle dumps using the old value for MD_CONTEXT_ARM

The value of MD_CONTEXT_CPU_MASK in use assumes that only the lower 6 bits are used for flags, and the upper 26 bits are for the CPU type. However, as of Windows 7 SP1, the 7th bit is being used as a flag (per http://msdn.microsoft.com/en-us/library/hh134238%28v=vs.85%29.aspx and the Windows SDK headers). Adjusting MD_CONTEXT_CPU_MASK works, but unfortunately that masks off the existing value of MD_CONTEXT_ARM. This patch also changes the value of MD_CONTEXT_ARM and adjusts the minidump context reading machinery to gracefully handle minidumps with the old value.
R=mark at http://breakpad.appspot.com/302001

git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@831 4c0a9323-5329-0410-9bdc-e9ce6186880e
This commit is contained in:
ted.mielczarek
2011-08-30 22:22:08 +00:00
parent 8ade75f955
commit 1a1890a52a
10 changed files with 658 additions and 42 deletions

View File

@@ -42,6 +42,7 @@
using google_breakpad::SynthMinidump::Context;
using google_breakpad::SynthMinidump::Dump;
using google_breakpad::SynthMinidump::Exception;
using google_breakpad::SynthMinidump::List;
using google_breakpad::SynthMinidump::Memory;
using google_breakpad::SynthMinidump::Module;
@@ -133,6 +134,17 @@ TEST(Context, X86) {
== 0);
}
TEST(Context, ARM) {
Dump dump(0, kLittleEndian);
assert(arm_raw_context.context_flags & MD_CONTEXT_ARM);
Context context(dump, arm_raw_context);
string contents;
ASSERT_TRUE(context.GetContents(&contents));
EXPECT_EQ(sizeof(arm_expected_contents), contents.size());
EXPECT_TRUE(memcmp(contents.data(), arm_expected_contents, contents.size())
== 0);
}
TEST(ContextDeathTest, X86BadFlags) {
Dump dump(0, kLittleEndian);
MDRawContextX86 raw;
@@ -179,6 +191,49 @@ TEST(Thread, Simple) {
EXPECT_TRUE(memcmp(contents.data(), expected_bytes, contents.size()) == 0);
}
TEST(Exception, Simple) {
Dump dump(0, kLittleEndian);
Context context(dump, x86_raw_context);
context.Finish(0x8665da0c);
Exception exception(dump, context,
0x1234abcd, // thread id
0xdcba4321, // exception code
0xf0e0d0c0, // exception flags
0x0919a9b9c9d9e9f9ULL); // exception address
string contents;
ASSERT_TRUE(exception.GetContents(&contents));
static const u_int8_t expected_bytes[] = {
0xcd, 0xab, 0x34, 0x12, // thread id
0x00, 0x00, 0x00, 0x00, // __align
0x21, 0x43, 0xba, 0xdc, // exception code
0xc0, 0xd0, 0xe0, 0xf0, // exception flags
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // exception record
0xf9, 0xe9, 0xd9, 0xc9, 0xb9, 0xa9, 0x19, 0x09, // exception address
0x00, 0x00, 0x00, 0x00, // number parameters
0x00, 0x00, 0x00, 0x00, // __align
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // exception_information
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // exception_information
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // exception_information
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // exception_information
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // exception_information
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // exception_information
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // exception_information
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // exception_information
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // exception_information
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // exception_information
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // exception_information
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // exception_information
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // exception_information
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // exception_information
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // exception_information
0xcc, 0x02, 0x00, 0x00, // context size
0x0c, 0xda, 0x65, 0x86 // context MDRVA
};
EXPECT_EQ(sizeof(expected_bytes), contents.size());
EXPECT_TRUE(memcmp(contents.data(), expected_bytes, contents.size()) == 0);
}
TEST(String, Simple) {
Dump dump(0, kBigEndian);
String s(dump, "All mimsy were the borogoves");