mirror of
https://github.com/intel/llvm.git
synced 2026-01-25 01:07:04 +08:00
[lldb] Support true/false in ValueObject::SetValueFromCString (#115780)
Support "true" and "false" (and "YES" and "NO" in Objective-C) in ValueObject::SetValueFromCString. Fixes #112597
This commit is contained in:
committed by
GitHub
parent
de0fd64bed
commit
4714215efb
@@ -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.")
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user