From 0f46e34f74e1881891078f3d7364722eac022a18 Mon Sep 17 00:00:00 2001 From: George Rimar Date: Wed, 31 Oct 2018 16:12:29 +0000 Subject: [PATCH] [LLDB] - Regroup the switch entries in DWARFFormValue::ExtractValue. NFC. This is NFC to clean up the `DWARFFormValue::ExtractValue`. It groups similar `DW_FORM_*` and removes an excessive assignment of `ref_addr_size` (it was assigned right after in any case). llvm-svn: 345733 --- .../Plugins/SymbolFile/DWARF/DWARFFormValue.cpp | 86 +++++++--------------- 1 file changed, 26 insertions(+), 60 deletions(-) diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp index 1882d21..a705728 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp @@ -182,8 +182,12 @@ bool DWARFFormValue::ExtractValue(const DWARFDataExtractor &data, switch (m_form) { case DW_FORM_addr: assert(m_cu); - m_value.value.uval = data.GetMaxU64( - offset_ptr, DWARFUnit::GetAddressByteSize(m_cu)); + m_value.value.uval = + data.GetMaxU64(offset_ptr, DWARFUnit::GetAddressByteSize(m_cu)); + break; + case DW_FORM_block1: + m_value.value.uval = data.GetU8(offset_ptr); + is_block = true; break; case DW_FORM_block2: m_value.value.uval = data.GetU16(offset_ptr); @@ -193,56 +197,39 @@ bool DWARFFormValue::ExtractValue(const DWARFDataExtractor &data, m_value.value.uval = data.GetU32(offset_ptr); is_block = true; break; - case DW_FORM_data2: - m_value.value.uval = data.GetU16(offset_ptr); - break; - case DW_FORM_data4: - m_value.value.uval = data.GetU32(offset_ptr); - break; - case DW_FORM_data8: - m_value.value.uval = data.GetU64(offset_ptr); - break; case DW_FORM_data16: m_value.value.uval = 16; is_block = true; break; - case DW_FORM_string: - m_value.value.cstr = data.GetCStr(offset_ptr); - break; case DW_FORM_exprloc: case DW_FORM_block: m_value.value.uval = data.GetULEB128(offset_ptr); is_block = true; break; - case DW_FORM_block1: - m_value.value.uval = data.GetU8(offset_ptr); - is_block = true; - break; - case DW_FORM_data1: - m_value.value.uval = data.GetU8(offset_ptr); - break; - case DW_FORM_flag: - m_value.value.uval = data.GetU8(offset_ptr); + case DW_FORM_string: + m_value.value.cstr = data.GetCStr(offset_ptr); break; case DW_FORM_sdata: m_value.value.sval = data.GetSLEB128(offset_ptr); break; case DW_FORM_strp: case DW_FORM_line_strp: + case DW_FORM_sec_offset: assert(m_cu); m_value.value.uval = data.GetMaxU64(offset_ptr, DWARFUnit::IsDWARF64(m_cu) ? 8 : 4); break; - case DW_FORM_addrx: - case DW_FORM_strx: - m_value.value.uval = data.GetULEB128(offset_ptr); - break; case DW_FORM_addrx1: case DW_FORM_strx1: + case DW_FORM_ref1: + case DW_FORM_data1: + case DW_FORM_flag: m_value.value.uval = data.GetU8(offset_ptr); break; case DW_FORM_addrx2: case DW_FORM_strx2: + case DW_FORM_ref2: + case DW_FORM_data2: m_value.value.uval = data.GetU16(offset_ptr); break; case DW_FORM_addrx3: @@ -251,61 +238,40 @@ bool DWARFFormValue::ExtractValue(const DWARFDataExtractor &data, break; case DW_FORM_addrx4: case DW_FORM_strx4: + case DW_FORM_ref4: + case DW_FORM_data4: m_value.value.uval = data.GetU32(offset_ptr); break; - // case DW_FORM_APPLE_db_str: + case DW_FORM_data8: + case DW_FORM_ref8: + case DW_FORM_ref_sig8: + m_value.value.uval = data.GetU64(offset_ptr); + break; + case DW_FORM_addrx: + case DW_FORM_strx: case DW_FORM_udata: + case DW_FORM_ref_udata: + case DW_FORM_GNU_str_index: + case DW_FORM_GNU_addr_index: m_value.value.uval = data.GetULEB128(offset_ptr); break; case DW_FORM_ref_addr: assert(m_cu); - ref_addr_size = 4; if (m_cu->GetVersion() <= 2) ref_addr_size = m_cu->GetAddressByteSize(); else ref_addr_size = m_cu->IsDWARF64() ? 8 : 4; m_value.value.uval = data.GetMaxU64(offset_ptr, ref_addr_size); break; - case DW_FORM_ref1: - m_value.value.uval = data.GetU8(offset_ptr); - break; - case DW_FORM_ref2: - m_value.value.uval = data.GetU16(offset_ptr); - break; - case DW_FORM_ref4: - m_value.value.uval = data.GetU32(offset_ptr); - break; - case DW_FORM_ref8: - m_value.value.uval = data.GetU64(offset_ptr); - break; - case DW_FORM_ref_udata: - m_value.value.uval = data.GetULEB128(offset_ptr); - break; case DW_FORM_indirect: m_form = data.GetULEB128(offset_ptr); indirect = true; break; - - case DW_FORM_sec_offset: - assert(m_cu); - m_value.value.uval = - data.GetMaxU64(offset_ptr, DWARFUnit::IsDWARF64(m_cu) ? 8 : 4); - break; case DW_FORM_flag_present: m_value.value.uval = 1; break; - case DW_FORM_ref_sig8: - m_value.value.uval = data.GetU64(offset_ptr); - break; - case DW_FORM_GNU_str_index: - m_value.value.uval = data.GetULEB128(offset_ptr); - break; - case DW_FORM_GNU_addr_index: - m_value.value.uval = data.GetULEB128(offset_ptr); - break; default: return false; - break; } } while (indirect); -- 2.7.4