Minidump/Windows: Fix module lookup
authorPavel Labath <pavel@labath.sk>
Fri, 9 Aug 2019 09:10:50 +0000 (09:10 +0000)
committerPavel Labath <pavel@labath.sk>
Fri, 9 Aug 2019 09:10:50 +0000 (09:10 +0000)
Summary:
When opening a minidump, we were failing to find an executable because
we were searching for i386-unknown-windows, whereas we recognize the
pe/coff files as i386-pc-windows. This fixes the triple computation code
in the minidump parser to match pe/coff, and adds an appropriate test.

NB: I'm not sure setting the vendor to "pc" is really correct for
arm(64) windows, but right now that seems to match what we do in the
pe/coff case (ArchSpec.cpp:935).

Reviewers: clayborg, amccarth

Subscribers: javed.absar, kristof.beyls, rnk, markmentovai, lldb-commits

Differential Revision: https://reviews.llvm.org/D65955

llvm-svn: 368416

lldb/lit/Minidump/Windows/Inputs/find-module.dmp.yaml [new file with mode: 0644]
lldb/lit/Minidump/Windows/Inputs/find-module.exe.yaml [new file with mode: 0644]
lldb/lit/Minidump/Windows/find-module.test [new file with mode: 0644]
lldb/source/Plugins/Process/minidump/MinidumpParser.cpp

diff --git a/lldb/lit/Minidump/Windows/Inputs/find-module.dmp.yaml b/lldb/lit/Minidump/Windows/Inputs/find-module.dmp.yaml
new file mode 100644 (file)
index 0000000..aef94e3
--- /dev/null
@@ -0,0 +1,26 @@
+--- !minidump
+Streams:
+  - Type:            ModuleList
+    Modules:
+      - Base of Image:   0x00000000000B0000
+        Size of Image:   0x00005000
+        Module Name:     'find-module.exe'
+        CodeView Record: 525344533ED87D89C8A8184197F3A925EE4BF74101000000433A5C70726F6A656374735C746573745F6170705C436F6E736F6C654170706C69636174696F6E315C44656275675C436F6E736F6C654170706C69636174696F6E312E70646200
+  - Type:            SystemInfo
+    Processor Arch:  X86
+    Processor Level: 23
+    Processor Revision: 2050
+    Number of Processors: 32
+    Product type:    1
+    Major Version:   10
+    Build Number:    17134
+    Platform ID:     Win32NT
+    Suite Mask:      0x0300
+    CPU:
+      Vendor ID:       AuthenticAMD
+      Version Info:    0x00800F82
+      Feature Info:    0x178BFBFF
+      AMD Extended Features: 0x2FD3FBFF
+  - Type:            MiscInfo
+    Content:         54050000F703000008290000C883495D0000000000000000AC0D000098080000AC0D00000200000002000000002000000D0000000000000002000000C4FFFFFF430065006E007400720061006C0020004500750072006F007000650020005300740061006E0064006100720064002000540069006D006500000000000000000000000A0000000500030000000000000000000000430065006E007400720061006C0020004500750072006F00700065002000530075006D006D00650072002000540069006D00650000000000000000000000000000000300000005000200000000000000C4FFFFFF310037003100330034002E0031002E007800380036006600720065002E007200730034005F00720065006C0065006100730065002E003100380030003400310030002D00310038003000340000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000064006200670063006F00720065002E0069003300380036002C00310030002E0030002E00310037003100330034002E0031000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006C816B92
+...
diff --git a/lldb/lit/Minidump/Windows/Inputs/find-module.exe.yaml b/lldb/lit/Minidump/Windows/Inputs/find-module.exe.yaml
new file mode 100644 (file)
index 0000000..42ccc6d
--- /dev/null
@@ -0,0 +1,32 @@
+--- !COFF
+OptionalHeader:
+  AddressOfEntryPoint: 4224
+  ImageBase:       4194304
+  SectionAlignment: 4096
+  FileAlignment:   512
+  MajorOperatingSystemVersion: 6
+  MinorOperatingSystemVersion: 0
+  MajorImageVersion: 0
+  MinorImageVersion: 0
+  MajorSubsystemVersion: 6
+  MinorSubsystemVersion: 0
+  Subsystem:       IMAGE_SUBSYSTEM_WINDOWS_CUI
+  DLLCharacteristics: [ IMAGE_DLL_CHARACTERISTICS_DYNAMIC_BASE, IMAGE_DLL_CHARACTERISTICS_NX_COMPAT, IMAGE_DLL_CHARACTERISTICS_NO_SEH, IMAGE_DLL_CHARACTERISTICS_TERMINAL_SERVER_AWARE ]
+  SizeOfStackReserve: 1048576
+  SizeOfStackCommit: 4096
+  SizeOfHeapReserve: 1048576
+  SizeOfHeapCommit: 4096
+header:
+  Machine:         IMAGE_FILE_MACHINE_I386
+  Characteristics: [ IMAGE_FILE_EXECUTABLE_IMAGE, IMAGE_FILE_32BIT_MACHINE ]
+sections:
+  - Name:            .rdata
+    Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ]
+    VirtualAddress:  8192
+    VirtualSize:     304
+  - Name:            .reloc
+    Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_DISCARDABLE, IMAGE_SCN_MEM_READ ]
+    VirtualAddress:  16384
+    VirtualSize:     48
+symbols:         []
+...
diff --git a/lldb/lit/Minidump/Windows/find-module.test b/lldb/lit/Minidump/Windows/find-module.test
new file mode 100644 (file)
index 0000000..170a180
--- /dev/null
@@ -0,0 +1,10 @@
+Test that we correctly find a PE/COFF file in our executable search path, and
+use it when opening minidumps.
+
+RUN: yaml2obj %S/Inputs/find-module.exe.yaml > %T/find-module.exe
+RUN: yaml2obj %S/Inputs/find-module.dmp.yaml > %T/find-module.dmp
+RUN: %lldb -O "settings set target.exec-search-paths %T" \
+RUN:   -c %T/find-module.dmp -o "image dump objfile" -o exit | FileCheck %s
+
+CHECK-LABEL: image dump objfile
+CHECK: ObjectFilePECOFF, file = '{{.*}}find-module.exe', arch = i386
index ff015aa..e1e0f39 100644 (file)
@@ -188,6 +188,7 @@ ArchSpec MinidumpParser::GetArchitecture() {
   case OSPlatform::Win32NT:
   case OSPlatform::Win32CE:
     triple.setOS(llvm::Triple::OSType::Win32);
+    triple.setVendor(llvm::Triple::VendorType::PC);
     break;
   case OSPlatform::Linux:
     triple.setOS(llvm::Triple::OSType::Linux);