[Lldb-commits] [lldb] [lldb][docs] Clean Variable Formatting Documentation (PR #193907)
David Spickett via lldb-commits
lldb-commits at lists.llvm.org
Fri Apr 24 03:15:32 PDT 2026
================
@@ -424,59 +478,57 @@ If you have code like the following:
int *z;
};
-the expression path for the y member of the x member of an object of type B
-would be .x.y and you would type ``${var.x.y}`` to display it in a summary
-string for type B.
+and were writing a Summary String to format an instance of ``B``, the expression
+path for the ``y`` member of the ``x`` member would be ``.x.y`` and you would
+use ``${var.x.y}`` in the Summary String.
-By default, a summary defined for type T, also works for types T* and T& (you
-can disable this behavior if desired). For this reason, expression paths do not
-differentiate between . and ->, and the above expression path .x.y would be
-just as good if you were displaying a B*, or even if the actual definition of B
-were:
+By default, a summary defined for type ``T``, also works for types ``T*`` and ``T&``
+(as mentioned above, you can disable this behavior if desired). For this reason,
+expression paths do not differentiate between ``.`` and ``->``, and the above
+expression path ``.x.y`` would be valid for displaying a value with type ``B*``,
+``B`` or even if the actual declaration of ``B`` were instead:
-::
+.. code-block:: C++
struct B {
A *x;
A y;
int *z;
};
-This is unlike the behavior of frame variable which, on the contrary, will
+This behavior differs from that of frame variable which, on the contrary, will
enforce the distinction. As hinted above, the rationale for this choice is that
-waiving this distinction enables you to write a summary string once for type T
-and use it for both T and T* instances. As a summary string is mostly about
+waiving this distinction enables you to write a Summary String once for type T
+and use it for both T and T* instances. As a Summary String is mostly about
extracting nested members' information, a pointer to an object is just as good
as the object itself for the purpose.
-If you need to access the value of the integer pointed to by B::z, you cannot
-simply say ${var.z} because that symbol refers to the pointer z. In order to
-dereference it and get the pointed value, you should say ``${*var.z}``. The
-``${*var`` tells LLDB to get the object that the expression paths leads to, and
-then dereference it. In this example is it equivalent to ``*(bObject.z)`` in
-C/C++ syntax. Because ``.`` and ``->`` operators can both be used, there is no
-need to have dereferences in the middle of an expression path (e.g. you do not
-need to type ``${*(var.x).x}``) to read A::x as contained in ``*(B::x)``. To
-achieve that effect you can simply write ``${var.x->x}``, or even
-``${var.x.x}``. The ``*`` operator only binds to the result of the whole
-expression path, rather than piecewise, and there is no way to use parentheses
-to change that behavior.
-
-Of course, a summary string can contain more than one ${var specifier, and can
-use ``${var`` and ``${*var`` specifiers together.
+If you need to access the value of the integer pointed to by ``B::z``, your
+Summary String cannot simply use expression path ``.z`` because that symbol
+refers to the pointer ``z``. To access the value of the integer pointer to by
+``B::z`` in your Summary String, you should use the same expression path but
+dereference it: ``${*var.z}``. The ``*`` tells LLDB to get the object that
+the expression paths leads to and then dereference it. In this example, it is
+equivalent to ``*(bObject.z)`` in C/C++ syntax. Because ``.`` and ``->``
+operators can be used interchangeably, there is no need to have dereferences
+in the middle of an expression path (e.g. you do not need to type ``${*(var.x).x}``)
+to read ``A::x`` as contained in ``*(B::x)``. Instead, you can simply write
----------------
DavidSpickett wrote:
Convert the bracketed bit to ". For example, ...".
https://github.com/llvm/llvm-project/pull/193907
More information about the lldb-commits
mailing list