cmDebuggerBreakpointManager.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file Copyright.txt or https://cmake.org/licensing for details. */
  3. #pragma once
  4. #include "cmConfigure.h" // IWYU pragma: keep
  5. #include <cstddef>
  6. #include <cstdint>
  7. #include <mutex>
  8. #include <string>
  9. #include <unordered_map>
  10. #include <unordered_set>
  11. #include <vector>
  12. #include <cm3p/cppdap/protocol.h>
  13. #include "cmDebuggerSourceBreakpoint.h"
  14. class cmListFileFunction;
  15. namespace dap {
  16. class Session;
  17. }
  18. namespace cmDebugger {
  19. struct cmDebuggerFunctionLocation
  20. {
  21. int64_t StartLine;
  22. int64_t EndLine;
  23. };
  24. /** The breakpoint manager. */
  25. class cmDebuggerBreakpointManager
  26. {
  27. dap::Session* DapSession;
  28. std::mutex Mutex;
  29. std::unordered_map<std::string, std::vector<cmDebuggerSourceBreakpoint>>
  30. Breakpoints;
  31. std::unordered_map<std::string,
  32. std::vector<struct cmDebuggerFunctionLocation>>
  33. ListFileFunctionLines;
  34. std::unordered_set<std::string> ListFilePendingValidations;
  35. int64_t NextBreakpointId = 0;
  36. dap::SetBreakpointsResponse HandleSetBreakpointsRequest(
  37. dap::SetBreakpointsRequest const& request);
  38. int64_t FindFunctionStartLine(std::string const& sourcePath, int64_t line);
  39. int64_t CalibrateBreakpointLine(std::string const& sourcePath, int64_t line);
  40. public:
  41. cmDebuggerBreakpointManager(dap::Session* dapSession);
  42. void SourceFileLoaded(std::string const& sourcePath,
  43. std::vector<cmListFileFunction> const& functions);
  44. std::vector<int64_t> GetBreakpoints(std::string const& sourcePath,
  45. int64_t line);
  46. size_t GetBreakpointCount() const;
  47. void ClearAll();
  48. };
  49. } // namespace cmDebugger