Skip to content

Commit 5ab3c52

Browse files
authored
[lldb-dap] Member variable cleanup in DAP.{cpp,h} (NFC) (#140390)
- Use in-class member initialization to simplify the constructor. - Remove unimplemented SetConfigurationDone. - Consistently use Doxygen-style comments.
1 parent 61ba3e4 commit 5ab3c52

File tree

2 files changed

+40
-26
lines changed

2 files changed

+40
-26
lines changed

lldb/tools/lldb-dap/DAP.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,9 @@ llvm::StringRef DAP::debug_adapter_path = "";
118118
DAP::DAP(Log *log, const ReplMode default_repl_mode,
119119
std::vector<std::string> pre_init_commands, Transport &transport)
120120
: log(log), transport(transport), broadcaster("lldb-dap"),
121-
exception_breakpoints(), focus_tid(LLDB_INVALID_THREAD_ID),
122-
stop_at_entry(false), is_attach(false),
123-
restarting_process_id(LLDB_INVALID_PROCESS_ID), configuration_done(false),
124-
waiting_for_run_in_terminal(false),
125121
progress_event_reporter(
126122
[&](const ProgressEvent &event) { SendJSON(event.ToJSON()); }),
127-
reverse_request_seq(0), repl_mode(default_repl_mode) {
123+
repl_mode(default_repl_mode) {
128124
configuration.preInitCommands = std::move(pre_init_commands);
129125
RegisterRequests();
130126
}

lldb/tools/lldb-dap/DAP.h

Lines changed: 39 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -162,50 +162,70 @@ struct DAP {
162162
lldb::SBFile in;
163163
OutputRedirector out;
164164
OutputRedirector err;
165+
165166
/// Configuration specified by the launch or attach commands.
166167
protocol::Configuration configuration;
168+
169+
/// The debugger instance for this DAP session.
167170
lldb::SBDebugger debugger;
171+
172+
/// The target instance for this DAP session.
168173
lldb::SBTarget target;
174+
169175
Variables variables;
170176
lldb::SBBroadcaster broadcaster;
171177
llvm::StringMap<SourceBreakpointMap> source_breakpoints;
172178
FunctionBreakpointMap function_breakpoints;
173179
InstructionBreakpointMap instruction_breakpoints;
174180
std::optional<std::vector<ExceptionBreakpoint>> exception_breakpoints;
175181
llvm::once_flag init_exception_breakpoints_flag;
176-
// Map step in target id to list of function targets that user can choose.
182+
183+
/// Map step in target id to list of function targets that user can choose.
177184
llvm::DenseMap<lldb::addr_t, std::string> step_in_targets;
178-
// A copy of the last LaunchRequest so we can reuse its arguments if we get a
179-
// RestartRequest. Restarting an AttachRequest is not supported.
185+
186+
/// A copy of the last LaunchRequest so we can reuse its arguments if we get a
187+
/// RestartRequest. Restarting an AttachRequest is not supported.
180188
std::optional<protocol::LaunchRequestArguments> last_launch_request;
181-
lldb::tid_t focus_tid;
189+
190+
/// The focused thread for this DAP session.
191+
lldb::tid_t focus_tid = LLDB_INVALID_THREAD_ID;
192+
182193
bool disconnecting = false;
183194
llvm::once_flag terminated_event_flag;
184-
bool stop_at_entry;
185-
bool is_attach;
186-
// The process event thread normally responds to process exited events by
187-
// shutting down the entire adapter. When we're restarting, we keep the id of
188-
// the old process here so we can detect this case and keep running.
189-
lldb::pid_t restarting_process_id;
195+
bool stop_at_entry = false;
196+
bool is_attach = false;
197+
198+
/// The process event thread normally responds to process exited events by
199+
/// shutting down the entire adapter. When we're restarting, we keep the id of
200+
/// the old process here so we can detect this case and keep running.
201+
lldb::pid_t restarting_process_id = LLDB_INVALID_PROCESS_ID;
202+
203+
/// Whether we have received the ConfigurationDone request, indicating that
204+
/// the client has finished initialization of the debug adapter.
190205
bool configuration_done;
191-
bool waiting_for_run_in_terminal;
206+
207+
bool waiting_for_run_in_terminal = false;
192208
ProgressEventReporter progress_event_reporter;
193-
// Keep track of the last stop thread index IDs as threads won't go away
194-
// unless we send a "thread" event to indicate the thread exited.
209+
210+
/// Keep track of the last stop thread index IDs as threads won't go away
211+
/// unless we send a "thread" event to indicate the thread exited.
195212
llvm::DenseSet<lldb::tid_t> thread_ids;
196-
uint32_t reverse_request_seq;
213+
214+
uint32_t reverse_request_seq = 0;
197215
std::mutex call_mutex;
198216
llvm::SmallDenseMap<int64_t, std::unique_ptr<ResponseHandler>>
199217
inflight_reverse_requests;
200218
ReplMode repl_mode;
201219
lldb::SBFormat frame_format;
202220
lldb::SBFormat thread_format;
203-
// This is used to allow request_evaluate to handle empty expressions
204-
// (ie the user pressed 'return' and expects the previous expression to
205-
// repeat). If the previous expression was a command, this string will be
206-
// empty; if the previous expression was a variable expression, this string
207-
// will contain that expression.
221+
222+
/// This is used to allow request_evaluate to handle empty expressions
223+
/// (ie the user pressed 'return' and expects the previous expression to
224+
/// repeat). If the previous expression was a command, this string will be
225+
/// empty; if the previous expression was a variable expression, this string
226+
/// will contain that expression.
208227
std::string last_nonempty_var_expression;
228+
209229
/// The set of features supported by the connected client.
210230
llvm::DenseSet<ClientFeature> clientFeatures;
211231

@@ -257,8 +277,6 @@ struct DAP {
257277
/// Configures the debug adapter for launching/attaching.
258278
void SetConfiguration(const protocol::Configuration &confing, bool is_attach);
259279

260-
void SetConfigurationDone();
261-
262280
/// Configure source maps based on the current `DAPConfiguration`.
263281
void ConfigureSourceMaps();
264282

0 commit comments

Comments
 (0)