mirror of
https://git.suyu.dev/suyu/breakpad.git
synced 2026-03-13 06:16:28 +00:00
Allow breakpad to read extended amd64 contexts
Minidumps can contain extended, and compacted extended, contexts to include xstate data such as the state of the cet registers cetumsr and cetussp. Previously breakpad would reject dumps with contexts larger than expected. With this chage, breakpad now accepts and reads these minidumps. This change does not yet add processing for this extra data, but will allow any minidumps to be passed on to other processing tools, or be available for manual inspection. See chromium-review.googlesource.com/c/crashpad/crashpad/+/2575920 for motivation. Bug: 1250098 Change-Id: Id67649738ef1c7fb6308e05e6cd8fde790771cb2 Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3256483 Reviewed-by: Robert Sesek <rsesek@chromium.org>
This commit is contained in:
@@ -470,7 +470,16 @@ bool MinidumpContext::Read(uint32_t expected_size) {
|
||||
// First, figure out what type of CPU this context structure is for.
|
||||
// For some reason, the AMD64 Context doesn't have context_flags
|
||||
// at the beginning of the structure, so special case it here.
|
||||
if (expected_size == sizeof(MDRawContextAMD64)) {
|
||||
|
||||
uint32_t sysinfo_cpu_type = 0;
|
||||
if (!minidump_->GetContextCPUFlagsFromSystemInfo(&sysinfo_cpu_type)) {
|
||||
BPLOG(ERROR) << "Failed to preserve the current stream position";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (expected_size == sizeof(MDRawContextAMD64) ||
|
||||
(sysinfo_cpu_type == MD_CONTEXT_AMD64 &&
|
||||
expected_size >= sizeof(MDRawContextAMD64))) {
|
||||
BPLOG(INFO) << "MinidumpContext: looks like AMD64 context";
|
||||
|
||||
scoped_ptr<MDRawContextAMD64> context_amd64(new MDRawContextAMD64());
|
||||
@@ -480,17 +489,24 @@ bool MinidumpContext::Read(uint32_t expected_size) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Context may include xsave registers and so be larger than
|
||||
// sizeof(MDRawContextAMD64). For now we skip this extended data.
|
||||
if (expected_size > sizeof(MDRawContextAMD64)) {
|
||||
size_t bytes_left = expected_size - sizeof(MDRawContextAMD64);
|
||||
std::vector<uint8_t> xstate(bytes_left);
|
||||
if (!minidump_->ReadBytes(xstate.data(),
|
||||
bytes_left)) {
|
||||
BPLOG(ERROR) << "MinidumpContext could not skip amd64 xstate";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (minidump_->swap())
|
||||
Swap(&context_amd64->context_flags);
|
||||
|
||||
uint32_t cpu_type = context_amd64->context_flags & MD_CONTEXT_CPU_MASK;
|
||||
if (cpu_type == 0) {
|
||||
if (minidump_->GetContextCPUFlagsFromSystemInfo(&cpu_type)) {
|
||||
context_amd64->context_flags |= cpu_type;
|
||||
} else {
|
||||
BPLOG(ERROR) << "Failed to preserve the current stream position";
|
||||
return false;
|
||||
}
|
||||
context_amd64->context_flags |= sysinfo_cpu_type;
|
||||
}
|
||||
|
||||
if (cpu_type != MD_CONTEXT_AMD64) {
|
||||
@@ -765,13 +781,10 @@ bool MinidumpContext::Read(uint32_t expected_size) {
|
||||
}
|
||||
}
|
||||
|
||||
// Fixup if we were not provided a cpu type.
|
||||
if (cpu_type == 0) {
|
||||
if (minidump_->GetContextCPUFlagsFromSystemInfo(&cpu_type)) {
|
||||
context_flags |= cpu_type;
|
||||
} else {
|
||||
BPLOG(ERROR) << "Failed to preserve the current stream position";
|
||||
return false;
|
||||
}
|
||||
cpu_type = sysinfo_cpu_type;
|
||||
context_flags |= cpu_type;
|
||||
}
|
||||
|
||||
// Allocate the context structure for the correct CPU and fill it. The
|
||||
|
||||
Reference in New Issue
Block a user