| 66 | } |
| 67 | |
| 68 | dap::SetBreakpointsResponse |
| 69 | cmDebuggerBreakpointManager::HandleSetBreakpointsRequest( |
| 70 | dap::SetBreakpointsRequest const& request) |
| 71 | { |
| 72 | std::unique_lock<std::mutex> lock(Mutex); |
| 73 | |
| 74 | dap::SetBreakpointsResponse response; |
| 75 | |
| 76 | auto sourcePath = |
| 77 | cmSystemTools::GetActualCaseForPath(request.source.path.value()); |
| 78 | dap::array<dap::SourceBreakpoint> const defaultValue{}; |
| 79 | auto const& breakpoints = request.breakpoints.value(defaultValue); |
| 80 | |
| 81 | if (Breakpoints.find(sourcePath) != Breakpoints.end()) { |
| 82 | Breakpoints[sourcePath].clear(); |
| 83 | } |
| 84 | response.breakpoints.resize(breakpoints.size()); |
| 85 | |
| 86 | if (ListFileFunctionLines.find(sourcePath) != ListFileFunctionLines.end()) { |
| 87 | // The file has loaded, we can validate breakpoints. |
| 88 | for (size_t i = 0; i < breakpoints.size(); i++) { |
| 89 | int64_t correctedLine = |
| 90 | CalibrateBreakpointLine(sourcePath, breakpoints[i].line); |
| 91 | if (correctedLine > 0) { |
| 92 | Breakpoints[sourcePath].emplace_back(NextBreakpointId++, |
| 93 | correctedLine); |
| 94 | response.breakpoints[i].id = Breakpoints[sourcePath].back().GetId(); |
| 95 | response.breakpoints[i].line = |
| 96 | Breakpoints[sourcePath].back().GetLine(); |
| 97 | response.breakpoints[i].verified = true; |
| 98 | } else { |
| 99 | response.breakpoints[i].verified = false; |
| 100 | response.breakpoints[i].line = breakpoints[i].line; |
| 101 | } |
| 102 | dap::Source dapSrc; |
| 103 | dapSrc.path = sourcePath; |
| 104 | response.breakpoints[i].source = dapSrc; |
| 105 | } |
| 106 | } else { |
| 107 | // The file has not loaded, validate breakpoints later. |
| 108 | ListFilePendingValidations.emplace(sourcePath); |
| 109 | |
| 110 | for (size_t i = 0; i < breakpoints.size(); i++) { |
| 111 | Breakpoints[sourcePath].emplace_back(NextBreakpointId++, |
| 112 | breakpoints[i].line); |
| 113 | response.breakpoints[i].id = Breakpoints[sourcePath].back().GetId(); |
| 114 | response.breakpoints[i].line = Breakpoints[sourcePath].back().GetLine(); |
| 115 | response.breakpoints[i].verified = false; |
| 116 | dap::Source dapSrc; |
| 117 | dapSrc.path = sourcePath; |
| 118 | response.breakpoints[i].source = dapSrc; |
| 119 | } |
| 120 | } |
| 121 | |
| 122 | return response; |
| 123 | } |
| 124 | |
| 125 | void cmDebuggerBreakpointManager::SourceFileLoaded( |