summaryrefslogtreecommitdiffstats
path: root/lldb
diff options
context:
space:
mode:
Diffstat (limited to 'lldb')
-rw-r--r--lldb/test/functionalities/watchpoint/hello_watchlocation/TestWatchLocation.py10
-rw-r--r--lldb/test/functionalities/watchpoint/hello_watchlocation/main.cpp2
-rw-r--r--lldb/test/lldbtest.py42
3 files changed, 45 insertions, 9 deletions
diff --git a/lldb/test/functionalities/watchpoint/hello_watchlocation/TestWatchLocation.py b/lldb/test/functionalities/watchpoint/hello_watchlocation/TestWatchLocation.py
index 73a0f29d64a..8ad797b0e08 100644
--- a/lldb/test/functionalities/watchpoint/hello_watchlocation/TestWatchLocation.py
+++ b/lldb/test/functionalities/watchpoint/hello_watchlocation/TestWatchLocation.py
@@ -62,6 +62,9 @@ class HelloWatchLocationTestCase(TestBase):
# incrmenting the global pool by 2.
self.expect("frame variable -w write -x 1 -g g_char_ptr", WATCHPOINT_CREATED,
substrs = ['Watchpoint created', 'size = 1', 'type = w'])
+ self.runCmd("expr unsigned val = *g_char_ptr; val")
+ self.expect(self.res.GetOutput().splitlines()[0], exe=False,
+ endstr = ' = 0')
# Use the '-v' option to do verbose listing of the watchpoint.
# The hit count should be 0 initially.
@@ -77,6 +80,13 @@ class HelloWatchLocationTestCase(TestBase):
'stop reason = watchpoint',
self.violating_func])
+ # Switch to the thread stopped due to watchpoint and issue some commands.
+ self.switch_to_thread_with_stop_reason(lldb.eStopReasonWatchpoint)
+ self.runCmd("thread backtrace")
+ self.runCmd("expr unsigned val = *g_char_ptr; val")
+ self.expect(self.res.GetOutput().splitlines()[0], exe=False,
+ endstr = ' = 1')
+
# Use the '-v' option to do verbose listing of the watchpoint.
# The hit count should now be 1.
self.expect("watchpoint list -v",
diff --git a/lldb/test/functionalities/watchpoint/hello_watchlocation/main.cpp b/lldb/test/functionalities/watchpoint/hello_watchlocation/main.cpp
index 8515ca0cca8..ef965715479 100644
--- a/lldb/test/functionalities/watchpoint/hello_watchlocation/main.cpp
+++ b/lldb/test/functionalities/watchpoint/hello_watchlocation/main.cpp
@@ -23,6 +23,8 @@ char *g_char_ptr = NULL;
void
do_bad_thing_with_location(char *char_ptr, char new_val)
{
+ unsigned what = new_val;
+ printf("new value written to location(%p) = %u\n", char_ptr, what);
*char_ptr = new_val;
}
diff --git a/lldb/test/lldbtest.py b/lldb/test/lldbtest.py
index 8af7185b854..cbddc289a9e 100644
--- a/lldb/test/lldbtest.py
+++ b/lldb/test/lldbtest.py
@@ -962,6 +962,21 @@ class TestBase(Base):
del self.dbg
+ def switch_to_thread_with_stop_reason(self, stop_reason):
+ """
+ Run the 'thread list' command, and select the thread with stop reason as
+ 'stop_reason'. If no such thread exists, no select action is done.
+ """
+ from lldbutil import stop_reason_to_str
+ self.runCmd('thread list')
+ output = self.res.GetOutput()
+ thread_line_pattern = re.compile("^[ *] thread #([0-9]+):.*stop reason = %s" %
+ stop_reason_to_str(stop_reason))
+ for line in output.splitlines():
+ matched = thread_line_pattern.match(line)
+ if matched:
+ self.runCmd('thread select %s' % matched.group(1))
+
def runCmd(self, cmd, msg=None, check=True, trace=False):
"""
Ask the command interpreter to handle the command and then check its
@@ -1000,7 +1015,7 @@ class TestBase(Base):
self.assertTrue(self.res.Succeeded(),
msg if msg else CMD_MSG(cmd))
- def expect(self, str, msg=None, patterns=None, startstr=None, substrs=None, trace=False, error=False, matching=True, exe=True):
+ def expect(self, str, msg=None, patterns=None, startstr=None, endstr=None, substrs=None, trace=False, error=False, matching=True, exe=True):
"""
Similar to runCmd; with additional expect style output matching ability.
@@ -1056,6 +1071,14 @@ class TestBase(Base):
print >> sbuf, "%s start string: %s" % (heading, startstr)
print >> sbuf, "Matched" if matched else "Not matched"
+ # Look for endstr, if specified.
+ keepgoing = matched if matching else not matched
+ if endstr:
+ matched = output.endswith(endstr)
+ with recording(self, trace) as sbuf:
+ print >> sbuf, "%s end string: %s" % (heading, endstr)
+ print >> sbuf, "Matched" if matched else "Not matched"
+
# Look for sub strings, if specified.
keepgoing = matched if matching else not matched
if substrs and keepgoing:
@@ -1110,14 +1133,15 @@ class TestBase(Base):
err = sys.stderr
err.write(val.GetName() + ":\n")
- err.write('\t' + "TypeName -> " + val.GetTypeName() + '\n')
- err.write('\t' + "ByteSize -> " + str(val.GetByteSize()) + '\n')
- err.write('\t' + "NumChildren -> " + str(val.GetNumChildren()) + '\n')
- err.write('\t' + "Value -> " + str(val.GetValue()) + '\n')
- err.write('\t' + "ValueType -> " + value_type_to_str(val.GetValueType()) + '\n')
- err.write('\t' + "Summary -> " + str(val.GetSummary()) + '\n')
- err.write('\t' + "IsPointerType -> " + str(val.TypeIsPointerType()) + '\n')
- err.write('\t' + "Location -> " + val.GetLocation() + '\n')
+ err.write('\t' + "TypeName -> " + val.GetTypeName() + '\n')
+ err.write('\t' + "ByteSize -> " + str(val.GetByteSize()) + '\n')
+ err.write('\t' + "NumChildren -> " + str(val.GetNumChildren()) + '\n')
+ err.write('\t' + "Value -> " + str(val.GetValue()) + '\n')
+ err.write('\t' + "ValueAsUnsigned -> " + str(val.GetValueAsUnsigned())+ '\n')
+ err.write('\t' + "ValueType -> " + value_type_to_str(val.GetValueType()) + '\n')
+ err.write('\t' + "Summary -> " + str(val.GetSummary()) + '\n')
+ err.write('\t' + "IsPointerType -> " + str(val.TypeIsPointerType()) + '\n')
+ err.write('\t' + "Location -> " + val.GetLocation() + '\n')
def DebugSBType(self, type):
"""Debug print a SBType object, if traceAlways is True."""
OpenPOWER on IntegriCloud