Detection of C strings does not work well for pointers. If the value object holding a (char*) pointer does not have an address (e.g., if it is a temp), the value is not considered a C string and its formatting is left to DumpDataExtractor rather than the special handling in ValueObject::DumpPrintableRepresentation. This leads to inconsistent outputs, e.g., in escaping non-ASCII characters. See the test for an example; the second test expectation is not met (without this patch). With this patch, the C string detection only insists that the pointer value is valid. The patch makes the code consistent with how the pointer is obtained in ValueObject::ReadPointedString.
Details
Details
Diff Detail
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Comment Actions
LGTM, thanks for tracking this down! I only have a minor comment about the test character.
lldb/test/API/functionalities/data-formatter/cstring-utf8-summary/TestCstringUnicode.py | ||
---|---|---|
19 | expect_expr is the modern way to check this: self.expect_expr("s", result_summary='"π₯"') self.expect_expr("(const char*)s", result_summary='"π₯"') | |
lldb/test/API/functionalities/data-formatter/cstring-utf8-summary/main.cpp | ||
3 | Could you make this a string like u8"π₯"? "Γ©" is also a valid character in a lot of extended-ASCII character sets (e.g., Latin-1) and we probably should take some unicode-exclusive character and make sure it's utf-8. |
expect_expr is the modern way to check this: