File: TestWatchpointMultipleSlots.py

package info (click to toggle)
llvm-toolchain-4.0 1%3A4.0.1-10~deb9u2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 493,332 kB
  • sloc: cpp: 2,698,100; ansic: 552,773; asm: 128,821; python: 121,589; objc: 105,054; sh: 21,174; lisp: 6,758; ml: 5,532; perl: 5,311; pascal: 5,245; makefile: 2,083; cs: 1,868; xml: 686; php: 212; csh: 117
file content (97 lines) | stat: -rw-r--r-- 3,591 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
"""
Test watchpoint slots we should not be able to install multiple watchpoints
within same word boundary. We should be able to install individual watchpoints
on any of the bytes, half-word, or word. This is only for ARM/AArch64 targets.
"""

from __future__ import print_function

import os
import time
import lldb
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil


class WatchpointSlotsTestCase(TestBase):
    NO_DEBUG_INFO_TESTCASE = True

    mydir = TestBase.compute_mydir(__file__)

    def setUp(self):
        # Call super's setUp().
        TestBase.setUp(self)

        # Source filename.
        self.source = 'main.c'

        # Output filename.
        self.exe_name = 'a.out'
        self.d = {'C_SOURCES': self.source, 'EXE': self.exe_name}

    # Watchpoints not supported
    @expectedFailureAndroid(archs=['arm', 'aarch64'])
    # This is a arm and aarch64 specific test case. No other architectures tested.
    @skipIf(archs=no_match(['arm', 'aarch64']))
    def test_multiple_watchpoints_on_same_word(self):

        self.build(dictionary=self.d)
        self.setTearDownCleanup(dictionary=self.d)

        exe = os.path.join(os.getcwd(), self.exe_name)
        self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)

        # Detect line number after which we are going to increment arrayName.
        loc_line = line_number('main.c', '// About to write byteArray')

        # Set a breakpoint on the line detected above.
        lldbutil.run_break_set_by_file_and_line(
            self, "main.c", loc_line, num_expected_locations=1, loc_exact=True)

        # Run the program.
        self.runCmd("run", RUN_SUCCEEDED)

        # The stop reason of the thread should be breakpoint.
        self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
                     substrs=['stopped', 'stop reason = breakpoint'])

        # Delete breakpoint we just hit.
        self.expect("breakpoint delete 1", substrs=['1 breakpoints deleted'])

        # Set a watchpoint at byteArray[0]
        self.expect("watchpoint set variable byteArray[0]", WATCHPOINT_CREATED,
                    substrs=['Watchpoint created','size = 1'])

        # Use the '-v' option to do verbose listing of the watchpoint.
        # The hit count should be 0 initially.
        self.expect("watchpoint list -v 1", substrs=['hit_count = 0'])

        # Try setting a watchpoint at byteArray[1]
        self.expect("watchpoint set variable byteArray[1]", error=True,
                    substrs=['Watchpoint creation failed'])

        self.runCmd("process continue")

        # We should be stopped due to the watchpoint.
        # The stop reason of the thread should be watchpoint.
        self.expect("thread list", STOPPED_DUE_TO_WATCHPOINT,
                    substrs=['stopped', 'stop reason = watchpoint 1'])

        # Delete the watchpoint we hit above successfully.
        self.expect("watchpoint delete 1", substrs=['1 watchpoints deleted'])

        # Set a watchpoint at byteArray[3]
        self.expect("watchpoint set variable byteArray[3]", WATCHPOINT_CREATED,
                    substrs=['Watchpoint created','size = 1'])
   
        # Resume inferior.
        self.runCmd("process continue")

        # We should be stopped due to the watchpoint.
        # The stop reason of the thread should be watchpoint.
        self.expect("thread list -v", STOPPED_DUE_TO_WATCHPOINT,
                    substrs=['stopped', 'stop reason = watchpoint 3'])
   
        # Resume inferior.
        self.runCmd("process continue")