[Lldb-commits] [lldb] 7202d1c - Fix lldb-vscode logging and enable logging for all lldb-vscode tests.

Greg Clayton via lldb-commits lldb-commits at lists.llvm.org
Thu Feb 13 09:58:44 PST 2020


Author: Greg Clayton
Date: 2020-02-13T09:58:30-08:00
New Revision: 7202d1c2f6c83e989979bb76a61cbe1d0c859420

URL: https://github.com/llvm/llvm-project/commit/7202d1c2f6c83e989979bb76a61cbe1d0c859420
DIFF: https://github.com/llvm/llvm-project/commit/7202d1c2f6c83e989979bb76a61cbe1d0c859420.diff

LOG: Fix lldb-vscode logging and enable logging for all lldb-vscode tests.

Summary:
This patch fixes logging to log incoming packets which was removed during a refactor.

We also enable logging to a "vscode.txt" file for each lldb-vscode test by creating the log file in the build artifacts directory for each test. This allows users to see the packets for their tests if needed and the log file is in a directory that will be removed after tests have been run.

Reviewers: labath, aadsm, serhiy.redko, jankratochvil, xiaobai, wallace

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D74566

Added: 
    

Modified: 
    lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
    lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
    lldb/tools/lldb-vscode/VSCode.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
index 35ce7f893fd4..1eb23ce56212 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
@@ -12,8 +12,10 @@ def create_debug_adaptor(self):
         '''Create the Visual Studio Code debug adaptor'''
         self.assertTrue(os.path.exists(self.lldbVSCodeExec),
                         'lldb-vscode must exist')
+        log_file_path = self.getBuildArtifact('vscode.txt')
         self.vscode = vscode.DebugAdaptor(
-            executable=self.lldbVSCodeExec, init_commands=self.setUpCommands())
+            executable=self.lldbVSCodeExec, init_commands=self.setUpCommands(),
+            log_file=log_file_path)
 
     def build_and_create_debug_adaptor(self):
         self.build()
@@ -133,7 +135,7 @@ def get_dict_value(self, d, key_path):
                                     key, key_path, d))
         return value
 
-    def get_stackFrames_and_totalFramesCount(self, threadId=None, startFrame=None, 
+    def get_stackFrames_and_totalFramesCount(self, threadId=None, startFrame=None,
                         levels=None, dump=False):
         response = self.vscode.request_stackTrace(threadId=threadId,
                                                   startFrame=startFrame,

diff  --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
index cdb3dc115769..3cdf1ee90ccb 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
@@ -847,13 +847,17 @@ def terminate(self):
 
 
 class DebugAdaptor(DebugCommunication):
-    def __init__(self, executable=None, port=None, init_commands=[]):
+    def __init__(self, executable=None, port=None, init_commands=[], log_file=None):
         self.process = None
         if executable is not None:
+            adaptor_env = os.environ.copy()
+            if log_file:
+                adaptor_env['LLDBVSCODE_LOG'] = log_file
             self.process = subprocess.Popen([executable],
                                             stdin=subprocess.PIPE,
                                             stdout=subprocess.PIPE,
-                                            stderr=subprocess.PIPE)
+                                            stderr=subprocess.PIPE,
+                                            env=adaptor_env)
             DebugCommunication.__init__(self, self.process.stdout,
                                         self.process.stdin, init_commands)
         elif port is not None:

diff  --git a/lldb/tools/lldb-vscode/VSCode.cpp b/lldb/tools/lldb-vscode/VSCode.cpp
index ba9542a63fca..8112f4c8d0d9 100644
--- a/lldb/tools/lldb-vscode/VSCode.cpp
+++ b/lldb/tools/lldb-vscode/VSCode.cpp
@@ -129,6 +129,12 @@ std::string VSCode::ReadJSON() {
   if (!input.read_full(log.get(), length, json_str))
     return json_str;
 
+  if (log) {
+    *log << "--> " << std::endl
+         << "Content-Length: " << length << "\r\n\r\n"
+         << json_str << std::endl;
+  }
+
   return json_str;
 }
 


        


More information about the lldb-commits mailing list