[Lldb-commits] [PATCH] D16322: Enable test log collection from remote debug servers

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Tue Jan 19 09:31:46 PST 2016


labath created this revision.
labath added a reviewer: tfiala.
labath added a subscriber: lldb-commits.

We already have the ability to collect the server logs when doing local debugging. This enables
the collection of remote logs as well. This relies on specifying a relative path "server.log" for
LLDB_DEBUGSERVER_LOG_FILE when starting remote platform. Since we always set the platform working
directory to a fresh folder to avoid conflicts, the actual file path will always be different and
we can pick the logs up from there.

http://reviews.llvm.org/D16322

Files:
  packages/Python/lldbsuite/test/lldbtest.py

Index: packages/Python/lldbsuite/test/lldbtest.py
===================================================================
--- packages/Python/lldbsuite/test/lldbtest.py
+++ packages/Python/lldbsuite/test/lldbtest.py
@@ -1345,21 +1345,24 @@
             else:
                 categories = "default"
 
-            if channel == "gdb-remote":
+            if channel == "gdb-remote" and lldb.remote_platform is None:
                 # communicate gdb-remote categories to debugserver
                 os.environ["LLDB_DEBUGSERVER_LOG_FLAGS"] = categories
 
             self.ci.HandleCommand(log_enable + channel_with_categories, self.res)
             if not self.res.Succeeded():
                 raise Exception('log enable failed (check LLDB_LOG_OPTION env variable)')
 
         # Communicate log path name to debugserver & lldb-server
-        server_log_path = "{}-server.log".format(log_basename)
-        open(server_log_path, 'w').close()
-        os.environ["LLDB_DEBUGSERVER_LOG_FILE"] = server_log_path
+        # For remote debugging, these variables need to be set when starting the platform
+        # instance.
+        if lldb.remote_platform is None:
+            server_log_path = "{}-server.log".format(log_basename)
+            open(server_log_path, 'w').close()
+            os.environ["LLDB_DEBUGSERVER_LOG_FILE"] = server_log_path
 
-        # Communicate channels to lldb-server
-        os.environ["LLDB_SERVER_LOG_CHANNELS"] = ":".join(lldbtest_config.channels)
+            # Communicate channels to lldb-server
+            os.environ["LLDB_SERVER_LOG_CHANNELS"] = ":".join(lldbtest_config.channels)
 
         if len(lldbtest_config.channels) == 0:
             return
@@ -1373,6 +1376,15 @@
             if not self.res.Succeeded():
                 raise Exception('log disable failed (check LLDB_LOG_OPTION env variable)')
 
+        # Retrieve the server log (if any) from the remote system. It is assumed the server log
+        # is writting to the "server.log" file in the current test directory. This can be
+        # achieved by setting LLDB_DEBUGSERVER_LOG_FILE="server.log" when starting remote
+        # platform.
+        if lldb.remote_platform:
+            # This is executed on a best-effort basis. If the file is not there, so be it.
+            lldb.remote_platform.Get(lldb.SBFileSpec("server.log"),
+                    lldb.SBFileSpec(self.getLogBasenameForCurrentTest()+"-server.log"))
+
     def setUp(self):
         """Fixture for unittest test case setup.
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D16322.45273.patch
Type: text/x-patch
Size: 2516 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20160119/f91bedf6/attachment.bin>


More information about the lldb-commits mailing list