Coverage Report

Created: 2026-02-09 06:05

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/CMake/Source/cmDebuggerAdapter.h
Line
Count
Source
1
/* Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
2
   file LICENSE.rst or https://cmake.org/licensing for details.  */
3
#pragma once
4
5
#include "cmConfigure.h" // IWYU pragma: keep
6
7
#include <atomic>
8
#include <cstdint>
9
#include <memory>
10
#include <mutex>
11
#include <string>
12
#include <thread>
13
#include <vector>
14
15
#include <cm/optional>
16
17
#include <cm3p/cppdap/io.h> // IWYU pragma: keep
18
19
#include "cmMessageType.h" // IWYU pragma: keep
20
21
class cmListFileFunction;
22
class cmMakefile;
23
24
namespace cmDebugger {
25
class Semaphore;
26
class SyncEvent;
27
class cmDebuggerBreakpointManager;
28
class cmDebuggerExceptionManager;
29
class cmDebuggerThread;
30
class cmDebuggerThreadManager;
31
}
32
33
namespace dap {
34
class Session;
35
}
36
37
namespace cmDebugger {
38
39
class cmDebuggerConnection
40
{
41
public:
42
0
  virtual ~cmDebuggerConnection() = default;
43
  virtual bool StartListening(std::string& errorMessage) = 0;
44
  virtual void WaitForConnection() = 0;
45
  virtual std::shared_ptr<dap::Reader> GetReader() = 0;
46
  virtual std::shared_ptr<dap::Writer> GetWriter() = 0;
47
};
48
49
class cmDebuggerAdapter
50
{
51
public:
52
  cmDebuggerAdapter(std::shared_ptr<cmDebuggerConnection> connection,
53
                    std::string const& dapLogPath);
54
  cmDebuggerAdapter(std::shared_ptr<cmDebuggerConnection> connection,
55
                    cm::optional<std::shared_ptr<dap::Writer>> logger);
56
  ~cmDebuggerAdapter();
57
58
  void ReportExitCode(int exitCode);
59
60
  void OnFileParsedSuccessfully(
61
    std::string const& sourcePath,
62
    std::vector<cmListFileFunction> const& functions);
63
  void OnBeginFunctionCall(cmMakefile* mf, std::string const& sourcePath,
64
                           cmListFileFunction const& lff);
65
  void OnEndFunctionCall();
66
  void OnBeginFileParse(cmMakefile* mf, std::string const& sourcePath);
67
  void OnEndFileParse();
68
69
  void OnMessageOutput(MessageType t, std::string const& text);
70
71
private:
72
  void ClearStepRequests();
73
  std::shared_ptr<cmDebuggerConnection> Connection;
74
  std::unique_ptr<dap::Session> Session;
75
  std::shared_ptr<dap::Writer> SessionLog;
76
  std::thread SessionThread;
77
  std::atomic<bool> SessionActive;
78
  std::mutex Mutex;
79
  std::unique_ptr<SyncEvent> DisconnectEvent;
80
  std::unique_ptr<SyncEvent> ConfigurationDoneEvent;
81
  std::unique_ptr<Semaphore> ContinueSem;
82
  std::atomic<int64_t> NextStepFrom;
83
  std::atomic<bool> StepInRequest;
84
  std::atomic<int64_t> StepOutDepth;
85
  std::atomic<bool> PauseRequest;
86
  std::unique_ptr<cmDebuggerThreadManager> ThreadManager;
87
  std::shared_ptr<cmDebuggerThread> DefaultThread;
88
  std::unique_ptr<cmDebuggerBreakpointManager> BreakpointManager;
89
  std::unique_ptr<cmDebuggerExceptionManager> ExceptionManager;
90
  bool SupportsVariableType;
91
};
92
93
} // namespace cmDebugger