Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lldb/source/API/SBValue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ class ValueImpl {
// they depend on. So I have no good way to make that check without
// tracking that in all the ValueObject subclasses.
TargetSP target_sp = m_valobj_sp->GetTargetSP();
return target_sp && target_sp->IsValid();
return target_sp && target_sp->IsValid() &&
m_valobj_sp->GetError().Success();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def call_function(self):
self.runCmd("process handle SIGCHLD -s 1 -p 1 -n 1")

value = frame.EvaluateExpression("call_me (%d)" % (num_sigchld), options)
self.assertTrue(value.IsValid())
self.assertFalse(value.IsValid())
self.assertFalse(value.GetError().Success())

# Set signal handling back to no-stop, and continue and we should end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def call_function(self):
self.orig_frame_pc = frame.GetPC()

value = frame.EvaluateExpression("[my_class callMeIThrow]", options)
self.assertTrue(value.IsValid())
self.assertFalse(value.IsValid())
self.assertFalse(value.GetError().Success())

self.check_after_call()
Expand All @@ -61,7 +61,8 @@ def call_function(self):

value = frame.EvaluateExpression("[my_class callMeIThrow]", options)

self.assertTrue(value.IsValid() and not value.GetError().Success())
self.assertFalse(value.IsValid())
self.assertFalse(value.GetError().Success())
self.check_after_call()

# Now set the ObjC language breakpoint and make sure that doesn't
Expand All @@ -76,7 +77,8 @@ def call_function(self):

value = frame.EvaluateExpression("[my_class callMeIThrow]", options)

self.assertTrue(value.IsValid() and not value.GetError().Success())
self.assertFalse(value.IsValid())
self.assertFalse(value.GetError().Success())
self.check_after_call()

# Now turn off exception trapping, and call a function that catches the exceptions,
Expand All @@ -95,5 +97,6 @@ def call_function(self):
options.SetUnwindOnError(False)
value = frame.EvaluateExpression("[my_class callMeIThrow]", options)

self.assertTrue(value.IsValid() and not value.GetError().Success())
self.assertFalse(value.IsValid())
self.assertFalse(value.GetError().Success())
self.check_after_call()
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def test_context_object(self):

# Test an expression evaluation
value = obj_val.EvaluateExpression("1")
self.assertTrue(value.IsValid())
self.assertFalse(value.IsValid())
self.assertFalse(value.GetError().Success())

#
Expand All @@ -81,7 +81,7 @@ def test_context_object(self):

# Test an expression evaluation
value = obj_val.EvaluateExpression("1")
self.assertTrue(value.IsValid())
self.assertFalse(value.IsValid())
self.assertFalse(value.GetError().Success())

# Test retrieveing of an element's field
Expand All @@ -99,7 +99,7 @@ def test_context_object(self):

# Test an expression evaluation
value = obj_val.EvaluateExpression("1")
self.assertTrue(value.IsValid())
self.assertFalse(value.IsValid())
self.assertFalse(value.GetError().Success())

# Test retrieveing of a dereferenced object's field
Expand All @@ -117,7 +117,7 @@ def test_context_object(self):

# Test an expression evaluation
value = obj_val.EvaluateExpression("1")
self.assertTrue(value.IsValid())
self.assertFalse(value.IsValid())
self.assertFalse(value.GetError().Success())

#
Expand All @@ -129,7 +129,7 @@ def test_context_object(self):

# Test an expression evaluation
value = obj_val.EvaluateExpression("1")
self.assertTrue(value.IsValid())
self.assertFalse(value.IsValid())
self.assertFalse(value.GetError().Success())

# Test retrieveing of a dereferenced object's field
Expand Down
2 changes: 1 addition & 1 deletion lldb/test/API/commands/expression/fixits/TestFixIts.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def test_with_target(self):
# Now turn off the fixits, and the expression should fail:
options.SetAutoApplyFixIts(False)
value = frame.EvaluateExpression(two_error_expression, options)
self.assertTrue(value.IsValid())
self.assertFalse(value.IsValid())
self.assertTrue(value.GetError().Fail())
error_string = value.GetError().GetCString()
self.assertNotEqual(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def test_expr_options(self):
# Make sure it fails if language is set to C:
options.SetLanguage(lldb.eLanguageTypeC)
val = frame.EvaluateExpression("foo != nullptr", options)
self.assertTrue(val.IsValid())
self.assertFalse(val.IsValid())
self.assertFalse(val.GetError().Success())

def test_expr_options_lang(self):
Expand All @@ -83,5 +83,5 @@ def test_expr_options_lang(self):
# Make sure we can't retrieve `id` variable if language is set to ObjC:
options.SetLanguage(lldb.eLanguageTypeObjC)
val = frame.EvaluateExpression("id == 0", options)
self.assertTrue(val.IsValid())
self.assertFalse(val.IsValid())
self.assertFalse(val.GetError().Success())
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ def test(self):

## b is not a Foo
value = frame.EvaluateExpression("b == Foo::FooBar")
self.assertTrue(value.IsValid())
self.assertFalse(value.IsValid())
self.assertFalse(value.GetError().Success())

## integral is not implicitly convertible to a scoped enum
value = frame.EvaluateExpression("1 == Foo::FooBar")
self.assertTrue(value.IsValid())
self.assertFalse(value.IsValid())
self.assertFalse(value.GetError().Success())
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def test(self):
frame = thread.GetFrameAtIndex(0)

value = frame.EvaluateExpression(f"wait_a_while({long_time})", options)
self.assertTrue(value.IsValid())
self.assertFalse(value.IsValid())
self.assertFalse(value.GetError().Success())

# Now do the same thing with the command line command, and make sure it
Expand Down
4 changes: 4 additions & 0 deletions lldb/test/API/python_api/sbvalue_is_valid/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
CXX_SOURCES := main.cpp
CFLAGS_EXTRAS := -std=c++17

include Makefile.rules
20 changes: 20 additions & 0 deletions lldb/test/API/python_api/sbvalue_is_valid/TestSBValueIsValid.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import lldb
from lldbsuite.test.lldbtest import TestBase
from lldbsuite.test import lldbutil


class TestCase(TestBase):
def test(self):
self.build()

(target, process, thread, main_breakpoint) = lldbutil.run_to_source_breakpoint(
self, "return", lldb.SBFileSpec("main.cpp")
)
frame = thread.GetSelectedFrame()

v1 = self.frame().EvaluateExpression("test")
v2 = self.frame().EvaluateExpression("i")

self.assertFalse(v1.IsValid())
self.assertTrue(v1.GetError().Fail())
self.assertTrue(v2.IsValid())
4 changes: 4 additions & 0 deletions lldb/test/API/python_api/sbvalue_is_valid/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
int main() {
int i = 42;
return 0;
}
Loading