[Lldb-commits] [PATCH] D111399: [lldb] Make char[N] formatters respect the end of the array (PR44649)
Pavel Labath via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Mon Oct 11 03:47:42 PDT 2021
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8093c2ea574b: [lldb] Make char[N] formatters respect the end of the array (PR44649) (authored by labath).
Changed prior to commit:
https://reviews.llvm.org/D111399?vs=378162&id=378616#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D111399/new/
https://reviews.llvm.org/D111399
Files:
lldb/source/DataFormatters/FormatManager.cpp
lldb/test/API/functionalities/data-formatter/stringprinter/main.cpp
Index: lldb/test/API/functionalities/data-formatter/stringprinter/main.cpp
===================================================================
--- lldb/test/API/functionalities/data-formatter/stringprinter/main.cpp
+++ lldb/test/API/functionalities/data-formatter/stringprinter/main.cpp
@@ -1,7 +1,18 @@
#include <string>
+#include <cstring>
+
+struct A {
+ char data[4];
+ char overflow[4];
+};
int main (int argc, char const *argv[])
{
+ A a, b;
+ // Deliberately write past the end of data to test that the formatter stops
+ // at the end of array.
+ memcpy(a.data, "FOOBAR", 7);
+ memcpy(b.data, "FO\0BAR", 7);
std::string stdstring("Hello\t\tWorld\nI am here\t\tto say hello\n"); //%self.addTearDownHook(lambda x: x.runCmd("setting set escape-non-printables true"))
const char* constcharstar = stdstring.c_str();
std::string longstring(
@@ -20,12 +31,15 @@
);
const char* longconstcharstar = longstring.c_str();
return 0; //% if self.TraceOn(): self.runCmd('frame variable')
- //% self.assertTrue(self.frame().FindVariable('stdstring').GetSummary() == '"Hello\\t\\tWorld\\nI am here\\t\\tto say hello\\n"')
- //% self.assertTrue(self.frame().FindVariable('constcharstar').GetSummary() == '"Hello\\t\\tWorld\\nI am here\\t\\tto say hello\\n"')
- //% self.runCmd("setting set escape-non-printables false")
- //% self.assertTrue(self.frame().FindVariable('stdstring').GetSummary() == '"Hello\t\tWorld\nI am here\t\tto say hello\n"')
- //% self.assertTrue(self.frame().FindVariable('constcharstar').GetSummary() == '"Hello\t\tWorld\nI am here\t\tto say hello\n"')
+ //% self.expect_var_path('stdstring', summary='"Hello\\t\\tWorld\\nI am here\\t\\tto say hello\\n"')
+ //% self.expect_var_path('constcharstar', summary='"Hello\\t\\tWorld\\nI am here\\t\\tto say hello\\n"')
+ //% self.runCmd("setting set escape-non-printables false")
+ //% self.expect_var_path('stdstring', summary='"Hello\t\tWorld\nI am here\t\tto say hello\n"')
+ //% self.expect_var_path('constcharstar', summary='"Hello\t\tWorld\nI am here\t\tto say hello\n"')
//% self.assertTrue(self.frame().FindVariable('longstring').GetSummary().endswith('"...'))
//% self.assertTrue(self.frame().FindVariable('longconstcharstar').GetSummary().endswith('"...'))
+ //% self.expect_var_path("a.data", summary='"FOOB"')
+ // FIXME: Should this be "FO\0B" instead?
+ //% self.expect_var_path("b.data", summary='"FO"')
}
Index: lldb/source/DataFormatters/FormatManager.cpp
===================================================================
--- lldb/source/DataFormatters/FormatManager.cpp
+++ lldb/source/DataFormatters/FormatManager.cpp
@@ -722,7 +722,7 @@
new StringSummaryFormat(string_flags, "${var%s}"));
lldb::TypeSummaryImplSP string_array_format(
- new StringSummaryFormat(string_array_flags, "${var%s}"));
+ new StringSummaryFormat(string_array_flags, "${var%char[]}"));
RegularExpression any_size_char_arr(llvm::StringRef("char \\[[0-9]+\\]"));
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D111399.378616.patch
Type: text/x-patch
Size: 3057 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20211011/2582a757/attachment.bin>
More information about the lldb-commits
mailing list