[Lldb-commits] [lldb] r237092 - Escape strings in disassembly comments.

Ilia K ki.stfu at gmail.com
Mon May 11 22:55:24 PDT 2015


Author: ki.stfu
Date: Tue May 12 00:55:23 2015
New Revision: 237092

URL: http://llvm.org/viewvc/llvm-project?rev=237092&view=rev
Log:
Escape strings in disassembly comments.

Summary: Patch from chuckr at microsoft.com

Reviewers: abidh, ChuckR

Subscribers: paulmaybee, lldb-commits

Differential Revision: http://reviews.llvm.org/D9544

Modified:
    lldb/trunk/test/tools/lldb-mi/data/TestMiData.py
    lldb/trunk/test/tools/lldb-mi/data/main.cpp
    lldb/trunk/tools/lldb-mi/MICmdCmdData.cpp

Modified: lldb/trunk/test/tools/lldb-mi/data/TestMiData.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/tools/lldb-mi/data/TestMiData.py?rev=237092&r1=237091&r2=237092&view=diff
==============================================================================
--- lldb/trunk/test/tools/lldb-mi/data/TestMiData.py (original)
+++ lldb/trunk/test/tools/lldb-mi/data/TestMiData.py Tue May 12 00:55:23 2015
@@ -38,6 +38,27 @@ class MiDataTestCase(lldbmi_testcase.MiT
         self.runCmd("-data-disassemble -s %#x -e %#x -- 0" % (addr, addr + 0x10))
         self.expect("\^done,asm_insns=\[{address=\"0x0*%x\",func-name=\"main\",offset=\"0\",size=\"[1-9]+\",inst=\".+?\"}," % addr)
 
+        # Run to hello_world
+        self.runCmd("-break-insert -f hello_world")
+        self.expect("\^done,bkpt={number=\"2\"")
+        self.runCmd("-exec-continue")
+        self.expect("\^running")
+        self.expect("\*stopped,reason=\"breakpoint-hit\"")
+
+        # Get an address for disassembling: use hello_world
+        self.runCmd("-data-evaluate-expression hello_world")
+        self.expect("\^done,value=\"0x[0-9a-f]+\"")
+        addr = int(self.child.after.split("\"")[1], 16)
+
+        # Test -data-disassemble: try to disassemble some address
+        self.runCmd("-data-disassemble -s %#x -e %#x -- 0" % (addr, addr + 0x10))
+
+        # This matches a line similar to:
+        # {address="0x0000000100000f18",func-name="hello_world()",offset="8",size="7",inst="leaq 0x65(%rip), %rdi; \"Hello, World!\\n\""},
+        # To match the escaped characters in the ouptut, we must use four backslashes per matches backslash
+        # See https://docs.python.org/2/howto/regex.html#the-backslash-plague
+        self.expect("{address=\"0x[0-9a-f]+\",func-name=\"hello_world\(\)\",offset=\"[0-9]+\",size=\"[0-9]+\",inst=\".+?; \\\\\"Hello, World!\\\\\\\\n\\\\\"\"},")
+
     @lldbmi_test
     @expectedFailureWindows("llvm.org/pr22274: need a pexpect replacement for windows")
     @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races

Modified: lldb/trunk/test/tools/lldb-mi/data/main.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/tools/lldb-mi/data/main.cpp?rev=237092&r1=237091&r2=237092&view=diff
==============================================================================
--- lldb/trunk/test/tools/lldb-mi/data/main.cpp (original)
+++ lldb/trunk/test/tools/lldb-mi/data/main.cpp Tue May 12 00:55:23 2015
@@ -7,6 +7,8 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include <stdio.h>
+
 const char g_CharArray[] = "\x10\x11\x12\x13";
 static const char s_CharArray[] = "\x20\x21\x22\x23";
 
@@ -28,9 +30,16 @@ local_array_test()
     return;
 }
 
+void
+hello_world()
+{
+    printf("Hello, World!\n"); // BP_hello_world
+}
+
 int
 main(int argc, char const *argv[])
 { // FUNC_main
     local_array_test();
+    hello_world();
     return 0;
 }

Modified: lldb/trunk/tools/lldb-mi/MICmdCmdData.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdCmdData.cpp?rev=237092&r1=237091&r2=237092&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmdCmdData.cpp (original)
+++ lldb/trunk/tools/lldb-mi/MICmdCmdData.cpp Tue May 12 00:55:23 2015
@@ -438,7 +438,7 @@ CMICmdCmdDataDisassemble::Execute(void)
         const CMICmnMIValueConst miValueConst4(CMIUtilString::Format("%d", instrtSize));
         const CMICmnMIValueResult miValueResult4("size", miValueConst4);
         miValueTuple.Add(miValueResult4);
-        const CMICmnMIValueConst miValueConst5(CMIUtilString::Format("%s %s%s", pStrMnemonic, pStrOperands, strComment.c_str()));
+        const CMICmnMIValueConst miValueConst5(CMIUtilString::Format("%s %s%s", pStrMnemonic, pStrOperands, strComment.Escape(true).c_str()));
         const CMICmnMIValueResult miValueResult5("inst", miValueConst5);
         miValueTuple.Add(miValueResult5);
 





More information about the lldb-commits mailing list