@@ -379,18 +379,17 @@ uint32_t SymbolFileNativePDB::CalculateNumCompileUnits() {
379
379
return count;
380
380
}
381
381
382
- Block & SymbolFileNativePDB::CreateBlock (PdbCompilandSymId block_id) {
382
+ Block * SymbolFileNativePDB::CreateBlock (PdbCompilandSymId block_id) {
383
383
CompilandIndexItem *cii = m_index->compilands ().GetCompiland (block_id.modi );
384
384
CVSymbol sym = cii->m_debug_stream .readSymbolAtOffset (block_id.offset );
385
385
CompUnitSP comp_unit = GetOrCreateCompileUnit (*cii);
386
386
lldb::user_id_t opaque_block_uid = toOpaqueUid (block_id);
387
- BlockSP child_block = std::make_shared<Block>(opaque_block_uid);
388
387
auto ts_or_err = GetTypeSystemForLanguage (comp_unit->GetLanguage ());
389
388
if (auto err = ts_or_err.takeError ())
390
- return *child_block ;
389
+ return nullptr ;
391
390
auto ts = *ts_or_err;
392
391
if (!ts)
393
- return *child_block ;
392
+ return nullptr ;
394
393
PdbAstBuilder* ast_builder = ts->GetNativePDBParser ();
395
394
396
395
switch (sym.kind ()) {
@@ -403,7 +402,7 @@ Block &SymbolFileNativePDB::CreateBlock(PdbCompilandSymId block_id) {
403
402
Block &block = func->GetBlock (false );
404
403
if (block.GetNumRanges () == 0 )
405
404
block.AddRange (Block::Range (0 , func->GetAddressRange ().GetByteSize ()));
406
- return block;
405
+ return & block;
407
406
}
408
407
break ;
409
408
}
@@ -416,13 +415,16 @@ Block &SymbolFileNativePDB::CreateBlock(PdbCompilandSymId block_id) {
416
415
cantFail (SymbolDeserializer::deserializeAs<BlockSym>(sym, block));
417
416
lldbassert (block.Parent != 0 );
418
417
PdbCompilandSymId parent_id (block_id.modi , block.Parent );
419
- Block &parent_block = GetOrCreateBlock (parent_id);
420
- Function *func = parent_block.CalculateSymbolContextFunction ();
418
+ Block *parent_block = GetOrCreateBlock (parent_id);
419
+ if (!parent_block)
420
+ return nullptr ;
421
+ Function *func = parent_block->CalculateSymbolContextFunction ();
421
422
lldbassert (func);
422
423
lldb::addr_t block_base =
423
424
m_index->MakeVirtualAddress (block.Segment , block.CodeOffset );
424
425
lldb::addr_t func_base =
425
426
func->GetAddressRange ().GetBaseAddress ().GetFileAddress ();
427
+ BlockSP child_block = std::make_shared<Block>(opaque_block_uid);
426
428
if (block_base >= func_base)
427
429
child_block->AddRange (Block::Range (block_base - func_base, block.CodeSize ));
428
430
else {
@@ -435,7 +437,7 @@ Block &SymbolFileNativePDB::CreateBlock(PdbCompilandSymId block_id) {
435
437
block_id.modi , block_id.offset , block_base,
436
438
block_base + block.CodeSize , func_base);
437
439
}
438
- parent_block. AddChild (child_block);
440
+ parent_block-> AddChild (child_block);
439
441
ast_builder->GetOrCreateBlockDecl (block_id);
440
442
m_blocks.insert ({opaque_block_uid, child_block});
441
443
break ;
@@ -445,8 +447,11 @@ Block &SymbolFileNativePDB::CreateBlock(PdbCompilandSymId block_id) {
445
447
comp_unit->GetLineTable ();
446
448
447
449
std::shared_ptr<InlineSite> inline_site = m_inline_sites[opaque_block_uid];
448
- Block &parent_block = GetOrCreateBlock (inline_site->parent_id );
449
- parent_block.AddChild (child_block);
450
+ Block *parent_block = GetOrCreateBlock (inline_site->parent_id );
451
+ if (!parent_block)
452
+ return nullptr ;
453
+ BlockSP child_block = std::make_shared<Block>(opaque_block_uid);
454
+ parent_block->AddChild (child_block);
450
455
ast_builder->GetOrCreateInlinedFunctionDecl (block_id);
451
456
// Copy ranges from InlineSite to Block.
452
457
for (size_t i = 0 ; i < inline_site->ranges .GetSize (); ++i) {
@@ -469,7 +474,7 @@ Block &SymbolFileNativePDB::CreateBlock(PdbCompilandSymId block_id) {
469
474
lldbassert (false && " Symbol is not a block!" );
470
475
}
471
476
472
- return *child_block ;
477
+ return nullptr ;
473
478
}
474
479
475
480
lldb::FunctionSP SymbolFileNativePDB::CreateFunction (PdbCompilandSymId func_id,
@@ -997,10 +1002,10 @@ SymbolFileNativePDB::GetOrCreateCompileUnit(const CompilandIndexItem &cci) {
997
1002
return emplace_result.first ->second ;
998
1003
}
999
1004
1000
- Block & SymbolFileNativePDB::GetOrCreateBlock (PdbCompilandSymId block_id) {
1005
+ Block * SymbolFileNativePDB::GetOrCreateBlock (PdbCompilandSymId block_id) {
1001
1006
auto iter = m_blocks.find (toOpaqueUid (block_id));
1002
1007
if (iter != m_blocks.end ())
1003
- return * iter->second ;
1008
+ return iter->second . get () ;
1004
1009
1005
1010
return CreateBlock (block_id);
1006
1011
}
@@ -1124,14 +1129,16 @@ uint32_t SymbolFileNativePDB::ResolveSymbolContext(
1124
1129
}
1125
1130
1126
1131
if (type == PDB_SymType::Block) {
1127
- Block &block = GetOrCreateBlock (csid);
1128
- sc.function = block.CalculateSymbolContextFunction ();
1132
+ Block *block = GetOrCreateBlock (csid);
1133
+ if (!block)
1134
+ continue ;
1135
+ sc.function = block->CalculateSymbolContextFunction ();
1129
1136
if (sc.function ) {
1130
1137
sc.function ->GetBlock (true );
1131
1138
addr_t func_base =
1132
1139
sc.function ->GetAddressRange ().GetBaseAddress ().GetFileAddress ();
1133
1140
addr_t offset = file_addr - func_base;
1134
- sc.block = block. FindInnermostBlockByOffset (offset);
1141
+ sc.block = block-> FindInnermostBlockByOffset (offset);
1135
1142
}
1136
1143
}
1137
1144
if (sc.function )
@@ -1837,12 +1844,16 @@ VariableSP SymbolFileNativePDB::CreateLocalVariable(PdbCompilandSymId scope_id,
1837
1844
PdbCompilandSymId var_id,
1838
1845
bool is_param) {
1839
1846
ModuleSP module = GetObjectFile ()->GetModule ();
1840
- Block &block = GetOrCreateBlock (scope_id);
1847
+ Block *block = GetOrCreateBlock (scope_id);
1848
+ if (!block)
1849
+ return nullptr ;
1850
+
1841
1851
// Get function block.
1842
- Block *func_block = & block;
1852
+ Block *func_block = block;
1843
1853
while (func_block->GetParent ()) {
1844
1854
func_block = func_block->GetParent ();
1845
1855
}
1856
+
1846
1857
Address addr;
1847
1858
func_block->GetStartAddress (addr);
1848
1859
VariableInfo var_info =
@@ -1875,8 +1886,8 @@ VariableSP SymbolFileNativePDB::CreateLocalVariable(PdbCompilandSymId scope_id,
1875
1886
bool static_member = false ;
1876
1887
Variable::RangeList scope_ranges;
1877
1888
VariableSP var_sp = std::make_shared<Variable>(
1878
- toOpaqueUid (var_id), name.c_str (), name.c_str (), sftype, var_scope,
1879
- &block, scope_ranges, &decl, var_info.location , external, artificial,
1889
+ toOpaqueUid (var_id), name.c_str (), name.c_str (), sftype, var_scope, block,
1890
+ scope_ranges, &decl, var_info.location , external, artificial,
1880
1891
location_is_constant_data, static_member);
1881
1892
if (!is_param) {
1882
1893
auto ts_or_err = GetTypeSystemForLanguage (comp_unit_sp->GetLanguage ());
@@ -1935,7 +1946,9 @@ TypeSP SymbolFileNativePDB::GetOrCreateTypedef(PdbGlobalSymId id) {
1935
1946
}
1936
1947
1937
1948
size_t SymbolFileNativePDB::ParseVariablesForBlock (PdbCompilandSymId block_id) {
1938
- Block &block = GetOrCreateBlock (block_id);
1949
+ Block *block = GetOrCreateBlock (block_id);
1950
+ if (!block)
1951
+ return 0 ;
1939
1952
1940
1953
size_t count = 0 ;
1941
1954
@@ -1977,10 +1990,10 @@ size_t SymbolFileNativePDB::ParseVariablesForBlock(PdbCompilandSymId block_id) {
1977
1990
return 0 ;
1978
1991
}
1979
1992
1980
- VariableListSP variables = block. GetBlockVariableList (false );
1993
+ VariableListSP variables = block-> GetBlockVariableList (false );
1981
1994
if (!variables) {
1982
1995
variables = std::make_shared<VariableList>();
1983
- block. SetVariableList (variables);
1996
+ block-> SetVariableList (variables);
1984
1997
}
1985
1998
1986
1999
CVSymbolArray syms = limitSymbolArrayToScope (
@@ -2027,7 +2040,7 @@ size_t SymbolFileNativePDB::ParseVariablesForBlock(PdbCompilandSymId block_id) {
2027
2040
2028
2041
// Pass false for set_children, since we call this recursively so that the
2029
2042
// children will call this for themselves.
2030
- block. SetDidParseVariables (true , false );
2043
+ block-> SetDidParseVariables (true , false );
2031
2044
2032
2045
return count;
2033
2046
}
0 commit comments