[Lldb-commits] [lldb] [LLDB] Expose and display GDB remote register union values (PR #224147)
Greg Clayton via lldb-commits
lldb-commits at lists.llvm.org
Wed Sep 23 14:58:43 PDT 2026
================
@@ -41,6 +47,76 @@ static size_t GetNameSize(const RegisterInfo *reg_info, bool use_primary_name) {
return reg_name ? strlen(reg_name) : 0;
}
+// Return the exact register and an empty path, the longest register-name prefix
+// and its remaining path, or {nullptr, {}} when no register matches.
+static std::pair<const RegisterInfo *, llvm::StringRef>
+FindRegisterWithExpressionPath(RegisterContext ®_ctx, llvm::StringRef name) {
+ if (const RegisterInfo *reg_info = reg_ctx.GetRegisterInfoByName(name))
+ return {reg_info, {}};
+
+ size_t search_end = name.size();
+ while (search_end) {
+ size_t split = name.take_front(search_end).find_last_of(".[");
+ if (split == llvm::StringRef::npos)
+ break;
+ if (const RegisterInfo *reg_info =
+ reg_ctx.GetRegisterInfoByName(name.take_front(split)))
+ return {reg_info, name.drop_front(split)};
+ search_end = split;
+ }
+ return {nullptr, {}};
+}
+
+static ValueObjectSP
+ResolveRegisterExpressionPath(ValueObjectSP value,
+ llvm::StringRef expression_path) {
+ // Generic expression paths permit out-of-bounds synthetic array members,
+ // but register paths must stay within the bytes supplied by the target.
----------------
clayborg wrote:
We should be using the ValueObject API:
```
lldb::ValueObjectSP GetValueForExpressionPath(
llvm::StringRef expression,
ExpressionPathScanEndReason *reason_to_stop = nullptr,
ExpressionPathEndResultType *final_value_type = nullptr,
const GetValueForExpressionPathOptions &options =
GetValueForExpressionPathOptions::DefaultOptions(),
ExpressionPathAftermath *final_task_on_target = nullptr);
```
instead of doing a manual fix here. We can make the above function virtual if needed and override it for ValueObjectRegister so it doesn't allow out of bounds accesses. There should be no need to reproduce this functionality. What happens if we just use the above function with no modifications? Is the only thing that doesn't work is out of bound accesses? I wouldn't worry about that too much if so and just let it happen maybe? The main issue is with the way this is done now, no one else can take advantage of this code elsewhere in LLDB. I would like this functionality to always be available which means it should live in the ValueObject classes only.
https://github.com/llvm/llvm-project/pull/224147
More information about the lldb-commits
mailing list