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