summaryrefslogtreecommitdiffstats
path: root/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem
diff options
context:
space:
mode:
Diffstat (limited to 'gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem')
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py379
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/altmain.c6
-rwxr-xr-xgnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/altmain.outbin0 -> 2330 bytes
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/fpr_sse.cpp38
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/gcore/TestGCore.py54
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/gcore/main.cpp62
-rwxr-xr-xgnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/gcore/main.mk3
-rwxr-xr-xgnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/gcore/make-core.sh56
-rwxr-xr-xgnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-i386.outbin0 -> 1971 bytes
-rwxr-xr-xgnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mips64el-gnuabi64.outbin0 -> 3576 bytes
-rwxr-xr-xgnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mips64el-gnuabin32.outbin0 -> 2792 bytes
-rwxr-xr-xgnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mipsel-gnuabio32.outbin0 -> 2872 bytes
-rwxr-xr-xgnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-ppc64le.outbin0 -> 3128 bytes
-rwxr-xr-xgnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-s390x.outbin0 -> 2824 bytes
-rwxr-xr-xgnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-x86_64.outbin0 -> 2575 bytes
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/main.c17
-rwxr-xr-xgnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/make-core.sh61
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/thread_crash/TestLinuxCoreThreads.py75
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/thread_crash/main.cpp62
-rwxr-xr-xgnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/thread_crash/main.mk3
-rwxr-xr-xgnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/thread_crash/make-core.sh64
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/mach-core/TestMachCore.py69
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/mach-core/operating_system.py44
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/mach-core/test.core.yaml853
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py463
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpUUID.py195
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/arm-linux.yaml18
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/arm-macos.yaml18
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/arm64-macos.yaml18
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/install_breakpad.cpp16
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/libuuidmatch.yaml14
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/libuuidmismatch.yaml14
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-arm-partial-uuids-match.yaml15
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-arm-partial-uuids-mismatch.yaml15
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-arm-same-uuids.yaml21
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-arm-uuids-elf-build-id-16.yaml19
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-arm-uuids-elf-build-id-20.yaml19
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-arm-uuids-elf-build-id-zero.yaml19
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-arm-uuids-no-age.yaml19
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-arm-uuids-with-age.yaml19
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-arm-zero-uuids.yaml21
-rwxr-xr-xgnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64bin0 -> 7279 bytes
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64.cpp12
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64.dmpbin0 -> 63592 bytes
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64.yaml44
-rwxr-xr-xgnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64_not_crashedbin0 -> 7675 bytes
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64_not_crashed.cpp22
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64_not_crashed.dmpbin0 -> 63744 bytes
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64_null_signal.yaml25
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/macos-arm-uuids-no-age.yaml21
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/makefile.txt29
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/regions-linux-map.yaml33
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/relative_module_name.yaml17
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump/Makefile4
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump/TestMiniDump.py176
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump/fizzbuzz.cpp31
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump/fizzbuzz.syms2
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump/fizzbuzz_no_heap.dmpbin0 -> 6297 bytes
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump/main.cpp21
-rwxr-xr-xgnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/netbsd-core/1lwp_SIGSEGV.aarch64bin0 -> 9088 bytes
-rwxr-xr-xgnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/netbsd-core/1lwp_SIGSEGV.amd64bin0 -> 13616 bytes
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/netbsd-core/1lwp_SIGSEGV.c14
-rwxr-xr-xgnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/netbsd-core/2lwp_process_SIGSEGV.aarch64bin0 -> 13192 bytes
-rwxr-xr-xgnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/netbsd-core/2lwp_process_SIGSEGV.amd64bin0 -> 16344 bytes
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/netbsd-core/2lwp_process_SIGSEGV.c37
-rwxr-xr-xgnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/netbsd-core/2lwp_t2_SIGSEGV.aarch64bin0 -> 11848 bytes
-rwxr-xr-xgnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/netbsd-core/2lwp_t2_SIGSEGV.amd64bin0 -> 15456 bytes
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/netbsd-core/2lwp_t2_SIGSEGV.c30
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/netbsd-core/GNUmakefile15
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/netbsd-core/TestNetBSDCore.py237
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/wow64_minidump/TestWow64MiniDump.py72
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/wow64_minidump/fizzbuzz.cpp31
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/wow64_minidump/fizzbuzz_wow64.dmpbin0 -> 9280561 bytes
73 files changed, 3642 insertions, 0 deletions
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py
new file mode 100644
index 00000000000..c2746bf1a80
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py
@@ -0,0 +1,379 @@
+"""
+Test basics of linux core file debugging.
+"""
+
+from __future__ import division, print_function
+
+import shutil
+import struct
+import os
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class LinuxCoreTestCase(TestBase):
+ NO_DEBUG_INFO_TESTCASE = True
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ _i386_pid = 32306
+ _x86_64_pid = 32259
+ _s390x_pid = 1045
+ _mips64_n64_pid = 25619
+ _mips64_n32_pid = 3670
+ _mips_o32_pid = 3532
+ _ppc64le_pid = 28147
+
+ _i386_regions = 4
+ _x86_64_regions = 5
+ _s390x_regions = 2
+ _mips_regions = 5
+ _ppc64le_regions = 2
+
+ def setUp(self):
+ super(LinuxCoreTestCase, self).setUp()
+ self._initial_platform = lldb.DBG.GetSelectedPlatform()
+
+ def tearDown(self):
+ lldb.DBG.SetSelectedPlatform(self._initial_platform)
+ super(LinuxCoreTestCase, self).tearDown()
+
+ @skipIf(triple='^mips')
+ @skipIfLLVMTargetMissing("X86")
+ def test_i386(self):
+ """Test that lldb can read the process information from an i386 linux core file."""
+ self.do_test("linux-i386", self._i386_pid, self._i386_regions, "a.out")
+
+ @skipIfLLVMTargetMissing("Mips")
+ def test_mips_o32(self):
+ """Test that lldb can read the process information from an MIPS O32 linux core file."""
+ self.do_test("linux-mipsel-gnuabio32", self._mips_o32_pid,
+ self._mips_regions, "linux-mipsel-gn")
+
+ @skipIfLLVMTargetMissing("Mips")
+ def test_mips_n32(self):
+ """Test that lldb can read the process information from an MIPS N32 linux core file """
+ self.do_test("linux-mips64el-gnuabin32", self._mips64_n32_pid,
+ self._mips_regions, "linux-mips64el-")
+
+ @skipIfLLVMTargetMissing("Mips")
+ def test_mips_n64(self):
+ """Test that lldb can read the process information from an MIPS N64 linux core file """
+ self.do_test("linux-mips64el-gnuabi64", self._mips64_n64_pid,
+ self._mips_regions, "linux-mips64el-")
+
+ @skipIf(triple='^mips')
+ @skipIfLLVMTargetMissing("PowerPC")
+ def test_ppc64le(self):
+ """Test that lldb can read the process information from an ppc64le linux core file."""
+ self.do_test("linux-ppc64le", self._ppc64le_pid, self._ppc64le_regions,
+ "linux-ppc64le.ou")
+
+ @skipIf(triple='^mips')
+ @skipIfLLVMTargetMissing("X86")
+ def test_x86_64(self):
+ """Test that lldb can read the process information from an x86_64 linux core file."""
+ self.do_test("linux-x86_64", self._x86_64_pid, self._x86_64_regions,
+ "a.out")
+
+ @skipIf(triple='^mips')
+ @skipIfLLVMTargetMissing("SystemZ")
+ def test_s390x(self):
+ """Test that lldb can read the process information from an s390x linux core file."""
+ self.do_test("linux-s390x", self._s390x_pid, self._s390x_regions,
+ "a.out")
+
+ @skipIf(triple='^mips')
+ @skipIfLLVMTargetMissing("X86")
+ def test_same_pid_running(self):
+ """Test that we read the information from the core correctly even if we have a running
+ process with the same PID around"""
+ exe_file = self.getBuildArtifact("linux-x86_64-pid.out")
+ core_file = self.getBuildArtifact("linux-x86_64-pid.core")
+ shutil.copyfile("linux-x86_64.out", exe_file)
+ shutil.copyfile("linux-x86_64.core", core_file)
+ with open(core_file, "r+b") as f:
+ # These are offsets into the NT_PRSTATUS and NT_PRPSINFO structures in the note
+ # segment of the core file. If you update the file, these offsets may need updating
+ # as well. (Notes can be viewed with readelf --notes.)
+ for pid_offset in [0x1c4, 0x320]:
+ f.seek(pid_offset)
+ self.assertEqual(
+ struct.unpack(
+ "<I",
+ f.read(4))[0],
+ self._x86_64_pid)
+
+ # We insert our own pid, and make sure the test still
+ # works.
+ f.seek(pid_offset)
+ f.write(struct.pack("<I", os.getpid()))
+ self.do_test(self.getBuildArtifact("linux-x86_64-pid"), os.getpid(),
+ self._x86_64_regions, "a.out")
+
+ @skipIf(triple='^mips')
+ @skipIfLLVMTargetMissing("X86")
+ def test_two_cores_same_pid(self):
+ """Test that we handle the situation if we have two core files with the same PID
+ around"""
+ alttarget = self.dbg.CreateTarget("altmain.out")
+ altprocess = alttarget.LoadCore("altmain.core")
+ self.assertTrue(altprocess, PROCESS_IS_VALID)
+ self.assertEqual(altprocess.GetNumThreads(), 1)
+ self.assertEqual(altprocess.GetProcessID(), self._x86_64_pid)
+
+ altframe = altprocess.GetSelectedThread().GetFrameAtIndex(0)
+ self.assertEqual(altframe.GetFunctionName(), "_start")
+ self.assertEqual(
+ altframe.GetLineEntry().GetLine(),
+ line_number(
+ "altmain.c",
+ "Frame _start"))
+
+ error = lldb.SBError()
+ F = altprocess.ReadCStringFromMemory(
+ altframe.FindVariable("F").GetValueAsUnsigned(), 256, error)
+ self.assertTrue(error.Success())
+ self.assertEqual(F, "_start")
+
+ # without destroying this process, run the test which opens another core file with the
+ # same pid
+ self.do_test("linux-x86_64", self._x86_64_pid, self._x86_64_regions,
+ "a.out")
+
+ @skipIf(triple='^mips')
+ @skipIfLLVMTargetMissing("X86")
+ def test_FPR_SSE(self):
+ # check x86_64 core file
+ target = self.dbg.CreateTarget(None)
+ self.assertTrue(target, VALID_TARGET)
+ process = target.LoadCore("linux-fpr_sse_x86_64.core")
+
+ values = {}
+ values["fctrl"] = "0x037f"
+ values["fstat"] = "0x0000"
+ values["ftag"] = "0x00ff"
+ values["fop"] = "0x0000"
+ values["fiseg"] = "0x00000000"
+ values["fioff"] = "0x0040011e"
+ values["foseg"] = "0x00000000"
+ values["fooff"] = "0x00000000"
+ values["mxcsr"] = "0x00001f80"
+ values["mxcsrmask"] = "0x0000ffff"
+ values["st0"] = "{0x99 0xf7 0xcf 0xfb 0x84 0x9a 0x20 0x9a 0xfd 0x3f}"
+ values["st1"] = "{0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x80 0xff 0x3f}"
+ values["st2"] = "{0xfe 0x8a 0x1b 0xcd 0x4b 0x78 0x9a 0xd4 0x00 0x40}"
+ values["st3"] = "{0xac 0x79 0xcf 0xd1 0xf7 0x17 0x72 0xb1 0xfe 0x3f}"
+ values["st4"] = "{0xbc 0xf0 0x17 0x5c 0x29 0x3b 0xaa 0xb8 0xff 0x3f}"
+ values["st5"] = "{0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x80 0xff 0x3f}"
+ values["st6"] = "{0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}"
+ values["st7"] = "{0x35 0xc2 0x68 0x21 0xa2 0xda 0x0f 0xc9 0x00 0x40}"
+ values["xmm0"] = "{0x29 0x31 0x64 0x46 0x29 0x31 0x64 0x46 0x29 0x31 0x64 0x46 0x29 0x31 0x64 0x46}"
+ values["xmm1"] = "{0x9c 0xed 0x86 0x64 0x9c 0xed 0x86 0x64 0x9c 0xed 0x86 0x64 0x9c 0xed 0x86 0x64}"
+ values["xmm2"] = "{0x07 0xc2 0x1f 0xd7 0x07 0xc2 0x1f 0xd7 0x07 0xc2 0x1f 0xd7 0x07 0xc2 0x1f 0xd7}"
+ values["xmm3"] = "{0xa2 0x20 0x48 0x25 0xa2 0x20 0x48 0x25 0xa2 0x20 0x48 0x25 0xa2 0x20 0x48 0x25}"
+ values["xmm4"] = "{0xeb 0x5a 0xa8 0xc4 0xeb 0x5a 0xa8 0xc4 0xeb 0x5a 0xa8 0xc4 0xeb 0x5a 0xa8 0xc4}"
+ values["xmm5"] = "{0x49 0x41 0x20 0x0b 0x49 0x41 0x20 0x0b 0x49 0x41 0x20 0x0b 0x49 0x41 0x20 0x0b}"
+ values["xmm6"] = "{0xf8 0xf1 0x8b 0x4f 0xf8 0xf1 0x8b 0x4f 0xf8 0xf1 0x8b 0x4f 0xf8 0xf1 0x8b 0x4f}"
+ values["xmm7"] = "{0x13 0xf1 0x30 0xcd 0x13 0xf1 0x30 0xcd 0x13 0xf1 0x30 0xcd 0x13 0xf1 0x30 0xcd}"
+
+ for regname, value in values.items():
+ self.expect("register read {}".format(regname), substrs=["{} = {}".format(regname, value)])
+
+
+ # now check i386 core file
+ target = self.dbg.CreateTarget(None)
+ self.assertTrue(target, VALID_TARGET)
+ process = target.LoadCore("linux-fpr_sse_i386.core")
+
+ values["fioff"] = "0x080480cc"
+
+ for regname, value in values.items():
+ self.expect("register read {}".format(regname), substrs=["{} = {}".format(regname, value)])
+
+ @skipIf(triple='^mips')
+ @skipIfLLVMTargetMissing("X86")
+ def test_i386_sysroot(self):
+ """Test that lldb can find the exe for an i386 linux core file using the sysroot."""
+
+ # Copy linux-i386.out to tmp_sysroot/home/labath/test/a.out (since it was compiled as
+ # /home/labath/test/a.out)
+ tmp_sysroot = os.path.join(self.getBuildDir(), "lldb_i386_mock_sysroot")
+ executable = os.path.join(tmp_sysroot, "home", "labath", "test", "a.out")
+ lldbutil.mkdir_p(os.path.dirname(executable))
+ shutil.copyfile("linux-i386.out", executable)
+
+ # Set sysroot and load core
+ self.runCmd("platform select remote-linux --sysroot '%s'" % tmp_sysroot)
+ target = self.dbg.CreateTarget(None)
+ self.assertTrue(target, VALID_TARGET)
+ process = target.LoadCore("linux-i386.core")
+
+ # Check that we found a.out from the sysroot
+ self.check_all(process, self._i386_pid, self._i386_regions, "a.out")
+
+ self.dbg.DeleteTarget(target)
+
+ @skipIf(triple='^mips')
+ @skipIfLLVMTargetMissing("ARM")
+ def test_arm_core(self):
+ # check 32 bit ARM core file
+ target = self.dbg.CreateTarget(None)
+ self.assertTrue(target, VALID_TARGET)
+ process = target.LoadCore("linux-arm.core")
+
+ values = {}
+ values["r0"] = "0x00000000"
+ values["r1"] = "0x00000001"
+ values["r2"] = "0x00000002"
+ values["r3"] = "0x00000003"
+ values["r4"] = "0x00000004"
+ values["r5"] = "0x00000005"
+ values["r6"] = "0x00000006"
+ values["r7"] = "0x00000007"
+ values["r8"] = "0x00000008"
+ values["r9"] = "0x00000009"
+ values["r10"] = "0x0000000a"
+ values["r11"] = "0x0000000b"
+ values["r12"] = "0x0000000c"
+ values["sp"] = "0x0000000d"
+ values["lr"] = "0x0000000e"
+ values["pc"] = "0x0000000f"
+ values["cpsr"] = "0x00000010"
+ for regname, value in values.items():
+ self.expect("register read {}".format(regname), substrs=["{} = {}".format(regname, value)])
+
+ def check_memory_regions(self, process, region_count):
+ region_list = process.GetMemoryRegions()
+ self.assertEqual(region_list.GetSize(), region_count)
+
+ region = lldb.SBMemoryRegionInfo()
+
+ # Check we have the right number of regions.
+ self.assertEqual(region_list.GetSize(), region_count)
+
+ # Check that getting a region beyond the last in the list fails.
+ self.assertFalse(
+ region_list.GetMemoryRegionAtIndex(
+ region_count, region))
+
+ # Check each region is valid.
+ for i in range(region_list.GetSize()):
+ # Check we can actually get this region.
+ self.assertTrue(region_list.GetMemoryRegionAtIndex(i, region))
+
+ # Every region in the list should be mapped.
+ self.assertTrue(region.IsMapped())
+
+ # Test the address at the start of a region returns it's enclosing
+ # region.
+ begin_address = region.GetRegionBase()
+ region_at_begin = lldb.SBMemoryRegionInfo()
+ error = process.GetMemoryRegionInfo(begin_address, region_at_begin)
+ self.assertEqual(region, region_at_begin)
+
+ # Test an address in the middle of a region returns it's enclosing
+ # region.
+ middle_address = (region.GetRegionBase() +
+ region.GetRegionEnd()) // 2
+ region_at_middle = lldb.SBMemoryRegionInfo()
+ error = process.GetMemoryRegionInfo(
+ middle_address, region_at_middle)
+ self.assertEqual(region, region_at_middle)
+
+ # Test the address at the end of a region returns it's enclosing
+ # region.
+ end_address = region.GetRegionEnd() - 1
+ region_at_end = lldb.SBMemoryRegionInfo()
+ error = process.GetMemoryRegionInfo(end_address, region_at_end)
+ self.assertEqual(region, region_at_end)
+
+ # Check that quering the end address does not return this region but
+ # the next one.
+ next_region = lldb.SBMemoryRegionInfo()
+ error = process.GetMemoryRegionInfo(
+ region.GetRegionEnd(), next_region)
+ self.assertNotEqual(region, next_region)
+ self.assertEqual(
+ region.GetRegionEnd(),
+ next_region.GetRegionBase())
+
+ # Check that query beyond the last region returns an unmapped region
+ # that ends at LLDB_INVALID_ADDRESS
+ last_region = lldb.SBMemoryRegionInfo()
+ region_list.GetMemoryRegionAtIndex(region_count - 1, last_region)
+ end_region = lldb.SBMemoryRegionInfo()
+ error = process.GetMemoryRegionInfo(
+ last_region.GetRegionEnd(), end_region)
+ self.assertFalse(end_region.IsMapped())
+ self.assertEqual(
+ last_region.GetRegionEnd(),
+ end_region.GetRegionBase())
+ self.assertEqual(end_region.GetRegionEnd(), lldb.LLDB_INVALID_ADDRESS)
+
+ def check_state(self, process):
+ with open(os.devnull) as devnul:
+ # sanitize test output
+ self.dbg.SetOutputFileHandle(devnul, False)
+ self.dbg.SetErrorFileHandle(devnul, False)
+
+ self.assertTrue(process.is_stopped)
+
+ # Process.Continue
+ error = process.Continue()
+ self.assertFalse(error.Success())
+ self.assertTrue(process.is_stopped)
+
+ # Thread.StepOut
+ thread = process.GetSelectedThread()
+ thread.StepOut()
+ self.assertTrue(process.is_stopped)
+
+ # command line
+ self.dbg.HandleCommand('s')
+ self.assertTrue(process.is_stopped)
+ self.dbg.HandleCommand('c')
+ self.assertTrue(process.is_stopped)
+
+ # restore file handles
+ self.dbg.SetOutputFileHandle(None, False)
+ self.dbg.SetErrorFileHandle(None, False)
+
+ def check_stack(self, process, pid, thread_name):
+ thread = process.GetSelectedThread()
+ self.assertTrue(thread)
+ self.assertEqual(thread.GetThreadID(), pid)
+ self.assertEqual(thread.GetName(), thread_name)
+ backtrace = ["bar", "foo", "_start"]
+ self.assertEqual(thread.GetNumFrames(), len(backtrace))
+ for i in range(len(backtrace)):
+ frame = thread.GetFrameAtIndex(i)
+ self.assertTrue(frame)
+ self.assertEqual(frame.GetFunctionName(), backtrace[i])
+ self.assertEqual(frame.GetLineEntry().GetLine(),
+ line_number("main.c", "Frame " + backtrace[i]))
+ self.assertEqual(
+ frame.FindVariable("F").GetValueAsUnsigned(), ord(
+ backtrace[i][0]))
+
+ def check_all(self, process, pid, region_count, thread_name):
+ self.assertTrue(process, PROCESS_IS_VALID)
+ self.assertEqual(process.GetNumThreads(), 1)
+ self.assertEqual(process.GetProcessID(), pid)
+
+ self.check_state(process)
+
+ self.check_stack(process, pid, thread_name)
+
+ self.check_memory_regions(process, region_count)
+
+ def do_test(self, filename, pid, region_count, thread_name):
+ target = self.dbg.CreateTarget(filename + ".out")
+ process = target.LoadCore(filename + ".core")
+
+ self.check_all(process, pid, region_count, thread_name)
+
+ self.dbg.DeleteTarget(target)
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/altmain.c b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/altmain.c
new file mode 100644
index 00000000000..da49a00996e
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/altmain.c
@@ -0,0 +1,6 @@
+void _start(void)
+{
+ const char *F = "_start";
+ char *boom = (char *)0;
+ *boom = 47; // Frame _start
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/altmain.out b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/altmain.out
new file mode 100755
index 00000000000..2fddf3e8f80
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/altmain.out
Binary files differ
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/fpr_sse.cpp b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/fpr_sse.cpp
new file mode 100644
index 00000000000..e6826fc7a09
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/fpr_sse.cpp
@@ -0,0 +1,38 @@
+// fpr_sse_x86_64.core was generated with:
+// ./make-core.sh fpr_sse.cpp
+//
+// fpr_sse_i386.core was generated with:
+// export CFLAGS=-m32
+// ./make-core.sh fpr_sse.cpp
+
+void _start(void) {
+ __asm__("fldpi;"
+ "fldz;"
+ "fld1;"
+ "fldl2e;"
+ "fldln2;"
+ "fldl2t;"
+ "fld1;"
+ "fldlg2;");
+
+ unsigned int values[8] = {
+ 0x46643129, 0x6486ed9c, 0xd71fc207, 0x254820a2,
+ 0xc4a85aeb, 0x0b204149, 0x4f8bf1f8, 0xcd30f113,
+ };
+
+ __asm__("vbroadcastss %0, %%xmm0;"
+ "vbroadcastss %1, %%xmm1;"
+ "vbroadcastss %2, %%xmm2;"
+ "vbroadcastss %3, %%xmm3;"
+ "vbroadcastss %4, %%xmm4;"
+ "vbroadcastss %5, %%xmm5;"
+ "vbroadcastss %6, %%xmm6;"
+ "vbroadcastss %7, %%xmm7;"
+
+ ::"m"(values[0]),
+ "m"(values[1]), "m"(values[2]), "m"(values[3]), "m"(values[4]),
+ "m"(values[5]), "m"(values[6]), "m"(values[7]));
+
+ volatile int *a = 0;
+ *a = 0;
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/gcore/TestGCore.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/gcore/TestGCore.py
new file mode 100644
index 00000000000..ca863d25048
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/gcore/TestGCore.py
@@ -0,0 +1,54 @@
+"""
+Test signal reporting when debugging with linux core files.
+"""
+
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class GCoreTestCase(TestBase):
+ NO_DEBUG_INFO_TESTCASE = True
+
+ mydir = TestBase.compute_mydir(__file__)
+ def setUp(self):
+ super(GCoreTestCase, self).setUp()
+ self._initial_platform = lldb.DBG.GetSelectedPlatform()
+
+ def tearDown(self):
+ lldb.DBG.SetSelectedPlatform(self._initial_platform)
+ super(GCoreTestCase, self).tearDown()
+
+ _i386_pid = 5586
+ _x86_64_pid = 5669
+
+ @skipIf(oslist=['windows'])
+ @skipIf(triple='^mips')
+ def test_i386(self):
+ """Test that lldb can read the process information from an i386 linux core file."""
+ self.do_test("linux-i386", self._i386_pid)
+
+ @skipIf(oslist=['windows'])
+ @skipIf(triple='^mips')
+ def test_x86_64(self):
+ """Test that lldb can read the process information from an x86_64 linux core file."""
+ self.do_test("linux-x86_64", self._x86_64_pid)
+
+ def do_test(self, filename, pid):
+ target = self.dbg.CreateTarget("")
+ process = target.LoadCore(filename + ".core")
+ self.assertTrue(process, PROCESS_IS_VALID)
+ self.assertEqual(process.GetNumThreads(), 3)
+ self.assertEqual(process.GetProcessID(), pid)
+
+ for thread in process:
+ reason = thread.GetStopReason()
+ self.assertEqual(reason, lldb.eStopReasonSignal)
+ signal = thread.GetStopReasonDataAtIndex(1)
+ # Check we got signal 19 (SIGSTOP)
+ self.assertEqual(signal, 19)
+
+ self.dbg.DeleteTarget(target)
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/gcore/main.cpp b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/gcore/main.cpp
new file mode 100644
index 00000000000..a8e5f34d14e
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/gcore/main.cpp
@@ -0,0 +1,62 @@
+//===-- main.cpp ------------------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// This test verifies the correct handling of child thread exits.
+
+#include "pseudo_barrier.h"
+#include <thread>
+#include <csignal>
+
+pseudo_barrier_t g_barrier1;
+pseudo_barrier_t g_barrier2;
+
+void *
+thread1 ()
+{
+ // Synchronize with the main thread.
+ pseudo_barrier_wait(g_barrier1);
+
+ // Synchronize with the main thread and thread2.
+ pseudo_barrier_wait(g_barrier2);
+
+ // Return
+ return NULL;
+}
+
+void *
+thread2 ()
+{
+
+ // Synchronize with thread1 and the main thread.
+ pseudo_barrier_wait(g_barrier2); // Should not reach here.
+
+ // Return
+ return NULL;
+}
+
+int main ()
+{
+
+ pseudo_barrier_init(g_barrier1, 2);
+ pseudo_barrier_init(g_barrier2, 3);
+
+ // Create a thread.
+ std::thread thread_1(thread1);
+
+ // Wait for thread1 to start.
+ pseudo_barrier_wait(g_barrier1);
+
+ // Wait for thread1 to start.
+ std::thread thread_2(thread2);
+
+ // Thread 2 is waiting for another thread to reach the barrier.
+ // This should have for ever. (So we can run gcore against this process.)
+ thread_2.join();
+
+ return 0;
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/gcore/main.mk b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/gcore/main.mk
new file mode 100755
index 00000000000..566938ca0cc
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/gcore/main.mk
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+ENABLE_THREADS := YES
+include Makefile.rules
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/gcore/make-core.sh b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/gcore/make-core.sh
new file mode 100755
index 00000000000..b6979c7790d
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/gcore/make-core.sh
@@ -0,0 +1,56 @@
+#! /bin/sh
+
+linux_check_ptrace_scope()
+{
+ if grep -q '1' </proc/sys/kernel/yama/ptrace_scope; then
+ cat <<EOF
+Your system prevents the use of PTRACE to attach to non-child processes. The core file
+cannot be generated. Please reset /proc/sys/kernel/yama/ptrace_scope to 0 (requires root
+privileges) to enable core generation via gcore.
+EOF
+ exit 1
+ fi
+}
+
+set -e -x
+
+OS=$(uname -s)
+if [ "$OS" = Linux ]; then
+ linux_check_ptrace_scope
+fi
+
+rm -f a.out
+make -f main.mk
+
+cat <<EOF
+Executable file is in a.out.
+Core file will be saved as core.<pid>.
+EOF
+
+stack_size=`ulimit -s`
+
+# Decrease stack size to 16k => smaller core files.
+# gcore won't run with the smaller stack
+ulimit -Ss 16
+
+core_dump_filter=`cat /proc/self/coredump_filter`
+echo 0 > /proc/self/coredump_filter
+
+./a.out &
+
+pid=$!
+
+echo $core_dump_filter > /proc/self/coredump_filter
+
+# Reset stack size as so there's enough space to run gcore.
+ulimit -s $stack_size
+
+echo "Sleeping for 5 seconds to wait for $pid"
+
+sleep 5
+echo "Taking core from process $pid"
+
+gcore -o core $pid
+
+echo "Killing process $pid"
+kill -9 $pid
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-i386.out b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-i386.out
new file mode 100755
index 00000000000..3cdd4eeca10
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-i386.out
Binary files differ
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mips64el-gnuabi64.out b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mips64el-gnuabi64.out
new file mode 100755
index 00000000000..a230aa4251a
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mips64el-gnuabi64.out
Binary files differ
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mips64el-gnuabin32.out b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mips64el-gnuabin32.out
new file mode 100755
index 00000000000..d1293a71a85
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mips64el-gnuabin32.out
Binary files differ
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mipsel-gnuabio32.out b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mipsel-gnuabio32.out
new file mode 100755
index 00000000000..dc809c8da48
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mipsel-gnuabio32.out
Binary files differ
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-ppc64le.out b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-ppc64le.out
new file mode 100755
index 00000000000..05c69fd291b
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-ppc64le.out
Binary files differ
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-s390x.out b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-s390x.out
new file mode 100755
index 00000000000..640fbdc257d
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-s390x.out
Binary files differ
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-x86_64.out b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-x86_64.out
new file mode 100755
index 00000000000..842402fd519
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-x86_64.out
Binary files differ
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/main.c b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/main.c
new file mode 100644
index 00000000000..f5bde4171ca
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/main.c
@@ -0,0 +1,17 @@
+static void bar(char *boom)
+{
+ char F = 'b';
+ *boom = 47; // Frame bar
+}
+
+static void foo(char *boom, void (*boomer)(char *))
+{
+ char F = 'f';
+ boomer(boom); // Frame foo
+}
+
+void _start(void)
+{
+ char F = '_';
+ foo(0, bar); // Frame _start
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/make-core.sh b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/make-core.sh
new file mode 100755
index 00000000000..9dd83f19c76
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/make-core.sh
@@ -0,0 +1,61 @@
+#! /bin/sh
+
+linux_check_core_pattern()
+{
+ if grep -q '^|' </proc/sys/kernel/core_pattern; then
+ cat <<EOF
+Your system uses a crash report tool ($(cat /proc/sys/kernel/core_pattern)). Core files
+will not be generated. Please reset /proc/sys/kernel/core_pattern (requires root
+privileges) to enable core generation.
+EOF
+ exit 1
+ fi
+}
+
+OS=$(uname -s)
+case "$OS" in
+FreeBSD)
+ core_pattern=$(sysctl -n kern.corefile)
+ ;;
+Linux)
+ core_pattern=$(cat /proc/sys/kernel/core_pattern)
+ ;;
+*)
+ echo "OS $OS not supported" >&2
+ exit 1
+ ;;
+esac
+
+set -e -x
+
+file=$1
+if [ -z "$file" ]; then
+ cat <<EOF
+Please supply the main source file as the first argument.
+EOF
+ exit 1
+fi
+
+if [ "$OS" = Linux ]; then
+ linux_check_core_pattern
+fi
+
+ulimit -c 1000
+real_limit=$(ulimit -c)
+if [ $real_limit -lt 100 ]; then
+ cat <<EOF
+Unable to increase the core file limit. Core file may be truncated!
+To fix this, increase HARD core file limit (ulimit -H -c 1000). This may require root
+privileges.
+EOF
+fi
+
+${CC:-cc} -nostdlib -static -g $CFLAGS "$file" -o a.out
+
+cat <<EOF
+Executable file is in a.out.
+Core file will be saved according to pattern $core_pattern.
+EOF
+
+ulimit -s 8 # Decrease stack size to 8k => smaller core files.
+exec ./a.out
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/thread_crash/TestLinuxCoreThreads.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/thread_crash/TestLinuxCoreThreads.py
new file mode 100644
index 00000000000..4be7ebe3122
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/thread_crash/TestLinuxCoreThreads.py
@@ -0,0 +1,75 @@
+"""
+Test signal reporting when debugging with linux core files.
+"""
+
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class LinuxCoreThreadsTestCase(TestBase):
+ NO_DEBUG_INFO_TESTCASE = True
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ super(LinuxCoreThreadsTestCase, self).setUp()
+ self._initial_platform = lldb.DBG.GetSelectedPlatform()
+
+ def tearDown(self):
+ lldb.DBG.SetSelectedPlatform(self._initial_platform)
+ super(LinuxCoreThreadsTestCase, self).tearDown()
+
+ _i386_pid = 5193
+ _x86_64_pid = 5222
+
+ # Thread id for the failing thread.
+ _i386_tid = 5195
+ _x86_64_tid = 5250
+
+ @skipIf(oslist=['windows'])
+ @skipIf(triple='^mips')
+ def test_i386(self):
+ """Test that lldb can read the process information from an i386 linux core file."""
+ self.do_test("linux-i386", self._i386_pid, self._i386_tid)
+
+ @skipIf(oslist=['windows'])
+ @skipIf(triple='^mips')
+ def test_x86_64(self):
+ """Test that lldb can read the process information from an x86_64 linux core file."""
+ self.do_test("linux-x86_64", self._x86_64_pid, self._x86_64_tid)
+
+ def do_test(self, filename, pid, tid):
+ target = self.dbg.CreateTarget("")
+ process = target.LoadCore(filename + ".core")
+ self.assertTrue(process, PROCESS_IS_VALID)
+ self.assertEqual(process.GetNumThreads(), 3)
+ self.assertEqual(process.GetProcessID(), pid)
+
+ for thread in process:
+ # Verify that if we try to read memory from a PT_LOAD that has
+ # p_filesz of zero that we don't get bytes from the next section
+ # that actually did have bytes. The addresses below were found by
+ # dumping the program headers of linux-i386.core and
+ # linux-x86_64.core and verifying that they had a p_filesz of zero.
+ mem_err = lldb.SBError()
+ if process.GetAddressByteSize() == 4:
+ bytes_read = process.ReadMemory(0x8048000, 4, mem_err)
+ else:
+ bytes_read = process.ReadMemory(0x400000, 4, mem_err)
+ self.assertEqual(bytes_read, None)
+ reason = thread.GetStopReason()
+ if( thread.GetThreadID() == tid ):
+ self.assertEqual(reason, lldb.eStopReasonSignal)
+ signal = thread.GetStopReasonDataAtIndex(1)
+ # Check we got signal 4 (SIGILL)
+ self.assertEqual(signal, 4)
+ else:
+ signal = thread.GetStopReasonDataAtIndex(1)
+ # Check we got no signal on the other threads
+ self.assertEqual(signal, 0)
+
+ self.dbg.DeleteTarget(target)
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/thread_crash/main.cpp b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/thread_crash/main.cpp
new file mode 100644
index 00000000000..dd83558bd69
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/thread_crash/main.cpp
@@ -0,0 +1,62 @@
+//===-- main.cpp ------------------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// This test verifies the correct handling of child thread exits.
+
+#include "pseudo_barrier.h"
+#include <thread>
+#include <csignal>
+
+pseudo_barrier_t g_barrier1;
+pseudo_barrier_t g_barrier2;
+
+void *
+thread1 ()
+{
+ // Synchronize with the main thread.
+ pseudo_barrier_wait(g_barrier1);
+
+ // Synchronize with the main thread and thread2.
+ pseudo_barrier_wait(g_barrier2);
+
+ // Return
+ return NULL; // Should not reach here. (thread2 should raise SIGILL)
+}
+
+void *
+thread2 ()
+{
+ raise(SIGILL); // Raise SIGILL
+
+ // Synchronize with thread1 and the main thread.
+ pseudo_barrier_wait(g_barrier2); // Should not reach here.
+
+ // Return
+ return NULL;
+}
+
+int main ()
+{
+ pseudo_barrier_init(g_barrier1, 2);
+ pseudo_barrier_init(g_barrier2, 3);
+
+ // Create a thread.
+ std::thread thread_1(thread1);
+
+ // Wait for thread1 to start.
+ pseudo_barrier_wait(g_barrier1);
+
+ // Create another thread.
+ std::thread thread_2(thread2);
+
+ // Wait for thread2 to start.
+ // Second thread should crash but first thread and main thread may reach here.
+ pseudo_barrier_wait(g_barrier2);
+
+ return 0;
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/thread_crash/main.mk b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/thread_crash/main.mk
new file mode 100755
index 00000000000..566938ca0cc
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/thread_crash/main.mk
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+ENABLE_THREADS := YES
+include Makefile.rules
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/thread_crash/make-core.sh b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/thread_crash/make-core.sh
new file mode 100755
index 00000000000..ea263c86ea4
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/thread_crash/make-core.sh
@@ -0,0 +1,64 @@
+#! /bin/sh
+
+linux_check_core_pattern()
+{
+ if grep -q '^|' </proc/sys/kernel/core_pattern; then
+ cat <<EOF
+Your system uses a crash report tool ($(cat /proc/sys/kernel/core_pattern)). Core files
+will not be generated. Please reset /proc/sys/kernel/core_pattern (requires root
+privileges) to enable core generation.
+EOF
+ exit 1
+ fi
+}
+
+OS=$(uname -s)
+case "$OS" in
+FreeBSD)
+ core_pattern=$(sysctl -n kern.corefile)
+ ;;
+Linux)
+ core_pattern=$(cat /proc/sys/kernel/core_pattern)
+ ;;
+*)
+ echo "OS $OS not supported" >&2
+ exit 1
+ ;;
+esac
+
+set -e -x
+
+if [ "$OS" = Linux ]; then
+ linux_check_core_pattern
+fi
+
+ulimit -c 1000
+real_limit=$(ulimit -c)
+if [ $real_limit -lt 100 ]; then
+ cat <<EOF
+Unable to increase the core file limit. Core file may be truncated!
+To fix this, increase HARD core file limit (ulimit -H -c 1000). This may require root
+privileges.
+EOF
+fi
+
+rm -f a.out
+make -f main.mk
+
+cat <<EOF
+Executable file is in a.out.
+Core file will be saved according to pattern $core_pattern.
+EOF
+
+# Save stack size and core_dump_filter
+stack_size=`ulimit -s`
+ulimit -Ss 32 # Decrease stack size to 32k => smaller core files.
+
+core_dump_filter=`cat /proc/self/coredump_filter`
+echo 0 > /proc/self/coredump_filter
+
+exec ./a.out
+
+# Reset stack size and core_dump_filter
+echo core_dump_filter > /proc/self/coredump_filter
+ulimit -s $stack_size
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/mach-core/TestMachCore.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/mach-core/TestMachCore.py
new file mode 100644
index 00000000000..7680b55e60d
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/mach-core/TestMachCore.py
@@ -0,0 +1,69 @@
+"""
+Test basics of mach core file debugging.
+"""
+
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class MachCoreTestCase(TestBase):
+ NO_DEBUG_INFO_TESTCASE = True
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ super(MachCoreTestCase, self).setUp()
+ self._initial_platform = lldb.DBG.GetSelectedPlatform()
+
+ def tearDown(self):
+ lldb.DBG.SetSelectedPlatform(self._initial_platform)
+ super(MachCoreTestCase, self).tearDown()
+
+ # This was originally marked as expected failure on Windows, but it has
+ # started timing out instead, so the expectedFailure attribute no longer
+ # correctly tracks it: llvm.org/pr37371
+ @skipIfWindows
+ def test_selected_thread(self):
+ """Test that the right thread is selected after a core is loaded."""
+ # Create core form YAML.
+ self.yaml2obj("test.core.yaml", self.getBuildArtifact("test.core"))
+
+ # Set debugger into synchronous mode
+ self.dbg.SetAsync(False)
+
+ # Create a target by the debugger.
+ target = self.dbg.CreateTarget("")
+
+ # Load OS plugin.
+ python_os_plugin_path = os.path.join(self.getSourceDir(),
+ 'operating_system.py')
+ command = "settings set target.process.python-os-plugin-path '{}'".format(
+ python_os_plugin_path)
+ self.dbg.HandleCommand(command)
+
+ # Load core.
+ process = target.LoadCore(self.getBuildArtifact("test.core"))
+ self.assertTrue(process, PROCESS_IS_VALID)
+ self.assertEqual(process.GetNumThreads(), 3)
+
+ # Verify our OS plug-in threads showed up
+ thread = process.GetThreadByID(0x111111111)
+ self.assertTrue(thread.IsValid(
+ ), "Make sure there is a thread 0x111111111 after we load the python OS plug-in"
+ )
+ thread = process.GetThreadByID(0x222222222)
+ self.assertTrue(thread.IsValid(
+ ), "Make sure there is a thread 0x222222222 after we load the python OS plug-in"
+ )
+ thread = process.GetThreadByID(0x333333333)
+ self.assertTrue(thread.IsValid(
+ ), "Make sure there is a thread 0x333333333 after we load the python OS plug-in"
+ )
+
+ # Verify that the correct thread is selected
+ thread = process.GetSelectedThread()
+ self.assertEqual(thread.GetThreadID(), 0x333333333)
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/mach-core/operating_system.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/mach-core/operating_system.py
new file mode 100644
index 00000000000..95a5bdc9dd8
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/mach-core/operating_system.py
@@ -0,0 +1,44 @@
+import lldb
+
+
+class OperatingSystemPlugIn(object):
+ """Class that provides data for an instance of a LLDB 'OperatingSystemPython' plug-in class"""
+
+ def __init__(self, process):
+ '''Initialization needs a valid.SBProcess object.
+
+ This plug-in will get created after a live process is valid and has stopped for the first time.
+ '''
+ self.process = None
+ self.registers = None
+ self.threads = None
+ if isinstance(process, lldb.SBProcess) and process.IsValid():
+ self.process = process
+ self.threads = None # Will be an dictionary containing info for each thread
+
+ def get_target(self):
+ return self.process.target
+
+ def get_thread_info(self):
+ if not self.threads:
+ self.threads = [{
+ 'tid': 0x111111111,
+ 'name': 'one',
+ 'queue': 'queue1',
+ 'state': 'stopped',
+ 'stop_reason': 'none'
+ }, {
+ 'tid': 0x222222222,
+ 'name': 'two',
+ 'queue': 'queue2',
+ 'state': 'stopped',
+ 'stop_reason': 'none'
+ }, {
+ 'tid': 0x333333333,
+ 'name': 'three',
+ 'queue': 'queue3',
+ 'state': 'stopped',
+ 'stop_reason': 'sigstop',
+ 'core': 0
+ }]
+ return self.threads
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/mach-core/test.core.yaml b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/mach-core/test.core.yaml
new file mode 100644
index 00000000000..84ce54e45e1
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/mach-core/test.core.yaml
@@ -0,0 +1,853 @@
+--- !mach-o
+FileHeader:
+ magic: 0xFEEDFACF
+ cputype: 0x01000007
+ cpusubtype: 0x00000003
+ filetype: 0x00000004
+ ncmds: 59
+ sizeofcmds: 4384
+ flags: 0x00000000
+ reserved: 0x00000000
+LoadCommands:
+ - cmd: LC_THREAD
+ cmdsize: 208
+ PayloadBytes:
+ - 0x04
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x2A
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x01
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x80
+ - 0xF7
+ - 0xBF
+ - 0xEF
+ - 0xFE
+ - 0x7F
+ - 0x00
+ - 0x00
+ - 0x20
+ - 0xF6
+ - 0xBF
+ - 0xEF
+ - 0xFE
+ - 0x7F
+ - 0x00
+ - 0x00
+ - 0x01
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x10
+ - 0xF6
+ - 0xBF
+ - 0xEF
+ - 0xFE
+ - 0x7F
+ - 0x00
+ - 0x00
+ - 0xF0
+ - 0xF5
+ - 0xBF
+ - 0xEF
+ - 0xFE
+ - 0x7F
+ - 0x00
+ - 0x00
+ - 0xF0
+ - 0xF5
+ - 0xBF
+ - 0xEF
+ - 0xFE
+ - 0x7F
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0xFF
+ - 0xFF
+ - 0xFF
+ - 0xFF
+ - 0xC8
+ - 0xB0
+ - 0x70
+ - 0xA7
+ - 0xFF
+ - 0x7F
+ - 0x00
+ - 0x00
+ - 0xD0
+ - 0xB0
+ - 0x70
+ - 0xA7
+ - 0xFF
+ - 0x7F
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0xA0
+ - 0x0F
+ - 0x00
+ - 0x00
+ - 0x01
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x46
+ - 0x02
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x2B
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x06
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x04
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x03
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x00
+ - 0x10
+ - 0x00
+ - 0x02
+ - 0xA7
+ - 0xFF
+ - 0x7F
+ - 0x00
+ - 0x00
+ - cmd: LC_SEGMENT_64
+ cmdsize: 72
+ segname: ''
+ vmaddr: 4294967296
+ vmsize: 4096
+ fileoff: 8192
+ filesize: 4096
+ maxprot: 5
+ initprot: 5
+ nsects: 0
+ flags: 0
+ - cmd: LC_SEGMENT_64
+ cmdsize: 72
+ segname: ''
+ vmaddr: 4294971392
+ vmsize: 4096
+ fileoff: 12288
+ filesize: 4096
+ maxprot: 1
+ initprot: 1
+ nsects: 0
+ flags: 0
+ - cmd: LC_SEGMENT_64
+ cmdsize: 72
+ segname: ''
+ vmaddr: 4294975488
+ vmsize: 307200
+ fileoff: 16384
+ filesize: 307200
+ maxprot: 5
+ initprot: 5
+ nsects: 0
+ flags: 0
+ - cmd: LC_SEGMENT_64
+ cmdsize: 72
+ segname: ''
+ vmaddr: 4295282688
+ vmsize: 12288
+ fileoff: 323584
+ filesize: 12288
+ maxprot: 3
+ initprot: 3
+ nsects: 0
+ flags: 0
+ - cmd: LC_SEGMENT_64
+ cmdsize: 72
+ segname: ''
+ vmaddr: 4295294976
+ vmsize: 217088
+ fileoff: 335872
+ filesize: 217088
+ maxprot: 3
+ initprot: 3
+ nsects: 0
+ flags: 0
+ - cmd: LC_SEGMENT_64
+ cmdsize: 72
+ segname: ''
+ vmaddr: 4295512064
+ vmsize: 110592
+ fileoff: 552960
+ filesize: 110592
+ maxprot: 1
+ initprot: 1
+ nsects: 0
+ flags: 0
+ - cmd: LC_SEGMENT_64
+ cmdsize: 72
+ segname: ''
+ vmaddr: 4295622656
+ vmsize: 8192
+ fileoff: 663552
+ filesize: 8192
+ maxprot: 1
+ initprot: 1
+ nsects: 0
+ flags: 0
+ - cmd: LC_SEGMENT_64
+ cmdsize: 72
+ segname: ''
+ vmaddr: 4295630848
+ vmsize: 8192
+ fileoff: 671744
+ filesize: 8192
+ maxprot: 3
+ initprot: 3
+ nsects: 0
+ flags: 0
+ - cmd: LC_SEGMENT_64
+ cmdsize: 72
+ segname: ''
+ vmaddr: 4295639040
+ vmsize: 4096
+ fileoff: 679936
+ filesize: 4096
+ maxprot: 1
+ initprot: 1
+ nsects: 0
+ flags: 0
+ - cmd: LC_SEGMENT_64
+ cmdsize: 72
+ segname: ''
+ vmaddr: 4295643136
+ vmsize: 4096
+ fileoff: 684032
+ filesize: 4096
+ maxprot: 3
+ initprot: 3
+ nsects: 0
+ flags: 0
+ - cmd: LC_SEGMENT_64
+ cmdsize: 72
+ segname: ''
+ vmaddr: 4295651328
+ vmsize: 24576
+ fileoff: 688128
+ filesize: 24576
+ maxprot: 3
+ initprot: 3
+ nsects: 0
+ flags: 0
+ - cmd: LC_SEGMENT_64
+ cmdsize: 72
+ segname: ''
+ vmaddr: 4295684096
+ vmsize: 24576
+ fileoff: 712704
+ filesize: 24576
+ maxprot: 3
+ initprot: 3
+ nsects: 0
+ flags: 0
+ - cmd: LC_SEGMENT_64
+ cmdsize: 72
+ segname: ''
+ vmaddr: 4295712768
+ vmsize: 4096
+ fileoff: 737280
+ filesize: 4096
+ maxprot: 1
+ initprot: 1
+ nsects: 0
+ flags: 0
+ - cmd: LC_SEGMENT_64
+ cmdsize: 72
+ segname: ''
+ vmaddr: 4295716864
+ vmsize: 8192
+ fileoff: 741376
+ filesize: 8192
+ maxprot: 1
+ initprot: 1
+ nsects: 0
+ flags: 0
+ - cmd: LC_SEGMENT_64
+ cmdsize: 72
+ segname: ''
+ vmaddr: 4296015872
+ vmsize: 1048576
+ fileoff: 749568
+ filesize: 1048576
+ maxprot: 3
+ initprot: 3
+ nsects: 0
+ flags: 0
+ - cmd: LC_SEGMENT_64
+ cmdsize: 72
+ segname: ''
+ vmaddr: 4297064448
+ vmsize: 1048576
+ fileoff: 1798144
+ filesize: 1048576
+ maxprot: 3
+ initprot: 3
+ nsects: 0
+ flags: 0
+ - cmd: LC_SEGMENT_64
+ cmdsize: 72
+ segname: ''
+ vmaddr: 4298113024
+ vmsize: 1048576
+ fileoff: 2846720
+ filesize: 1048576
+ maxprot: 3
+ initprot: 3
+ nsects: 0
+ flags: 0
+ - cmd: LC_SEGMENT_64
+ cmdsize: 72
+ segname: ''
+ vmaddr: 4303355904
+ vmsize: 8388608
+ fileoff: 3895296
+ filesize: 8388608
+ maxprot: 3
+ initprot: 3
+ nsects: 0
+ flags: 0
+ - cmd: LC_SEGMENT_64
+ cmdsize: 72
+ segname: ''
+ vmaddr: 140732912369664
+ vmsize: 8388608
+ fileoff: 12283904
+ filesize: 8388608
+ maxprot: 3
+ initprot: 3
+ nsects: 0
+ flags: 0
+ - cmd: LC_SEGMENT_64
+ cmdsize: 72
+ segname: ''
+ vmaddr: 140734252867584
+ vmsize: 811999232
+ fileoff: 20672512
+ filesize: 811999232
+ maxprot: 5
+ initprot: 5
+ nsects: 0
+ flags: 0
+ - cmd: LC_SEGMENT_64
+ cmdsize: 72
+ segname: ''
+ vmaddr: 140735863480320
+ vmsize: 20553728
+ fileoff: 832671744
+ filesize: 20553728
+ maxprot: 3
+ initprot: 3
+ nsects: 0
+ flags: 0
+ - cmd: LC_SEGMENT_64
+ cmdsize: 72
+ segname: ''
+ vmaddr: 140735884034048
+ vmsize: 2097152
+ fileoff: 853225472
+ filesize: 2097152
+ maxprot: 3
+ initprot: 3
+ nsects: 0
+ flags: 0
+ - cmd: LC_SEGMENT_64
+ cmdsize: 72
+ segname: ''
+ vmaddr: 140735886131200
+ vmsize: 2097152
+ fileoff: 855322624
+ filesize: 2097152
+ maxprot: 3
+ initprot: 3
+ nsects: 0
+ flags: 0
+ - cmd: LC_SEGMENT_64
+ cmdsize: 72
+ segname: ''
+ vmaddr: 140735888228352
+ vmsize: 2097152
+ fileoff: 857419776
+ filesize: 2097152
+ maxprot: 3
+ initprot: 3
+ nsects: 0
+ flags: 0
+ - cmd: LC_SEGMENT_64
+ cmdsize: 72
+ segname: ''
+ vmaddr: 140735890325504
+ vmsize: 2097152
+ fileoff: 859516928
+ filesize: 2097152
+ maxprot: 3
+ initprot: 3
+ nsects: 0
+ flags: 0
+ - cmd: LC_SEGMENT_64
+ cmdsize: 72
+ segname: ''
+ vmaddr: 140735892422656
+ vmsize: 2097152
+ fileoff: 861614080
+ filesize: 2097152
+ maxprot: 3
+ initprot: 3
+ nsects: 0
+ flags: 0
+ - cmd: LC_SEGMENT_64
+ cmdsize: 72
+ segname: ''
+ vmaddr: 140735894519808
+ vmsize: 2097152
+ fileoff: 863711232
+ filesize: 2097152
+ maxprot: 3
+ initprot: 3
+ nsects: 0
+ flags: 0
+ - cmd: LC_SEGMENT_64
+ cmdsize: 72
+ segname: ''
+ vmaddr: 140735896616960
+ vmsize: 2097152
+ fileoff: 865808384
+ filesize: 2097152
+ maxprot: 3
+ initprot: 3
+ nsects: 0
+ flags: 0
+ - cmd: LC_SEGMENT_64
+ cmdsize: 72
+ segname: ''
+ vmaddr: 140735898714112
+ vmsize: 2097152
+ fileoff: 867905536
+ filesize: 2097152
+ maxprot: 3
+ initprot: 3
+ nsects: 0
+ flags: 0
+ - cmd: LC_SEGMENT_64
+ cmdsize: 72
+ segname: ''
+ vmaddr: 140735900811264
+ vmsize: 2097152
+ fileoff: 870002688
+ filesize: 2097152
+ maxprot: 3
+ initprot: 3
+ nsects: 0
+ flags: 0
+ - cmd: LC_SEGMENT_64
+ cmdsize: 72
+ segname: ''
+ vmaddr: 140735902908416
+ vmsize: 10485760
+ fileoff: 872099840
+ filesize: 10485760
+ maxprot: 3
+ initprot: 3
+ nsects: 0
+ flags: 0
+ - cmd: LC_SEGMENT_64
+ cmdsize: 72
+ segname: ''
+ vmaddr: 140735913394176
+ vmsize: 4194304
+ fileoff: 882585600
+ filesize: 4194304
+ maxprot: 3
+ initprot: 3
+ nsects: 0
+ flags: 0
+ - cmd: LC_SEGMENT_64
+ cmdsize: 72
+ segname: ''
+ vmaddr: 140735917588480
+ vmsize: 2097152
+ fileoff: 886779904
+ filesize: 2097152
+ maxprot: 3
+ initprot: 3
+ nsects: 0
+ flags: 0
+ - cmd: LC_SEGMENT_64
+ cmdsize: 72
+ segname: ''
+ vmaddr: 140735919685632
+ vmsize: 2097152
+ fileoff: 888877056
+ filesize: 2097152
+ maxprot: 3
+ initprot: 3
+ nsects: 0
+ flags: 0
+ - cmd: LC_SEGMENT_64
+ cmdsize: 72
+ segname: ''
+ vmaddr: 140735921782784
+ vmsize: 4194304
+ fileoff: 890974208
+ filesize: 4194304
+ maxprot: 3
+ initprot: 3
+ nsects: 0
+ flags: 0
+ - cmd: LC_SEGMENT_64
+ cmdsize: 72
+ segname: ''
+ vmaddr: 140735925977088
+ vmsize: 4194304
+ fileoff: 895168512
+ filesize: 4194304
+ maxprot: 3
+ initprot: 3
+ nsects: 0
+ flags: 0
+ - cmd: LC_SEGMENT_64
+ cmdsize: 72
+ segname: ''
+ vmaddr: 140735930171392
+ vmsize: 6291456
+ fileoff: 899362816
+ filesize: 6291456
+ maxprot: 3
+ initprot: 3
+ nsects: 0
+ flags: 0
+ - cmd: LC_SEGMENT_64
+ cmdsize: 72
+ segname: ''
+ vmaddr: 140735936462848
+ vmsize: 2097152
+ fileoff: 905654272
+ filesize: 2097152
+ maxprot: 3
+ initprot: 3
+ nsects: 0
+ flags: 0
+ - cmd: LC_SEGMENT_64
+ cmdsize: 72
+ segname: ''
+ vmaddr: 140735938560000
+ vmsize: 2097152
+ fileoff: 907751424
+ filesize: 2097152
+ maxprot: 3
+ initprot: 3
+ nsects: 0
+ flags: 0
+ - cmd: LC_SEGMENT_64
+ cmdsize: 72
+ segname: ''
+ vmaddr: 140735940657152
+ vmsize: 2097152
+ fileoff: 909848576
+ filesize: 2097152
+ maxprot: 3
+ initprot: 3
+ nsects: 0
+ flags: 0
+ - cmd: LC_SEGMENT_64
+ cmdsize: 72
+ segname: ''
+ vmaddr: 140735942754304
+ vmsize: 2097152
+ fileoff: 911945728
+ filesize: 2097152
+ maxprot: 3
+ initprot: 3
+ nsects: 0
+ flags: 0
+ - cmd: LC_SEGMENT_64
+ cmdsize: 72
+ segname: ''
+ vmaddr: 140735944851456
+ vmsize: 6291456
+ fileoff: 914042880
+ filesize: 6291456
+ maxprot: 3
+ initprot: 3
+ nsects: 0
+ flags: 0
+ - cmd: LC_SEGMENT_64
+ cmdsize: 72
+ segname: ''
+ vmaddr: 140735951142912
+ vmsize: 2097152
+ fileoff: 920334336
+ filesize: 2097152
+ maxprot: 3
+ initprot: 3
+ nsects: 0
+ flags: 0
+ - cmd: LC_SEGMENT_64
+ cmdsize: 72
+ segname: ''
+ vmaddr: 140735953240064
+ vmsize: 4194304
+ fileoff: 922431488
+ filesize: 4194304
+ maxprot: 3
+ initprot: 3
+ nsects: 0
+ flags: 0
+ - cmd: LC_SEGMENT_64
+ cmdsize: 72
+ segname: ''
+ vmaddr: 140735957434368
+ vmsize: 2097152
+ fileoff: 926625792
+ filesize: 2097152
+ maxprot: 3
+ initprot: 3
+ nsects: 0
+ flags: 0
+ - cmd: LC_SEGMENT_64
+ cmdsize: 72
+ segname: ''
+ vmaddr: 140735959531520
+ vmsize: 2097152
+ fileoff: 928722944
+ filesize: 2097152
+ maxprot: 3
+ initprot: 3
+ nsects: 0
+ flags: 0
+ - cmd: LC_SEGMENT_64
+ cmdsize: 72
+ segname: ''
+ vmaddr: 140735961628672
+ vmsize: 20971520
+ fileoff: 930820096
+ filesize: 20971520
+ maxprot: 3
+ initprot: 3
+ nsects: 0
+ flags: 0
+ - cmd: LC_SEGMENT_64
+ cmdsize: 72
+ segname: ''
+ vmaddr: 140735982600192
+ vmsize: 6291456
+ fileoff: 951791616
+ filesize: 6291456
+ maxprot: 3
+ initprot: 3
+ nsects: 0
+ flags: 0
+ - cmd: LC_SEGMENT_64
+ cmdsize: 72
+ segname: ''
+ vmaddr: 140735988891648
+ vmsize: 2097152
+ fileoff: 958083072
+ filesize: 2097152
+ maxprot: 3
+ initprot: 3
+ nsects: 0
+ flags: 0
+ - cmd: LC_SEGMENT_64
+ cmdsize: 72
+ segname: ''
+ vmaddr: 140735990988800
+ vmsize: 2097152
+ fileoff: 960180224
+ filesize: 2097152
+ maxprot: 3
+ initprot: 3
+ nsects: 0
+ flags: 0
+ - cmd: LC_SEGMENT_64
+ cmdsize: 72
+ segname: ''
+ vmaddr: 140735993085952
+ vmsize: 2097152
+ fileoff: 962277376
+ filesize: 2097152
+ maxprot: 3
+ initprot: 3
+ nsects: 0
+ flags: 0
+ - cmd: LC_SEGMENT_64
+ cmdsize: 72
+ segname: ''
+ vmaddr: 140735995183104
+ vmsize: 2097152
+ fileoff: 964374528
+ filesize: 2097152
+ maxprot: 3
+ initprot: 3
+ nsects: 0
+ flags: 0
+ - cmd: LC_SEGMENT_64
+ cmdsize: 72
+ segname: ''
+ vmaddr: 140735997280256
+ vmsize: 2097152
+ fileoff: 966471680
+ filesize: 2097152
+ maxprot: 3
+ initprot: 3
+ nsects: 0
+ flags: 0
+ - cmd: LC_SEGMENT_64
+ cmdsize: 72
+ segname: ''
+ vmaddr: 140735999377408
+ vmsize: 2097152
+ fileoff: 968568832
+ filesize: 2097152
+ maxprot: 3
+ initprot: 3
+ nsects: 0
+ flags: 0
+ - cmd: LC_SEGMENT_64
+ cmdsize: 72
+ segname: ''
+ vmaddr: 140736001474560
+ vmsize: 1302528
+ fileoff: 970665984
+ filesize: 1302528
+ maxprot: 3
+ initprot: 3
+ nsects: 0
+ flags: 0
+ - cmd: LC_SEGMENT_64
+ cmdsize: 72
+ segname: ''
+ vmaddr: 140736937222144
+ vmsize: 219267072
+ fileoff: 971968512
+ filesize: 219267072
+ maxprot: 1
+ initprot: 1
+ nsects: 0
+ flags: 0
+ - cmd: LC_SEGMENT_64
+ cmdsize: 72
+ segname: ''
+ vmaddr: 140737486258176
+ vmsize: 4096
+ fileoff: 1191235584
+ filesize: 4096
+ maxprot: 1
+ initprot: 1
+ nsects: 0
+ flags: 0
+ - cmd: LC_SEGMENT_64
+ cmdsize: 72
+ segname: ''
+ vmaddr: 140737487028224
+ vmsize: 4096
+ fileoff: 1191239680
+ filesize: 4096
+ maxprot: 5
+ initprot: 5
+ nsects: 0
+ flags: 0
+...
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
new file mode 100644
index 00000000000..62b6c80e0b3
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
@@ -0,0 +1,463 @@
+"""
+Test basics of Minidump debugging.
+"""
+
+from six import iteritems
+
+import shutil
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class MiniDumpNewTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ NO_DEBUG_INFO_TESTCASE = True
+
+ _linux_x86_64_pid = 29917
+ _linux_x86_64_not_crashed_pid = 29939
+ _linux_x86_64_not_crashed_pid_offset = 0xD967
+
+ def setUp(self):
+ super(MiniDumpNewTestCase, self).setUp()
+ self._initial_platform = lldb.DBG.GetSelectedPlatform()
+
+ def tearDown(self):
+ lldb.DBG.SetSelectedPlatform(self._initial_platform)
+ super(MiniDumpNewTestCase, self).tearDown()
+
+ def process_from_yaml(self, yaml_file):
+ minidump_path = self.getBuildArtifact(os.path.basename(yaml_file) + ".dmp")
+ self.yaml2obj(yaml_file, minidump_path)
+ self.target = self.dbg.CreateTarget(None)
+ self.process = self.target.LoadCore(minidump_path)
+ return self.process
+
+ def check_state(self):
+ with open(os.devnull) as devnul:
+ # sanitize test output
+ self.dbg.SetOutputFileHandle(devnul, False)
+ self.dbg.SetErrorFileHandle(devnul, False)
+
+ self.assertTrue(self.process.is_stopped)
+
+ # Process.Continue
+ error = self.process.Continue()
+ self.assertFalse(error.Success())
+ self.assertTrue(self.process.is_stopped)
+
+ # Thread.StepOut
+ thread = self.process.GetSelectedThread()
+ thread.StepOut()
+ self.assertTrue(self.process.is_stopped)
+
+ # command line
+ self.dbg.HandleCommand('s')
+ self.assertTrue(self.process.is_stopped)
+ self.dbg.HandleCommand('c')
+ self.assertTrue(self.process.is_stopped)
+
+ # restore file handles
+ self.dbg.SetOutputFileHandle(None, False)
+ self.dbg.SetErrorFileHandle(None, False)
+
+ def test_loadcore_error_status(self):
+ """Test the SBTarget.LoadCore(core, error) overload."""
+ minidump_path = self.getBuildArtifact("linux-x86_64.dmp")
+ self.yaml2obj("linux-x86_64.yaml", minidump_path)
+ self.target = self.dbg.CreateTarget(None)
+ error = lldb.SBError()
+ self.process = self.target.LoadCore(minidump_path, error)
+ self.assertTrue(self.process, PROCESS_IS_VALID)
+ self.assertTrue(error.Success())
+
+ def test_loadcore_error_status_failure(self):
+ """Test the SBTarget.LoadCore(core, error) overload."""
+ self.target = self.dbg.CreateTarget(None)
+ error = lldb.SBError()
+ self.process = self.target.LoadCore("non-existent.dmp", error)
+ self.assertFalse(self.process, PROCESS_IS_VALID)
+ self.assertTrue(error.Fail())
+
+ def test_process_info_in_minidump(self):
+ """Test that lldb can read the process information from the Minidump."""
+ self.process_from_yaml("linux-x86_64.yaml")
+ self.assertTrue(self.process, PROCESS_IS_VALID)
+ self.assertEqual(self.process.GetNumThreads(), 1)
+ self.assertEqual(self.process.GetProcessID(), self._linux_x86_64_pid)
+ self.check_state()
+
+ def test_memory_region_name(self):
+ self.process_from_yaml("regions-linux-map.yaml")
+ result = lldb.SBCommandReturnObject()
+ addr_region_name_pairs = [
+ ("0x400d9000", "/system/bin/app_process"),
+ ("0x400db000", "/system/bin/app_process"),
+ ("0x400dd000", "/system/bin/linker"),
+ ("0x400ed000", "/system/bin/linker"),
+ ("0x400ee000", "/system/bin/linker"),
+ ("0x400fb000", "/system/lib/liblog.so"),
+ ("0x400fc000", "/system/lib/liblog.so"),
+ ("0x400fd000", "/system/lib/liblog.so"),
+ ("0x400ff000", "/system/lib/liblog.so"),
+ ("0x40100000", "/system/lib/liblog.so"),
+ ("0x40101000", "/system/lib/libc.so"),
+ ("0x40122000", "/system/lib/libc.so"),
+ ("0x40123000", "/system/lib/libc.so"),
+ ("0x40167000", "/system/lib/libc.so"),
+ ("0x40169000", "/system/lib/libc.so"),
+ ]
+ ci = self.dbg.GetCommandInterpreter()
+ for (addr, region_name) in addr_region_name_pairs:
+ command = 'memory region ' + addr
+ ci.HandleCommand(command, result, False)
+ message = 'Ensure memory "%s" shows up in output for "%s"' % (
+ region_name, command)
+ self.assertTrue(region_name in result.GetOutput(), message)
+
+ def test_thread_info_in_minidump(self):
+ """Test that lldb can read the thread information from the Minidump."""
+ self.process_from_yaml("linux-x86_64.yaml")
+ self.check_state()
+ # This process crashed due to a segmentation fault in its
+ # one and only thread.
+ self.assertEqual(self.process.GetNumThreads(), 1)
+ thread = self.process.GetThreadAtIndex(0)
+ self.assertEqual(thread.GetStopReason(), lldb.eStopReasonSignal)
+ stop_description = thread.GetStopDescription(256)
+ self.assertTrue("SIGSEGV" in stop_description)
+
+ def test_stack_info_in_minidump(self):
+ """Test that we can see a trivial stack in a breakpad-generated Minidump."""
+ # target create linux-x86_64 -c linux-x86_64.dmp
+ self.dbg.CreateTarget("linux-x86_64")
+ self.target = self.dbg.GetSelectedTarget()
+ self.process = self.target.LoadCore("linux-x86_64.dmp")
+ self.check_state()
+ self.assertEqual(self.process.GetNumThreads(), 1)
+ self.assertEqual(self.process.GetProcessID(), self._linux_x86_64_pid)
+ thread = self.process.GetThreadAtIndex(0)
+ # frame #0: linux-x86_64`crash()
+ # frame #1: linux-x86_64`_start
+ self.assertEqual(thread.GetNumFrames(), 2)
+ frame = thread.GetFrameAtIndex(0)
+ self.assertTrue(frame.IsValid())
+ self.assertTrue(frame.GetModule().IsValid())
+ pc = frame.GetPC()
+ eip = frame.FindRegister("pc")
+ self.assertTrue(eip.IsValid())
+ self.assertEqual(pc, eip.GetValueAsUnsigned())
+
+ def test_snapshot_minidump_dump_requested(self):
+ """Test that if we load a snapshot minidump file (meaning the process
+ did not crash) with exception code "DUMP_REQUESTED" there is no stop reason."""
+ # target create -c linux-x86_64_not_crashed.dmp
+ self.dbg.CreateTarget(None)
+ self.target = self.dbg.GetSelectedTarget()
+ self.process = self.target.LoadCore("linux-x86_64_not_crashed.dmp")
+ self.check_state()
+ self.assertEqual(self.process.GetNumThreads(), 1)
+ thread = self.process.GetThreadAtIndex(0)
+ self.assertEqual(thread.GetStopReason(), lldb.eStopReasonNone)
+ stop_description = thread.GetStopDescription(256)
+ self.assertEqual(stop_description, "")
+
+ def test_snapshot_minidump_null_exn_code(self):
+ """Test that if we load a snapshot minidump file (meaning the process
+ did not crash) with exception code zero there is no stop reason."""
+ self.process_from_yaml("linux-x86_64_null_signal.yaml")
+ self.check_state()
+ self.assertEqual(self.process.GetNumThreads(), 1)
+ thread = self.process.GetThreadAtIndex(0)
+ self.assertEqual(thread.GetStopReason(), lldb.eStopReasonNone)
+ stop_description = thread.GetStopDescription(256)
+ self.assertEqual(stop_description, "")
+
+ def check_register_unsigned(self, set, name, expected):
+ reg_value = set.GetChildMemberWithName(name)
+ self.assertTrue(reg_value.IsValid(),
+ 'Verify we have a register named "%s"' % (name))
+ self.assertEqual(reg_value.GetValueAsUnsigned(), expected,
+ 'Verify "%s" == %i' % (name, expected))
+
+ def check_register_string_value(self, set, name, expected, format):
+ reg_value = set.GetChildMemberWithName(name)
+ self.assertTrue(reg_value.IsValid(),
+ 'Verify we have a register named "%s"' % (name))
+ if format is not None:
+ reg_value.SetFormat(format)
+ self.assertEqual(reg_value.GetValue(), expected,
+ 'Verify "%s" has string value "%s"' % (name,
+ expected))
+
+ def test_arm64_registers(self):
+ """Test ARM64 registers from a breakpad created minidump."""
+ self.process_from_yaml("arm64-macos.yaml")
+ self.check_state()
+ self.assertEqual(self.process.GetNumThreads(), 1)
+ thread = self.process.GetThreadAtIndex(0)
+ self.assertEqual(thread.GetStopReason(), lldb.eStopReasonNone)
+ stop_description = thread.GetStopDescription(256)
+ self.assertEqual(stop_description, "")
+ registers = thread.GetFrameAtIndex(0).GetRegisters()
+ # Verify the GPR registers are all correct
+ # Verify x0 - x31 register values
+ gpr = registers.GetValueAtIndex(0)
+ for i in range(32):
+ v = i+1 | i+2 << 32 | i+3 << 48
+ w = i+1
+ self.check_register_unsigned(gpr, 'x%i' % (i), v)
+ self.check_register_unsigned(gpr, 'w%i' % (i), w)
+ # Verify arg1 - arg8 register values
+ for i in range(1, 9):
+ v = i | i+1 << 32 | i+2 << 48
+ self.check_register_unsigned(gpr, 'arg%i' % (i), v)
+ i = 29
+ v = i+1 | i+2 << 32 | i+3 << 48
+ self.check_register_unsigned(gpr, 'fp', v)
+ i = 30
+ v = i+1 | i+2 << 32 | i+3 << 48
+ self.check_register_unsigned(gpr, 'lr', v)
+ i = 31
+ v = i+1 | i+2 << 32 | i+3 << 48
+ self.check_register_unsigned(gpr, 'sp', v)
+ self.check_register_unsigned(gpr, 'pc', 0x1000)
+ self.check_register_unsigned(gpr, 'cpsr', 0x11223344)
+ self.check_register_unsigned(gpr, 'psr', 0x11223344)
+
+ # Verify the FPR registers are all correct
+ fpr = registers.GetValueAtIndex(1)
+ for i in range(32):
+ v = "0x"
+ d = "0x"
+ s = "0x"
+ h = "0x"
+ for j in range(i+15, i-1, -1):
+ v += "%2.2x" % (j)
+ for j in range(i+7, i-1, -1):
+ d += "%2.2x" % (j)
+ for j in range(i+3, i-1, -1):
+ s += "%2.2x" % (j)
+ for j in range(i+1, i-1, -1):
+ h += "%2.2x" % (j)
+ self.check_register_string_value(fpr, "v%i" % (i), v,
+ lldb.eFormatHex)
+ self.check_register_string_value(fpr, "d%i" % (i), d,
+ lldb.eFormatHex)
+ self.check_register_string_value(fpr, "s%i" % (i), s,
+ lldb.eFormatHex)
+ self.check_register_string_value(fpr, "h%i" % (i), h,
+ lldb.eFormatHex)
+ self.check_register_unsigned(gpr, 'fpsr', 0x55667788)
+ self.check_register_unsigned(gpr, 'fpcr', 0x99aabbcc)
+
+ def verify_arm_registers(self, apple=False):
+ """
+ Verify values of all ARM registers from a breakpad created
+ minidump.
+ """
+ if apple:
+ self.process_from_yaml("arm-macos.yaml")
+ else:
+ self.process_from_yaml("arm-linux.yaml")
+ self.check_state()
+ self.assertEqual(self.process.GetNumThreads(), 1)
+ thread = self.process.GetThreadAtIndex(0)
+ self.assertEqual(thread.GetStopReason(), lldb.eStopReasonNone)
+ stop_description = thread.GetStopDescription(256)
+ self.assertEqual(stop_description, "")
+ registers = thread.GetFrameAtIndex(0).GetRegisters()
+ # Verify the GPR registers are all correct
+ # Verify x0 - x31 register values
+ gpr = registers.GetValueAtIndex(0)
+ for i in range(1, 16):
+ self.check_register_unsigned(gpr, 'r%i' % (i), i+1)
+ # Verify arg1 - arg4 register values
+ for i in range(1, 5):
+ self.check_register_unsigned(gpr, 'arg%i' % (i), i)
+ if apple:
+ self.check_register_unsigned(gpr, 'fp', 0x08)
+ else:
+ self.check_register_unsigned(gpr, 'fp', 0x0c)
+ self.check_register_unsigned(gpr, 'lr', 0x0f)
+ self.check_register_unsigned(gpr, 'sp', 0x0e)
+ self.check_register_unsigned(gpr, 'pc', 0x10)
+ self.check_register_unsigned(gpr, 'cpsr', 0x11223344)
+
+ # Verify the FPR registers are all correct
+ fpr = registers.GetValueAtIndex(1)
+ # Check d0 - d31
+ self.check_register_unsigned(gpr, 'fpscr', 0x55667788aabbccdd)
+ for i in range(32):
+ value = (i+1) | (i+1) << 8 | (i+1) << 32 | (i+1) << 48
+ self.check_register_unsigned(fpr, "d%i" % (i), value)
+ # Check s0 - s31
+ for i in range(32):
+ i_val = (i >> 1) + 1
+ if i & 1:
+ value = "%#8.8x" % (i_val | i_val << 16)
+ else:
+ value = "%#8.8x" % (i_val | i_val << 8)
+ self.check_register_string_value(fpr, "s%i" % (i), value,
+ lldb.eFormatHex)
+ # Check q0 - q15
+ for i in range(15):
+ a = i * 2 + 1
+ b = a + 1
+ value = ("0x00%2.2x00%2.2x0000%2.2x%2.2x"
+ "00%2.2x00%2.2x0000%2.2x%2.2x") % (b, b, b, b, a, a, a, a)
+ self.check_register_string_value(fpr, "q%i" % (i), value,
+ lldb.eFormatHex)
+
+ def test_linux_arm_registers(self):
+ """Test Linux ARM registers from a breakpad created minidump.
+
+ The frame pointer is R11 for linux.
+ """
+ self.verify_arm_registers(apple=False)
+
+ def test_apple_arm_registers(self):
+ """Test Apple ARM registers from a breakpad created minidump.
+
+ The frame pointer is R7 for linux.
+ """
+ self.verify_arm_registers(apple=True)
+
+ def do_test_deeper_stack(self, binary, core, pid):
+ target = self.dbg.CreateTarget(binary)
+ process = target.LoadCore(core)
+ thread = process.GetThreadAtIndex(0)
+
+ self.assertEqual(process.GetProcessID(), pid)
+
+ expected_stack = {1: 'bar', 2: 'foo', 3: '_start'}
+ self.assertGreaterEqual(thread.GetNumFrames(), len(expected_stack))
+ for index, name in iteritems(expected_stack):
+ frame = thread.GetFrameAtIndex(index)
+ self.assertTrue(frame.IsValid())
+ function_name = frame.GetFunctionName()
+ self.assertTrue(name in function_name)
+
+ @skipIfLLVMTargetMissing("X86")
+ def test_deeper_stack_in_minidump(self):
+ """Test that we can examine a more interesting stack in a Minidump."""
+ # Launch with the Minidump, and inspect the stack.
+ # target create linux-x86_64_not_crashed -c linux-x86_64_not_crashed.dmp
+ self.do_test_deeper_stack("linux-x86_64_not_crashed",
+ "linux-x86_64_not_crashed.dmp",
+ self._linux_x86_64_not_crashed_pid)
+
+ def do_change_pid_in_minidump(self, core, newcore, offset, oldpid, newpid):
+ """ This assumes that the minidump is breakpad generated on Linux -
+ meaning that the PID in the file will be an ascii string part of
+ /proc/PID/status which is written in the file
+ """
+ shutil.copyfile(core, newcore)
+ with open(newcore, "rb+") as f:
+ f.seek(offset)
+ currentpid = f.read(5).decode('utf-8')
+ self.assertEqual(currentpid, oldpid)
+
+ f.seek(offset)
+ if len(newpid) < len(oldpid):
+ newpid += " " * (len(oldpid) - len(newpid))
+ newpid += "\n"
+ f.write(newpid.encode('utf-8'))
+
+ def test_deeper_stack_in_minidump_with_same_pid_running(self):
+ """Test that we read the information from the core correctly even if we
+ have a running process with the same PID"""
+ new_core = self.getBuildArtifact("linux-x86_64_not_crashed-pid.dmp")
+ self.do_change_pid_in_minidump("linux-x86_64_not_crashed.dmp",
+ new_core,
+ self._linux_x86_64_not_crashed_pid_offset,
+ str(self._linux_x86_64_not_crashed_pid),
+ str(os.getpid()))
+ self.do_test_deeper_stack("linux-x86_64_not_crashed", new_core, os.getpid())
+
+ def test_two_cores_same_pid(self):
+ """Test that we handle the situation if we have two core files with the same PID """
+ new_core = self.getBuildArtifact("linux-x86_64_not_crashed-pid.dmp")
+ self.do_change_pid_in_minidump("linux-x86_64_not_crashed.dmp",
+ new_core,
+ self._linux_x86_64_not_crashed_pid_offset,
+ str(self._linux_x86_64_not_crashed_pid),
+ str(self._linux_x86_64_pid))
+ self.do_test_deeper_stack("linux-x86_64_not_crashed",
+ new_core, self._linux_x86_64_pid)
+ self.test_stack_info_in_minidump()
+
+ def test_local_variables_in_minidump(self):
+ """Test that we can examine local variables in a Minidump."""
+ # Launch with the Minidump, and inspect a local variable.
+ # target create linux-x86_64_not_crashed -c linux-x86_64_not_crashed.dmp
+ self.target = self.dbg.CreateTarget("linux-x86_64_not_crashed")
+ self.process = self.target.LoadCore("linux-x86_64_not_crashed.dmp")
+ self.check_state()
+ thread = self.process.GetThreadAtIndex(0)
+ frame = thread.GetFrameAtIndex(1)
+ value = frame.EvaluateExpression('x')
+ self.assertEqual(value.GetValueAsSigned(), 3)
+
+ def test_memory_regions_in_minidump(self):
+ """Test memory regions from a Minidump"""
+ self.process_from_yaml("regions-linux-map.yaml")
+ self.check_state()
+
+ regions_count = 19
+ region_info_list = self.process.GetMemoryRegions()
+ self.assertEqual(region_info_list.GetSize(), regions_count)
+
+ def check_region(index, start, end, read, write, execute, mapped, name):
+ region_info = lldb.SBMemoryRegionInfo()
+ self.assertTrue(
+ self.process.GetMemoryRegionInfo(start, region_info).Success())
+ self.assertEqual(start, region_info.GetRegionBase())
+ self.assertEqual(end, region_info.GetRegionEnd())
+ self.assertEqual(read, region_info.IsReadable())
+ self.assertEqual(write, region_info.IsWritable())
+ self.assertEqual(execute, region_info.IsExecutable())
+ self.assertEqual(mapped, region_info.IsMapped())
+ self.assertEqual(name, region_info.GetName())
+
+ # Ensure we have the same regions as SBMemoryRegionInfoList contains.
+ if index >= 0 and index < regions_count:
+ region_info_from_list = lldb.SBMemoryRegionInfo()
+ self.assertTrue(region_info_list.GetMemoryRegionAtIndex(
+ index, region_info_from_list))
+ self.assertEqual(region_info_from_list, region_info)
+
+ a = "/system/bin/app_process"
+ b = "/system/bin/linker"
+ c = "/system/lib/liblog.so"
+ d = "/system/lib/libc.so"
+ n = None
+ max_int = 0xffffffffffffffff
+
+ # Test address before the first entry comes back with nothing mapped up
+ # to first valid region info
+ check_region(-1, 0x00000000, 0x400d9000, False, False, False, False, n)
+ check_region( 0, 0x400d9000, 0x400db000, True, False, True, True, a)
+ check_region( 1, 0x400db000, 0x400dc000, True, False, False, True, a)
+ check_region( 2, 0x400dc000, 0x400dd000, True, True, False, True, n)
+ check_region( 3, 0x400dd000, 0x400ec000, True, False, True, True, b)
+ check_region( 4, 0x400ec000, 0x400ed000, True, False, False, True, n)
+ check_region( 5, 0x400ed000, 0x400ee000, True, False, False, True, b)
+ check_region( 6, 0x400ee000, 0x400ef000, True, True, False, True, b)
+ check_region( 7, 0x400ef000, 0x400fb000, True, True, False, True, n)
+ check_region( 8, 0x400fb000, 0x400fc000, True, False, True, True, c)
+ check_region( 9, 0x400fc000, 0x400fd000, True, True, True, True, c)
+ check_region(10, 0x400fd000, 0x400ff000, True, False, True, True, c)
+ check_region(11, 0x400ff000, 0x40100000, True, False, False, True, c)
+ check_region(12, 0x40100000, 0x40101000, True, True, False, True, c)
+ check_region(13, 0x40101000, 0x40122000, True, False, True, True, d)
+ check_region(14, 0x40122000, 0x40123000, True, True, True, True, d)
+ check_region(15, 0x40123000, 0x40167000, True, False, True, True, d)
+ check_region(16, 0x40167000, 0x40169000, True, False, False, True, d)
+ check_region(17, 0x40169000, 0x4016b000, True, True, False, True, d)
+ check_region(18, 0x4016b000, 0x40176000, True, True, False, True, n)
+ check_region(-1, 0x40176000, max_int, False, False, False, False, n)
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpUUID.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpUUID.py
new file mode 100644
index 00000000000..ca0ad5f67b2
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpUUID.py
@@ -0,0 +1,195 @@
+"""
+Test basics of Minidump debugging.
+"""
+
+from six import iteritems
+
+
+import lldb
+import os
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class MiniDumpUUIDTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ NO_DEBUG_INFO_TESTCASE = True
+
+ def setUp(self):
+ super(MiniDumpUUIDTestCase, self).setUp()
+ self._initial_platform = lldb.DBG.GetSelectedPlatform()
+
+ def tearDown(self):
+ lldb.DBG.SetSelectedPlatform(self._initial_platform)
+ super(MiniDumpUUIDTestCase, self).tearDown()
+
+ def verify_module(self, module, verify_path, verify_uuid):
+ uuid = module.GetUUIDString()
+ self.assertEqual(verify_path, module.GetFileSpec().fullpath)
+ self.assertEqual(verify_uuid, uuid)
+
+ def get_minidump_modules(self, yaml_file):
+ minidump_path = self.getBuildArtifact(os.path.basename(yaml_file) + ".dmp")
+ self.yaml2obj(yaml_file, minidump_path)
+ self.target = self.dbg.CreateTarget(None)
+ self.process = self.target.LoadCore(minidump_path)
+ return self.target.modules
+
+ def test_zero_uuid_modules(self):
+ """
+ Test multiple modules having a MINIDUMP_MODULE.CvRecord that is valid,
+ but contains a PDB70 value whose age is zero and whose UUID values are
+ all zero. Prior to a fix all such modules would be duplicated to the
+ first one since the UUIDs claimed to be valid and all zeroes. Now we
+ ensure that the UUID is not valid for each module and that we have
+ each of the modules in the target after loading the core
+ """
+ modules = self.get_minidump_modules("linux-arm-zero-uuids.yaml")
+ self.assertEqual(2, len(modules))
+ self.verify_module(modules[0], "/file/does/not/exist/a", None)
+ self.verify_module(modules[1], "/file/does/not/exist/b", None)
+
+ def test_uuid_modules_no_age(self):
+ """
+ Test multiple modules having a MINIDUMP_MODULE.CvRecord that is valid,
+ and contains a PDB70 value whose age is zero and whose UUID values are
+ valid. Ensure we decode the UUID and don't include the age field in the UUID.
+ """
+ modules = self.get_minidump_modules("linux-arm-uuids-no-age.yaml")
+ modules = self.target.modules
+ self.assertEqual(2, len(modules))
+ self.verify_module(modules[0], "/tmp/a", "01020304-0506-0708-090A-0B0C0D0E0F10")
+ self.verify_module(modules[1], "/tmp/b", "0A141E28-323C-4650-5A64-6E78828C96A0")
+
+ def test_uuid_modules_no_age_apple(self):
+ """
+ Test multiple modules having a MINIDUMP_MODULE.CvRecord that is valid,
+ and contains a PDB70 value whose age is zero and whose UUID values are
+ valid. Ensure we decode the UUID and don't include the age field in the UUID.
+ Also ensure that the first uint32_t is byte swapped, along with the next
+ two uint16_t values. Breakpad incorrectly byte swaps these values when it
+ saves Darwin minidump files.
+ """
+ modules = self.get_minidump_modules("macos-arm-uuids-no-age.yaml")
+ modules = self.target.modules
+ self.assertEqual(2, len(modules))
+ self.verify_module(modules[0], "/tmp/a", "04030201-0605-0807-090A-0B0C0D0E0F10")
+ self.verify_module(modules[1], "/tmp/b", "281E140A-3C32-5046-5A64-6E78828C96A0")
+
+ def test_uuid_modules_with_age(self):
+ """
+ Test multiple modules having a MINIDUMP_MODULE.CvRecord that is valid,
+ and contains a PDB70 value whose age is valid and whose UUID values are
+ valid. Ensure we decode the UUID and include the age field in the UUID.
+ """
+ modules = self.get_minidump_modules("linux-arm-uuids-with-age.yaml")
+ self.assertEqual(2, len(modules))
+ self.verify_module(modules[0], "/tmp/a", "01020304-0506-0708-090A-0B0C0D0E0F10-10101010")
+ self.verify_module(modules[1], "/tmp/b", "0A141E28-323C-4650-5A64-6E78828C96A0-20202020")
+
+ def test_uuid_modules_elf_build_id_16(self):
+ """
+ Test multiple modules having a MINIDUMP_MODULE.CvRecord that is valid,
+ and contains a ELF build ID whose value is valid and is 16 bytes long.
+ """
+ modules = self.get_minidump_modules("linux-arm-uuids-elf-build-id-16.yaml")
+ self.assertEqual(2, len(modules))
+ self.verify_module(modules[0], "/tmp/a", "01020304-0506-0708-090A-0B0C0D0E0F10")
+ self.verify_module(modules[1], "/tmp/b", "0A141E28-323C-4650-5A64-6E78828C96A0")
+
+ def test_uuid_modules_elf_build_id_20(self):
+ """
+ Test multiple modules having a MINIDUMP_MODULE.CvRecord that is valid,
+ and contains a ELF build ID whose value is valid and is 20 bytes long.
+ """
+ modules = self.get_minidump_modules("linux-arm-uuids-elf-build-id-20.yaml")
+ self.assertEqual(2, len(modules))
+ self.verify_module(modules[0], "/tmp/a", "01020304-0506-0708-090A-0B0C0D0E0F10-11121314")
+ self.verify_module(modules[1], "/tmp/b", "0A141E28-323C-4650-5A64-6E78828C96A0-AAB4BEC8")
+
+ def test_uuid_modules_elf_build_id_zero(self):
+ """
+ Test multiple modules having a MINIDUMP_MODULE.CvRecord that is valid,
+ and contains a ELF build ID whose value is all zero.
+ """
+ modules = self.get_minidump_modules("linux-arm-uuids-elf-build-id-zero.yaml")
+ self.assertEqual(2, len(modules))
+ self.verify_module(modules[0], "/not/exist/a", None)
+ self.verify_module(modules[1], "/not/exist/b", None)
+
+ def test_uuid_modules_elf_build_id_same(self):
+ """
+ Test multiple modules having a MINIDUMP_MODULE.CvRecord that is
+ valid, and contains a ELF build ID whose value is the same. There
+ is an assert in the PlaceholderObjectFile that was firing when we
+ encountered this which was crashing the process that was checking
+ if PlaceholderObjectFile.m_base was the same as the address this
+ fake module was being loaded at. We need to ensure we don't crash
+ in such cases and that we add both modules even though they have
+ the same UUID.
+ """
+ modules = self.get_minidump_modules("linux-arm-same-uuids.yaml")
+ self.assertEqual(2, len(modules))
+ self.verify_module(modules[0], "/file/does/not/exist/a",
+ '11223344-1122-3344-1122-334411223344-11223344')
+ self.verify_module(modules[1], "/file/does/not/exist/b",
+ '11223344-1122-3344-1122-334411223344-11223344')
+
+ @expectedFailureAll(oslist=["windows"])
+ def test_partial_uuid_match(self):
+ """
+ Breakpad has been known to create minidump files using CvRecord in each
+ module whose signature is set to PDB70 where the UUID only contains the
+ first 16 bytes of a 20 byte ELF build ID. Code was added to
+ ProcessMinidump.cpp to deal with this and allows partial UUID matching.
+
+ This test verifies that if we have a minidump with a 16 byte UUID, that
+ we are able to associate a symbol file with a 20 byte UUID only if the
+ first 16 bytes match. In this case we will see the path from the file
+ we found in the test directory and the 20 byte UUID from the actual
+ file, not the 16 byte shortened UUID from the minidump.
+ """
+ so_path = self.getBuildArtifact("libuuidmatch.so")
+ self.yaml2obj("libuuidmatch.yaml", so_path)
+ cmd = 'settings set target.exec-search-paths "%s"' % (os.path.dirname(so_path))
+ self.dbg.HandleCommand(cmd)
+ modules = self.get_minidump_modules("linux-arm-partial-uuids-match.yaml")
+ self.assertEqual(1, len(modules))
+ self.verify_module(modules[0], so_path,
+ "7295E17C-6668-9E05-CBB5-DEE5003865D5-5267C116")
+
+ def test_partial_uuid_mismatch(self):
+ """
+ Breakpad has been known to create minidump files using CvRecord in each
+ module whose signature is set to PDB70 where the UUID only contains the
+ first 16 bytes of a 20 byte ELF build ID. Code was added to
+ ProcessMinidump.cpp to deal with this and allows partial UUID matching.
+
+ This test verifies that if we have a minidump with a 16 byte UUID, that
+ we are not able to associate a symbol file with a 20 byte UUID only if
+ any of the first 16 bytes do not match. In this case we will see the UUID
+ from the minidump file and the path from the minidump file.
+ """
+ so_path = self.getBuildArtifact("libuuidmismatch.so")
+ self.yaml2obj("libuuidmismatch.yaml", so_path)
+ cmd = 'settings set target.exec-search-paths "%s"' % (os.path.dirname(so_path))
+ self.dbg.HandleCommand(cmd)
+ modules = self.get_minidump_modules("linux-arm-partial-uuids-mismatch.yaml")
+ self.assertEqual(1, len(modules))
+ self.verify_module(modules[0],
+ "/invalid/path/on/current/system/libuuidmismatch.so",
+ "7295E17C-6668-9E05-CBB5-DEE5003865D5")
+
+ def test_relative_module_name(self):
+ old_cwd = os.getcwd()
+ self.addTearDownHook(lambda: os.chdir(old_cwd))
+ os.chdir(self.getBuildDir())
+ name = "file-with-a-name-unlikely-to-exist-in-the-current-directory.so"
+ open(name, "a").close()
+ modules = self.get_minidump_modules(
+ self.getSourcePath("relative_module_name.yaml"))
+ self.assertEqual(1, len(modules))
+ self.verify_module(modules[0], name, None)
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/arm-linux.yaml b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/arm-linux.yaml
new file mode 100644
index 00000000000..072b4de411f
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/arm-linux.yaml
@@ -0,0 +1,18 @@
+--- !minidump
+Streams:
+ - Type: SystemInfo
+ Processor Arch: ARM
+ Platform ID: Linux
+ CSD Version: ABC123
+ CPU:
+ CPUID: 0x00000000
+ - Type: MiscInfo
+ Content: 00000000010000007B000000000000000000000000000000
+ - Type: ThreadList
+ Threads:
+ - Thread Id: 0x00001000
+ Context: 060000400100000002000000030000000400000005000000060000000700000008000000090000000A0000000B0000000C0000000D0000000E0000000F0000001000000044332211DDCCBBAA887766550101000001000100020200000200020003030000030003000404000004000400050500000500050006060000060006000707000007000700080800000800080009090000090009000A0A00000A000A000B0B00000B000B000C0C00000C000C000D0D00000D000D000E0E00000E000E000F0F00000F000F0010100000100010001111000011001100121200001200120013130000130013001414000014001400151500001500150016160000160016001717000017001700181800001800180019190000190019001A1A00001A001A001B1B00001B001B001C1C00001C001C001D1D00001D001D001E1E00001E001E001F1F00001F001F0020200000200020000000000001000100020002000300030004000400050005000600060007000700
+ Stack:
+ Start of Memory Range: 0x0000000000000000
+ Content: ''
+...
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/arm-macos.yaml b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/arm-macos.yaml
new file mode 100644
index 00000000000..b194492f6f0
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/arm-macos.yaml
@@ -0,0 +1,18 @@
+--- !minidump
+Streams:
+ - Type: SystemInfo
+ Processor Arch: ARM
+ Platform ID: MacOSX
+ CSD Version: ABC123
+ CPU:
+ CPUID: 0x00000000
+ - Type: MiscInfo
+ Content: 00000000010000007B000000000000000000000000000000
+ - Type: ThreadList
+ Threads:
+ - Thread Id: 0x00001000
+ Context: 060000400100000002000000030000000400000005000000060000000700000008000000090000000A0000000B0000000C0000000D0000000E0000000F0000001000000044332211DDCCBBAA887766550101000001000100020200000200020003030000030003000404000004000400050500000500050006060000060006000707000007000700080800000800080009090000090009000A0A00000A000A000B0B00000B000B000C0C00000C000C000D0D00000D000D000E0E00000E000E000F0F00000F000F0010100000100010001111000011001100121200001200120013130000130013001414000014001400151500001500150016160000160016001717000017001700181800001800180019190000190019001A1A00001A001A001B1B00001B001B001C1C00001C001C001D1D00001D001D001E1E00001E001E001F1F00001F001F0020200000200020000000000001000100020002000300030004000400050005000600060007000700
+ Stack:
+ Start of Memory Range: 0x0000000000000000
+ Content: ''
+...
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/arm64-macos.yaml b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/arm64-macos.yaml
new file mode 100644
index 00000000000..70817f14da5
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/arm64-macos.yaml
@@ -0,0 +1,18 @@
+--- !minidump
+Streams:
+ - Type: SystemInfo
+ Processor Arch: BP_ARM64
+ Platform ID: MacOSX
+ CSD Version: '15E216'
+ CPU:
+ CPUID: 0x00000000
+ - Type: MiscInfo
+ Content: 00000000010000007B000000000000000000000000000000
+ - Type: ThreadList
+ Threads:
+ - Thread Id: 0x00001000
+ Context: 060000800000000001000000020003000200000003000400030000000400050004000000050006000500000006000700060000000700080007000000080009000800000009000A00090000000A000B000A0000000B000C000B0000000C000D000C0000000D000E000D0000000E000F000E0000000F0010000F00000010001100100000001100120011000000120013001200000013001400130000001400150014000000150016001500000016001700160000001700180017000000180019001800000019001A00190000001A001B001A0000001B001C001B0000001C001D001C0000001D001E001D0000001E001F001E0000001F0020001F00000020002100200000002100220000100000000000004433221188776655CCBBAA99000102030405060708090A0B0C0D0E0F0102030405060708090A0B0C0D0E0F1002030405060708090A0B0C0D0E0F1011030405060708090A0B0C0D0E0F1011120405060708090A0B0C0D0E0F1011121305060708090A0B0C0D0E0F1011121314060708090A0B0C0D0E0F1011121314150708090A0B0C0D0E0F1011121314151608090A0B0C0D0E0F1011121314151617090A0B0C0D0E0F1011121314151617180A0B0C0D0E0F101112131415161718190B0C0D0E0F101112131415161718191A0C0D0E0F101112131415161718191A1B0D0E0F101112131415161718191A1B1C0E0F101112131415161718191A1B1C1D0F101112131415161718191A1B1C1D1E101112131415161718191A1B1C1D1E1F1112131415161718191A1B1C1D1E1F2012131415161718191A1B1C1D1E1F2021131415161718191A1B1C1D1E1F2021221415161718191A1B1C1D1E1F2021222315161718191A1B1C1D1E1F2021222324161718191A1B1C1D1E1F2021222324251718191A1B1C1D1E1F2021222324252618191A1B1C1D1E1F2021222324252627191A1B1C1D1E1F2021222324252627281A1B1C1D1E1F202122232425262728291B1C1D1E1F202122232425262728292A1C1D1E1F202122232425262728292A2B1D1E1F202122232425262728292A2B2C1E1F202122232425262728292A2B2C2D1F202122232425262728292A2B2C2D2E
+ Stack:
+ Start of Memory Range: 0x0000000000000000
+ Content: ''
+...
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/install_breakpad.cpp b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/install_breakpad.cpp
new file mode 100644
index 00000000000..c34ac17128f
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/install_breakpad.cpp
@@ -0,0 +1,16 @@
+#include "client/linux/handler/exception_handler.h"
+
+static bool dumpCallback(const google_breakpad::MinidumpDescriptor &descriptor,
+ void *context, bool succeeded) {
+ return succeeded;
+}
+
+google_breakpad::ExceptionHandler *eh;
+
+void InstallBreakpad() {
+ google_breakpad::MinidumpDescriptor descriptor("/tmp");
+ eh = new google_breakpad::ExceptionHandler(descriptor, NULL, dumpCallback,
+ NULL, true, -1);
+}
+
+void WriteMinidump() { eh->WriteMinidump(); }
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/libuuidmatch.yaml b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/libuuidmatch.yaml
new file mode 100644
index 00000000000..3610694d4db
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/libuuidmatch.yaml
@@ -0,0 +1,14 @@
+--- !ELF
+FileHeader:
+ Class: ELFCLASS32
+ Data: ELFDATA2LSB
+ Type: ET_DYN
+ Machine: EM_ARM
+ Flags: [ EF_ARM_SOFT_FLOAT, EF_ARM_EABI_VER5 ]
+Sections:
+ - Name: .note.gnu.build-id
+ Type: SHT_NOTE
+ Flags: [ SHF_ALLOC ]
+ Address: 0x0000000000000114
+ AddressAlign: 0x0000000000000004
+ Content: 040000001400000003000000474E55007295E17C66689E05CBB5DEE5003865D55267C116
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/libuuidmismatch.yaml b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/libuuidmismatch.yaml
new file mode 100644
index 00000000000..5fef636228e
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/libuuidmismatch.yaml
@@ -0,0 +1,14 @@
+--- !ELF
+FileHeader:
+ Class: ELFCLASS32
+ Data: ELFDATA2LSB
+ Type: ET_DYN
+ Machine: EM_ARM
+ Flags: [ EF_ARM_SOFT_FLOAT, EF_ARM_EABI_VER5 ]
+Sections:
+ - Name: .note.gnu.build-id
+ Type: SHT_NOTE
+ Flags: [ SHF_ALLOC ]
+ Address: 0x0000000000000114
+ AddressAlign: 0x0000000000000004
+ Content: 040000001400000003000000474E55008295E17C66689E05CBB5DEE5003865D55267C116
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-arm-partial-uuids-match.yaml b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-arm-partial-uuids-match.yaml
new file mode 100644
index 00000000000..edb0001ff27
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-arm-partial-uuids-match.yaml
@@ -0,0 +1,15 @@
+--- !minidump
+Streams:
+ - Type: SystemInfo
+ Processor Arch: ARM
+ Platform ID: Linux
+ CSD Version: '15E216'
+ CPU:
+ CPUID: 0x00000000
+ - Type: ModuleList
+ Modules:
+ - Base of Image: 0x0000000000001000
+ Size of Image: 0x00001000
+ Module Name: '/invalid/path/on/current/system/libuuidmatch.so'
+ CodeView Record: 525344537295E17C66689E05CBB5DEE5003865D50000000000
+...
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-arm-partial-uuids-mismatch.yaml b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-arm-partial-uuids-mismatch.yaml
new file mode 100644
index 00000000000..0b56a967bf6
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-arm-partial-uuids-mismatch.yaml
@@ -0,0 +1,15 @@
+--- !minidump
+Streams:
+ - Type: SystemInfo
+ Processor Arch: ARM
+ Platform ID: Linux
+ CSD Version: '15E216'
+ CPU:
+ CPUID: 0x00000000
+ - Type: ModuleList
+ Modules:
+ - Base of Image: 0x0000000000001000
+ Size of Image: 0x00001000
+ Module Name: '/invalid/path/on/current/system/libuuidmismatch.so'
+ CodeView Record: 525344537295E17C66689E05CBB5DEE5003865D50000000000
+...
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-arm-same-uuids.yaml b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-arm-same-uuids.yaml
new file mode 100644
index 00000000000..21c5220e415
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-arm-same-uuids.yaml
@@ -0,0 +1,21 @@
+--- !minidump
+Streams:
+ - Type: SystemInfo
+ Processor Arch: AMD64
+ Platform ID: Linux
+ CSD Version: '15E216'
+ CPU:
+ Vendor ID: GenuineIntel
+ Version Info: 0x00000000
+ Feature Info: 0x00000000
+ - Type: ModuleList
+ Modules:
+ - Base of Image: 0x0000000000001000
+ Size of Image: 0x00001000
+ Module Name: '/file/does/not/exist/a'
+ CodeView Record: '52534453112233441122334411223344112233441122334411'
+ - Base of Image: 0x0000000000003000
+ Size of Image: 0x00001000
+ Module Name: '/file/does/not/exist/b'
+ CodeView Record: '52534453112233441122334411223344112233441122334411'
+...
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-arm-uuids-elf-build-id-16.yaml b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-arm-uuids-elf-build-id-16.yaml
new file mode 100644
index 00000000000..f4c18b93334
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-arm-uuids-elf-build-id-16.yaml
@@ -0,0 +1,19 @@
+--- !minidump
+Streams:
+ - Type: SystemInfo
+ Processor Arch: ARM
+ Platform ID: Linux
+ CSD Version: '15E216'
+ CPU:
+ CPUID: 0x00000000
+ - Type: ModuleList
+ Modules:
+ - Base of Image: 0x0000000000001000
+ Size of Image: 0x00001000
+ Module Name: '/tmp/a'
+ CodeView Record: 4C4570420102030405060708090A0B0C0D0E0F10
+ - Base of Image: 0x0000000000001000
+ Size of Image: 0x00001000
+ Module Name: '/tmp/b'
+ CodeView Record: 4C4570420A141E28323C46505A646E78828C96A0
+...
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-arm-uuids-elf-build-id-20.yaml b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-arm-uuids-elf-build-id-20.yaml
new file mode 100644
index 00000000000..e3c170fc335
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-arm-uuids-elf-build-id-20.yaml
@@ -0,0 +1,19 @@
+--- !minidump
+Streams:
+ - Type: SystemInfo
+ Processor Arch: ARM
+ Platform ID: Linux
+ CSD Version: '15E216'
+ CPU:
+ CPUID: 0x00000000
+ - Type: ModuleList
+ Modules:
+ - Base of Image: 0x0000000000001000
+ Size of Image: 0x00001000
+ Module Name: '/tmp/a'
+ CodeView Record: 4C4570420102030405060708090A0B0C0D0E0F1011121314
+ - Base of Image: 0x0000000000001000
+ Size of Image: 0x00001000
+ Module Name: '/tmp/b'
+ CodeView Record: 4C4570420A141E28323C46505A646E78828C96A0AAB4BEC8
+...
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-arm-uuids-elf-build-id-zero.yaml b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-arm-uuids-elf-build-id-zero.yaml
new file mode 100644
index 00000000000..5bde77efaa7
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-arm-uuids-elf-build-id-zero.yaml
@@ -0,0 +1,19 @@
+--- !minidump
+Streams:
+ - Type: SystemInfo
+ Processor Arch: ARM
+ Platform ID: Linux
+ CSD Version: '15E216'
+ CPU:
+ CPUID: 0x00000000
+ - Type: ModuleList
+ Modules:
+ - Base of Image: 0x0000000000001000
+ Size of Image: 0x00001000
+ Module Name: '/not/exist/a'
+ CodeView Record: 4C45704200000000000000000000000000000000
+ - Base of Image: 0x0000000000001000
+ Size of Image: 0x00001000
+ Module Name: '/not/exist/b'
+ CodeView Record: 4C45704200000000000000000000000000000000
+...
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-arm-uuids-no-age.yaml b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-arm-uuids-no-age.yaml
new file mode 100644
index 00000000000..7b80fd51abd
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-arm-uuids-no-age.yaml
@@ -0,0 +1,19 @@
+--- !minidump
+Streams:
+ - Type: SystemInfo
+ Processor Arch: ARM
+ Platform ID: Linux
+ CSD Version: '15E216'
+ CPU:
+ CPUID: 0x00000000
+ - Type: ModuleList
+ Modules:
+ - Base of Image: 0x0000000000001000
+ Size of Image: 0x00001000
+ Module Name: '/tmp/a'
+ CodeView Record: 525344530102030405060708090A0B0C0D0E0F100000000000
+ - Base of Image: 0x0000000000001000
+ Size of Image: 0x00001000
+ Module Name: '/tmp/b'
+ CodeView Record: 525344530A141E28323C46505A646E78828C96A00000000000
+...
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-arm-uuids-with-age.yaml b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-arm-uuids-with-age.yaml
new file mode 100644
index 00000000000..083b313254e
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-arm-uuids-with-age.yaml
@@ -0,0 +1,19 @@
+--- !minidump
+Streams:
+ - Type: SystemInfo
+ Processor Arch: ARM
+ Platform ID: Linux
+ CSD Version: '15E216'
+ CPU:
+ CPUID: 0x00000000
+ - Type: ModuleList
+ Modules:
+ - Base of Image: 0x0000000000001000
+ Size of Image: 0x00001000
+ Module Name: '/tmp/a'
+ CodeView Record: 525344530102030405060708090A0B0C0D0E0F101010101000
+ - Base of Image: 0x0000000000001000
+ Size of Image: 0x00001000
+ Module Name: '/tmp/b'
+ CodeView Record: 525344530A141E28323C46505A646E78828C96A02020202000
+...
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-arm-zero-uuids.yaml b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-arm-zero-uuids.yaml
new file mode 100644
index 00000000000..7ca887cdf2c
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-arm-zero-uuids.yaml
@@ -0,0 +1,21 @@
+--- !minidump
+Streams:
+ - Type: SystemInfo
+ Processor Arch: AMD64
+ Platform ID: Linux
+ CSD Version: '15E216'
+ CPU:
+ Vendor ID: GenuineIntel
+ Version Info: 0x00000000
+ Feature Info: 0x00000000
+ - Type: ModuleList
+ Modules:
+ - Base of Image: 0x0000000000001000
+ Size of Image: 0x00001000
+ Module Name: '/file/does/not/exist/a'
+ CodeView Record: '52534453000000000000000000000000000000000000000000'
+ - Base of Image: 0x0000000000001000
+ Size of Image: 0x00001000
+ Module Name: '/file/does/not/exist/b'
+ CodeView Record: '52534453000000000000000000000000000000000000000000'
+...
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64 b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64
new file mode 100755
index 00000000000..078d9c8fa90
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64
Binary files differ
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64.cpp b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64.cpp
new file mode 100644
index 00000000000..61d31492940
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64.cpp
@@ -0,0 +1,12 @@
+void crash() {
+ volatile int *a = (int *)(nullptr);
+ *a = 1;
+}
+
+extern "C" void _start();
+void InstallBreakpad();
+
+void _start() {
+ InstallBreakpad();
+ crash();
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64.dmp b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64.dmp
new file mode 100644
index 00000000000..e2ae724abe9
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64.dmp
Binary files differ
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64.yaml b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64.yaml
new file mode 100644
index 00000000000..21ea3ba5dea
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64.yaml
@@ -0,0 +1,44 @@
+--- !minidump
+Streams:
+ - Type: ThreadList
+ Threads:
+ - Thread Id: 0x000074DD
+ Context: 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000B0010000000000033000000000000000000000002020100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040109600000000000100000000000000000000000000000068E7D0C8FF7F000068E7D0C8FF7F000097E6D0C8FF7F000010109600000000000000000000000000020000000000000088E4D0C8FF7F0000603FFF85C77F0000F00340000000000080E7D0C8FF7F000000000000000000000000000000000000E0034000000000007F0300000000000000000000000000000000000000000000801F0000FFFF00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF252525252525252525252525252525250000000000000000000000000000000000000000000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000FF00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+ Stack:
+ Start of Memory Range: 0x00007FFFC8D0E000
+ Content: DEADBEEFBAADF00D
+ - Type: ModuleList
+ Modules:
+ - Base of Image: 0x0000000000400000
+ Size of Image: 0x00001000
+ Module Name: '/tmp/test/linux-x86_64'
+ CodeView Record: 4C457042E35C283BC327C28762DB788BF5A4078BE2351448
+ - Type: Exception
+ Thread ID: 0x000074DD
+ Exception Record:
+ Exception Code: 0x0000000B
+ Thread Context: 00000000
+ - Type: SystemInfo
+ Processor Arch: AMD64
+ Processor Level: 6
+ Processor Revision: 15876
+ Number of Processors: 40
+ Platform ID: Linux
+ CSD Version: 'Linux 3.13.0-91-generic'
+ CPU:
+ Vendor ID: GenuineIntel
+ Version Info: 0x00000000
+ Feature Info: 0x00000000
+ - Type: LinuxProcStatus
+ Text: |
+ Name: linux-x86_64
+ State: t (tracing stop)
+ Tgid: 29917
+ Ngid: 0
+ Pid: 29917
+ PPid: 29370
+ TracerPid: 29918
+ Uid: 1001 1001 1001 1001
+ Gid: 1001 1001 1001 1001
+
+...
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64_not_crashed b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64_not_crashed
new file mode 100755
index 00000000000..8b38cdb48bd
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64_not_crashed
Binary files differ
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64_not_crashed.cpp b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64_not_crashed.cpp
new file mode 100644
index 00000000000..070c565e72b
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64_not_crashed.cpp
@@ -0,0 +1,22 @@
+void InstallBreakpad();
+void WriteMinidump();
+
+int global = 42;
+
+int bar(int x) {
+ WriteMinidump();
+ int y = 4 * x + global;
+ return y;
+}
+
+int foo(int x) {
+ int y = 2 * bar(3 * x);
+ return y;
+}
+
+extern "C" void _start();
+
+void _start() {
+ InstallBreakpad();
+ foo(1);
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64_not_crashed.dmp b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64_not_crashed.dmp
new file mode 100644
index 00000000000..ad4b61a7bbb
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64_not_crashed.dmp
Binary files differ
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64_null_signal.yaml b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64_null_signal.yaml
new file mode 100644
index 00000000000..93b3fd0e8aa
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64_null_signal.yaml
@@ -0,0 +1,25 @@
+--- !minidump
+Streams:
+ - Type: ThreadList
+ Threads:
+ - Thread Id: 0x00002177
+ Context: 0000
+ Stack:
+ Start of Memory Range: 0x00007FFE2F689000
+ Content: 00000000
+ - Type: Exception
+ Thread ID: 0x00002177
+ Exception Record:
+ Exception Code: 0x00000000
+ Exception Address: 0x0000000000400582
+ Thread Context: 0000
+ - Type: SystemInfo
+ Processor Arch: AMD64
+ Platform ID: Linux
+ - Type: LinuxProcStatus
+ Text: |
+ Name: busyloop
+ Umask: 0002
+ State: t (tracing stop)
+ Pid: 8567
+...
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/macos-arm-uuids-no-age.yaml b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/macos-arm-uuids-no-age.yaml
new file mode 100644
index 00000000000..57e291ee1b1
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/macos-arm-uuids-no-age.yaml
@@ -0,0 +1,21 @@
+--- !minidump
+Streams:
+ - Type: SystemInfo
+ Processor Arch: AMD64
+ Platform ID: MacOSX
+ CSD Version: '15E216'
+ CPU:
+ Vendor ID: GenuineIntel
+ Version Info: 0x00000000
+ Feature Info: 0x00000000
+ - Type: ModuleList
+ Modules:
+ - Base of Image: 0x0000000000001000
+ Size of Image: 0x00001000
+ Module Name: '/tmp/a'
+ CodeView Record: 525344530102030405060708090A0B0C0D0E0F100000000000
+ - Base of Image: 0x0000000000001000
+ Size of Image: 0x00001000
+ Module Name: '/tmp/b'
+ CodeView Record: 525344530A141E28323C46505A646E78828C96A00000000000
+...
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/makefile.txt b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/makefile.txt
new file mode 100644
index 00000000000..79a95d61d85
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/makefile.txt
@@ -0,0 +1,29 @@
+# This makefile aims to make the binaries as small as possible, for us not to
+# upload huge binary blobs in the repo.
+# The binary should have debug symbols because stack unwinding doesn't work
+# correctly using the information in the Minidump only. Also we want to evaluate
+# local variables, etc.
+# Breakpad compiles as a static library, so statically linking againts it
+# makes the binary huge.
+# Dynamically linking to it does improve things, but we are still #include-ing
+# breakpad headers (which is a lot of source code for which we generate debug
+# symbols)
+# So, install_breakpad.cpp does the #include-ing and defines a global function
+# "InstallBreakpad" that does all the exception handler registration.
+# We compile install_breakpad to object file and then link it, alongside the
+# static libbreakpad, into a shared library.
+# Then the binaries dynamically link to that lib.
+# The other optimisation is not using the standard library (hence the _start
+# instead of main). We only link dynamically to some standard libraries.
+# This way we have a tiny binary (~8K) that has debug symbols and uses breakpad
+# to generate a Minidump when the binary crashes/requests such.
+#
+CC=g++
+FLAGS=-g --std=c++11
+INCLUDE=-I$HOME/breakpad/src/src/
+LINK=-L. -lbreakpad -lpthread -nostdlib -lc -lstdc++ -lgcc_s -fno-exceptions
+all:
+ $(CC) $(FLAGS) -fPIC -c install_breakpad.cpp $(INCLUDE) -o install_breakpad.o
+ ld -shared install_breakpad.o libbreakpad_client.a -o libbreakpad.so
+ $(CC) $(FLAGS) -o linux-x86_64 linux-x86_64.cpp $(LINK)
+ $(CC) $(FLAGS) -o linux-x86_64_not_crashed linux-x86_64_not_crashed.cpp $(LINK)
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/regions-linux-map.yaml b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/regions-linux-map.yaml
new file mode 100644
index 00000000000..3c0961eba07
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/regions-linux-map.yaml
@@ -0,0 +1,33 @@
+--- !minidump
+Streams:
+ - Type: SystemInfo
+ Processor Arch: ARM64
+ Platform ID: Linux
+ CSD Version: '15E216'
+ CPU:
+ CPUID: 0x00000000
+ - Type: MiscInfo
+ Content: 00000000010000007B000000000000000000000000000000
+ - Type: LinuxMaps
+ Text: |
+ 400d9000-400db000 r-xp 00000000 b3:04 227 /system/bin/app_process
+ 400db000-400dc000 r--p 00001000 b3:04 227 /system/bin/app_process
+ 400dc000-400dd000 rw-p 00000000 00:00 0
+ 400dd000-400ec000 r-xp 00000000 b3:04 300 /system/bin/linker
+ 400ec000-400ed000 r--p 00000000 00:00 0
+ 400ed000-400ee000 r--p 0000f000 b3:04 300 /system/bin/linker
+ 400ee000-400ef000 rw-p 00010000 b3:04 300 /system/bin/linker
+ 400ef000-400fb000 rw-p 00000000 00:00 0
+ 400fb000-400fc000 r-xp 00000000 b3:04 1096 /system/lib/liblog.so
+ 400fc000-400fd000 rwxp 00001000 b3:04 1096 /system/lib/liblog.so
+ 400fd000-400ff000 r-xp 00002000 b3:04 1096 /system/lib/liblog.so
+ 400ff000-40100000 r--p 00003000 b3:04 1096 /system/lib/liblog.so
+ 40100000-40101000 rw-p 00004000 b3:04 1096 /system/lib/liblog.so
+ 40101000-40122000 r-xp 00000000 b3:04 955 /system/lib/libc.so
+ 40122000-40123000 rwxp 00021000 b3:04 955 /system/lib/libc.so
+ 40123000-40167000 r-xp 00022000 b3:04 955 /system/lib/libc.so
+ 40167000-40169000 r--p 00065000 b3:04 955 /system/lib/libc.so
+ 40169000-4016b000 rw-p 00067000 b3:04 955 /system/lib/libc.so
+ 4016b000-40176000 rw-p 00000000 00:00 0
+
+...
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/relative_module_name.yaml b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/relative_module_name.yaml
new file mode 100644
index 00000000000..23f2b490280
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/relative_module_name.yaml
@@ -0,0 +1,17 @@
+--- !minidump
+Streams:
+ - Type: SystemInfo
+ Processor Arch: AMD64
+ Platform ID: Linux
+ CSD Version: '15E216'
+ CPU:
+ Vendor ID: GenuineIntel
+ Version Info: 0x00000000
+ Feature Info: 0x00000000
+ - Type: ModuleList
+ Modules:
+ - Base of Image: 0x0000000000001000
+ Size of Image: 0x00001000
+ Module Name: 'file-with-a-name-unlikely-to-exist-in-the-current-directory.so'
+ CodeView Record: ''
+...
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump/Makefile b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump/Makefile
new file mode 100644
index 00000000000..65e9dd2fa9e
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump/Makefile
@@ -0,0 +1,4 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules
+
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump/TestMiniDump.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump/TestMiniDump.py
new file mode 100644
index 00000000000..c3301fb323c
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump/TestMiniDump.py
@@ -0,0 +1,176 @@
+"""
+Test basics of mini dump debugging.
+"""
+
+from six import iteritems
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class MiniDumpTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+ NO_DEBUG_INFO_TESTCASE = True
+
+ def test_process_info_in_mini_dump(self):
+ """Test that lldb can read the process information from the minidump."""
+ # target create -c fizzbuzz_no_heap.dmp
+ self.dbg.CreateTarget("")
+ self.target = self.dbg.GetSelectedTarget()
+ self.process = self.target.LoadCore("fizzbuzz_no_heap.dmp")
+ self.assertTrue(self.process, PROCESS_IS_VALID)
+ self.assertEqual(self.process.GetNumThreads(), 1)
+ self.assertEqual(self.process.GetProcessID(), 4440)
+
+ def test_thread_info_in_mini_dump(self):
+ """Test that lldb can read the thread information from the minidump."""
+ # target create -c fizzbuzz_no_heap.dmp
+ self.dbg.CreateTarget("")
+ self.target = self.dbg.GetSelectedTarget()
+ self.process = self.target.LoadCore("fizzbuzz_no_heap.dmp")
+ # This process crashed due to an access violation (0xc0000005) in its
+ # one and only thread.
+ self.assertEqual(self.process.GetNumThreads(), 1)
+ thread = self.process.GetThreadAtIndex(0)
+ self.assertEqual(thread.GetStopReason(), lldb.eStopReasonException)
+ stop_description = thread.GetStopDescription(256)
+ self.assertTrue("0xc0000005" in stop_description)
+
+ def test_modules_in_mini_dump(self):
+ """Test that lldb can read the list of modules from the minidump."""
+ # target create -c fizzbuzz_no_heap.dmp
+ self.dbg.CreateTarget("")
+ self.target = self.dbg.GetSelectedTarget()
+ self.process = self.target.LoadCore("fizzbuzz_no_heap.dmp")
+ self.assertTrue(self.process, PROCESS_IS_VALID)
+ expected_modules = [
+ {
+ 'filename' : r"C:\Users\amccarth\Documents\Visual Studio 2013\Projects\fizzbuzz\Debug/fizzbuzz.exe",
+ 'uuid' : '0F45B791-9A96-46F9-BF8F-2D6076EA421A-00000011',
+ },
+ {
+ 'filename' : r"C:\Windows\SysWOW64/ntdll.dll",
+ 'uuid' : 'BBB0846A-402C-4052-A16B-67650BBFE6B0-00000002',
+ },
+ {
+ 'filename' : r"C:\Windows\SysWOW64/kernel32.dll",
+ 'uuid' : 'E5CB7E1B-005E-4113-AB98-98D6913B52D8-00000002',
+ },
+ {
+ 'filename' : r"C:\Windows\SysWOW64/KERNELBASE.dll",
+ 'uuid' : '0BF95241-CB0D-4BD4-AC5D-186A6452E522-00000001',
+ },
+ {
+ 'filename' : r"C:\Windows\System32/MSVCP120D.dll",
+ 'uuid' : '3C05516E-57E7-40EB-8D3F-9722C5BD80DD-00000001',
+ },
+ {
+ 'filename' : r"C:\Windows\System32/MSVCR120D.dll",
+ 'uuid' : '6382FB86-46C4-4046-AE42-8D97B3F91FF2-00000001',
+ },
+ ]
+ self.assertEqual(self.target.GetNumModules(), len(expected_modules))
+ for module, expected in zip(self.target.modules, expected_modules):
+ self.assertTrue(module.IsValid())
+ self.assertEqual(module.file.fullpath, expected['filename'])
+ self.assertEqual(module.GetUUIDString(), expected['uuid'])
+
+ def test_breakpad_uuid_matching(self):
+ """Test that the uuid computation algorithms in minidump and breakpad
+ files match."""
+ self.target = self.dbg.CreateTarget("")
+ self.process = self.target.LoadCore("fizzbuzz_no_heap.dmp")
+ self.assertTrue(self.process, PROCESS_IS_VALID)
+ self.expect("target symbols add fizzbuzz.syms", substrs=["symbol file",
+ "fizzbuzz.syms", "has been added to", "fizzbuzz.exe"]),
+ self.assertTrue(self.target.modules[0].FindSymbol("main"))
+
+ @skipIfLLVMTargetMissing("X86")
+ def test_stack_info_in_mini_dump(self):
+ """Test that we can see a trivial stack in a VS-generate mini dump."""
+ # target create -c fizzbuzz_no_heap.dmp
+ self.dbg.CreateTarget("")
+ self.target = self.dbg.GetSelectedTarget()
+ self.process = self.target.LoadCore("fizzbuzz_no_heap.dmp")
+ self.assertEqual(self.process.GetNumThreads(), 1)
+ thread = self.process.GetThreadAtIndex(0)
+
+ pc_list = [ 0x00164d14, 0x00167c79, 0x00167e6d, 0x7510336a, 0x77759882, 0x77759855]
+
+ self.assertEqual(thread.GetNumFrames(), len(pc_list))
+ for i in range(len(pc_list)):
+ frame = thread.GetFrameAtIndex(i)
+ self.assertTrue(frame.IsValid())
+ self.assertEqual(frame.GetPC(), pc_list[i])
+ self.assertTrue(frame.GetModule().IsValid())
+
+ @skipUnlessWindows # Minidump saving works only on windows
+ def test_deeper_stack_in_mini_dump(self):
+ """Test that we can examine a more interesting stack in a mini dump."""
+ self.build()
+ exe = self.getBuildArtifact("a.out")
+ core = self.getBuildArtifact("core.dmp")
+ try:
+ # Set a breakpoint and capture a mini dump.
+ target = self.dbg.CreateTarget(exe)
+ breakpoint = target.BreakpointCreateByName("bar")
+ process = target.LaunchSimple(
+ None, None, self.get_process_working_directory())
+ self.assertEqual(process.GetState(), lldb.eStateStopped)
+ self.assertTrue(process.SaveCore(core))
+ self.assertTrue(os.path.isfile(core))
+ self.assertTrue(process.Kill().Success())
+
+ # Launch with the mini dump, and inspect the stack.
+ target = self.dbg.CreateTarget(None)
+ process = target.LoadCore(core)
+ thread = process.GetThreadAtIndex(0)
+
+ expected_stack = {0: 'bar', 1: 'foo', 2: 'main'}
+ self.assertGreaterEqual(thread.GetNumFrames(), len(expected_stack))
+ for index, name in iteritems(expected_stack):
+ frame = thread.GetFrameAtIndex(index)
+ self.assertTrue(frame.IsValid())
+ function_name = frame.GetFunctionName()
+ self.assertTrue(name in function_name)
+
+ finally:
+ # Clean up the mini dump file.
+ self.assertTrue(self.dbg.DeleteTarget(target))
+ if (os.path.isfile(core)):
+ os.unlink(core)
+
+ @skipUnlessWindows # Minidump saving works only on windows
+ def test_local_variables_in_mini_dump(self):
+ """Test that we can examine local variables in a mini dump."""
+ self.build()
+ exe = self.getBuildArtifact("a.out")
+ core = self.getBuildArtifact("core.dmp")
+ try:
+ # Set a breakpoint and capture a mini dump.
+ target = self.dbg.CreateTarget(exe)
+ breakpoint = target.BreakpointCreateByName("bar")
+ process = target.LaunchSimple(
+ None, None, self.get_process_working_directory())
+ self.assertEqual(process.GetState(), lldb.eStateStopped)
+ self.assertTrue(process.SaveCore(core))
+ self.assertTrue(os.path.isfile(core))
+ self.assertTrue(process.Kill().Success())
+
+ # Launch with the mini dump, and inspect a local variable.
+ target = self.dbg.CreateTarget(None)
+ process = target.LoadCore(core)
+ thread = process.GetThreadAtIndex(0)
+ frame = thread.GetFrameAtIndex(0)
+ value = frame.EvaluateExpression('x')
+ self.assertEqual(value.GetValueAsSigned(), 3)
+
+ finally:
+ # Clean up the mini dump file.
+ self.assertTrue(self.dbg.DeleteTarget(target))
+ if (os.path.isfile(core)):
+ os.unlink(core)
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump/fizzbuzz.cpp b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump/fizzbuzz.cpp
new file mode 100644
index 00000000000..295d4a1f24d
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump/fizzbuzz.cpp
@@ -0,0 +1,31 @@
+// A sample program for getting minidumps on Windows.
+
+#include <iostream>
+
+bool
+fizz(int x)
+{
+ return x % 3 == 0;
+}
+
+bool
+buzz(int x)
+{
+ return x % 5 == 0;
+}
+
+int
+main()
+{
+ int *buggy = 0;
+
+ for (int i = 1; i <= 100; ++i)
+ {
+ if (fizz(i)) std::cout << "fizz";
+ if (buzz(i)) std::cout << "buzz";
+ if (!fizz(i) && !buzz(i)) std::cout << i;
+ std::cout << '\n';
+ }
+
+ return *buggy;
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump/fizzbuzz.syms b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump/fizzbuzz.syms
new file mode 100644
index 00000000000..cab06c1c9d5
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump/fizzbuzz.syms
@@ -0,0 +1,2 @@
+MODULE windows x86 0F45B7919A9646F9BF8F2D6076EA421A11 fizzbuzz.pdb
+PUBLIC 1000 0 main
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump/fizzbuzz_no_heap.dmp b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump/fizzbuzz_no_heap.dmp
new file mode 100644
index 00000000000..19008c91fc3
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump/fizzbuzz_no_heap.dmp
Binary files differ
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump/main.cpp b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump/main.cpp
new file mode 100644
index 00000000000..4037ea522ca
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump/main.cpp
@@ -0,0 +1,21 @@
+int global = 42;
+
+int
+bar(int x)
+{
+ int y = 4*x + global;
+ return y;
+}
+
+int
+foo(int x)
+{
+ int y = 2*bar(3*x);
+ return y;
+}
+
+int
+main()
+{
+ return 0 * foo(1);
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/netbsd-core/1lwp_SIGSEGV.aarch64 b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/netbsd-core/1lwp_SIGSEGV.aarch64
new file mode 100755
index 00000000000..de0208c756d
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/netbsd-core/1lwp_SIGSEGV.aarch64
Binary files differ
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/netbsd-core/1lwp_SIGSEGV.amd64 b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/netbsd-core/1lwp_SIGSEGV.amd64
new file mode 100755
index 00000000000..56fa077bd6a
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/netbsd-core/1lwp_SIGSEGV.amd64
Binary files differ
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/netbsd-core/1lwp_SIGSEGV.c b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/netbsd-core/1lwp_SIGSEGV.c
new file mode 100644
index 00000000000..972e9678af5
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/netbsd-core/1lwp_SIGSEGV.c
@@ -0,0 +1,14 @@
+static void bar(char *boom) {
+ char F = 'b';
+ *boom = 47; // Frame bar
+}
+
+static void foo(char *boom, void (*boomer)(char *)) {
+ char F = 'f';
+ boomer(boom); // Frame foo
+}
+
+void main(void) {
+ char F = 'm';
+ foo(0, bar); // Frame main
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/netbsd-core/2lwp_process_SIGSEGV.aarch64 b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/netbsd-core/2lwp_process_SIGSEGV.aarch64
new file mode 100755
index 00000000000..8781f033c5a
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/netbsd-core/2lwp_process_SIGSEGV.aarch64
Binary files differ
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/netbsd-core/2lwp_process_SIGSEGV.amd64 b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/netbsd-core/2lwp_process_SIGSEGV.amd64
new file mode 100755
index 00000000000..32a49852215
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/netbsd-core/2lwp_process_SIGSEGV.amd64
Binary files differ
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/netbsd-core/2lwp_process_SIGSEGV.c b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/netbsd-core/2lwp_process_SIGSEGV.c
new file mode 100644
index 00000000000..fcbfa8a6b51
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/netbsd-core/2lwp_process_SIGSEGV.c
@@ -0,0 +1,37 @@
+#include <lwp.h>
+#include <stddef.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <signal.h>
+
+volatile int sem = 0;
+
+static void bar() {
+ char F = 'b';
+ sem = 1;
+ while (1) continue; // Frame bar
+}
+
+static void foo(void (*boomer)()) {
+ char F = 'f';
+ boomer(); // Frame foo
+}
+
+static void lwp_main(void *unused) {
+ char F = 'l';
+ foo(bar); // Frame lwp_main
+}
+
+int main(int argc, char **argv) {
+ ucontext_t uc;
+ lwpid_t lid;
+ static const size_t ssize = 16 * 1024;
+ void *stack;
+
+ stack = malloc(ssize);
+ _lwp_makecontext(&uc, lwp_main, NULL, NULL, stack, ssize);
+ _lwp_create(&uc, 0, &lid);
+ while (sem != 1) continue;
+ kill(getpid(), SIGSEGV);
+ _lwp_wait(lid, NULL);
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/netbsd-core/2lwp_t2_SIGSEGV.aarch64 b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/netbsd-core/2lwp_t2_SIGSEGV.aarch64
new file mode 100755
index 00000000000..89394a7c084
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/netbsd-core/2lwp_t2_SIGSEGV.aarch64
Binary files differ
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/netbsd-core/2lwp_t2_SIGSEGV.amd64 b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/netbsd-core/2lwp_t2_SIGSEGV.amd64
new file mode 100755
index 00000000000..d304de160f0
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/netbsd-core/2lwp_t2_SIGSEGV.amd64
Binary files differ
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/netbsd-core/2lwp_t2_SIGSEGV.c b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/netbsd-core/2lwp_t2_SIGSEGV.c
new file mode 100644
index 00000000000..1cd86631edd
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/netbsd-core/2lwp_t2_SIGSEGV.c
@@ -0,0 +1,30 @@
+#include <lwp.h>
+#include <stddef.h>
+#include <stdlib.h>
+
+static void bar(char *boom) {
+ char F = 'b';
+ *boom = 47; // Frame bar
+}
+
+static void foo(char *boom, void (*boomer)(char *)) {
+ char F = 'f';
+ boomer(boom); // Frame foo
+}
+
+void lwp_main(void *unused) {
+ char F = 'l';
+ foo(0, bar); // Frame lwp_main
+}
+
+int main(int argc, char **argv) {
+ ucontext_t uc;
+ lwpid_t lid;
+ static const size_t ssize = 16 * 1024;
+ void *stack;
+
+ stack = malloc(ssize);
+ _lwp_makecontext(&uc, lwp_main, NULL, NULL, stack, ssize);
+ _lwp_create(&uc, 0, &lid);
+ _lwp_wait(lid, NULL);
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/netbsd-core/GNUmakefile b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/netbsd-core/GNUmakefile
new file mode 100644
index 00000000000..62c719d3d2f
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/netbsd-core/GNUmakefile
@@ -0,0 +1,15 @@
+ARCH = $(shell uname -m)
+PROGRAMS = 1lwp_SIGSEGV 2lwp_t2_SIGSEGV 2lwp_process_SIGSEGV
+EXECS = $(patsubst %,%.$(ARCH),$(PROGRAMS))
+CORES = $(patsubst %,%.core,$(EXECS))
+
+all: $(CORES) $(EXECS)
+clean:
+ rm -f $(CORES) $(EXECS)
+
+%.core: %
+ sysctl -w proc.$$$$.corename=$@; ulimit -s 16; ! ./$<
+%.$(ARCH): %.c
+ $(CC) -o $@ -g $<
+
+.PHONY: all clean
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/netbsd-core/TestNetBSDCore.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/netbsd-core/TestNetBSDCore.py
new file mode 100644
index 00000000000..067b04d997d
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/netbsd-core/TestNetBSDCore.py
@@ -0,0 +1,237 @@
+"""
+Test NetBSD core file debugging.
+"""
+
+from __future__ import division, print_function
+
+import signal
+import os
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class NetBSDCoreCommonTestCase(TestBase):
+ NO_DEBUG_INFO_TESTCASE = True
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ super(NetBSDCoreCommonTestCase, self).setUp()
+ self._initial_platform = lldb.DBG.GetSelectedPlatform()
+
+ def tearDown(self):
+ lldb.DBG.SetSelectedPlatform(self._initial_platform)
+ super(NetBSDCoreCommonTestCase, self).tearDown()
+
+ def check_memory_regions(self, process, region_count):
+ region_list = process.GetMemoryRegions()
+ self.assertEqual(region_list.GetSize(), region_count)
+
+ region = lldb.SBMemoryRegionInfo()
+
+ # Check we have the right number of regions.
+ self.assertEqual(region_list.GetSize(), region_count)
+
+ # Check that getting a region beyond the last in the list fails.
+ self.assertFalse(
+ region_list.GetMemoryRegionAtIndex(
+ region_count, region))
+
+ # Check each region is valid.
+ for i in range(region_list.GetSize()):
+ # Check we can actually get this region.
+ self.assertTrue(region_list.GetMemoryRegionAtIndex(i, region))
+
+ # Every region in the list should be mapped.
+ self.assertTrue(region.IsMapped())
+
+ # Test the address at the start of a region returns it's enclosing
+ # region.
+ begin_address = region.GetRegionBase()
+ region_at_begin = lldb.SBMemoryRegionInfo()
+ error = process.GetMemoryRegionInfo(begin_address, region_at_begin)
+ self.assertEqual(region, region_at_begin)
+
+ # Test an address in the middle of a region returns it's enclosing
+ # region.
+ middle_address = (region.GetRegionBase() +
+ region.GetRegionEnd()) // 2
+ region_at_middle = lldb.SBMemoryRegionInfo()
+ error = process.GetMemoryRegionInfo(
+ middle_address, region_at_middle)
+ self.assertEqual(region, region_at_middle)
+
+ # Test the address at the end of a region returns it's enclosing
+ # region.
+ end_address = region.GetRegionEnd() - 1
+ region_at_end = lldb.SBMemoryRegionInfo()
+ error = process.GetMemoryRegionInfo(end_address, region_at_end)
+ self.assertEqual(region, region_at_end)
+
+ # Check that quering the end address does not return this region but
+ # the next one.
+ next_region = lldb.SBMemoryRegionInfo()
+ error = process.GetMemoryRegionInfo(
+ region.GetRegionEnd(), next_region)
+ self.assertNotEqual(region, next_region)
+ self.assertEqual(
+ region.GetRegionEnd(),
+ next_region.GetRegionBase())
+
+ # Check that query beyond the last region returns an unmapped region
+ # that ends at LLDB_INVALID_ADDRESS
+ last_region = lldb.SBMemoryRegionInfo()
+ region_list.GetMemoryRegionAtIndex(region_count - 1, last_region)
+ end_region = lldb.SBMemoryRegionInfo()
+ error = process.GetMemoryRegionInfo(
+ last_region.GetRegionEnd(), end_region)
+ self.assertFalse(end_region.IsMapped())
+ self.assertEqual(
+ last_region.GetRegionEnd(),
+ end_region.GetRegionBase())
+ self.assertEqual(end_region.GetRegionEnd(), lldb.LLDB_INVALID_ADDRESS)
+
+ def check_state(self, process):
+ with open(os.devnull) as devnul:
+ # sanitize test output
+ self.dbg.SetOutputFileHandle(devnul, False)
+ self.dbg.SetErrorFileHandle(devnul, False)
+
+ self.assertTrue(process.is_stopped)
+
+ # Process.Continue
+ error = process.Continue()
+ self.assertFalse(error.Success())
+ self.assertTrue(process.is_stopped)
+
+ # Thread.StepOut
+ thread = process.GetSelectedThread()
+ thread.StepOut()
+ self.assertTrue(process.is_stopped)
+
+ # command line
+ self.dbg.HandleCommand('s')
+ self.assertTrue(process.is_stopped)
+ self.dbg.HandleCommand('c')
+ self.assertTrue(process.is_stopped)
+
+ # restore file handles
+ self.dbg.SetOutputFileHandle(None, False)
+ self.dbg.SetErrorFileHandle(None, False)
+
+ def check_backtrace(self, thread, filename, backtrace):
+ self.assertGreaterEqual(thread.GetNumFrames(), len(backtrace))
+ src = filename.rpartition('.')[0] + '.c'
+ for i in range(len(backtrace)):
+ frame = thread.GetFrameAtIndex(i)
+ self.assertTrue(frame)
+ if not backtrace[i].startswith('_'):
+ self.assertEqual(frame.GetFunctionName(), backtrace[i])
+ self.assertEqual(frame.GetLineEntry().GetLine(),
+ line_number(src, "Frame " + backtrace[i]))
+ self.assertEqual(
+ frame.FindVariable("F").GetValueAsUnsigned(), ord(
+ backtrace[i][0]))
+
+ def do_test(self, filename, pid, region_count):
+ target = self.dbg.CreateTarget(filename)
+ process = target.LoadCore(filename + ".core")
+
+ self.assertTrue(process, PROCESS_IS_VALID)
+ self.assertEqual(process.GetNumThreads(), self.THREAD_COUNT)
+ self.assertEqual(process.GetProcessID(), pid)
+
+ self.check_state(process)
+
+ self.check_stack(process, pid, filename)
+
+ self.check_memory_regions(process, region_count)
+
+ self.dbg.DeleteTarget(target)
+
+
+class NetBSD1LWPCoreTestCase(NetBSDCoreCommonTestCase):
+ THREAD_COUNT = 1
+
+ def check_stack(self, process, pid, filename):
+ thread = process.GetSelectedThread()
+ self.assertTrue(thread)
+ self.assertEqual(thread.GetThreadID(), 1)
+ self.assertEqual(thread.GetStopReason(), lldb.eStopReasonSignal)
+ self.assertEqual(thread.GetStopReasonDataCount(), 1)
+ self.assertEqual(thread.GetStopReasonDataAtIndex(0), signal.SIGSEGV)
+ backtrace = ["bar", "foo", "main"]
+ self.check_backtrace(thread, filename, backtrace)
+
+ @skipIfLLVMTargetMissing("AArch64")
+ def test_aarch64(self):
+ """Test single-threaded aarch64 core dump."""
+ self.do_test("1lwp_SIGSEGV.aarch64", pid=8339, region_count=32)
+
+ @skipIfLLVMTargetMissing("X86")
+ def test_amd64(self):
+ """Test single-threaded amd64 core dump."""
+ self.do_test("1lwp_SIGSEGV.amd64", pid=693, region_count=21)
+
+
+class NetBSD2LWPT2CoreTestCase(NetBSDCoreCommonTestCase):
+ THREAD_COUNT = 2
+
+ def check_stack(self, process, pid, filename):
+ thread = process.GetSelectedThread()
+ self.assertTrue(thread)
+ self.assertEqual(thread.GetThreadID(), 2)
+ self.assertEqual(thread.GetStopReason(), lldb.eStopReasonSignal)
+ self.assertEqual(thread.GetStopReasonDataCount(), 1)
+ self.assertEqual(thread.GetStopReasonDataAtIndex(0), signal.SIGSEGV)
+ backtrace = ["bar", "foo", "lwp_main"]
+ self.check_backtrace(thread, filename, backtrace)
+
+ # thread 1 should have no signal
+ thread = process.GetThreadByID(1)
+ self.assertEqual(thread.GetStopReason(), lldb.eStopReasonSignal)
+ self.assertEqual(thread.GetStopReasonDataCount(), 1)
+ self.assertEqual(thread.GetStopReasonDataAtIndex(0), 0)
+
+ @skipIfLLVMTargetMissing("AArch64")
+ def test_aarch64(self):
+ """Test double-threaded aarch64 core dump where thread 2 is signalled."""
+ self.do_test("2lwp_t2_SIGSEGV.aarch64", pid=14142, region_count=31)
+
+ @skipIfLLVMTargetMissing("X86")
+ def test_amd64(self):
+ """Test double-threaded amd64 core dump where thread 2 is signalled."""
+ self.do_test("2lwp_t2_SIGSEGV.amd64", pid=622, region_count=24)
+
+
+class NetBSD2LWPProcessSigCoreTestCase(NetBSDCoreCommonTestCase):
+ THREAD_COUNT = 2
+
+ def check_stack(self, process, pid, filename):
+ thread = process.GetSelectedThread()
+ self.assertTrue(thread)
+ self.assertEqual(thread.GetThreadID(), 2)
+ self.assertEqual(thread.GetStopReason(), lldb.eStopReasonSignal)
+ self.assertEqual(thread.GetStopReasonDataCount(), 1)
+ self.assertEqual(thread.GetStopReasonDataAtIndex(0), signal.SIGSEGV)
+ backtrace = ["bar", "foo", "lwp_main"]
+ self.check_backtrace(thread, filename, backtrace)
+
+ # thread 1 should have the same signal
+ thread = process.GetThreadByID(1)
+ self.assertEqual(thread.GetStopReason(), lldb.eStopReasonSignal)
+ self.assertEqual(thread.GetStopReasonDataCount(), 1)
+ self.assertEqual(thread.GetStopReasonDataAtIndex(0), signal.SIGSEGV)
+
+ @skipIfLLVMTargetMissing("AArch64")
+ def test_aarch64(self):
+ """Test double-threaded aarch64 core dump where process is signalled."""
+ self.do_test("2lwp_process_SIGSEGV.aarch64", pid=1403, region_count=30)
+
+ @skipIfLLVMTargetMissing("X86")
+ def test_amd64(self):
+ """Test double-threaded amd64 core dump where process is signalled."""
+ self.do_test("2lwp_process_SIGSEGV.amd64", pid=665, region_count=24)
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/wow64_minidump/TestWow64MiniDump.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/wow64_minidump/TestWow64MiniDump.py
new file mode 100644
index 00000000000..cbfc8525ea2
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/wow64_minidump/TestWow64MiniDump.py
@@ -0,0 +1,72 @@
+"""
+Test basics of a mini dump taken of a 32-bit process running in WoW64
+
+WoW64 is the subsystem that lets 32-bit processes run in 64-bit Windows. If you
+capture a mini dump of a process running under WoW64 with a 64-bit debugger, you
+end up with a dump of the WoW64 layer. In that case, LLDB must do extra work to
+get the 32-bit register contexts.
+"""
+
+from six import iteritems
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class Wow64MiniDumpTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+ NO_DEBUG_INFO_TESTCASE = True
+
+ def test_wow64_mini_dump(self):
+ """Test that lldb can read the process information from the minidump."""
+ # target create -c fizzbuzz_wow64.dmp
+ target = self.dbg.CreateTarget("")
+ process = target.LoadCore("fizzbuzz_wow64.dmp")
+ self.assertTrue(process, PROCESS_IS_VALID)
+ self.assertEqual(process.GetNumThreads(), 1)
+ self.assertEqual(process.GetProcessID(), 0x1E9C)
+
+ def test_thread_info_in_wow64_mini_dump(self):
+ """Test that lldb can read the thread information from the minidump."""
+ # target create -c fizzbuzz_wow64.dmp
+ target = self.dbg.CreateTarget("")
+ process = target.LoadCore("fizzbuzz_wow64.dmp")
+ # This process crashed due to an access violation (0xc0000005), but the
+ # minidump doesn't have an exception record--perhaps the crash handler
+ # ate it.
+ # TODO: See if we can recover the exception information from the TEB,
+ # which, according to Windbg, has a pointer to an exception list.
+
+ # In the dump, none of the threads are stopped, so we cannot use
+ # lldbutil.get_stopped_thread.
+ thread = process.GetThreadAtIndex(0)
+ self.assertEqual(thread.GetStopReason(), lldb.eStopReasonNone)
+
+ def test_stack_info_in_wow64_mini_dump(self):
+ """Test that we can see a trivial stack in a VS-generate mini dump."""
+ # target create -c fizzbuzz_no_heap.dmp
+ target = self.dbg.CreateTarget("")
+ process = target.LoadCore("fizzbuzz_wow64.dmp")
+ self.assertGreaterEqual(process.GetNumThreads(), 1)
+ # This process crashed due to an access violation (0xc0000005), but the
+ # minidump doesn't have an exception record--perhaps the crash handler
+ # ate it.
+ # TODO: See if we can recover the exception information from the TEB,
+ # which, according to Windbg, has a pointer to an exception list.
+
+ # In the dump, none of the threads are stopped, so we cannot use
+ # lldbutil.get_stopped_thread.
+ thread = process.GetThreadAtIndex(0)
+ # The crash is in main, so there should be at least one frame on the
+ # stack.
+ self.assertGreaterEqual(thread.GetNumFrames(), 1)
+ frame = thread.GetFrameAtIndex(0)
+ self.assertTrue(frame.IsValid())
+ pc = frame.GetPC()
+ eip = frame.FindRegister("pc")
+ self.assertTrue(eip.IsValid())
+ self.assertEqual(pc, eip.GetValueAsUnsigned())
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/wow64_minidump/fizzbuzz.cpp b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/wow64_minidump/fizzbuzz.cpp
new file mode 100644
index 00000000000..295d4a1f24d
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/wow64_minidump/fizzbuzz.cpp
@@ -0,0 +1,31 @@
+// A sample program for getting minidumps on Windows.
+
+#include <iostream>
+
+bool
+fizz(int x)
+{
+ return x % 3 == 0;
+}
+
+bool
+buzz(int x)
+{
+ return x % 5 == 0;
+}
+
+int
+main()
+{
+ int *buggy = 0;
+
+ for (int i = 1; i <= 100; ++i)
+ {
+ if (fizz(i)) std::cout << "fizz";
+ if (buzz(i)) std::cout << "buzz";
+ if (!fizz(i) && !buzz(i)) std::cout << i;
+ std::cout << '\n';
+ }
+
+ return *buggy;
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/wow64_minidump/fizzbuzz_wow64.dmp b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/wow64_minidump/fizzbuzz_wow64.dmp
new file mode 100644
index 00000000000..3d97186f2cd
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/wow64_minidump/fizzbuzz_wow64.dmp
Binary files differ