|
14 | 14 | #include "LLDBUtils.h"
|
15 | 15 | #include "OutputRedirector.h"
|
16 | 16 | #include "Protocol/ProtocolBase.h"
|
| 17 | +#include "Protocol/ProtocolTypes.h" |
17 | 18 | #include "Transport.h"
|
18 | 19 | #include "lldb/API/SBBreakpoint.h"
|
19 | 20 | #include "lldb/API/SBCommandInterpreter.h"
|
@@ -1144,31 +1145,137 @@ lldb::SBValue Variables::FindVariable(uint64_t variablesReference,
|
1144 | 1145 | return variable;
|
1145 | 1146 | }
|
1146 | 1147 |
|
1147 |
| -llvm::StringMap<bool> DAP::GetCapabilities() { |
1148 |
| - llvm::StringMap<bool> capabilities; |
| 1148 | +static void mergeCapabilities(protocol::Capabilities &into, |
| 1149 | + const protocol::Capabilities &from) { |
| 1150 | + if (from.supportsConfigurationDoneRequest) |
| 1151 | + into.supportsConfigurationDoneRequest = |
| 1152 | + *from.supportsConfigurationDoneRequest; |
| 1153 | + if (from.supportsFunctionBreakpoints) |
| 1154 | + into.supportsFunctionBreakpoints = *from.supportsFunctionBreakpoints; |
| 1155 | + if (from.supportsConditionalBreakpoints) |
| 1156 | + into.supportsConditionalBreakpoints = *from.supportsConditionalBreakpoints; |
| 1157 | + if (from.supportsHitConditionalBreakpoints) |
| 1158 | + into.supportsHitConditionalBreakpoints = |
| 1159 | + *from.supportsHitConditionalBreakpoints; |
| 1160 | + if (from.supportsEvaluateForHovers) |
| 1161 | + into.supportsEvaluateForHovers = *from.supportsEvaluateForHovers; |
| 1162 | + if (from.exceptionBreakpointFilters) |
| 1163 | + into.exceptionBreakpointFilters = *from.exceptionBreakpointFilters; |
| 1164 | + if (from.supportsStepBack) |
| 1165 | + into.supportsStepBack = *from.supportsStepBack; |
| 1166 | + if (from.supportsSetVariable) |
| 1167 | + into.supportsSetVariable = *from.supportsSetVariable; |
| 1168 | + if (from.supportsRestartFrame) |
| 1169 | + into.supportsRestartFrame = *from.supportsRestartFrame; |
| 1170 | + if (from.supportsGotoTargetsRequest) |
| 1171 | + into.supportsGotoTargetsRequest = *from.supportsGotoTargetsRequest; |
| 1172 | + if (from.supportsStepInTargetsRequest) |
| 1173 | + into.supportsStepInTargetsRequest = *from.supportsStepInTargetsRequest; |
| 1174 | + if (from.supportsCompletionsRequest) |
| 1175 | + into.supportsCompletionsRequest = *from.supportsCompletionsRequest; |
| 1176 | + if (from.completionTriggerCharacters) |
| 1177 | + into.completionTriggerCharacters = *from.completionTriggerCharacters; |
| 1178 | + if (from.supportsModulesRequest) |
| 1179 | + into.supportsModulesRequest = *from.supportsModulesRequest; |
| 1180 | + if (from.additionalModuleColumns) |
| 1181 | + into.additionalModuleColumns = *from.additionalModuleColumns; |
| 1182 | + if (from.supportedChecksumAlgorithms) |
| 1183 | + into.supportedChecksumAlgorithms = *from.supportedChecksumAlgorithms; |
| 1184 | + if (from.supportsRestartRequest) |
| 1185 | + into.supportsRestartRequest = *from.supportsRestartRequest; |
| 1186 | + if (from.supportsExceptionOptions) |
| 1187 | + into.supportsExceptionOptions = *from.supportsExceptionOptions; |
| 1188 | + if (from.supportsValueFormattingOptions) |
| 1189 | + into.supportsValueFormattingOptions = *from.supportsValueFormattingOptions; |
| 1190 | + if (from.supportsExceptionInfoRequest) |
| 1191 | + into.supportsExceptionInfoRequest = *from.supportsExceptionInfoRequest; |
| 1192 | + if (from.supportTerminateDebuggee) |
| 1193 | + into.supportTerminateDebuggee = *from.supportTerminateDebuggee; |
| 1194 | + if (from.supportSuspendDebuggee) |
| 1195 | + into.supportSuspendDebuggee = *from.supportSuspendDebuggee; |
| 1196 | + if (from.supportsDelayedStackTraceLoading) |
| 1197 | + into.supportsDelayedStackTraceLoading = |
| 1198 | + *from.supportsDelayedStackTraceLoading; |
| 1199 | + if (from.supportsLoadedSourcesRequest) |
| 1200 | + into.supportsLoadedSourcesRequest = *from.supportsLoadedSourcesRequest; |
| 1201 | + if (from.supportsLogPoints) |
| 1202 | + into.supportsLogPoints = *from.supportsLogPoints; |
| 1203 | + if (from.supportsTerminateThreadsRequest) |
| 1204 | + into.supportsTerminateThreadsRequest = |
| 1205 | + *from.supportsTerminateThreadsRequest; |
| 1206 | + if (from.supportsSetExpression) |
| 1207 | + into.supportsSetExpression = *from.supportsSetExpression; |
| 1208 | + if (from.supportsTerminateRequest) |
| 1209 | + into.supportsTerminateRequest = *from.supportsTerminateRequest; |
| 1210 | + if (from.supportsDataBreakpoints) |
| 1211 | + into.supportsDataBreakpoints = *from.supportsDataBreakpoints; |
| 1212 | + if (from.supportsReadMemoryRequest) |
| 1213 | + into.supportsReadMemoryRequest = *from.supportsReadMemoryRequest; |
| 1214 | + if (from.supportsWriteMemoryRequest) |
| 1215 | + into.supportsWriteMemoryRequest = *from.supportsWriteMemoryRequest; |
| 1216 | + if (from.supportsDisassembleRequest) |
| 1217 | + into.supportsDisassembleRequest = *from.supportsDisassembleRequest; |
| 1218 | + if (from.supportsCancelRequest) |
| 1219 | + into.supportsCancelRequest = *from.supportsCancelRequest; |
| 1220 | + if (from.supportsBreakpointLocationsRequest) |
| 1221 | + into.supportsBreakpointLocationsRequest = |
| 1222 | + *from.supportsBreakpointLocationsRequest; |
| 1223 | + if (from.supportsClipboardContext) |
| 1224 | + into.supportsClipboardContext = *from.supportsClipboardContext; |
| 1225 | + if (from.supportsSteppingGranularity) |
| 1226 | + into.supportsSteppingGranularity = *from.supportsSteppingGranularity; |
| 1227 | + if (from.supportsInstructionBreakpoints) |
| 1228 | + into.supportsInstructionBreakpoints = *from.supportsInstructionBreakpoints; |
| 1229 | + if (from.supportsExceptionFilterOptions) |
| 1230 | + into.supportsExceptionFilterOptions = *from.supportsExceptionFilterOptions; |
| 1231 | + if (from.supportsSingleThreadExecutionRequests) |
| 1232 | + into.supportsSingleThreadExecutionRequests = |
| 1233 | + *from.supportsSingleThreadExecutionRequests; |
| 1234 | + if (from.supportsDataBreakpointBytes) |
| 1235 | + into.supportsDataBreakpointBytes = *from.supportsDataBreakpointBytes; |
| 1236 | + if (from.breakpointModes) |
| 1237 | + into.breakpointModes = *from.breakpointModes; |
| 1238 | + if (from.supportsANSIStyling) |
| 1239 | + into.supportsANSIStyling = *from.supportsANSIStyling; |
| 1240 | +} |
| 1241 | + |
| 1242 | +protocol::Capabilities DAP::GetCapabilities() { |
| 1243 | + protocol::Capabilities capabilities; |
1149 | 1244 |
|
1150 | 1245 | // Supported capabilities.
|
1151 |
| - capabilities["supportTerminateDebuggee"] = true; |
1152 |
| - capabilities["supportsDataBreakpoints"] = true; |
1153 |
| - capabilities["supportsDelayedStackTraceLoading"] = true; |
1154 |
| - capabilities["supportsEvaluateForHovers"] = true; |
1155 |
| - capabilities["supportsExceptionOptions"] = true; |
1156 |
| - capabilities["supportsLogPoints"] = true; |
1157 |
| - capabilities["supportsProgressReporting"] = true; |
1158 |
| - capabilities["supportsSteppingGranularity"] = true; |
1159 |
| - capabilities["supportsValueFormattingOptions"] = true; |
| 1246 | + capabilities.supportTerminateDebuggee = true; |
| 1247 | + capabilities.supportsDataBreakpoints = true; |
| 1248 | + capabilities.supportsDelayedStackTraceLoading = true; |
| 1249 | + capabilities.supportsEvaluateForHovers = true; |
| 1250 | + capabilities.supportsExceptionOptions = true; |
| 1251 | + capabilities.supportsLogPoints = true; |
| 1252 | + capabilities.supportsSteppingGranularity = true; |
| 1253 | + capabilities.supportsValueFormattingOptions = true; |
1160 | 1254 |
|
1161 | 1255 | // Unsupported capabilities.
|
1162 |
| - capabilities["supportsGotoTargetsRequest"] = false; |
1163 |
| - capabilities["supportsLoadedSourcesRequest"] = false; |
1164 |
| - capabilities["supportsRestartFrame"] = false; |
1165 |
| - capabilities["supportsStepBack"] = false; |
| 1256 | + capabilities.supportsGotoTargetsRequest = false; |
| 1257 | + capabilities.supportsLoadedSourcesRequest = false; |
| 1258 | + capabilities.supportsRestartFrame = false; |
| 1259 | + capabilities.supportsStepBack = false; |
1166 | 1260 |
|
1167 | 1261 | // Capabilities associated with specific requests.
|
1168 |
| - for (auto &kv : request_handlers) { |
1169 |
| - for (auto &request_kv : kv.second->GetCapabilities()) |
1170 |
| - capabilities[request_kv.getKey()] = request_kv.getValue(); |
1171 |
| - } |
| 1262 | + for (auto &kv : request_handlers) |
| 1263 | + mergeCapabilities(capabilities, kv.second->GetCapabilities()); |
| 1264 | + |
| 1265 | + // Available filters or options for the setExceptionBreakpoints request. |
| 1266 | + std::vector<protocol::ExceptionBreakpointsFilter> filters; |
| 1267 | + for (const auto &exc_bp : *exception_breakpoints) |
| 1268 | + filters.emplace_back(CreateExceptionBreakpointFilter(exc_bp)); |
| 1269 | + capabilities.exceptionBreakpointFilters = std::move(filters); |
| 1270 | + |
| 1271 | + std::vector<std::string> completion_characters; |
| 1272 | + completion_characters.emplace_back("."); |
| 1273 | + completion_characters.emplace_back(" "); |
| 1274 | + completion_characters.emplace_back("\t"); |
| 1275 | + capabilities.completionTriggerCharacters = std::move(completion_characters); |
| 1276 | + |
| 1277 | + // Put in non-DAP specification lldb specific information. |
| 1278 | + capabilities.lldbVersion = debugger.GetVersionString(); |
1172 | 1279 |
|
1173 | 1280 | return capabilities;
|
1174 | 1281 | }
|
|
0 commit comments