diff options
Diffstat (limited to 'contrib/llvm/tools/lldb/source/Expression')
11 files changed, 88 insertions, 92 deletions
diff --git a/contrib/llvm/tools/lldb/source/Expression/DWARFExpression.cpp b/contrib/llvm/tools/lldb/source/Expression/DWARFExpression.cpp index 55eb65f32b5a..a6249b3a2864 100644 --- a/contrib/llvm/tools/lldb/source/Expression/DWARFExpression.cpp +++ b/contrib/llvm/tools/lldb/source/Expression/DWARFExpression.cpp @@ -9,19 +9,17 @@ #include "lldb/Expression/DWARFExpression.h" -// C Includes #include <inttypes.h> -// C++ Includes #include <vector> #include "lldb/Core/Module.h" -#include "lldb/Core/RegisterValue.h" -#include "lldb/Core/Scalar.h" #include "lldb/Core/Value.h" #include "lldb/Core/dwarf.h" #include "lldb/Utility/DataEncoder.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/RegisterValue.h" +#include "lldb/Utility/Scalar.h" #include "lldb/Utility/StreamString.h" #include "lldb/Utility/VMRange.h" @@ -1841,7 +1839,7 @@ bool DWARFExpression::Evaluate( error_ptr->SetErrorString( "Expression stack needs at least 1 item for DW_OP_abs."); return false; - } else if (stack.back().ResolveValue(exe_ctx).AbsoluteValue() == false) { + } else if (!stack.back().ResolveValue(exe_ctx).AbsoluteValue()) { if (error_ptr) error_ptr->SetErrorString( "Failed to take the absolute value of the first stack item."); @@ -1974,7 +1972,7 @@ bool DWARFExpression::Evaluate( "Expression stack needs at least 1 item for DW_OP_neg."); return false; } else { - if (stack.back().ResolveValue(exe_ctx).UnaryNegate() == false) { + if (!stack.back().ResolveValue(exe_ctx).UnaryNegate()) { if (error_ptr) error_ptr->SetErrorString("Unary negate failed."); return false; @@ -1995,7 +1993,7 @@ bool DWARFExpression::Evaluate( "Expression stack needs at least 1 item for DW_OP_not."); return false; } else { - if (stack.back().ResolveValue(exe_ctx).OnesComplement() == false) { + if (!stack.back().ResolveValue(exe_ctx).OnesComplement()) { if (error_ptr) error_ptr->SetErrorString("Logical NOT failed."); return false; @@ -2102,8 +2100,8 @@ bool DWARFExpression::Evaluate( } else { tmp = stack.back(); stack.pop_back(); - if (stack.back().ResolveValue(exe_ctx).ShiftRightLogical( - tmp.ResolveValue(exe_ctx)) == false) { + if (!stack.back().ResolveValue(exe_ctx).ShiftRightLogical( + tmp.ResolveValue(exe_ctx))) { if (error_ptr) error_ptr->SetErrorString("DW_OP_shr failed."); return false; @@ -2382,7 +2380,7 @@ bool DWARFExpression::Evaluate( case DW_OP_lit29: case DW_OP_lit30: case DW_OP_lit31: - stack.push_back(Scalar(op - DW_OP_lit0)); + stack.push_back(Scalar((uint64_t)(op - DW_OP_lit0))); break; //---------------------------------------------------------------------- @@ -3029,7 +3027,9 @@ bool DWARFExpression::AddressRangeForLocationListEntry( if (!debug_loc_data.ValidOffset(*offset_ptr)) return false; - switch (dwarf_cu->GetSymbolFileDWARF()->GetLocationListFormat()) { + DWARFExpression::LocationListFormat format = + dwarf_cu->GetSymbolFileDWARF()->GetLocationListFormat(); + switch (format) { case NonLocationList: return false; case RegularLocationList: @@ -3037,6 +3037,7 @@ bool DWARFExpression::AddressRangeForLocationListEntry( high_pc = debug_loc_data.GetAddress(offset_ptr); return true; case SplitDwarfLocationList: + case LocLists: switch (debug_loc_data.GetU8(offset_ptr)) { case DW_LLE_end_of_list: return false; @@ -3050,12 +3051,25 @@ bool DWARFExpression::AddressRangeForLocationListEntry( case DW_LLE_startx_length: { uint64_t index = debug_loc_data.GetULEB128(offset_ptr); low_pc = ReadAddressFromDebugAddrSection(dwarf_cu, index); - uint32_t length = debug_loc_data.GetU32(offset_ptr); + uint64_t length = (format == LocLists) + ? debug_loc_data.GetULEB128(offset_ptr) + : debug_loc_data.GetU32(offset_ptr); high_pc = low_pc + length; return true; } + case DW_LLE_start_length: { + low_pc = debug_loc_data.GetAddress(offset_ptr); + high_pc = low_pc + debug_loc_data.GetULEB128(offset_ptr); + return true; + } + case DW_LLE_start_end: { + low_pc = debug_loc_data.GetAddress(offset_ptr); + high_pc = debug_loc_data.GetAddress(offset_ptr); + return true; + } default: // Not supported entry type + lldbassert(false && "Not supported location list type"); return false; } } diff --git a/contrib/llvm/tools/lldb/source/Expression/ExpressionSourceCode.cpp b/contrib/llvm/tools/lldb/source/Expression/ExpressionSourceCode.cpp index abbb332fac48..03b2d26a256d 100644 --- a/contrib/llvm/tools/lldb/source/Expression/ExpressionSourceCode.cpp +++ b/contrib/llvm/tools/lldb/source/Expression/ExpressionSourceCode.cpp @@ -105,10 +105,7 @@ public: if (m_file_stack.back() != m_current_file) return true; - if (line >= m_current_file_line) - return false; - else - return true; + return line < m_current_file_line; default: return false; } @@ -378,7 +375,5 @@ bool ExpressionSourceCode::GetOriginalBodyBounds( return false; start_loc += strlen(start_marker); end_loc = transformed_text.find(end_marker); - if (end_loc == std::string::npos) - return false; - return true; + return end_loc != std::string::npos; } diff --git a/contrib/llvm/tools/lldb/source/Expression/FunctionCaller.cpp b/contrib/llvm/tools/lldb/source/Expression/FunctionCaller.cpp index 9742ed0b270e..97f4f51e1ff6 100644 --- a/contrib/llvm/tools/lldb/source/Expression/FunctionCaller.cpp +++ b/contrib/llvm/tools/lldb/source/Expression/FunctionCaller.cpp @@ -7,14 +7,9 @@ // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Expression/FunctionCaller.h" #include "lldb/Core/Module.h" -#include "lldb/Core/State.h" #include "lldb/Core/ValueObject.h" #include "lldb/Core/ValueObjectList.h" #include "lldb/Expression/DiagnosticManager.h" @@ -31,6 +26,7 @@ #include "lldb/Target/ThreadPlanCallFunction.h" #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/State.h" using namespace lldb_private; diff --git a/contrib/llvm/tools/lldb/source/Expression/IRDynamicChecks.cpp b/contrib/llvm/tools/lldb/source/Expression/IRDynamicChecks.cpp index e0a7dca4113d..20431d5f93c5 100644 --- a/contrib/llvm/tools/lldb/source/Expression/IRDynamicChecks.cpp +++ b/contrib/llvm/tools/lldb/source/Expression/IRDynamicChecks.cpp @@ -7,9 +7,6 @@ // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes #include "llvm/IR/Constants.h" #include "llvm/IR/DataLayout.h" #include "llvm/IR/Function.h" @@ -18,7 +15,6 @@ #include "llvm/IR/Value.h" #include "llvm/Support/raw_ostream.h" -// Project includes #include "lldb/Expression/IRDynamicChecks.h" #include "lldb/Expression/UtilityFunction.h" diff --git a/contrib/llvm/tools/lldb/source/Expression/IRExecutionUnit.cpp b/contrib/llvm/tools/lldb/source/Expression/IRExecutionUnit.cpp index e34a4c7fac52..ec6ceeac1813 100644 --- a/contrib/llvm/tools/lldb/source/Expression/IRExecutionUnit.cpp +++ b/contrib/llvm/tools/lldb/source/Expression/IRExecutionUnit.cpp @@ -553,6 +553,8 @@ lldb::SectionType IRExecutionUnit::GetSectionTypeFromSectionName( sect_type = lldb::eSectionTypeDWARFDebugLine; else if (dwarf_name.equals("loc")) sect_type = lldb::eSectionTypeDWARFDebugLoc; + else if (dwarf_name.equals("loclists")) + sect_type = lldb::eSectionTypeDWARFDebugLocLists; break; case 'm': @@ -707,9 +709,10 @@ FindBestAlternateMangledName(const ConstString &demangled, struct IRExecutionUnit::SearchSpec { ConstString name; - uint32_t mask; + lldb::FunctionNameType mask; - SearchSpec(ConstString n, uint32_t m = lldb::eFunctionNameTypeFull) + SearchSpec(ConstString n, + lldb::FunctionNameType m = lldb::eFunctionNameTypeFull) : name(n), mask(m) {} }; @@ -1010,7 +1013,7 @@ IRExecutionUnit::MemoryManager::getSymbolAddress(const std::string &Name) { Name.c_str()); m_parent.ReportSymbolLookupError(name_cs); - return 0xbad0bad0; + return 0; } else { if (log) log->Printf("IRExecutionUnit::getSymbolAddress(Name=\"%s\") = %" PRIx64, @@ -1088,6 +1091,7 @@ bool IRExecutionUnit::CommitOneAllocation(lldb::ProcessSP &process_sp, case lldb::eSectionTypeDWARFDebugInfo: case lldb::eSectionTypeDWARFDebugLine: case lldb::eSectionTypeDWARFDebugLoc: + case lldb::eSectionTypeDWARFDebugLocLists: case lldb::eSectionTypeDWARFDebugMacInfo: case lldb::eSectionTypeDWARFDebugPubNames: case lldb::eSectionTypeDWARFDebugPubTypes: @@ -1213,14 +1217,11 @@ void IRExecutionUnit::PopulateSectionList( } } -bool IRExecutionUnit::GetArchitecture(lldb_private::ArchSpec &arch) { +ArchSpec IRExecutionUnit::GetArchitecture() { ExecutionContext exe_ctx(GetBestExecutionContextScope()); - Target *target = exe_ctx.GetTargetPtr(); - if (target) - arch = target->GetArchitecture(); - else - arch.Clear(); - return arch.IsValid(); + if(Target *target = exe_ctx.GetTargetPtr()) + return target->GetArchitecture(); + return ArchSpec(); } lldb::ModuleSP IRExecutionUnit::GetJITModule() { diff --git a/contrib/llvm/tools/lldb/source/Expression/IRInterpreter.cpp b/contrib/llvm/tools/lldb/source/Expression/IRInterpreter.cpp index abf86b739f07..457eaef46dd3 100644 --- a/contrib/llvm/tools/lldb/source/Expression/IRInterpreter.cpp +++ b/contrib/llvm/tools/lldb/source/Expression/IRInterpreter.cpp @@ -10,7 +10,6 @@ #include "lldb/Expression/IRInterpreter.h" #include "lldb/Core/Module.h" #include "lldb/Core/ModuleSpec.h" -#include "lldb/Core/Scalar.h" #include "lldb/Core/ValueObject.h" #include "lldb/Expression/DiagnosticManager.h" #include "lldb/Expression/IRExecutionUnit.h" @@ -19,6 +18,7 @@ #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/Endian.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/Scalar.h" #include "lldb/Utility/Status.h" #include "lldb/Utility/StreamString.h" @@ -152,17 +152,13 @@ public: Type *type) { size_t type_size = m_target_data.getTypeStoreSize(type); - switch (type_size) { - case 1: - case 2: - case 4: - case 8: - scalar = llvm::APInt(type_size*8, u64value); - break; - default: + if (type_size > 8) return false; - } + if (type_size != 1) + type_size = PowerOf2Ceil(type_size); + + scalar = llvm::APInt(type_size*8, u64value); return true; } @@ -192,8 +188,7 @@ public: return false; lldb::offset_t offset = 0; - if (value_size == 1 || value_size == 2 || value_size == 4 || - value_size == 8) { + if (value_size <= 8) { uint64_t u64value = value_extractor.GetMaxU64(&offset, value_size); return AssignToMatchType(scalar, u64value, value->getType()); } @@ -618,6 +613,18 @@ bool IRInterpreter::CanInterpret(llvm::Module &module, llvm::Function &function, } } + // The IR interpreter currently doesn't know about + // 128-bit integers. As they're not that frequent, + // we can just fall back to the JIT rather than + // choking. + if (operand_type->getPrimitiveSizeInBits() > 64) { + if (log) + log->Printf("Unsupported operand type: %s", + PrintType(operand_type).c_str()); + error.SetErrorString(unsupported_operand_error); + return false; + } + if (Constant *constant = llvm::dyn_cast<Constant>(operand)) { if (!CanResolveConstant(constant)) { if (log) @@ -1585,9 +1592,6 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function, // Check if this is a string literal or constant string pointer if (arg_ty->isPointerTy()) { - // Pointer to just one type - assert(arg_ty->getNumContainedTypes() == 1); - lldb::addr_t addr = tmp_op.ULongLong(); size_t dataSize = 0; diff --git a/contrib/llvm/tools/lldb/source/Expression/IRMemoryMap.cpp b/contrib/llvm/tools/lldb/source/Expression/IRMemoryMap.cpp index 1953e80852ff..e4c85d6ce727 100644 --- a/contrib/llvm/tools/lldb/source/Expression/IRMemoryMap.cpp +++ b/contrib/llvm/tools/lldb/source/Expression/IRMemoryMap.cpp @@ -8,7 +8,6 @@ //===----------------------------------------------------------------------===// #include "lldb/Expression/IRMemoryMap.h" -#include "lldb/Core/Scalar.h" #include "lldb/Target/MemoryRegionInfo.h" #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" @@ -16,6 +15,7 @@ #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/LLDBAssert.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/Scalar.h" #include "lldb/Utility/Status.h" using namespace lldb_private; @@ -272,21 +272,17 @@ IRMemoryMap::Allocation::Allocation(lldb::addr_t process_alloc, uint32_t permissions, uint8_t alignment, AllocationPolicy policy) : m_process_alloc(process_alloc), m_process_start(process_start), - m_size(size), m_permissions(permissions), m_alignment(alignment), - m_policy(policy), m_leak(false) { + m_size(size), m_policy(policy), m_leak(false), m_permissions(permissions), + m_alignment(alignment) { switch (policy) { default: assert(0 && "We cannot reach this!"); case eAllocationPolicyHostOnly: + case eAllocationPolicyMirror: m_data.SetByteSize(size); - memset(m_data.GetBytes(), 0, size); break; case eAllocationPolicyProcessOnly: break; - case eAllocationPolicyMirror: - m_data.SetByteSize(size); - memset(m_data.GetBytes(), 0, size); - break; } } @@ -393,9 +389,10 @@ lldb::addr_t IRMemoryMap::Malloc(size_t size, uint8_t alignment, lldb::addr_t mask = alignment - 1; aligned_address = (allocation_address + mask) & (~mask); - m_allocations[aligned_address] = - Allocation(allocation_address, aligned_address, allocation_size, - permissions, alignment, policy); + m_allocations.emplace( + std::piecewise_construct, std::forward_as_tuple(aligned_address), + std::forward_as_tuple(allocation_address, aligned_address, + allocation_size, permissions, alignment, policy)); if (zero_memory) { Status write_error; diff --git a/contrib/llvm/tools/lldb/source/Expression/LLVMUserExpression.cpp b/contrib/llvm/tools/lldb/source/Expression/LLVMUserExpression.cpp index fc32bfbd37a2..edf1e69c30d8 100644 --- a/contrib/llvm/tools/lldb/source/Expression/LLVMUserExpression.cpp +++ b/contrib/llvm/tools/lldb/source/Expression/LLVMUserExpression.cpp @@ -7,10 +7,7 @@ // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Project includes #include "lldb/Expression/LLVMUserExpression.h" #include "lldb/Core/Module.h" #include "lldb/Core/StreamFile.h" diff --git a/contrib/llvm/tools/lldb/source/Expression/Materializer.cpp b/contrib/llvm/tools/lldb/source/Expression/Materializer.cpp index 74a965e015ce..4d4e5e21092c 100644 --- a/contrib/llvm/tools/lldb/source/Expression/Materializer.cpp +++ b/contrib/llvm/tools/lldb/source/Expression/Materializer.cpp @@ -7,13 +7,8 @@ // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Expression/Materializer.h" #include "lldb/Core/DumpDataExtractor.h" -#include "lldb/Core/RegisterValue.h" #include "lldb/Core/ValueObjectConstResult.h" #include "lldb/Core/ValueObjectVariable.h" #include "lldb/Expression/ExpressionVariable.h" @@ -27,6 +22,7 @@ #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/RegisterValue.h" using namespace lldb_private; @@ -50,7 +46,8 @@ uint32_t Materializer::AddStructMember(Entity &entity) { } void Materializer::Entity::SetSizeAndAlignmentFromType(CompilerType &type) { - m_size = type.GetByteSize(nullptr); + if (llvm::Optional<uint64_t> size = type.GetByteSize(nullptr)) + m_size = *size; uint32_t bit_alignment = type.GetTypeBitAlign(); @@ -532,7 +529,7 @@ public: if (data.GetByteSize() < m_variable_sp->GetType()->GetByteSize()) { if (data.GetByteSize() == 0 && - m_variable_sp->LocationExpression().IsValid() == false) { + !m_variable_sp->LocationExpression().IsValid()) { err.SetErrorStringWithFormat("the variable '%s' has no location, " "it may have been optimized out", m_variable_sp->GetName().AsCString()); @@ -798,7 +795,11 @@ public: ExecutionContextScope *exe_scope = map.GetBestExecutionContextScope(); - size_t byte_size = m_type.GetByteSize(exe_scope); + llvm::Optional<uint64_t> byte_size = m_type.GetByteSize(exe_scope); + if (!byte_size) { + err.SetErrorString("can't get size of type"); + return; + } size_t bit_align = m_type.GetTypeBitAlign(); size_t byte_align = (bit_align + 7) / 8; @@ -809,10 +810,10 @@ public: const bool zero_memory = true; m_temporary_allocation = map.Malloc( - byte_size, byte_align, + *byte_size, byte_align, lldb::ePermissionsReadable | lldb::ePermissionsWritable, IRMemoryMap::eAllocationPolicyMirror, zero_memory, alloc_error); - m_temporary_allocation_size = byte_size; + m_temporary_allocation_size = *byte_size; if (!alloc_error.Success()) { err.SetErrorStringWithFormat( diff --git a/contrib/llvm/tools/lldb/source/Expression/REPL.cpp b/contrib/llvm/tools/lldb/source/Expression/REPL.cpp index a441e381985c..943385bb3aac 100644 --- a/contrib/llvm/tools/lldb/source/Expression/REPL.cpp +++ b/contrib/llvm/tools/lldb/source/Expression/REPL.cpp @@ -7,10 +7,6 @@ // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Expression/REPL.h" #include "lldb/Core/Debugger.h" #include "lldb/Core/PluginManager.h" @@ -66,7 +62,7 @@ std::string REPL::GetSourcePath() { tmpdir_file_spec.GetFilename().SetCString(file_basename.AsCString()); m_repl_source_path = tmpdir_file_spec.GetPath(); } else { - tmpdir_file_spec = FileSpec("/tmp", false); + tmpdir_file_spec = FileSpec("/tmp"); tmpdir_file_spec.AppendPathComponent(file_basename.AsCString()); } @@ -416,11 +412,12 @@ void REPL::IOHandlerInputComplete(IOHandler &io_handler, std::string &code) { // Update our code on disk if (!m_repl_source_path.empty()) { - lldb_private::File file(m_repl_source_path.c_str(), - File::eOpenOptionWrite | - File::eOpenOptionTruncate | - File::eOpenOptionCanCreate, - lldb::eFilePermissionsFileDefault); + lldb_private::File file; + FileSystem::Instance().Open(file, FileSpec(m_repl_source_path), + File::eOpenOptionWrite | + File::eOpenOptionTruncate | + File::eOpenOptionCanCreate, + lldb::eFilePermissionsFileDefault); std::string code(m_code.CopyList()); code.append(1, '\n'); size_t bytes_written = code.size(); @@ -429,7 +426,7 @@ void REPL::IOHandlerInputComplete(IOHandler &io_handler, std::string &code) { // Now set the default file and line to the REPL source file m_target.GetSourceManager().SetDefaultFileAndLine( - FileSpec(m_repl_source_path, false), new_default_line); + FileSpec(m_repl_source_path), new_default_line); } static_cast<IOHandlerEditline &>(io_handler) .SetBaseLineNumber(m_code.GetSize() + 1); @@ -453,7 +450,7 @@ void REPL::IOHandlerInputComplete(IOHandler &io_handler, std::string &code) { int REPL::IOHandlerComplete(IOHandler &io_handler, const char *current_line, const char *cursor, const char *last_char, int skip_first_n_matches, int max_matches, - StringList &matches) { + StringList &matches, StringList &descriptions) { matches.Clear(); llvm::StringRef line(current_line, cursor - current_line); @@ -466,7 +463,7 @@ int REPL::IOHandlerComplete(IOHandler &io_handler, const char *current_line, const char *lldb_current_line = line.substr(1).data(); return debugger.GetCommandInterpreter().HandleCompletion( lldb_current_line, cursor, last_char, skip_first_n_matches, max_matches, - matches); + matches, descriptions); } // Strip spaces from the line and see if we had only spaces diff --git a/contrib/llvm/tools/lldb/source/Expression/UtilityFunction.cpp b/contrib/llvm/tools/lldb/source/Expression/UtilityFunction.cpp index 52f3bfc4d128..a0a1e4edfb0b 100644 --- a/contrib/llvm/tools/lldb/source/Expression/UtilityFunction.cpp +++ b/contrib/llvm/tools/lldb/source/Expression/UtilityFunction.cpp @@ -7,13 +7,11 @@ // //===----------------------------------------------------------------------===// -// C Includes #include <stdio.h> #if HAVE_SYS_TYPES_H #include <sys/types.h> #endif -// C++ Includes #include "lldb/Core/Module.h" #include "lldb/Core/StreamFile.h" |
