================
@@ -800,16 +800,24 @@ Print the dynamic type of the result of an expression
   (gdb) p someCPPObjectPtrOrReference
   (Only works for C++ objects)
 
+LLDB does this automatically if determining the dynamic type does not require
+running the target (in C++, running the target is never needed). This default 
is
+controlled by the `target.prefer-dynamic-value` setting. If that is disabled, 
it
+can be re-enabled on a per-command basis:
+
 .. code-block:: shell
 
-  (lldb) expr -d 1 -- [SomeClass returnAnObject]
-  (lldb) expr -d 1 -- someCPPObjectPtrOrReference
+  (lldb) settings set target.prefer-dynamic-value no-dynamic-values
+  (lldb) frame variable -d no-run-target someCPPObjectPtrOrReference
+  (lldb) expr -d no-run-target -- someCPPObjectPtr
 
-or set dynamic type printing to be the default:
+Note that printing of the dynamic type of references is not possible with the
+`expr` command. The workaround is to take the address of the reference and
+instruct lldb to print the children of the resulting pointer.
----------------
labath wrote:

I spent some time trying to make this work, but I came to the conclusion that 
this would require a relatively big change in how the expression evaluator 
works. Because we're creating persistent copies of the expression result, it's 
not just a matter of getting something to recognise the dynamic type of the 
result -- we would actually need to determine the dynamic type of the object 
before we create the copy (so that we copy the entire object) -- and then I 
guess somehow reset the original (non-dynamic) ValueObject to point to the 
subobject of the result. And that might be too much work to put on the 
shoulders of the "use-dynamic" setting?

https://github.com/llvm/llvm-project/pull/138538
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to