@@ -1873,7 +1873,7 @@ SymbolFileDWARF::ParseChildMembers
1873
1873
AccessType accessibility = default_accessibility;
1874
1874
bool is_virtual = false ;
1875
1875
bool is_base_of_class = true ;
1876
- // off_t member_offset = 0;
1876
+ off_t member_byte_offset = 0 ;
1877
1877
uint32_t i;
1878
1878
for (i=0 ; i<num_attributes; ++i)
1879
1879
{
@@ -1887,31 +1887,31 @@ SymbolFileDWARF::ParseChildMembers
1887
1887
case DW_AT_decl_line: decl.SetLine (form_value.Unsigned ()); break ;
1888
1888
case DW_AT_decl_column: decl.SetColumn (form_value.Unsigned ()); break ;
1889
1889
case DW_AT_type: encoding_uid = form_value.Reference (dwarf_cu); break ;
1890
- // case DW_AT_data_member_location:
1891
- // if (form_value.BlockData())
1892
- // {
1893
- // Value initialValue(0);
1894
- // Value memberOffset(0);
1895
- // const DataExtractor& debug_info_data = get_debug_info_data();
1896
- // uint32_t block_length = form_value.Unsigned();
1897
- // uint32_t block_offset = form_value.BlockData() - debug_info_data.GetDataStart();
1898
- // if (DWARFExpression::Evaluate (NULL,
1899
- // NULL,
1900
- // NULL,
1901
- // NULL,
1902
- // NULL,
1903
- // debug_info_data,
1904
- // block_offset,
1905
- // block_length,
1906
- // eRegisterKindDWARF,
1907
- // &initialValue,
1908
- // memberOffset,
1909
- // NULL))
1910
- // {
1911
- // member_offset = memberOffset.ResolveValue(NULL, NULL).UInt();
1912
- // }
1913
- // }
1914
- // break;
1890
+ case DW_AT_data_member_location:
1891
+ if (form_value.BlockData ())
1892
+ {
1893
+ Value initialValue (0 );
1894
+ Value memberOffset (0 );
1895
+ const DataExtractor& debug_info_data = get_debug_info_data ();
1896
+ uint32_t block_length = form_value.Unsigned ();
1897
+ uint32_t block_offset = form_value.BlockData () - debug_info_data.GetDataStart ();
1898
+ if (DWARFExpression::Evaluate (NULL ,
1899
+ NULL ,
1900
+ NULL ,
1901
+ NULL ,
1902
+ NULL ,
1903
+ debug_info_data,
1904
+ block_offset,
1905
+ block_length,
1906
+ eRegisterKindDWARF,
1907
+ &initialValue,
1908
+ memberOffset,
1909
+ NULL ))
1910
+ {
1911
+ member_byte_offset = memberOffset.ResolveValue (NULL , NULL ).UInt ();
1912
+ }
1913
+ }
1914
+ break ;
1915
1915
1916
1916
case DW_AT_accessibility:
1917
1917
accessibility = DW_ACCESS_to_AccessType (form_value.Unsigned ());
@@ -1940,6 +1940,17 @@ SymbolFileDWARF::ParseChildMembers
1940
1940
accessibility,
1941
1941
is_virtual,
1942
1942
is_base_of_class));
1943
+
1944
+ if (is_virtual)
1945
+ {
1946
+ layout_info.vbase_offsets .insert (std::make_pair (ClangASTType::GetAsCXXRecordDecl (class_clang_type),
1947
+ clang::CharUnits::fromQuantity (member_byte_offset)));
1948
+ }
1949
+ else
1950
+ {
1951
+ layout_info.base_offsets .insert (std::make_pair (ClangASTType::GetAsCXXRecordDecl (class_clang_type),
1952
+ clang::CharUnits::fromQuantity (member_byte_offset)));
1953
+ }
1943
1954
}
1944
1955
}
1945
1956
}
@@ -2278,37 +2289,68 @@ SymbolFileDWARF::ResolveClangOpaqueTypeDefinition (lldb::clang_type_t clang_type
2278
2289
2279
2290
ast.CompleteTagDeclarationDefinition (clang_type);
2280
2291
2281
- if (!layout_info.field_offsets .empty ())
2292
+ if (!layout_info.field_offsets .empty () ||
2293
+ !layout_info.base_offsets .empty () ||
2294
+ !layout_info.vbase_offsets .empty () )
2282
2295
{
2283
2296
if (type)
2284
2297
layout_info.bit_size = type->GetByteSize () * 8 ;
2285
2298
if (layout_info.bit_size == 0 )
2286
2299
layout_info.bit_size = die->GetAttributeValueAsUnsigned (this , dwarf_cu, DW_AT_byte_size, 0 ) * 8 ;
2287
- clang::QualType qual_type ( clang::QualType::getFromOpaquePtr (clang_type));
2288
- const clang::RecordType *record_type = clang::dyn_cast<clang::RecordType>(qual_type. getTypePtr () );
2289
- if (record_type )
2300
+
2301
+ clang::CXXRecordDecl *record_decl = ClangASTType::GetAsCXXRecordDecl (clang_type );
2302
+ if (record_decl )
2290
2303
{
2291
- const clang::RecordDecl *record_decl = record_type->getDecl ();
2292
-
2293
2304
if (log )
2294
2305
{
2295
2306
GetObjectFile ()->GetModule ()->LogMessage (log .get (),
2296
- " SymbolFileDWARF::ResolveClangOpaqueTypeDefinition (clang_type = %p) caching layout info for record_decl = %p, bit_size = %llu, alignment = %llu, field_offsets[%u], base_offsets[0 ], vbase_offsets[0 ])" ,
2307
+ " SymbolFileDWARF::ResolveClangOpaqueTypeDefinition (clang_type = %p) caching layout info for record_decl = %p, bit_size = %llu, alignment = %llu, field_offsets[%u], base_offsets[%u ], vbase_offsets[%u ])" ,
2297
2308
clang_type,
2298
2309
record_decl,
2299
2310
layout_info.bit_size ,
2300
2311
layout_info.alignment ,
2301
- (uint32_t )layout_info.field_offsets .size ());
2312
+ (uint32_t )layout_info.field_offsets .size (),
2313
+ (uint32_t )layout_info.base_offsets .size (),
2314
+ (uint32_t )layout_info.vbase_offsets .size ());
2302
2315
2316
+ uint32_t idx;
2317
+ {
2303
2318
llvm::DenseMap <const clang::FieldDecl *, uint64_t >::const_iterator pos, end = layout_info.field_offsets .end ();
2304
- for (pos = layout_info.field_offsets .begin (); pos != end; ++pos)
2319
+ for (idx = 0 , pos = layout_info.field_offsets .begin (); pos != end; ++pos, ++idx )
2305
2320
{
2306
2321
GetObjectFile ()->GetModule ()->LogMessage (log .get (),
2307
- " SymbolFileDWARF::ResolveClangOpaqueTypeDefinition (clang_type = %p) field = { bit_offset=%u, name='%s' }" ,
2322
+ " SymbolFileDWARF::ResolveClangOpaqueTypeDefinition (clang_type = %p) field[%u] = { bit_offset=%u, name='%s' }" ,
2308
2323
clang_type,
2324
+ idx,
2309
2325
(uint32_t )pos->second ,
2310
2326
pos->first ->getNameAsString ().c_str ());
2311
2327
}
2328
+ }
2329
+
2330
+ {
2331
+ llvm::DenseMap <const clang::CXXRecordDecl *, clang::CharUnits>::const_iterator base_pos, base_end = layout_info.base_offsets .end ();
2332
+ for (idx = 0 , base_pos = layout_info.base_offsets .begin (); base_pos != base_end; ++base_pos, ++idx)
2333
+ {
2334
+ GetObjectFile ()->GetModule ()->LogMessage (log .get (),
2335
+ " SymbolFileDWARF::ResolveClangOpaqueTypeDefinition (clang_type = %p) base[%u] = { byte_offset=%u, name='%s' }" ,
2336
+ clang_type,
2337
+ idx,
2338
+ (uint32_t )base_pos->second .getQuantity (),
2339
+ base_pos->first ->getNameAsString ().c_str ());
2340
+ }
2341
+ }
2342
+ {
2343
+ llvm::DenseMap <const clang::CXXRecordDecl *, clang::CharUnits>::const_iterator vbase_pos, vbase_end = layout_info.vbase_offsets .end ();
2344
+ for (idx = 0 , vbase_pos = layout_info.vbase_offsets .begin (); vbase_pos != vbase_end; ++vbase_pos, ++idx)
2345
+ {
2346
+ GetObjectFile ()->GetModule ()->LogMessage (log .get (),
2347
+ " SymbolFileDWARF::ResolveClangOpaqueTypeDefinition (clang_type = %p) vbase[%u] = { byte_offset=%u, name='%s' }" ,
2348
+ clang_type,
2349
+ idx,
2350
+ (uint32_t )vbase_pos->second .getQuantity (),
2351
+ vbase_pos->first ->getNameAsString ().c_str ());
2352
+ }
2353
+ }
2312
2354
}
2313
2355
m_record_decl_to_layout_map.insert (std::make_pair (record_decl, layout_info));
2314
2356
}
@@ -7259,6 +7301,8 @@ SymbolFileDWARF::LayoutRecordType (const clang::RecordDecl *record_decl,
7259
7301
bit_size = pos->second .bit_size ;
7260
7302
alignment = pos->second .alignment ;
7261
7303
field_offsets.swap (pos->second .field_offsets );
7304
+ base_offsets.swap (pos->second .base_offsets );
7305
+ vbase_offsets.swap (pos->second .vbase_offsets );
7262
7306
m_record_decl_to_layout_map.erase (pos);
7263
7307
success = true ;
7264
7308
}
0 commit comments