summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rw-r--r--source/Commands/CommandObjectRegister.cpp11
-rw-r--r--source/Core/Address.cpp12
-rw-r--r--source/Core/ArchSpec.cpp8
-rw-r--r--source/Core/CMakeLists.txt1
-rw-r--r--source/Core/Section.cpp22
-rw-r--r--source/DataFormatters/TypeCategory.cpp21
-rw-r--r--source/Host/common/Host.cpp8
-rw-r--r--source/Host/posix/ConnectionFileDescriptorPosix.cpp7
-rw-r--r--source/Host/posix/ProcessLauncherPosixFork.cpp5
-rw-r--r--source/Plugins/Language/ObjC/ObjCLanguage.cpp2
-rw-r--r--source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp1
-rw-r--r--source/Plugins/ObjectFile/ELF/CMakeLists.txt1
-rw-r--r--source/Plugins/ObjectFile/ELF/ELFHeader.h2
-rw-r--r--source/Plugins/ObjectFile/PECOFF/CMakeLists.txt1
-rw-r--r--source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp2
-rw-r--r--source/Plugins/Process/Darwin/DarwinProcessLauncher.cpp38
-rw-r--r--source/Plugins/Process/FreeBSD/ProcessMonitor.cpp7
-rw-r--r--source/Plugins/Process/Linux/NativeProcessLinux.cpp10
-rw-r--r--source/Plugins/Process/Utility/RegisterContextLLDB.cpp12
-rw-r--r--source/Plugins/Process/elf-core/CMakeLists.txt1
-rw-r--r--source/Plugins/Process/elf-core/ProcessElfCore.cpp2
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp4
-rw-r--r--source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp5
-rw-r--r--source/Target/SectionLoadList.cpp15
-rw-r--r--source/Target/StackFrame.cpp3
-rw-r--r--source/Utility/CMakeLists.txt1
-rw-r--r--source/Utility/Status.cpp18
-rw-r--r--source/Utility/TaskPool.cpp2
-rw-r--r--source/Utility/VMRange.cpp46
29 files changed, 111 insertions, 157 deletions
diff --git a/source/Commands/CommandObjectRegister.cpp b/source/Commands/CommandObjectRegister.cpp
index 6de8c667e7a7..d535742016ac 100644
--- a/source/Commands/CommandObjectRegister.cpp
+++ b/source/Commands/CommandObjectRegister.cpp
@@ -7,12 +7,6 @@
//
//===----------------------------------------------------------------------===//
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-#include "llvm/ADT/STLExtras.h"
-
-// Project includes
#include "CommandObjectRegister.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/RegisterValue.h"
@@ -32,6 +26,7 @@
#include "lldb/Target/SectionLoadList.h"
#include "lldb/Target/Thread.h"
#include "lldb/Utility/DataExtractor.h"
+#include "llvm/Support/Errno.h"
using namespace lldb;
using namespace lldb_private;
@@ -178,8 +173,8 @@ protected:
if (set_idx < reg_ctx->GetRegisterSetCount()) {
if (!DumpRegisterSet(m_exe_ctx, strm, reg_ctx, set_idx)) {
if (errno)
- result.AppendErrorWithFormat("register read failed: %s\n",
- strerror(errno));
+ result.AppendErrorWithFormatv("register read failed: {0}\n",
+ llvm::sys::StrError());
else
result.AppendError("unknown error while reading registers.\n");
result.SetStatus(eReturnStatusFailed);
diff --git a/source/Core/Address.cpp b/source/Core/Address.cpp
index 6328e433852a..0c929c22f75f 100644
--- a/source/Core/Address.cpp
+++ b/source/Core/Address.cpp
@@ -361,8 +361,9 @@ addr_t Address::GetOpcodeLoadAddress(Target *target,
}
bool Address::SetOpcodeLoadAddress(lldb::addr_t load_addr, Target *target,
- AddressClass addr_class) {
- if (SetLoadAddress(load_addr, target)) {
+ AddressClass addr_class,
+ bool allow_section_end) {
+ if (SetLoadAddress(load_addr, target, allow_section_end)) {
if (target) {
if (addr_class == eAddressClassInvalid)
addr_class = GetAddressClass();
@@ -1001,9 +1002,10 @@ AddressClass Address::GetAddressClass() const {
return eAddressClassUnknown;
}
-bool Address::SetLoadAddress(lldb::addr_t load_addr, Target *target) {
- if (target &&
- target->GetSectionLoadList().ResolveLoadAddress(load_addr, *this))
+bool Address::SetLoadAddress(lldb::addr_t load_addr, Target *target,
+ bool allow_section_end) {
+ if (target && target->GetSectionLoadList().ResolveLoadAddress(
+ load_addr, *this, allow_section_end))
return true;
m_section_wp.reset();
m_offset = load_addr;
diff --git a/source/Core/ArchSpec.cpp b/source/Core/ArchSpec.cpp
index 91b73847ac1f..bfe9750f70f0 100644
--- a/source/Core/ArchSpec.cpp
+++ b/source/Core/ArchSpec.cpp
@@ -24,11 +24,11 @@
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/Twine.h" // for Twine
-#include "llvm/Support/COFF.h"
-#include "llvm/Support/Compiler.h" // for LLVM_FALLTHROUGH
-#include "llvm/Support/ELF.h"
+#include "llvm/BinaryFormat/COFF.h"
+#include "llvm/BinaryFormat/ELF.h"
+#include "llvm/BinaryFormat/MachO.h" // for CPUType::CPU_T...
+#include "llvm/Support/Compiler.h" // for LLVM_FALLTHROUGH
#include "llvm/Support/Host.h"
-#include "llvm/Support/MachO.h" // for CPUType::CPU_T...
#include <memory> // for shared_ptr
#include <string>
diff --git a/source/Core/CMakeLists.txt b/source/Core/CMakeLists.txt
index 7dcec050d866..806227793f24 100644
--- a/source/Core/CMakeLists.txt
+++ b/source/Core/CMakeLists.txt
@@ -67,6 +67,7 @@ add_lldb_library(lldbCore
lldbPluginObjectFileJIT
LINK_COMPONENTS
+ BinaryFormat
Support
Demangle
)
diff --git a/source/Core/Section.cpp b/source/Core/Section.cpp
index f6428ced0164..3b76dd361ff3 100644
--- a/source/Core/Section.cpp
+++ b/source/Core/Section.cpp
@@ -220,18 +220,18 @@ addr_t Section::GetLoadBaseAddress(Target *target) const {
return load_base_addr;
}
-bool Section::ResolveContainedAddress(addr_t offset, Address &so_addr) const {
+bool Section::ResolveContainedAddress(addr_t offset, Address &so_addr,
+ bool allow_section_end) const {
const size_t num_children = m_children.GetSize();
- if (num_children > 0) {
- for (size_t i = 0; i < num_children; i++) {
- Section *child_section = m_children.GetSectionAtIndex(i).get();
-
- addr_t child_offset = child_section->GetOffset();
- if (child_offset <= offset &&
- offset - child_offset < child_section->GetByteSize())
- return child_section->ResolveContainedAddress(offset - child_offset,
- so_addr);
- }
+ for (size_t i = 0; i < num_children; i++) {
+ Section *child_section = m_children.GetSectionAtIndex(i).get();
+
+ addr_t child_offset = child_section->GetOffset();
+ if (child_offset <= offset &&
+ offset - child_offset <
+ child_section->GetByteSize() + (allow_section_end ? 1 : 0))
+ return child_section->ResolveContainedAddress(offset - child_offset,
+ so_addr, allow_section_end);
}
so_addr.SetOffset(offset);
so_addr.SetSection(const_cast<Section *>(this)->shared_from_this());
diff --git a/source/DataFormatters/TypeCategory.cpp b/source/DataFormatters/TypeCategory.cpp
index db3372c52925..184a8c98de62 100644
--- a/source/DataFormatters/TypeCategory.cpp
+++ b/source/DataFormatters/TypeCategory.cpp
@@ -36,23 +36,8 @@ TypeCategoryImpl::TypeCategoryImpl(
static bool IsApplicable(lldb::LanguageType category_lang,
lldb::LanguageType valobj_lang) {
switch (category_lang) {
- // these are not languages that LLDB would ordinarily deal with
- // only allow an exact equality here, since we really don't know
- // any better
- case eLanguageTypeAda83:
- case eLanguageTypeCobol74:
- case eLanguageTypeCobol85:
- case eLanguageTypeFortran77:
- case eLanguageTypeFortran90:
- case eLanguageTypePascal83:
- case eLanguageTypeModula2:
- case eLanguageTypeJava:
- case eLanguageTypeAda95:
- case eLanguageTypeFortran95:
- case eLanguageTypePLI:
- case eLanguageTypeUPC:
- case eLanguageTypeD:
- case eLanguageTypePython:
+ // Unless we know better, allow only exact equality.
+ default:
return category_lang == valobj_lang;
// the C family, we consider it as one
@@ -80,7 +65,7 @@ static bool IsApplicable(lldb::LanguageType category_lang,
valobj_lang == eLanguageTypeC_plus_plus ||
valobj_lang == eLanguageTypeObjC;
- default:
+ // Categories with unspecified language match everything.
case eLanguageTypeUnknown:
return true;
}
diff --git a/source/Host/common/Host.cpp b/source/Host/common/Host.cpp
index da35022c813c..d78961e5bffc 100644
--- a/source/Host/common/Host.cpp
+++ b/source/Host/common/Host.cpp
@@ -68,6 +68,7 @@
#include "lldb/Utility/Status.h"
#include "lldb/lldb-private-forward.h"
#include "llvm/ADT/SmallString.h"
+#include "llvm/Support/Errno.h"
#include "llvm/Support/FileSystem.h"
#if defined(_WIN32)
@@ -217,10 +218,9 @@ static thread_result_t MonitorChildProcessThreadFunction(void *arg) {
if (errno == EINTR)
continue;
else {
- if (log)
- log->Printf(
- "%s (arg = %p) thread exiting because waitpid failed (%s)...",
- __FUNCTION__, arg, strerror(errno));
+ LLDB_LOG(log,
+ "arg = {0}, thread exiting because waitpid failed ({1})...",
+ arg, llvm::sys::StrError());
break;
}
} else if (wait_pid > 0) {
diff --git a/source/Host/posix/ConnectionFileDescriptorPosix.cpp b/source/Host/posix/ConnectionFileDescriptorPosix.cpp
index 7a0c92b44918..c3b237a87302 100644
--- a/source/Host/posix/ConnectionFileDescriptorPosix.cpp
+++ b/source/Host/posix/ConnectionFileDescriptorPosix.cpp
@@ -36,6 +36,7 @@
#include <sstream>
// Other libraries and framework includes
+#include "llvm/Support/Errno.h"
#include "llvm/Support/ErrorHandling.h"
#if defined(__APPLE__)
#include "llvm/ADT/SmallVector.h"
@@ -461,10 +462,8 @@ size_t ConnectionFileDescriptor::Read(void *dst, size_t dst_len,
return 0;
default:
- if (log)
- log->Printf(
- "%p ConnectionFileDescriptor::Read (), unexpected error: %s",
- static_cast<void *>(this), strerror(error_value));
+ LLDB_LOG(log, "this = {0}, unexpected error: {1}", this,
+ llvm::sys::StrError(error_value));
status = eConnectionStatusError;
break; // Break to close....
}
diff --git a/source/Host/posix/ProcessLauncherPosixFork.cpp b/source/Host/posix/ProcessLauncherPosixFork.cpp
index 378670cd2a9a..1eace5cd24cd 100644
--- a/source/Host/posix/ProcessLauncherPosixFork.cpp
+++ b/source/Host/posix/ProcessLauncherPosixFork.cpp
@@ -14,6 +14,7 @@
#include "lldb/Target/ProcessLaunchInfo.h"
#include "lldb/Utility/FileSpec.h"
#include "lldb/Utility/Log.h"
+#include "llvm/Support/Errno.h"
#include <limits.h>
#include <sys/ptrace.h>
@@ -204,8 +205,8 @@ ProcessLauncherPosixFork::LaunchProcess(const ProcessLaunchInfo &launch_info,
::pid_t pid = ::fork();
if (pid == -1) {
// Fork failed
- error.SetErrorStringWithFormat("Fork failed with error message: %s",
- strerror(errno));
+ error.SetErrorStringWithFormatv("Fork failed with error message: {0}",
+ llvm::sys::StrError());
return HostProcess(LLDB_INVALID_PROCESS_ID);
}
if (pid == 0) {
diff --git a/source/Plugins/Language/ObjC/ObjCLanguage.cpp b/source/Plugins/Language/ObjC/ObjCLanguage.cpp
index 193c5864d01f..4d9227598cef 100644
--- a/source/Plugins/Language/ObjC/ObjCLanguage.cpp
+++ b/source/Plugins/Language/ObjC/ObjCLanguage.cpp
@@ -95,7 +95,7 @@ bool ObjCLanguage::MethodName::SetName(llvm::StringRef name, bool strict) {
// or '-' can be omitted
bool valid_prefix = false;
- if (name[0] == '+' || name[0] == '-') {
+ if (name.size() > 1 && (name[0] == '+' || name[0] == '-')) {
valid_prefix = name[1] == '[';
if (name[0] == '+')
m_type = eTypeClassMethod;
diff --git a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp
index 566fefaf7984..9cac499c0ff0 100644
--- a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp
+++ b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp
@@ -171,6 +171,7 @@ UtilityFunction *AppleObjCRuntimeV1::CreateObjectChecker(const char *name) {
" \n",
name);
assert(strformatsize < (int)sizeof(buf->contents));
+ (void)strformatsize;
Status error;
return GetTargetRef().GetUtilityFunctionForLanguage(
diff --git a/source/Plugins/ObjectFile/ELF/CMakeLists.txt b/source/Plugins/ObjectFile/ELF/CMakeLists.txt
index a941b8d55848..e0680b07efc5 100644
--- a/source/Plugins/ObjectFile/ELF/CMakeLists.txt
+++ b/source/Plugins/ObjectFile/ELF/CMakeLists.txt
@@ -8,5 +8,6 @@ add_lldb_library(lldbPluginObjectFileELF PLUGIN
lldbSymbol
lldbTarget
LINK_COMPONENTS
+ BinaryFormat
Support
)
diff --git a/source/Plugins/ObjectFile/ELF/ELFHeader.h b/source/Plugins/ObjectFile/ELF/ELFHeader.h
index e6738a1ecb2b..4e2d3155ebb9 100644
--- a/source/Plugins/ObjectFile/ELF/ELFHeader.h
+++ b/source/Plugins/ObjectFile/ELF/ELFHeader.h
@@ -21,7 +21,7 @@
#ifndef liblldb_ELFHeader_h_
#define liblldb_ELFHeader_h_
-#include "llvm/Support/ELF.h"
+#include "llvm/BinaryFormat/ELF.h"
#include "lldb/lldb-enumerations.h"
#include "lldb/lldb-types.h"
diff --git a/source/Plugins/ObjectFile/PECOFF/CMakeLists.txt b/source/Plugins/ObjectFile/PECOFF/CMakeLists.txt
index 1e8fb85c72c9..04321f276551 100644
--- a/source/Plugins/ObjectFile/PECOFF/CMakeLists.txt
+++ b/source/Plugins/ObjectFile/PECOFF/CMakeLists.txt
@@ -8,5 +8,6 @@ add_lldb_library(lldbPluginObjectFilePECOFF PLUGIN
lldbSymbol
lldbTarget
LINK_COMPONENTS
+ BinaryFormat
Support
)
diff --git a/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp b/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
index dcb9527f24c8..4739a4934aa6 100644
--- a/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
+++ b/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
@@ -10,7 +10,7 @@
#include "ObjectFilePECOFF.h"
#include "WindowsMiniDump.h"
-#include "llvm/Support/COFF.h"
+#include "llvm/BinaryFormat/COFF.h"
#include "lldb/Core/ArchSpec.h"
#include "lldb/Core/FileSpecList.h"
diff --git a/source/Plugins/Process/Darwin/DarwinProcessLauncher.cpp b/source/Plugins/Process/Darwin/DarwinProcessLauncher.cpp
index 6845a36730c9..c6daf6ccea6e 100644
--- a/source/Plugins/Process/Darwin/DarwinProcessLauncher.cpp
+++ b/source/Plugins/Process/Darwin/DarwinProcessLauncher.cpp
@@ -35,6 +35,7 @@
#include "lldb/Utility/Log.h"
#include "lldb/Utility/Status.h"
#include "lldb/Utility/StreamString.h"
+#include "llvm/Support/Errno.h"
#include "CFBundle.h"
#include "CFString.h"
@@ -319,13 +320,12 @@ static Status PosixSpawnChildForPTraceDebugging(const char *path,
::posix_spawnattr_setsigdefault(&attr, &all_signals);
if ((error_code = ::posix_spawnattr_setflags(&attr, flags)) != 0) {
- if (log)
- log->Printf("::posix_spawnattr_setflags(&attr, "
- "POSIX_SPAWN_START_SUSPENDED%s) failed: %s",
- flags & _POSIX_SPAWN_DISABLE_ASLR
- ? " | _POSIX_SPAWN_DISABLE_ASLR"
- : "",
- strerror(error_code));
+ LLDB_LOG(log,
+ "::posix_spawnattr_setflags(&attr, "
+ "POSIX_SPAWN_START_SUSPENDED{0}) failed: {1}",
+ flags & _POSIX_SPAWN_DISABLE_ASLR ? " | _POSIX_SPAWN_DISABLE_ASLR"
+ : "",
+ llvm::sys::StrError(error_code));
error.SetError(error_code, eErrorTypePOSIX);
return error;
}
@@ -341,10 +341,10 @@ static Status PosixSpawnChildForPTraceDebugging(const char *path,
error_code =
::posix_spawnattr_setbinpref_np(&attr, 1, &desired_cpu_type, &ocount);
if (error_code != 0) {
- if (log)
- log->Printf("::posix_spawnattr_setbinpref_np(&attr, 1, "
- "cpu_type = 0x%8.8x, count => %llu): %s",
- desired_cpu_type, (uint64_t)ocount, strerror(error_code));
+ LLDB_LOG(log,
+ "::posix_spawnattr_setbinpref_np(&attr, 1, "
+ "cpu_type = {0:x8}, count => {1}): {2}",
+ desired_cpu_type, ocount, llvm::sys::StrError(error_code));
error.SetError(error_code, eErrorTypePOSIX);
return error;
}
@@ -361,10 +361,8 @@ static Status PosixSpawnChildForPTraceDebugging(const char *path,
posix_spawn_file_actions_t file_actions;
if ((error_code = ::posix_spawn_file_actions_init(&file_actions)) != 0) {
- if (log)
- log->Printf("::posix_spawn_file_actions_init(&file_actions) "
- "failed: %s",
- strerror(error_code));
+ LLDB_LOG(log, "::posix_spawn_file_actions_init(&file_actions) failed: {0}",
+ llvm::sys::StrError(error_code));
error.SetError(error_code, eErrorTypePOSIX);
return error;
}
@@ -409,11 +407,11 @@ static Status PosixSpawnChildForPTraceDebugging(const char *path,
error_code = ::posix_spawnp(pid, path, &file_actions, &attr,
(char *const *)argv, (char *const *)envp);
if (error_code != 0) {
- if (log)
- log->Printf("::posix_spawnp(pid => %p, path = '%s', file_actions "
- "= %p, attr = %p, argv = %p, envp = %p) failed: %s",
- pid, path, &file_actions, &attr, argv, envp,
- strerror(error_code));
+ LLDB_LOG(log,
+ "::posix_spawnp(pid => {0}, path = '{1}', file_actions "
+ "= {2}, attr = {3}, argv = {4}, envp = {5}) failed: {6}",
+ pid, path, &file_actions, &attr, argv, envp,
+ llvm::sys::StrError(error_code));
error.SetError(error_code, eErrorTypePOSIX);
return error;
}
diff --git a/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp b/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp
index 34d99cd39de2..10dd14753914 100644
--- a/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp
+++ b/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp
@@ -30,6 +30,7 @@
#include "lldb/Target/Thread.h"
#include "lldb/Target/UnixSignals.h"
#include "lldb/Utility/Status.h"
+#include "llvm/Support/Errno.h"
#include "FreeBSDThread.h"
#include "Plugins/Process/POSIX/CrashReason.h"
@@ -529,10 +530,8 @@ void ResumeOperation::Execute(ProcessMonitor *monitor) {
if (PTRACE(PT_CONTINUE, pid, (caddr_t)1, data)) {
Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PROCESS));
-
- if (log)
- log->Printf("ResumeOperation (%" PRIu64 ") failed: %s", pid,
- strerror(errno));
+ LLDB_LOG(log, "ResumeOperation ({0}) failed: {1}", pid,
+ llvm::sys::StrError(errno));
m_result = false;
} else
m_result = true;
diff --git a/source/Plugins/Process/Linux/NativeProcessLinux.cpp b/source/Plugins/Process/Linux/NativeProcessLinux.cpp
index 15e7c9b5f698..a130472c72d0 100644
--- a/source/Plugins/Process/Linux/NativeProcessLinux.cpp
+++ b/source/Plugins/Process/Linux/NativeProcessLinux.cpp
@@ -43,14 +43,14 @@
#include "lldb/Utility/LLDBAssert.h"
#include "lldb/Utility/Status.h"
#include "lldb/Utility/StringExtractor.h"
+#include "llvm/Support/Errno.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Threading.h"
#include "NativeThreadLinux.h"
#include "Plugins/Process/POSIX/ProcessPOSIXLog.h"
#include "Procfs.h"
-#include "llvm/Support/FileSystem.h"
-#include "llvm/Support/Threading.h"
-
#include <linux/unistd.h>
#include <sys/socket.h>
#include <sys/syscall.h>
@@ -97,7 +97,7 @@ static bool ProcessVmReadvSupported() {
LLDB_LOG(log,
"syscall process_vm_readv failed (error: {0}). Fast memory "
"reads disabled.",
- strerror(errno));
+ llvm::sys::StrError());
});
return is_supported;
@@ -1988,7 +1988,7 @@ Status NativeProcessLinux::ReadMemory(lldb::addr_t addr, void *buf, size_t size,
LLDB_LOG(log,
"using process_vm_readv to read {0} bytes from inferior "
"address {1:x}: {2}",
- size, addr, success ? "Success" : strerror(errno));
+ size, addr, success ? "Success" : llvm::sys::StrError(errno));
if (success)
return Status();
diff --git a/source/Plugins/Process/Utility/RegisterContextLLDB.cpp b/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
index 312c1887b581..bce77d7e0a32 100644
--- a/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
+++ b/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
@@ -329,7 +329,8 @@ void RegisterContextLLDB::InitializeNonZerothFrame() {
if (abi)
pc = abi->FixCodeAddress(pc);
- m_current_pc.SetLoadAddress(pc, &process->GetTarget());
+ const bool allow_section_end = true;
+ m_current_pc.SetLoadAddress(pc, &process->GetTarget(), allow_section_end);
// If we don't have a Module for some reason, we're not going to find
// symbol/function information - just
@@ -477,11 +478,12 @@ void RegisterContextLLDB::InitializeNonZerothFrame() {
// Or if we're in the middle of the stack (and not "above" an asynchronous
// event like sigtramp),
// and our "current" pc is the start of a function...
- if (m_sym_ctx_valid && GetNextFrame()->m_frame_type != eTrapHandlerFrame &&
+ if (GetNextFrame()->m_frame_type != eTrapHandlerFrame &&
GetNextFrame()->m_frame_type != eDebuggerFrame &&
- addr_range.GetBaseAddress().IsValid() &&
- addr_range.GetBaseAddress().GetSection() == m_current_pc.GetSection() &&
- addr_range.GetBaseAddress().GetOffset() == m_current_pc.GetOffset()) {
+ (!m_sym_ctx_valid ||
+ (addr_range.GetBaseAddress().IsValid() &&
+ addr_range.GetBaseAddress().GetSection() == m_current_pc.GetSection() &&
+ addr_range.GetBaseAddress().GetOffset() == m_current_pc.GetOffset()))) {
decr_pc_and_recompute_addr_range = true;
}
diff --git a/source/Plugins/Process/elf-core/CMakeLists.txt b/source/Plugins/Process/elf-core/CMakeLists.txt
index b358697d25af..c7ffae695320 100644
--- a/source/Plugins/Process/elf-core/CMakeLists.txt
+++ b/source/Plugins/Process/elf-core/CMakeLists.txt
@@ -17,5 +17,6 @@ add_lldb_library(lldbPluginProcessElfCore PLUGIN
lldbPluginObjectFileELF
lldbPluginProcessUtility
LINK_COMPONENTS
+ BinaryFormat
Support
)
diff --git a/source/Plugins/Process/elf-core/ProcessElfCore.cpp b/source/Plugins/Process/elf-core/ProcessElfCore.cpp
index 5a459e80348b..71eb6437ceed 100644
--- a/source/Plugins/Process/elf-core/ProcessElfCore.cpp
+++ b/source/Plugins/Process/elf-core/ProcessElfCore.cpp
@@ -27,7 +27,7 @@
#include "lldb/Utility/DataBufferLLVM.h"
#include "lldb/Utility/Log.h"
-#include "llvm/Support/ELF.h"
+#include "llvm/BinaryFormat/ELF.h"
#include "llvm/Support/Threading.h"
#include "Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h"
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index cb00e840673f..f5418763d67b 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -3732,8 +3732,8 @@ static DWARFDIE GetContainingFunctionWithAbstractOrigin(const DWARFDIE &die) {
}
}
}
- assert(!"Shouldn't call GetContainingFunctionWithAbstractOrigin on something "
- "not in a function");
+ assert(0 && "Shouldn't call GetContainingFunctionWithAbstractOrigin on "
+ "something not in a function");
return DWARFDIE();
}
diff --git a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index 279efe320a46..252a9807a3b5 100644
--- a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -1958,7 +1958,7 @@ void SymbolFileDWARF::Index() {
&function_fullname_index, &function_method_index,
&function_selector_index, &objc_class_selectors_index,
&global_index, &type_index,
- &namespace_index](uint32_t cu_idx) {
+ &namespace_index](size_t cu_idx) {
DWARFCompileUnit *dwarf_cu = debug_info->GetCompileUnitAtIndex(cu_idx);
if (dwarf_cu) {
dwarf_cu->Index(
@@ -1967,10 +1967,9 @@ void SymbolFileDWARF::Index() {
objc_class_selectors_index[cu_idx], global_index[cu_idx],
type_index[cu_idx], namespace_index[cu_idx]);
}
- return cu_idx;
};
- auto extract_fn = [debug_info, &clear_cu_dies](uint32_t cu_idx) {
+ auto extract_fn = [debug_info, &clear_cu_dies](size_t cu_idx) {
DWARFCompileUnit *dwarf_cu = debug_info->GetCompileUnitAtIndex(cu_idx);
if (dwarf_cu) {
// dwarf_cu->ExtractDIEsIfNeeded(false) will return zero if the
diff --git a/source/Target/SectionLoadList.cpp b/source/Target/SectionLoadList.cpp
index 7f12c262f47e..31ccf17369db 100644
--- a/source/Target/SectionLoadList.cpp
+++ b/source/Target/SectionLoadList.cpp
@@ -207,8 +207,8 @@ bool SectionLoadList::SetSectionUnloaded(const lldb::SectionSP &section_sp,
return erased;
}
-bool SectionLoadList::ResolveLoadAddress(addr_t load_addr,
- Address &so_addr) const {
+bool SectionLoadList::ResolveLoadAddress(addr_t load_addr, Address &so_addr,
+ bool allow_section_end) const {
// First find the top level section that this load address exists in
std::lock_guard<std::recursive_mutex> guard(m_mutex);
if (!m_addr_to_sect.empty()) {
@@ -220,10 +220,11 @@ bool SectionLoadList::ResolveLoadAddress(addr_t load_addr,
const addr_t pos_load_addr = pos->first;
if (load_addr >= pos_load_addr) {
addr_t offset = load_addr - pos_load_addr;
- if (offset < pos->second->GetByteSize()) {
+ if (offset < pos->second->GetByteSize() + (allow_section_end ? 1 : 0)) {
// We have found the top level section, now we need to find the
// deepest child section.
- return pos->second->ResolveContainedAddress(offset, so_addr);
+ return pos->second->ResolveContainedAddress(offset, so_addr,
+ allow_section_end);
}
}
} else {
@@ -233,10 +234,12 @@ bool SectionLoadList::ResolveLoadAddress(addr_t load_addr,
m_addr_to_sect.rbegin();
if (load_addr >= rpos->first) {
addr_t offset = load_addr - rpos->first;
- if (offset < rpos->second->GetByteSize()) {
+ if (offset <
+ rpos->second->GetByteSize() + (allow_section_end ? 1 : 0)) {
// We have found the top level section, now we need to find the
// deepest child section.
- return rpos->second->ResolveContainedAddress(offset, so_addr);
+ return rpos->second->ResolveContainedAddress(offset, so_addr,
+ allow_section_end);
}
}
}
diff --git a/source/Target/StackFrame.cpp b/source/Target/StackFrame.cpp
index 9deebcaf9250..4ef4a399290a 100644
--- a/source/Target/StackFrame.cpp
+++ b/source/Target/StackFrame.cpp
@@ -191,9 +191,10 @@ const Address &StackFrame::GetFrameCodeAddress() {
if (thread_sp) {
TargetSP target_sp(thread_sp->CalculateTarget());
if (target_sp) {
+ const bool allow_section_end = true;
if (m_frame_code_addr.SetOpcodeLoadAddress(
m_frame_code_addr.GetOffset(), target_sp.get(),
- eAddressClassCode)) {
+ eAddressClassCode, allow_section_end)) {
ModuleSP module_sp(m_frame_code_addr.GetModule());
if (module_sp) {
m_sc.module_sp = module_sp;
diff --git a/source/Utility/CMakeLists.txt b/source/Utility/CMakeLists.txt
index a1675670f0b4..31b14acda962 100644
--- a/source/Utility/CMakeLists.txt
+++ b/source/Utility/CMakeLists.txt
@@ -38,5 +38,6 @@ add_lldb_library(lldbUtility
# lldbUtility cannot have any dependencies
LINK_COMPONENTS
+ BinaryFormat
Support
)
diff --git a/source/Utility/Status.cpp b/source/Utility/Status.cpp
index ba87d3e5144f..6ecc7717620b 100644
--- a/source/Utility/Status.cpp
+++ b/source/Utility/Status.cpp
@@ -11,10 +11,11 @@
#include "lldb/Utility/Status.h"
#include "lldb/Utility/VASPrintf.h"
-#include "lldb/lldb-defines.h" // for LLDB_GENERIC_ERROR
-#include "lldb/lldb-enumerations.h" // for ErrorType, ErrorType::eErr...
-#include "llvm/ADT/SmallString.h" // for SmallString
-#include "llvm/ADT/StringRef.h" // for StringRef
+#include "lldb/lldb-defines.h" // for LLDB_GENERIC_ERROR
+#include "lldb/lldb-enumerations.h" // for ErrorType, ErrorType::eErr...
+#include "llvm/ADT/SmallString.h" // for SmallString
+#include "llvm/ADT/StringRef.h" // for StringRef
+#include "llvm/Support/Errno.h"
#include "llvm/Support/FormatProviders.h" // for format_provider
#include <cerrno>
@@ -27,7 +28,6 @@
#endif
#include <stdint.h> // for uint32_t
-#include <string.h> // for strerror
namespace llvm {
class raw_ostream;
@@ -121,23 +121,21 @@ const char *Status::AsCString(const char *default_error_str) const {
return nullptr;
if (m_string.empty()) {
- const char *s = nullptr;
switch (m_type) {
case eErrorTypeMachKernel:
#if defined(__APPLE__)
- s = ::mach_error_string(m_code);
+ if (const char *s = ::mach_error_string(m_code))
+ m_string.assign(s);
#endif
break;
case eErrorTypePOSIX:
- s = ::strerror(m_code);
+ m_string = llvm::sys::StrError(m_code);
break;
default:
break;
}
- if (s != nullptr)
- m_string.assign(s);
}
if (m_string.empty()) {
if (default_error_str)
diff --git a/source/Utility/TaskPool.cpp b/source/Utility/TaskPool.cpp
index d8306dc7dc8f..d33f23cd861c 100644
--- a/source/Utility/TaskPool.cpp
+++ b/source/Utility/TaskPool.cpp
@@ -75,7 +75,7 @@ void TaskPoolImpl::Worker(TaskPoolImpl *pool) {
}
void TaskMapOverInt(size_t begin, size_t end,
- std::function<void(size_t)> const &func) {
+ const llvm::function_ref<void(size_t)> &func) {
std::atomic<size_t> idx{begin};
size_t num_workers =
std::min<size_t>(end, std::thread::hardware_concurrency());
diff --git a/source/Utility/VMRange.cpp b/source/Utility/VMRange.cpp
index 5eccd292a851..105b1a58c48c 100644
--- a/source/Utility/VMRange.cpp
+++ b/source/Utility/VMRange.cpp
@@ -25,34 +25,13 @@ using namespace lldb_private;
bool VMRange::ContainsValue(const VMRange::collection &coll,
lldb::addr_t value) {
ValueInRangeUnaryPredicate in_range_predicate(value);
- VMRange::const_iterator pos;
- VMRange::const_iterator end = coll.end();
- pos = std::find_if(coll.begin(), end, in_range_predicate);
- if (pos != end)
- return true;
- return false;
+ return llvm::find_if(coll, in_range_predicate) != coll.end();
}
bool VMRange::ContainsRange(const VMRange::collection &coll,
const VMRange &range) {
RangeInRangeUnaryPredicate in_range_predicate(range);
- VMRange::const_iterator pos;
- VMRange::const_iterator end = coll.end();
- pos = std::find_if(coll.begin(), end, in_range_predicate);
- if (pos != end)
- return true;
- return false;
-}
-
-size_t VMRange::FindRangeIndexThatContainsValue(const VMRange::collection &coll,
- lldb::addr_t value) {
- ValueInRangeUnaryPredicate in_range_predicate(value);
- VMRange::const_iterator begin = coll.begin();
- VMRange::const_iterator end = coll.end();
- VMRange::const_iterator pos = std::find_if(begin, end, in_range_predicate);
- if (pos != end)
- return std::distance(begin, pos);
- return UINT32_MAX;
+ return llvm::find_if(coll, in_range_predicate) != coll.end();
}
void VMRange::Dump(Stream *s, lldb::addr_t offset, uint32_t addr_width) const {
@@ -66,8 +45,7 @@ bool lldb_private::operator==(const VMRange &lhs, const VMRange &rhs) {
}
bool lldb_private::operator!=(const VMRange &lhs, const VMRange &rhs) {
- return lhs.GetBaseAddress() != rhs.GetBaseAddress() ||
- lhs.GetEndAddress() != rhs.GetEndAddress();
+ return !(lhs == rhs);
}
bool lldb_private::operator<(const VMRange &lhs, const VMRange &rhs) {
@@ -79,25 +57,13 @@ bool lldb_private::operator<(const VMRange &lhs, const VMRange &rhs) {
}
bool lldb_private::operator<=(const VMRange &lhs, const VMRange &rhs) {
- if (lhs.GetBaseAddress() < rhs.GetBaseAddress())
- return true;
- else if (lhs.GetBaseAddress() > rhs.GetBaseAddress())
- return false;
- return lhs.GetEndAddress() <= rhs.GetEndAddress();
+ return !(lhs > rhs);
}
bool lldb_private::operator>(const VMRange &lhs, const VMRange &rhs) {
- if (lhs.GetBaseAddress() > rhs.GetBaseAddress())
- return true;
- else if (lhs.GetBaseAddress() < rhs.GetBaseAddress())
- return false;
- return lhs.GetEndAddress() > rhs.GetEndAddress();
+ return rhs < lhs;
}
bool lldb_private::operator>=(const VMRange &lhs, const VMRange &rhs) {
- if (lhs.GetBaseAddress() > rhs.GetBaseAddress())
- return true;
- else if (lhs.GetBaseAddress() < rhs.GetBaseAddress())
- return false;
- return lhs.GetEndAddress() >= rhs.GetEndAddress();
+ return !(lhs < rhs);
}