[Lldb-commits] [lldb] r282167 - Fix TestBreakpointSerialization on windows

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Thu Sep 22 08:26:44 PDT 2016


Author: labath
Date: Thu Sep 22 10:26:43 2016
New Revision: 282167

URL: http://llvm.org/viewvc/llvm-project?rev=282167&view=rev
Log:
Fix TestBreakpointSerialization on windows

The test exposed a bug in the StructuredData Serialization code, which did not
escape the backslash properly. This manifested itself as windows breakpoint
serialization roundtrip test not succeeding (as windows paths included
backslashes).

Added:
    lldb/trunk/unittests/Core/StructuredDataTest.cpp
Modified:
    lldb/trunk/source/Core/StructuredData.cpp
    lldb/trunk/unittests/Core/CMakeLists.txt

Modified: lldb/trunk/source/Core/StructuredData.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/StructuredData.cpp?rev=282167&r1=282166&r2=282167&view=diff
==============================================================================
--- lldb/trunk/source/Core/StructuredData.cpp (original)
+++ lldb/trunk/source/Core/StructuredData.cpp Thu Sep 22 10:26:43 2016
@@ -264,7 +264,7 @@ void StructuredData::String::Dump(Stream
   const size_t strsize = m_value.size();
   for (size_t i = 0; i < strsize; ++i) {
     char ch = m_value[i];
-    if (ch == '"')
+    if (ch == '"' || ch == '\\')
       quoted.push_back('\\');
     quoted.push_back(ch);
   }

Modified: lldb/trunk/unittests/Core/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Core/CMakeLists.txt?rev=282167&r1=282166&r2=282167&view=diff
==============================================================================
--- lldb/trunk/unittests/Core/CMakeLists.txt (original)
+++ lldb/trunk/unittests/Core/CMakeLists.txt Thu Sep 22 10:26:43 2016
@@ -3,4 +3,5 @@ add_lldb_unittest(LLDBCoreTests
   BroadcasterTest.cpp
   DataExtractorTest.cpp
   ScalarTest.cpp
+  StructuredDataTest.cpp
   )

Added: lldb/trunk/unittests/Core/StructuredDataTest.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Core/StructuredDataTest.cpp?rev=282167&view=auto
==============================================================================
--- lldb/trunk/unittests/Core/StructuredDataTest.cpp (added)
+++ lldb/trunk/unittests/Core/StructuredDataTest.cpp Thu Sep 22 10:26:43 2016
@@ -0,0 +1,32 @@
+//===-- StructuredDataTest.cpp ----------------------------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "gtest/gtest.h"
+
+#include "lldb/Core/StructuredData.h"
+#include "lldb/Core/StreamString.h"
+
+#include "llvm/Support/MachO.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+TEST(StructuredDataTest, StringDump) {
+  std::pair<llvm::StringRef, llvm::StringRef> TestCases[] = {
+    { R"(asdfg)", R"("asdfg")" },
+    { R"(as"df)", R"("as\"df")" },
+    { R"(as\df)", R"("as\\df")" },
+  };
+  for(auto P : TestCases) {
+    StreamString S;
+    const bool pretty_print = false;
+    StructuredData::String(P.first).Dump(S, pretty_print);
+    EXPECT_EQ(P.second, S.GetString());
+  }
+}




More information about the lldb-commits mailing list