Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions lldb/tools/lldb-dap/DAP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,18 @@ using namespace lldb_dap;

namespace lldb_dap {

DAP g_dap;

DAP::DAP()
: broadcaster("lldb-dap"), exception_breakpoints(),
focus_tid(LLDB_INVALID_THREAD_ID), stop_at_entry(false), is_attach(false),
DAP::DAP(llvm::StringRef path, ReplMode repl_mode)
: debug_adaptor_path(path), broadcaster("lldb-dap"),
exception_breakpoints(), focus_tid(LLDB_INVALID_THREAD_ID),
stop_at_entry(false), is_attach(false),
enable_auto_variable_summaries(false),
enable_synthetic_child_debugging(false),
display_extended_backtrace(false),
restarting_process_id(LLDB_INVALID_PROCESS_ID),
configuration_done_sent(false), waiting_for_run_in_terminal(false),
progress_event_reporter(
[&](const ProgressEvent &event) { SendJSON(event.ToJSON()); }),
reverse_request_seq(0), repl_mode(ReplMode::Auto) {
reverse_request_seq(0), repl_mode(repl_mode) {
const char *log_file_path = getenv("LLDBDAP_LOG");
#if defined(_WIN32)
// Windows opens stdout and stdin in text mode which converts \n to 13,10
Expand Down Expand Up @@ -693,15 +692,15 @@ bool DAP::HandleObject(const llvm::json::Object &object) {
if (packet_type == "request") {
const auto command = GetString(object, "command");
auto handler_pos = request_handlers.find(command);
if (handler_pos != request_handlers.end()) {
handler_pos->second(object);
return true; // Success
} else {
if (handler_pos == request_handlers.end()) {
if (log)
*log << "error: unhandled command \"" << command.data() << "\""
<< std::endl;
return false; // Fail
}

handler_pos->second(*this, object);
return true; // Success
}

if (packet_type == "response") {
Expand Down
8 changes: 3 additions & 5 deletions lldb/tools/lldb-dap/DAP.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ enum DAPBroadcasterBits {
eBroadcastBitStopProgressThread = 1u << 1
};

typedef void (*RequestCallback)(const llvm::json::Object &command);
typedef void (*RequestCallback)(DAP &dap, const llvm::json::Object &command);
typedef void (*ResponseCallback)(llvm::Expected<llvm::json::Value> value);

enum class PacketStatus {
Expand Down Expand Up @@ -137,7 +137,7 @@ struct SendEventRequestHandler : public lldb::SBCommandPluginInterface {
};

struct DAP {
std::string debug_adaptor_path;
llvm::StringRef debug_adaptor_path;
InputStream input;
OutputStream output;
lldb::SBDebugger debugger;
Expand Down Expand Up @@ -198,7 +198,7 @@ struct DAP {
// will contain that expression.
std::string last_nonempty_var_expression;

DAP();
DAP(llvm::StringRef path, ReplMode repl_mode);
~DAP();
DAP(const DAP &rhs) = delete;
void operator=(const DAP &rhs) = delete;
Expand Down Expand Up @@ -353,8 +353,6 @@ struct DAP {
void SendJSON(const std::string &json_str);
};

extern DAP g_dap;

} // namespace lldb_dap

#endif
Loading
Loading