@@ -630,9 +630,8 @@ CreateExceptionBreakpointFilter(const ExceptionBreakpoint &bp) {
630630// }
631631// }
632632// }
633- llvm::json::Value CreateSource (lldb::SBLineEntry &line_entry ) {
633+ llvm::json::Value CreateSource (const lldb::SBFileSpec &file ) {
634634 llvm::json::Object object;
635- lldb::SBFileSpec file = line_entry.GetFileSpec ();
636635 if (file.IsValid ()) {
637636 const char *name = file.GetFilename ();
638637 if (name)
@@ -646,6 +645,10 @@ llvm::json::Value CreateSource(lldb::SBLineEntry &line_entry) {
646645 return llvm::json::Value (std::move (object));
647646}
648647
648+ llvm::json::Value CreateSource (const lldb::SBLineEntry &line_entry) {
649+ return CreateSource (line_entry.GetFileSpec ());
650+ }
651+
649652llvm::json::Value CreateSource (llvm::StringRef source_path) {
650653 llvm::json::Object source;
651654 llvm::StringRef name = llvm::sys::path::filename (source_path);
@@ -1250,7 +1253,7 @@ std::string VariableDescription::GetResult(llvm::StringRef context) {
12501253// "description": "The number of indexed child variables. The client
12511254// can use this optional information to present the
12521255// children in a paged UI and fetch them in chunks."
1253- // }
1256+ // },
12541257// "memoryReference": {
12551258// "type": "string",
12561259// "description": "A memory reference associated with this variable.
@@ -1260,63 +1263,75 @@ std::string VariableDescription::GetResult(llvm::StringRef context) {
12601263// be used in a `disassemble` request. This attribute may
12611264// be returned by a debug adapter if corresponding
12621265// capability `supportsMemoryReferences` is true."
1263- // },
1266+ // },
1267+ // "declarationLocationReference": {
1268+ // "type": "integer",
1269+ // "description": "A reference that allows the client to request the
1270+ // location where the variable is declared. This should be
1271+ // present only if the adapter is likely to be able to
1272+ // resolve the location.\n\nThis reference shares the same
1273+ // lifetime as the `variablesReference`. See 'Lifetime of
1274+ // Object References' in the Overview section for
1275+ // details."
1276+ // },
1277+ //
12641278// "$__lldb_extensions": {
12651279// "description": "Unofficial extensions to the protocol",
12661280// "properties": {
12671281// "declaration": {
1268- // "type": "object",
1269- // "description": "The source location where the variable was declared.
1270- // This value won't be present if no declaration is
1271- // available.",
1272- // "properties": {
1273- // "path": {
1274- // "type": "string",
1275- // "description": "The source file path where the variable was
1276- // declared."
1277- // },
1278- // "line": {
1279- // "type": "number",
1280- // "description": "The 1-indexed source line where the variable was
1281- // declared."
1282- // },
1283- // "column": {
1284- // "type": "number",
1285- // "description": "The 1-indexed source column where the variable
1286- // was declared."
1282+ // "type": "object",
1283+ // "description": "The source location where the variable was
1284+ // declared. This value won't be present if no
1285+ // declaration is available.
1286+ // Superseded by `declarationLocationReference`",
1287+ // "properties": {
1288+ // "path": {
1289+ // "type": "string",
1290+ // "description": "The source file path where the variable was
1291+ // declared."
1292+ // },
1293+ // "line": {
1294+ // "type": "number",
1295+ // "description": "The 1-indexed source line where the variable
1296+ // was declared."
1297+ // },
1298+ // "column": {
1299+ // "type": "number",
1300+ // "description": "The 1-indexed source column where the variable
1301+ // was declared."
1302+ // }
12871303// }
1304+ // },
1305+ // "value": {
1306+ // "type": "string",
1307+ // "description": "The internal value of the variable as returned by
1308+ // This is effectively SBValue.GetValue(). The other
1309+ // `value` entry in the top-level variable response
1310+ // is, on the other hand, just a display string for
1311+ // the variable."
1312+ // },
1313+ // "summary": {
1314+ // "type": "string",
1315+ // "description": "The summary string of the variable. This is
1316+ // effectively SBValue.GetSummary()."
1317+ // },
1318+ // "autoSummary": {
1319+ // "type": "string",
1320+ // "description": "The auto generated summary if using
1321+ // `enableAutoVariableSummaries`."
1322+ // },
1323+ // "error": {
1324+ // "type": "string",
1325+ // "description": "An error message generated if LLDB couldn't inspect
1326+ // the variable."
12881327// }
1289- // },
1290- // "value":
1291- // "type": "string",
1292- // "description": "The internal value of the variable as returned by
1293- // This is effectively SBValue.GetValue(). The other
1294- // `value` entry in the top-level variable response is,
1295- // on the other hand, just a display string for the
1296- // variable."
1297- // },
1298- // "summary":
1299- // "type": "string",
1300- // "description": "The summary string of the variable. This is
1301- // effectively SBValue.GetSummary()."
1302- // },
1303- // "autoSummary":
1304- // "type": "string",
1305- // "description": "The auto generated summary if using
1306- // `enableAutoVariableSummaries`."
1307- // },
1308- // "error":
1309- // "type": "string",
1310- // "description": "An error message generated if LLDB couldn't inspect
1311- // the variable."
13121328// }
13131329// }
13141330// },
13151331// "required": [ "name", "value", "variablesReference" ]
13161332// }
1317- llvm::json::Value CreateVariable (lldb::SBValue v, int64_t variablesReference,
1318- int64_t varID, bool format_hex,
1319- bool is_name_duplicated,
1333+ llvm::json::Value CreateVariable (lldb::SBValue v, int64_t var_ref,
1334+ bool format_hex, bool is_name_duplicated,
13201335 std::optional<std::string> custom_name) {
13211336 VariableDescription desc (v, format_hex, is_name_duplicated, custom_name);
13221337 llvm::json::Object object;
@@ -1361,12 +1376,18 @@ llvm::json::Value CreateVariable(lldb::SBValue v, int64_t variablesReference,
13611376 }
13621377 }
13631378 EmplaceSafeString (object, " type" , desc.display_type_name );
1364- if (varID != INT64_MAX)
1365- object.try_emplace (" id" , varID);
1379+
1380+ // A unique variable identifier to help in properly identifying variables with
1381+ // the same name. This is an extension to the VS protocol.
1382+ object.try_emplace (" id" , var_ref);
1383+
13661384 if (v.MightHaveChildren ())
1367- object.try_emplace (" variablesReference" , variablesReference );
1385+ object.try_emplace (" variablesReference" , var_ref );
13681386 else
1369- object.try_emplace (" variablesReference" , (int64_t )0 );
1387+ object.try_emplace (" variablesReference" , 0 );
1388+
1389+ if (v.GetDeclaration ().IsValid ())
1390+ object.try_emplace (" declarationLocationReference" , var_ref);
13701391
13711392 if (lldb::addr_t addr = v.GetLoadAddress (); addr != LLDB_INVALID_ADDRESS)
13721393 object.try_emplace (" memoryReference" , EncodeMemoryReference (addr));
0 commit comments