Skip to content

Commit 6a99d81

Browse files
authored
[lldb/docs] Fix/improve the gdb command map for dynamic types (llvm#138538)
The setting and option value names were wrong. I'm assuming this changed over time, but I haven't tried to figure out when.
1 parent 1eaa289 commit 6a99d81

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

lldb/docs/use/map.rst

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -800,16 +800,24 @@ Print the dynamic type of the result of an expression
800800
(gdb) p someCPPObjectPtrOrReference
801801
(Only works for C++ objects)
802802
803+
LLDB does this automatically if determining the dynamic type does not require
804+
running the target (in C++, running the target is never needed). This default is
805+
controlled by the `target.prefer-dynamic-value` setting. If that is disabled, it
806+
can be re-enabled on a per-command basis:
807+
803808
.. code-block:: shell
804809
805-
(lldb) expr -d 1 -- [SomeClass returnAnObject]
806-
(lldb) expr -d 1 -- someCPPObjectPtrOrReference
810+
(lldb) settings set target.prefer-dynamic-value no-dynamic-values
811+
(lldb) frame variable -d no-run-target someCPPObjectPtrOrReference
812+
(lldb) expr -d no-run-target -- someCPPObjectPtr
807813
808-
or set dynamic type printing to be the default:
814+
Note that printing of the dynamic type of references is not possible with the
815+
`expr` command. The workaround is to take the address of the reference and
816+
instruct lldb to print the children of the resulting pointer.
809817
810818
.. code-block:: shell
811819
812-
(lldb) settings set target.prefer-dynamic run-target
820+
(lldb) expr -P1 -d no-run-target -- &someCPPObjectReference
813821
814822
Call a function so you can stop at a breakpoint in it
815823
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

0 commit comments

Comments
 (0)