Changeset View
Changeset View
Standalone View
Standalone View
lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.cpp
Show All 19 Lines | |||||
void DWARFAbbreviationDeclarationSet::Clear() { | void DWARFAbbreviationDeclarationSet::Clear() { | ||||
m_idx_offset = 0; | m_idx_offset = 0; | ||||
m_decls.clear(); | m_decls.clear(); | ||||
} | } | ||||
//---------------------------------------------------------------------- | //---------------------------------------------------------------------- | ||||
// DWARFAbbreviationDeclarationSet::Extract() | // DWARFAbbreviationDeclarationSet::Extract() | ||||
//---------------------------------------------------------------------- | //---------------------------------------------------------------------- | ||||
bool DWARFAbbreviationDeclarationSet::Extract(const DWARFDataExtractor &data, | llvm::Error | ||||
DWARFAbbreviationDeclarationSet::extract(const DWARFDataExtractor &data, | |||||
lldb::offset_t *offset_ptr) { | lldb::offset_t *offset_ptr) { | ||||
const lldb::offset_t begin_offset = *offset_ptr; | const lldb::offset_t begin_offset = *offset_ptr; | ||||
m_offset = begin_offset; | m_offset = begin_offset; | ||||
Clear(); | Clear(); | ||||
DWARFAbbreviationDeclaration abbrevDeclaration; | DWARFAbbreviationDeclaration abbrevDeclaration; | ||||
dw_uleb128_t prev_abbr_code = 0; | dw_uleb128_t prev_abbr_code = 0; | ||||
while (abbrevDeclaration.Extract(data, offset_ptr)) { | DWARFEnumState state = DWARFEnumState::MoreItems; | ||||
while (state == DWARFEnumState::MoreItems) { | |||||
llvm::Expected<DWARFEnumState> es = | |||||
abbrevDeclaration.extract(data, offset_ptr); | |||||
if (!es) | |||||
return es.takeError(); | |||||
state = *es; | |||||
m_decls.push_back(abbrevDeclaration); | m_decls.push_back(abbrevDeclaration); | ||||
if (m_idx_offset == 0) | if (m_idx_offset == 0) | ||||
m_idx_offset = abbrevDeclaration.Code(); | m_idx_offset = abbrevDeclaration.Code(); | ||||
else { | else { | ||||
if (prev_abbr_code + 1 != abbrevDeclaration.Code()) | if (prev_abbr_code + 1 != abbrevDeclaration.Code()) | ||||
m_idx_offset = | m_idx_offset = | ||||
UINT32_MAX; // Out of order indexes, we can't do O(1) lookups... | UINT32_MAX; // Out of order indexes, we can't do O(1) lookups... | ||||
} | } | ||||
prev_abbr_code = abbrevDeclaration.Code(); | prev_abbr_code = abbrevDeclaration.Code(); | ||||
} | } | ||||
return begin_offset != *offset_ptr; | return llvm::ErrorSuccess(); | ||||
} | } | ||||
//---------------------------------------------------------------------- | //---------------------------------------------------------------------- | ||||
// DWARFAbbreviationDeclarationSet::Dump() | // DWARFAbbreviationDeclarationSet::Dump() | ||||
//---------------------------------------------------------------------- | //---------------------------------------------------------------------- | ||||
void DWARFAbbreviationDeclarationSet::Dump(Stream *s) const { | void DWARFAbbreviationDeclarationSet::Dump(Stream *s) const { | ||||
std::for_each( | std::for_each( | ||||
m_decls.begin(), m_decls.end(), | m_decls.begin(), m_decls.end(), | ||||
▲ Show 20 Lines • Show All 78 Lines • ▼ Show 20 Lines | |||||
// DWARFDebugAbbrev constructor | // DWARFDebugAbbrev constructor | ||||
//---------------------------------------------------------------------- | //---------------------------------------------------------------------- | ||||
DWARFDebugAbbrev::DWARFDebugAbbrev() | DWARFDebugAbbrev::DWARFDebugAbbrev() | ||||
: m_abbrevCollMap(), m_prev_abbr_offset_pos(m_abbrevCollMap.end()) {} | : m_abbrevCollMap(), m_prev_abbr_offset_pos(m_abbrevCollMap.end()) {} | ||||
//---------------------------------------------------------------------- | //---------------------------------------------------------------------- | ||||
// DWARFDebugAbbrev::Parse() | // DWARFDebugAbbrev::Parse() | ||||
//---------------------------------------------------------------------- | //---------------------------------------------------------------------- | ||||
void DWARFDebugAbbrev::Parse(const DWARFDataExtractor &data) { | llvm::Error DWARFDebugAbbrev::parse(const DWARFDataExtractor &data) { | ||||
lldb::offset_t offset = 0; | lldb::offset_t offset = 0; | ||||
while (data.ValidOffset(offset)) { | while (data.ValidOffset(offset)) { | ||||
uint32_t initial_cu_offset = offset; | uint32_t initial_cu_offset = offset; | ||||
DWARFAbbreviationDeclarationSet abbrevDeclSet; | DWARFAbbreviationDeclarationSet abbrevDeclSet; | ||||
if (abbrevDeclSet.Extract(data, &offset)) | llvm::Error error = abbrevDeclSet.extract(data, &offset); | ||||
if (error) | |||||
return error; | |||||
m_abbrevCollMap[initial_cu_offset] = abbrevDeclSet; | m_abbrevCollMap[initial_cu_offset] = abbrevDeclSet; | ||||
else | |||||
break; | |||||
} | } | ||||
m_prev_abbr_offset_pos = m_abbrevCollMap.end(); | m_prev_abbr_offset_pos = m_abbrevCollMap.end(); | ||||
return llvm::ErrorSuccess(); | |||||
} | } | ||||
//---------------------------------------------------------------------- | //---------------------------------------------------------------------- | ||||
// DWARFDebugAbbrev::Dump() | // DWARFDebugAbbrev::Dump() | ||||
//---------------------------------------------------------------------- | //---------------------------------------------------------------------- | ||||
void DWARFDebugAbbrev::Dump(Stream *s) const { | void DWARFDebugAbbrev::Dump(Stream *s) const { | ||||
if (m_abbrevCollMap.empty()) { | if (m_abbrevCollMap.empty()) { | ||||
s->PutCString("< EMPTY >\n"); | s->PutCString("< EMPTY >\n"); | ||||
Show All 39 Lines |