[Lldb-commits] [lldb] r225219 - Make array symbol reading resilient to incomplete DWARF.
Siva Chandra
sivachandra at google.com
Mon Jan 5 15:06:14 PST 2015
Author: sivachandra
Date: Mon Jan 5 17:06:14 2015
New Revision: 225219
URL: http://llvm.org/viewvc/llvm-project?rev=225219&view=rev
Log:
Make array symbol reading resilient to incomplete DWARF.
Summary:
GCC emits DW_TAG_subrange_type for static member arrays, but with no
attributes. This in turn results in wrong type/value of the array when
printing with 'target variable <array var name>'. This patch fixes this
so that the array value is printed in this format:
(<element type> []) <array var name> = {}
Earlier, the array was being interpreted to be of its element type.
Note: This does not fix anything to do with 'expr' or 'p' commands.
Those commands still error out complaining about incomplete types.
Test Plan: dotest.py -p TestStaticVariables
Reviewers: emaste, clayborg
Reviewed By: clayborg
Subscribers: lldb-commits
Differential Revision: http://reviews.llvm.org/D6799
Modified:
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/trunk/test/lang/cpp/class_static/TestStaticVariables.py
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=225219&r1=225218&r2=225219&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Mon Jan 5 17:06:14 2015
@@ -6836,17 +6836,26 @@ SymbolFileDWARF::ParseType (const Symbol
byte_stride = element_type->GetByteSize();
ClangASTType array_element_type = element_type->GetClangForwardType();
uint64_t array_element_bit_stride = byte_stride * 8 + bit_stride;
- uint64_t num_elements = 0;
- std::vector<uint64_t>::const_reverse_iterator pos;
- std::vector<uint64_t>::const_reverse_iterator end = element_orders.rend();
- for (pos = element_orders.rbegin(); pos != end; ++pos)
+ if (element_orders.size() > 0)
{
- num_elements = *pos;
- clang_type = ast.CreateArrayType (array_element_type,
- num_elements,
- is_vector);
- array_element_type = clang_type;
- array_element_bit_stride = num_elements ? array_element_bit_stride * num_elements : array_element_bit_stride;
+ uint64_t num_elements = 0;
+ std::vector<uint64_t>::const_reverse_iterator pos;
+ std::vector<uint64_t>::const_reverse_iterator end = element_orders.rend();
+ for (pos = element_orders.rbegin(); pos != end; ++pos)
+ {
+ num_elements = *pos;
+ clang_type = ast.CreateArrayType (array_element_type,
+ num_elements,
+ is_vector);
+ array_element_type = clang_type;
+ array_element_bit_stride = num_elements ?
+ array_element_bit_stride * num_elements :
+ array_element_bit_stride;
+ }
+ }
+ else
+ {
+ clang_type = ast.CreateArrayType (array_element_type, 0, is_vector);
}
ConstString empty_name;
type_sp.reset( new Type (MakeUserID(die->GetOffset()),
Modified: lldb/trunk/test/lang/cpp/class_static/TestStaticVariables.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/cpp/class_static/TestStaticVariables.py?rev=225219&r1=225218&r2=225219&view=diff
==============================================================================
--- lldb/trunk/test/lang/cpp/class_static/TestStaticVariables.py (original)
+++ lldb/trunk/test/lang/cpp/class_static/TestStaticVariables.py Mon Jan 5 17:06:14 2015
@@ -20,8 +20,6 @@ class StaticVariableTestCase(TestBase):
self.buildDsym()
self.static_variable_commands()
- @expectedFailureFreeBSD('llvm.org/pr15261', failing_compilers) # lldb on FreeBSD does not display the size of (class or file)static arrays
- @expectedFailureLinux('llvm.org/pr15261', failing_compilers) # lldb on Linux does not display the size of (class or file)static arrays
@dwarf_test
def test_with_dwarf_and_run_command(self):
"""Test that file and class static variables display correctly."""
@@ -69,13 +67,13 @@ class StaticVariableTestCase(TestBase):
# global variables are no longer displayed with the "frame variable" command.
self.expect('target variable A::g_points', VARIABLES_DISPLAYED_CORRECTLY,
- substrs = ['(PointType [2]) A::g_points'])
+ patterns=['\(PointType \[[1-9]*\]\) A::g_points = {.*}'])
self.expect('target variable g_points', VARIABLES_DISPLAYED_CORRECTLY,
substrs = ['(PointType [2]) g_points'])
# On Mac OS X, gcc 4.2 emits the wrong debug info for A::g_points.
# A::g_points is an array of two elements.
- if sys.platform.startswith("darwin") and self.getCompiler() in ['clang', 'llvm-gcc']:
+ if sys.platform.startswith("darwin") or sys.platform.startswith("linux"):
self.expect("target variable A::g_points[1].x", VARIABLES_DISPLAYED_CORRECTLY,
startstr = "(int) A::g_points[1].x = 11")
More information about the lldb-commits
mailing list