From 6c7d641dc9052fa1fe731bf04388fa1a2eb34fc9 Mon Sep 17 00:00:00 2001 From: "ted.mielczarek" Date: Tue, 31 Aug 2010 15:08:49 +0000 Subject: Issue 370 - fix PDBSourceLineWriter::GetModuleInfo's CPU detection R=nealsid at http://breakpad.appspot.com/181001 git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@678 4c0a9323-5329-0410-9bdc-e9ce6186880e --- src/common/windows/pdb_source_line_writer.cc | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'src/common/windows') diff --git a/src/common/windows/pdb_source_line_writer.cc b/src/common/windows/pdb_source_line_writer.cc index 9cd0d2e3..48a35bed 100644 --- a/src/common/windows/pdb_source_line_writer.cc +++ b/src/common/windows/pdb_source_line_writer.cc @@ -764,11 +764,25 @@ bool PDBSourceLineWriter::GetModuleInfo(PDBModuleInfo *info) { return false; } - // All CPUs in CV_CPU_TYPE_e (cvconst.h) below 0x10 are x86. There's no - // single specific constant to use. - DWORD platform; - if (SUCCEEDED(global->get_platform(&platform)) && platform < 0x10) { - info->cpu = L"x86"; + DWORD machine_type; + // get_machineType can return S_FALSE. + if (global->get_machineType(&machine_type) == S_OK) { + // The documentation claims that get_machineType returns a value from + // the CV_CPU_TYPE_e enumeration, but that's not the case. + // Instead, it returns one of the IMAGE_FILE_MACHINE values as + // defined here: + // http://msdn.microsoft.com/en-us/library/ms680313%28VS.85%29.aspx + switch (machine_type) { + case IMAGE_FILE_MACHINE_I386: + info->cpu = L"x86"; + break; + case IMAGE_FILE_MACHINE_AMD64: + info->cpu = L"x86_64"; + break; + default: + info->cpu = L"unknown"; + break; + } } else { // Unexpected, but handle gracefully. info->cpu = L"unknown"; -- cgit v1.2.1