diff options
| author | Jonas Devlieghere <jonas@devlieghere.com> | 2024-11-12 21:18:22 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-11-12 21:18:22 -0800 |
| commit | 4714215efb0486682feaa3a99162e80a934be8f9 (patch) | |
| tree | 5c3b0ee76543f0f32a54b6c153f0699d749c3d32 /lldb/test/API/python_api | |
| parent | de0fd64bedd23660f557833cc0108c3fb2be3918 (diff) | |
| download | llvm-4714215efb0486682feaa3a99162e80a934be8f9.zip llvm-4714215efb0486682feaa3a99162e80a934be8f9.tar.gz llvm-4714215efb0486682feaa3a99162e80a934be8f9.tar.bz2 | |
[lldb] Support true/false in ValueObject::SetValueFromCString (#115780)
Support "true" and "false" (and "YES" and "NO" in Objective-C) in
ValueObject::SetValueFromCString.
Fixes #112597
Diffstat (limited to 'lldb/test/API/python_api')
| -rw-r--r-- | lldb/test/API/python_api/value/change_values/TestChangeValueAPI.py | 27 | ||||
| -rw-r--r-- | lldb/test/API/python_api/value/change_values/main.c | 15 |
2 files changed, 34 insertions, 8 deletions
diff --git a/lldb/test/API/python_api/value/change_values/TestChangeValueAPI.py b/lldb/test/API/python_api/value/change_values/TestChangeValueAPI.py index 7d9aa76..4c253fa 100644 --- a/lldb/test/API/python_api/value/change_values/TestChangeValueAPI.py +++ b/lldb/test/API/python_api/value/change_values/TestChangeValueAPI.py @@ -2,7 +2,6 @@ Test some SBValue APIs. """ - import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * @@ -111,6 +110,30 @@ class ChangeValueAPITestCase(TestBase): actual_value, 98765, "Got the right changed value from ptr->second_val" ) + ptr_fourth_value = ptr_value.GetChildMemberWithName("fourth_val") + self.assertTrue(ptr_fourth_value.IsValid(), "Got fourth_val from ptr") + fourth_actual_value = ptr_fourth_value.GetValueAsUnsigned(error, 1) + self.assertTrue(error.Success(), "Got an unsigned value for ptr->fourth_val") + self.assertEqual(fourth_actual_value, 0) + + result = ptr_fourth_value.SetValueFromCString("true") + self.assertTrue(result, "Success setting ptr->fourth_val.") + fourth_actual_value = ptr_fourth_value.GetValueAsSigned(error, 0) + self.assertTrue(error.Success(), "Got a changed value from ptr->fourth_val") + self.assertEqual( + fourth_actual_value, 1, "Got the right changed value from ptr->fourth_val" + ) + + result = ptr_fourth_value.SetValueFromCString("NO") + self.assertFalse(result, "Failed setting ptr->fourth_val.") + fourth_actual_value = ptr_fourth_value.GetValueAsSigned(error, 0) + self.assertTrue(error.Success(), "Got the original value from ptr->fourth_val") + self.assertEqual( + fourth_actual_value, + 1, + "Got the original changed value from ptr->fourth_val", + ) + # gcc may set multiple locations for breakpoint breakpoint.SetEnabled(False) @@ -125,7 +148,7 @@ class ChangeValueAPITestCase(TestBase): ) expected_value = ( - "Val - 12345 Mine - 55, 98765, 55555555. Ptr - 66, 98765, 66666666" + "Val - 12345 Mine - 55, 98765, 55555555, 0. Ptr - 66, 98765, 66666666, 1" ) stdout = process.GetSTDOUT(1000) self.assertIn(expected_value, stdout, "STDOUT showed changed values.") diff --git a/lldb/test/API/python_api/value/change_values/main.c b/lldb/test/API/python_api/value/change_values/main.c index 01455c0..a606eec 100644 --- a/lldb/test/API/python_api/value/change_values/main.c +++ b/lldb/test/API/python_api/value/change_values/main.c @@ -1,5 +1,6 @@ -#include <stdio.h> +#include <stdbool.h> #include <stdint.h> +#include <stdio.h> #include <stdlib.h> struct foo @@ -7,21 +8,23 @@ struct foo uint8_t first_val; uint32_t second_val; uint64_t third_val; + bool fourth_val; }; - + int main () { int val = 100; - struct foo mine = {55, 5555, 55555555}; + struct foo mine = {55, 5555, 55555555, false}; struct foo *ptr = (struct foo *) malloc (sizeof (struct foo)); ptr->first_val = 66; ptr->second_val = 6666; ptr->third_val = 66666666; + ptr->fourth_val = false; // Stop here and set values - printf ("Val - %d Mine - %d, %d, %llu. Ptr - %d, %d, %llu\n", val, - mine.first_val, mine.second_val, mine.third_val, - ptr->first_val, ptr->second_val, ptr->third_val); + printf("Val - %d Mine - %d, %d, %llu, %d. Ptr - %d, %d, %llu, %d\n", val, + mine.first_val, mine.second_val, mine.third_val, mine.fourth_val, + ptr->first_val, ptr->second_val, ptr->third_val, ptr->fourth_val); // Stop here and check values printf ("This is just another call which we won't make it over %d.", val); |
