Skip to content

Commit b9713bb

Browse files
committed
Addressing review feedback.
1 parent 8591c84 commit b9713bb

File tree

6 files changed

+20
-23
lines changed

6 files changed

+20
-23
lines changed

lldb/test/API/tools/lldb-dap/server/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
int main(int argc, char const *argv[]) {
44
printf("hello world!\n"); // breakpoint 1
55
return 0;
6-
}
6+
}

lldb/tools/lldb-dap/DAP.cpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
#include <chrono>
1010
#include <cstdarg>
11-
#include <fstream>
1211
#include <mutex>
1312

1413
#include "DAP.h"
@@ -35,8 +34,8 @@ using namespace lldb_dap;
3534

3635
namespace lldb_dap {
3736

38-
DAP::DAP(llvm::StringRef path, std::shared_ptr<llvm::raw_ostream> log,
39-
ReplMode repl_mode, std::vector<std::string> pre_init_commands)
37+
DAP::DAP(llvm::StringRef path, llvm::raw_ostream *log, ReplMode repl_mode,
38+
std::vector<std::string> pre_init_commands)
4039
: debug_adaptor_path(path), broadcaster("lldb-dap"), log(log),
4140
exception_breakpoints(), pre_init_commands(pre_init_commands),
4241
focus_tid(LLDB_INVALID_THREAD_ID), stop_at_entry(false), is_attach(false),
@@ -220,19 +219,19 @@ std::string DAP::ReadJSON() {
220219
std::string json_str;
221220
int length;
222221

223-
if (!input.read_expected(log.get(), "Content-Length: "))
222+
if (!input.read_expected(log, "Content-Length: "))
224223
return json_str;
225224

226-
if (!input.read_line(log.get(), length_str))
225+
if (!input.read_line(log, length_str))
227226
return json_str;
228227

229228
if (!llvm::to_integer(length_str, length))
230229
return json_str;
231230

232-
if (!input.read_expected(log.get(), "\r\n"))
231+
if (!input.read_expected(log, "\r\n"))
233232
return json_str;
234233

235-
if (!input.read_full(log.get(), length, json_str))
234+
if (!input.read_full(log, length, json_str))
236235
return json_str;
237236

238237
if (log) {
@@ -685,9 +684,8 @@ PacketStatus DAP::GetNextObject(llvm::json::Object &object) {
685684
return PacketStatus::JSONMalformed;
686685
}
687686

688-
if (log) {
687+
if (log)
689688
*log << llvm::formatv("{0:2}", *json_value).str() << "\n";
690-
}
691689

692690
llvm::json::Object *object_ptr = json_value->getAsObject();
693691
if (!object_ptr) {

lldb/tools/lldb-dap/DAP.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
#include "llvm/Support/JSON.h"
3333
#include "llvm/Support/Threading.h"
3434
#include "llvm/Support/raw_ostream.h"
35-
#include <iosfwd>
3635
#include <map>
3736
#include <optional>
3837
#include <thread>
@@ -146,7 +145,7 @@ struct DAP {
146145
lldb::SBBroadcaster broadcaster;
147146
std::thread event_thread;
148147
std::thread progress_event_thread;
149-
std::shared_ptr<llvm::raw_ostream> log;
148+
llvm::raw_ostream *log;
150149
llvm::StringMap<SourceBreakpointMap> source_breakpoints;
151150
FunctionBreakpointMap function_breakpoints;
152151
InstructionBreakpointMap instruction_breakpoints;
@@ -198,8 +197,8 @@ struct DAP {
198197
// will contain that expression.
199198
std::string last_nonempty_var_expression;
200199

201-
DAP(llvm::StringRef path, std::shared_ptr<llvm::raw_ostream> log,
202-
ReplMode repl_mode, std::vector<std::string> pre_init_commands);
200+
DAP(llvm::StringRef path, llvm::raw_ostream *log, ReplMode repl_mode,
201+
std::vector<std::string> pre_init_commands);
203202
~DAP();
204203

205204
DAP() = delete;

lldb/tools/lldb-dap/IOStream.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
//===----------------------------------------------------------------------===//
88

99
#include "IOStream.h"
10-
#include <string>
1110
#include "llvm/Support/raw_ostream.h"
11+
#include <string>
1212

1313
#if defined(_WIN32)
1414
#include <io.h>
@@ -18,7 +18,6 @@
1818
#include <unistd.h>
1919
#endif
2020

21-
2221
using namespace lldb_dap;
2322

2423
StreamDescriptor::StreamDescriptor() = default;
@@ -144,7 +143,8 @@ bool InputStream::read_line(llvm::raw_ostream *log, std::string &line) {
144143
return true;
145144
}
146145

147-
bool InputStream::read_expected(llvm::raw_ostream *log, llvm::StringRef expected) {
146+
bool InputStream::read_expected(llvm::raw_ostream *log,
147+
llvm::StringRef expected) {
148148
std::string result;
149149
if (!read_full(log, expected.size(), result))
150150
return false;

lldb/tools/lldb-dap/IOStream.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ typedef int SOCKET;
2323

2424
#include "llvm/ADT/StringRef.h"
2525
#include "llvm/Support/raw_ostream.h"
26-
#include <fstream>
2726
#include <string>
2827

2928
// Windows requires different system calls for dealing with sockets and other

lldb/tools/lldb-dap/lldb-dap.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4968,10 +4968,10 @@ int main(int argc, char *argv[]) {
49684968
}
49694969

49704970
const char *log_file_path = getenv("LLDBDAP_LOG");
4971-
std::shared_ptr<llvm::raw_ostream> log;
4971+
llvm::raw_ostream *log;
49724972
if (log_file_path) {
49734973
std::error_code EC;
4974-
log.reset(new llvm::raw_fd_ostream(log_file_path, EC));
4974+
log = new llvm::raw_fd_ostream(log_file_path, EC);
49754975
if (EC) {
49764976
llvm::errs() << "Could not open log file: " << EC.message() << ", "
49774977
<< log_file_path << '\n';
@@ -5028,7 +5028,8 @@ int main(int argc, char *argv[]) {
50285028

50295029
llvm::outs() << "Listening for: "
50305030
<< llvm::join(*maybeListenerAddresses, ", ") << "\n";
5031-
// Ensure listening address are flushed for calles to retrieve the resolve address.
5031+
// Ensure listening address are flushed for calles to retrieve the resolve
5032+
// address.
50325033
llvm::outs().flush();
50335034

50345035
while (g_listener && g_listener->isListening()) {
@@ -5100,8 +5101,8 @@ int main(int argc, char *argv[]) {
51005101

51015102
bool CleanExit = true;
51025103
if (auto Err = dap.Loop()) {
5103-
if (dap.log)
5104-
*dap.log << "Transport Error: " << Err << "\n";
5104+
if (log)
5105+
*log << "Transport Error: " << Err << "\n";
51055106
CleanExit = false;
51065107
}
51075108

0 commit comments

Comments
 (0)