2 Test lldb process crash info.
8 from lldbsuite
.test
.decorators
import *
9 from lldbsuite
.test
.lldbtest
import *
10 from lldbsuite
.test
import lldbutil
11 from lldbsuite
.test
import lldbtest
14 class PlatformProcessCrashInfoTestCase(TestBase
):
17 self
.runCmd("settings set auto-confirm true")
18 self
.source
= "main.c"
19 self
.line
= line_number(self
.source
, "// break here")
22 self
.runCmd("settings clear auto-confirm")
23 TestBase
.tearDown(self
)
25 @skipIfAsan # The test process intentionally double-frees.
28 """Test that `process status --verbose` fetches the extended crash
29 information dictionary from the command-line properly."""
31 exe
= self
.getBuildArtifact("a.out")
32 self
.expect("file " + exe
, patterns
=["Current executable set to .*a.out"])
34 self
.expect("process launch", patterns
=["Process .* launched: .*a.out"])
37 "process status --verbose",
39 "Extended Crash Information",
40 "Crash-Info Annotations",
41 "pointer being freed was not allocated",
45 @skipIfAsan # The test process intentionally hits a memory bug.
48 """Test that lldb can fetch a crashed process' extended crash information
49 dictionary from the api properly."""
51 target
= self
.dbg
.CreateTarget(self
.getBuildArtifact("a.out"))
52 self
.assertTrue(target
, VALID_TARGET
)
54 target
.LaunchSimple(None, None, os
.getcwd())
56 stream
= lldb
.SBStream()
57 self
.assertTrue(stream
)
59 process
= target
.GetProcess()
60 self
.assertTrue(process
)
62 crash_info
= process
.GetExtendedCrashInformation()
64 error
= crash_info
.GetAsJSON(stream
)
66 self
.assertSuccess(error
)
68 self
.assertTrue(crash_info
.IsValid())
70 self
.assertIn("pointer being freed was not allocated", stream
.GetData())
72 # dyld leaves permanent crash_info records when testing on device.
74 def test_on_sane_process(self
):
75 """Test that lldb doesn't fetch the extended crash information
76 dictionary from a 'sane' stopped process."""
78 target
, _
, _
, _
= lldbutil
.run_to_line_breakpoint(
79 self
, lldb
.SBFileSpec(self
.source
), self
.line
82 stream
= lldb
.SBStream()
83 self
.assertTrue(stream
)
85 process
= target
.GetProcess()
86 self
.assertTrue(process
)
88 crash_info
= process
.GetExtendedCrashInformation()
90 error
= crash_info
.GetAsJSON(stream
)
91 self
.assertFalse(error
.Success())
92 self
.assertIn("No structured data.", error
.GetCString())