[lldb] [llvm] [lldb-dap] Add support for data breakpoint. (PR #81541)
Zequan Wu via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 13 14:43:01 PST 2024
================
@@ -561,6 +561,46 @@ void EventThreadFunction() {
}
}
+lldb::SBValue FindVariable(uint64_t variablesReference, llvm::StringRef name) {
+ lldb::SBValue variable;
+ if (lldb::SBValueList *top_scope = GetTopLevelScope(variablesReference)) {
+ bool is_duplicated_variable_name = name.contains(" @");
+ // 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);
----------------
ZequanWu wrote:
This functions is shared between `request_setVariable` and `request_dataBreakpointInfo`, so it checks name that contains `foo @ main.cpp:12`. I tested this manually.
For anonymous unions inside struct, I also tested manually. If we watch either `c` or `d`, changes on either value stops the program as expected.
```
struct A {
int a;
int b;
union {
char c;
int d;
};
};
```
https://github.com/llvm/llvm-project/pull/81541
More information about the llvm-commits
mailing list