diff options
author | Glen Chung <kuchung@microsoft.com> | 2023-03-16 00:50:08 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2023-05-30 13:46:12 (GMT) |
commit | a9a592f96e6498da302f8e968be1db0ad3c32123 (patch) | |
tree | 0d75f16ee2eae99b1a3f063e575b3f5f8f2ee931 /Source/cmDebuggerAdapter.h | |
parent | b0d1ddb7234950374977b83f8dbded806c15b356 (diff) | |
download | CMake-a9a592f96e6498da302f8e968be1db0ad3c32123.zip CMake-a9a592f96e6498da302f8e968be1db0ad3c32123.tar.gz CMake-a9a592f96e6498da302f8e968be1db0ad3c32123.tar.bz2 |
cmake: Add debugger
- Depends on cppdap and jsoncpp.
- Add --debugger argument to enable the Debugger.
- Add --debugger-pipe argument for DAP traffics over named pipes.
- Support breakpoints by filenames and line numbers.
- Support exception breakpoints.
- Call stack shows filenames and line numbers.
- Show Cache Variables.
- Show the state of currently defined targets,
tests and directories with their properties.
- Add cmakeVersion to DAP initialize response.
- Include unit tests.
Co-authored-by: Ben McMorran <bemcmorr@microsoft.com>
Diffstat (limited to 'Source/cmDebuggerAdapter.h')
-rw-r--r-- | Source/cmDebuggerAdapter.h | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/Source/cmDebuggerAdapter.h b/Source/cmDebuggerAdapter.h new file mode 100644 index 0000000..f261d88 --- /dev/null +++ b/Source/cmDebuggerAdapter.h @@ -0,0 +1,93 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ +#pragma once + +#include "cmConfigure.h" // IWYU pragma: keep + +#include <atomic> +#include <cstdint> +#include <memory> +#include <mutex> +#include <string> +#include <thread> +#include <vector> + +#include <cm/optional> + +#include <cm3p/cppdap/io.h> // IWYU pragma: keep + +#include "cmMessageType.h" + +class cmListFileFunction; +class cmMakefile; + +namespace cmDebugger { +class Semaphore; +class SyncEvent; +class cmDebuggerBreakpointManager; +class cmDebuggerExceptionManager; +class cmDebuggerThread; +class cmDebuggerThreadManager; +} + +namespace dap { +class Session; +} + +namespace cmDebugger { + +class cmDebuggerConnection +{ +public: + virtual ~cmDebuggerConnection() = default; + virtual bool StartListening(std::string& errorMessage) = 0; + virtual void WaitForConnection() = 0; + virtual std::shared_ptr<dap::Reader> GetReader() = 0; + virtual std::shared_ptr<dap::Writer> GetWriter() = 0; +}; + +class cmDebuggerAdapter +{ +public: + cmDebuggerAdapter(std::shared_ptr<cmDebuggerConnection> connection, + std::string const& dapLogPath); + cmDebuggerAdapter(std::shared_ptr<cmDebuggerConnection> connection, + cm::optional<std::shared_ptr<dap::Writer>> logger); + ~cmDebuggerAdapter(); + + void ReportExitCode(int exitCode); + + void OnFileParsedSuccessfully( + std::string const& sourcePath, + std::vector<cmListFileFunction> const& functions); + void OnBeginFunctionCall(cmMakefile* mf, std::string const& sourcePath, + cmListFileFunction const& lff); + void OnEndFunctionCall(); + void OnBeginFileParse(cmMakefile* mf, std::string const& sourcePath); + void OnEndFileParse(); + + void OnMessageOutput(MessageType t, std::string const& text); + +private: + void ClearStepRequests(); + std::shared_ptr<cmDebuggerConnection> Connection; + std::unique_ptr<dap::Session> Session; + std::shared_ptr<dap::Writer> SessionLog; + std::thread SessionThread; + std::atomic<bool> SessionActive; + std::mutex Mutex; + std::unique_ptr<SyncEvent> DisconnectEvent; + std::unique_ptr<SyncEvent> ConfigurationDoneEvent; + std::unique_ptr<Semaphore> ContinueSem; + std::atomic<int64_t> NextStepFrom; + std::atomic<bool> StepInRequest; + std::atomic<int64_t> StepOutDepth; + std::atomic<bool> PauseRequest; + std::unique_ptr<cmDebuggerThreadManager> ThreadManager; + std::shared_ptr<cmDebuggerThread> DefaultThread; + std::unique_ptr<cmDebuggerBreakpointManager> BreakpointManager; + std::unique_ptr<cmDebuggerExceptionManager> ExceptionManager; + bool SupportsVariableType; +}; + +} // namespace cmDebugger |