Skip to content

[lldb-dap] Member variable cleanup in DAP.{cpp,h} (NFC) #140390

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 18, 2025

Conversation

JDevlieghere
Copy link
Member

  • Use in-class member initialization to simplify the constructor.
  • Remove unimplemented SetConfigurationDone.
  • Consistently use Doxygen-style comments.

- Use in-class member initialization to simplify the constructor.
- Remove unimplemented SetConfigurationDone.
- Consistently use Doxygen-style comments.
@llvmbot
Copy link
Member

llvmbot commented May 17, 2025

@llvm/pr-subscribers-lldb

Author: Jonas Devlieghere (JDevlieghere)

Changes
  • Use in-class member initialization to simplify the constructor.
  • Remove unimplemented SetConfigurationDone.
  • Consistently use Doxygen-style comments.

Full diff: https://github.com/llvm/llvm-project/pull/140390.diff

2 Files Affected:

  • (modified) lldb/tools/lldb-dap/DAP.cpp (+1-5)
  • (modified) lldb/tools/lldb-dap/DAP.h (+39-21)
diff --git a/lldb/tools/lldb-dap/DAP.cpp b/lldb/tools/lldb-dap/DAP.cpp
index 0d5eba6c40961..d813cdb0b9074 100644
--- a/lldb/tools/lldb-dap/DAP.cpp
+++ b/lldb/tools/lldb-dap/DAP.cpp
@@ -118,13 +118,9 @@ llvm::StringRef DAP::debug_adapter_path = "";
 DAP::DAP(Log *log, const ReplMode default_repl_mode,
          std::vector<std::string> pre_init_commands, Transport &transport)
     : log(log), transport(transport), broadcaster("lldb-dap"),
-      exception_breakpoints(), focus_tid(LLDB_INVALID_THREAD_ID),
-      stop_at_entry(false), is_attach(false),
-      restarting_process_id(LLDB_INVALID_PROCESS_ID), configuration_done(false),
-      waiting_for_run_in_terminal(false),
       progress_event_reporter(
           [&](const ProgressEvent &event) { SendJSON(event.ToJSON()); }),
