1"""Test that lldb can report the exception reason for threads in a corefile."""
2
3import os
4import re
5import subprocess
6
7import lldb
8from lldbsuite.test.decorators import *
9from lldbsuite.test.lldbtest import *
10from lldbsuite.test import lldbutil
11
12class TestCorefileExceptionReason(TestBase):
13
14    mydir = TestBase.compute_mydir(__file__)
15
16    @skipIfOutOfTreeDebugserver  # newer debugserver required for these qMemoryRegionInfo types
17    @no_debug_info_test
18    @skipUnlessDarwin
19    @skipIf(archs=no_match(['arm64','arm64e']))
20    @skipIfRemote
21    def test(self):
22
23        corefile = self.getBuildArtifact("process.core")
24        self.build()
25        (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(
26            self, "// break here", lldb.SBFileSpec("main.cpp"))
27
28        self.runCmd("continue")
29
30        self.runCmd("process save-core -s stack " + corefile)
31        process.Kill()
32        self.dbg.DeleteTarget(target)
33
34        # Now load the corefile
35        target = self.dbg.CreateTarget('')
36        process = target.LoadCore(corefile)
37        thread = process.GetSelectedThread()
38        self.assertTrue(process.GetSelectedThread().IsValid())
39        if self.TraceOn():
40            self.runCmd("image list")
41            self.runCmd("bt")
42            self.runCmd("fr v")
43
44        self.assertTrue(thread.GetStopDescription(256) == "ESR_EC_DABORT_EL0 (fault address: 0x0)")
45