@@ -614,9 +614,8 @@ CreateExceptionBreakpointFilter(const ExceptionBreakpoint &bp) {
614
614
// }
615
615
// }
616
616
// }
617
- llvm::json::Value CreateSource (lldb::SBLineEntry &line_entry ) {
617
+ llvm::json::Value CreateSource (const lldb::SBFileSpec &file ) {
618
618
llvm::json::Object object;
619
- lldb::SBFileSpec file = line_entry.GetFileSpec ();
620
619
if (file.IsValid ()) {
621
620
const char *name = file.GetFilename ();
622
621
if (name)
@@ -630,6 +629,10 @@ llvm::json::Value CreateSource(lldb::SBLineEntry &line_entry) {
630
629
return llvm::json::Value (std::move (object));
631
630
}
632
631
632
+ llvm::json::Value CreateSource (const lldb::SBLineEntry &line_entry) {
633
+ return CreateSource (line_entry.GetFileSpec ());
634
+ }
635
+
633
636
llvm::json::Value CreateSource (llvm::StringRef source_path) {
634
637
llvm::json::Object source;
635
638
llvm::StringRef name = llvm::sys::path::filename (source_path);
@@ -1143,65 +1146,75 @@ std::string VariableDescription::GetResult(llvm::StringRef context) {
1143
1146
// "description": "The number of indexed child variables. The client
1144
1147
// can use this optional information to present the
1145
1148
// children in a paged UI and fetch them in chunks."
1146
- // }
1147
- //
1149
+ // },
1150
+ // "declarationLocationReference": {
1151
+ // "type": "integer",
1152
+ // "description": "A reference that allows the client to request the
1153
+ // location where the variable is declared. This should be
1154
+ // present only if the adapter is likely to be able to
1155
+ // resolve the location.\n\nThis reference shares the same
1156
+ // lifetime as the `variablesReference`. See 'Lifetime of
1157
+ // Object References' in the Overview section for
1158
+ // details."
1159
+ // },
1148
1160
//
1149
1161
// "$__lldb_extensions": {
1150
1162
// "description": "Unofficial extensions to the protocol",
1151
1163
// "properties": {
1152
1164
// "declaration": {
1153
- // "type": "object",
1154
- // "description": "The source location where the variable was declared.
1155
- // This value won't be present if no declaration is
1156
- // available.",
1157
- // "properties": {
1158
- // "path": {
1159
- // "type": "string",
1160
- // "description": "The source file path where the variable was
1161
- // declared."
1162
- // },
1163
- // "line": {
1164
- // "type": "number",
1165
- // "description": "The 1-indexed source line where the variable was
1166
- // declared."
1167
- // },
1168
- // "column": {
1169
- // "type": "number",
1170
- // "description": "The 1-indexed source column where the variable
1171
- // was declared."
1165
+ // "type": "object",
1166
+ // "description": "The source location where the variable was declared.
1167
+ // This value won't be present if no declaration is
1168
+ // available.
1169
+ // Superseded by `declarationLocationReference`",
1170
+ // "properties": {
1171
+ // "path": {
1172
+ // "type": "string",
1173
+ // "description": "The source file path where the variable was
1174
+ // declared."
1175
+ // },
1176
+ // "line": {
1177
+ // "type": "number",
1178
+ // "description": "The 1-indexed source line where the variable
1179
+ // was declared."
1180
+ // },
1181
+ // "column": {
1182
+ // "type": "number",
1183
+ // "description": "The 1-indexed source column where the variable
1184
+ // was declared."
1185
+ // }
1172
1186
// }
1187
+ // },
1188
+ // "value": {
1189
+ // "type": "string",
1190
+ // "description": "The internal value of the variable as returned by
1191
+ // This is effectively SBValue.GetValue(). The other
1192
+ // `value` entry in the top-level variable response
1193
+ // is, on the other hand, just a display string for
1194
+ // the variable."
1195
+ // },
1196
+ // "summary": {
1197
+ // "type": "string",
1198
+ // "description": "The summary string of the variable. This is
1199
+ // effectively SBValue.GetSummary()."
1200
+ // },
1201
+ // "autoSummary": {
1202
+ // "type": "string",
1203
+ // "description": "The auto generated summary if using
1204
+ // `enableAutoVariableSummaries`."
1205
+ // },
1206
+ // "error": {
1207
+ // "type": "string",
1208
+ // "description": "An error message generated if LLDB couldn't inspect
1209
+ // the variable."
1173
1210
// }
1174
- // },
1175
- // "value":
1176
- // "type": "string",
1177
- // "description": "The internal value of the variable as returned by
1178
- // This is effectively SBValue.GetValue(). The other
1179
- // `value` entry in the top-level variable response is,
1180
- // on the other hand, just a display string for the
1181
- // variable."
1182
- // },
1183
- // "summary":
1184
- // "type": "string",
1185
- // "description": "The summary string of the variable. This is
1186
- // effectively SBValue.GetSummary()."
1187
- // },
1188
- // "autoSummary":
1189
- // "type": "string",
1190
- // "description": "The auto generated summary if using
1191
- // `enableAutoVariableSummaries`."
1192
- // },
1193
- // "error":
1194
- // "type": "string",
1195
- // "description": "An error message generated if LLDB couldn't inspect
1196
- // the variable."
1197
1211
// }
1198
1212
// }
1199
1213
// },
1200
1214
// "required": [ "name", "value", "variablesReference" ]
1201
1215
// }
1202
- llvm::json::Value CreateVariable (lldb::SBValue v, int64_t variablesReference,
1203
- int64_t varID, bool format_hex,
1204
- bool is_name_duplicated,
1216
+ llvm::json::Value CreateVariable (lldb::SBValue v, int64_t var_ref,
1217
+ bool format_hex, bool is_name_duplicated,
1205
1218
std::optional<std::string> custom_name) {
1206
1219
VariableDescription desc (v, format_hex, is_name_duplicated, custom_name);
1207
1220
llvm::json::Object object;
@@ -1246,12 +1259,18 @@ llvm::json::Value CreateVariable(lldb::SBValue v, int64_t variablesReference,
1246
1259
}
1247
1260
}
1248
1261
EmplaceSafeString (object, " type" , desc.display_type_name );
1249
- if (varID != INT64_MAX)
1250
- object.try_emplace (" id" , varID);
1262
+
1263
+ // A unique variable identifier to help in properly identifying variables with
1264
+ // the same name. This is an extension to the VS protocol.
1265
+ object.try_emplace (" id" , var_ref);
1266
+
1251
1267
if (v.MightHaveChildren ())
1252
- object.try_emplace (" variablesReference" , variablesReference );
1268
+ object.try_emplace (" variablesReference" , var_ref );
1253
1269
else
1254
- object.try_emplace (" variablesReference" , (int64_t )0 );
1270
+ object.try_emplace (" variablesReference" , 0 );
1271
+
1272
+ if (v.GetDeclaration ().IsValid ())
1273
+ object.try_emplace (" declarationLocationReference" , var_ref << 1 );
1255
1274
1256
1275
object.try_emplace (" $__lldb_extensions" , desc.GetVariableExtensionsJSON ());
1257
1276
return llvm::json::Value (std::move (object));
0 commit comments