diff options
Diffstat (limited to 'source/Expression/DWARFExpression.cpp')
| -rw-r--r-- | source/Expression/DWARFExpression.cpp | 376 |
1 files changed, 196 insertions, 180 deletions
diff --git a/source/Expression/DWARFExpression.cpp b/source/Expression/DWARFExpression.cpp index 14011aece7c99..55eb65f32b5af 100644 --- a/source/Expression/DWARFExpression.cpp +++ b/source/Expression/DWARFExpression.cpp @@ -15,6 +15,7 @@ // C++ Includes #include <vector> +#include "lldb/Core/Module.h" #include "lldb/Core/RegisterValue.h" #include "lldb/Core/Scalar.h" #include "lldb/Core/Value.h" @@ -37,13 +38,13 @@ #include "lldb/Target/StackID.h" #include "lldb/Target/Thread.h" -#include "Plugins/SymbolFile/DWARF/DWARFCompileUnit.h" +#include "Plugins/SymbolFile/DWARF/DWARFUnit.h" using namespace lldb; using namespace lldb_private; static lldb::addr_t -ReadAddressFromDebugAddrSection(const DWARFCompileUnit *dwarf_cu, +ReadAddressFromDebugAddrSection(const DWARFUnit *dwarf_cu, uint32_t index) { uint32_t index_size = dwarf_cu->GetAddressByteSize(); dw_offset_t addr_base = dwarf_cu->GetAddrBase(); @@ -55,7 +56,7 @@ ReadAddressFromDebugAddrSection(const DWARFCompileUnit *dwarf_cu, //---------------------------------------------------------------------- // DWARFExpression constructor //---------------------------------------------------------------------- -DWARFExpression::DWARFExpression(DWARFCompileUnit *dwarf_cu) +DWARFExpression::DWARFExpression(DWARFUnit *dwarf_cu) : m_module_wp(), m_data(), m_dwarf_cu(dwarf_cu), m_reg_kind(eRegisterKindDWARF), m_loclist_slide(LLDB_INVALID_ADDRESS) {} @@ -66,7 +67,7 @@ DWARFExpression::DWARFExpression(const DWARFExpression &rhs) DWARFExpression::DWARFExpression(lldb::ModuleSP module_sp, const DataExtractor &data, - DWARFCompileUnit *dwarf_cu, + DWARFUnit *dwarf_cu, lldb::offset_t data_offset, lldb::offset_t data_length) : m_module_wp(), m_data(data, data_offset, data_length), @@ -147,13 +148,13 @@ void DWARFExpression::DumpLocation(Stream *s, lldb::offset_t offset, break; case lldb::eDescriptionLevelBrief: - if (offset > start_offset) + if (op_offset > start_offset) s->PutChar(' '); break; case lldb::eDescriptionLevelFull: case lldb::eDescriptionLevelVerbose: - if (offset > start_offset) + if (op_offset > start_offset) s->EOL(); s->Indent(); if (level == lldb::eDescriptionLevelFull) @@ -172,34 +173,34 @@ void DWARFExpression::DumpLocation(Stream *s, lldb::offset_t offset, *s << "DW_OP_deref"; break; // 0x06 case DW_OP_const1u: - s->Printf("DW_OP_const1u(0x%2.2x) ", m_data.GetU8(&offset)); + s->Printf("DW_OP_const1u(0x%2.2x)", m_data.GetU8(&offset)); break; // 0x08 1 1-byte constant case DW_OP_const1s: - s->Printf("DW_OP_const1s(0x%2.2x) ", m_data.GetU8(&offset)); + s->Printf("DW_OP_const1s(0x%2.2x)", m_data.GetU8(&offset)); break; // 0x09 1 1-byte constant case DW_OP_const2u: - s->Printf("DW_OP_const2u(0x%4.4x) ", m_data.GetU16(&offset)); + s->Printf("DW_OP_const2u(0x%4.4x)", m_data.GetU16(&offset)); break; // 0x0a 1 2-byte constant case DW_OP_const2s: - s->Printf("DW_OP_const2s(0x%4.4x) ", m_data.GetU16(&offset)); + s->Printf("DW_OP_const2s(0x%4.4x)", m_data.GetU16(&offset)); break; // 0x0b 1 2-byte constant case DW_OP_const4u: - s->Printf("DW_OP_const4u(0x%8.8x) ", m_data.GetU32(&offset)); + s->Printf("DW_OP_const4u(0x%8.8x)", m_data.GetU32(&offset)); break; // 0x0c 1 4-byte constant case DW_OP_const4s: - s->Printf("DW_OP_const4s(0x%8.8x) ", m_data.GetU32(&offset)); + s->Printf("DW_OP_const4s(0x%8.8x)", m_data.GetU32(&offset)); break; // 0x0d 1 4-byte constant case DW_OP_const8u: - s->Printf("DW_OP_const8u(0x%16.16" PRIx64 ") ", m_data.GetU64(&offset)); + s->Printf("DW_OP_const8u(0x%16.16" PRIx64 ")", m_data.GetU64(&offset)); break; // 0x0e 1 8-byte constant case DW_OP_const8s: - s->Printf("DW_OP_const8s(0x%16.16" PRIx64 ") ", m_data.GetU64(&offset)); + s->Printf("DW_OP_const8s(0x%16.16" PRIx64 ")", m_data.GetU64(&offset)); break; // 0x0f 1 8-byte constant case DW_OP_constu: - s->Printf("DW_OP_constu(0x%" PRIx64 ") ", m_data.GetULEB128(&offset)); + s->Printf("DW_OP_constu(0x%" PRIx64 ")", m_data.GetULEB128(&offset)); break; // 0x10 1 ULEB128 constant case DW_OP_consts: - s->Printf("DW_OP_consts(0x%" PRId64 ") ", m_data.GetSLEB128(&offset)); + s->Printf("DW_OP_consts(0x%" PRId64 ")", m_data.GetSLEB128(&offset)); break; // 0x11 1 SLEB128 constant case DW_OP_dup: s->PutCString("DW_OP_dup"); @@ -211,7 +212,7 @@ void DWARFExpression::DumpLocation(Stream *s, lldb::offset_t offset, s->PutCString("DW_OP_over"); break; // 0x14 case DW_OP_pick: - s->Printf("DW_OP_pick(0x%2.2x) ", m_data.GetU8(&offset)); + s->Printf("DW_OP_pick(0x%2.2x)", m_data.GetU8(&offset)); break; // 0x15 1 1-byte stack index case DW_OP_swap: s->PutCString("DW_OP_swap"); @@ -253,7 +254,7 @@ void DWARFExpression::DumpLocation(Stream *s, lldb::offset_t offset, s->PutCString("DW_OP_plus"); break; // 0x22 case DW_OP_plus_uconst: // 0x23 1 ULEB128 addend - s->Printf("DW_OP_plus_uconst(0x%" PRIx64 ") ", + s->Printf("DW_OP_plus_uconst(0x%" PRIx64 ")", m_data.GetULEB128(&offset)); break; @@ -679,8 +680,8 @@ static bool ReadRegisterValueAsScalar(RegisterContext *reg_ctx, error_ptr->Clear(); return true; } else { - // If we get this error, then we need to implement a value - // buffer in the dwarf expression evaluation function... + // If we get this error, then we need to implement a value buffer in + // the dwarf expression evaluation function... if (error_ptr) error_ptr->SetErrorStringWithFormat( "register %s can't be converted to a scalar value", @@ -991,17 +992,17 @@ bool DWARFExpression::Update_DW_OP_addr(lldb::addr_t file_addr) { if (op == DW_OP_addr) { const uint32_t addr_byte_size = m_data.GetAddressByteSize(); - // We have to make a copy of the data as we don't know if this - // data is from a read only memory mapped buffer, so we duplicate - // all of the data first, then modify it, and if all goes well, - // we then replace the data for this expression + // We have to make a copy of the data as we don't know if this data is + // from a read only memory mapped buffer, so we duplicate all of the data + // first, then modify it, and if all goes well, we then replace the data + // for this expression // So first we copy the data into a heap buffer std::unique_ptr<DataBufferHeap> head_data_ap( new DataBufferHeap(m_data.GetDataStart(), m_data.GetByteSize())); - // Make en encoder so we can write the address into the buffer using - // the correct byte order (endianness) + // Make en encoder so we can write the address into the buffer using the + // correct byte order (endianness) DataEncoder encoder(head_data_ap->GetBytes(), head_data_ap->GetByteSize(), m_data.GetByteOrder(), addr_byte_size); @@ -1009,9 +1010,8 @@ bool DWARFExpression::Update_DW_OP_addr(lldb::addr_t file_addr) { if (encoder.PutMaxU64(offset, addr_byte_size, file_addr) == UINT32_MAX) return false; - // All went well, so now we can reset the data using a shared - // pointer to the heap data so "m_data" will now correctly - // manage the heap data. + // All went well, so now we can reset the data using a shared pointer to + // the heap data so "m_data" will now correctly manage the heap data. m_data.SetData(DataBufferSP(head_data_ap.release())); return true; } else { @@ -1025,9 +1025,9 @@ bool DWARFExpression::Update_DW_OP_addr(lldb::addr_t file_addr) { } bool DWARFExpression::ContainsThreadLocalStorage() const { - // We are assuming for now that any thread local variable will not - // have a location list. This has been true for all thread local - // variables we have seen so far produced by any compiler. + // We are assuming for now that any thread local variable will not have a + // location list. This has been true for all thread local variables we have + // seen so far produced by any compiler. if (IsLocationList()) return false; lldb::offset_t offset = 0; @@ -1048,24 +1048,24 @@ bool DWARFExpression::LinkThreadLocalStorage( lldb::ModuleSP new_module_sp, std::function<lldb::addr_t(lldb::addr_t file_addr)> const &link_address_callback) { - // We are assuming for now that any thread local variable will not - // have a location list. This has been true for all thread local - // variables we have seen so far produced by any compiler. + // We are assuming for now that any thread local variable will not have a + // location list. This has been true for all thread local variables we have + // seen so far produced by any compiler. if (IsLocationList()) return false; const uint32_t addr_byte_size = m_data.GetAddressByteSize(); - // We have to make a copy of the data as we don't know if this - // data is from a read only memory mapped buffer, so we duplicate - // all of the data first, then modify it, and if all goes well, - // we then replace the data for this expression + // We have to make a copy of the data as we don't know if this data is from a + // read only memory mapped buffer, so we duplicate all of the data first, + // then modify it, and if all goes well, we then replace the data for this + // expression // So first we copy the data into a heap buffer std::shared_ptr<DataBufferHeap> heap_data_sp( new DataBufferHeap(m_data.GetDataStart(), m_data.GetByteSize())); - // Make en encoder so we can write the address into the buffer using - // the correct byte order (endianness) + // Make en encoder so we can write the address into the buffer using the + // correct byte order (endianness) DataEncoder encoder(heap_data_sp->GetBytes(), heap_data_sp->GetByteSize(), m_data.GetByteOrder(), addr_byte_size); @@ -1080,8 +1080,7 @@ bool DWARFExpression::LinkThreadLocalStorage( switch (op) { case DW_OP_const4u: // Remember the const offset in case we later have a - // DW_OP_form_tls_address - // or DW_OP_GNU_push_tls_address + // DW_OP_form_tls_address or DW_OP_GNU_push_tls_address const_offset = offset; const_value = m_data.GetU32(&offset); decoded_data = true; @@ -1090,8 +1089,7 @@ bool DWARFExpression::LinkThreadLocalStorage( case DW_OP_const8u: // Remember the const offset in case we later have a - // DW_OP_form_tls_address - // or DW_OP_GNU_push_tls_address + // DW_OP_form_tls_address or DW_OP_GNU_push_tls_address const_offset = offset; const_value = m_data.GetU64(&offset); decoded_data = true; @@ -1101,21 +1099,15 @@ bool DWARFExpression::LinkThreadLocalStorage( case DW_OP_form_tls_address: case DW_OP_GNU_push_tls_address: // DW_OP_form_tls_address and DW_OP_GNU_push_tls_address must be preceded - // by - // a file address on the stack. We assume that DW_OP_const4u or - // DW_OP_const8u - // is used for these values, and we check that the last opcode we got - // before - // either of these was DW_OP_const4u or DW_OP_const8u. If so, then we can - // link - // the value accodingly. For Darwin, the value in the DW_OP_const4u or - // DW_OP_const8u is the file address of a structure that contains a - // function - // pointer, the pthread key and the offset into the data pointed to by the - // pthread key. So we must link this address and also set the module of - // this - // expression to the new_module_sp so we can resolve the file address - // correctly + // by a file address on the stack. We assume that DW_OP_const4u or + // DW_OP_const8u is used for these values, and we check that the last + // opcode we got before either of these was DW_OP_const4u or + // DW_OP_const8u. If so, then we can link the value accodingly. For + // Darwin, the value in the DW_OP_const4u or DW_OP_const8u is the file + // address of a structure that contains a function pointer, the pthread + // key and the offset into the data pointed to by the pthread key. So we + // must link this address and also set the module of this expression to + // the new_module_sp so we can resolve the file address correctly if (const_byte_size > 0) { lldb::addr_t linked_file_addr = link_address_callback(const_value); if (linked_file_addr == LLDB_INVALID_ADDRESS) @@ -1144,8 +1136,8 @@ bool DWARFExpression::LinkThreadLocalStorage( } // If we linked the TLS address correctly, update the module so that when the - // expression - // is evaluated it can resolve the file address to a load address and read the + // expression is evaluated it can resolve the file address to a load address + // and read the // TLS data m_module_wp = new_module_sp; m_data.SetData(heap_data_sp); @@ -1323,7 +1315,7 @@ bool DWARFExpression::Evaluate(ExecutionContext *exe_ctx, bool DWARFExpression::Evaluate( ExecutionContext *exe_ctx, RegisterContext *reg_ctx, lldb::ModuleSP module_sp, const DataExtractor &opcodes, - DWARFCompileUnit *dwarf_cu, const lldb::offset_t opcodes_offset, + 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) { @@ -1383,6 +1375,7 @@ bool DWARFExpression::Evaluate( } log->Printf("0x%8.8" PRIx64 ": %s", op_offset, DW_OP_value_to_name(op)); } + switch (op) { //---------------------------------------------------------------------- // The DW_OP_addr operation has a single operand that encodes a machine @@ -1391,17 +1384,22 @@ bool DWARFExpression::Evaluate( case DW_OP_addr: stack.push_back(Scalar(opcodes.GetAddress(&offset))); stack.back().SetValueType(Value::eValueTypeFileAddress); + // Convert the file address to a load address, so subsequent + // DWARF operators can operate on it. + if (frame) + stack.back().ConvertToLoadAddress(module_sp.get(), + frame->CalculateTarget().get()); break; //---------------------------------------------------------------------- // The DW_OP_addr_sect_offset4 is used for any location expressions in // shared libraries that have a location like: // DW_OP_addr(0x1000) - // If this address resides in a shared library, then this virtual - // address won't make sense when it is evaluated in the context of a - // running process where shared libraries have been slid. To account for - // this, this new address type where we can store the section pointer - // and a 4 byte offset. + // If this address resides in a shared library, then this virtual address + // won't make sense when it is evaluated in the context of a running + // process where shared libraries have been slid. To account for this, this + // new address type where we can store the section pointer and a 4 byte + // offset. //---------------------------------------------------------------------- // case DW_OP_addr_sect_offset4: // { @@ -1436,9 +1434,9 @@ bool DWARFExpression::Evaluate( // OPCODE: DW_OP_deref // OPERANDS: none // DESCRIPTION: Pops the top stack entry and treats it as an address. - // The value retrieved from that address is pushed. The size of the - // data retrieved from the dereferenced address is the size of an - // address on the target machine. + // The value retrieved from that address is pushed. The size of the data + // retrieved from the dereferenced address is the size of an address on the + // target machine. //---------------------------------------------------------------------- case DW_OP_deref: { if (stack.empty()) { @@ -1455,6 +1453,33 @@ bool DWARFExpression::Evaluate( stack.back().GetScalar() = ptr; stack.back().ClearContext(); } break; + case Value::eValueTypeFileAddress: { + auto file_addr = stack.back().GetScalar().ULongLong( + LLDB_INVALID_ADDRESS); + if (!module_sp) { + if (error_ptr) + error_ptr->SetErrorStringWithFormat( + "need module to resolve file address for DW_OP_deref"); + return false; + } + Address so_addr; + if (!module_sp->ResolveFileAddress(file_addr, so_addr)) { + if (error_ptr) + error_ptr->SetErrorStringWithFormat( + "failed to resolve file address in module"); + return false; + } + addr_t load_Addr = so_addr.GetLoadAddress(exe_ctx->GetTargetPtr()); + if (load_Addr == LLDB_INVALID_ADDRESS) { + if (error_ptr) + error_ptr->SetErrorStringWithFormat( + "failed to resolve load address"); + return false; + } + stack.back().GetScalar() = load_Addr; + stack.back().SetValueType(Value::eValueTypeLoadAddress); + // Fall through to load address code below... + } LLVM_FALLTHROUGH; case Value::eValueTypeLoadAddress: if (exe_ctx) { if (process) { @@ -1500,13 +1525,13 @@ bool DWARFExpression::Evaluate( // 1 - uint8_t that specifies the size of the data to dereference. // DESCRIPTION: Behaves like the DW_OP_deref operation: it pops the top // stack entry and treats it as an address. The value retrieved from that - // address is pushed. In the DW_OP_deref_size operation, however, the - // size in bytes of the data retrieved from the dereferenced address is + // address is pushed. In the DW_OP_deref_size operation, however, the size + // in bytes of the data retrieved from the dereferenced address is // specified by the single operand. This operand is a 1-byte unsigned // integral constant whose value may not be larger than the size of an - // address on the target machine. The data retrieved is zero extended - // to the size of an address on the target machine before being pushed - // on the expression stack. + // address on the target machine. The data retrieved is zero extended to + // the size of an address on the target machine before being pushed on the + // expression stack. //---------------------------------------------------------------------- case DW_OP_deref_size: { if (stack.empty()) { @@ -1525,8 +1550,7 @@ bool DWARFExpression::Evaluate( // I can't decide whether the size operand should apply to the bytes in // their // lldb-host endianness or the target endianness.. I doubt this'll ever - // come up - // but I'll opt for assuming big endian regardless. + // come up but I'll opt for assuming big endian regardless. switch (size) { case 1: ptr = ptr & 0xff; @@ -1622,18 +1646,17 @@ bool DWARFExpression::Evaluate( // OPERANDS: 1 // 1 - uint8_t that specifies the size of the data to dereference. // DESCRIPTION: Behaves like the DW_OP_xderef operation: the entry at - // the top of the stack is treated as an address. The second stack - // entry is treated as an "address space identifier" for those - // architectures that support multiple address spaces. The top two - // stack elements are popped, a data item is retrieved through an - // implementation-defined address calculation and pushed as the new - // stack top. In the DW_OP_xderef_size operation, however, the size in - // bytes of the data retrieved from the dereferenced address is - // specified by the single operand. This operand is a 1-byte unsigned - // integral constant whose value may not be larger than the size of an - // address on the target machine. The data retrieved is zero extended - // to the size of an address on the target machine before being pushed - // on the expression stack. + // the top of the stack is treated as an address. The second stack entry is + // treated as an "address space identifier" for those architectures that + // support multiple address spaces. The top two stack elements are popped, + // a data item is retrieved through an implementation-defined address + // calculation and pushed as the new stack top. In the DW_OP_xderef_size + // operation, however, the size in bytes of the data retrieved from the + // dereferenced address is specified by the single operand. This operand is + // a 1-byte unsigned integral constant whose value may not be larger than + // the size of an address on the target machine. The data retrieved is zero + // extended to the size of an address on the target machine before being + // pushed on the expression stack. //---------------------------------------------------------------------- case DW_OP_xderef_size: if (error_ptr) @@ -1643,13 +1666,13 @@ bool DWARFExpression::Evaluate( // OPCODE: DW_OP_xderef // OPERANDS: none // DESCRIPTION: Provides an extended dereference mechanism. The entry at - // the top of the stack is treated as an address. The second stack entry - // is treated as an "address space identifier" for those architectures - // that support multiple address spaces. The top two stack elements are - // popped, a data item is retrieved through an implementation-defined - // address calculation and pushed as the new stack top. The size of the - // data retrieved from the dereferenced address is the size of an address - // on the target machine. + // the top of the stack is treated as an address. The second stack entry is + // treated as an "address space identifier" for those architectures that + // support multiple address spaces. The top two stack elements are popped, + // a data item is retrieved through an implementation-defined address + // calculation and pushed as the new stack top. The size of the data + // retrieved from the dereferenced address is the size of an address on the + // target machine. //---------------------------------------------------------------------- case DW_OP_xderef: if (error_ptr) @@ -1661,16 +1684,13 @@ bool DWARFExpression::Evaluate( // // Opcode Operand 1 // --------------- ---------------------------------------------------- - // DW_OP_const1u 1-byte unsigned integer constant - // DW_OP_const1s 1-byte signed integer constant - // DW_OP_const2u 2-byte unsigned integer constant - // DW_OP_const2s 2-byte signed integer constant - // DW_OP_const4u 4-byte unsigned integer constant - // DW_OP_const4s 4-byte signed integer constant - // DW_OP_const8u 8-byte unsigned integer constant - // DW_OP_const8s 8-byte signed integer constant - // DW_OP_constu unsigned LEB128 integer constant - // DW_OP_consts signed LEB128 integer constant + // DW_OP_const1u 1-byte unsigned integer constant DW_OP_const1s + // 1-byte signed integer constant DW_OP_const2u 2-byte unsigned integer + // constant DW_OP_const2s 2-byte signed integer constant DW_OP_const4u + // 4-byte unsigned integer constant DW_OP_const4s 4-byte signed integer + // constant DW_OP_const8u 8-byte unsigned integer constant DW_OP_const8s + // 8-byte signed integer constant DW_OP_constu unsigned LEB128 integer + // constant DW_OP_consts signed LEB128 integer constant //---------------------------------------------------------------------- case DW_OP_const1u: stack.push_back(Scalar((uint8_t)opcodes.GetU8(&offset))); @@ -1789,9 +1809,9 @@ bool DWARFExpression::Evaluate( // OPCODE: DW_OP_rot // OPERANDS: none // DESCRIPTION: Rotates the first three stack entries. The entry at - // the top of the stack becomes the third stack entry, the second - // entry becomes the top of the stack, and the third entry becomes - // the second entry. + // the top of the stack becomes the third stack entry, the second entry + // becomes the top of the stack, and the third entry becomes the second + // entry. //---------------------------------------------------------------------- case DW_OP_rot: if (stack.size() < 3) { @@ -1853,8 +1873,8 @@ bool DWARFExpression::Evaluate( // OPCODE: DW_OP_div // OPERANDS: none // DESCRIPTION: pops the top two stack values, divides the former second - // entry by the former top of the stack using signed division, and - // pushes the result. + // entry by the former top of the stack using signed division, and pushes + // the result. //---------------------------------------------------------------------- case DW_OP_div: if (stack.size() < 2) { @@ -1905,8 +1925,8 @@ bool DWARFExpression::Evaluate( // OPCODE: DW_OP_mod // OPERANDS: none // DESCRIPTION: pops the top two stack values and pushes the result of - // the calculation: former second stack entry modulo the former top of - // the stack. + // the calculation: former second stack entry modulo the former top of the + // stack. //---------------------------------------------------------------------- case DW_OP_mod: if (stack.size() < 2) { @@ -2050,8 +2070,8 @@ bool DWARFExpression::Evaluate( // OPCODE: DW_OP_shl // OPERANDS: none // DESCRIPTION: pops the top two stack entries, shifts the former - // second entry left by the number of bits specified by the former top - // of the stack, and pushes the result. + // second entry left by the number of bits specified by the former top of + // the stack, and pushes the result. //---------------------------------------------------------------------- case DW_OP_shl: if (stack.size() < 2) { @@ -2096,8 +2116,8 @@ bool DWARFExpression::Evaluate( // OPERANDS: none // DESCRIPTION: pops the top two stack entries, shifts the former second // entry right arithmetically (divide the magnitude by 2, keep the same - // sign for the result) by the number of bits specified by the former - // top of the stack, and pushes the result. + // sign for the result) by the number of bits specified by the former top + // of the stack, and pushes the result. //---------------------------------------------------------------------- case DW_OP_shra: if (stack.size() < 2) { @@ -2136,8 +2156,8 @@ bool DWARFExpression::Evaluate( // OPCODE: DW_OP_skip // OPERANDS: int16_t // DESCRIPTION: An unconditional branch. Its single operand is a 2-byte - // signed integer constant. The 2-byte constant is the number of bytes - // of the DWARF expression to skip forward or backward from the current + // signed integer constant. The 2-byte constant is the number of bytes of + // the DWARF expression to skip forward or backward from the current // operation, beginning after the 2-byte constant. //---------------------------------------------------------------------- case DW_OP_skip: { @@ -2156,11 +2176,10 @@ bool DWARFExpression::Evaluate( // OPCODE: DW_OP_bra // OPERANDS: int16_t // DESCRIPTION: A conditional branch. Its single operand is a 2-byte - // signed integer constant. This operation pops the top of stack. If - // the value popped is not the constant 0, the 2-byte constant operand - // is the number of bytes of the DWARF expression to skip forward or - // backward from the current operation, beginning after the 2-byte - // constant. + // signed integer constant. This operation pops the top of stack. If the + // value popped is not the constant 0, the 2-byte constant operand is the + // number of bytes of the DWARF expression to skip forward or backward from + // the current operation, beginning after the 2-byte constant. //---------------------------------------------------------------------- case DW_OP_bra: if (stack.empty()) { @@ -2537,15 +2556,15 @@ bool DWARFExpression::Evaluate( // OPERANDS: 1 // ULEB128: byte size of the piece // DESCRIPTION: The operand describes the size in bytes of the piece of - // the object referenced by the DWARF expression whose result is at the - // top of the stack. If the piece is located in a register, but does not - // occupy the entire register, the placement of the piece within that - // register is defined by the ABI. + // the object referenced by the DWARF expression whose result is at the top + // of the stack. If the piece is located in a register, but does not occupy + // the entire register, the placement of the piece within that register is + // defined by the ABI. // - // Many compilers store a single variable in sets of registers, or store - // a variable partially in memory and partially in registers. - // DW_OP_piece provides a way of describing how large a part of a - // variable a particular DWARF expression refers to. + // Many compilers store a single variable in sets of registers, or store a + // variable partially in memory and partially in registers. DW_OP_piece + // provides a way of describing how large a part of a variable a particular + // DWARF expression refers to. //---------------------------------------------------------------------- case DW_OP_piece: { const uint64_t piece_byte_size = opcodes.GetULEB128(&offset); @@ -2555,8 +2574,8 @@ bool DWARFExpression::Evaluate( if (stack.empty()) { // In a multi-piece expression, this means that the current piece is - // not available. - // Fill with zeros for now by resizing the data and appending it + // not available. Fill with zeros for now by resizing the data and + // appending it curr_piece.ResizeData(piece_byte_size); ::memset(curr_piece.GetBuffer().GetBytes(), 0, piece_byte_size); pieces.AppendDataToHostBuffer(curr_piece); @@ -2646,9 +2665,9 @@ bool DWARFExpression::Evaluate( // Check if this is the first piece? if (op_piece_offset == 0) { - // This is the first piece, we should push it back onto the stack so - // subsequent - // pieces will be able to access this piece and add to it + // This is the first piece, we should push it back onto the stack + // so subsequent pieces will be able to access this piece and add + // to it if (pieces.AppendDataToHostBuffer(curr_piece) == 0) { if (error_ptr) error_ptr->SetErrorString("failed to append piece data"); @@ -2706,7 +2725,7 @@ bool DWARFExpression::Evaluate( if (error_ptr) { error_ptr->SetErrorStringWithFormat( "unable to extract DW_OP_bit_piece(bit_size = %" PRIu64 - ", bit_offset = %" PRIu64 ") from an addresss value.", + ", bit_offset = %" PRIu64 ") from an address value.", piece_bit_size, piece_bit_offset); } return false; @@ -2727,11 +2746,11 @@ bool DWARFExpression::Evaluate( // OPCODE: DW_OP_push_object_address // OPERANDS: none // DESCRIPTION: Pushes the address of the object currently being - // evaluated as part of evaluation of a user presented expression. - // This object may correspond to an independent variable described by - // its own DIE or it may be a component of an array, structure, or class - // whose address has been dynamically determined by an earlier step - // during user expression evaluation. + // evaluated as part of evaluation of a user presented expression. This + // object may correspond to an independent variable described by its own + // DIE or it may be a component of an array, structure, or class whose + // address has been dynamically determined by an earlier step during user + // expression evaluation. //---------------------------------------------------------------------- case DW_OP_push_object_address: if (object_address_ptr) @@ -2749,21 +2768,20 @@ bool DWARFExpression::Evaluate( // OPERANDS: // uint16_t compile unit relative offset of a DIE // DESCRIPTION: Performs subroutine calls during evaluation - // of a DWARF expression. The operand is the 2-byte unsigned offset - // of a debugging information entry in the current compilation unit. + // of a DWARF expression. The operand is the 2-byte unsigned offset of a + // debugging information entry in the current compilation unit. // // Operand interpretation is exactly like that for DW_FORM_ref2. // - // This operation transfers control of DWARF expression evaluation - // to the DW_AT_location attribute of the referenced DIE. If there is - // no such attribute, then there is no effect. Execution of the DWARF - // expression of a DW_AT_location attribute may add to and/or remove from - // values on the stack. Execution returns to the point following the call - // when the end of the attribute is reached. Values on the stack at the - // time of the call may be used as parameters by the called expression - // and values left on the stack by the called expression may be used as - // return values by prior agreement between the calling and called - // expressions. + // This operation transfers control of DWARF expression evaluation to the + // DW_AT_location attribute of the referenced DIE. If there is no such + // attribute, then there is no effect. Execution of the DWARF expression of + // a DW_AT_location attribute may add to and/or remove from values on the + // stack. Execution returns to the point following the call when the end of + // the attribute is reached. Values on the stack at the time of the call + // may be used as parameters by the called expression and values left on + // the stack by the called expression may be used as return values by prior + // agreement between the calling and called expressions. //---------------------------------------------------------------------- case DW_OP_call2: if (error_ptr) @@ -2774,22 +2792,21 @@ bool DWARFExpression::Evaluate( // OPERANDS: 1 // uint32_t compile unit relative offset of a DIE // DESCRIPTION: Performs a subroutine call during evaluation of a DWARF - // expression. For DW_OP_call4, the operand is a 4-byte unsigned offset - // of a debugging information entry in the current compilation unit. + // expression. For DW_OP_call4, the operand is a 4-byte unsigned offset of + // a debugging information entry in the current compilation unit. // // Operand interpretation DW_OP_call4 is exactly like that for // DW_FORM_ref4. // - // This operation transfers control of DWARF expression evaluation - // to the DW_AT_location attribute of the referenced DIE. If there is - // no such attribute, then there is no effect. Execution of the DWARF - // expression of a DW_AT_location attribute may add to and/or remove from - // values on the stack. Execution returns to the point following the call - // when the end of the attribute is reached. Values on the stack at the - // time of the call may be used as parameters by the called expression - // and values left on the stack by the called expression may be used as - // return values by prior agreement between the calling and called - // expressions. + // This operation transfers control of DWARF expression evaluation to the + // DW_AT_location attribute of the referenced DIE. If there is no such + // attribute, then there is no effect. Execution of the DWARF expression of + // a DW_AT_location attribute may add to and/or remove from values on the + // stack. Execution returns to the point following the call when the end of + // the attribute is reached. Values on the stack at the time of the call + // may be used as parameters by the called expression and values left on + // the stack by the called expression may be used as return values by prior + // agreement between the calling and called expressions. //---------------------------------------------------------------------- case DW_OP_call4: if (error_ptr) @@ -2800,9 +2817,8 @@ bool DWARFExpression::Evaluate( // OPCODE: DW_OP_stack_value // OPERANDS: None // DESCRIPTION: Specifies that the object does not exist in memory but - // rather is a constant value. The value from the top of the stack is - // the value to be used. This is the actual object value and not the - // location. + // rather is a constant value. The value from the top of the stack is the + // value to be used. This is the actual object value and not the location. //---------------------------------------------------------------------- case DW_OP_stack_value: stack.back().SetValueType(Value::eValueTypeScalar); @@ -2841,8 +2857,8 @@ bool DWARFExpression::Evaluate( // opcode, DW_OP_GNU_push_tls_address) // OPERANDS: none // DESCRIPTION: Pops a TLS offset from the stack, converts it to - // an address in the current thread's thread-local storage block, - // and pushes it on the stack. + // an address in the current thread's thread-local storage block, and + // pushes it on the stack. //---------------------------------------------------------------------- case DW_OP_form_tls_address: case DW_OP_GNU_push_tls_address: { @@ -2893,8 +2909,8 @@ bool DWARFExpression::Evaluate( // OPERANDS: 1 // ULEB128: index to the .debug_addr section // DESCRIPTION: Pushes an address to the stack from the .debug_addr - // section with the base address specified by the DW_AT_addr_base - // attribute and the 0 based index is the ULEB128 encoded index. + // section with the base address specified by the DW_AT_addr_base attribute + // and the 0 based index is the ULEB128 encoded index. //---------------------------------------------------------------------- case DW_OP_GNU_addr_index: { if (!dwarf_cu) { @@ -2984,7 +3000,7 @@ bool DWARFExpression::Evaluate( return true; // Return true on success } -size_t DWARFExpression::LocationListSize(const DWARFCompileUnit *dwarf_cu, +size_t DWARFExpression::LocationListSize(const DWARFUnit *dwarf_cu, const DataExtractor &debug_loc_data, lldb::offset_t offset) { const lldb::offset_t debug_loc_offset = offset; @@ -3008,7 +3024,7 @@ size_t DWARFExpression::LocationListSize(const DWARFCompileUnit *dwarf_cu, } bool DWARFExpression::AddressRangeForLocationListEntry( - const DWARFCompileUnit *dwarf_cu, const DataExtractor &debug_loc_data, + const DWARFUnit *dwarf_cu, const DataExtractor &debug_loc_data, lldb::offset_t *offset_ptr, lldb::addr_t &low_pc, lldb::addr_t &high_pc) { if (!debug_loc_data.ValidOffset(*offset_ptr)) return false; @@ -3242,11 +3258,11 @@ bool DWARFExpression::PrintDWARFExpression(Stream &s, const DataExtractor &data, } void DWARFExpression::PrintDWARFLocationList( - Stream &s, const DWARFCompileUnit *cu, const DataExtractor &debug_loc_data, + Stream &s, const DWARFUnit *cu, const DataExtractor &debug_loc_data, lldb::offset_t offset) { uint64_t start_addr, end_addr; - uint32_t addr_size = DWARFCompileUnit::GetAddressByteSize(cu); - s.SetAddressByteSize(DWARFCompileUnit::GetAddressByteSize(cu)); + uint32_t addr_size = DWARFUnit::GetAddressByteSize(cu); + s.SetAddressByteSize(DWARFUnit::GetAddressByteSize(cu)); dw_addr_t base_addr = cu ? cu->GetBaseAddress() : 0; while (debug_loc_data.ValidOffset(offset)) { start_addr = debug_loc_data.GetMaxU64(&offset, addr_size); |
