[Lldb-commits] [lldb] 79ac5bb - [LLDB] Clarifying the documentation for variable formatting wrt to qualifiers and adding a test that demonstrates this

Shafik Yaghmour via lldb-commits lldb-commits at lists.llvm.org
Wed Apr 7 14:31:28 PDT 2021


Author: Shafik Yaghmour
Date: 2021-04-07T14:29:12-07:00
New Revision: 79ac5bbb96c46e3c6c3568a441c13aa10c087b25

URL: https://github.com/llvm/llvm-project/commit/79ac5bbb96c46e3c6c3568a441c13aa10c087b25
DIFF: https://github.com/llvm/llvm-project/commit/79ac5bbb96c46e3c6c3568a441c13aa10c087b25.diff

LOG: [LLDB] Clarifying the documentation for variable formatting wrt to qualifiers and adding a test that demonstrates this

When looking up user specified formatters qualifiers are removed from types before matching,
I have added a clarifying example to the document and added an example to a relevant test to demonstrate this behavior.

Differential Revision: https://reviews.llvm.org/D99827

Added: 
    

Modified: 
    lldb/docs/use/variable.rst
    lldb/test/API/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py
    lldb/test/API/functionalities/data-formatter/data-formatter-advanced/main.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/docs/use/variable.rst b/lldb/docs/use/variable.rst
index b9bcdf57cdde..b3e4de588d5e 100644
--- a/lldb/docs/use/variable.rst
+++ b/lldb/docs/use/variable.rst
@@ -131,6 +131,20 @@ which provides the desired output:
    (C) c = {0x03 0x00 0x00 0x00}
    (D) d = 4
 
+Note, that qualifiers such as const and volatile will be stripped when matching types for example:
+
+::
+
+   (lldb) frame var x y z
+   (int) x = 1
+   (const int) y = 2
+   (volatile int) z = 4
+   (lldb) type format add -f hex int
+   (lldb) frame var x y z
+   (int) x = 0x00000001
+   (const int) y = 0x00000002
+   (volatile int) z = 0x00000004
+
 Two additional options that you will want to look at are --skip-pointers (-p)
 and --skip-references (-r). These two options prevent LLDB from applying a
 format for type T to values of type T* and T& respectively.

diff  --git a/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py b/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py
index d29547bb6050..42b31a10fb2c 100644
--- a/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py
+++ b/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py
@@ -244,6 +244,12 @@ def cleanup():
         self.expect("frame variable a_simple_object", matching=True,
                     substrs=['x=0x00000003'])
 
+        self.expect_var_path("constInt", value='0x0000002a')
+
+        self.expect_var_path("volatileInt", value='0x0000002b')
+
+        self.expect_var_path("constVolatileInt", value='0x0000002c')
+
         # check that we can correctly cap the number of children shown
         self.runCmd("settings set target.max-children-count 5")
 

diff  --git a/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/main.cpp b/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/main.cpp
index ac13113da427..857e2493e1a2 100644
--- a/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/main.cpp
+++ b/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/main.cpp
@@ -128,6 +128,9 @@ int main (int argc, const char * argv[])
 {
     
     int iAmInt = 9;
+    const int constInt = 42;
+    volatile int volatileInt = 43;
+    const volatile int constVolatileInt = 44;
     
     i_am_cool cool_boy(1,0.5,3);
     i_am_cooler cooler_boy(1,2,0.1,0.2,'A','B');


        


More information about the lldb-commits mailing list