summaryrefslogtreecommitdiffstats
path: root/lldb/packages/Python/lldbsuite/test/python_api/value
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test/python_api/value')
-rw-r--r--lldb/packages/Python/lldbsuite/test/python_api/value/TestValueAPI.py57
-rw-r--r--lldb/packages/Python/lldbsuite/test/python_api/value/change_values/TestChangeValueAPI.py173
-rw-r--r--lldb/packages/Python/lldbsuite/test/python_api/value/linked_list/TestValueAPILinkedList.py28
3 files changed, 162 insertions, 96 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/python_api/value/TestValueAPI.py b/lldb/packages/Python/lldbsuite/test/python_api/value/TestValueAPI.py
index 2a53177d28a..632244e8b9e 100644
--- a/lldb/packages/Python/lldbsuite/test/python_api/value/TestValueAPI.py
+++ b/lldb/packages/Python/lldbsuite/test/python_api/value/TestValueAPI.py
@@ -13,6 +13,7 @@ from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
+
class ValueAPITestCase(TestBase):
mydir = TestBase.compute_mydir(__file__)
@@ -43,13 +44,17 @@ class ValueAPITestCase(TestBase):
self.assertTrue(breakpoint, VALID_BREAKPOINT)
# Now launch the process, and do not stop at entry point.
- process = target.LaunchSimple (None, None, self.get_process_working_directory())
+ process = target.LaunchSimple(
+ None, None, self.get_process_working_directory())
self.assertTrue(process, PROCESS_IS_VALID)
# Get Frame #0.
self.assertTrue(process.GetState() == lldb.eStateStopped)
- thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint)
- self.assertTrue(thread.IsValid(), "There should be a thread stopped due to breakpoint condition")
+ thread = lldbutil.get_stopped_thread(
+ process, lldb.eStopReasonBreakpoint)
+ self.assertTrue(
+ thread.IsValid(),
+ "There should be a thread stopped due to breakpoint condition")
frame0 = thread.GetFrameAtIndex(0)
# Get global variable 'days_of_week'.
@@ -93,10 +98,11 @@ class ValueAPITestCase(TestBase):
self.DebugSBValue(pointed)
# While we are at it, verify that 'my_int_ptr' points to 'g_my_int'.
- symbol = target.ResolveLoadAddress(int(pointed.GetLocation(), 0)).GetSymbol()
+ symbol = target.ResolveLoadAddress(
+ int(pointed.GetLocation(), 0)).GetSymbol()
self.assertTrue(symbol)
self.expect(symbol.GetName(), exe=False,
- startstr = 'g_my_int')
+ startstr='g_my_int')
# Get variable 'str_ptr'.
value = frame0.FindVariable('str_ptr')
@@ -119,7 +125,7 @@ class ValueAPITestCase(TestBase):
self.DebugSBValue(child)
self.expect(child.GetSummary(), exe=False,
- substrs = ['Friday'])
+ substrs=['Friday'])
# Now try to get at the same variable using GetValueForExpressionPath().
# These two SBValue objects should have the same value.
@@ -132,14 +138,31 @@ class ValueAPITestCase(TestBase):
val_i = target.EvaluateExpression('i')
val_s = target.EvaluateExpression('s')
val_a = target.EvaluateExpression('a')
- self.assertTrue(val_s.GetChildMemberWithName('a').AddressOf(), VALID_VARIABLE)
- self.assertTrue(val_a.Cast(val_i.GetType()).AddressOf(), VALID_VARIABLE)
-
- self.assertTrue(int(lldb.value(frame0.FindVariable('uinthex'))) == 3768803088, 'uinthex == 3768803088')
- self.assertTrue(int(lldb.value(frame0.FindVariable('sinthex'))) == -526164208, 'sinthex == -526164208')
-
- self.assertTrue(frame0.FindVariable('uinthex').GetValueAsUnsigned() == 3768803088, 'unsigned uinthex == 3768803088')
- self.assertTrue(frame0.FindVariable('sinthex').GetValueAsUnsigned() == 3768803088, 'unsigned sinthex == 3768803088')
-
- self.assertTrue(frame0.FindVariable('uinthex').GetValueAsSigned() == -526164208, 'signed uinthex == -526164208')
- self.assertTrue(frame0.FindVariable('sinthex').GetValueAsSigned() == -526164208, 'signed sinthex == -526164208')
+ self.assertTrue(
+ val_s.GetChildMemberWithName('a').AddressOf(),
+ VALID_VARIABLE)
+ self.assertTrue(
+ val_a.Cast(
+ val_i.GetType()).AddressOf(),
+ VALID_VARIABLE)
+
+ self.assertTrue(int(lldb.value(frame0.FindVariable('uinthex')))
+ == 3768803088, 'uinthex == 3768803088')
+ self.assertTrue(int(lldb.value(frame0.FindVariable('sinthex')))
+ == -526164208, 'sinthex == -526164208')
+
+ self.assertTrue(
+ frame0.FindVariable('uinthex').GetValueAsUnsigned() == 3768803088,
+ 'unsigned uinthex == 3768803088')
+ self.assertTrue(
+ frame0.FindVariable('sinthex').GetValueAsUnsigned() == 3768803088,
+ 'unsigned sinthex == 3768803088')
+
+ self.assertTrue(
+ frame0.FindVariable('uinthex').GetValueAsSigned() == -
+ 526164208,
+ 'signed uinthex == -526164208')
+ self.assertTrue(
+ frame0.FindVariable('sinthex').GetValueAsSigned() == -
+ 526164208,
+ 'signed sinthex == -526164208')
diff --git a/lldb/packages/Python/lldbsuite/test/python_api/value/change_values/TestChangeValueAPI.py b/lldb/packages/Python/lldbsuite/test/python_api/value/change_values/TestChangeValueAPI.py
index 52c91e0b262..64c7fde2267 100644
--- a/lldb/packages/Python/lldbsuite/test/python_api/value/change_values/TestChangeValueAPI.py
+++ b/lldb/packages/Python/lldbsuite/test/python_api/value/change_values/TestChangeValueAPI.py
@@ -5,14 +5,15 @@ Test some SBValue APIs.
from __future__ import print_function
-
-import os, time
+import os
+import time
import re
import lldb
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
+
class ChangeValueAPITestCase(TestBase):
mydir = TestBase.compute_mydir(__file__)
@@ -24,8 +25,10 @@ class ChangeValueAPITestCase(TestBase):
self.exe_name = self.testMethodName
# Find the line number to of function 'c'.
self.line = line_number('main.c', '// Stop here and set values')
- self.check_line = line_number('main.c', '// Stop here and check values')
- self.end_line = line_number ('main.c', '// Set a breakpoint here at the end')
+ self.check_line = line_number(
+ 'main.c', '// Stop here and check values')
+ self.end_line = line_number(
+ 'main.c', '// Set a breakpoint here at the end')
@add_test_categories(['pyapi'])
@expectedFlakeyLinux("llvm.org/pr25652")
@@ -46,97 +49,126 @@ class ChangeValueAPITestCase(TestBase):
self.assertTrue(breakpoint, VALID_BREAKPOINT)
# Create the breakpoint inside the function 'main'
- check_breakpoint = target.BreakpointCreateByLocation('main.c', self.check_line)
+ check_breakpoint = target.BreakpointCreateByLocation(
+ 'main.c', self.check_line)
self.assertTrue(check_breakpoint, VALID_BREAKPOINT)
# Create the breakpoint inside function 'main'.
- end_breakpoint = target.BreakpointCreateByLocation('main.c', self.end_line)
+ end_breakpoint = target.BreakpointCreateByLocation(
+ 'main.c', self.end_line)
self.assertTrue(end_breakpoint, VALID_BREAKPOINT)
# Now launch the process, and do not stop at entry point.
- process = target.LaunchSimple (None, None, self.get_process_working_directory())
+ process = target.LaunchSimple(
+ None, None, self.get_process_working_directory())
self.assertTrue(process, PROCESS_IS_VALID)
# Get Frame #0.
self.assertTrue(process.GetState() == lldb.eStateStopped)
- thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint)
- self.assertTrue(thread.IsValid(), "There should be a thread stopped due to breakpoint condition")
+ thread = lldbutil.get_stopped_thread(
+ process, lldb.eStopReasonBreakpoint)
+ self.assertTrue(
+ thread.IsValid(),
+ "There should be a thread stopped due to breakpoint condition")
frame0 = thread.GetFrameAtIndex(0)
- self.assertTrue (frame0.IsValid(), "Got a valid frame.")
+ self.assertTrue(frame0.IsValid(), "Got a valid frame.")
# Get the val variable and change it:
error = lldb.SBError()
- val_value = frame0.FindVariable ("val")
- self.assertTrue (val_value.IsValid(), "Got the SBValue for val")
- actual_value = val_value.GetValueAsSigned (error, 0);
- self.assertTrue (error.Success(), "Got a value from val")
- self.assertTrue (actual_value == 100, "Got the right value from val")
-
- result = val_value.SetValueFromCString ("12345")
- self.assertTrue (result, "Setting val returned True.")
- actual_value = val_value.GetValueAsSigned (error, 0);
- self.assertTrue (error.Success(), "Got a changed value from val")
- self.assertTrue (actual_value == 12345, "Got the right changed value from val")
-
+ val_value = frame0.FindVariable("val")
+ self.assertTrue(val_value.IsValid(), "Got the SBValue for val")
+ actual_value = val_value.GetValueAsSigned(error, 0)
+ self.assertTrue(error.Success(), "Got a value from val")
+ self.assertTrue(actual_value == 100, "Got the right value from val")
+
+ result = val_value.SetValueFromCString("12345")
+ self.assertTrue(result, "Setting val returned True.")
+ actual_value = val_value.GetValueAsSigned(error, 0)
+ self.assertTrue(error.Success(), "Got a changed value from val")
+ self.assertTrue(
+ actual_value == 12345,
+ "Got the right changed value from val")
+
# Now check that we can set a structure element:
- mine_value = frame0.FindVariable ("mine")
- self.assertTrue (mine_value.IsValid(), "Got the SBValue for mine")
-
- mine_second_value = mine_value.GetChildMemberWithName ("second_val")
- self.assertTrue (mine_second_value.IsValid(), "Got second_val from mine")
- actual_value = mine_second_value.GetValueAsUnsigned (error, 0)
- self.assertTrue (error.Success(), "Got an unsigned value for second_val")
- self.assertTrue (actual_value == 5555)
-
- result = mine_second_value.SetValueFromCString ("98765")
- self.assertTrue (result, "Success setting mine.second_value.")
- actual_value = mine_second_value.GetValueAsSigned (error, 0);
- self.assertTrue (error.Success(), "Got a changed value from mine.second_val")
- self.assertTrue (actual_value == 98765, "Got the right changed value from mine.second_val")
-
+ mine_value = frame0.FindVariable("mine")
+ self.assertTrue(mine_value.IsValid(), "Got the SBValue for mine")
+
+ mine_second_value = mine_value.GetChildMemberWithName("second_val")
+ self.assertTrue(
+ mine_second_value.IsValid(),
+ "Got second_val from mine")
+ actual_value = mine_second_value.GetValueAsUnsigned(error, 0)
+ self.assertTrue(
+ error.Success(),
+ "Got an unsigned value for second_val")
+ self.assertTrue(actual_value == 5555)
+
+ result = mine_second_value.SetValueFromCString("98765")
+ self.assertTrue(result, "Success setting mine.second_value.")
+ actual_value = mine_second_value.GetValueAsSigned(error, 0)
+ self.assertTrue(
+ error.Success(),
+ "Got a changed value from mine.second_val")
+ self.assertTrue(actual_value == 98765,
+ "Got the right changed value from mine.second_val")
+
# Next do the same thing with the pointer version.
- ptr_value = frame0.FindVariable ("ptr")
- self.assertTrue (ptr_value.IsValid(), "Got the SBValue for ptr")
-
- ptr_second_value = ptr_value.GetChildMemberWithName ("second_val")
- self.assertTrue (ptr_second_value.IsValid(), "Got second_val from ptr")
- actual_value = ptr_second_value.GetValueAsUnsigned (error, 0)
- self.assertTrue (error.Success(), "Got an unsigned value for ptr->second_val")
- self.assertTrue (actual_value == 6666)
-
- result = ptr_second_value.SetValueFromCString ("98765")
- self.assertTrue (result, "Success setting ptr->second_value.")
- actual_value = ptr_second_value.GetValueAsSigned (error, 0);
- self.assertTrue (error.Success(), "Got a changed value from ptr->second_val")
- self.assertTrue (actual_value == 98765, "Got the right changed value from ptr->second_val")
-
+ ptr_value = frame0.FindVariable("ptr")
+ self.assertTrue(ptr_value.IsValid(), "Got the SBValue for ptr")
+
+ ptr_second_value = ptr_value.GetChildMemberWithName("second_val")
+ self.assertTrue(ptr_second_value.IsValid(), "Got second_val from ptr")
+ actual_value = ptr_second_value.GetValueAsUnsigned(error, 0)
+ self.assertTrue(
+ error.Success(),
+ "Got an unsigned value for ptr->second_val")
+ self.assertTrue(actual_value == 6666)
+
+ result = ptr_second_value.SetValueFromCString("98765")
+ self.assertTrue(result, "Success setting ptr->second_value.")
+ actual_value = ptr_second_value.GetValueAsSigned(error, 0)
+ self.assertTrue(
+ error.Success(),
+ "Got a changed value from ptr->second_val")
+ self.assertTrue(actual_value == 98765,
+ "Got the right changed value from ptr->second_val")
+
# gcc may set multiple locations for breakpoint
breakpoint.SetEnabled(False)
- # Now continue, grab the stdout and make sure we changed the real values as well...
- process.Continue();
+ # Now continue, grab the stdout and make sure we changed the real
+ # values as well...
+ process.Continue()
self.assertTrue(process.GetState() == lldb.eStateStopped)
- thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint)
- self.assertTrue(thread.IsValid(), "There should be a thread stopped due to breakpoint condition")
+ thread = lldbutil.get_stopped_thread(
+ process, lldb.eStopReasonBreakpoint)
+ self.assertTrue(
+ thread.IsValid(),
+ "There should be a thread stopped due to breakpoint condition")
expected_value = "Val - 12345 Mine - 55, 98765, 55555555. Ptr - 66, 98765, 66666666"
stdout = process.GetSTDOUT(1000)
- self.assertTrue (expected_value in stdout, "STDOUT showed changed values.")
+ self.assertTrue(
+ expected_value in stdout,
+ "STDOUT showed changed values.")
- # Finally, change the stack pointer to 0, and we should not make it to our end breakpoint.
+ # Finally, change the stack pointer to 0, and we should not make it to
+ # our end breakpoint.
frame0 = thread.GetFrameAtIndex(0)
- self.assertTrue (frame0.IsValid(), "Second time: got a valid frame.")
- sp_value = frame0.FindValue ("sp", lldb.eValueTypeRegister);
- self.assertTrue (sp_value.IsValid(), "Got a stack pointer value")
+ self.assertTrue(frame0.IsValid(), "Second time: got a valid frame.")
+ sp_value = frame0.FindValue("sp", lldb.eValueTypeRegister)
+ self.assertTrue(sp_value.IsValid(), "Got a stack pointer value")
result = sp_value.SetValueFromCString("1")
- self.assertTrue (result, "Setting sp returned true.")
- actual_value = sp_value.GetValueAsUnsigned (error, 0)
- self.assertTrue (error.Success(), "Got a changed value for sp")
- self.assertTrue (actual_value == 1, "Got the right changed value for sp.")
-
+ self.assertTrue(result, "Setting sp returned true.")
+ actual_value = sp_value.GetValueAsUnsigned(error, 0)
+ self.assertTrue(error.Success(), "Got a changed value for sp")
+ self.assertTrue(
+ actual_value == 1,
+ "Got the right changed value for sp.")
+
# Boundary condition test the SBValue.CreateValueFromExpression() API.
# LLDB should not crash!
nosuchval = mine_value.CreateValueFromExpression(None, None)
@@ -144,7 +176,10 @@ class ChangeValueAPITestCase(TestBase):
process.Continue()
self.assertTrue(process.GetState() == lldb.eStateStopped)
- thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint)
- self.assertTrue(thread == None, "We should not have managed to hit our second breakpoint with sp == 1")
-
+ thread = lldbutil.get_stopped_thread(
+ process, lldb.eStopReasonBreakpoint)
+ self.assertTrue(
+ thread is None,
+ "We should not have managed to hit our second breakpoint with sp == 1")
+
process.Kill()
diff --git a/lldb/packages/Python/lldbsuite/test/python_api/value/linked_list/TestValueAPILinkedList.py b/lldb/packages/Python/lldbsuite/test/python_api/value/linked_list/TestValueAPILinkedList.py
index 879efd186d6..d5f53d712e7 100644
--- a/lldb/packages/Python/lldbsuite/test/python_api/value/linked_list/TestValueAPILinkedList.py
+++ b/lldb/packages/Python/lldbsuite/test/python_api/value/linked_list/TestValueAPILinkedList.py
@@ -6,14 +6,15 @@ supports iteration till the end of list is reached.
from __future__ import print_function
-
-import os, time
+import os
+import time
import re
import lldb
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
+
class ValueAsLinkedListTestCase(TestBase):
mydir = TestBase.compute_mydir(__file__)
@@ -26,8 +27,9 @@ class ValueAsLinkedListTestCase(TestBase):
# Find the line number to break at.
self.line = line_number('main.cpp', '// Break at this line')
- # Py3 asserts due to a bug in SWIG. A fix for this was upstreamed into SWIG 3.0.8.
- @skipIf(py_version=['>=', (3,0)], swig_version=['<', (3,0,8)])
+ # Py3 asserts due to a bug in SWIG. A fix for this was upstreamed into
+ # SWIG 3.0.8.
+ @skipIf(py_version=['>=', (3, 0)], swig_version=['<', (3, 0, 8)])
@add_test_categories(['pyapi'])
def test(self):
"""Exercise SBValue API linked_list_iter."""
@@ -45,13 +47,17 @@ class ValueAsLinkedListTestCase(TestBase):
self.assertTrue(breakpoint, VALID_BREAKPOINT)
# Now launch the process, and do not stop at entry point.
- process = target.LaunchSimple (None, None, self.get_process_working_directory())
+ process = target.LaunchSimple(
+ None, None, self.get_process_working_directory())
self.assertTrue(process, PROCESS_IS_VALID)
# Get Frame #0.
self.assertTrue(process.GetState() == lldb.eStateStopped)
- thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint)
- self.assertTrue(thread.IsValid(), "There should be a thread stopped due to breakpoint condition")
+ thread = lldbutil.get_stopped_thread(
+ process, lldb.eStopReasonBreakpoint)
+ self.assertTrue(
+ thread.IsValid(),
+ "There should be a thread stopped due to breakpoint condition")
frame0 = thread.GetFrameAtIndex(0)
# Get variable 'task_head'.
@@ -66,7 +72,8 @@ class ValueAsLinkedListTestCase(TestBase):
cvf = lldbutil.ChildVisitingFormatter(indent_child=2)
for t in task_head.linked_list_iter('next'):
self.assertTrue(t, VALID_VARIABLE)
- # Make sure that 'next' corresponds to an SBValue with pointer type.
+ # Make sure that 'next' corresponds to an SBValue with pointer
+ # type.
self.assertTrue(t.TypeIsPointerType())
if self.TraceOn():
print(cvf.format(t))
@@ -96,7 +103,8 @@ class ValueAsLinkedListTestCase(TestBase):
list = []
for t in task_head.linked_list_iter('next', eol):
self.assertTrue(t, VALID_VARIABLE)
- # Make sure that 'next' corresponds to an SBValue with pointer type.
+ # Make sure that 'next' corresponds to an SBValue with pointer
+ # type.
self.assertTrue(t.TypeIsPointerType())
if self.TraceOn():
print(cvf.format(t))
@@ -106,7 +114,7 @@ class ValueAsLinkedListTestCase(TestBase):
if self.TraceOn():
print("visited IDs:", list)
self.assertTrue(visitedIDs == list)
-
+
# Get variable 'empty_task_head'.
empty_task_head = frame0.FindVariable('empty_task_head')
self.assertTrue(empty_task_head, VALID_VARIABLE)
OpenPOWER on IntegriCloud