|
3 | 3 | # You can obtain one at http://mozilla.org/MPL/2.0/.
|
4 | 4 | """ffpuppet minidump parser tests"""
|
5 | 5 |
|
| 6 | +from copy import deepcopy |
6 | 7 | from json import dumps
|
7 | 8 | from pathlib import Path
|
8 | 9 | from subprocess import CompletedProcess
|
|
12 | 13 |
|
13 | 14 | from .minidump_parser import MinidumpParser
|
14 | 15 |
|
15 |
| -MD_UNSYMBOLIZED_AMD64_WIN = { |
| 16 | +MD_BASE_AMD64_WIN = { |
16 | 17 | "crash_info": {
|
17 | 18 | "address": "0x00007ffe4e09af8d",
|
18 |
| - "crashing_thread": 0, |
19 | 19 | "type": "EXCEPTION_BREAKPOINT",
|
20 | 20 | },
|
21 |
| - "crashing_thread": { |
22 |
| - "frame_count": 49, |
23 |
| - "frames": [ |
24 |
| - { |
25 |
| - "file": None, |
26 |
| - "frame": 0, |
27 |
| - "function": None, |
28 |
| - "function_offset": None, |
29 |
| - "line": None, |
30 |
| - "module": "xul.dll", |
31 |
| - "registers": {"r10": "0x0"}, |
32 |
| - }, |
33 |
| - ], |
34 |
| - }, |
35 | 21 | "system_info": {
|
36 | 22 | "cpu_arch": "amd64",
|
37 | 23 | "cpu_count": 8,
|
|
41 | 27 | },
|
42 | 28 | }
|
43 | 29 |
|
| 30 | +MD_UNSYMBOLIZED_AMD64_WIN = deepcopy(MD_BASE_AMD64_WIN) |
| 31 | +MD_UNSYMBOLIZED_AMD64_WIN["crash_info"]["crashing_thread"] = 0 |
| 32 | +MD_UNSYMBOLIZED_AMD64_WIN["crashing_thread"] = { |
| 33 | + "frame_count": 49, |
| 34 | + "frames": [ |
| 35 | + { |
| 36 | + "file": None, |
| 37 | + "frame": 0, |
| 38 | + "function": None, |
| 39 | + "function_offset": None, |
| 40 | + "line": None, |
| 41 | + "module": "xul.dll", |
| 42 | + "registers": {"r10": "0x0"}, |
| 43 | + }, |
| 44 | + ], |
| 45 | +} |
| 46 | + |
44 | 47 | MD_UNSYMBOLIZED_ARM64_MAC = {
|
45 | 48 | "crash_info": {
|
46 | 49 | "address": "0x0000000000000000",
|
@@ -165,54 +168,43 @@ def test_minidump_parser_03(tmp_path, data, reg, operating_system, cpu, crash, f
|
165 | 168 |
|
166 | 169 | def test_minidump_parser_04(tmp_path):
|
167 | 170 | """test MinidumpParser._fmt_output() - symbolized"""
|
168 |
| - data = { |
169 |
| - "crash_info": { |
170 |
| - "address": "0x00007ffe4e09af8d", |
171 |
| - "crashing_thread": 0, |
172 |
| - "type": "EXCEPTION_BREAKPOINT", |
173 |
| - }, |
174 |
| - "crashing_thread": { |
175 |
| - "frames": [ |
176 |
| - { |
177 |
| - "file": "file0.cpp", |
178 |
| - "frame": 0, |
179 |
| - "function": "function00()", |
180 |
| - "function_offset": "0x00000000000001ed", |
181 |
| - "line": 47, |
182 |
| - "module": "xul.dll", |
183 |
| - "registers": { |
184 |
| - "r10": "0x12345678", |
185 |
| - "r11": "0x0badf00d", |
186 |
| - "r12": "0x00000000", |
187 |
| - "r13": "0x000000dceebfc2e8", |
188 |
| - }, |
189 |
| - }, |
190 |
| - { |
191 |
| - "file": "file1.cpp", |
192 |
| - "frame": 1, |
193 |
| - "function": "function01()", |
194 |
| - "function_offset": "0x00000000000001bb", |
195 |
| - "line": 210, |
196 |
| - "module": "xul.dll", |
197 |
| - }, |
198 |
| - { |
199 |
| - "file": "file2.cpp", |
200 |
| - "frame": 2, |
201 |
| - "function": "function02()", |
202 |
| - "function_offset": "0x0000000000000123", |
203 |
| - "line": 123, |
204 |
| - "module": "xul.dll", |
| 171 | + data = deepcopy(MD_BASE_AMD64_WIN) |
| 172 | + data["crash_info"]["crashing_thread"] = 0 |
| 173 | + data["crashing_thread"] = { |
| 174 | + "frames": [ |
| 175 | + { |
| 176 | + "file": "file0.cpp", |
| 177 | + "frame": 0, |
| 178 | + "function": "function00()", |
| 179 | + "function_offset": "0x00000000000001ed", |
| 180 | + "line": 47, |
| 181 | + "module": "xul.dll", |
| 182 | + "registers": { |
| 183 | + "r10": "0x12345678", |
| 184 | + "r11": "0x0badf00d", |
| 185 | + "r12": "0x00000000", |
| 186 | + "r13": "0x000000dceebfc2e8", |
205 | 187 | },
|
206 |
| - ], |
207 |
| - }, |
208 |
| - "system_info": { |
209 |
| - "cpu_arch": "amd64", |
210 |
| - "cpu_count": 8, |
211 |
| - "cpu_info": "family 6 model 70 stepping 1", |
212 |
| - "os": "Windows NT", |
213 |
| - "os_ver": "10.0.19044", |
214 |
| - }, |
| 188 | + }, |
| 189 | + { |
| 190 | + "file": "file1.cpp", |
| 191 | + "frame": 1, |
| 192 | + "function": "function01()", |
| 193 | + "function_offset": "0x00000000000001bb", |
| 194 | + "line": 210, |
| 195 | + "module": "xul.dll", |
| 196 | + }, |
| 197 | + { |
| 198 | + "file": "file2.cpp", |
| 199 | + "frame": 2, |
| 200 | + "function": "function02()", |
| 201 | + "function_offset": "0x0000000000000123", |
| 202 | + "line": 123, |
| 203 | + "module": "xul.dll", |
| 204 | + }, |
| 205 | + ], |
215 | 206 | }
|
| 207 | + |
216 | 208 | with (tmp_path / "out.txt").open("w+b") as ofp:
|
217 | 209 | # pylint: disable=protected-access
|
218 | 210 | MinidumpParser._fmt_output(data, ofp, limit=2)
|
@@ -289,3 +281,16 @@ def test_minidump_parser_06(tmp_path):
|
289 | 281 | # add .extra file to prioritize .dmp file
|
290 | 282 | (tmp_path / "b.extra").write_text('{"MozCrashReason":"foo"}')
|
291 | 283 | assert MinidumpParser.dmp_files(tmp_path)[0] == (tmp_path / "b.dmp")
|
| 284 | + |
| 285 | + |
| 286 | +def test_minidump_parser_missing_crashing_thread(tmp_path): |
| 287 | + """test MinidumpParser._fmt_output() - missing crashing thread""" |
| 288 | + with (tmp_path / "out.txt").open("w+b") as ofp: |
| 289 | + # pylint: disable=protected-access |
| 290 | + MinidumpParser._fmt_output(MD_BASE_AMD64_WIN, ofp) |
| 291 | + ofp.seek(0) |
| 292 | + formatted = ofp.read().rstrip().decode().split("\n") |
| 293 | + assert len(formatted) == 3 |
| 294 | + assert formatted[0] == "OS|Windows NT|10.0.19044" |
| 295 | + assert formatted[1] == "CPU|amd64|family 6 model 70 stepping 1|8" |
| 296 | + assert formatted[2] == "Crash|EXCEPTION_BREAKPOINT|0x00007ffe4e09af8d|?" |
0 commit comments