[Lldb-commits] [lldb] r207285 - Added TestLldbGdbServer test for A start exe packet.

Todd Fiala todd.fiala at gmail.com
Fri Apr 25 16:08:24 PDT 2014


Author: tfiala
Date: Fri Apr 25 18:08:24 2014
New Revision: 207285

URL: http://llvm.org/viewvc/llvm-project?rev=207285&view=rev
Log:
Added TestLldbGdbServer test for A start exe packet.
Fixed up bug in XFAIL tests where I appended an array when I intended to merge an array.

Added:
    lldb/trunk/test/tools/lldb-gdbserver/Makefile
    lldb/trunk/test/tools/lldb-gdbserver/main.cpp
Modified:
    lldb/trunk/test/tools/lldb-gdbserver/TestLldbGdbServer.py
    lldb/trunk/test/tools/lldb-gdbserver/lldbgdbserverutils.py

Added: lldb/trunk/test/tools/lldb-gdbserver/Makefile
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/tools/lldb-gdbserver/Makefile?rev=207285&view=auto
==============================================================================
--- lldb/trunk/test/tools/lldb-gdbserver/Makefile (added)
+++ lldb/trunk/test/tools/lldb-gdbserver/Makefile Fri Apr 25 18:08:24 2014
@@ -0,0 +1,5 @@
+LEVEL = ../../make
+
+CXX_SOURCES := main.cpp
+
+include $(LEVEL)/Makefile.rules

Modified: lldb/trunk/test/tools/lldb-gdbserver/TestLldbGdbServer.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/tools/lldb-gdbserver/TestLldbGdbServer.py?rev=207285&r1=207284&r2=207285&view=diff
==============================================================================
--- lldb/trunk/test/tools/lldb-gdbserver/TestLldbGdbServer.py (original)
+++ lldb/trunk/test/tools/lldb-gdbserver/TestLldbGdbServer.py Fri Apr 25 18:08:24 2014
@@ -9,6 +9,7 @@ import sys
 from lldbtest import *
 from lldbgdbserverutils import *
 import logging
+import os.path
 
 class LldbGdbServerTestCase(TestBase):
 
@@ -20,8 +21,8 @@ class LldbGdbServerTestCase(TestBase):
 
     _GDBREMOTE_KILL_PACKET = "$k#6b"
 
-    _LOGGING_LEVEL = logging.WARNING
-#    _LOGGING_LEVEL = logging.DEBUG
+    # _LOGGING_LEVEL = logging.WARNING
+    _LOGGING_LEVEL = logging.DEBUG
 
     def setUp(self):
         TestBase.setUp(self)
@@ -109,7 +110,7 @@ class LldbGdbServerTestCase(TestBase):
         self.assertIsNotNone(server)
 
         log_lines = self.create_no_ack_remote_stream()
-        log_lines.append([
+        log_lines.extend([
             "lldb-gdbserver <  26> read packet: $QThreadSuffixSupported#e4",
             "lldb-gdbserver <   6> send packet: $OK#9a"])
 
@@ -122,13 +123,40 @@ class LldbGdbServerTestCase(TestBase):
         self.assertIsNotNone(server)
 
         log_lines = self.create_no_ack_remote_stream()
-        log_lines.append([
+        log_lines.extend([
             "lldb-gdbserver <  27> read packet: $QListThreadsInStopReply#21",
             "lldb-gdbserver <   6> send packet: $OK#9a"])
 
         expect_lldb_gdbserver_replay(self, self.sock, log_lines, True,
                                      self._TIMEOUT_SECONDS, self.logger)
 
+    def start_inferior(self):
+        server = self.start_server()
+        self.assertIsNotNone(server)
+
+        # TODO grab the build output directory rather than current directory.
+        inferior_exe_name = os.path.abspath('a.out')
+        inferior_exe_name_hex = gdbremote_hex_encode_string(inferior_exe_name)
+
+        log_lines = self.create_no_ack_remote_stream()
+        log_lines.extend([
+            "lldb-gdbserver < 000> read packet: {}".format(
+                gdbremote_packet_encode_string(
+                        "A{},0,{}".format(len(inferior_exe_name_hex), inferior_exe_name_hex))),
+            "lldb-gdbserver <   6> send packet: $OK#9a"])
+
+        expect_lldb_gdbserver_replay(self, self.sock, log_lines, True,
+                                     self._TIMEOUT_SECONDS, self.logger)
+
+    @dsym_test
+    def test_start_inferior(self):
+        self.buildDsym()
+        self.start_inferior()
+
+    @dwarf_test
+    def test_start_inferior(self):
+        self.buildDwarf()
+        self.start_inferior()
 
 if __name__ == '__main__':
     unittest2.main()

Modified: lldb/trunk/test/tools/lldb-gdbserver/lldbgdbserverutils.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/tools/lldb-gdbserver/lldbgdbserverutils.py?rev=207285&r1=207284&r2=207285&view=diff
==============================================================================
--- lldb/trunk/test/tools/lldb-gdbserver/lldbgdbserverutils.py (original)
+++ lldb/trunk/test/tools/lldb-gdbserver/lldbgdbserverutils.py Fri Apr 25 18:08:24 2014
@@ -198,6 +198,20 @@ def expect_lldb_gdbserver_replay(
     return None
 
 
+def gdbremote_hex_encode_string(str):
+    output = ''
+    for c in str:
+        output += '{0:02x}'.format(ord(c))
+    return output
+
+
+def gdbremote_packet_encode_string(str):
+    checksum = 0
+    for c in str:
+        checksum += ord(c)
+    return '$' + str + '#{0:02x}'.format(checksum % 256)
+
+
 if __name__ == '__main__':
     EXE_PATH = get_lldb_gdbserver_exe()
     if EXE_PATH:

Added: lldb/trunk/test/tools/lldb-gdbserver/main.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/tools/lldb-gdbserver/main.cpp?rev=207285&view=auto
==============================================================================
--- lldb/trunk/test/tools/lldb-gdbserver/main.cpp (added)
+++ lldb/trunk/test/tools/lldb-gdbserver/main.cpp Fri Apr 25 18:08:24 2014
@@ -0,0 +1,7 @@
+#include <iostream>
+
+int main(int argc, char **argv)
+{
+    std::cout << "hello, world" << std::endl;
+    return 0;
+}





More information about the lldb-commits mailing list