xref: /llvm-project/lldb/test/API/functionalities/value_md5_crash/TestValueMD5Crash.py (revision 80fcecb13c388ff087a27a4b0e7ca3dd8c98eaa4)
1"""
2Verify that the hash computing logic for ValueObject's values can't crash us.
3"""
4
5
6import lldb
7from lldbsuite.test.decorators import *
8from lldbsuite.test.lldbtest import *
9from lldbsuite.test import lldbutil
10
11
12class ValueMD5CrashTestCase(TestBase):
13    def setUp(self):
14        # Call super's setUp().
15        TestBase.setUp(self)
16        # Find the line number to break at.
17        self.line = line_number("main.cpp", "// break here")
18
19    @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24663")
20    def test_with_run_command(self):
21        """Verify that the hash computing logic for ValueObject's values can't crash us."""
22        self.build()
23        self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET)
24
25        lldbutil.run_break_set_by_file_and_line(
26            self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True
27        )
28
29        self.runCmd("run", RUN_SUCCEEDED)
30
31        # The stop reason of the thread should be breakpoint.
32        self.expect(
33            "thread list",
34            STOPPED_DUE_TO_BREAKPOINT,
35            substrs=["stopped", "stop reason = breakpoint"],
36        )
37
38        value = self.frame().FindVariable("a")
39        value.SetPreferDynamicValue(lldb.eDynamicCanRunTarget)
40
41        v = value.GetValue()
42        type_name = value.GetTypeName()
43        self.assertEqual(type_name, "B *", "a is a B*")
44
45        self.runCmd("next")
46        self.runCmd("process kill")
47
48        # now the process is dead, and value needs updating
49        v = value.GetValue()
50
51        # if we are here, instead of crashed, the test succeeded
52