Skip to content

Commit

Permalink
Fix std::string::data() xmethod
Browse files Browse the repository at this point in the history
dcca6898563b485eb7f46fdd5dd82cb011409735
  • Loading branch information
vadim-xd committed Apr 12, 2024
1 parent eebb503 commit 2f60b92
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ynd/gdb/14/pretty_printers/libcxx_xmethods.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def __call__(self, obj):
is_long = ss['__is_long_']
if is_long:
sl = destructure_compressed_pair(obj['__r_'])[0]['__l']
return sl['__data_'].address.cast(self.result_type)
return sl['__data_'].cast(self.result_type)
else:
return ss['__data_'].address.cast(self.result_type)

Expand Down
1 change: 1 addition & 0 deletions ynd/gdb/14/pretty_printers/test/gdbtest/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ std::pair<int, int> test_pair = {1, 2};
std::array<int, 4> test_array = {{1, 2, 3, 4}};

std::string test_string = "Это тест.";
std::string test_long_string = "A very long string that will not use small string optimization...";
std::string test_nullbyte_string{"\x00тест"sv};
std::string test_binary_string{"\xff\x00\xff\x00"sv};
std::string_view test_string_view(test_string);
Expand Down
7 changes: 6 additions & 1 deletion ynd/gdb/14/pretty_printers/test/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ def data(field):
test_pair='pair = {first = 1, second = 2}',
test_array='{__elems_ = {1, 2, 3, 4}}',
test_string='"Это тест."',
test_long_string='"A very long string that will not use small string optimization..."',
test_nullbyte_string='"\\000тест"',
test_binary_string='"\\377\\000\\377\\000"',
test_string_view='"Это тест."',
Expand Down Expand Up @@ -134,9 +135,13 @@ def test_pretty_printers(test_name, test_output):
test_array_elem=('test_array[2]', re.compile(r'= \(int &\) @0x[0-9a-f]+: 3')),
test_array_data=('test_array.data()', re.compile(r'= \(int \*\) 0x[0-9a-f]+ <test_array>')),
test_string_length=('test_string.length()', '= 16'),
test_string_elem=('test_string[15]', re.compile(r'= \(char &\) @0x[0-9a-f]+: 46 \'.\'')),
test_string_elem=('test_string[15]', re.compile(r'= \(char &\) @0x[0-9a-f]+: 46 \'\.\'')),
test_string_data=('test_string.data()', re.compile(r'= 0x[0-9a-f]+ <test_string\+[0-9a-z]> "Это тест\."')),
test_string_c_str=('test_string.c_str()', re.compile(r'= 0x[0-9a-f]+ <test_string\+[0-9a-z]> "Это тест\."')),
test_long_string_length=('test_long_string.length()', '= 65'),
test_long_string_elem=('test_long_string[33]', re.compile(r'= \(char &\) @0x[0-9a-f]+: 117 \'u\'')),
test_long_string_data=('test_long_string.data()', re.compile(r'= 0x[0-9a-f]+ "A very long string that will not use small string optimization\.\.\."')),
# c_str() shares implementation with data(), no need to re-test it for long strings.
test_tstring_length=('test_tstring.length()', '= 16'),
test_tstring_elem=('test_tstring[15]', re.compile(r'= \(char &\) @0x[0-9a-f]+: 46 \'.\'')),
test_tstring_data=('test_tstring.data()', re.compile(r'= 0x[0-9a-f]+ "Это тест\."')),
Expand Down

0 comments on commit 2f60b92

Please sign in to comment.