cmDebuggerBreakpointManager.h 1.6 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 <cstdint>
  6. #include <mutex>
  7. #include <string>
  8. #include <unordered_map>
  9. #include <unordered_set>
  10. #include <vector>
  11. #include <cm3p/cppdap/protocol.h>
  12. class cmListFileFunction;
  13. namespace cmDebugger {
  14. class cmDebuggerSourceBreakpoint;
  15. }
  16. namespace dap {
  17. class Session;
  18. }
  19. namespace cmDebugger {
  20. struct cmDebuggerFunctionLocation
  21. {
  22. int64_t StartLine;
  23. int64_t EndLine;
  24. };
  25. /** The breakpoint manager. */
  26. class cmDebuggerBreakpointManager
  27. {
  28. dap::Session* DapSession;
  29. std::mutex Mutex;
  30. std::unordered_map<std::string, std::vector<cmDebuggerSourceBreakpoint>>
  31. Breakpoints;
  32. std::unordered_map<std::string,
  33. std::vector<struct cmDebuggerFunctionLocation>>
  34. ListFileFunctionLines;
  35. std::unordered_set<std::string> ListFilePendingValidations;
  36. int64_t NextBreakpointId = 0;
  37. dap::SetBreakpointsResponse HandleSetBreakpointsRequest(
  38. dap::SetBreakpointsRequest const& request);
  39. int64_t FindFunctionStartLine(std::string const& sourcePath, int64_t line);
  40. int64_t CalibrateBreakpointLine(std::string const& sourcePath, int64_t line);
  41. public:
  42. cmDebuggerBreakpointManager(dap::Session* dapSession);
  43. void SourceFileLoaded(std::string const& sourcePath,
  44. std::vector<cmListFileFunction> const& functions);
  45. std::vector<int64_t> GetBreakpoints(std::string const& sourcePath,
  46. int64_t line);
  47. void ClearAll();
  48. };
  49. } // namespace cmDebugger