[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
================
@@ -323,96 +328,145 @@ pick:
| ``void`` | v | don't show anything |
+-----------------------------------------------+------------------+--------------------------------------------------------------------------+
+.. _type-summary:
+
Type Summary
------------
-Type formats work by showing a different kind of display for the value of a
-variable. However, they only work for basic types. When you want to display a
-class or struct in a custom format, you cannot do that using formats.
+Type formats specify the way to format a variable/value with a fundamental type.
+When you want to display a variable/value for a user-defined type,\ [#]_ you need
+another tool, type summaries.
+
+Type summaries work by extracting information from aggregate types and arranging it
+in a user-defined format. Consider the following example:
+
+Before adding a type summary, for a C++ program with a ``struct`` declared like
-A different feature, type summaries, works by extracting information from
-classes, structures, ... (aggregate types) and arranging it in a user-defined
-format, as in the following example:
+.. code-block:: C++
+
+ struct Person {
+ std::string name;
+ int age;
+ };
-before adding a summary...
+
+LLDB will format a variable that is an instance of the ``Person`` type as
::
- (lldb) frame variable -T one
- (i_am_cool) one = {
- (int) x = 3
- (float) y = 3.14159
- (char) z = 'E'
+ (lldb) frame variable -T p
+ (Person) p = {
+ (std::string) name = "Jaime"
+ (int) age = 44
}
-after adding a summary...
+But, using a type summary, the LLDB user can specify that an instance of
+the ``Person`` type be formatted as
::
- (lldb) frame variable one
- (i_am_cool) one = int = 3, float = 3.14159, char = 69
+ (lldb) frame variable -T p
+ (Person) p = The person is named "Jaime" and is 44 years old.
-There are two ways to use type summaries: the first one is to bind a summary
-string to the type; the second is to write a Python script that returns the
-string to be used as summary. Both options are enabled by the type summary add
-command.
+There are two ways to specify type summaries:
----------------
DavidSpickett wrote:
"ways" -> "methods" since you want to say "method 1" later and "way 1" is kinda correct but an uncommon way to say it.
https://github.com/llvm/llvm-project/pull/193907
More information about the lldb-commits
mailing list