[Lldb-commits] [lldb] [llvm] [lldb-dap] Add support for data breakpoint. (PR #81541)

Zequan Wu via lldb-commits lldb-commits at lists.llvm.org
Tue Feb 13 14:43:02 PST 2024


================
@@ -2697,58 +2737,41 @@ void request_dataBreakpointInfo(const llvm::json::Object &request) {
       GetUnsigned(arguments, "variablesReference", 0);
   llvm::StringRef name = GetString(arguments, "name");
   lldb::SBFrame frame = g_dap.GetLLDBFrame(*arguments);
-  bool is_duplicated_variable_name = name.contains(" @");
+  lldb::SBValue variable = FindVariable(variablesReference, name);
+  std::string addr, size;
 
-  lldb::SBValue variable;
-  if (lldb::SBValueList *top_scope = GetTopLevelScope(variablesReference)) {
-    // variablesReference is one of our scopes, not an actual variable it is
-    // asking for a variable in locals or globals or registers
-    int64_t end_idx = top_scope->GetSize();
-    // Searching backward so that we choose the variable in closest scope
-    // among variables of the same name.
-    for (int64_t i = end_idx - 1; i >= 0; --i) {
-      lldb::SBValue curr_variable = top_scope->GetValueAtIndex(i);
-      std::string variable_name = CreateUniqueVariableNameForDisplay(
-          curr_variable, is_duplicated_variable_name);
-      if (variable_name == name) {
-        variable = curr_variable;
-        break;
-      }
-    }
+  if (variable.IsValid()) {
+    addr = llvm::utohexstr(variable.GetLoadAddress());
+    size = llvm::utostr(variable.GetByteSize());
----------------
ZequanWu wrote:

Sent a fix at https://github.com/llvm/llvm-project/pull/81680

https://github.com/llvm/llvm-project/pull/81541


More information about the lldb-commits mailing list