Index: lldb/include/lldb/Expression/DWARFExpression.h =================================================================== --- lldb/include/lldb/Expression/DWARFExpression.h +++ lldb/include/lldb/Expression/DWARFExpression.h @@ -43,8 +43,7 @@ // (.debug_loclists/.debug_loclists.dwo). }; - /// Constructor - explicit DWARFExpression(DWARFUnit *dwarf_cu); + DWARFExpression(); /// Constructor /// @@ -58,7 +57,7 @@ /// \param[in] data_length /// The byte length of the location expression. DWARFExpression(lldb::ModuleSP module, const DataExtractor &data, - DWARFUnit *dwarf_cu, lldb::offset_t data_offset, + const DWARFUnit *dwarf_cu, lldb::offset_t data_offset, lldb::offset_t data_length); /// Destructor @@ -141,32 +140,6 @@ std::function const &link_address_callback); - /// Make the expression parser read its location information from a given - /// data source. Does not change the offset and length - /// - /// \param[in] data - /// A data extractor configured to read the DWARF location expression's - /// bytecode. - void SetOpcodeData(const DataExtractor &data); - - /// Make the expression parser read its location information from a given - /// data source - /// - /// \param[in] module_sp - /// The module that defines the DWARF expression. - /// - /// \param[in] data - /// A data extractor configured to read the DWARF location expression's - /// bytecode. - /// - /// \param[in] data_offset - /// The offset of the location expression in the extractor. - /// - /// \param[in] data_length - /// The byte length of the location expression. - void SetOpcodeData(lldb::ModuleSP module_sp, const DataExtractor &data, - lldb::offset_t data_offset, lldb::offset_t data_length); - /// Copy the DWARF location expression into a local buffer. /// /// It is a good idea to copy the data so we don't keep the entire object @@ -178,25 +151,6 @@ /// end up being referenced. Location lists are typically small so even /// though we are copying the data, it shouldn't amount to that much for the /// variables we end up parsing. - /// - /// \param[in] module_sp - /// The module that defines the DWARF expression. - /// - /// \param[in] data - /// A data extractor configured to read and copy the DWARF - /// location expression's bytecode. - /// - /// \param[in] data_offset - /// The offset of the location expression in the extractor. - /// - /// \param[in] data_length - /// The byte length of the location expression. - void CopyOpcodeData(lldb::ModuleSP module_sp, const DataExtractor &data, - lldb::offset_t data_offset, lldb::offset_t data_length); - - void CopyOpcodeData(const void *data, lldb::offset_t data_length, - lldb::ByteOrder byte_order, uint8_t addr_byte_size); - void CopyOpcodeData(uint64_t const_value, lldb::offset_t const_value_byte_size, uint8_t addr_byte_size); @@ -294,7 +248,7 @@ /// details of the failure are provided through it. static bool Evaluate(ExecutionContext *exe_ctx, RegisterContext *reg_ctx, lldb::ModuleSP opcode_ctx, const DataExtractor &opcodes, - DWARFUnit *dwarf_cu, const lldb::offset_t offset, + const DWARFUnit *dwarf_cu, const lldb::offset_t offset, const lldb::offset_t length, const lldb::RegisterKind reg_set, const Value *initial_value_ptr, @@ -359,14 +313,15 @@ lldb::ModuleWP m_module_wp; ///< Module which defined this expression. DataExtractor m_data; ///< A data extractor capable of reading opcode bytes - DWARFUnit *m_dwarf_cu; ///< The DWARF compile unit this expression - ///belongs to. It is used + const DWARFUnit *m_dwarf_cu; ///< The DWARF compile unit this expression + /// belongs to. It is used ///< to evaluate values indexing into the .debug_addr section (e.g. ///< DW_OP_GNU_addr_index, DW_OP_GNU_const_index) lldb::RegisterKind m_reg_kind; ///< One of the defines that starts with LLDB_REGKIND_ lldb::addr_t m_loclist_slide; ///< A value used to slide the location list - ///offsets so that + /// offsets so that + /// m_c ///< they are relative to the object that owns the location list ///< (the function for frame base and variable location lists) }; Index: lldb/source/Expression/DWARFExpression.cpp =================================================================== --- lldb/source/Expression/DWARFExpression.cpp +++ lldb/source/Expression/DWARFExpression.cpp @@ -53,13 +53,13 @@ } // DWARFExpression constructor -DWARFExpression::DWARFExpression(DWARFUnit *dwarf_cu) - : m_module_wp(), m_data(), m_dwarf_cu(dwarf_cu), +DWARFExpression::DWARFExpression() + : m_module_wp(), m_data(), m_dwarf_cu(nullptr), m_reg_kind(eRegisterKindDWARF), m_loclist_slide(LLDB_INVALID_ADDRESS) {} DWARFExpression::DWARFExpression(lldb::ModuleSP module_sp, const DataExtractor &data, - DWARFUnit *dwarf_cu, + const DWARFUnit *dwarf_cu, lldb::offset_t data_offset, lldb::offset_t data_length) : m_module_wp(), m_data(data, data_offset, data_length), @@ -74,34 +74,6 @@ bool DWARFExpression::IsValid() const { return m_data.GetByteSize() > 0; } -void DWARFExpression::SetOpcodeData(const DataExtractor &data) { - m_data = data; -} - -void DWARFExpression::CopyOpcodeData(lldb::ModuleSP module_sp, - const DataExtractor &data, - lldb::offset_t data_offset, - lldb::offset_t data_length) { - const uint8_t *bytes = data.PeekData(data_offset, data_length); - if (bytes) { - m_module_wp = module_sp; - m_data.SetData(DataBufferSP(new DataBufferHeap(bytes, data_length))); - m_data.SetByteOrder(data.GetByteOrder()); - m_data.SetAddressByteSize(data.GetAddressByteSize()); - } -} - -void DWARFExpression::CopyOpcodeData(const void *data, - lldb::offset_t data_length, - ByteOrder byte_order, - uint8_t addr_byte_size) { - if (data && data_length) { - m_data.SetData(DataBufferSP(new DataBufferHeap(data, data_length))); - m_data.SetByteOrder(byte_order); - m_data.SetAddressByteSize(addr_byte_size); - } -} - void DWARFExpression::CopyOpcodeData(uint64_t const_value, lldb::offset_t const_value_byte_size, uint8_t addr_byte_size) { @@ -113,14 +85,6 @@ } } -void DWARFExpression::SetOpcodeData(lldb::ModuleSP module_sp, - const DataExtractor &data, - lldb::offset_t data_offset, - lldb::offset_t data_length) { - m_module_wp = module_sp; - m_data.SetData(data, data_offset, data_length); -} - void DWARFExpression::DumpLocation(Stream *s, lldb::offset_t offset, lldb::offset_t length, lldb::DescriptionLevel level, @@ -1310,7 +1274,7 @@ bool DWARFExpression::Evaluate( ExecutionContext *exe_ctx, RegisterContext *reg_ctx, lldb::ModuleSP module_sp, const DataExtractor &opcodes, - DWARFUnit *dwarf_cu, const lldb::offset_t opcodes_offset, + const DWARFUnit *dwarf_cu, const lldb::offset_t opcodes_offset, const lldb::offset_t opcodes_length, const lldb::RegisterKind reg_kind, const Value *initial_value_ptr, const Value *object_address_ptr, Value &result, Status *error_ptr) { Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp =================================================================== --- lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -2553,7 +2553,7 @@ int call_file = 0; int call_line = 0; int call_column = 0; - DWARFExpression frame_base(die.GetCU()); + DWARFExpression frame_base; const dw_tag_t tag = die.Tag(); @@ -2692,7 +2692,6 @@ const size_t num_attributes = die.GetAttributes(attributes); if (num_attributes > 0) { Declaration decl; - // DWARFExpression location; const char *name = nullptr; const char *prop_name = nullptr; const char *prop_getter_name = nullptr; @@ -3172,7 +3171,6 @@ const size_t num_attributes = die.GetAttributes(attributes); if (num_attributes > 0) { Declaration decl; - DWARFExpression location(die.GetCU()); DWARFFormValue encoding_form; AccessType accessibility = default_accessibility; bool is_virtual = false; Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp =================================================================== --- lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp +++ lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp @@ -505,8 +505,8 @@ uint32_t block_offset = form_value.BlockData() - debug_info_data.GetDataStart(); uint32_t block_length = form_value.Unsigned(); - frame_base->SetOpcodeData(module, debug_info_data, block_offset, - block_length); + frame_base = new (frame_base) DWARFExpression( + module, debug_info_data, cu, block_offset, block_length); } else { const DWARFDataExtractor &debug_loc_data = dwarf2Data->DebugLocData(); @@ -515,8 +515,9 @@ size_t loc_list_length = DWARFExpression::LocationListSize( cu, debug_loc_data, debug_loc_offset); if (loc_list_length > 0) { - frame_base->SetOpcodeData(module, debug_loc_data, - debug_loc_offset, loc_list_length); + frame_base = new (frame_base) + DWARFExpression(module, debug_loc_data, cu, + debug_loc_offset, loc_list_length); if (lo_pc != LLDB_INVALID_ADDRESS) { assert(lo_pc >= cu->GetBaseAddress()); frame_base->SetLocationListSlide(lo_pc - Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp =================================================================== --- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -3111,7 +3111,7 @@ Declaration decl; uint32_t i; DWARFFormValue type_die_form; - DWARFExpression location(die.GetCU()); + DWARFExpression location; bool is_external = false; bool is_artificial = false; bool location_is_const_value_data = false; @@ -3162,8 +3162,8 @@ uint32_t block_offset = form_value.BlockData() - debug_info_data.GetDataStart(); uint32_t block_length = form_value.Unsigned(); - location.CopyOpcodeData(module, debug_info_data, block_offset, - block_length); + location = DWARFExpression(module, debug_info_data, die.GetCU(), + block_offset, block_length); } else if (DWARFFormValue::IsDataForm(form_value.Form())) { // Retrieve the value as a data expression. DWARFFormValue::FixedFormSizes fixed_form_sizes = @@ -3182,8 +3182,9 @@ const_value = form_value; } } else - location.CopyOpcodeData(module, debug_info_data, data_offset, - data_length); + location = + DWARFExpression(module, debug_info_data, die.GetCU(), + data_offset, data_length); } else { // Retrieve the value as a string expression. if (form_value.Form() == DW_FORM_strp) { @@ -3194,15 +3195,17 @@ uint32_t data_offset = attributes.DIEOffsetAtIndex(i); uint32_t data_length = fixed_form_sizes.GetSize(form_value.Form()); - location.CopyOpcodeData(module, debug_info_data, data_offset, - data_length); + location = + DWARFExpression(module, debug_info_data, die.GetCU(), + data_offset, data_length); } else { const char *str = form_value.AsCString(); uint32_t string_offset = str - (const char *)debug_info_data.GetDataStart(); uint32_t string_length = strlen(str) + 1; - location.CopyOpcodeData(module, debug_info_data, - string_offset, string_length); + location = + DWARFExpression(module, debug_info_data, die.GetCU(), + string_offset, string_length); } } } @@ -3216,7 +3219,8 @@ uint32_t block_offset = form_value.BlockData() - data.GetDataStart(); uint32_t block_length = form_value.Unsigned(); - location.CopyOpcodeData(module, data, block_offset, block_length); + location = DWARFExpression(module, data, die.GetCU(), + block_offset, block_length); } else { const DWARFDataExtractor &debug_loc_data = DebugLocData(); const dw_offset_t debug_loc_offset = form_value.Unsigned(); @@ -3224,8 +3228,8 @@ size_t loc_list_length = DWARFExpression::LocationListSize( die.GetCU(), debug_loc_data, debug_loc_offset); if (loc_list_length > 0) { - location.CopyOpcodeData(module, debug_loc_data, - debug_loc_offset, loc_list_length); + location = DWARFExpression(module, debug_loc_data, die.GetCU(), + debug_loc_offset, loc_list_length); assert(func_low_pc != LLDB_INVALID_ADDRESS); location.SetLocationListSlide( func_low_pc - Index: lldb/source/Plugins/SymbolFile/NativePDB/DWARFLocationExpression.cpp =================================================================== --- lldb/source/Plugins/SymbolFile/NativePDB/DWARFLocationExpression.cpp +++ lldb/source/Plugins/SymbolFile/NativePDB/DWARFLocationExpression.cpp @@ -111,13 +111,13 @@ uint32_t address_size = architecture.GetAddressByteSize(); uint32_t byte_size = architecture.GetDataByteSize(); if (byte_order == eByteOrderInvalid || address_size == 0) - return DWARFExpression(nullptr); + return DWARFExpression(); RegisterKind register_kind = eRegisterKindDWARF; StreamBuffer<32> stream(Stream::eBinary, address_size, byte_order); if (!writer(stream, register_kind)) - return DWARFExpression(nullptr); + return DWARFExpression(); DataBufferSP buffer = std::make_shared(stream.GetData(), stream.GetSize()); Index: lldb/source/Plugins/SymbolFile/PDB/PDBLocationToDWARFExpression.cpp =================================================================== --- lldb/source/Plugins/SymbolFile/PDB/PDBLocationToDWARFExpression.cpp +++ lldb/source/Plugins/SymbolFile/PDB/PDBLocationToDWARFExpression.cpp @@ -69,7 +69,7 @@ is_constant = true; if (!module) - return DWARFExpression(nullptr); + return DWARFExpression(); const ArchSpec &architecture = module->GetArchitecture(); llvm::Triple::ArchType arch_type = architecture.GetMachine(); @@ -77,7 +77,7 @@ uint32_t address_size = architecture.GetAddressByteSize(); uint32_t byte_size = architecture.GetDataByteSize(); if (byte_order == eByteOrderInvalid || address_size == 0) - return DWARFExpression(nullptr); + return DWARFExpression(); RegisterKind register_kind = eRegisterKindDWARF; StreamBuffer<32> stream(Stream::eBinary, address_size, byte_order); @@ -88,13 +88,13 @@ SectionList *section_list = module->GetSectionList(); if (!section_list) - return DWARFExpression(nullptr); + return DWARFExpression(); uint32_t section_id = symbol.getAddressSection(); auto section = section_list->FindSectionByID(section_id); if (!section) - return DWARFExpression(nullptr); + return DWARFExpression(); uint32_t offset = symbol.getAddressOffset(); stream.PutMaxHex64(section->GetFileAddress() + offset, address_size, @@ -129,7 +129,7 @@ register_kind = eRegisterKindLLDB; reg_num = GetLLDBRegisterNumber(arch_type, reg_id); if (reg_num == LLDB_INVALID_REGNUM) - return DWARFExpression(nullptr); + return DWARFExpression(); } if (reg_num > 31) { @@ -149,7 +149,7 @@ register_kind = eRegisterKindLLDB; uint32_t reg_num = GetLLDBRegisterNumber(arch_type, symbol.getRegisterId()); if (reg_num == LLDB_INVALID_REGNUM) - return DWARFExpression(nullptr); + return DWARFExpression(); if (reg_num > 31) { stream.PutHex8(DW_OP_regx); @@ -168,7 +168,7 @@ break; } default: - return DWARFExpression(nullptr); + return DWARFExpression(); } DataBufferSP buffer = Index: lldb/source/Symbol/Function.cpp =================================================================== --- lldb/source/Symbol/Function.cpp +++ lldb/source/Symbol/Function.cpp @@ -184,7 +184,7 @@ const AddressRange &range) : UserID(func_uid), m_comp_unit(comp_unit), m_type_uid(type_uid), m_type(type), m_mangled(mangled), m_block(func_uid), m_range(range), - m_frame_base(nullptr), m_flags(), m_prologue_byte_size(0) { + m_frame_base(), m_flags(), m_prologue_byte_size(0) { m_block.SetParentScope(this); assert(comp_unit != nullptr); }