[Lldb-commits] [lldb] 7bbd0fb - Revert "[lldb-vscode] Send Statistics Dump in terminated event"

Wanyi Ye via lldb-commits lldb-commits at lists.llvm.org
Wed Oct 26 20:10:37 PDT 2022


Author: Wanyi Ye
Date: 2022-10-26T19:49:03-07:00
New Revision: 7bbd0fba986c241162b77b7e424ad82bc7e17b41

URL: https://github.com/llvm/llvm-project/commit/7bbd0fba986c241162b77b7e424ad82bc7e17b41
DIFF: https://github.com/llvm/llvm-project/commit/7bbd0fba986c241162b77b7e424ad82bc7e17b41.diff

LOG: Revert "[lldb-vscode] Send Statistics Dump in terminated event"

This reverts commit c8a26f8c6de30dbd814546f02e4c89a4fcb2b4ef.

Returning full statistics result in "terminated" (DAP) event could result in delay in the UI when debugging from VSCode.

If the program run to exit and debug session terminates. The DAP event order will be: exited event --> terminateCommands --> terminated event --> disconnect request --> disconnect response.

The debugging UI in VSCode corresponds to "disconnect" request/response. If the terminated event is taking long to process, the IDE won't quit debugging UI until it's done.

For big binary (tested example has 29 GB of debug info), it can cause ~15s delay in terminated event itself. And the UI could take ~20s to reflect.

This may cause confusion in debug sessions. We should persuit a more lightweight return or other solution to return such info.

Added: 
    

Modified: 
    lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
    lldb/tools/lldb-vscode/JSONUtils.cpp
    lldb/tools/lldb-vscode/JSONUtils.h
    lldb/tools/lldb-vscode/lldb-vscode.cpp

Removed: 
    lldb/test/API/tools/lldb-vscode/terminated-event/Makefile
    lldb/test/API/tools/lldb-vscode/terminated-event/TestVSCode_terminatedEvent.py
    lldb/test/API/tools/lldb-vscode/terminated-event/foo.cpp
    lldb/test/API/tools/lldb-vscode/terminated-event/foo.h
    lldb/test/API/tools/lldb-vscode/terminated-event/main.cpp


################################################################################
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 c2de4ad5c7d9a..d6a6abca53e38 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
@@ -369,13 +369,7 @@ def wait_for_stopped(self, timeout=None):
     def wait_for_exited(self):
         event_dict = self.wait_for_event('exited')
         if event_dict is None:
-            raise ValueError("didn't get exited event")
-        return event_dict
-
-    def wait_for_terminated(self):
-        event_dict = self.wait_for_event('terminated')
-        if event_dict is None:
-            raise ValueError("didn't get terminated event")
+            raise ValueError("didn't get stopped event")
         return event_dict
 
     def get_initialize_value(self, key):

diff  --git a/lldb/test/API/tools/lldb-vscode/terminated-event/Makefile b/lldb/test/API/tools/lldb-vscode/terminated-event/Makefile
deleted file mode 100644
index b30baf48b972e..0000000000000
--- a/lldb/test/API/tools/lldb-vscode/terminated-event/Makefile
+++ /dev/null
@@ -1,17 +0,0 @@
-DYLIB_NAME := foo
-DYLIB_CXX_SOURCES := foo.cpp
-CXX_SOURCES := main.cpp
-
-LD_EXTRAS := -Wl,-rpath "-Wl,$(shell pwd)"
-USE_LIBDL :=1
-
-include Makefile.rules
-
-all: a.out.stripped
-
-a.out.stripped:
-	strip -o a.out.stripped a.out
-
-ifneq "$(CODESIGN)" ""
-	$(CODESIGN) -fs - a.out.stripped
-endif
\ No newline at end of file

diff  --git a/lldb/test/API/tools/lldb-vscode/terminated-event/TestVSCode_terminatedEvent.py b/lldb/test/API/tools/lldb-vscode/terminated-event/TestVSCode_terminatedEvent.py
deleted file mode 100644
index 0a9fe6ac5a719..0000000000000
--- a/lldb/test/API/tools/lldb-vscode/terminated-event/TestVSCode_terminatedEvent.py
+++ /dev/null
@@ -1,60 +0,0 @@
-"""
-Test lldb-vscode terminated event
-"""
-
-import vscode
-from lldbsuite.test.decorators import *
-from lldbsuite.test.lldbtest import *
-from lldbsuite.test import lldbutil
-import lldbvscode_testcase
-import re
-import json
-
-class TestVSCode_terminatedEvent(lldbvscode_testcase.VSCodeTestCaseBase):
-
-    @skipIfWindows
-    @skipIfRemote
-    def test_terminated_event(self):
-        '''
-            Terminated Event
-            Now contains the statistics of a debug session:
-            metatdata:
-                totalDebugInfoByteSize > 0
-                totalDebugInfoEnabled > 0
-                totalModuleCountHasDebugInfo > 0
-                ...
-            targetInfo:
-                totalBreakpointResolveTime > 0
-            breakpoints:
-                recognize function breakpoint
-                recognize source line breakpoint
-            It should contains the breakpoints info: function bp & source line bp
-        '''
-
-        program_basename = "a.out.stripped"
-        program = self.getBuildArtifact(program_basename)
-        self.build_and_launch(program)
-        # Set breakpoints
-        functions = ['foo']
-        breakpoint_ids = self.set_function_breakpoints(functions)
-        self.assertEquals(len(breakpoint_ids), len(functions), 'expect one breakpoint')
-        main_bp_line = line_number('main.cpp', '// main breakpoint 1')
-        breakpoint_ids.append(self.set_source_breakpoints('main.cpp', [main_bp_line]))
-
-        self.continue_to_breakpoints(breakpoint_ids)
-        self.continue_to_exit()
-
-        statistics = json.loads(self.vscode.wait_for_terminated()['statistics'])
-        self.assertTrue(statistics['totalDebugInfoByteSize'] > 0)
-        self.assertTrue(statistics['totalDebugInfoEnabled'] > 0)
-        self.assertTrue(statistics['totalModuleCountHasDebugInfo'] > 0)
-
-        # lldb-vscode debugs one target at a time
-        self.assertTrue(statistics['targets'][0]['totalBreakpointResolveTime'] > 0)
-
-        breakpoints = statistics['targets'][0]['breakpoints']
-        self.assertIn('foo',
-                      breakpoints[0]['details']['Breakpoint']['BKPTResolver']['Options']['SymbolNames'],
-                      'foo is a symbol breakpoint')
-        self.assertTrue(breakpoints[1]['details']['Breakpoint']['BKPTResolver']['Options']['FileName'].endswith('main.cpp'),
-                        'target has source line breakpoint in main.cpp')

