[Lldb-commits] [PATCH] D74566: Fix lldb-vscode logging and enable logging for all lldb-vscode tests.

Greg Clayton via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu Feb 13 09:01:27 PST 2020


clayborg created this revision.
clayborg added reviewers: labath, aadsm, serhiy.redko, jankratochvil, xiaobai, wallace.
Herald added a project: LLDB.
clayborg added a comment.

Here is an example of where these files end up after running tests:

  $ cd lldb-test-build.noindex/
  $ find . -name vscode.txt
  ./tools/lldb-vscode/breakpoint-events/TestVSCode_breakpointEvents.test_breakpoint_events/vscode.txt
  ./tools/lldb-vscode/launch/TestVSCode_launch.test_shellExpandArguments_enabled/vscode.txt
  ./tools/lldb-vscode/launch/TestVSCode_launch.test_shellExpandArguments_disabled/vscode.txt
  ./tools/lldb-vscode/launch/TestVSCode_launch.test_stopOnEntry/vscode.txt
  ./tools/lldb-vscode/launch/TestVSCode_launch.test_commands/vscode.txt
  ./tools/lldb-vscode/launch/TestVSCode_launch.test_cwd/vscode.txt
  ./tools/lldb-vscode/launch/TestVSCode_launch.test_args/vscode.txt
  ./tools/lldb-vscode/launch/TestVSCode_launch.test_disableSTDIO/vscode.txt
  ./tools/lldb-vscode/launch/TestVSCode_launch.test_debuggerRoot/vscode.txt
  ./tools/lldb-vscode/launch/TestVSCode_launch.test_environment/vscode.txt
  ./tools/lldb-vscode/launch/TestVSCode_launch.test_extra_launch_commands/vscode.txt
  ./tools/lldb-vscode/launch/TestVSCode_launch.test_sourcePath/vscode.txt
  ./tools/lldb-vscode/step/TestVSCode_step.test_step/vscode.txt
  ./tools/lldb-vscode/breakpoint/TestVSCode_setExceptionBreakpoints.test_functionality/vscode.txt
  ./tools/lldb-vscode/breakpoint/TestVSCode_setFunctionBreakpoints.test_functionality/vscode.txt
  ./tools/lldb-vscode/breakpoint/TestVSCode_setBreakpoints.test_set_and_clear/vscode.txt
  ./tools/lldb-vscode/breakpoint/TestVSCode_setBreakpoints.test_functionality/vscode.txt
  ./tools/lldb-vscode/breakpoint/TestVSCode_setFunctionBreakpoints.test_set_and_clear/vscode.txt
  ./tools/lldb-vscode/attach/TestVSCode_attach.test_by_pid/vscode.txt
  ./tools/lldb-vscode/attach/TestVSCode_attach.test_by_name/vscode.txt
  ./tools/lldb-vscode/variables/TestVSCode_variables.test_scopes_variables_setVariable_evaluate/vscode.txt
  ./tools/lldb-vscode/stackTrace/TestVSCode_stackTrace.test_stackTrace/vscode.txt


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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74566

Files:
  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


Index: lldb/tools/lldb-vscode/VSCode.cpp
===================================================================
--- lldb/tools/lldb-vscode/VSCode.cpp
+++ lldb/tools/lldb-vscode/VSCode.cpp
@@ -129,6 +129,12 @@
   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;
 }
 
Index: lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
===================================================================
--- lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
+++ lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
@@ -847,13 +847,17 @@
 
 
 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:
Index: lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
===================================================================
--- lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
+++ lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
@@ -12,8 +12,10 @@
         '''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 @@
                                     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,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D74566.244453.patch
Type: text/x-patch
Size: 3064 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20200213/720ed1f1/attachment.bin>


More information about the lldb-commits mailing list