diff options
author | Ed Maste <emaste@FreeBSD.org> | 2016-01-04 01:16:32 +0000 |
---|---|---|
committer | Ed Maste <emaste@FreeBSD.org> | 2016-01-04 01:16:32 +0000 |
commit | 9f2f44ceeb195c67fbbf0953f03c530f6f1e59d4 (patch) | |
tree | 1a3cc0a2c3d432ddf9ffc14f06bd43e8097fc93c /contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/DWARFAttribute.cpp | |
parent | 0a97e59728ecf251d065745cb716ffe32b24aa28 (diff) | |
parent | 3bd2e91faeb9eeec1aae82c64a3253afff551cfd (diff) | |
download | src-9f2f44ceeb195c67fbbf0953f03c530f6f1e59d4.tar.gz src-9f2f44ceeb195c67fbbf0953f03c530f6f1e59d4.zip |
Merge LLDB 3.8
As with previous imports a number of plugins not immediately relevant
to FreeBSD have been excluded:
ABIMacOSX_i386
ABIMacOSX_arm
ABIMacOSX_arm64
ABISysV_hexagon
AppleObjCRuntimeV2
AppleObjCRuntimeV1
SystemRuntimeMacOSX
RenderScriptRuntime
GoLanguageRuntime
GoLanguage
ObjCLanguage
ObjCPlusPlusLanguage
ObjectFilePECOFF
DynamicLoaderWindowsDYLD
platform_linux
platform_netbsd
PlatformWindows
PlatformKalimba
platform_android
DynamicLoaderMacOSXDYLD
ObjectContainerUniversalMachO
PlatformRemoteiOS
PlatformMacOSX
OperatingSystemGo
Notes
Notes:
svn path=/projects/clang380-import/; revision=293127
Diffstat (limited to 'contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/DWARFAttribute.cpp')
-rw-r--r-- | contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/DWARFAttribute.cpp | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/DWARFAttribute.cpp b/contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/DWARFAttribute.cpp new file mode 100644 index 000000000000..a522bcb35288 --- /dev/null +++ b/contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/DWARFAttribute.cpp @@ -0,0 +1,90 @@ +//===-- DWARFAttribute.cpp --------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "DWARFAttribute.h" +#include "DWARFDebugInfo.h" +#include "DWARFCompileUnit.h" + +DWARFAttributes::DWARFAttributes() : + m_infos() +{ +} + +DWARFAttributes::~DWARFAttributes() +{ +} + + +uint32_t +DWARFAttributes::FindAttributeIndex(dw_attr_t attr) const +{ + collection::const_iterator end = m_infos.end(); + collection::const_iterator beg = m_infos.begin(); + collection::const_iterator pos; + for (pos = beg; pos != end; ++pos) + { + if (pos->attr.get_attr() == attr) + return std::distance(beg, pos); + } + return UINT32_MAX; +} + +void +DWARFAttributes::Append(const DWARFCompileUnit *cu, dw_offset_t attr_die_offset, dw_attr_t attr, dw_form_t form) +{ + AttributeValue attr_value = { cu, attr_die_offset, { attr, form } }; + m_infos.push_back(attr_value); +} + +bool +DWARFAttributes::ContainsAttribute(dw_attr_t attr) const +{ + return FindAttributeIndex(attr) != UINT32_MAX; +} + +bool +DWARFAttributes::RemoveAttribute(dw_attr_t attr) +{ + uint32_t attr_index = FindAttributeIndex(attr); + if (attr_index != UINT32_MAX) + { + m_infos.erase(m_infos.begin() + attr_index); + return true; + } + return false; +} + +bool +DWARFAttributes::ExtractFormValueAtIndex (uint32_t i, DWARFFormValue &form_value) const +{ + const DWARFCompileUnit *cu = CompileUnitAtIndex(i); + form_value.SetCompileUnit(cu); + form_value.SetForm(FormAtIndex(i)); + lldb::offset_t offset = DIEOffsetAtIndex(i); + return form_value.ExtractValue(cu->GetSymbolFileDWARF()->get_debug_info_data(), &offset); +} + +uint64_t +DWARFAttributes::FormValueAsUnsigned (dw_attr_t attr, uint64_t fail_value) const +{ + const uint32_t attr_idx = FindAttributeIndex (attr); + if (attr_idx != UINT32_MAX) + return FormValueAsUnsignedAtIndex (attr_idx, fail_value); + return fail_value; +} + +uint64_t +DWARFAttributes::FormValueAsUnsignedAtIndex(uint32_t i, uint64_t fail_value) const +{ + DWARFFormValue form_value; + if (ExtractFormValueAtIndex(i, form_value)) + return form_value.Reference(); + return fail_value; +} + |