diff  --git a/lldb/test/API/tools/lldb-vscode/terminated-event/foo.cpp b/lldb/test/API/tools/lldb-vscode/terminated-event/foo.cpp
deleted file mode 100644
index 9dba85a9cccab..0000000000000
--- a/lldb/test/API/tools/lldb-vscode/terminated-event/foo.cpp
+++ /dev/null
@@ -1,3 +0,0 @@
-int foo() {
-    return 12;
-}

diff  --git a/lldb/test/API/tools/lldb-vscode/terminated-event/foo.h b/lldb/test/API/tools/lldb-vscode/terminated-event/foo.h
deleted file mode 100644
index 5d5f8f0c9e786..0000000000000
--- a/lldb/test/API/tools/lldb-vscode/terminated-event/foo.h
+++ /dev/null
@@ -1 +0,0 @@
-int foo();

diff  --git a/lldb/test/API/tools/lldb-vscode/terminated-event/main.cpp b/lldb/test/API/tools/lldb-vscode/terminated-event/main.cpp
deleted file mode 100644
index cd984e560e0d2..0000000000000
--- a/lldb/test/API/tools/lldb-vscode/terminated-event/main.cpp
+++ /dev/null
@@ -1,8 +0,0 @@
-#include <iostream>
-#include "foo.h"
-
-int main(int argc, char const *argv[]) {
-  std::cout << "Hello World!" << std::endl; // main breakpoint 1
-  foo();
-  return 0;
-}

diff  --git a/lldb/tools/lldb-vscode/JSONUtils.cpp b/lldb/tools/lldb-vscode/JSONUtils.cpp
index 14ab8181c9518..baeed2a81105c 100644
--- a/lldb/tools/lldb-vscode/JSONUtils.cpp
+++ b/lldb/tools/lldb-vscode/JSONUtils.cpp
@@ -19,7 +19,6 @@
 #include "lldb/API/SBBreakpoint.h"
 #include "lldb/API/SBBreakpointLocation.h"
 #include "lldb/API/SBDeclaration.h"
-#include "lldb/API/SBStructuredData.h"
 #include "lldb/API/SBValue.h"
 #include "lldb/Host/PosixApi.h"
 
@@ -1140,21 +1139,6 @@ CreateRunInTerminalReverseRequest(const llvm::json::Object &launch_request,
   return reverse_request;
 }
 
-llvm::json::Object CreateTerminatedEventObject() {
-  llvm::json::Object event(CreateEventObject("terminated"));
-  lldb::SBStructuredData statistics = g_vsc.target.GetStatistics();
-  bool is_dictionary =
-      statistics.GetType() == lldb::eStructuredDataTypeDictionary;
-  if (!is_dictionary) {
-    return event;
-  }
-
-  lldb::SBStream stats_stream;
-  statistics.GetAsJSON(stats_stream);
-  event.try_emplace("statistics", llvm::json::fixUTF8(stats_stream.GetData()));
-  return event;
-}
-
 std::string JSONToString(const llvm::json::Value &json) {
   std::string data;
   llvm::raw_string_ostream os(data);

diff  --git a/lldb/tools/lldb-vscode/JSONUtils.h b/lldb/tools/lldb-vscode/JSONUtils.h
index c812ec87beab0..bb81b88895938 100644
--- a/lldb/tools/lldb-vscode/JSONUtils.h
+++ b/lldb/tools/lldb-vscode/JSONUtils.h
@@ -485,12 +485,6 @@ CreateRunInTerminalReverseRequest(const llvm::json::Object &launch_request,
                                   llvm::StringRef debug_adaptor_path,
                                   llvm::StringRef comm_file);
 
-/// Create a "Terminated" JSON object that contains statistics
-///
-/// \return
-///     A body JSON object with debug info and breakpoint info
-llvm::json::Object CreateTerminatedEventObject();
-
 /// Convert a given JSON object to a string.
 std::string JSONToString(const llvm::json::Value &json);
 

diff  --git a/lldb/tools/lldb-vscode/lldb-vscode.cpp b/lldb/tools/lldb-vscode/lldb-vscode.cpp
index 3c86eb70bf8ca..1c6f9c829c388 100644
--- a/lldb/tools/lldb-vscode/lldb-vscode.cpp
+++ b/lldb/tools/lldb-vscode/lldb-vscode.cpp
@@ -204,7 +204,7 @@ void SendTerminatedEvent() {
     g_vsc.sent_terminated_event = true;
     g_vsc.RunTerminateCommands();
     // Send a "terminated" event
-    llvm::json::Object event(CreateTerminatedEventObject());
+    llvm::json::Object event(CreateEventObject("terminated"));
     g_vsc.SendJSON(llvm::json::Value(std::move(event)));
   }
 }


        


More information about the lldb-commits mailing list