[Lldb-commits] [lldb] r255887 - Inspect DW_AT_const_value global static const variables

Ewan Crawford via lldb-commits lldb-commits at lists.llvm.org
Thu Dec 17 03:59:49 PST 2015


Author: ewancrawford
Date: Thu Dec 17 05:59:47 2015
New Revision: 255887

URL: http://llvm.org/viewvc/llvm-project?rev=255887&view=rev
Log:
Inspect DW_AT_const_value global static const variables

This patch adds support for printing global static const variables which are given a DW_AT_const_value DWARF tag by clang.

Fix for bug https://llvm.org/bugs/show_bug.cgi?id=25653

Reviewers: clayborg, tberghammer
Subscribers: emaste, lldb-commits
Differential Revision: http://reviews.llvm.org/D15576

Modified:
    lldb/trunk/packages/Python/lldbsuite/test/lang/c/global_variables/TestGlobalVariables.py
    lldb/trunk/packages/Python/lldbsuite/test/lang/c/global_variables/main.c
    lldb/trunk/source/Core/ValueObject.cpp
    lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
    lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp

Modified: lldb/trunk/packages/Python/lldbsuite/test/lang/c/global_variables/TestGlobalVariables.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/c/global_variables/TestGlobalVariables.py?rev=255887&r1=255886&r2=255887&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/lang/c/global_variables/TestGlobalVariables.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/lang/c/global_variables/TestGlobalVariables.py Thu Dec 17 05:59:47 2015
@@ -52,6 +52,7 @@ class GlobalVariablesTestCase(TestBase):
         # Check that GLOBAL scopes are indicated for the variables.
         self.expect("frame variable --show-types --scope --show-globals --no-args", VARIABLES_DISPLAYED_CORRECTLY,
             substrs = ['GLOBAL: (int) g_file_global_int = 42',
+                       'STATIC: (const int) g_file_static_int = 2',
                        'GLOBAL: (const char *) g_file_global_cstr',
                        '"g_file_global_cstr"',
                        'STATIC: (const char *) g_file_static_cstr',

Modified: lldb/trunk/packages/Python/lldbsuite/test/lang/c/global_variables/main.c
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/c/global_variables/main.c?rev=255887&r1=255886&r2=255887&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/lang/c/global_variables/main.c (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/lang/c/global_variables/main.c Thu Dec 17 05:59:47 2015
@@ -10,13 +10,14 @@
 
 int g_common_1; // Not initialized on purpose to cause it to be undefined external in .o file
 int g_file_global_int = 42;
+static const int g_file_static_int = 2;
 const char *g_file_global_cstr = "g_file_global_cstr";
 static const char *g_file_static_cstr = "g_file_static_cstr";
 
 extern int g_a;
 int main (int argc, char const *argv[])
 {
-    g_common_1 = g_file_global_int / 2;
+    g_common_1 = g_file_global_int / g_file_static_int;
     static const char *g_func_static_cstr = "g_func_static_cstr";
     printf ("%s %s\n", g_file_global_cstr, g_file_static_cstr);
     return g_file_global_int + g_a + g_common_1; // Set break point at this line.  //// break $source:$line; continue; var -global g_a -global g_global_int

Modified: lldb/trunk/source/Core/ValueObject.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=255887&r1=255886&r2=255887&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObject.cpp (original)
+++ lldb/trunk/source/Core/ValueObject.cpp Thu Dec 17 05:59:47 2015
@@ -1135,6 +1135,7 @@ ValueObject::GetData (DataExtractor& dat
         if (m_data.GetByteSize())
         {
             data = m_data;
+            error.Clear();
             return data.GetByteSize();
         }
         else

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp?rev=255887&r1=255886&r2=255887&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp Thu Dec 17 05:59:47 2015
@@ -815,7 +815,7 @@ DWARFCompileUnit::IndexPrivate (DWARFCom
         bool is_declaration = false;
         //bool is_artificial = false;
         bool has_address = false;
-        bool has_location = false;
+        bool has_location_or_const_value = false;
         bool is_global_or_static_variable = false;
         
         DWARFFormValue specification_die_form;
@@ -860,7 +860,8 @@ DWARFCompileUnit::IndexPrivate (DWARFCom
                     break;
 
                 case DW_AT_location:
-                    has_location = true;
+                case DW_AT_const_value:
+                    has_location_or_const_value = true;
                     if (tag == DW_TAG_variable)
                     {
                         const DWARFDebugInfoEntry* parent_die = die.GetParent();
@@ -1035,7 +1036,7 @@ DWARFCompileUnit::IndexPrivate (DWARFCom
             break;
 
         case DW_TAG_variable:
-            if (name && has_location && is_global_or_static_variable)
+            if (name && has_location_or_const_value && is_global_or_static_variable)
             {
                 globals.Insert (ConstString(name), DIERef(cu_offset, die.GetOffset()));
                 // Be sure to include variables by their mangled and demangled

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=255887&r1=255886&r2=255887&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Thu Dec 17 05:59:47 2015
@@ -4260,7 +4260,10 @@ SymbolFileDWARF::ParseVariableDIE
                 }
                 else
                 {
-                    scope = eValueTypeVariableLocal;
+                    if (location_is_const_value_data)
+                        scope = eValueTypeVariableStatic;
+                    else
+                        scope = eValueTypeVariableLocal;
                 }
             }
 




More information about the lldb-commits mailing list