Skip to content

Commit

Permalink
Revert "[lldb-vscode] Send Statistics Dump in terminated event"
Browse files Browse the repository at this point in the history
This reverts commit c8a26f8.

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.
  • Loading branch information
kusmour committed Oct 27, 2022
1 parent ada9ab6 commit 7bbd0fb
Show file tree
Hide file tree
Showing 9 changed files with 2 additions and 119 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
17 changes: 0 additions & 17 deletions lldb/test/API/tools/lldb-vscode/terminated-event/Makefile

This file was deleted.

This file was deleted.

3 changes: 0 additions & 3 deletions lldb/test/API/tools/lldb-vscode/terminated-event/foo.cpp

This file was deleted.

1 change: 0 additions & 1 deletion lldb/test/API/tools/lldb-vscode/terminated-event/foo.h

This file was deleted.

8 changes: 0 additions & 8 deletions lldb/test/API/tools/lldb-vscode/terminated-event/main.cpp

This file was deleted.

16 changes: 0 additions & 16 deletions lldb/tools/lldb-vscode/JSONUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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);
Expand Down
6 changes: 0 additions & 6 deletions lldb/tools/lldb-vscode/JSONUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion lldb/tools/lldb-vscode/lldb-vscode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
}
}
Expand Down

0 comments on commit 7bbd0fb

Please sign in to comment.