-      reverse_request_seq(0), repl_mode(default_repl_mode) {
+      repl_mode(default_repl_mode) {
   configuration.preInitCommands = std::move(pre_init_commands);
   RegisterRequests();
 }
diff --git a/lldb/tools/lldb-dap/DAP.h b/lldb/tools/lldb-dap/DAP.h
index 8f24c6cf82924..975e2b290e1f9 100644
--- a/lldb/tools/lldb-dap/DAP.h
+++ b/lldb/tools/lldb-dap/DAP.h
@@ -162,10 +162,16 @@ struct DAP {
   lldb::SBFile in;
   OutputRedirector out;
   OutputRedirector err;
+
   /// Configuration specified by the launch or attach commands.
   protocol::Configuration configuration;
+
+  /// The debugger instance for this DAP session.
   lldb::SBDebugger debugger;
+
+  /// The target instance for this DAP session.
   lldb::SBTarget target;
+
   Variables variables;
   lldb::SBBroadcaster broadcaster;
   llvm::StringMap<SourceBreakpointMap> source_breakpoints;
@@ -173,39 +179,53 @@ struct DAP {
   InstructionBreakpointMap instruction_breakpoints;
   std::optional<std::vector<ExceptionBreakpoint>> exception_breakpoints;
   llvm::once_flag init_exception_breakpoints_flag;
-  // Map step in target id to list of function targets that user can choose.
+
+  /// Map step in target id to list of function targets that user can choose.
   llvm::DenseMap<lldb::addr_t, std::string> step_in_targets;
-  // A copy of the last LaunchRequest so we can reuse its arguments if we get a
-  // RestartRequest. Restarting an AttachRequest is not supported.
+
+  /// A copy of the last LaunchRequest so we can reuse its arguments if we get a
+  /// RestartRequest. Restarting an AttachRequest is not supported.
   std::optional<protocol::LaunchRequestArguments> last_launch_request;
-  lldb::tid_t focus_tid;
+
+  /// The focused thread for this DAP session.
+  lldb::tid_t focus_tid = LLDB_INVALID_THREAD_ID;
+
   bool disconnecting = false;
   llvm::once_flag terminated_event_flag;
-  bool stop_at_entry;
-  bool is_attach;
-  // The process event thread normally responds to process exited events by
-  // shutting down the entire adapter. When we're restarting, we keep the id of
-  // the old process here so we can detect this case and keep running.
-  lldb::pid_t restarting_process_id;
+  bool stop_at_entry = false;
+  bool is_attach = false;
+
+  /// The process event thread normally responds to process exited events by
+  /// shutting down the entire adapter. When we're restarting, we keep the id of
+  /// the old process here so we can detect this case and keep running.
+  lldb::pid_t restarting_process_id = LLDB_INVALID_PROCESS_ID;
+
+  /// Whether we have received the ConfigurationDone request, indicating that
+  /// the client has finished initialization of the debug adapter.
   bool configuration_done;
-  bool waiting_for_run_in_terminal;
+
+  bool waiting_for_run_in_terminal = false;
   ProgressEventReporter progress_event_reporter;
-  // Keep track of the last stop thread index IDs as threads won't go away
-  // unless we send a "thread" event to indicate the thread exited.
+
+  /// Keep track of the last stop thread index IDs as threads won't go away
+  /// unless we send a "thread" event to indicate the thread exited.
   llvm::DenseSet<lldb::tid_t> thread_ids;
-  uint32_t reverse_request_seq;
+
+  uint32_t reverse_request_seq = 0;
   std::mutex call_mutex;
   llvm::SmallDenseMap<int64_t, std::unique_ptr<ResponseHandler>>
       inflight_reverse_requests;
   ReplMode repl_mode;
   lldb::SBFormat frame_format;
   lldb::SBFormat thread_format;
-  // This is used to allow request_evaluate to handle empty expressions
-  // (ie the user pressed 'return' and expects the previous expression to
-  // repeat). If the previous expression was a command, this string will be
-  // empty; if the previous expression was a variable expression, this string
-  // will contain that expression.
+
+  /// This is used to allow request_evaluate to handle empty expressions
+  /// (ie the user pressed 'return' and expects the previous expression to
+  /// repeat). If the previous expression was a command, this string will be
+  /// empty; if the previous expression was a variable expression, this string
+  /// will contain that expression.
   std::string last_nonempty_var_expression;
+
   /// The set of features supported by the connected client.
   llvm::DenseSet<ClientFeature> clientFeatures;
 
@@ -257,8 +277,6 @@ struct DAP {
   /// Configures the debug adapter for launching/attaching.
   void SetConfiguration(const protocol::Configuration &confing, bool is_attach);
 
-  void SetConfigurationDone();
-
   /// Configure source maps based on the current `DAPConfiguration`.
   void ConfigureSourceMaps();
 

@JDevlieghere JDevlieghere merged commit 5ab3c52 into llvm:main May 18, 2025
13 checks passed
@JDevlieghere JDevlieghere deleted the lldb-dap-gardening branch May 18, 2025 17:23
@llvm-ci
Copy link
Collaborator

llvm-ci commented May 18, 2025

LLVM Buildbot has detected a new failure on builder lldb-remote-linux-win running on as-builder-10 while building lldb at step 17 "test-check-lldb-api".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/197/builds/5499

Here is the relevant piece of the build log for the reference
Step 17 (test-check-lldb-api) failure: Test just built components: check-lldb-api completed (failure)
******************** TEST 'lldb-api :: commands/source/info/TestSourceInfo.py' FAILED ********************
Script:
--
C:/Python312/python.exe C:/buildbot/as-builder-10/lldb-x-aarch64/llvm-project/lldb\test\API\dotest.py -u CXXFLAGS -u CFLAGS --env LLVM_LIBS_DIR=C:/buildbot/as-builder-10/lldb-x-aarch64/build/./lib --env LLVM_INCLUDE_DIR=C:/buildbot/as-builder-10/lldb-x-aarch64/build/include --env LLVM_TOOLS_DIR=C:/buildbot/as-builder-10/lldb-x-aarch64/build/./bin --arch aarch64 --build-dir C:/buildbot/as-builder-10/lldb-x-aarch64/build/lldb-test-build.noindex --lldb-module-cache-dir C:/buildbot/as-builder-10/lldb-x-aarch64/build/lldb-test-build.noindex/module-cache-lldb\lldb-api --clang-module-cache-dir C:/buildbot/as-builder-10/lldb-x-aarch64/build/lldb-test-build.noindex/module-cache-clang\lldb-api --executable C:/buildbot/as-builder-10/lldb-x-aarch64/build/./bin/lldb.exe --compiler C:/buildbot/as-builder-10/lldb-x-aarch64/build/./bin/clang.exe --dsymutil C:/buildbot/as-builder-10/lldb-x-aarch64/build/./bin/dsymutil.exe --make C:/ninja/make.exe --llvm-tools-dir C:/buildbot/as-builder-10/lldb-x-aarch64/build/./bin --lldb-obj-root C:/buildbot/as-builder-10/lldb-x-aarch64/build/tools/lldb --lldb-libs-dir C:/buildbot/as-builder-10/lldb-x-aarch64/build/./lib --platform-url connect://jetson-agx-0086.lab.llvm.org:1234 --platform-working-dir /home/ubuntu/lldb-tests --sysroot c:/buildbot/fs/jetson-agx-ubuntu --env ARCH_CFLAGS=-mcpu=cortex-a78 --platform-name remote-linux --skip-category=lldb-server C:\buildbot\as-builder-10\lldb-x-aarch64\llvm-project\lldb\test\API\commands\source\info -p TestSourceInfo.py
--
Exit Code: 3221226356

Command Output (stdout):
--
lldb version 21.0.0git (https://github.com/llvm/llvm-project.git revision 5ab3c5215688f62dbc3707f0e9cc2e8b69c0a7f0)
  clang revision 5ab3c5215688f62dbc3707f0e9cc2e8b69c0a7f0
  llvm revision 5ab3c5215688f62dbc3707f0e9cc2e8b69c0a7f0
Setting up remote platform 'remote-linux'

Connecting to remote platform 'remote-linux' at 'connect://jetson-agx-0086.lab.llvm.org:1234'...

Connected.

Setting remote platform working directory to '/home/ubuntu/lldb-tests'...

Skipping the following test categories: ['lldb-server', 'dsym', 'gmodules', 'debugserver', 'objc', 'lldb-dap']


--
Command Output (stderr):
--
UNSUPPORTED: LLDB (C:\buildbot\as-builder-10\lldb-x-aarch64\build\bin\clang.exe-aarch64) :: test_dsym (lldbsuite.test.lldbtest.TestSourceInfo.test_dsym) (test case does not fall in any category of interest for this run) 

PASS: LLDB (C:\buildbot\as-builder-10\lldb-x-aarch64\build\bin\clang.exe-aarch64) :: test_dwarf (lldbsuite.test.lldbtest.TestSourceInfo.test_dwarf)

PASS: LLDB (C:\buildbot\as-builder-10\lldb-x-aarch64\build\bin\clang.exe-aarch64) :: test_dwo (lldbsuite.test.lldbtest.TestSourceInfo.test_dwo)

----------------------------------------------------------------------

Ran 3 tests in 1.294s



OK (skipped=1)

Windows fatal exception: code 0xc0000374

Current thread 0x00003284 (most recent call first):
  <no Python frame>

--

********************


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants