Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Data formatters: fix detection of C strings
Summary: 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. Reviewers: teemperor Reviewed By: teemperor Subscribers: lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D76650
- Loading branch information
Showing
4 changed files
with
26 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
lldb/test/API/functionalities/data-formatter/cstring-utf8-summary/Makefile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
CXX_SOURCES := main.cpp | ||
|
||
include Makefile.rules |
18 changes: 18 additions & 0 deletions
18
lldb/test/API/functionalities/data-formatter/cstring-utf8-summary/TestCstringUnicode.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# coding=utf8 | ||
|
||
import lldb | ||
from lldbsuite.test.lldbtest import * | ||
import lldbsuite.test.lldbutil as lldbutil | ||
|
||
|
||
class CstringUnicodeTestCase(TestBase): | ||
|
||
mydir = TestBase.compute_mydir(__file__) | ||
NO_DEBUG_INFO_TESTCASE = True | ||
|
||
def test_cstring_unicode(self): | ||
self.build() | ||
lldbutil.run_to_source_breakpoint(self, "// break here", | ||
lldb.SBFileSpec("main.cpp", False)) | ||
self.expect_expr("s", result_summary='"🔥"') | ||
self.expect_expr("(const char*)s", result_summary='"🔥"') |
4 changes: 4 additions & 0 deletions
4
lldb/test/API/functionalities/data-formatter/cstring-utf8-summary/main.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
int main() { | ||
const char *s = u8"🔥"; | ||
return 0; // break here | ||
} |