Skip to content

Commit 46cdcf0

Browse files
committed
[lldb] Add support for UTF-8 unicode formatting
This patch adds missing formatting for UTF-8 unicode. Cross-referencing https://reviews.llvm.org/D66447 Reviewed By: labath Differential Revision: https://reviews.llvm.org/D112564
1 parent 5b2e611 commit 46cdcf0

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -5149,6 +5149,8 @@ lldb::Format TypeSystemClang::GetFormat(lldb::opaque_compiler_type_t type) {
51495149
case clang::BuiltinType::UChar:
51505150
case clang::BuiltinType::WChar_U:
51515151
return lldb::eFormatChar;
5152+
case clang::BuiltinType::Char8:
5153+
return lldb::eFormatUnicode8;
51525154
case clang::BuiltinType::Char16:
51535155
return lldb::eFormatUnicode16;
51545156
case clang::BuiltinType::Char32:
@@ -8957,6 +8959,7 @@ bool TypeSystemClang::DumpTypeValue(
89578959
case eFormatCharPrintable:
89588960
case eFormatCharArray:
89598961
case eFormatBytes:
8962+
case eFormatUnicode8:
89608963
case eFormatBytesWithASCII:
89618964
item_count = byte_size;
89628965
byte_size = 1;

lldb/test/API/functionalities/data-formatter/builtin-formats/TestBuiltinFormats.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,7 @@ def test(self):
115115
self.assertIn('= \\0\\e90zaZA\\v\\t\\r\\n\\f\\b\\a \n', self.getFormatted("character array", string_expr))
116116
self.assertIn('= \\0\\e90zaZA\\v\\t\\r\\n\\f\\b\\a \n', self.getFormatted("character", string_expr))
117117
self.assertIn('= ..90zaZA....... \n', self.getFormatted("printable character", string_expr))
118-
# FIXME: This should probably print the characters in the uint128_t.
119-
self.assertIn('= 0x2007080c0a0d090b415a617a30391b00\n', self.getFormatted("unicode8", string_expr))
118+
self.assertIn('= 0x00 0x1b 0x39 0x30 0x7a 0x61 0x5a 0x41 0x0b 0x09 0x0d 0x0a 0x0c 0x08 0x07 0x20\n', self.getFormatted("unicode8", string_expr))
120119

121120
# OSType
122121
ostype_expr = "(__UINT64_TYPE__)0x"
@@ -137,6 +136,9 @@ def test(self):
137136
# bytes with ASCII
138137
self.assertIn(r'= " \U0000001b\a\b\f\n\r\t\vaA09\0"', self.getFormatted("bytes with ASCII", "cstring"))
139138

139+
# unicode8
140+
self.assertIn('= 0x78 0x56 0x34 0x12\n', self.getFormatted("unicode8", "0x12345678"))
141+
140142
# unicode16
141143
self.assertIn('= U+5678 U+1234\n', self.getFormatted("unicode16", "0x12345678"))
142144

0 commit comments

Comments
 (0)