[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:44 PDT 2026
================
@@ -161,6 +238,60 @@ class CommandObjectRegisterRead : public CommandObjectParsed {
return true;
}
+ bool DumpRegisterField(const ExecutionContext &exe_ctx, Stream &strm,
+ const RegisterInfo ®_info,
+ llvm::StringRef expression_path,
+ size_t reg_name_right_align_at,
+ CommandReturnObject &result) {
+ if (!llvm::isa_and_present<RegisterTypeComposite>(reg_info.register_type)) {
+ result.AppendErrorWithFormat(
+ "Register '%s' does not have a structured type", reg_info.name);
+ return false;
+ }
+
+ StackFrame *frame = exe_ctx.GetFramePtr();
+ if (!frame)
+ return false;
+ lldb::RegisterContextSP reg_ctx_sp = frame->GetRegisterContextSP();
+ ValueObjectSP register_value =
+ ValueObjectRegister::Create(frame, reg_ctx_sp, ®_info);
+ ValueObjectSP child =
+ ResolveRegisterExpressionPath(register_value, expression_path);
----------------
clayborg wrote:
We should make a new ValueObjectRegister creator function like:
```
llvm::Expected<ValueObjectSP>
ValueObjectRegister::CreateFromExpressionPath(
StackFrame *frame,
lldb::RegisterContextSP reg_ctx_sp,
StringRef expression_path);
```
Expression path is always the full path that includes the register name and anything after it. So if the user specifies "x0", it will return a ValueObjectRegister shared pointer to the root register. If it is "u0.f32" or "u0.floats[2]", it will get root ValueObjectRegister and call `ValueObject::GetValueForExpressionPath(...)` where the expression path is relative to the current ValueObject. So we would get the value object for "u0" and call `register_value->GetValueForExpressionPath(".f32", ...)`. This way we can re-use this functionality everywhere in LLDB, not just here.
https://github.com/llvm/llvm-project/pull/224147
More information about the lldb-commits
mailing list