summaryrefslogtreecommitdiff
path: root/source/Target
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2019-08-20 20:51:52 +0000
committerDimitry Andric <dim@FreeBSD.org>2019-08-20 20:51:52 +0000
commit5f29bb8a675e8f96452b632e7129113f7dec850e (patch)
tree3d3f2a0d3ad10872a4dcaba8ec8d1d20c87ab147 /source/Target
parent88c643b6fec27eec436c8d138fee6346e92337d6 (diff)
Notes
Diffstat (limited to 'source/Target')
-rw-r--r--source/Target/ABI.cpp35
-rw-r--r--source/Target/CPPLanguageRuntime.cpp346
-rw-r--r--source/Target/ExecutionContext.cpp15
-rw-r--r--source/Target/FileAction.cpp91
-rw-r--r--source/Target/InstrumentationRuntime.cpp7
-rw-r--r--source/Target/InstrumentationRuntimeStopInfo.cpp7
-rw-r--r--source/Target/JITLoader.cpp7
-rw-r--r--source/Target/JITLoaderList.cpp7
-rw-r--r--source/Target/Language.cpp40
-rw-r--r--source/Target/LanguageRuntime.cpp59
-rw-r--r--source/Target/Memory.cpp33
-rw-r--r--source/Target/MemoryHistory.cpp7
-rw-r--r--source/Target/ModuleCache.cpp7
-rw-r--r--source/Target/ObjCLanguageRuntime.cpp384
-rw-r--r--source/Target/OperatingSystem.cpp19
-rw-r--r--source/Target/PathMappingList.cpp92
-rw-r--r--source/Target/Platform.cpp68
-rw-r--r--source/Target/Process.cpp850
-rw-r--r--source/Target/ProcessInfo.cpp114
-rw-r--r--source/Target/ProcessLaunchInfo.cpp348
-rw-r--r--source/Target/Queue.cpp7
-rw-r--r--source/Target/QueueItem.cpp7
-rw-r--r--source/Target/QueueList.cpp7
-rw-r--r--source/Target/RegisterContext.cpp7
-rw-r--r--source/Target/RegisterNumber.cpp7
-rw-r--r--source/Target/RemoteAwarePlatform.cpp284
-rw-r--r--source/Target/SectionLoadHistory.cpp11
-rw-r--r--source/Target/SectionLoadList.cpp12
-rw-r--r--source/Target/StackFrame.cpp38
-rw-r--r--source/Target/StackFrameList.cpp53
-rw-r--r--source/Target/StackFrameRecognizer.cpp25
-rw-r--r--source/Target/StackID.cpp7
-rw-r--r--source/Target/StopInfo.cpp23
-rw-r--r--source/Target/StructuredDataPlugin.cpp11
-rw-r--r--source/Target/SystemRuntime.cpp15
-rw-r--r--source/Target/Target.cpp293
-rw-r--r--source/Target/TargetList.cpp13
-rw-r--r--source/Target/Thread.cpp109
-rw-r--r--source/Target/ThreadCollection.cpp7
-rw-r--r--source/Target/ThreadList.cpp13
-rw-r--r--source/Target/ThreadPlan.cpp13
-rw-r--r--source/Target/ThreadPlanBase.cpp9
-rw-r--r--source/Target/ThreadPlanCallFunction.cpp15
-rw-r--r--source/Target/ThreadPlanCallFunctionUsingABI.cpp9
-rw-r--r--source/Target/ThreadPlanCallOnFunctionExit.cpp9
-rw-r--r--source/Target/ThreadPlanCallUserExpression.cpp11
-rw-r--r--source/Target/ThreadPlanPython.cpp14
-rw-r--r--source/Target/ThreadPlanRunToAddress.cpp9
-rw-r--r--source/Target/ThreadPlanShouldStopHere.cpp11
-rw-r--r--source/Target/ThreadPlanStepInRange.cpp17
-rw-r--r--source/Target/ThreadPlanStepInstruction.cpp9
-rw-r--r--source/Target/ThreadPlanStepOut.cpp25
-rw-r--r--source/Target/ThreadPlanStepOverBreakpoint.cpp9
-rw-r--r--source/Target/ThreadPlanStepOverRange.cpp9
-rw-r--r--source/Target/ThreadPlanStepRange.cpp28
-rw-r--r--source/Target/ThreadPlanStepThrough.cpp35
-rw-r--r--source/Target/ThreadPlanStepUntil.cpp9
-rw-r--r--source/Target/ThreadPlanTracer.cpp9
-rw-r--r--source/Target/ThreadSpec.cpp19
-rw-r--r--source/Target/UnixSignals.cpp16
-rw-r--r--source/Target/UnwindAssembly.cpp13
61 files changed, 1276 insertions, 2507 deletions
diff --git a/source/Target/ABI.cpp b/source/Target/ABI.cpp
index 96e09b75094af..28cd9aec665cb 100644
--- a/source/Target/ABI.cpp
+++ b/source/Target/ABI.cpp
@@ -1,17 +1,16 @@
//===-- ABI.cpp -------------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "lldb/Target/ABI.h"
-#include "Plugins/ExpressionParser/Clang/ClangPersistentVariables.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/Value.h"
#include "lldb/Core/ValueObjectConstResult.h"
+#include "lldb/Expression/ExpressionVariable.h"
#include "lldb/Symbol/CompilerType.h"
#include "lldb/Symbol/TypeSystem.h"
#include "lldb/Target/Target.h"
@@ -40,7 +39,7 @@ ABI::FindPlugin(lldb::ProcessSP process_sp, const ArchSpec &arch) {
ABI::~ABI() = default;
-bool ABI::GetRegisterInfoByName(const ConstString &name, RegisterInfo &info) {
+bool ABI::GetRegisterInfoByName(ConstString name, RegisterInfo &info) {
uint32_t count = 0;
const RegisterInfo *register_info_array = GetRegisterInfoArray(count);
if (register_info_array) {
@@ -125,11 +124,11 @@ ValueObjectSP ABI::GetReturnValueObject(Thread &thread, CompilerType &ast_type,
return_valobj_sp = const_valobj_sp;
- ExpressionVariableSP clang_expr_variable_sp(
+ ExpressionVariableSP expr_variable_sp(
persistent_expression_state->CreatePersistentVariable(
return_valobj_sp));
- assert(clang_expr_variable_sp);
+ assert(expr_variable_sp);
// Set flags and live data as appropriate
@@ -142,21 +141,21 @@ ValueObjectSP ABI::GetReturnValueObject(Thread &thread, CompilerType &ast_type,
break;
case Value::eValueTypeScalar:
case Value::eValueTypeVector:
- clang_expr_variable_sp->m_flags |=
- ClangExpressionVariable::EVIsFreezeDried;
- clang_expr_variable_sp->m_flags |=
- ClangExpressionVariable::EVIsLLDBAllocated;
- clang_expr_variable_sp->m_flags |=
- ClangExpressionVariable::EVNeedsAllocation;
+ expr_variable_sp->m_flags |=
+ ExpressionVariable::EVIsFreezeDried;
+ expr_variable_sp->m_flags |=
+ ExpressionVariable::EVIsLLDBAllocated;
+ expr_variable_sp->m_flags |=
+ ExpressionVariable::EVNeedsAllocation;
break;
case Value::eValueTypeLoadAddress:
- clang_expr_variable_sp->m_live_sp = live_valobj_sp;
- clang_expr_variable_sp->m_flags |=
- ClangExpressionVariable::EVIsProgramReference;
+ expr_variable_sp->m_live_sp = live_valobj_sp;
+ expr_variable_sp->m_flags |=
+ ExpressionVariable::EVIsProgramReference;
break;
}
- return_valobj_sp = clang_expr_variable_sp->GetValueObject();
+ return_valobj_sp = expr_variable_sp->GetValueObject();
}
return return_valobj_sp;
}
diff --git a/source/Target/CPPLanguageRuntime.cpp b/source/Target/CPPLanguageRuntime.cpp
deleted file mode 100644
index f0bd1758461cb..0000000000000
--- a/source/Target/CPPLanguageRuntime.cpp
+++ /dev/null
@@ -1,346 +0,0 @@
-//===-- CPPLanguageRuntime.cpp
-//-------------------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "lldb/Target/CPPLanguageRuntime.h"
-
-#include <string.h>
-
-#include "llvm/ADT/StringRef.h"
-
-#include "lldb/Symbol/Block.h"
-#include "lldb/Symbol/VariableList.h"
-
-#include "lldb/Core/PluginManager.h"
-#include "lldb/Core/UniqueCStringMap.h"
-#include "lldb/Symbol/ClangASTContext.h"
-#include "lldb/Target/ABI.h"
-#include "lldb/Target/ExecutionContext.h"
-#include "lldb/Target/RegisterContext.h"
-#include "lldb/Target/SectionLoadList.h"
-#include "lldb/Target/StackFrame.h"
-#include "lldb/Target/ThreadPlanRunToAddress.h"
-#include "lldb/Target/ThreadPlanStepInRange.h"
-
-using namespace lldb;
-using namespace lldb_private;
-
-//----------------------------------------------------------------------
-// Destructor
-//----------------------------------------------------------------------
-CPPLanguageRuntime::~CPPLanguageRuntime() {}
-
-CPPLanguageRuntime::CPPLanguageRuntime(Process *process)
- : LanguageRuntime(process) {}
-
-bool CPPLanguageRuntime::GetObjectDescription(Stream &str,
- ValueObject &object) {
- // C++ has no generic way to do this.
- return false;
-}
-
-bool CPPLanguageRuntime::GetObjectDescription(
- Stream &str, Value &value, ExecutionContextScope *exe_scope) {
- // C++ has no generic way to do this.
- return false;
-}
-
-CPPLanguageRuntime::LibCppStdFunctionCallableInfo
-CPPLanguageRuntime::FindLibCppStdFunctionCallableInfo(
- lldb::ValueObjectSP &valobj_sp) {
- LibCppStdFunctionCallableInfo optional_info;
-
- if (!valobj_sp)
- return optional_info;
-
- // Member __f_ has type __base*, the contents of which will hold:
- // 1) a vtable entry which may hold type information needed to discover the
- // lambda being called
- // 2) possibly hold a pointer to the callable object
- // e.g.
- //
- // (lldb) frame var -R f_display
- // (std::__1::function<void (int)>) f_display = {
- // __buf_ = {
- // …
- // }
- // __f_ = 0x00007ffeefbffa00
- // }
- // (lldb) memory read -fA 0x00007ffeefbffa00
- // 0x7ffeefbffa00: ... `vtable for std::__1::__function::__func<void (*) ...
- // 0x7ffeefbffa08: ... `print_num(int) at std_function_cppreference_exam ...
- //
- // We will be handling five cases below, std::function is wrapping:
- //
- // 1) a lambda we know at compile time. We will obtain the name of the lambda
- // from the first template pameter from __func's vtable. We will look up
- // the lambda's operator()() and obtain the line table entry.
- // 2) a lambda we know at runtime. A pointer to the lambdas __invoke method
- // will be stored after the vtable. We will obtain the lambdas name from
- // this entry and lookup operator()() and obtain the line table entry.
- // 3) a callable object via operator()(). We will obtain the name of the
- // object from the first template parameter from __func's vtable. We will
- // look up the objectc operator()() and obtain the line table entry.
- // 4) a member function. A pointer to the function will stored after the
- // we will obtain the name from this pointer.
- // 5) a free function. A pointer to the function will stored after the vtable
- // we will obtain the name from this pointer.
- ValueObjectSP member__f_(
- valobj_sp->GetChildMemberWithName(ConstString("__f_"), true));
-
- if (member__f_) {
- ValueObjectSP sub_member__f_(
- member__f_->GetChildMemberWithName(ConstString("__f_"), true));
-
- if (sub_member__f_)
- member__f_ = sub_member__f_;
- }
-
- lldb::addr_t member__f_pointer_value = member__f_->GetValueAsUnsigned(0);
-
- optional_info.member__f_pointer_value = member__f_pointer_value;
-
- ExecutionContext exe_ctx(valobj_sp->GetExecutionContextRef());
- Process *process = exe_ctx.GetProcessPtr();
-
- if (process == nullptr)
- return optional_info;
-
- uint32_t address_size = process->GetAddressByteSize();
- Status status;
-
- // First item pointed to by __f_ should be the pointer to the vtable for
- // a __base object.
- lldb::addr_t vtable_address =
- process->ReadPointerFromMemory(member__f_pointer_value, status);
-
- if (status.Fail())
- return optional_info;
-
- lldb::addr_t address_after_vtable = member__f_pointer_value + address_size;
- // As commened above we may not have a function pointer but if we do we will
- // need it.
- lldb::addr_t possible_function_address =
- process->ReadPointerFromMemory(address_after_vtable, status);
-
- if (status.Fail())
- return optional_info;
-
- Target &target = process->GetTarget();
-
- if (target.GetSectionLoadList().IsEmpty())
- return optional_info;
-
- Address vtable_addr_resolved;
- SymbolContext sc;
- Symbol *symbol;
-
- if (!target.GetSectionLoadList().ResolveLoadAddress(vtable_address,
- vtable_addr_resolved))
- return optional_info;
-
- target.GetImages().ResolveSymbolContextForAddress(
- vtable_addr_resolved, eSymbolContextEverything, sc);
- symbol = sc.symbol;
-
- if (symbol == nullptr)
- return optional_info;
-
- llvm::StringRef vtable_name(symbol->GetName().GetCString());
- bool found_expected_start_string =
- vtable_name.startswith("vtable for std::__1::__function::__func<");
-
- if (!found_expected_start_string)
- return optional_info;
-
- // Given case 1 or 3 we have a vtable name, we are want to extract the first
- // template parameter
- //
- // ... __func<main::$_0, std::__1::allocator<main::$_0> ...
- // ^^^^^^^^^
- //
- // We do this by find the first < and , and extracting in between.
- //
- // This covers the case of the lambda known at compile time.
- size_t first_open_angle_bracket = vtable_name.find('<') + 1;
- size_t first_comma = vtable_name.find_first_of(',');
-
- llvm::StringRef first_template_parameter =
- vtable_name.slice(first_open_angle_bracket, first_comma);
-
- Address function_address_resolved;
-
- // Setup for cases 2, 4 and 5 we have a pointer to a function after the
- // vtable. We will use a process of elimination to drop through each case
- // and obtain the data we need.
- if (target.GetSectionLoadList().ResolveLoadAddress(
- possible_function_address, function_address_resolved)) {
- target.GetImages().ResolveSymbolContextForAddress(
- function_address_resolved, eSymbolContextEverything, sc);
- symbol = sc.symbol;
- }
-
- auto get_name = [&first_template_parameter, &symbol]() {
- // Given case 1:
- //
- // main::$_0
- //
- // we want to append ::operator()()
- if (first_template_parameter.contains("$_"))
- return llvm::Regex::escape(first_template_parameter.str()) +
- R"(::operator\(\)\(.*\))";
-
- if (symbol != NULL &&
- symbol->GetName().GetStringRef().contains("__invoke")) {
-
- llvm::StringRef symbol_name = symbol->GetName().GetStringRef();
- size_t pos2 = symbol_name.find_last_of(':');
-
- // Given case 2:
- //
- // main::$_1::__invoke(...)
- //
- // We want to slice off __invoke(...) and append operator()()
- std::string lambda_operator =
- llvm::Regex::escape(symbol_name.slice(0, pos2 + 1).str()) +
- R"(operator\(\)\(.*\))";
-
- return lambda_operator;
- }
-
- // Case 3
- return first_template_parameter.str() + R"(::operator\(\)\(.*\))";
- ;
- };
-
- std::string func_to_match = get_name();
-
- SymbolContextList scl;
-
- target.GetImages().FindFunctions(RegularExpression{func_to_match}, true, true,
- true, scl);
-
- // Case 1,2 or 3
- if (scl.GetSize() >= 1) {
- SymbolContext sc2 = scl[0];
-
- AddressRange range;
- sc2.GetAddressRange(eSymbolContextEverything, 0, false, range);
-
- Address address = range.GetBaseAddress();
-
- Address addr;
- if (target.ResolveLoadAddress(address.GetCallableLoadAddress(&target),
- addr)) {
- LineEntry line_entry;
- addr.CalculateSymbolContextLineEntry(line_entry);
-
- if (first_template_parameter.contains("$_") ||
- (symbol != nullptr &&
- symbol->GetName().GetStringRef().contains("__invoke"))) {
- // Case 1 and 2
- optional_info.callable_case = LibCppStdFunctionCallableCase::Lambda;
- } else {
- // Case 3
- optional_info.callable_case =
- LibCppStdFunctionCallableCase::CallableObject;
- }
-
- optional_info.callable_symbol = *symbol;
- optional_info.callable_line_entry = line_entry;
- optional_info.callable_address = addr;
- return optional_info;
- }
- }
-
- // Case 4 or 5
- if (!symbol->GetName().GetStringRef().startswith("vtable for")) {
- optional_info.callable_case =
- LibCppStdFunctionCallableCase::FreeOrMemberFunction;
- optional_info.callable_address = function_address_resolved;
- optional_info.callable_symbol = *symbol;
-
- return optional_info;
- }
-
- return optional_info;
-}
-
-lldb::ThreadPlanSP
-CPPLanguageRuntime::GetStepThroughTrampolinePlan(Thread &thread,
- bool stop_others) {
- ThreadPlanSP ret_plan_sp;
-
- lldb::addr_t curr_pc = thread.GetRegisterContext()->GetPC();
-
- TargetSP target_sp(thread.CalculateTarget());
-
- if (target_sp->GetSectionLoadList().IsEmpty())
- return ret_plan_sp;
-
- Address pc_addr_resolved;
- SymbolContext sc;
- Symbol *symbol;
-
- if (!target_sp->GetSectionLoadList().ResolveLoadAddress(curr_pc,
- pc_addr_resolved))
- return ret_plan_sp;
-
- target_sp->GetImages().ResolveSymbolContextForAddress(
- pc_addr_resolved, eSymbolContextEverything, sc);
- symbol = sc.symbol;
-
- if (symbol == nullptr)
- return ret_plan_sp;
-
- llvm::StringRef function_name(symbol->GetName().GetCString());
-
- // Handling the case where we are attempting to step into std::function.
- // The behavior will be that we will attempt to obtain the wrapped
- // callable via FindLibCppStdFunctionCallableInfo() and if we find it we
- // will return a ThreadPlanRunToAddress to the callable. Therefore we will
- // step into the wrapped callable.
- //
- bool found_expected_start_string =
- function_name.startswith("std::__1::function<");
-
- if (!found_expected_start_string)
- return ret_plan_sp;
-
- AddressRange range_of_curr_func;
- sc.GetAddressRange(eSymbolContextEverything, 0, false, range_of_curr_func);
-
- StackFrameSP frame = thread.GetStackFrameAtIndex(0);
-
- if (frame) {
- ValueObjectSP value_sp = frame->FindVariable(ConstString("this"));
-
- CPPLanguageRuntime::LibCppStdFunctionCallableInfo callable_info =
- FindLibCppStdFunctionCallableInfo(value_sp);
-
- if (callable_info.callable_case != LibCppStdFunctionCallableCase::Invalid &&
- value_sp->GetValueIsValid()) {
- // We found the std::function wrapped callable and we have its address.
- // We now create a ThreadPlan to run to the callable.
- ret_plan_sp.reset(new ThreadPlanRunToAddress(
- thread, callable_info.callable_address, stop_others));
- return ret_plan_sp;
- } else {
- // We are in std::function but we could not obtain the callable.
- // We create a ThreadPlan to keep stepping through using the address range
- // of the current function.
- ret_plan_sp.reset(new ThreadPlanStepInRange(thread, range_of_curr_func,
- sc, eOnlyThisThread,
- eLazyBoolYes, eLazyBoolYes));
- return ret_plan_sp;
- }
- }
-
- return ret_plan_sp;
-}
diff --git a/source/Target/ExecutionContext.cpp b/source/Target/ExecutionContext.cpp
index 7f1f0331c922f..77327372f88bf 100644
--- a/source/Target/ExecutionContext.cpp
+++ b/source/Target/ExecutionContext.cpp
@@ -1,9 +1,8 @@
//===-- ExecutionContext.cpp ------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -225,30 +224,22 @@ ExecutionContextScope *ExecutionContext::GetBestExecutionContextScope() const {
}
Target &ExecutionContext::GetTargetRef() const {
-#if defined(LLDB_CONFIGURATION_DEBUG) || defined(LLDB_CONFIGURATION_RELEASE)
assert(m_target_sp);
-#endif
return *m_target_sp;
}
Process &ExecutionContext::GetProcessRef() const {
-#if defined(LLDB_CONFIGURATION_DEBUG) || defined(LLDB_CONFIGURATION_RELEASE)
assert(m_process_sp);
-#endif
return *m_process_sp;
}
Thread &ExecutionContext::GetThreadRef() const {
-#if defined(LLDB_CONFIGURATION_DEBUG) || defined(LLDB_CONFIGURATION_RELEASE)
assert(m_thread_sp);
-#endif
return *m_thread_sp;
}
StackFrame &ExecutionContext::GetFrameRef() const {
-#if defined(LLDB_CONFIGURATION_DEBUG) || defined(LLDB_CONFIGURATION_RELEASE)
assert(m_frame_sp);
-#endif
return *m_frame_sp;
}
diff --git a/source/Target/FileAction.cpp b/source/Target/FileAction.cpp
deleted file mode 100644
index c9cc325b5a539..0000000000000
--- a/source/Target/FileAction.cpp
+++ /dev/null
@@ -1,91 +0,0 @@
-//===-- FileAction.cpp ------------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include <fcntl.h>
-
-#include "lldb/Host/PosixApi.h"
-#include "lldb/Target/FileAction.h"
-#include "lldb/Utility/Stream.h"
-
-using namespace lldb_private;
-
-//----------------------------------------------------------------------------
-// FileAction member functions
-//----------------------------------------------------------------------------
-
-FileAction::FileAction()
- : m_action(eFileActionNone), m_fd(-1), m_arg(-1), m_file_spec() {}
-
-void FileAction::Clear() {
- m_action = eFileActionNone;
- m_fd = -1;
- m_arg = -1;
- m_file_spec.Clear();
-}
-
-llvm::StringRef FileAction::GetPath() const { return m_file_spec.GetCString(); }
-
-const FileSpec &FileAction::GetFileSpec() const { return m_file_spec; }
-
-bool FileAction::Open(int fd, const FileSpec &file_spec, bool read,
- bool write) {
- if ((read || write) && fd >= 0 && file_spec) {
- m_action = eFileActionOpen;
- m_fd = fd;
- if (read && write)
- m_arg = O_NOCTTY | O_CREAT | O_RDWR;
- else if (read)
- m_arg = O_NOCTTY | O_RDONLY;
- else
- m_arg = O_NOCTTY | O_CREAT | O_WRONLY;
- m_file_spec = file_spec;
- return true;
- } else {
- Clear();
- }
- return false;
-}
-
-bool FileAction::Close(int fd) {
- Clear();
- if (fd >= 0) {
- m_action = eFileActionClose;
- m_fd = fd;
- }
- return m_fd >= 0;
-}
-
-bool FileAction::Duplicate(int fd, int dup_fd) {
- Clear();
- if (fd >= 0 && dup_fd >= 0) {
- m_action = eFileActionDuplicate;
- m_fd = fd;
- m_arg = dup_fd;
- }
- return m_fd >= 0;
-}
-
-void FileAction::Dump(Stream &stream) const {
- stream.PutCString("file action: ");
- switch (m_action) {
- case eFileActionClose:
- stream.Printf("close fd %d", m_fd);
- break;
- case eFileActionDuplicate:
- stream.Printf("duplicate fd %d to %d", m_fd, m_arg);
- break;
- case eFileActionNone:
- stream.PutCString("no action");
- break;
- case eFileActionOpen:
- stream.Printf("open fd %d with '%s', OFLAGS = 0x%x", m_fd,
- m_file_spec.GetCString(), m_arg);
- break;
- }
-}
diff --git a/source/Target/InstrumentationRuntime.cpp b/source/Target/InstrumentationRuntime.cpp
index e948d43d50af7..4c2eb064fbb05 100644
--- a/source/Target/InstrumentationRuntime.cpp
+++ b/source/Target/InstrumentationRuntime.cpp
@@ -1,9 +1,8 @@
//===-- InstrumentationRuntime.cpp ------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===---------------------------------------------------------------------===//
diff --git a/source/Target/InstrumentationRuntimeStopInfo.cpp b/source/Target/InstrumentationRuntimeStopInfo.cpp
index dbbd4f4fc1d8c..f2767ffbff0d9 100644
--- a/source/Target/InstrumentationRuntimeStopInfo.cpp
+++ b/source/Target/InstrumentationRuntimeStopInfo.cpp
@@ -1,9 +1,8 @@
//===-- InstrumentationRuntimeStopInfo.cpp ----------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Target/JITLoader.cpp b/source/Target/JITLoader.cpp
index ddadcfa87a0ad..e7c13bddcb361 100644
--- a/source/Target/JITLoader.cpp
+++ b/source/Target/JITLoader.cpp
@@ -1,9 +1,8 @@
//===-- JITLoader.cpp -------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Target/JITLoaderList.cpp b/source/Target/JITLoaderList.cpp
index 1e908bd543afb..4d1f06d0843e8 100644
--- a/source/Target/JITLoaderList.cpp
+++ b/source/Target/JITLoaderList.cpp
@@ -1,9 +1,8 @@
//===-- JITLoaderList.cpp ---------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Target/Language.cpp b/source/Target/Language.cpp
index 5c7a4097dd6ff..3c3ef2841d444 100644
--- a/source/Target/Language.cpp
+++ b/source/Target/Language.cpp
@@ -1,10 +1,9 @@
//===-- Language.cpp -------------------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -274,6 +273,24 @@ bool Language::LanguageIsC(LanguageType language) {
}
}
+bool Language::LanguageIsCFamily(LanguageType language) {
+ switch (language) {
+ case eLanguageTypeC:
+ case eLanguageTypeC89:
+ case eLanguageTypeC99:
+ case eLanguageTypeC11:
+ case eLanguageTypeC_plus_plus:
+ case eLanguageTypeC_plus_plus_03:
+ case eLanguageTypeC_plus_plus_11:
+ case eLanguageTypeC_plus_plus_14:
+ case eLanguageTypeObjC_plus_plus:
+ case eLanguageTypeObjC:
+ return true;
+ default:
+ return false;
+ }
+}
+
bool Language::LanguageIsPascal(LanguageType language) {
switch (language) {
case eLanguageTypePascal83:
@@ -331,6 +348,15 @@ LanguageType Language::GetPrimaryLanguage(LanguageType language) {
}
}
+std::set<lldb::LanguageType> Language::GetSupportedLanguages() {
+ std::set<lldb::LanguageType> supported_languages;
+ ForEach([&](Language *lang) {
+ supported_languages.emplace(lang->GetLanguageType());
+ return true;
+ });
+ return supported_languages;
+}
+
void Language::GetLanguagesSupportingTypeSystems(
std::set<lldb::LanguageType> &languages,
std::set<lldb::LanguageType> &languages_for_expressions) {
@@ -391,7 +417,7 @@ bool Language::ImageListTypeScavenger::Find_Impl(
images.FindTypes(nullptr, cs_key, false, UINT32_MAX, searched_sym_files,
matches);
for (const auto &match : matches.Types()) {
- if (match.get()) {
+ if (match) {
CompilerType compiler_type(match->GetFullCompilerType());
compiler_type = AdjustForInclusion(compiler_type);
if (!compiler_type)
@@ -444,12 +470,8 @@ void Language::GetDefaultExceptionResolverDescription(bool catch_on,
s.Printf("Exception breakpoint (catch: %s throw: %s)",
catch_on ? "on" : "off", throw_on ? "on" : "off");
}
-//----------------------------------------------------------------------
// Constructor
-//----------------------------------------------------------------------
Language::Language() {}
-//----------------------------------------------------------------------
// Destructor
-//----------------------------------------------------------------------
Language::~Language() {}
diff --git a/source/Target/LanguageRuntime.cpp b/source/Target/LanguageRuntime.cpp
index ea6914fb076d1..dd44158106132 100644
--- a/source/Target/LanguageRuntime.cpp
+++ b/source/Target/LanguageRuntime.cpp
@@ -1,23 +1,23 @@
//===-- LanguageRuntime.cpp -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "lldb/Target/LanguageRuntime.h"
-#include "Plugins/Language/ObjC/ObjCLanguage.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/SearchFilter.h"
#include "lldb/Interpreter/CommandInterpreter.h"
-#include "lldb/Target/ObjCLanguageRuntime.h"
+#include "lldb/Target/Language.h"
#include "lldb/Target/Target.h"
using namespace lldb;
using namespace lldb_private;
+char LanguageRuntime::ID = 0;
+
ExceptionSearchFilter::ExceptionSearchFilter(const lldb::TargetSP &target_sp,
lldb::LanguageType language,
bool update_module_list)
@@ -202,7 +202,7 @@ protected:
LanguageRuntime *LanguageRuntime::FindPlugin(Process *process,
lldb::LanguageType language) {
- std::unique_ptr<LanguageRuntime> language_runtime_ap;
+ std::unique_ptr<LanguageRuntime> language_runtime_up;
LanguageRuntimeCreateInstance create_callback;
for (uint32_t idx = 0;
@@ -210,10 +210,10 @@ LanguageRuntime *LanguageRuntime::FindPlugin(Process *process,
PluginManager::GetLanguageRuntimeCreateCallbackAtIndex(idx)) !=
nullptr;
++idx) {
- language_runtime_ap.reset(create_callback(process, language));
+ language_runtime_up.reset(create_callback(process, language));
- if (language_runtime_ap)
- return language_runtime_ap.release();
+ if (language_runtime_up)
+ return language_runtime_up.release();
}
return nullptr;
@@ -223,19 +223,24 @@ LanguageRuntime::LanguageRuntime(Process *process) : m_process(process) {}
LanguageRuntime::~LanguageRuntime() = default;
-Breakpoint::BreakpointPreconditionSP
-LanguageRuntime::CreateExceptionPrecondition(lldb::LanguageType language,
- bool catch_bp, bool throw_bp) {
- switch (language) {
- case eLanguageTypeObjC:
- if (throw_bp)
- return Breakpoint::BreakpointPreconditionSP(
- new ObjCLanguageRuntime::ObjCExceptionPrecondition());
- break;
- default:
- break;
+BreakpointPreconditionSP
+LanguageRuntime::GetExceptionPrecondition(LanguageType language,
+ bool throw_bp) {
+ LanguageRuntimeCreateInstance create_callback;
+ for (uint32_t idx = 0;
+ (create_callback =
+ PluginManager::GetLanguageRuntimeCreateCallbackAtIndex(idx)) !=
+ nullptr;
+ idx++) {
+ if (auto precondition_callback =
+ PluginManager::GetLanguageRuntimeGetExceptionPreconditionAtIndex(
+ idx)) {
+ if (BreakpointPreconditionSP precond =
+ precondition_callback(language, throw_bp))
+ return precond;
+ }
}
- return Breakpoint::BreakpointPreconditionSP();
+ return BreakpointPreconditionSP();
}
BreakpointSP LanguageRuntime::CreateExceptionBreakpoint(
@@ -251,10 +256,8 @@ BreakpointSP LanguageRuntime::CreateExceptionBreakpoint(
target.CreateBreakpoint(filter_sp, resolver_sp, is_internal, hardware,
resolve_indirect_functions));
if (exc_breakpt_sp) {
- Breakpoint::BreakpointPreconditionSP precondition_sp =
- CreateExceptionPrecondition(language, catch_bp, throw_bp);
- if (precondition_sp)
- exc_breakpt_sp->SetPrecondition(precondition_sp);
+ if (auto precond = GetExceptionPrecondition(language, throw_bp))
+ exc_breakpt_sp->SetPrecondition(precond);
if (is_internal)
exc_breakpt_sp->SetBreakpointKind("exception");
@@ -291,7 +294,3 @@ void LanguageRuntime::InitializeCommands(CommandObject *parent) {
}
}
}
-
-lldb::SearchFilterSP LanguageRuntime::CreateExceptionSearchFilter() {
- return m_process->GetTarget().GetSearchFilterForModule(nullptr);
-}
diff --git a/source/Target/Memory.cpp b/source/Target/Memory.cpp
index 190c5057e8811..31a378069cec8 100644
--- a/source/Target/Memory.cpp
+++ b/source/Target/Memory.cpp
@@ -1,34 +1,31 @@
//===-- Memory.cpp ----------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "lldb/Target/Memory.h"
-#include <inttypes.h>
-#include "lldb/Core/RangeMap.h"
#include "lldb/Target/Process.h"
#include "lldb/Utility/DataBufferHeap.h"
#include "lldb/Utility/Log.h"
+#include "lldb/Utility/RangeMap.h"
#include "lldb/Utility/State.h"
+#include <cinttypes>
+#include <memory>
+
using namespace lldb;
using namespace lldb_private;
-//----------------------------------------------------------------------
// MemoryCache constructor
-//----------------------------------------------------------------------
MemoryCache::MemoryCache(Process &process)
: m_mutex(), m_L1_cache(), m_L2_cache(), m_invalid_ranges(),
m_process(process),
m_L2_cache_line_byte_size(process.GetMemoryCacheLineSize()) {}
-//----------------------------------------------------------------------
// Destructor
-//----------------------------------------------------------------------
MemoryCache::~MemoryCache() {}
void MemoryCache::Clear(bool clear_invalid_ranges) {
@@ -145,7 +142,7 @@ size_t MemoryCache::Read(addr_t addr, void *dst, size_t dst_len,
}
AddrRange chunk_range(pos->first, pos->second->GetByteSize());
if (chunk_range.Contains(read_range)) {
- memcpy(dst, pos->second->GetBytes() + addr - chunk_range.GetRangeBase(),
+ memcpy(dst, pos->second->GetBytes() + (addr - chunk_range.GetRangeBase()),
dst_len);
return dst_len;
}
@@ -227,17 +224,17 @@ size_t MemoryCache::Read(addr_t addr, void *dst, size_t dst_len,
if (bytes_left > 0) {
assert((curr_addr % cache_line_byte_size) == 0);
- std::unique_ptr<DataBufferHeap> data_buffer_heap_ap(
+ std::unique_ptr<DataBufferHeap> data_buffer_heap_up(
new DataBufferHeap(cache_line_byte_size, 0));
size_t process_bytes_read = m_process.ReadMemoryFromInferior(
- curr_addr, data_buffer_heap_ap->GetBytes(),
- data_buffer_heap_ap->GetByteSize(), error);
+ curr_addr, data_buffer_heap_up->GetBytes(),
+ data_buffer_heap_up->GetByteSize(), error);
if (process_bytes_read == 0)
return dst_len - bytes_left;
if (process_bytes_read != cache_line_byte_size)
- data_buffer_heap_ap->SetByteSize(process_bytes_read);
- m_L2_cache[curr_addr] = DataBufferSP(data_buffer_heap_ap.release());
+ data_buffer_heap_up->SetByteSize(process_bytes_read);
+ m_L2_cache[curr_addr] = DataBufferSP(data_buffer_heap_up.release());
// We have read data and put it into the cache, continue through the
// loop again to get the data out of the cache...
}
@@ -358,8 +355,8 @@ AllocatedMemoryCache::AllocatePage(uint32_t byte_size, uint32_t permissions,
}
if (addr != LLDB_INVALID_ADDRESS) {
- block_sp.reset(
- new AllocatedBlock(addr, page_byte_size, permissions, chunk_size));
+ block_sp = std::make_shared<AllocatedBlock>(addr, page_byte_size,
+ permissions, chunk_size);
m_memory_map.insert(std::make_pair(permissions, block_sp));
}
return block_sp;
diff --git a/source/Target/MemoryHistory.cpp b/source/Target/MemoryHistory.cpp
index eae9314825529..37148e1e72e9a 100644
--- a/source/Target/MemoryHistory.cpp
+++ b/source/Target/MemoryHistory.cpp
@@ -1,9 +1,8 @@
//===-- MemoryHistory.cpp ---------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Target/ModuleCache.cpp b/source/Target/ModuleCache.cpp
index daf787b1fb222..444c9806f98bf 100644
--- a/source/Target/ModuleCache.cpp
+++ b/source/Target/ModuleCache.cpp
@@ -1,9 +1,8 @@
//===--------------------- ModuleCache.cpp ----------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Target/ObjCLanguageRuntime.cpp b/source/Target/ObjCLanguageRuntime.cpp
deleted file mode 100644
index 8627da938ea34..0000000000000
--- a/source/Target/ObjCLanguageRuntime.cpp
+++ /dev/null
@@ -1,384 +0,0 @@
-//===-- ObjCLanguageRuntime.cpp ---------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-#include "clang/AST/Type.h"
-
-#include "lldb/Core/MappedHash.h"
-#include "lldb/Core/Module.h"
-#include "lldb/Core/PluginManager.h"
-#include "lldb/Core/ValueObject.h"
-#include "lldb/Symbol/ClangASTContext.h"
-#include "lldb/Symbol/SymbolContext.h"
-#include "lldb/Symbol/SymbolFile.h"
-#include "lldb/Symbol/Type.h"
-#include "lldb/Symbol/TypeList.h"
-#include "lldb/Target/ObjCLanguageRuntime.h"
-#include "lldb/Target/Target.h"
-#include "lldb/Utility/Log.h"
-#include "lldb/Utility/Timer.h"
-
-#include "llvm/ADT/StringRef.h"
-#include "llvm/Support/DJB.h"
-
-using namespace lldb;
-using namespace lldb_private;
-
-//----------------------------------------------------------------------
-// Destructor
-//----------------------------------------------------------------------
-ObjCLanguageRuntime::~ObjCLanguageRuntime() {}
-
-ObjCLanguageRuntime::ObjCLanguageRuntime(Process *process)
- : LanguageRuntime(process), m_impl_cache(),
- m_has_new_literals_and_indexing(eLazyBoolCalculate),
- m_isa_to_descriptor(), m_hash_to_isa_map(), m_type_size_cache(),
- m_isa_to_descriptor_stop_id(UINT32_MAX), m_complete_class_cache(),
- m_negative_complete_class_cache() {}
-
-bool ObjCLanguageRuntime::AddClass(ObjCISA isa,
- const ClassDescriptorSP &descriptor_sp,
- const char *class_name) {
- if (isa != 0) {
- m_isa_to_descriptor[isa] = descriptor_sp;
- // class_name is assumed to be valid
- m_hash_to_isa_map.insert(std::make_pair(llvm::djbHash(class_name), isa));
- return true;
- }
- return false;
-}
-
-void ObjCLanguageRuntime::AddToMethodCache(lldb::addr_t class_addr,
- lldb::addr_t selector,
- lldb::addr_t impl_addr) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
- if (log) {
- log->Printf("Caching: class 0x%" PRIx64 " selector 0x%" PRIx64
- " implementation 0x%" PRIx64 ".",
- class_addr, selector, impl_addr);
- }
- m_impl_cache.insert(std::pair<ClassAndSel, lldb::addr_t>(
- ClassAndSel(class_addr, selector), impl_addr));
-}
-
-lldb::addr_t ObjCLanguageRuntime::LookupInMethodCache(lldb::addr_t class_addr,
- lldb::addr_t selector) {
- MsgImplMap::iterator pos, end = m_impl_cache.end();
- pos = m_impl_cache.find(ClassAndSel(class_addr, selector));
- if (pos != end)
- return (*pos).second;
- return LLDB_INVALID_ADDRESS;
-}
-
-lldb::TypeSP
-ObjCLanguageRuntime::LookupInCompleteClassCache(ConstString &name) {
- CompleteClassMap::iterator complete_class_iter =
- m_complete_class_cache.find(name);
-
- if (complete_class_iter != m_complete_class_cache.end()) {
- // Check the weak pointer to make sure the type hasn't been unloaded
- TypeSP complete_type_sp(complete_class_iter->second.lock());
-
- if (complete_type_sp)
- return complete_type_sp;
- else
- m_complete_class_cache.erase(name);
- }
-
- if (m_negative_complete_class_cache.count(name) > 0)
- return TypeSP();
-
- const ModuleList &modules = m_process->GetTarget().GetImages();
-
- SymbolContextList sc_list;
- const size_t matching_symbols =
- modules.FindSymbolsWithNameAndType(name, eSymbolTypeObjCClass, sc_list);
-
- if (matching_symbols) {
- SymbolContext sc;
-
- sc_list.GetContextAtIndex(0, sc);
-
- ModuleSP module_sp(sc.module_sp);
-
- if (!module_sp)
- return TypeSP();
-
- const bool exact_match = true;
- const uint32_t max_matches = UINT32_MAX;
- TypeList types;
-
- llvm::DenseSet<SymbolFile *> searched_symbol_files;
- const uint32_t num_types = module_sp->FindTypes(
- name, exact_match, max_matches, searched_symbol_files, types);
-
- if (num_types) {
- uint32_t i;
- for (i = 0; i < num_types; ++i) {
- TypeSP type_sp(types.GetTypeAtIndex(i));
-
- if (ClangASTContext::IsObjCObjectOrInterfaceType(
- type_sp->GetForwardCompilerType())) {
- if (type_sp->IsCompleteObjCClass()) {
- m_complete_class_cache[name] = type_sp;
- return type_sp;
- }
- }
- }
- }
- }
- m_negative_complete_class_cache.insert(name);
- return TypeSP();
-}
-
-size_t ObjCLanguageRuntime::GetByteOffsetForIvar(CompilerType &parent_qual_type,
- const char *ivar_name) {
- return LLDB_INVALID_IVAR_OFFSET;
-}
-
-bool ObjCLanguageRuntime::ClassDescriptor::IsPointerValid(
- lldb::addr_t value, uint32_t ptr_size, bool allow_NULLs, bool allow_tagged,
- bool check_version_specific) const {
- if (!value)
- return allow_NULLs;
- if ((value % 2) == 1 && allow_tagged)
- return true;
- if ((value % ptr_size) == 0)
- return (check_version_specific ? CheckPointer(value, ptr_size) : true);
- else
- return false;
-}
-
-ObjCLanguageRuntime::ObjCISA
-ObjCLanguageRuntime::GetISA(const ConstString &name) {
- ISAToDescriptorIterator pos = GetDescriptorIterator(name);
- if (pos != m_isa_to_descriptor.end())
- return pos->first;
- return 0;
-}
-
-ObjCLanguageRuntime::ISAToDescriptorIterator
-ObjCLanguageRuntime::GetDescriptorIterator(const ConstString &name) {
- ISAToDescriptorIterator end = m_isa_to_descriptor.end();
-
- if (name) {
- UpdateISAToDescriptorMap();
- if (m_hash_to_isa_map.empty()) {
- // No name hashes were provided, we need to just linearly power through
- // the names and find a match
- for (ISAToDescriptorIterator pos = m_isa_to_descriptor.begin();
- pos != end; ++pos) {
- if (pos->second->GetClassName() == name)
- return pos;
- }
- } else {
- // Name hashes were provided, so use them to efficiently lookup name to
- // isa/descriptor
- const uint32_t name_hash = llvm::djbHash(name.GetStringRef());
- std::pair<HashToISAIterator, HashToISAIterator> range =
- m_hash_to_isa_map.equal_range(name_hash);
- for (HashToISAIterator range_pos = range.first; range_pos != range.second;
- ++range_pos) {
- ISAToDescriptorIterator pos =
- m_isa_to_descriptor.find(range_pos->second);
- if (pos != m_isa_to_descriptor.end()) {
- if (pos->second->GetClassName() == name)
- return pos;
- }
- }
- }
- }
- return end;
-}
-
-std::pair<ObjCLanguageRuntime::ISAToDescriptorIterator,
- ObjCLanguageRuntime::ISAToDescriptorIterator>
-ObjCLanguageRuntime::GetDescriptorIteratorPair(bool update_if_needed) {
- if (update_if_needed)
- UpdateISAToDescriptorMapIfNeeded();
-
- return std::pair<ObjCLanguageRuntime::ISAToDescriptorIterator,
- ObjCLanguageRuntime::ISAToDescriptorIterator>(
- m_isa_to_descriptor.begin(), m_isa_to_descriptor.end());
-}
-
-ObjCLanguageRuntime::ObjCISA
-ObjCLanguageRuntime::GetParentClass(ObjCLanguageRuntime::ObjCISA isa) {
- ClassDescriptorSP objc_class_sp(GetClassDescriptorFromISA(isa));
- if (objc_class_sp) {
- ClassDescriptorSP objc_super_class_sp(objc_class_sp->GetSuperclass());
- if (objc_super_class_sp)
- return objc_super_class_sp->GetISA();
- }
- return 0;
-}
-
-ConstString
-ObjCLanguageRuntime::GetActualTypeName(ObjCLanguageRuntime::ObjCISA isa) {
- ClassDescriptorSP objc_class_sp(GetNonKVOClassDescriptor(isa));
- if (objc_class_sp)
- return objc_class_sp->GetClassName();
- return ConstString();
-}
-
-ObjCLanguageRuntime::ClassDescriptorSP
-ObjCLanguageRuntime::GetClassDescriptorFromClassName(
- const ConstString &class_name) {
- ISAToDescriptorIterator pos = GetDescriptorIterator(class_name);
- if (pos != m_isa_to_descriptor.end())
- return pos->second;
- return ClassDescriptorSP();
-}
-
-ObjCLanguageRuntime::ClassDescriptorSP
-ObjCLanguageRuntime::GetClassDescriptor(ValueObject &valobj) {
- ClassDescriptorSP objc_class_sp;
- // if we get an invalid VO (which might still happen when playing around with
- // pointers returned by the expression parser, don't consider this a valid
- // ObjC object)
- if (valobj.GetCompilerType().IsValid()) {
- addr_t isa_pointer = valobj.GetPointerValue();
- if (isa_pointer != LLDB_INVALID_ADDRESS) {
- ExecutionContext exe_ctx(valobj.GetExecutionContextRef());
-
- Process *process = exe_ctx.GetProcessPtr();
- if (process) {
- Status error;
- ObjCISA isa = process->ReadPointerFromMemory(isa_pointer, error);
- if (isa != LLDB_INVALID_ADDRESS)
- objc_class_sp = GetClassDescriptorFromISA(isa);
- }
- }
- }
- return objc_class_sp;
-}
-
-ObjCLanguageRuntime::ClassDescriptorSP
-ObjCLanguageRuntime::GetNonKVOClassDescriptor(ValueObject &valobj) {
- ObjCLanguageRuntime::ClassDescriptorSP objc_class_sp(
- GetClassDescriptor(valobj));
- if (objc_class_sp) {
- if (!objc_class_sp->IsKVO())
- return objc_class_sp;
-
- ClassDescriptorSP non_kvo_objc_class_sp(objc_class_sp->GetSuperclass());
- if (non_kvo_objc_class_sp && non_kvo_objc_class_sp->IsValid())
- return non_kvo_objc_class_sp;
- }
- return ClassDescriptorSP();
-}
-
-ObjCLanguageRuntime::ClassDescriptorSP
-ObjCLanguageRuntime::GetClassDescriptorFromISA(ObjCISA isa) {
- if (isa) {
- UpdateISAToDescriptorMap();
- ObjCLanguageRuntime::ISAToDescriptorIterator pos =
- m_isa_to_descriptor.find(isa);
- if (pos != m_isa_to_descriptor.end())
- return pos->second;
- }
- return ClassDescriptorSP();
-}
-
-ObjCLanguageRuntime::ClassDescriptorSP
-ObjCLanguageRuntime::GetNonKVOClassDescriptor(ObjCISA isa) {
- if (isa) {
- ClassDescriptorSP objc_class_sp = GetClassDescriptorFromISA(isa);
- if (objc_class_sp && objc_class_sp->IsValid()) {
- if (!objc_class_sp->IsKVO())
- return objc_class_sp;
-
- ClassDescriptorSP non_kvo_objc_class_sp(objc_class_sp->GetSuperclass());
- if (non_kvo_objc_class_sp && non_kvo_objc_class_sp->IsValid())
- return non_kvo_objc_class_sp;
- }
- }
- return ClassDescriptorSP();
-}
-
-CompilerType
-ObjCLanguageRuntime::EncodingToType::RealizeType(const char *name,
- bool for_expression) {
- if (m_scratch_ast_ctx_ap)
- return RealizeType(*m_scratch_ast_ctx_ap, name, for_expression);
- return CompilerType();
-}
-
-CompilerType ObjCLanguageRuntime::EncodingToType::RealizeType(
- ClangASTContext &ast_ctx, const char *name, bool for_expression) {
- clang::ASTContext *clang_ast = ast_ctx.getASTContext();
- if (!clang_ast)
- return CompilerType();
- return RealizeType(*clang_ast, name, for_expression);
-}
-
-ObjCLanguageRuntime::EncodingToType::~EncodingToType() {}
-
-ObjCLanguageRuntime::EncodingToTypeSP ObjCLanguageRuntime::GetEncodingToType() {
- return nullptr;
-}
-
-bool ObjCLanguageRuntime::GetTypeBitSize(const CompilerType &compiler_type,
- uint64_t &size) {
- void *opaque_ptr = compiler_type.GetOpaqueQualType();
- size = m_type_size_cache.Lookup(opaque_ptr);
- // an ObjC object will at least have an ISA, so 0 is definitely not OK
- if (size > 0)
- return true;
-
- ClassDescriptorSP class_descriptor_sp =
- GetClassDescriptorFromClassName(compiler_type.GetTypeName());
- if (!class_descriptor_sp)
- return false;
-
- int32_t max_offset = INT32_MIN;
- uint64_t sizeof_max = 0;
- bool found = false;
-
- for (size_t idx = 0; idx < class_descriptor_sp->GetNumIVars(); idx++) {
- const auto &ivar = class_descriptor_sp->GetIVarAtIndex(idx);
- int32_t cur_offset = ivar.m_offset;
- if (cur_offset > max_offset) {
- max_offset = cur_offset;
- sizeof_max = ivar.m_size;
- found = true;
- }
- }
-
- size = 8 * (max_offset + sizeof_max);
- if (found)
- m_type_size_cache.Insert(opaque_ptr, size);
-
- return found;
-}
-
-//------------------------------------------------------------------
-// Exception breakpoint Precondition class for ObjC:
-//------------------------------------------------------------------
-void ObjCLanguageRuntime::ObjCExceptionPrecondition::AddClassName(
- const char *class_name) {
- m_class_names.insert(class_name);
-}
-
-ObjCLanguageRuntime::ObjCExceptionPrecondition::ObjCExceptionPrecondition() {}
-
-bool ObjCLanguageRuntime::ObjCExceptionPrecondition::EvaluatePrecondition(
- StoppointCallbackContext &context) {
- return true;
-}
-
-void ObjCLanguageRuntime::ObjCExceptionPrecondition::GetDescription(
- Stream &stream, lldb::DescriptionLevel level) {}
-
-Status ObjCLanguageRuntime::ObjCExceptionPrecondition::ConfigurePrecondition(
- Args &args) {
- Status error;
- if (args.GetArgumentCount() > 0)
- error.SetErrorString(
- "The ObjC Exception breakpoint doesn't support extra options.");
- return error;
-}
diff --git a/source/Target/OperatingSystem.cpp b/source/Target/OperatingSystem.cpp
index 099bfd055ed12..c78c197db5be9 100644
--- a/source/Target/OperatingSystem.cpp
+++ b/source/Target/OperatingSystem.cpp
@@ -1,9 +1,8 @@
//===-- OperatingSystem.cpp -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -23,10 +22,10 @@ OperatingSystem *OperatingSystem::FindPlugin(Process *process,
PluginManager::GetOperatingSystemCreateCallbackForPluginName(
const_plugin_name);
if (create_callback) {
- std::unique_ptr<OperatingSystem> instance_ap(
+ std::unique_ptr<OperatingSystem> instance_up(
create_callback(process, true));
- if (instance_ap)
- return instance_ap.release();
+ if (instance_up)
+ return instance_up.release();
}
} else {
for (uint32_t idx = 0;
@@ -34,10 +33,10 @@ OperatingSystem *OperatingSystem::FindPlugin(Process *process,
PluginManager::GetOperatingSystemCreateCallbackAtIndex(idx)) !=
nullptr;
++idx) {
- std::unique_ptr<OperatingSystem> instance_ap(
+ std::unique_ptr<OperatingSystem> instance_up(
create_callback(process, false));
- if (instance_ap)
- return instance_ap.release();
+ if (instance_up)
+ return instance_up.release();
}
}
return nullptr;
diff --git a/source/Target/PathMappingList.cpp b/source/Target/PathMappingList.cpp
index c2249cce89b9a..58c2c43c93683 100644
--- a/source/Target/PathMappingList.cpp
+++ b/source/Target/PathMappingList.cpp
@@ -1,9 +1,8 @@
//===-- PathMappingList.cpp -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -31,15 +30,13 @@ namespace {
// with the raw path pair, which doesn't work anymore because the paths have
// been normalized when the debug info was loaded. So we need to store
// nomalized path pairs to ensure things match up.
- ConstString NormalizePath(const ConstString &path) {
+ ConstString NormalizePath(ConstString path) {
// If we use "path" to construct a FileSpec, it will normalize the path for
// us. We then grab the string and turn it back into a ConstString.
return ConstString(FileSpec(path.GetStringRef()).GetPath());
}
}
-//----------------------------------------------------------------------
// PathMappingList constructor
-//----------------------------------------------------------------------
PathMappingList::PathMappingList()
: m_pairs(), m_callback(nullptr), m_callback_baton(nullptr), m_mod_id(0) {}
@@ -63,8 +60,8 @@ const PathMappingList &PathMappingList::operator=(const PathMappingList &rhs) {
PathMappingList::~PathMappingList() = default;
-void PathMappingList::Append(const ConstString &path,
- const ConstString &replacement, bool notify) {
+void PathMappingList::Append(ConstString path,
+ ConstString replacement, bool notify) {
++m_mod_id;
m_pairs.emplace_back(pair(NormalizePath(path), NormalizePath(replacement)));
if (notify && m_callback)
@@ -82,8 +79,8 @@ void PathMappingList::Append(const PathMappingList &rhs, bool notify) {
}
}
-void PathMappingList::Insert(const ConstString &path,
- const ConstString &replacement, uint32_t index,
+void PathMappingList::Insert(ConstString path,
+ ConstString replacement, uint32_t index,
bool notify) {
++m_mod_id;
iterator insert_iter;
@@ -97,8 +94,8 @@ void PathMappingList::Insert(const ConstString &path,
m_callback(*this, m_callback_baton);
}
-bool PathMappingList::Replace(const ConstString &path,
- const ConstString &replacement, uint32_t index,
+bool PathMappingList::Replace(ConstString path,
+ ConstString replacement, uint32_t index,
bool notify) {
if (index >= m_pairs.size())
return false;
@@ -147,7 +144,7 @@ void PathMappingList::Clear(bool notify) {
m_callback(*this, m_callback_baton);
}
-bool PathMappingList::RemapPath(const ConstString &path,
+bool PathMappingList::RemapPath(ConstString path,
ConstString &new_path) const {
std::string remapped;
if (RemapPath(path.GetStringRef(), remapped)) {
@@ -202,32 +199,51 @@ bool PathMappingList::ReverseRemapPath(const FileSpec &file, FileSpec &fixed) co
bool PathMappingList::FindFile(const FileSpec &orig_spec,
FileSpec &new_spec) const {
- if (!m_pairs.empty()) {
- char orig_path[PATH_MAX];
- const size_t orig_path_len =
- orig_spec.GetPath(orig_path, sizeof(orig_path));
- if (orig_path_len > 0) {
- const_iterator pos, end = m_pairs.end();
- for (pos = m_pairs.begin(); pos != end; ++pos) {
- const size_t prefix_len = pos->first.GetLength();
-
- if (orig_path_len >= prefix_len) {
- if (::strncmp(pos->first.GetCString(), orig_path, prefix_len) == 0) {
- new_spec.SetFile(pos->second.GetCString(), FileSpec::Style::native);
- new_spec.AppendPathComponent(orig_path + prefix_len);
- if (FileSystem::Instance().Exists(new_spec))
- return true;
- }
- }
- }
+ if (m_pairs.empty())
+ return false;
+
+ std::string orig_path = orig_spec.GetPath();
+
+ if (orig_path.empty())
+ return false;
+
+ bool orig_is_relative = orig_spec.IsRelative();
+
+ for (auto entry : m_pairs) {
+ llvm::StringRef orig_ref(orig_path);
+ llvm::StringRef prefix_ref = entry.first.GetStringRef();
+ if (orig_ref.size() < prefix_ref.size())
+ continue;
+ // We consider a relative prefix or one of just "." to
+ // mean "only apply to relative paths".
+ bool prefix_is_relative = false;
+
+ if (prefix_ref == ".") {
+ prefix_is_relative = true;
+ // Remove the "." since it will have been removed from the
+ // FileSpec paths already.
+ prefix_ref = prefix_ref.drop_front();
+ } else {
+ FileSpec prefix_spec(prefix_ref, FileSpec::Style::native);
+ prefix_is_relative = prefix_spec.IsRelative();
+ }
+ if (prefix_is_relative != orig_is_relative)
+ continue;
+
+ if (orig_ref.consume_front(prefix_ref)) {
+ new_spec.SetFile(entry.second.GetCString(), FileSpec::Style::native);
+ new_spec.AppendPathComponent(orig_ref);
+ if (FileSystem::Instance().Exists(new_spec))
+ return true;
}
}
+
new_spec.Clear();
return false;
}
-bool PathMappingList::Replace(const ConstString &path,
- const ConstString &new_path, bool notify) {
+bool PathMappingList::Replace(ConstString path,
+ ConstString new_path, bool notify) {
uint32_t idx = FindIndexForPath(path);
if (idx < m_pairs.size()) {
++m_mod_id;
@@ -239,7 +255,7 @@ bool PathMappingList::Replace(const ConstString &path,
return false;
}
-bool PathMappingList::Remove(const ConstString &path, bool notify) {
+bool PathMappingList::Remove(ConstString path, bool notify) {
iterator pos = FindIteratorForPath(path);
if (pos != m_pairs.end()) {
++m_mod_id;
@@ -252,7 +268,7 @@ bool PathMappingList::Remove(const ConstString &path, bool notify) {
}
PathMappingList::const_iterator
-PathMappingList::FindIteratorForPath(const ConstString &path) const {
+PathMappingList::FindIteratorForPath(ConstString path) const {
const_iterator pos;
const_iterator begin = m_pairs.begin();
const_iterator end = m_pairs.end();
@@ -265,7 +281,7 @@ PathMappingList::FindIteratorForPath(const ConstString &path) const {
}
PathMappingList::iterator
-PathMappingList::FindIteratorForPath(const ConstString &path) {
+PathMappingList::FindIteratorForPath(ConstString path) {
iterator pos;
iterator begin = m_pairs.begin();
iterator end = m_pairs.end();
@@ -287,7 +303,7 @@ bool PathMappingList::GetPathsAtIndex(uint32_t idx, ConstString &path,
return false;
}
-uint32_t PathMappingList::FindIndexForPath(const ConstString &orig_path) const {
+uint32_t PathMappingList::FindIndexForPath(ConstString orig_path) const {
const ConstString path = NormalizePath(orig_path);
const_iterator pos;
const_iterator begin = m_pairs.begin();
diff --git a/source/Target/Platform.cpp b/source/Target/Platform.cpp
index 400b3c92b5abf..710f82eaefa9c 100644
--- a/source/Target/Platform.cpp
+++ b/source/Target/Platform.cpp
@@ -1,15 +1,15 @@
//===-- Platform.cpp --------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include <algorithm>
#include <csignal>
#include <fstream>
+#include <memory>
#include <vector>
#include "llvm/Support/FileSystem.h"
@@ -79,7 +79,7 @@ ConstString PlatformProperties::GetSettingName() {
}
PlatformProperties::PlatformProperties() {
- m_collection_sp.reset(new OptionValueProperties(GetSettingName()));
+ m_collection_sp = std::make_shared<OptionValueProperties>(GetSettingName());
m_collection_sp->Initialize(g_properties);
auto module_cache_dir = GetModuleCacheDirectory();
@@ -117,7 +117,6 @@ bool PlatformProperties::SetModuleCacheDirectory(const FileSpec &dir_spec) {
nullptr, ePropertyModuleCacheDirectory, dir_spec);
}
-//------------------------------------------------------------------
/// Get the native host platform plug-in.
///
/// There should only be one of these for each host that LLDB runs
@@ -126,7 +125,6 @@ bool PlatformProperties::SetModuleCacheDirectory(const FileSpec &dir_spec) {
///
/// This platform will be used as the default platform when launching
/// or attaching to processes unless another platform is specified.
-//------------------------------------------------------------------
PlatformSP Platform::GetHostPlatform() { return GetHostPlatformSP(); }
static std::vector<PlatformSP> &GetPlatformList() {
@@ -180,7 +178,7 @@ Platform::LocateExecutableScriptingResources(Target *target, Module &module,
}
// PlatformSP
-// Platform::FindPlugin (Process *process, const ConstString &plugin_name)
+// Platform::FindPlugin (Process *process, ConstString plugin_name)
//{
// PlatformCreateInstance create_callback = nullptr;
// if (plugin_name)
@@ -267,7 +265,7 @@ bool Platform::GetModuleSpec(const FileSpec &module_file_spec,
module_spec);
}
-PlatformSP Platform::Find(const ConstString &name) {
+PlatformSP Platform::Find(ConstString name) {
if (name) {
static ConstString g_host_platform_name("host");
if (name == g_host_platform_name)
@@ -282,7 +280,7 @@ PlatformSP Platform::Find(const ConstString &name) {
return PlatformSP();
}
-PlatformSP Platform::Create(const ConstString &name, Status &error) {
+PlatformSP Platform::Create(ConstString name, Status &error) {
PlatformCreateInstance create_callback = nullptr;
lldb::PlatformSP platform_sp;
if (name) {
@@ -377,29 +375,25 @@ ArchSpec Platform::GetAugmentedArchSpec(Platform *platform, llvm::StringRef trip
return HostInfo::GetAugmentedArchSpec(triple);
}
-//------------------------------------------------------------------
/// Default Constructor
-//------------------------------------------------------------------
Platform::Platform(bool is_host)
: m_is_host(is_host), m_os_version_set_while_connected(false),
m_system_arch_set_while_connected(false), m_sdk_sysroot(), m_sdk_build(),
m_working_dir(), m_remote_url(), m_name(), m_system_arch(), m_mutex(),
- m_uid_map(), m_gid_map(), m_max_uid_name_len(0), m_max_gid_name_len(0),
- m_supports_rsync(false), m_rsync_opts(), m_rsync_prefix(),
- m_supports_ssh(false), m_ssh_opts(), m_ignores_remote_hostname(false),
- m_trap_handlers(), m_calculated_trap_handlers(false),
+ m_max_uid_name_len(0), m_max_gid_name_len(0), m_supports_rsync(false),
+ m_rsync_opts(), m_rsync_prefix(), m_supports_ssh(false), m_ssh_opts(),
+ m_ignores_remote_hostname(false), m_trap_handlers(),
+ m_calculated_trap_handlers(false),
m_module_cache(llvm::make_unique<ModuleCache>()) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_OBJECT));
if (log)
log->Printf("%p Platform::Platform()", static_cast<void *>(this));
}
-//------------------------------------------------------------------
/// Destructor.
///
/// The destructor is virtual since this class is designed to be
/// inherited from by the plug-in instance.
-//------------------------------------------------------------------
Platform::~Platform() {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_OBJECT));
if (log)
@@ -834,34 +828,6 @@ bool Platform::SetRemoteWorkingDirectory(const FileSpec &working_dir) {
return true;
}
-const char *Platform::GetUserName(uint32_t uid) {
-#if !defined(LLDB_DISABLE_POSIX)
- const char *user_name = GetCachedUserName(uid);
- if (user_name)
- return user_name;
- if (IsHost()) {
- std::string name;
- if (HostInfo::LookupUserName(uid, name))
- return SetCachedUserName(uid, name.c_str(), name.size());
- }
-#endif
- return nullptr;
-}
-
-const char *Platform::GetGroupName(uint32_t gid) {
-#if !defined(LLDB_DISABLE_POSIX)
- const char *group_name = GetCachedGroupName(gid);
- if (group_name)
- return group_name;
- if (IsHost()) {
- std::string name;
- if (HostInfo::LookupGroupName(gid, name))
- return SetCachedGroupName(gid, name.c_str(), name.size());
- }
-#endif
- return nullptr;
-}
-
bool Platform::SetOSVersion(llvm::VersionTuple version) {
if (IsHost()) {
// We don't need anyone setting the OS version for the host platform, we
@@ -1060,11 +1026,11 @@ Status Platform::LaunchProcess(ProcessLaunchInfo &launch_info) {
uint32_t num_resumes = GetResumeCountForLaunchInfo(launch_info);
if (log) {
const FileSpec &shell = launch_info.GetShell();
- const char *shell_str = (shell) ? shell.GetPath().c_str() : "<null>";
+ std::string shell_str = (shell) ? shell.GetPath() : "<null>";
log->Printf(
"Platform::%s GetResumeCountForLaunchInfo() returned %" PRIu32
", shell is '%s'",
- __FUNCTION__, num_resumes, shell_str);
+ __FUNCTION__, num_resumes, shell_str.c_str());
}
if (!launch_info.ConvertArgumentsForLaunchingInShell(
@@ -1226,10 +1192,8 @@ Platform::GetPlatformForArchitecture(const ArchSpec &arch,
return platform_sp;
}
-//------------------------------------------------------------------
/// Lets a platform answer if it is compatible with a given
/// architecture and the target triple contained within.
-//------------------------------------------------------------------
bool Platform::IsCompatibleArchitecture(const ArchSpec &arch,
bool exact_arch_match,
ArchSpec *compatible_arch_ptr) {
@@ -1740,9 +1704,9 @@ const UnixSignalsSP &Platform::GetRemoteUnixSignals() {
return s_default_unix_signals_sp;
}
-const UnixSignalsSP &Platform::GetUnixSignals() {
+UnixSignalsSP Platform::GetUnixSignals() {
if (IsHost())
- return Host::GetUnixSignals();
+ return UnixSignals::CreateForHost();
return GetRemoteUnixSignals();
}
diff --git a/source/Target/Process.cpp b/source/Target/Process.cpp
index fb3b758912ebd..6c634dba00c7f 100644
--- a/source/Target/Process.cpp
+++ b/source/Target/Process.cpp
@@ -1,13 +1,13 @@
//===-- Process.cpp ---------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include <atomic>
+#include <memory>
#include <mutex>
#include "llvm/Support/ScopedPrinter.h"
@@ -22,7 +22,7 @@
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/StreamFile.h"
#include "lldb/Expression/DiagnosticManager.h"
-#include "lldb/Expression/IRDynamicChecks.h"
+#include "lldb/Expression/DynamicCheckerFunctions.h"
#include "lldb/Expression/UserExpression.h"
#include "lldb/Expression/UtilityFunction.h"
#include "lldb/Host/ConnectionFileDescriptor.h"
@@ -39,15 +39,14 @@
#include "lldb/Symbol/Function.h"
#include "lldb/Symbol/Symbol.h"
#include "lldb/Target/ABI.h"
-#include "lldb/Target/CPPLanguageRuntime.h"
#include "lldb/Target/DynamicLoader.h"
#include "lldb/Target/InstrumentationRuntime.h"
#include "lldb/Target/JITLoader.h"
#include "lldb/Target/JITLoaderList.h"
+#include "lldb/Target/Language.h"
#include "lldb/Target/LanguageRuntime.h"
#include "lldb/Target/MemoryHistory.h"
#include "lldb/Target/MemoryRegionInfo.h"
-#include "lldb/Target/ObjCLanguageRuntime.h"
#include "lldb/Target/OperatingSystem.h"
#include "lldb/Target/Platform.h"
#include "lldb/Target/Process.h"
@@ -64,6 +63,7 @@
#include "lldb/Utility/Event.h"
#include "lldb/Utility/Log.h"
#include "lldb/Utility/NameMatches.h"
+#include "lldb/Utility/ProcessInfo.h"
#include "lldb/Utility/SelectHelper.h"
#include "lldb/Utility/State.h"
@@ -83,7 +83,7 @@ using namespace std::chrono;
class ProcessOptionValueProperties : public OptionValueProperties {
public:
- ProcessOptionValueProperties(const ConstString &name)
+ ProcessOptionValueProperties(ConstString name)
: OptionValueProperties(name) {}
// This constructor is used when creating ProcessOptionValueProperties when
@@ -143,7 +143,11 @@ static constexpr PropertyDefinition g_properties[] = {
"stepping and variable availability may not behave as expected."},
{"stop-on-exec", OptionValue::eTypeBoolean, true, true,
nullptr, {},
- "If true, stop when a shared library is loaded or unloaded."}};
+ "If true, stop when a shared library is loaded or unloaded."},
+ {"utility-expression-timeout", OptionValue::eTypeUInt64, false, 15,
+ nullptr, {},
+ "The time in seconds to wait for LLDB-internal utility expressions."}
+};
enum {
ePropertyDisableMemCache,
@@ -155,7 +159,8 @@ enum {
ePropertyDetachKeepsStopped,
ePropertyMemCacheLineSize,
ePropertyWarningOptimization,
- ePropertyStopOnExec
+ ePropertyStopOnExec,
+ ePropertyUtilityExpressionTimeout,
};
ProcessProperties::ProcessProperties(lldb_private::Process *process)
@@ -164,15 +169,15 @@ ProcessProperties::ProcessProperties(lldb_private::Process *process)
{
if (process == nullptr) {
// Global process properties, set them up one time
- m_collection_sp.reset(
- new ProcessOptionValueProperties(ConstString("process")));
+ m_collection_sp =
+ std::make_shared<ProcessOptionValueProperties>(ConstString("process"));
m_collection_sp->Initialize(g_properties);
m_collection_sp->AppendProperty(
ConstString("thread"), ConstString("Settings specific to threads."),
true, Thread::GetGlobalProperties()->GetValueProperties());
} else {
- m_collection_sp.reset(
- new ProcessOptionValueProperties(Process::GetGlobalProperties().get()));
+ m_collection_sp = std::make_shared<ProcessOptionValueProperties>(
+ Process::GetGlobalProperties().get());
m_collection_sp->SetValueChangedCallback(
ePropertyPythonOSPluginPath,
ProcessProperties::OptionValueChangedCallback, this);
@@ -278,138 +283,11 @@ bool ProcessProperties::GetStopOnExec() const {
nullptr, idx, g_properties[idx].default_uint_value != 0);
}
-void ProcessInstanceInfo::Dump(Stream &s, Platform *platform) const {
- const char *cstr;
- if (m_pid != LLDB_INVALID_PROCESS_ID)
- s.Printf(" pid = %" PRIu64 "\n", m_pid);
-
- if (m_parent_pid != LLDB_INVALID_PROCESS_ID)
- s.Printf(" parent = %" PRIu64 "\n", m_parent_pid);
-
- if (m_executable) {
- s.Printf(" name = %s\n", m_executable.GetFilename().GetCString());
- s.PutCString(" file = ");
- m_executable.Dump(&s);
- s.EOL();
- }
- const uint32_t argc = m_arguments.GetArgumentCount();
- if (argc > 0) {
- for (uint32_t i = 0; i < argc; i++) {
- const char *arg = m_arguments.GetArgumentAtIndex(i);
- if (i < 10)
- s.Printf(" arg[%u] = %s\n", i, arg);
- else
- s.Printf("arg[%u] = %s\n", i, arg);
- }
- }
-
- s.Format("{0}", m_environment);
-
- if (m_arch.IsValid()) {
- s.Printf(" arch = ");
- m_arch.DumpTriple(s);
- s.EOL();
- }
-
- if (m_uid != UINT32_MAX) {
- cstr = platform->GetUserName(m_uid);
- s.Printf(" uid = %-5u (%s)\n", m_uid, cstr ? cstr : "");
- }
- if (m_gid != UINT32_MAX) {
- cstr = platform->GetGroupName(m_gid);
- s.Printf(" gid = %-5u (%s)\n", m_gid, cstr ? cstr : "");
- }
- if (m_euid != UINT32_MAX) {
- cstr = platform->GetUserName(m_euid);
- s.Printf(" euid = %-5u (%s)\n", m_euid, cstr ? cstr : "");
- }
- if (m_egid != UINT32_MAX) {
- cstr = platform->GetGroupName(m_egid);
- s.Printf(" egid = %-5u (%s)\n", m_egid, cstr ? cstr : "");
- }
-}
-
-void ProcessInstanceInfo::DumpTableHeader(Stream &s, Platform *platform,
- bool show_args, bool verbose) {
- const char *label;
- if (show_args || verbose)
- label = "ARGUMENTS";
- else
- label = "NAME";
-
- if (verbose) {
- s.Printf("PID PARENT USER GROUP EFF USER EFF GROUP TRIPLE "
- " %s\n",
- label);
- s.PutCString("====== ====== ========== ========== ========== ========== "
- "======================== ============================\n");
- } else {
- s.Printf("PID PARENT USER TRIPLE %s\n", label);
- s.PutCString("====== ====== ========== ======================== "
- "============================\n");
- }
-}
-
-void ProcessInstanceInfo::DumpAsTableRow(Stream &s, Platform *platform,
- bool show_args, bool verbose) const {
- if (m_pid != LLDB_INVALID_PROCESS_ID) {
- const char *cstr;
- s.Printf("%-6" PRIu64 " %-6" PRIu64 " ", m_pid, m_parent_pid);
-
- StreamString arch_strm;
- if (m_arch.IsValid())
- m_arch.DumpTriple(arch_strm);
-
- if (verbose) {
- cstr = platform->GetUserName(m_uid);
- if (cstr &&
- cstr[0]) // Watch for empty string that indicates lookup failed
- s.Printf("%-10s ", cstr);
- else
- s.Printf("%-10u ", m_uid);
-
- cstr = platform->GetGroupName(m_gid);
- if (cstr &&
- cstr[0]) // Watch for empty string that indicates lookup failed
- s.Printf("%-10s ", cstr);
- else
- s.Printf("%-10u ", m_gid);
-
- cstr = platform->GetUserName(m_euid);
- if (cstr &&
- cstr[0]) // Watch for empty string that indicates lookup failed
- s.Printf("%-10s ", cstr);
- else
- s.Printf("%-10u ", m_euid);
-
- cstr = platform->GetGroupName(m_egid);
- if (cstr &&
- cstr[0]) // Watch for empty string that indicates lookup failed
- s.Printf("%-10s ", cstr);
- else
- s.Printf("%-10u ", m_egid);
-
- s.Printf("%-24s ", arch_strm.GetData());
- } else {
- s.Printf("%-10s %-24s ", platform->GetUserName(m_euid),
- arch_strm.GetData());
- }
-
- if (verbose || show_args) {
- const uint32_t argc = m_arguments.GetArgumentCount();
- if (argc > 0) {
- for (uint32_t i = 0; i < argc; i++) {
- if (i > 0)
- s.PutChar(' ');
- s.PutCString(m_arguments.GetArgumentAtIndex(i));
- }
- }
- } else {
- s.PutCString(GetName());
- }
-
- s.EOL();
- }
+std::chrono::seconds ProcessProperties::GetUtilityExpressionTimeout() const {
+ const uint32_t idx = ePropertyUtilityExpressionTimeout;
+ uint64_t value = m_collection_sp->GetPropertyAtIndexAsUInt64(
+ nullptr, idx, g_properties[idx].default_uint_value);
+ return std::chrono::seconds(value);
}
Status ProcessLaunchCommandOptions::SetOptionValue(
@@ -581,89 +459,6 @@ llvm::ArrayRef<OptionDefinition> ProcessLaunchCommandOptions::GetDefinitions() {
return llvm::makeArrayRef(g_process_launch_options);
}
-bool ProcessInstanceInfoMatch::NameMatches(const char *process_name) const {
- if (m_name_match_type == NameMatch::Ignore || process_name == nullptr)
- return true;
- const char *match_name = m_match_info.GetName();
- if (!match_name)
- return true;
-
- return lldb_private::NameMatches(process_name, m_name_match_type, match_name);
-}
-
-bool ProcessInstanceInfoMatch::Matches(
- const ProcessInstanceInfo &proc_info) const {
- if (!NameMatches(proc_info.GetName()))
- return false;
-
- if (m_match_info.ProcessIDIsValid() &&
- m_match_info.GetProcessID() != proc_info.GetProcessID())
- return false;
-
- if (m_match_info.ParentProcessIDIsValid() &&
- m_match_info.GetParentProcessID() != proc_info.GetParentProcessID())
- return false;
-
- if (m_match_info.UserIDIsValid() &&
- m_match_info.GetUserID() != proc_info.GetUserID())
- return false;
-
- if (m_match_info.GroupIDIsValid() &&
- m_match_info.GetGroupID() != proc_info.GetGroupID())
- return false;
-
- if (m_match_info.EffectiveUserIDIsValid() &&
- m_match_info.GetEffectiveUserID() != proc_info.GetEffectiveUserID())
- return false;
-
- if (m_match_info.EffectiveGroupIDIsValid() &&
- m_match_info.GetEffectiveGroupID() != proc_info.GetEffectiveGroupID())
- return false;
-
- if (m_match_info.GetArchitecture().IsValid() &&
- !m_match_info.GetArchitecture().IsCompatibleMatch(
- proc_info.GetArchitecture()))
- return false;
- return true;
-}
-
-bool ProcessInstanceInfoMatch::MatchAllProcesses() const {
- if (m_name_match_type != NameMatch::Ignore)
- return false;
-
- if (m_match_info.ProcessIDIsValid())
- return false;
-
- if (m_match_info.ParentProcessIDIsValid())
- return false;
-
- if (m_match_info.UserIDIsValid())
- return false;
-
- if (m_match_info.GroupIDIsValid())
- return false;
-
- if (m_match_info.EffectiveUserIDIsValid())
- return false;
-
- if (m_match_info.EffectiveGroupIDIsValid())
- return false;
-
- if (m_match_info.GetArchitecture().IsValid())
- return false;
-
- if (m_match_all_users)
- return false;
-
- return true;
-}
-
-void ProcessInstanceInfoMatch::Clear() {
- m_match_info.Clear();
- m_name_match_type = NameMatch::Ignore;
- m_match_all_users = false;
-}
-
ProcessSP Process::FindPlugin(lldb::TargetSP target_sp,
llvm::StringRef plugin_name,
ListenerSP listener_sp,
@@ -734,13 +529,13 @@ Process::Process(lldb::TargetSP target_sp, ListenerSP listener_sp,
m_thread_list(this), m_extended_thread_list(this),
m_extended_thread_stop_id(0), m_queue_list(this), m_queue_list_stop_id(0),
m_notifications(), m_image_tokens(), m_listener_sp(listener_sp),
- m_breakpoint_site_list(), m_dynamic_checkers_ap(),
+ m_breakpoint_site_list(), m_dynamic_checkers_up(),
m_unix_signals_sp(unix_signals_sp), m_abi_sp(), m_process_input_reader(),
m_stdio_communication("process.stdio"), m_stdio_communication_mutex(),
m_stdin_forward(false), m_stdout_data(), m_stderr_data(),
m_profile_data_comm_mutex(), m_profile_data(), m_iohandler_sync(0),
m_memory_cache(*this), m_allocated_memory_cache(*this),
- m_should_detach(false), m_next_event_action_ap(), m_public_run_lock(),
+ m_should_detach(false), m_next_event_action_up(), m_public_run_lock(),
m_private_run_lock(), m_finalizing(false), m_finalize_called(false),
m_clear_thread_plans_on_stop(false), m_force_next_event_delivery(false),
m_last_broadcast_state(eStateInvalid), m_destroy_in_process(false),
@@ -848,12 +643,12 @@ void Process::Finalize() {
// We need to destroy the loader before the derived Process class gets
// destroyed since it is very likely that undoing the loader will require
// access to the real process.
- m_dynamic_checkers_ap.reset();
+ m_dynamic_checkers_up.reset();
m_abi_sp.reset();
- m_os_ap.reset();
- m_system_runtime_ap.reset();
- m_dyld_ap.reset();
- m_jit_loaders_ap.reset();
+ m_os_up.reset();
+ m_system_runtime_up.reset();
+ m_dyld_up.reset();
+ m_jit_loaders_up.reset();
m_thread_list_real.Destroy();
m_thread_list.Destroy();
m_extended_thread_list.Destroy();
@@ -864,9 +659,12 @@ void Process::Finalize() {
m_image_tokens.clear();
m_memory_cache.Clear();
m_allocated_memory_cache.Clear();
- m_language_runtimes.clear();
+ {
+ std::lock_guard<std::recursive_mutex> guard(m_language_runtimes_mutex);
+ m_language_runtimes.clear();
+ }
m_instrumentation_runtimes.clear();
- m_next_event_action_ap.reset();
+ m_next_event_action_up.reset();
// Clear the last natural stop ID since it has a strong reference to this
// process
m_mod_id.SetStopEventForLastNaturalStopID(EventSP());
@@ -1506,12 +1304,12 @@ void Process::UpdateThreadListIfNeeded() {
}
void Process::UpdateQueueListIfNeeded() {
- if (m_system_runtime_ap) {
+ if (m_system_runtime_up) {
if (m_queue_list.GetSize() == 0 ||
m_queue_list_stop_id != GetLastNaturalStopID()) {
const StateType state = GetPrivateState();
if (StateIsStoppedState(state, true)) {
- m_system_runtime_ap->PopulateQueueList(m_queue_list);
+ m_system_runtime_up->PopulateQueueList(m_queue_list);
m_queue_list_stop_id = GetLastNaturalStopID();
}
}
@@ -1552,16 +1350,6 @@ StateType Process::GetState() {
return m_public_state.GetValue();
}
-bool Process::StateChangedIsExternallyHijacked() {
- if (IsHijackedForEvent(eBroadcastBitStateChanged)) {
- const char *hijacking_name = GetHijackingListenerName();
- if (hijacking_name &&
- strcmp(hijacking_name, "lldb.Process.ResumeSynchronous.hijack"))
- return true;
- }
- return false;
-}
-
void Process::SetPublicState(StateType new_state, bool restarted) {
Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_STATE |
LIBLLDB_LOG_PROCESS));
@@ -1615,6 +1403,8 @@ Status Process::Resume() {
return error;
}
+static const char *g_resume_sync_name = "lldb.Process.ResumeSynchronous.hijack";
+
Status Process::ResumeSynchronous(Stream *stream) {
Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_STATE |
LIBLLDB_LOG_PROCESS));
@@ -1628,13 +1418,13 @@ Status Process::ResumeSynchronous(Stream *stream) {
}
ListenerSP listener_sp(
- Listener::MakeListener("lldb.Process.ResumeSynchronous.hijack"));
+ Listener::MakeListener(g_resume_sync_name));
HijackProcessEvents(listener_sp);
Status error = PrivateResume();
if (error.Success()) {
StateType state =
- WaitForProcessToStop(llvm::None, NULL, true, listener_sp, stream);
+ WaitForProcessToStop(llvm::None, nullptr, true, listener_sp, stream);
const bool must_be_alive =
false; // eStateExited is ok, so this must be false
if (!StateIsStoppedState(state, must_be_alive))
@@ -1652,6 +1442,26 @@ Status Process::ResumeSynchronous(Stream *stream) {
return error;
}
+bool Process::StateChangedIsExternallyHijacked() {
+ if (IsHijackedForEvent(eBroadcastBitStateChanged)) {
+ const char *hijacking_name = GetHijackingListenerName();
+ if (hijacking_name &&
+ strcmp(hijacking_name, g_resume_sync_name))
+ return true;
+ }
+ return false;
+}
+
+bool Process::StateChangedIsHijackedForSynchronousResume() {
+ if (IsHijackedForEvent(eBroadcastBitStateChanged)) {
+ const char *hijacking_name = GetHijackingListenerName();
+ if (hijacking_name &&
+ strcmp(hijacking_name, g_resume_sync_name) == 0)
+ return true;
+ }
+ return false;
+}
+
StateType Process::GetPrivateState() { return m_private_state.GetValue(); }
void Process::SetPrivateState(StateType new_state) {
@@ -1736,38 +1546,54 @@ const lldb::ABISP &Process::GetABI() {
return m_abi_sp;
}
+std::vector<LanguageRuntime *>
+Process::GetLanguageRuntimes(bool retry_if_null) {
+ std::vector<LanguageRuntime *> language_runtimes;
+
+ if (m_finalizing)
+ return language_runtimes;
+
+ std::lock_guard<std::recursive_mutex> guard(m_language_runtimes_mutex);
+ // Before we pass off a copy of the language runtimes, we must make sure that
+ // our collection is properly populated. It's possible that some of the
+ // language runtimes were not loaded yet, either because nobody requested it
+ // yet or the proper condition for loading wasn't yet met (e.g. libc++.so
+ // hadn't been loaded).
+ for (const lldb::LanguageType lang_type : Language::GetSupportedLanguages()) {
+ if (LanguageRuntime *runtime = GetLanguageRuntime(lang_type, retry_if_null))
+ language_runtimes.emplace_back(runtime);
+ }
+
+ return language_runtimes;
+}
+
LanguageRuntime *Process::GetLanguageRuntime(lldb::LanguageType language,
bool retry_if_null) {
if (m_finalizing)
return nullptr;
+ LanguageRuntime *runtime = nullptr;
+
+ std::lock_guard<std::recursive_mutex> guard(m_language_runtimes_mutex);
LanguageRuntimeCollection::iterator pos;
pos = m_language_runtimes.find(language);
- if (pos == m_language_runtimes.end() || (retry_if_null && !(*pos).second)) {
+ if (pos == m_language_runtimes.end() || (retry_if_null && !pos->second)) {
lldb::LanguageRuntimeSP runtime_sp(
LanguageRuntime::FindPlugin(this, language));
m_language_runtimes[language] = runtime_sp;
- return runtime_sp.get();
+ runtime = runtime_sp.get();
} else
- return (*pos).second.get();
-}
+ runtime = pos->second.get();
-CPPLanguageRuntime *Process::GetCPPLanguageRuntime(bool retry_if_null) {
- LanguageRuntime *runtime =
- GetLanguageRuntime(eLanguageTypeC_plus_plus, retry_if_null);
- if (runtime != nullptr &&
- runtime->GetLanguageType() == eLanguageTypeC_plus_plus)
- return static_cast<CPPLanguageRuntime *>(runtime);
- return nullptr;
-}
+ if (runtime)
+ // It's possible that a language runtime can support multiple LanguageTypes,
+ // for example, CPPLanguageRuntime will support eLanguageTypeC_plus_plus,
+ // eLanguageTypeC_plus_plus_03, etc. Because of this, we should get the
+ // primary language type and make sure that our runtime supports it.
+ assert(runtime->GetLanguageType() == Language::GetPrimaryLanguage(language));
-ObjCLanguageRuntime *Process::GetObjCLanguageRuntime(bool retry_if_null) {
- LanguageRuntime *runtime =
- GetLanguageRuntime(eLanguageTypeObjC, retry_if_null);
- if (runtime != nullptr && runtime->GetLanguageType() == eLanguageTypeObjC)
- return static_cast<ObjCLanguageRuntime *>(runtime);
- return nullptr;
+ return runtime;
}
bool Process::IsPossibleDynamicValue(ValueObject &in_value) {
@@ -1783,16 +1609,16 @@ bool Process::IsPossibleDynamicValue(ValueObject &in_value) {
return runtime ? runtime->CouldHaveDynamicValue(in_value) : false;
}
- LanguageRuntime *cpp_runtime = GetLanguageRuntime(eLanguageTypeC_plus_plus);
- if (cpp_runtime && cpp_runtime->CouldHaveDynamicValue(in_value))
- return true;
+ for (LanguageRuntime *runtime : GetLanguageRuntimes()) {
+ if (runtime->CouldHaveDynamicValue(in_value))
+ return true;
+ }
- LanguageRuntime *objc_runtime = GetLanguageRuntime(eLanguageTypeObjC);
- return objc_runtime ? objc_runtime->CouldHaveDynamicValue(in_value) : false;
+ return false;
}
void Process::SetDynamicCheckers(DynamicCheckerFunctions *dynamic_checkers) {
- m_dynamic_checkers_ap.reset(dynamic_checkers);
+ m_dynamic_checkers_up.reset(dynamic_checkers);
}
BreakpointSiteList &Process::GetBreakpointSiteList() {
@@ -2413,67 +2239,64 @@ size_t Process::WriteMemory(addr_t addr, const void *buf, size_t size,
// may have placed in our tasks memory.
BreakpointSiteList bp_sites_in_range;
+ if (!m_breakpoint_site_list.FindInRange(addr, addr + size, bp_sites_in_range))
+ return WriteMemoryPrivate(addr, buf, size, error);
- if (m_breakpoint_site_list.FindInRange(addr, addr + size,
- bp_sites_in_range)) {
- // No breakpoint sites overlap
- if (bp_sites_in_range.IsEmpty())
- return WriteMemoryPrivate(addr, buf, size, error);
- else {
- const uint8_t *ubuf = (const uint8_t *)buf;
- uint64_t bytes_written = 0;
+ // No breakpoint sites overlap
+ if (bp_sites_in_range.IsEmpty())
+ return WriteMemoryPrivate(addr, buf, size, error);
- bp_sites_in_range.ForEach([this, addr, size, &bytes_written, &ubuf,
- &error](BreakpointSite *bp) -> void {
+ const uint8_t *ubuf = (const uint8_t *)buf;
+ uint64_t bytes_written = 0;
- if (error.Success()) {
- addr_t intersect_addr;
- size_t intersect_size;
- size_t opcode_offset;
- const bool intersects = bp->IntersectsRange(
- addr, size, &intersect_addr, &intersect_size, &opcode_offset);
- UNUSED_IF_ASSERT_DISABLED(intersects);
- assert(intersects);
- assert(addr <= intersect_addr && intersect_addr < addr + size);
- assert(addr < intersect_addr + intersect_size &&
- intersect_addr + intersect_size <= addr + size);
- assert(opcode_offset + intersect_size <= bp->GetByteSize());
-
- // Check for bytes before this breakpoint
- const addr_t curr_addr = addr + bytes_written;
- if (intersect_addr > curr_addr) {
- // There are some bytes before this breakpoint that we need to just
- // write to memory
- size_t curr_size = intersect_addr - curr_addr;
- size_t curr_bytes_written = WriteMemoryPrivate(
- curr_addr, ubuf + bytes_written, curr_size, error);
- bytes_written += curr_bytes_written;
- if (curr_bytes_written != curr_size) {
- // We weren't able to write all of the requested bytes, we are
- // done looping and will return the number of bytes that we have
- // written so far.
- if (error.Success())
- error.SetErrorToGenericError();
- }
- }
- // Now write any bytes that would cover up any software breakpoints
- // directly into the breakpoint opcode buffer
- ::memcpy(bp->GetSavedOpcodeBytes() + opcode_offset,
- ubuf + bytes_written, intersect_size);
- bytes_written += intersect_size;
- }
- });
+ bp_sites_in_range.ForEach([this, addr, size, &bytes_written, &ubuf,
+ &error](BreakpointSite *bp) -> void {
+ if (error.Fail())
+ return;
- if (bytes_written < size)
- WriteMemoryPrivate(addr + bytes_written, ubuf + bytes_written,
- size - bytes_written, error);
+ addr_t intersect_addr;
+ size_t intersect_size;
+ size_t opcode_offset;
+ const bool intersects = bp->IntersectsRange(
+ addr, size, &intersect_addr, &intersect_size, &opcode_offset);
+ UNUSED_IF_ASSERT_DISABLED(intersects);
+ assert(intersects);
+ assert(addr <= intersect_addr && intersect_addr < addr + size);
+ assert(addr < intersect_addr + intersect_size &&
+ intersect_addr + intersect_size <= addr + size);
+ assert(opcode_offset + intersect_size <= bp->GetByteSize());
+
+ // Check for bytes before this breakpoint
+ const addr_t curr_addr = addr + bytes_written;
+ if (intersect_addr > curr_addr) {
+ // There are some bytes before this breakpoint that we need to just
+ // write to memory
+ size_t curr_size = intersect_addr - curr_addr;
+ size_t curr_bytes_written =
+ WriteMemoryPrivate(curr_addr, ubuf + bytes_written, curr_size, error);
+ bytes_written += curr_bytes_written;
+ if (curr_bytes_written != curr_size) {
+ // We weren't able to write all of the requested bytes, we are
+ // done looping and will return the number of bytes that we have
+ // written so far.
+ if (error.Success())
+ error.SetErrorToGenericError();
+ }
}
- } else {
- return WriteMemoryPrivate(addr, buf, size, error);
- }
+ // Now write any bytes that would cover up any software breakpoints
+ // directly into the breakpoint opcode buffer
+ ::memcpy(bp->GetSavedOpcodeBytes() + opcode_offset, ubuf + bytes_written,
+ intersect_size);
+ bytes_written += intersect_size;
+ });
// Write any remaining bytes after the last breakpoint if we have any left
- return 0; // bytes_written;
+ if (bytes_written < size)
+ bytes_written +=
+ WriteMemoryPrivate(addr + bytes_written, ubuf + bytes_written,
+ size - bytes_written, error);
+
+ return bytes_written;
}
size_t Process::WriteScalarToMemory(addr_t addr, const Scalar &scalar,
@@ -2708,7 +2531,7 @@ Process::WaitForProcessStopPrivate(EventSP &event_sp,
void Process::LoadOperatingSystemPlugin(bool flush) {
if (flush)
m_thread_list.Clear();
- m_os_ap.reset(OperatingSystem::FindPlugin(this, nullptr));
+ m_os_up.reset(OperatingSystem::FindPlugin(this, nullptr));
if (flush)
Flush();
}
@@ -2716,115 +2539,119 @@ void Process::LoadOperatingSystemPlugin(bool flush) {
Status Process::Launch(ProcessLaunchInfo &launch_info) {
Status error;
m_abi_sp.reset();
- m_dyld_ap.reset();
- m_jit_loaders_ap.reset();
- m_system_runtime_ap.reset();
- m_os_ap.reset();
+ m_dyld_up.reset();
+ m_jit_loaders_up.reset();
+ m_system_runtime_up.reset();
+ m_os_up.reset();
m_process_input_reader.reset();
Module *exe_module = GetTarget().GetExecutableModulePointer();
- if (exe_module) {
- char local_exec_file_path[PATH_MAX];
- char platform_exec_file_path[PATH_MAX];
- exe_module->GetFileSpec().GetPath(local_exec_file_path,
- sizeof(local_exec_file_path));
- exe_module->GetPlatformFileSpec().GetPath(platform_exec_file_path,
- sizeof(platform_exec_file_path));
- if (FileSystem::Instance().Exists(exe_module->GetFileSpec())) {
- // Install anything that might need to be installed prior to launching.
- // For host systems, this will do nothing, but if we are connected to a
- // remote platform it will install any needed binaries
- error = GetTarget().Install(&launch_info);
- if (error.Fail())
- return error;
+ if (!exe_module) {
+ error.SetErrorString("executable module does not exist");
+ return error;
+ }
- if (PrivateStateThreadIsValid())
- PausePrivateStateThread();
+ char local_exec_file_path[PATH_MAX];
+ char platform_exec_file_path[PATH_MAX];
+ exe_module->GetFileSpec().GetPath(local_exec_file_path,
+ sizeof(local_exec_file_path));
+ exe_module->GetPlatformFileSpec().GetPath(platform_exec_file_path,
+ sizeof(platform_exec_file_path));
+ if (FileSystem::Instance().Exists(exe_module->GetFileSpec())) {
+ // Install anything that might need to be installed prior to launching.
+ // For host systems, this will do nothing, but if we are connected to a
+ // remote platform it will install any needed binaries
+ error = GetTarget().Install(&launch_info);
+ if (error.Fail())
+ return error;
- error = WillLaunch(exe_module);
- if (error.Success()) {
- const bool restarted = false;
- SetPublicState(eStateLaunching, restarted);
- m_should_detach = false;
+ if (PrivateStateThreadIsValid())
+ PausePrivateStateThread();
- if (m_public_run_lock.TrySetRunning()) {
- // Now launch using these arguments.
- error = DoLaunch(exe_module, launch_info);
- } else {
- // This shouldn't happen
- error.SetErrorString("failed to acquire process run lock");
+ error = WillLaunch(exe_module);
+ if (error.Success()) {
+ const bool restarted = false;
+ SetPublicState(eStateLaunching, restarted);
+ m_should_detach = false;
+
+ if (m_public_run_lock.TrySetRunning()) {
+ // Now launch using these arguments.
+ error = DoLaunch(exe_module, launch_info);
+ } else {
+ // This shouldn't happen
+ error.SetErrorString("failed to acquire process run lock");
+ }
+
+ if (error.Fail()) {
+ if (GetID() != LLDB_INVALID_PROCESS_ID) {
+ SetID(LLDB_INVALID_PROCESS_ID);
+ const char *error_string = error.AsCString();
+ if (error_string == nullptr)
+ error_string = "launch failed";
+ SetExitStatus(-1, error_string);
}
+ } else {
+ EventSP event_sp;
+
+ // Now wait for the process to launch and return control to us, and then
+ // call DidLaunch:
+ StateType state = WaitForProcessStopPrivate(event_sp, seconds(10));
+
+ if (state == eStateInvalid || !event_sp) {
+ // We were able to launch the process, but we failed to catch the
+ // initial stop.
+ error.SetErrorString("failed to catch stop after launch");
+ SetExitStatus(0, "failed to catch stop after launch");
+ Destroy(false);
+ } else if (state == eStateStopped || state == eStateCrashed) {
+ DidLaunch();
+
+ DynamicLoader *dyld = GetDynamicLoader();
+ if (dyld)
+ dyld->DidLaunch();
+
+ GetJITLoaders().DidLaunch();
+
+ SystemRuntime *system_runtime = GetSystemRuntime();
+ if (system_runtime)
+ system_runtime->DidLaunch();
+
+ if (!m_os_up)
+ LoadOperatingSystemPlugin(false);
+
+ // We successfully launched the process and stopped, now it the
+ // right time to set up signal filters before resuming.
+ UpdateAutomaticSignalFiltering();
+
+ // Note, the stop event was consumed above, but not handled. This
+ // was done to give DidLaunch a chance to run. The target is either
+ // stopped or crashed. Directly set the state. This is done to
+ // prevent a stop message with a bunch of spurious output on thread
+ // status, as well as not pop a ProcessIOHandler.
+ SetPublicState(state, false);
+
+ if (PrivateStateThreadIsValid())
+ ResumePrivateStateThread();
+ else
+ StartPrivateStateThread();
- if (error.Fail()) {
- if (GetID() != LLDB_INVALID_PROCESS_ID) {
- SetID(LLDB_INVALID_PROCESS_ID);
- const char *error_string = error.AsCString();
- if (error_string == nullptr)
- error_string = "launch failed";
- SetExitStatus(-1, error_string);
- }
- } else {
- EventSP event_sp;
-
- // Now wait for the process to launch and return control to us, and then call
- // DidLaunch:
- StateType state = WaitForProcessStopPrivate(event_sp, seconds(10));
-
- if (state == eStateInvalid || !event_sp) {
- // We were able to launch the process, but we failed to catch the
- // initial stop.
- error.SetErrorString("failed to catch stop after launch");
- SetExitStatus(0, "failed to catch stop after launch");
- Destroy(false);
- } else if (state == eStateStopped || state == eStateCrashed) {
- DidLaunch();
-
- DynamicLoader *dyld = GetDynamicLoader();
- if (dyld)
- dyld->DidLaunch();
-
- GetJITLoaders().DidLaunch();
-
- SystemRuntime *system_runtime = GetSystemRuntime();
- if (system_runtime)
- system_runtime->DidLaunch();
-
- if (!m_os_ap)
- LoadOperatingSystemPlugin(false);
-
- // We successfully launched the process and stopped, now it the
- // right time to set up signal filters before resuming.
- UpdateAutomaticSignalFiltering();
-
- // Note, the stop event was consumed above, but not handled. This
- // was done to give DidLaunch a chance to run. The target is either
- // stopped or crashed. Directly set the state. This is done to
- // prevent a stop message with a bunch of spurious output on thread
- // status, as well as not pop a ProcessIOHandler.
- SetPublicState(state, false);
-
- if (PrivateStateThreadIsValid())
- ResumePrivateStateThread();
- else
- StartPrivateStateThread();
-
- // Target was stopped at entry as was intended. Need to notify the
- // listeners about it.
- if (state == eStateStopped &&
- launch_info.GetFlags().Test(eLaunchFlagStopAtEntry))
- HandlePrivateEvent(event_sp);
- } else if (state == eStateExited) {
- // We exited while trying to launch somehow. Don't call DidLaunch
- // as that's not likely to work, and return an invalid pid.
+ // Target was stopped at entry as was intended. Need to notify the
+ // listeners about it.
+ if (state == eStateStopped &&
+ launch_info.GetFlags().Test(eLaunchFlagStopAtEntry))
HandlePrivateEvent(event_sp);
- }
+ } else if (state == eStateExited) {
+ // We exited while trying to launch somehow. Don't call DidLaunch
+ // as that's not likely to work, and return an invalid pid.
+ HandlePrivateEvent(event_sp);
}
}
- } else {
- error.SetErrorStringWithFormat("file doesn't exist: '%s'",
- local_exec_file_path);
}
+ } else {
+ error.SetErrorStringWithFormat("file doesn't exist: '%s'",
+ local_exec_file_path);
}
+
return error;
}
@@ -2850,7 +2677,7 @@ Status Process::LoadCore() {
if (system_runtime)
system_runtime->DidAttach();
- if (!m_os_ap)
+ if (!m_os_up)
LoadOperatingSystemPlugin(false);
// We successfully loaded a core file, now pretend we stopped so we can
@@ -2860,7 +2687,7 @@ Status Process::LoadCore() {
// Wait for a stopped event since we just posted one above...
lldb::EventSP event_sp;
StateType state =
- WaitForProcessToStop(seconds(10), &event_sp, true, listener_sp);
+ WaitForProcessToStop(llvm::None, &event_sp, true, listener_sp);
if (!StateIsStoppedState(state, false)) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
@@ -2876,25 +2703,25 @@ Status Process::LoadCore() {
}
DynamicLoader *Process::GetDynamicLoader() {
- if (!m_dyld_ap)
- m_dyld_ap.reset(DynamicLoader::FindPlugin(this, nullptr));
- return m_dyld_ap.get();
+ if (!m_dyld_up)
+ m_dyld_up.reset(DynamicLoader::FindPlugin(this, nullptr));
+ return m_dyld_up.get();
}
-const lldb::DataBufferSP Process::GetAuxvData() { return DataBufferSP(); }
+DataExtractor Process::GetAuxvData() { return DataExtractor(); }
JITLoaderList &Process::GetJITLoaders() {
- if (!m_jit_loaders_ap) {
- m_jit_loaders_ap.reset(new JITLoaderList());
- JITLoader::LoadPlugins(this, *m_jit_loaders_ap);
+ if (!m_jit_loaders_up) {
+ m_jit_loaders_up.reset(new JITLoaderList());
+ JITLoader::LoadPlugins(this, *m_jit_loaders_up);
}
- return *m_jit_loaders_ap;
+ return *m_jit_loaders_up;
}
SystemRuntime *Process::GetSystemRuntime() {
- if (!m_system_runtime_ap)
- m_system_runtime_ap.reset(SystemRuntime::FindPlugin(this));
- return m_system_runtime_ap.get();
+ if (!m_system_runtime_up)
+ m_system_runtime_up.reset(SystemRuntime::FindPlugin(this));
+ return m_system_runtime_up.get();
}
Process::AttachCompletionHandler::AttachCompletionHandler(Process *process,
@@ -2984,10 +2811,10 @@ ListenerSP ProcessAttachInfo::GetListenerForProcess(Debugger &debugger) {
Status Process::Attach(ProcessAttachInfo &attach_info) {
m_abi_sp.reset();
m_process_input_reader.reset();
- m_dyld_ap.reset();
- m_jit_loaders_ap.reset();
- m_system_runtime_ap.reset();
- m_os_ap.reset();
+ m_dyld_up.reset();
+ m_jit_loaders_up.reset();
+ m_system_runtime_up.reset();
+ m_os_up.reset();
lldb::pid_t attach_pid = attach_info.GetProcessID();
Status error;
@@ -3045,11 +2872,10 @@ Status Process::Attach(ProcessAttachInfo &attach_info) {
process_name, sizeof(process_name));
if (num_matches > 1) {
StreamString s;
- ProcessInstanceInfo::DumpTableHeader(s, platform_sp.get(), true,
- false);
+ ProcessInstanceInfo::DumpTableHeader(s, true, false);
for (size_t i = 0; i < num_matches; i++) {
process_infos.GetProcessInfoAtIndex(i).DumpAsTableRow(
- s, platform_sp.get(), true, false);
+ s, platform_sp->GetUserIDResolver(), true, false);
}
error.SetErrorStringWithFormat(
"more than one process named %s:\n%s", process_name,
@@ -3193,8 +3019,16 @@ void Process::CompleteAttach() {
}
}
- if (!m_os_ap)
+ if (!m_os_up) {
LoadOperatingSystemPlugin(false);
+ if (m_os_up) {
+ // Somebody might have gotten threads before now, but we need to force the
+ // update after we've loaded the OperatingSystem plugin or it won't get a
+ // chance to process the threads.
+ m_thread_list.Clear();
+ UpdateThreadListIfNeeded();
+ }
+ }
// Figure out which one is the executable, and set that in our target:
const ModuleList &target_modules = GetTarget().GetImages();
std::lock_guard<std::recursive_mutex> guard(target_modules.GetMutex());
@@ -3754,14 +3588,20 @@ bool Process::StartPrivateStateThread(bool is_secondary_thread) {
// Create the private state thread, and start it running.
PrivateStateThreadArgs *args_ptr =
new PrivateStateThreadArgs(this, is_secondary_thread);
- m_private_state_thread =
+ llvm::Expected<HostThread> private_state_thread =
ThreadLauncher::LaunchThread(thread_name, Process::PrivateStateThread,
- (void *)args_ptr, nullptr, 8 * 1024 * 1024);
- if (m_private_state_thread.IsJoinable()) {
- ResumePrivateStateThread();
- return true;
- } else
+ (void *)args_ptr, 8 * 1024 * 1024);
+ if (!private_state_thread) {
+ LLDB_LOG(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST),
+ "failed to launch host thread: {}",
+ llvm::toString(private_state_thread.takeError()));
return false;
+ }
+
+ assert(private_state_thread->IsJoinable());
+ m_private_state_thread = *private_state_thread;
+ ResumePrivateStateThread();
+ return true;
}
void Process::PausePrivateStateThread() {
@@ -3810,10 +3650,10 @@ void Process::ControlPrivateStateThread(uint32_t signal) {
bool receipt_received = false;
if (PrivateStateThreadIsValid()) {
while (!receipt_received) {
- // Check for a receipt for 2 seconds and then check if the private
+ // Check for a receipt for n seconds and then check if the private
// state thread is still around.
receipt_received =
- event_receipt_sp->WaitForEventReceived(std::chrono::seconds(2));
+ event_receipt_sp->WaitForEventReceived(GetUtilityExpressionTimeout());
if (!receipt_received) {
// Check if the private state thread is still around. If it isn't
// then we are done waiting
@@ -3824,7 +3664,7 @@ void Process::ControlPrivateStateThread(uint32_t signal) {
}
if (signal == eBroadcastInternalStateControlStop) {
- thread_result_t result = NULL;
+ thread_result_t result = {};
m_private_state_thread.Join(&result);
m_private_state_thread.Reset();
}
@@ -3851,9 +3691,9 @@ void Process::HandlePrivateEvent(EventSP &event_sp) {
Process::ProcessEventData::GetStateFromEvent(event_sp.get());
// First check to see if anybody wants a shot at this event:
- if (m_next_event_action_ap) {
+ if (m_next_event_action_up) {
NextEventAction::EventActionResult action_result =
- m_next_event_action_ap->PerformAction(event_sp);
+ m_next_event_action_up->PerformAction(event_sp);
if (log)
log->Printf("Ran next event action, result was %d.", action_result);
@@ -3871,7 +3711,7 @@ void Process::HandlePrivateEvent(EventSP &event_sp) {
// to exit so the next event will kill us.
if (new_state != eStateExited) {
// FIXME: should cons up an exited event, and discard this one.
- SetExitStatus(0, m_next_event_action_ap->GetExitString());
+ SetExitStatus(0, m_next_event_action_up->GetExitString());
SetNextEventAction(nullptr);
return;
}
@@ -4099,12 +3939,10 @@ thread_result_t Process::RunPrivateStateThread(bool is_secondary_thread) {
// it was doing yet, so don't try to change it on the way out.
if (!is_secondary_thread)
m_public_run_lock.SetStopped();
- return NULL;
+ return {};
}
-//------------------------------------------------------------------
// Process Event Data
-//------------------------------------------------------------------
Process::ProcessEventData::ProcessEventData()
: EventData(), m_process_wp(), m_state(eStateInvalid), m_restarted(false),
@@ -4120,12 +3958,12 @@ Process::ProcessEventData::ProcessEventData(const ProcessSP &process_sp,
Process::ProcessEventData::~ProcessEventData() = default;
-const ConstString &Process::ProcessEventData::GetFlavorString() {
+ConstString Process::ProcessEventData::GetFlavorString() {
static ConstString g_flavor("Process::ProcessEventData");
return g_flavor;
}
-const ConstString &Process::ProcessEventData::GetFlavor() const {
+ConstString Process::ProcessEventData::GetFlavor() const {
return ProcessEventData::GetFlavorString();
}
@@ -4260,15 +4098,24 @@ void Process::ProcessEventData::DoOnRemoval(Event *event_ptr) {
// public resume.
process_sp->PrivateResume();
} else {
- // If we didn't restart, run the Stop Hooks here: They might also
- // restart the target, so watch for that.
- process_sp->GetTarget().RunStopHooks();
- if (process_sp->GetPrivateState() == eStateRunning)
- SetRestarted(true);
+ bool hijacked =
+ process_sp->IsHijackedForEvent(eBroadcastBitStateChanged) &&
+ !process_sp->StateChangedIsHijackedForSynchronousResume();
+
+ if (!hijacked) {
+ // If we didn't restart, run the Stop Hooks here.
+ // Don't do that if state changed events aren't hooked up to the
+ // public (or SyncResume) broadcasters. StopHooks are just for
+ // real public stops. They might also restart the target,
+ // so watch for that.
+ process_sp->GetTarget().RunStopHooks();
+ if (process_sp->GetPrivateState() == eStateRunning)
+ SetRestarted(true);
}
}
}
}
+}
void Process::ProcessEventData::Dump(Stream *s) const {
ProcessSP process_sp(m_process_wp.lock());
@@ -4439,7 +4286,7 @@ void Process::BroadcastStructuredData(const StructuredData::ObjectSP &object_sp,
}
StructuredDataPluginSP
-Process::GetStructuredDataPlugin(const ConstString &type_name) const {
+Process::GetStructuredDataPlugin(ConstString type_name) const {
auto find_it = m_structured_data_plugin_map.find(type_name);
if (find_it != m_structured_data_plugin_map.end())
return find_it->second;
@@ -4471,9 +4318,7 @@ size_t Process::GetAsyncProfileData(char *buf, size_t buf_size, Status &error) {
return bytes_available;
}
-//------------------------------------------------------------------
// Process STDIO
-//------------------------------------------------------------------
size_t Process::GetSTDOUT(char *buf, size_t buf_size, Status &error) {
std::lock_guard<std::recursive_mutex> guard(m_stdio_communication_mutex);
@@ -4658,11 +4503,11 @@ protected:
void Process::SetSTDIOFileDescriptor(int fd) {
// First set up the Read Thread for reading/handling process I/O
- std::unique_ptr<ConnectionFileDescriptor> conn_ap(
+ std::unique_ptr<ConnectionFileDescriptor> conn_up(
new ConnectionFileDescriptor(fd, true));
- if (conn_ap) {
- m_stdio_communication.SetConnection(conn_ap.release());
+ if (conn_up) {
+ m_stdio_communication.SetConnection(conn_up.release());
if (m_stdio_communication.IsConnected()) {
m_stdio_communication.SetReadThreadBytesReceivedCallback(
STDIOReadThreadBytesReceived, this);
@@ -4671,7 +4516,8 @@ void Process::SetSTDIOFileDescriptor(int fd) {
// Now read thread is set up, set up input reader.
if (!m_process_input_reader)
- m_process_input_reader.reset(new IOHandlerProcessSTDIO(this, fd));
+ m_process_input_reader =
+ std::make_shared<IOHandlerProcessSTDIO>(this, fd);
}
}
}
@@ -5096,7 +4942,7 @@ Process::RunThreadPlan(ExecutionContext &exe_ctx,
}
got_event =
- listener_sp->GetEvent(event_sp, std::chrono::milliseconds(500));
+ listener_sp->GetEvent(event_sp, GetUtilityExpressionTimeout());
if (!got_event) {
if (log)
log->Printf("Process::RunThreadPlan(): didn't get any event after "
@@ -5327,7 +5173,7 @@ Process::RunThreadPlan(ExecutionContext &exe_ctx,
log->PutCString("Process::RunThreadPlan(): Halt succeeded.");
got_event =
- listener_sp->GetEvent(event_sp, std::chrono::milliseconds(500));
+ listener_sp->GetEvent(event_sp, GetUtilityExpressionTimeout());
if (got_event) {
stop_state =
@@ -5530,7 +5376,7 @@ Process::RunThreadPlan(ExecutionContext &exe_ctx,
event_explanation = ts.GetData();
}
- } while (0);
+ } while (false);
if (event_explanation)
log->Printf("Process::RunThreadPlan(): execution interrupted: %s %s",
@@ -5782,15 +5628,18 @@ void Process::DidExec() {
Target &target = GetTarget();
target.CleanupProcess();
target.ClearModules(false);
- m_dynamic_checkers_ap.reset();
+ m_dynamic_checkers_up.reset();
m_abi_sp.reset();
- m_system_runtime_ap.reset();
- m_os_ap.reset();
- m_dyld_ap.reset();
- m_jit_loaders_ap.reset();
+ m_system_runtime_up.reset();
+ m_os_up.reset();
+ m_dyld_up.reset();
+ m_jit_loaders_up.reset();
m_image_tokens.clear();
m_allocated_memory_cache.Clear();
- m_language_runtimes.clear();
+ {
+ std::lock_guard<std::recursive_mutex> guard(m_language_runtimes_mutex);
+ m_language_runtimes.clear();
+ }
m_instrumentation_runtimes.clear();
m_thread_list.DiscardThreadPlans();
m_memory_cache.Clear(true);
@@ -5859,19 +5708,22 @@ void Process::ModulesDidLoad(ModuleList &module_list) {
// Iterate over a copy of this language runtime list in case the language
// runtime ModulesDidLoad somehow causes the language runtime to be
// unloaded.
- LanguageRuntimeCollection language_runtimes(m_language_runtimes);
- for (const auto &pair : language_runtimes) {
- // We must check language_runtime_sp to make sure it is not nullptr as we
- // might cache the fact that we didn't have a language runtime for a
- // language.
- LanguageRuntimeSP language_runtime_sp = pair.second;
- if (language_runtime_sp)
- language_runtime_sp->ModulesDidLoad(module_list);
+ {
+ std::lock_guard<std::recursive_mutex> guard(m_language_runtimes_mutex);
+ LanguageRuntimeCollection language_runtimes(m_language_runtimes);
+ for (const auto &pair : language_runtimes) {
+ // We must check language_runtime_sp to make sure it is not nullptr as we
+ // might cache the fact that we didn't have a language runtime for a
+ // language.
+ LanguageRuntimeSP language_runtime_sp = pair.second;
+ if (language_runtime_sp)
+ language_runtime_sp->ModulesDidLoad(module_list);
+ }
}
// If we don't have an operating system plug-in, try to load one since
// loading shared libraries might cause a new one to try and load
- if (!m_os_ap)
+ if (!m_os_up)
LoadOperatingSystemPlugin(false);
// Give structured-data plugins a chance to see the modified modules.
@@ -5945,7 +5797,8 @@ ThreadCollectionSP Process::GetHistoryThreads(lldb::addr_t addr) {
return threads;
}
- threads.reset(new ThreadCollection(memory_history->GetHistoryThreads(addr)));
+ threads = std::make_shared<ThreadCollection>(
+ memory_history->GetHistoryThreads(addr));
return threads;
}
@@ -6017,7 +5870,8 @@ Process::AdvanceAddressToNextBranchInstruction(Address default_stop_addr,
}
uint32_t branch_index =
- insn_list->GetIndexOfNextBranchInstruction(insn_offset, target);
+ insn_list->GetIndexOfNextBranchInstruction(insn_offset, target,
+ false /* ignore_calls*/);
if (branch_index == UINT32_MAX) {
return retval;
}
@@ -6061,7 +5915,7 @@ Process::GetMemoryRegions(lldb_private::MemoryRegionInfos &region_list) {
}
Status
-Process::ConfigureStructuredData(const ConstString &type_name,
+Process::ConfigureStructuredData(ConstString type_name,
const StructuredData::ObjectSP &config_sp) {
// If you get this, the Process-derived class needs to implement a method to
// enable an already-reported asynchronous structured data feature. See
diff --git a/source/Target/ProcessInfo.cpp b/source/Target/ProcessInfo.cpp
deleted file mode 100644
index 1ada6123fa1ea..0000000000000
--- a/source/Target/ProcessInfo.cpp
+++ /dev/null
@@ -1,114 +0,0 @@
-//===-- ProcessInfo.cpp -----------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "lldb/Target/ProcessInfo.h"
-
-#include <climits>
-
-#include "lldb/Host/PosixApi.h"
-#include "lldb/Utility/Stream.h"
-
-#include "llvm/ADT/SmallString.h"
-
-using namespace lldb;
-using namespace lldb_private;
-
-ProcessInfo::ProcessInfo()
- : m_executable(), m_arguments(), m_environment(), m_uid(UINT32_MAX),
- m_gid(UINT32_MAX), m_arch(), m_pid(LLDB_INVALID_PROCESS_ID) {}
-
-ProcessInfo::ProcessInfo(const char *name, const ArchSpec &arch,
- lldb::pid_t pid)
- : m_executable(name), m_arguments(), m_environment(), m_uid(UINT32_MAX),
- m_gid(UINT32_MAX), m_arch(arch), m_pid(pid) {}
-
-void ProcessInfo::Clear() {
- m_executable.Clear();
- m_arguments.Clear();
- m_environment.clear();
- m_uid = UINT32_MAX;
- m_gid = UINT32_MAX;
- m_arch.Clear();
- m_pid = LLDB_INVALID_PROCESS_ID;
-}
-
-const char *ProcessInfo::GetName() const {
- return m_executable.GetFilename().GetCString();
-}
-
-size_t ProcessInfo::GetNameLength() const {
- return m_executable.GetFilename().GetLength();
-}
-
-void ProcessInfo::Dump(Stream &s, Platform *platform) const {
- s << "Executable: " << GetName() << "\n";
- s << "Triple: ";
- m_arch.DumpTriple(s);
- s << "\n";
-
- s << "Arguments:\n";
- m_arguments.Dump(s);
-
- s.Format("Environment:\n{0}", m_environment);
-}
-
-void ProcessInfo::SetExecutableFile(const FileSpec &exe_file,
- bool add_exe_file_as_first_arg) {
- if (exe_file) {
- m_executable = exe_file;
- if (add_exe_file_as_first_arg) {
- llvm::SmallString<128> filename;
- exe_file.GetPath(filename);
- if (!filename.empty())
- m_arguments.InsertArgumentAtIndex(0, filename);
- }
- } else {
- m_executable.Clear();
- }
-}
-
-llvm::StringRef ProcessInfo::GetArg0() const {
- return m_arg0;
-}
-
-void ProcessInfo::SetArg0(llvm::StringRef arg) {
- m_arg0 = arg;
-}
-
-void ProcessInfo::SetArguments(char const **argv,
- bool first_arg_is_executable) {
- m_arguments.SetArguments(argv);
-
- // Is the first argument the executable?
- if (first_arg_is_executable) {
- const char *first_arg = m_arguments.GetArgumentAtIndex(0);
- if (first_arg) {
- // Yes the first argument is an executable, set it as the executable in
- // the launch options. Don't resolve the file path as the path could be a
- // remote platform path
- m_executable.SetFile(first_arg, FileSpec::Style::native);
- }
- }
-}
-
-void ProcessInfo::SetArguments(const Args &args, bool first_arg_is_executable) {
- // Copy all arguments
- m_arguments = args;
-
- // Is the first argument the executable?
- if (first_arg_is_executable) {
- const char *first_arg = m_arguments.GetArgumentAtIndex(0);
- if (first_arg) {
- // Yes the first argument is an executable, set it as the executable in
- // the launch options. Don't resolve the file path as the path could be a
- // remote platform path
- m_executable.SetFile(first_arg, FileSpec::Style::native);
- }
- }
-}
diff --git a/source/Target/ProcessLaunchInfo.cpp b/source/Target/ProcessLaunchInfo.cpp
deleted file mode 100644
index ac1eba04f0cb8..0000000000000
--- a/source/Target/ProcessLaunchInfo.cpp
+++ /dev/null
@@ -1,348 +0,0 @@
-//===-- ProcessLaunchInfo.cpp -----------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include <climits>
-
-#include "lldb/Host/Config.h"
-#include "lldb/Host/FileSystem.h"
-#include "lldb/Host/HostInfo.h"
-#include "lldb/Target/FileAction.h"
-#include "lldb/Target/ProcessLaunchInfo.h"
-#include "lldb/Utility/Log.h"
-#include "lldb/Utility/StreamString.h"
-
-#include "llvm/Support/ConvertUTF.h"
-#include "llvm/Support/FileSystem.h"
-
-#if !defined(_WIN32)
-#include <limits.h>
-#endif
-
-using namespace lldb;
-using namespace lldb_private;
-
-//----------------------------------------------------------------------------
-// ProcessLaunchInfo member functions
-//----------------------------------------------------------------------------
-
-ProcessLaunchInfo::ProcessLaunchInfo()
- : ProcessInfo(), m_working_dir(), m_plugin_name(), m_flags(0),
- m_file_actions(), m_pty(new PseudoTerminal), m_resume_count(0),
- m_monitor_callback(nullptr), m_monitor_callback_baton(nullptr),
- m_monitor_signals(false), m_listener_sp(), m_hijack_listener_sp() {}
-
-ProcessLaunchInfo::ProcessLaunchInfo(const FileSpec &stdin_file_spec,
- const FileSpec &stdout_file_spec,
- const FileSpec &stderr_file_spec,
- const FileSpec &working_directory,
- uint32_t launch_flags)
- : ProcessInfo(), m_working_dir(), m_plugin_name(), m_flags(launch_flags),
- m_file_actions(), m_pty(new PseudoTerminal), m_resume_count(0),
- m_monitor_callback(nullptr), m_monitor_callback_baton(nullptr),
- m_monitor_signals(false), m_listener_sp(), m_hijack_listener_sp() {
- if (stdin_file_spec) {
- FileAction file_action;
- const bool read = true;
- const bool write = false;
- if (file_action.Open(STDIN_FILENO, stdin_file_spec, read, write))
- AppendFileAction(file_action);
- }
- if (stdout_file_spec) {
- FileAction file_action;
- const bool read = false;
- const bool write = true;
- if (file_action.Open(STDOUT_FILENO, stdout_file_spec, read, write))
- AppendFileAction(file_action);
- }
- if (stderr_file_spec) {
- FileAction file_action;
- const bool read = false;
- const bool write = true;
- if (file_action.Open(STDERR_FILENO, stderr_file_spec, read, write))
- AppendFileAction(file_action);
- }
- if (working_directory)
- SetWorkingDirectory(working_directory);
-}
-
-bool ProcessLaunchInfo::AppendCloseFileAction(int fd) {
- FileAction file_action;
- if (file_action.Close(fd)) {
- AppendFileAction(file_action);
- return true;
- }
- return false;
-}
-
-bool ProcessLaunchInfo::AppendDuplicateFileAction(int fd, int dup_fd) {
- FileAction file_action;
- if (file_action.Duplicate(fd, dup_fd)) {
- AppendFileAction(file_action);
- return true;
- }
- return false;
-}
-
-bool ProcessLaunchInfo::AppendOpenFileAction(int fd, const FileSpec &file_spec,
- bool read, bool write) {
- FileAction file_action;
- if (file_action.Open(fd, file_spec, read, write)) {
- AppendFileAction(file_action);
- return true;
- }
- return false;
-}
-
-bool ProcessLaunchInfo::AppendSuppressFileAction(int fd, bool read,
- bool write) {
- FileAction file_action;
- if (file_action.Open(fd, FileSpec(FileSystem::DEV_NULL), read, write)) {
- AppendFileAction(file_action);
- return true;
- }
- return false;
-}
-
-const FileAction *ProcessLaunchInfo::GetFileActionAtIndex(size_t idx) const {
- if (idx < m_file_actions.size())
- return &m_file_actions[idx];
- return nullptr;
-}
-
-const FileAction *ProcessLaunchInfo::GetFileActionForFD(int fd) const {
- for (size_t idx = 0, count = m_file_actions.size(); idx < count; ++idx) {
- if (m_file_actions[idx].GetFD() == fd)
- return &m_file_actions[idx];
- }
- return nullptr;
-}
-
-const FileSpec &ProcessLaunchInfo::GetWorkingDirectory() const {
- return m_working_dir;
-}
-
-void ProcessLaunchInfo::SetWorkingDirectory(const FileSpec &working_dir) {
- m_working_dir = working_dir;
-}
-
-const char *ProcessLaunchInfo::GetProcessPluginName() const {
- return (m_plugin_name.empty() ? nullptr : m_plugin_name.c_str());
-}
-
-void ProcessLaunchInfo::SetProcessPluginName(llvm::StringRef plugin) {
- m_plugin_name = plugin;
-}
-
-const FileSpec &ProcessLaunchInfo::GetShell() const { return m_shell; }
-
-void ProcessLaunchInfo::SetShell(const FileSpec &shell) {
- m_shell = shell;
- if (m_shell) {
- FileSystem::Instance().ResolveExecutableLocation(m_shell);
- m_flags.Set(lldb::eLaunchFlagLaunchInShell);
- } else
- m_flags.Clear(lldb::eLaunchFlagLaunchInShell);
-}
-
-void ProcessLaunchInfo::SetLaunchInSeparateProcessGroup(bool separate) {
- if (separate)
- m_flags.Set(lldb::eLaunchFlagLaunchInSeparateProcessGroup);
- else
- m_flags.Clear(lldb::eLaunchFlagLaunchInSeparateProcessGroup);
-}
-
-void ProcessLaunchInfo::SetShellExpandArguments(bool expand) {
- if (expand)
- m_flags.Set(lldb::eLaunchFlagShellExpandArguments);
- else
- m_flags.Clear(lldb::eLaunchFlagShellExpandArguments);
-}
-
-void ProcessLaunchInfo::Clear() {
- ProcessInfo::Clear();
- m_working_dir.Clear();
- m_plugin_name.clear();
- m_shell.Clear();
- m_flags.Clear();
- m_file_actions.clear();
- m_resume_count = 0;
- m_listener_sp.reset();
- m_hijack_listener_sp.reset();
-}
-
-void ProcessLaunchInfo::SetMonitorProcessCallback(
- const Host::MonitorChildProcessCallback &callback, bool monitor_signals) {
- m_monitor_callback = callback;
- m_monitor_signals = monitor_signals;
-}
-
-bool ProcessLaunchInfo::NoOpMonitorCallback(lldb::pid_t pid, bool exited, int signal, int status) {
- Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS);
- LLDB_LOG(log, "pid = {0}, exited = {1}, signal = {2}, status = {3}", pid,
- exited, signal, status);
- return true;
-}
-
-bool ProcessLaunchInfo::MonitorProcess() const {
- if (m_monitor_callback && ProcessIDIsValid()) {
- Host::StartMonitoringChildProcess(m_monitor_callback, GetProcessID(),
- m_monitor_signals);
- return true;
- }
- return false;
-}
-
-void ProcessLaunchInfo::SetDetachOnError(bool enable) {
- if (enable)
- m_flags.Set(lldb::eLaunchFlagDetachOnError);
- else
- m_flags.Clear(lldb::eLaunchFlagDetachOnError);
-}
-
-llvm::Error ProcessLaunchInfo::SetUpPtyRedirection() {
- Log *log = GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS);
- LLDB_LOG(log, "Generating a pty to use for stdin/out/err");
-
- int open_flags = O_RDWR | O_NOCTTY;
-#if !defined(_WIN32)
- // We really shouldn't be specifying platform specific flags that are
- // intended for a system call in generic code. But this will have to
- // do for now.
- open_flags |= O_CLOEXEC;
-#endif
- if (!m_pty->OpenFirstAvailableMaster(open_flags, nullptr, 0)) {
- return llvm::createStringError(llvm::inconvertibleErrorCode(),
- "PTY::OpenFirstAvailableMaster failed");
- }
- const FileSpec slave_file_spec(m_pty->GetSlaveName(nullptr, 0));
-
- // Only use the slave tty if we don't have anything specified for
- // input and don't have an action for stdin
- if (GetFileActionForFD(STDIN_FILENO) == nullptr)
- AppendOpenFileAction(STDIN_FILENO, slave_file_spec, true, false);
-
- // Only use the slave tty if we don't have anything specified for
- // output and don't have an action for stdout
- if (GetFileActionForFD(STDOUT_FILENO) == nullptr)
- AppendOpenFileAction(STDOUT_FILENO, slave_file_spec, false, true);
-
- // Only use the slave tty if we don't have anything specified for
- // error and don't have an action for stderr
- if (GetFileActionForFD(STDERR_FILENO) == nullptr)
- AppendOpenFileAction(STDERR_FILENO, slave_file_spec, false, true);
- return llvm::Error::success();
-}
-
-bool ProcessLaunchInfo::ConvertArgumentsForLaunchingInShell(
- Status &error, bool localhost, bool will_debug,
- bool first_arg_is_full_shell_command, int32_t num_resumes) {
- error.Clear();
-
- if (GetFlags().Test(eLaunchFlagLaunchInShell)) {
- if (m_shell) {
- std::string shell_executable = m_shell.GetPath();
-
- const char **argv = GetArguments().GetConstArgumentVector();
- if (argv == nullptr || argv[0] == nullptr)
- return false;
- Args shell_arguments;
- std::string safe_arg;
- shell_arguments.AppendArgument(shell_executable);
- const llvm::Triple &triple = GetArchitecture().GetTriple();
- if (triple.getOS() == llvm::Triple::Win32 &&
- !triple.isWindowsCygwinEnvironment())
- shell_arguments.AppendArgument(llvm::StringRef("/C"));
- else
- shell_arguments.AppendArgument(llvm::StringRef("-c"));
-
- StreamString shell_command;
- if (will_debug) {
- // Add a modified PATH environment variable in case argv[0] is a
- // relative path.
- const char *argv0 = argv[0];
- FileSpec arg_spec(argv0);
- if (arg_spec.IsRelative()) {
- // We have a relative path to our executable which may not work if we
- // just try to run "a.out" (without it being converted to "./a.out")
- FileSpec working_dir = GetWorkingDirectory();
- // Be sure to put quotes around PATH's value in case any paths have
- // spaces...
- std::string new_path("PATH=\"");
- const size_t empty_path_len = new_path.size();
-
- if (working_dir) {
- new_path += working_dir.GetPath();
- } else {
- llvm::SmallString<64> cwd;
- if (! llvm::sys::fs::current_path(cwd))
- new_path += cwd;
- }
- std::string curr_path;
- if (HostInfo::GetEnvironmentVar("PATH", curr_path)) {
- if (new_path.size() > empty_path_len)
- new_path += ':';
- new_path += curr_path;
- }
- new_path += "\" ";
- shell_command.PutCString(new_path);
- }
-
- if (triple.getOS() != llvm::Triple::Win32 ||
- triple.isWindowsCygwinEnvironment())
- shell_command.PutCString("exec");
-
- // Only Apple supports /usr/bin/arch being able to specify the
- // architecture
- if (GetArchitecture().IsValid() && // Valid architecture
- GetArchitecture().GetTriple().getVendor() ==
- llvm::Triple::Apple && // Apple only
- GetArchitecture().GetCore() !=
- ArchSpec::eCore_x86_64_x86_64h) // Don't do this for x86_64h
- {
- shell_command.Printf(" /usr/bin/arch -arch %s",
- GetArchitecture().GetArchitectureName());
- // Set the resume count to 2:
- // 1 - stop in shell
- // 2 - stop in /usr/bin/arch
- // 3 - then we will stop in our program
- SetResumeCount(num_resumes + 1);
- } else {
- // Set the resume count to 1:
- // 1 - stop in shell
- // 2 - then we will stop in our program
- SetResumeCount(num_resumes);
- }
- }
-
- if (first_arg_is_full_shell_command) {
- // There should only be one argument that is the shell command itself
- // to be used as is
- if (argv[0] && !argv[1])
- shell_command.Printf("%s", argv[0]);
- else
- return false;
- } else {
- for (size_t i = 0; argv[i] != nullptr; ++i) {
- const char *arg =
- Args::GetShellSafeArgument(m_shell, argv[i], safe_arg);
- shell_command.Printf(" %s", arg);
- }
- }
- shell_arguments.AppendArgument(shell_command.GetString());
- m_executable = m_shell;
- m_arguments = shell_arguments;
- return true;
- } else {
- error.SetErrorString("invalid shell path");
- }
- } else {
- error.SetErrorString("not launching in shell");
- }
- return false;
-}
diff --git a/source/Target/Queue.cpp b/source/Target/Queue.cpp
index c0683d10b1517..fc2a93dbe8993 100644
--- a/source/Target/Queue.cpp
+++ b/source/Target/Queue.cpp
@@ -1,9 +1,8 @@
//===-- Queue.cpp -----------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Target/QueueItem.cpp b/source/Target/QueueItem.cpp
index a20fa918a758e..47ff9e028fcbd 100644
--- a/source/Target/QueueItem.cpp
+++ b/source/Target/QueueItem.cpp
@@ -1,9 +1,8 @@
//===-- QueueItem.cpp -------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Target/QueueList.cpp b/source/Target/QueueList.cpp
index ae9e7b93793b5..796825135187b 100644
--- a/source/Target/QueueList.cpp
+++ b/source/Target/QueueList.cpp
@@ -1,9 +1,8 @@
//===-- QueueList.cpp -------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Target/RegisterContext.cpp b/source/Target/RegisterContext.cpp
index 976f9e8b45e7b..c960260f30c88 100644
--- a/source/Target/RegisterContext.cpp
+++ b/source/Target/RegisterContext.cpp
@@ -1,9 +1,8 @@
//===-- RegisterContext.cpp -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Target/RegisterNumber.cpp b/source/Target/RegisterNumber.cpp
index 8b01bd103395a..63b58d3582fd0 100644
--- a/source/Target/RegisterNumber.cpp
+++ b/source/Target/RegisterNumber.cpp
@@ -1,9 +1,8 @@
//===--------------------- RegisterNumber.cpp -------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Target/RemoteAwarePlatform.cpp b/source/Target/RemoteAwarePlatform.cpp
new file mode 100644
index 0000000000000..1704e1533e9cb
--- /dev/null
+++ b/source/Target/RemoteAwarePlatform.cpp
@@ -0,0 +1,284 @@
+//===-- RemoteAwarePlatform.cpp ---------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "lldb/Target/RemoteAwarePlatform.h"
+#include "lldb/Host/FileCache.h"
+#include "lldb/Host/FileSystem.h"
+#include "lldb/Host/Host.h"
+#include "lldb/Host/HostInfo.h"
+
+using namespace lldb_private;
+
+bool RemoteAwarePlatform::GetModuleSpec(const FileSpec &module_file_spec,
+ const ArchSpec &arch,
+ ModuleSpec &module_spec) {
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->GetModuleSpec(module_file_spec, arch,
+ module_spec);
+
+ return Platform::GetModuleSpec(module_file_spec, arch, module_spec);
+}
+
+Status RemoteAwarePlatform::RunShellCommand(
+ const char *command, const FileSpec &working_dir, int *status_ptr,
+ int *signo_ptr, std::string *command_output,
+ const Timeout<std::micro> &timeout) {
+ if (IsHost())
+ return Host::RunShellCommand(command, working_dir, status_ptr, signo_ptr,
+ command_output, timeout);
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->RunShellCommand(
+ command, working_dir, status_ptr, signo_ptr, command_output, timeout);
+ return Status("unable to run a remote command without a platform");
+}
+
+Status RemoteAwarePlatform::MakeDirectory(const FileSpec &file_spec,
+ uint32_t file_permissions) {
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->MakeDirectory(file_spec, file_permissions);
+ return Platform::MakeDirectory(file_spec, file_permissions);
+}
+
+Status RemoteAwarePlatform::GetFilePermissions(const FileSpec &file_spec,
+ uint32_t &file_permissions) {
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->GetFilePermissions(file_spec,
+ file_permissions);
+ return Platform::GetFilePermissions(file_spec, file_permissions);
+}
+
+Status RemoteAwarePlatform::SetFilePermissions(const FileSpec &file_spec,
+ uint32_t file_permissions) {
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->SetFilePermissions(file_spec,
+ file_permissions);
+ return Platform::SetFilePermissions(file_spec, file_permissions);
+}
+
+lldb::user_id_t RemoteAwarePlatform::OpenFile(const FileSpec &file_spec,
+ uint32_t flags, uint32_t mode,
+ Status &error) {
+ if (IsHost())
+ return FileCache::GetInstance().OpenFile(file_spec, flags, mode, error);
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->OpenFile(file_spec, flags, mode, error);
+ return Platform::OpenFile(file_spec, flags, mode, error);
+}
+
+bool RemoteAwarePlatform::CloseFile(lldb::user_id_t fd, Status &error) {
+ if (IsHost())
+ return FileCache::GetInstance().CloseFile(fd, error);
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->CloseFile(fd, error);
+ return Platform::CloseFile(fd, error);
+}
+
+uint64_t RemoteAwarePlatform::ReadFile(lldb::user_id_t fd, uint64_t offset,
+ void *dst, uint64_t dst_len,
+ Status &error) {
+ if (IsHost())
+ return FileCache::GetInstance().ReadFile(fd, offset, dst, dst_len, error);
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->ReadFile(fd, offset, dst, dst_len, error);
+ return Platform::ReadFile(fd, offset, dst, dst_len, error);
+}
+
+uint64_t RemoteAwarePlatform::WriteFile(lldb::user_id_t fd, uint64_t offset,
+ const void *src, uint64_t src_len,
+ Status &error) {
+ if (IsHost())
+ return FileCache::GetInstance().WriteFile(fd, offset, src, src_len, error);
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->WriteFile(fd, offset, src, src_len, error);
+ return Platform::WriteFile(fd, offset, src, src_len, error);
+}
+
+lldb::user_id_t RemoteAwarePlatform::GetFileSize(const FileSpec &file_spec) {
+ if (IsHost()) {
+ uint64_t Size;
+ if (llvm::sys::fs::file_size(file_spec.GetPath(), Size))
+ return 0;
+ return Size;
+ }
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->GetFileSize(file_spec);
+ return Platform::GetFileSize(file_spec);
+}
+
+Status RemoteAwarePlatform::CreateSymlink(const FileSpec &src,
+ const FileSpec &dst) {
+ if (IsHost())
+ return FileSystem::Instance().Symlink(src, dst);
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->CreateSymlink(src, dst);
+ return Platform::CreateSymlink(src, dst);
+}
+
+bool RemoteAwarePlatform::GetFileExists(const FileSpec &file_spec) {
+ if (IsHost())
+ return FileSystem::Instance().Exists(file_spec);
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->GetFileExists(file_spec);
+ return Platform::GetFileExists(file_spec);
+}
+
+Status RemoteAwarePlatform::Unlink(const FileSpec &file_spec) {
+ if (IsHost())
+ return llvm::sys::fs::remove(file_spec.GetPath());
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->Unlink(file_spec);
+ return Platform::Unlink(file_spec);
+}
+
+bool RemoteAwarePlatform::CalculateMD5(const FileSpec &file_spec, uint64_t &low,
+ uint64_t &high) {
+ if (IsHost())
+ return Platform::CalculateMD5(file_spec, low, high);
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->CalculateMD5(file_spec, low, high);
+ return false;
+}
+
+FileSpec RemoteAwarePlatform::GetRemoteWorkingDirectory() {
+ if (IsRemote() && m_remote_platform_sp)
+ return m_remote_platform_sp->GetRemoteWorkingDirectory();
+ return Platform::GetRemoteWorkingDirectory();
+}
+
+bool RemoteAwarePlatform::SetRemoteWorkingDirectory(
+ const FileSpec &working_dir) {
+ if (IsRemote() && m_remote_platform_sp)
+ return m_remote_platform_sp->SetRemoteWorkingDirectory(working_dir);
+ return Platform::SetRemoteWorkingDirectory(working_dir);
+}
+
+Status RemoteAwarePlatform::GetFileWithUUID(const FileSpec &platform_file,
+ const UUID *uuid_ptr,
+ FileSpec &local_file) {
+ if (IsRemote() && m_remote_platform_sp)
+ return m_remote_platform_sp->GetFileWithUUID(platform_file, uuid_ptr,
+ local_file);
+
+ // Default to the local case
+ local_file = platform_file;
+ return Status();
+}
+
+bool RemoteAwarePlatform::GetRemoteOSVersion() {
+ if (m_remote_platform_sp) {
+ m_os_version = m_remote_platform_sp->GetOSVersion();
+ return !m_os_version.empty();
+ }
+ return false;
+}
+
+bool RemoteAwarePlatform::GetRemoteOSBuildString(std::string &s) {
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->GetRemoteOSBuildString(s);
+ s.clear();
+ return false;
+}
+
+bool RemoteAwarePlatform::GetRemoteOSKernelDescription(std::string &s) {
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->GetRemoteOSKernelDescription(s);
+ s.clear();
+ return false;
+}
+
+ArchSpec RemoteAwarePlatform::GetRemoteSystemArchitecture() {
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->GetRemoteSystemArchitecture();
+ return ArchSpec();
+}
+
+const char *RemoteAwarePlatform::GetHostname() {
+ if (IsHost())
+ return Platform::GetHostname();
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->GetHostname();
+ return nullptr;
+}
+
+UserIDResolver &RemoteAwarePlatform::GetUserIDResolver() {
+ if (IsHost())
+ return HostInfo::GetUserIDResolver();
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->GetUserIDResolver();
+ return UserIDResolver::GetNoopResolver();
+}
+
+Environment RemoteAwarePlatform::GetEnvironment() {
+ if (IsRemote()) {
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->GetEnvironment();
+ return Environment();
+ }
+ return Host::GetEnvironment();
+}
+
+bool RemoteAwarePlatform::IsConnected() const {
+ if (IsHost())
+ return true;
+ else if (m_remote_platform_sp)
+ return m_remote_platform_sp->IsConnected();
+ return false;
+}
+
+bool RemoteAwarePlatform::GetProcessInfo(lldb::pid_t pid,
+ ProcessInstanceInfo &process_info) {
+ if (IsHost())
+ return Platform::GetProcessInfo(pid, process_info);
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->GetProcessInfo(pid, process_info);
+ return false;
+}
+
+uint32_t
+RemoteAwarePlatform::FindProcesses(const ProcessInstanceInfoMatch &match_info,
+ ProcessInstanceInfoList &process_infos) {
+ if (IsHost())
+ return Platform::FindProcesses(match_info, process_infos);
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->FindProcesses(match_info, process_infos);
+ return 0;
+}
+
+lldb::ProcessSP RemoteAwarePlatform::ConnectProcess(llvm::StringRef connect_url,
+ llvm::StringRef plugin_name,
+ Debugger &debugger,
+ Target *target,
+ Status &error) {
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->ConnectProcess(connect_url, plugin_name,
+ debugger, target, error);
+ return Platform::ConnectProcess(connect_url, plugin_name, debugger, target,
+ error);
+}
+
+Status RemoteAwarePlatform::LaunchProcess(ProcessLaunchInfo &launch_info) {
+ Status error;
+
+ if (IsHost()) {
+ error = Platform::LaunchProcess(launch_info);
+ } else {
+ if (m_remote_platform_sp)
+ error = m_remote_platform_sp->LaunchProcess(launch_info);
+ else
+ error.SetErrorString("the platform is not currently connected");
+ }
+ return error;
+}
+
+Status RemoteAwarePlatform::KillProcess(const lldb::pid_t pid) {
+ if (IsHost())
+ return Platform::KillProcess(pid);
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->KillProcess(pid);
+ return Status("the platform is not currently connected");
+}
diff --git a/source/Target/SectionLoadHistory.cpp b/source/Target/SectionLoadHistory.cpp
index 1229933793ffb..ec16b58b4451c 100644
--- a/source/Target/SectionLoadHistory.cpp
+++ b/source/Target/SectionLoadHistory.cpp
@@ -1,9 +1,8 @@
//===-- SectionLoadHistory.cpp ----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -81,7 +80,7 @@ SectionLoadHistory::GetSectionLoadListForStopID(uint32_t stop_id,
StopIDToSectionLoadList::reverse_iterator rpos =
m_stop_id_to_section_load_list.rbegin();
SectionLoadListSP section_load_list_sp(
- new SectionLoadList(*rpos->second.get()));
+ new SectionLoadList(*rpos->second));
m_stop_id_to_section_load_list[stop_id] = section_load_list_sp;
return section_load_list_sp.get();
}
@@ -98,7 +97,7 @@ SectionLoadList &SectionLoadHistory::GetCurrentSectionLoadList() {
std::lock_guard<std::recursive_mutex> guard(m_mutex);
SectionLoadList *section_load_list =
GetSectionLoadListForStopID(eStopIDNow, read_only);
- assert(section_load_list != NULL);
+ assert(section_load_list != nullptr);
return *section_load_list;
}
diff --git a/source/Target/SectionLoadList.cpp b/source/Target/SectionLoadList.cpp
index ea9f7ea9911ca..598f49ca13de0 100644
--- a/source/Target/SectionLoadList.cpp
+++ b/source/Target/SectionLoadList.cpp
@@ -1,9 +1,8 @@
//===-- SectionLoadList.cpp -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -28,8 +27,9 @@ SectionLoadList::SectionLoadList(const SectionLoadList &rhs)
}
void SectionLoadList::operator=(const SectionLoadList &rhs) {
- std::lock_guard<std::recursive_mutex> lhs_guard(m_mutex);
- std::lock_guard<std::recursive_mutex> rhs_guard(rhs.m_mutex);
+ std::lock(m_mutex, rhs.m_mutex);
+ std::lock_guard<std::recursive_mutex> lhs_guard(m_mutex, std::adopt_lock);
+ std::lock_guard<std::recursive_mutex> rhs_guard(rhs.m_mutex, std::adopt_lock);
m_addr_to_sect = rhs.m_addr_to_sect;
m_sect_to_addr = rhs.m_sect_to_addr;
}
diff --git a/source/Target/StackFrame.cpp b/source/Target/StackFrame.cpp
index 3cea6444596c7..f8b22d96e16fb 100644
--- a/source/Target/StackFrame.cpp
+++ b/source/Target/StackFrame.cpp
@@ -1,9 +1,8 @@
//===-- StackFrame.cpp ------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -34,6 +33,8 @@
#include "lldb/lldb-enumerations.h"
+#include <memory>
+
using namespace lldb;
using namespace lldb_private;
@@ -258,12 +259,10 @@ Block *StackFrame::GetFrameBlock() {
return nullptr;
}
-//----------------------------------------------------------------------
// Get the symbol context if we already haven't done so by resolving the
// PC address as much as possible. This way when we pass around a
// StackFrame object, everyone will have as much information as possible and no
// one will ever have to look things up manually.
-//----------------------------------------------------------------------
const SymbolContext &
StackFrame::GetSymbolContext(SymbolContextItem resolve_scope) {
std::lock_guard<std::recursive_mutex> guard(m_mutex);
@@ -423,7 +422,7 @@ VariableList *StackFrame::GetVariableList(bool get_file_globals) {
const bool get_child_variables = true;
const bool can_create = true;
const bool stop_if_child_block_is_inlined_function = true;
- m_variable_list_sp.reset(new VariableList());
+ m_variable_list_sp = std::make_shared<VariableList>();
frame_block->AppendBlockVariables(can_create, get_child_variables,
stop_if_child_block_is_inlined_function,
[](Variable *v) { return true; },
@@ -641,7 +640,12 @@ ValueObjectSP StackFrame::GetValueForVariableExpressionPath(
valobj_sp = valobj_sp->Dereference(deref_error);
if (error.Fail()) {
error.SetErrorStringWithFormatv(
- "Failed to dereference sythetic value: %s", deref_error);
+ "Failed to dereference sythetic value: {0}", deref_error);
+ return ValueObjectSP();
+ }
+ // Some synthetic plug-ins fail to set the error in Dereference
+ if (!valobj_sp) {
+ error.SetErrorString("Failed to dereference sythetic value");
return ValueObjectSP();
}
expr_is_ptr = false;
@@ -1174,7 +1178,7 @@ ValueObjectSP StackFrame::TrackGlobalVariable(const VariableSP &variable_sp,
VariableList *var_list = GetVariableList(true);
// If this frame has no variables, create a new list
if (var_list == nullptr)
- m_variable_list_sp.reset(new VariableList());
+ m_variable_list_sp = std::make_shared<VariableList>();
// Add the global/static variable to this frame
m_variable_list_sp->AddVariable(variable_sp);
@@ -1447,33 +1451,31 @@ ValueObjectSP GetValueForDereferincingOffset(StackFrame &frame,
return GetValueForOffset(frame, pointee, offset);
}
-//------------------------------------------------------------------
/// Attempt to reconstruct the ValueObject for the address contained in a
/// given register plus an offset.
///
-/// @params [in] frame
+/// \params [in] frame
/// The current stack frame.
///
-/// @params [in] reg
+/// \params [in] reg
/// The register.
///
-/// @params [in] offset
+/// \params [in] offset
/// The offset from the register.
///
-/// @param [in] disassembler
+/// \param [in] disassembler
/// A disassembler containing instructions valid up to the current PC.
///
-/// @param [in] variables
+/// \param [in] variables
/// The variable list from the current frame,
///
-/// @param [in] pc
+/// \param [in] pc
/// The program counter for the instruction considered the 'user'.
///
-/// @return
+/// \return
/// A string describing the base for the ExpressionPath. This could be a
/// variable, a register value, an argument, or a function return value.
/// The ValueObject if found. If valid, it has a valid ExpressionPath.
-//------------------------------------------------------------------
lldb::ValueObjectSP DoGuessValueAt(StackFrame &frame, ConstString reg,
int64_t offset, Disassembler &disassembler,
VariableList &variables, const Address &pc) {
diff --git a/source/Target/StackFrameList.cpp b/source/Target/StackFrameList.cpp
index fc9fcec6c076d..5492dda46402d 100644
--- a/source/Target/StackFrameList.cpp
+++ b/source/Target/StackFrameList.cpp
@@ -1,9 +1,8 @@
//===-- StackFrameList.cpp --------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -25,14 +24,14 @@
#include "lldb/Utility/Log.h"
#include "llvm/ADT/SmallPtrSet.h"
+#include <memory>
+
//#define DEBUG_STACK_FRAMES 1
using namespace lldb;
using namespace lldb_private;
-//----------------------------------------------------------------------
// StackFrameList constructor
-//----------------------------------------------------------------------
StackFrameList::StackFrameList(Thread &thread,
const lldb::StackFrameListSP &prev_frames_sp,
bool show_inline_frames)
@@ -466,9 +465,9 @@ void StackFrameList::GetFramesUpTo(uint32_t end_idx) {
pc = reg_ctx_sp->GetPC();
}
- unwind_frame_sp.reset(new StackFrame(m_thread.shared_from_this(),
- m_frames.size(), idx, reg_ctx_sp,
- cfa, pc, nullptr));
+ unwind_frame_sp = std::make_shared<StackFrame>(
+ m_thread.shared_from_this(), m_frames.size(), idx, reg_ctx_sp,
+ cfa, pc, nullptr);
m_frames.push_back(unwind_frame_sp);
}
} else {
@@ -484,9 +483,9 @@ void StackFrameList::GetFramesUpTo(uint32_t end_idx) {
break;
}
const bool cfa_is_valid = true;
- unwind_frame_sp.reset(
- new StackFrame(m_thread.shared_from_this(), m_frames.size(), idx, cfa,
- cfa_is_valid, pc, StackFrame::Kind::Regular, nullptr));
+ unwind_frame_sp = std::make_shared<StackFrame>(
+ m_thread.shared_from_this(), m_frames.size(), idx, cfa, cfa_is_valid,
+ pc, StackFrame::Kind::Regular, nullptr);
// Create synthetic tail call frames between the previous frame and the
// newly-found frame. The new frame's index may change after this call,
@@ -664,9 +663,9 @@ StackFrameSP StackFrameList::GetFrameAtIndex(uint32_t idx) {
addr_t pc, cfa;
if (unwinder->GetFrameInfoAtIndex(idx, cfa, pc)) {
const bool cfa_is_valid = true;
- frame_sp.reset(new StackFrame(m_thread.shared_from_this(), idx, idx,
- cfa, cfa_is_valid, pc,
- StackFrame::Kind::Regular, nullptr));
+ frame_sp = std::make_shared<StackFrame>(
+ m_thread.shared_from_this(), idx, idx, cfa, cfa_is_valid, pc,
+ StackFrame::Kind::Regular, nullptr);
Function *function =
frame_sp->GetSymbolContext(eSymbolContextFunction).function;
@@ -818,11 +817,11 @@ void StackFrameList::Clear() {
m_concrete_frames_fetched = 0;
}
-void StackFrameList::Merge(std::unique_ptr<StackFrameList> &curr_ap,
+void StackFrameList::Merge(std::unique_ptr<StackFrameList> &curr_up,
lldb::StackFrameListSP &prev_sp) {
std::unique_lock<std::recursive_mutex> current_lock, previous_lock;
- if (curr_ap)
- current_lock = std::unique_lock<std::recursive_mutex>(curr_ap->m_mutex);
+ if (curr_up)
+ current_lock = std::unique_lock<std::recursive_mutex>(curr_up->m_mutex);
if (prev_sp)
previous_lock = std::unique_lock<std::recursive_mutex>(prev_sp->m_mutex);
@@ -834,18 +833,18 @@ void StackFrameList::Merge(std::unique_ptr<StackFrameList> &curr_ap,
else
s.PutCString("NULL");
s.PutCString("\nCurr:\n");
- if (curr_ap)
- curr_ap->Dump(&s);
+ if (curr_up)
+ curr_up->Dump(&s);
else
s.PutCString("NULL");
s.EOL();
#endif
- if (!curr_ap || curr_ap->GetNumFrames(false) == 0) {
+ if (!curr_up || curr_up->GetNumFrames(false) == 0) {
#if defined(DEBUG_STACK_FRAMES)
s.PutCString("No current frames, leave previous frames alone...\n");
#endif
- curr_ap.release();
+ curr_up.release();
return;
}
@@ -856,11 +855,11 @@ void StackFrameList::Merge(std::unique_ptr<StackFrameList> &curr_ap,
// We either don't have any previous frames, or since we have more than one
// current frames it means we have all the frames and can safely replace
// our previous frames.
- prev_sp.reset(curr_ap.release());
+ prev_sp.reset(curr_up.release());
return;
}
- const uint32_t num_curr_frames = curr_ap->GetNumFrames(false);
+ const uint32_t num_curr_frames = curr_up->GetNumFrames(false);
if (num_curr_frames > 1) {
#if defined(DEBUG_STACK_FRAMES)
@@ -869,7 +868,7 @@ void StackFrameList::Merge(std::unique_ptr<StackFrameList> &curr_ap,
#endif
// We have more than one current frames it means we have all the frames and
// can safely replace our previous frames.
- prev_sp.reset(curr_ap.release());
+ prev_sp.reset(curr_up.release());
#if defined(DEBUG_STACK_FRAMES)
s.PutCString("\nMerged:\n");
@@ -879,7 +878,7 @@ void StackFrameList::Merge(std::unique_ptr<StackFrameList> &curr_ap,
}
StackFrameSP prev_frame_zero_sp(prev_sp->GetFrameAtIndex(0));
- StackFrameSP curr_frame_zero_sp(curr_ap->GetFrameAtIndex(0));
+ StackFrameSP curr_frame_zero_sp(curr_up->GetFrameAtIndex(0));
StackID curr_stack_id(curr_frame_zero_sp->GetStackID());
StackID prev_stack_id(prev_frame_zero_sp->GetStackID());
@@ -909,7 +908,7 @@ void StackFrameList::Merge(std::unique_ptr<StackFrameList> &curr_ap,
prev_sp->m_frames.insert(prev_sp->m_frames.begin(), curr_frame_zero_sp);
}
- curr_ap.release();
+ curr_up.release();
#if defined(DEBUG_STACK_FRAMES)
s.PutCString("\nMerged:\n");
diff --git a/source/Target/StackFrameRecognizer.cpp b/source/Target/StackFrameRecognizer.cpp
index 152f4a198e20d..567d694bf093e 100644
--- a/source/Target/StackFrameRecognizer.cpp
+++ b/source/Target/StackFrameRecognizer.cpp
@@ -1,9 +1,8 @@
//===-- StackFrameRecognizer.cpp --------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -18,8 +17,6 @@
using namespace lldb;
using namespace lldb_private;
-#ifndef LLDB_DISABLE_PYTHON
-
class ScriptedRecognizedStackFrame : public RecognizedStackFrame {
public:
ScriptedRecognizedStackFrame(ValueObjectListSP args) {
@@ -41,16 +38,20 @@ ScriptedStackFrameRecognizer::RecognizeFrame(lldb::StackFrameSP frame) {
ValueObjectListSP args =
m_interpreter->GetRecognizedArguments(m_python_object_sp, frame);
+ auto args_synthesized = ValueObjectListSP(new ValueObjectList());
+ for (const auto o : args->GetObjects()) {
+ args_synthesized->Append(ValueObjectRecognizerSynthesizedValue::Create(
+ *o, eValueTypeVariableArgument));
+ }
- return RecognizedStackFrameSP(new ScriptedRecognizedStackFrame(args));
+ return RecognizedStackFrameSP(
+ new ScriptedRecognizedStackFrame(args_synthesized));
}
-#endif
-
class StackFrameRecognizerManagerImpl {
public:
void AddRecognizer(StackFrameRecognizerSP recognizer,
- const ConstString &module, const ConstString &symbol,
+ ConstString module, ConstString symbol,
bool first_instruction_only) {
m_recognizers.push_front({(uint32_t)m_recognizers.size(), false, recognizer, false, module, RegularExpressionSP(),
symbol, RegularExpressionSP(),
@@ -153,8 +154,8 @@ StackFrameRecognizerManagerImpl &GetStackFrameRecognizerManagerImpl() {
}
void StackFrameRecognizerManager::AddRecognizer(
- StackFrameRecognizerSP recognizer, const ConstString &module,
- const ConstString &symbol, bool first_instruction_only) {
+ StackFrameRecognizerSP recognizer, ConstString module,
+ ConstString symbol, bool first_instruction_only) {
GetStackFrameRecognizerManagerImpl().AddRecognizer(recognizer, module, symbol,
first_instruction_only);
}
diff --git a/source/Target/StackID.cpp b/source/Target/StackID.cpp
index d6640b24ad5c7..a8f6b787f4b4f 100644
--- a/source/Target/StackID.cpp
+++ b/source/Target/StackID.cpp
@@ -1,9 +1,8 @@
//===-- StackID.cpp ---------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Target/StopInfo.cpp b/source/Target/StopInfo.cpp
index 4e13c588b4845..6db0c2b037e9b 100644
--- a/source/Target/StopInfo.cpp
+++ b/source/Target/StopInfo.cpp
@@ -1,9 +1,8 @@
//===-- StopInfo.cpp --------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -79,9 +78,7 @@ bool StopInfo::HasTargetRunSinceMe() {
return false;
}
-//----------------------------------------------------------------------
// StopInfoBreakpoint
-//----------------------------------------------------------------------
namespace lldb_private {
class StopInfoBreakpoint : public StopInfo {
@@ -576,9 +573,7 @@ private:
bool m_was_one_shot;
};
-//----------------------------------------------------------------------
// StopInfoWatchpoint
-//----------------------------------------------------------------------
class StopInfoWatchpoint : public StopInfo {
public:
@@ -913,9 +908,7 @@ private:
lldb::addr_t m_watch_hit_addr;
};
-//----------------------------------------------------------------------
// StopInfoUnixSignal
-//----------------------------------------------------------------------
class StopInfoUnixSignal : public StopInfo {
public:
@@ -990,9 +983,7 @@ public:
}
};
-//----------------------------------------------------------------------
// StopInfoTrace
-//----------------------------------------------------------------------
class StopInfoTrace : public StopInfo {
public:
@@ -1010,9 +1001,7 @@ public:
}
};
-//----------------------------------------------------------------------
// StopInfoException
-//----------------------------------------------------------------------
class StopInfoException : public StopInfo {
public:
@@ -1034,9 +1023,7 @@ public:
}
};
-//----------------------------------------------------------------------
// StopInfoThreadPlan
-//----------------------------------------------------------------------
class StopInfoThreadPlan : public StopInfo {
public:
@@ -1079,9 +1066,7 @@ private:
ExpressionVariableSP m_expression_variable_sp;
};
-//----------------------------------------------------------------------
// StopInfoExec
-//----------------------------------------------------------------------
class StopInfoExec : public StopInfo {
public:
@@ -1211,7 +1196,7 @@ StopInfo::GetCrashingDereference(StopInfoSP &stop_info_sp,
address_loc += (sizeof(address_string) - 1);
- uint64_t address = strtoull(address_loc, 0, 0);
+ uint64_t address = strtoull(address_loc, nullptr, 0);
if (crashing_address) {
*crashing_address = address;
}
diff --git a/source/Target/StructuredDataPlugin.cpp b/source/Target/StructuredDataPlugin.cpp
index fe267e5e45a04..a22902d99f7c1 100644
--- a/source/Target/StructuredDataPlugin.cpp
+++ b/source/Target/StructuredDataPlugin.cpp
@@ -1,9 +1,8 @@
//===-- StructuredDataPlugin.cpp --------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -24,7 +23,7 @@ public:
"Parent for per-plugin structured data commands",
"plugin structured-data <plugin>") {}
- ~CommandStructuredData() {}
+ ~CommandStructuredData() override {}
};
}
@@ -33,7 +32,7 @@ StructuredDataPlugin::StructuredDataPlugin(const ProcessWP &process_wp)
StructuredDataPlugin::~StructuredDataPlugin() {}
-bool StructuredDataPlugin::GetEnabled(const ConstString &type_name) const {
+bool StructuredDataPlugin::GetEnabled(ConstString type_name) const {
// By default, plugins are always enabled. Plugin authors should override
// this if there is an enabled/disabled state for their plugin.
return true;
diff --git a/source/Target/SystemRuntime.cpp b/source/Target/SystemRuntime.cpp
index 574c01cb5ae1e..286bea09f854f 100644
--- a/source/Target/SystemRuntime.cpp
+++ b/source/Target/SystemRuntime.cpp
@@ -1,9 +1,8 @@
//===-- SystemRuntime.cpp ---------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -21,16 +20,14 @@ SystemRuntime *SystemRuntime::FindPlugin(Process *process) {
(create_callback = PluginManager::GetSystemRuntimeCreateCallbackAtIndex(
idx)) != nullptr;
++idx) {
- std::unique_ptr<SystemRuntime> instance_ap(create_callback(process));
- if (instance_ap)
- return instance_ap.release();
+ std::unique_ptr<SystemRuntime> instance_up(create_callback(process));
+ if (instance_up)
+ return instance_up.release();
}
return nullptr;
}
-//----------------------------------------------------------------------
// SystemRuntime constructor
-//----------------------------------------------------------------------
SystemRuntime::SystemRuntime(Process *process)
: m_process(process), m_types() {}
diff --git a/source/Target/Target.cpp b/source/Target/Target.cpp
index 437f92abdab3b..4941cb585c554 100644
--- a/source/Target/Target.cpp
+++ b/source/Target/Target.cpp
@@ -1,17 +1,15 @@
//===-- Target.cpp ----------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "lldb/Target/Target.h"
-#include "Plugins/ExpressionParser/Clang/ClangASTSource.h"
#include "Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.h"
-#include "Plugins/ExpressionParser/Clang/ClangPersistentVariables.h"
#include "lldb/Breakpoint/BreakpointIDList.h"
+#include "lldb/Breakpoint/BreakpointPrecondition.h"
#include "lldb/Breakpoint/BreakpointResolver.h"
#include "lldb/Breakpoint/BreakpointResolverAddress.h"
#include "lldb/Breakpoint/BreakpointResolverFileLine.h"
@@ -39,12 +37,12 @@
#include "lldb/Interpreter/OptionValues.h"
#include "lldb/Interpreter/Property.h"
#include "lldb/Symbol/ClangASTContext.h"
+#include "lldb/Symbol/ClangASTImporter.h"
#include "lldb/Symbol/Function.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/Symbol.h"
#include "lldb/Target/Language.h"
#include "lldb/Target/LanguageRuntime.h"
-#include "lldb/Target/ObjCLanguageRuntime.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/SectionLoadList.h"
#include "lldb/Target/StackFrame.h"
@@ -58,6 +56,10 @@
#include "lldb/Utility/State.h"
#include "lldb/Utility/StreamString.h"
#include "lldb/Utility/Timer.h"
+
+#include "llvm/ADT/ScopeExit.h"
+
+#include <memory>
#include <mutex>
using namespace lldb;
@@ -90,7 +92,7 @@ Target::Target(Debugger &debugger, const ArchSpec &target_arch,
m_breakpoint_list(false), m_internal_breakpoint_list(true),
m_watchpoint_list(), m_process_sp(), m_search_filter_sp(),
m_image_search_paths(ImageSearchPathsChanged, this), m_ast_importer_sp(),
- m_source_manager_ap(), m_stop_hooks(), m_stop_hook_next_id(0),
+ m_source_manager_up(), m_stop_hooks(), m_stop_hook_next_id(0),
m_valid(true), m_suppress_stop_hooks(false),
m_is_dummy_target(is_dummy_target),
m_stats_storage(static_cast<int>(StatisticKind::StatisticMax))
@@ -498,12 +500,13 @@ Target::GetSearchFilterForModule(const FileSpec *containingModule) {
if (containingModule != nullptr) {
// TODO: We should look into sharing module based search filters
// across many breakpoints like we do for the simple target based one
- filter_sp.reset(
- new SearchFilterByModule(shared_from_this(), *containingModule));
+ filter_sp = std::make_shared<SearchFilterByModule>(shared_from_this(),
+ *containingModule);
} else {
if (!m_search_filter_sp)
- m_search_filter_sp.reset(
- new SearchFilterForUnconstrainedSearches(shared_from_this()));
+ m_search_filter_sp =
+ std::make_shared<SearchFilterForUnconstrainedSearches>(
+ shared_from_this());
filter_sp = m_search_filter_sp;
}
return filter_sp;
@@ -515,12 +518,13 @@ Target::GetSearchFilterForModuleList(const FileSpecList *containingModules) {
if (containingModules && containingModules->GetSize() != 0) {
// TODO: We should look into sharing module based search filters
// across many breakpoints like we do for the simple target based one
- filter_sp.reset(
- new SearchFilterByModuleList(shared_from_this(), *containingModules));
+ filter_sp = std::make_shared<SearchFilterByModuleList>(shared_from_this(),
+ *containingModules);
} else {
if (!m_search_filter_sp)
- m_search_filter_sp.reset(
- new SearchFilterForUnconstrainedSearches(shared_from_this()));
+ m_search_filter_sp =
+ std::make_shared<SearchFilterForUnconstrainedSearches>(
+ shared_from_this());
filter_sp = m_search_filter_sp;
}
return filter_sp;
@@ -537,11 +541,11 @@ SearchFilterSP Target::GetSearchFilterForModuleAndCUList(
// We could make a special "CU List only SearchFilter". Better yet was if
// these could be composable, but that will take a little reworking.
- filter_sp.reset(new SearchFilterByModuleListAndCU(
- shared_from_this(), FileSpecList(), *containingSourceFiles));
+ filter_sp = std::make_shared<SearchFilterByModuleListAndCU>(
+ shared_from_this(), FileSpecList(), *containingSourceFiles);
} else {
- filter_sp.reset(new SearchFilterByModuleListAndCU(
- shared_from_this(), *containingModules, *containingSourceFiles));
+ filter_sp = std::make_shared<SearchFilterByModuleListAndCU>(
+ shared_from_this(), *containingModules, *containingSourceFiles);
}
return filter_sp;
}
@@ -569,8 +573,7 @@ Target::CreateExceptionBreakpoint(enum lldb::LanguageType language,
BreakpointSP exc_bkpt_sp = LanguageRuntime::CreateExceptionBreakpoint(
*this, language, catch_bp, throw_bp, internal);
if (exc_bkpt_sp && additional_args) {
- Breakpoint::BreakpointPreconditionSP precondition_sp =
- exc_bkpt_sp->GetPrecondition();
+ BreakpointPreconditionSP precondition_sp = exc_bkpt_sp->GetPrecondition();
if (precondition_sp && additional_args) {
if (error)
*error = precondition_sp->ConfigurePrecondition(*additional_args);
@@ -605,19 +608,17 @@ Target::CreateScriptedBreakpoint(const llvm::StringRef class_name,
} else if (has_modules) {
filter_sp = GetSearchFilterForModuleList(containingModules);
} else {
- filter_sp.reset(new SearchFilterForUnconstrainedSearches(shared_from_this()));
+ filter_sp = std::make_shared<SearchFilterForUnconstrainedSearches>(
+ shared_from_this());
}
StructuredDataImpl *extra_args_impl = new StructuredDataImpl();
if (extra_args_sp)
extra_args_impl->SetObjectSP(extra_args_sp);
-
- BreakpointResolverSP resolver_sp(new
- BreakpointResolverScripted(nullptr, class_name,
- depth,
- extra_args_impl,
- *GetDebugger().GetCommandInterpreter()
- .GetScriptInterpreter()));
+
+ BreakpointResolverSP resolver_sp(new BreakpointResolverScripted(
+ nullptr, class_name, depth, extra_args_impl,
+ *GetDebugger().GetScriptInterpreter()));
return CreateBreakpoint(filter_sp, resolver_sp, internal, false, true);
}
@@ -697,7 +698,7 @@ void Target::AddBreakpointName(BreakpointName *bp_name) {
m_breakpoint_names.insert(std::make_pair(bp_name->GetName(), bp_name));
}
-BreakpointName *Target::FindBreakpointName(const ConstString &name,
+BreakpointName *Target::FindBreakpointName(ConstString name,
bool can_create,
Status &error)
{
@@ -722,7 +723,7 @@ BreakpointName *Target::FindBreakpointName(const ConstString &name,
}
void
-Target::DeleteBreakpointName(const ConstString &name)
+Target::DeleteBreakpointName(ConstString name)
{
BreakpointNameList::iterator iter = m_breakpoint_names.find(name);
@@ -735,7 +736,7 @@ Target::DeleteBreakpointName(const ConstString &name)
}
void Target::RemoveNameFromBreakpoint(lldb::BreakpointSP &bp_sp,
- const ConstString &name)
+ ConstString name)
{
bp_sp->RemoveName(name.AsCString());
}
@@ -848,7 +849,7 @@ WatchpointSP Target::CreateWatchpoint(lldb::addr_t addr, size_t size,
}
if (!wp_sp) {
- wp_sp.reset(new Watchpoint(*this, addr, size, type));
+ wp_sp = std::make_shared<Watchpoint>(*this, addr, size, type);
wp_sp->SetWatchpointType(kind, notify);
m_watchpoint_list.Add(wp_sp, true);
}
@@ -1025,7 +1026,7 @@ Status Target::SerializeBreakpointsToFile(const FileSpec &file,
}
if (!break_store_ptr) {
- break_store_sp.reset(new StructuredData::Array());
+ break_store_sp = std::make_shared<StructuredData::Array>();
break_store_ptr = break_store_sp.get();
}
@@ -1438,7 +1439,8 @@ void Target::SetExecutableModule(ModuleSP &executable_sp,
"Target::SetExecutableModule (executable = '%s')",
executable_sp->GetFileSpec().GetPath().c_str());
- m_images.Append(executable_sp); // The first image is our executable file
+ const bool notify = true;
+ m_images.Append(executable_sp, notify); // The first image is our executable file
// If we haven't set an architecture yet, reset our architecture based on
// what we found in the executable module.
@@ -1466,6 +1468,7 @@ void Target::SetExecutableModule(ModuleSP &executable_sp,
}
if (executable_objfile && load_dependents) {
+ ModuleList added_modules;
executable_objfile->GetDependentModules(dependent_files);
for (uint32_t i = 0; i < dependent_files.GetSize(); i++) {
FileSpec dependent_file_spec(
@@ -1478,13 +1481,16 @@ void Target::SetExecutableModule(ModuleSP &executable_sp,
platform_dependent_file_spec = dependent_file_spec;
ModuleSpec module_spec(platform_dependent_file_spec, m_arch.GetSpec());
- ModuleSP image_module_sp(GetSharedModule(module_spec));
+ ModuleSP image_module_sp(GetOrCreateModule(module_spec,
+ false /* notify */));
if (image_module_sp) {
+ added_modules.AppendIfNeeded (image_module_sp, false);
ObjectFile *objfile = image_module_sp->GetObjectFile();
if (objfile)
objfile->GetDependentModules(dependent_files);
}
}
+ ModulesDidLoad(added_modules);
}
}
}
@@ -1565,8 +1571,9 @@ bool Target::SetArchitecture(const ArchSpec &arch_spec, bool set_platform) {
arch_spec.GetArchitectureName(),
arch_spec.GetTriple().getTriple().c_str());
ModuleSpec module_spec(executable_sp->GetFileSpec(), other);
+ FileSpecList search_paths = GetExecutableSearchPaths();
Status error = ModuleList::GetSharedModule(module_spec, executable_sp,
- &GetExecutableSearchPaths(),
+ &search_paths,
nullptr, nullptr);
if (!error.Fail() && executable_sp) {
@@ -1602,20 +1609,19 @@ bool Target::MergeArchitecture(const ArchSpec &arch_spec) {
return false;
}
-void Target::WillClearList(const ModuleList &module_list) {}
+void Target::NotifyWillClearList(const ModuleList &module_list) {}
-void Target::ModuleAdded(const ModuleList &module_list,
+void Target::NotifyModuleAdded(const ModuleList &module_list,
const ModuleSP &module_sp) {
// A module is being added to this target for the first time
if (m_valid) {
ModuleList my_module_list;
my_module_list.Append(module_sp);
- LoadScriptingResourceForModule(module_sp, this);
ModulesDidLoad(my_module_list);
}
}
-void Target::ModuleRemoved(const ModuleList &module_list,
+void Target::NotifyModuleRemoved(const ModuleList &module_list,
const ModuleSP &module_sp) {
// A module is being removed from this target.
if (m_valid) {
@@ -1625,7 +1631,7 @@ void Target::ModuleRemoved(const ModuleList &module_list,
}
}
-void Target::ModuleUpdated(const ModuleList &module_list,
+void Target::NotifyModuleUpdated(const ModuleList &module_list,
const ModuleSP &old_module_sp,
const ModuleSP &new_module_sp) {
// A module is replacing an already added module
@@ -1637,8 +1643,18 @@ void Target::ModuleUpdated(const ModuleList &module_list,
}
}
+void Target::NotifyModulesRemoved(lldb_private::ModuleList &module_list) {
+ ModulesDidUnload (module_list, false);
+}
+
+
void Target::ModulesDidLoad(ModuleList &module_list) {
- if (m_valid && module_list.GetSize()) {
+ const size_t num_images = module_list.GetSize();
+ if (m_valid && num_images) {
+ for (size_t idx = 0; idx < num_images; ++idx) {
+ ModuleSP module_sp(module_list.GetModuleAtIndex(idx));
+ LoadScriptingResourceForModule(module_sp, this);
+ }
m_breakpoint_list.UpdateBreakpoints(module_list, true, false);
m_internal_breakpoint_list.UpdateBreakpoints(module_list, true, false);
if (m_process_sp) {
@@ -1652,11 +1668,8 @@ void Target::ModulesDidLoad(ModuleList &module_list) {
void Target::SymbolsDidLoad(ModuleList &module_list) {
if (m_valid && module_list.GetSize()) {
if (m_process_sp) {
- LanguageRuntime *runtime =
- m_process_sp->GetLanguageRuntime(lldb::eLanguageTypeObjC);
- if (runtime) {
- ObjCLanguageRuntime *objc_runtime = (ObjCLanguageRuntime *)runtime;
- objc_runtime->SymbolsDidLoad(module_list);
+ for (LanguageRuntime *runtime : m_process_sp->GetLanguageRuntimes()) {
+ runtime->SymbolsDidLoad(module_list);
}
}
@@ -1840,7 +1853,7 @@ size_t Target::ReadCStringFromMemory(const Address &addr, std::string &out_str,
out_str.clear();
addr_t curr_addr = addr.GetLoadAddress(this);
Address address(addr);
- while (1) {
+ while (true) {
size_t length = ReadCStringFromMemory(address, buf, sizeof(buf), error);
if (length == 0)
break;
@@ -1980,8 +1993,8 @@ bool Target::ReadPointerFromMemory(const Address &addr, bool prefer_file_cache,
return false;
}
-ModuleSP Target::GetSharedModule(const ModuleSpec &module_spec,
- Status *error_ptr) {
+ModuleSP Target::GetOrCreateModule(const ModuleSpec &module_spec, bool notify,
+ Status *error_ptr) {
ModuleSP module_sp;
Status error;
@@ -1997,7 +2010,7 @@ ModuleSP Target::GetSharedModule(const ModuleSpec &module_spec,
ModuleSP old_module_sp; // This will get filled in if we have a new version
// of the library
bool did_create_module = false;
-
+ FileSpecList search_paths = GetExecutableSearchPaths();
// If there are image search path entries, try to use them first to acquire
// a suitable image.
if (m_image_search_paths.GetSize()) {
@@ -2008,7 +2021,7 @@ ModuleSP Target::GetSharedModule(const ModuleSpec &module_spec,
transformed_spec.GetFileSpec().GetFilename() =
module_spec.GetFileSpec().GetFilename();
error = ModuleList::GetSharedModule(transformed_spec, module_sp,
- &GetExecutableSearchPaths(),
+ &search_paths,
&old_module_sp, &did_create_module);
}
}
@@ -2025,7 +2038,7 @@ ModuleSP Target::GetSharedModule(const ModuleSpec &module_spec,
if (module_spec.GetUUID().IsValid()) {
// We have a UUID, it is OK to check the global module list...
error = ModuleList::GetSharedModule(module_spec, module_sp,
- &GetExecutableSearchPaths(),
+ &search_paths,
&old_module_sp, &did_create_module);
}
@@ -2035,7 +2048,7 @@ ModuleSP Target::GetSharedModule(const ModuleSpec &module_spec,
if (m_platform_sp) {
error = m_platform_sp->GetSharedModule(
module_spec, m_process_sp.get(), module_sp,
- &GetExecutableSearchPaths(), &old_module_sp, &did_create_module);
+ &search_paths, &old_module_sp, &did_create_module);
} else {
error.SetErrorString("no platform is currently set");
}
@@ -2114,8 +2127,9 @@ ModuleSP Target::GetSharedModule(const ModuleSpec &module_spec,
Module *old_module_ptr = old_module_sp.get();
old_module_sp.reset();
ModuleList::RemoveSharedModuleIfOrphaned(old_module_ptr);
- } else
- m_images.Append(module_sp);
+ } else {
+ m_images.Append(module_sp, notify);
+ }
} else
module_sp.reset();
}
@@ -2200,7 +2214,8 @@ Target::GetPersistentExpressionStateForLanguage(lldb::LanguageType language) {
UserExpression *Target::GetUserExpressionForLanguage(
llvm::StringRef expr, llvm::StringRef prefix, lldb::LanguageType language,
Expression::ResultType desired_type,
- const EvaluateExpressionOptions &options, Status &error) {
+ const EvaluateExpressionOptions &options,
+ ValueObject *ctx_obj, Status &error) {
Status type_system_error;
TypeSystem *type_system =
@@ -2216,7 +2231,7 @@ UserExpression *Target::GetUserExpressionForLanguage(
}
user_expr = type_system->GetUserExpression(expr, prefix, language,
- desired_type, options);
+ desired_type, options, ctx_obj);
if (!user_expr)
error.SetErrorStringWithFormat(
"Could not create an expression for language %s",
@@ -2290,7 +2305,7 @@ ClangASTContext *Target::GetScratchClangASTContext(bool create_on_demand) {
ClangASTImporterSP Target::GetClangASTImporter() {
if (m_valid) {
if (!m_ast_importer_sp) {
- m_ast_importer_sp.reset(new ClangASTImporter());
+ m_ast_importer_sp = std::make_shared<ClangASTImporter>();
}
return m_ast_importer_sp;
}
@@ -2315,13 +2330,6 @@ FileSpecList Target::GetDefaultDebugFileSearchPaths() {
return FileSpecList();
}
-FileSpecList Target::GetDefaultClangModuleSearchPaths() {
- TargetPropertiesSP properties_sp(Target::GetGlobalProperties());
- if (properties_sp)
- return properties_sp->GetClangModuleSearchPaths();
- return FileSpecList();
-}
-
ArchSpec Target::GetDefaultArchitecture() {
TargetPropertiesSP properties_sp(Target::GetGlobalProperties());
if (properties_sp)
@@ -2357,7 +2365,8 @@ Target *Target::GetTargetFromContexts(const ExecutionContext *exe_ctx_ptr,
ExpressionResults Target::EvaluateExpression(
llvm::StringRef expr, ExecutionContextScope *exe_scope,
lldb::ValueObjectSP &result_valobj_sp,
- const EvaluateExpressionOptions &options, std::string *fixed_expression) {
+ const EvaluateExpressionOptions &options, std::string *fixed_expression,
+ ValueObject *ctx_obj) {
result_valobj_sp.reset();
ExpressionResults execution_results = eExpressionSetupError;
@@ -2365,10 +2374,11 @@ ExpressionResults Target::EvaluateExpression(
if (expr.empty())
return execution_results;
- // We shouldn't run stop hooks in expressions. Be sure to reset this if you
- // return anywhere within this function.
+ // We shouldn't run stop hooks in expressions.
bool old_suppress_value = m_suppress_stop_hooks;
m_suppress_stop_hooks = true;
+ auto on_exit = llvm::make_scope_exit([this, old_suppress_value]() {
+ m_suppress_stop_hooks = old_suppress_value; });
ExecutionContext exe_ctx;
@@ -2395,19 +2405,18 @@ ExpressionResults Target::EvaluateExpression(
} else {
llvm::StringRef prefix = GetExpressionPrefixContents();
Status error;
- execution_results = UserExpression::Evaluate(exe_ctx, options, expr, prefix,
- result_valobj_sp, error,
- 0, // Line Number
- fixed_expression);
+ execution_results =
+ UserExpression::Evaluate(exe_ctx, options, expr, prefix,
+ result_valobj_sp, error, fixed_expression,
+ nullptr, // Module
+ ctx_obj);
}
- m_suppress_stop_hooks = old_suppress_value;
-
return execution_results;
}
lldb::ExpressionVariableSP
-Target::GetPersistentVariable(const ConstString &name) {
+Target::GetPersistentVariable(ConstString name) {
lldb::ExpressionVariableSP variable_sp;
m_scratch_type_system_map.ForEach(
[name, &variable_sp](TypeSystem *type_system) -> bool {
@@ -2423,7 +2432,7 @@ Target::GetPersistentVariable(const ConstString &name) {
return variable_sp;
}
-lldb::addr_t Target::GetPersistentSymbol(const ConstString &name) {
+lldb::addr_t Target::GetPersistentSymbol(ConstString name) {
lldb::addr_t address = LLDB_INVALID_ADDRESS;
m_scratch_type_system_map.ForEach(
@@ -2460,9 +2469,9 @@ lldb::addr_t Target::GetBreakableLoadAddress(lldb::addr_t addr) {
}
SourceManager &Target::GetSourceManager() {
- if (!m_source_manager_ap)
- m_source_manager_ap.reset(new SourceManager(shared_from_this()));
- return *m_source_manager_ap;
+ if (!m_source_manager_up)
+ m_source_manager_up.reset(new SourceManager(shared_from_this()));
+ return *m_source_manager_up;
}
ClangModulesDeclVendor *Target::GetClangModulesDeclVendor() {
@@ -2473,13 +2482,13 @@ ClangModulesDeclVendor *Target::GetClangModulesDeclVendor() {
{
std::lock_guard<std::mutex> guard(s_clang_modules_decl_vendor_mutex);
- if (!m_clang_modules_decl_vendor_ap) {
- m_clang_modules_decl_vendor_ap.reset(
+ if (!m_clang_modules_decl_vendor_up) {
+ m_clang_modules_decl_vendor_up.reset(
ClangModulesDeclVendor::Create(*this));
}
}
- return m_clang_modules_decl_vendor_ap.get();
+ return m_clang_modules_decl_vendor_up.get();
}
Target::StopHookSP Target::CreateStopHook() {
@@ -2546,12 +2555,14 @@ void Target::RunStopHooks() {
StopHookCollection::iterator pos, end = m_stop_hooks.end();
- // If there aren't any active stop hooks, don't bother either:
+ // If there aren't any active stop hooks, don't bother either.
+ // Also see if any of the active hooks want to auto-continue.
bool any_active_hooks = false;
- for (pos = m_stop_hooks.begin(); pos != end; pos++) {
- if ((*pos).second->IsActive()) {
+ bool auto_continue = false;
+ for (auto hook : m_stop_hooks) {
+ if (hook.second->IsActive()) {
any_active_hooks = true;
- break;
+ auto_continue |= hook.second->GetAutoContinue();
}
}
if (!any_active_hooks)
@@ -2587,6 +2598,7 @@ void Target::RunStopHooks() {
bool hooks_ran = false;
bool print_hook_header = (m_stop_hooks.size() != 1);
bool print_thread_header = (num_exe_ctx != 1);
+ bool did_restart = false;
for (pos = m_stop_hooks.begin(); keep_going && pos != end; pos++) {
// result.Clear();
@@ -2629,12 +2641,16 @@ void Target::RunStopHooks() {
options.SetStopOnError(true);
options.SetEchoCommands(false);
options.SetPrintResults(true);
+ options.SetPrintErrors(true);
options.SetAddToHistory(false);
+ // Force Async:
+ bool old_async = GetDebugger().GetAsyncExecution();
+ GetDebugger().SetAsyncExecution(true);
GetDebugger().GetCommandInterpreter().HandleCommands(
cur_hook_sp->GetCommands(), &exc_ctx_with_reasons[i], options,
result);
-
+ GetDebugger().SetAsyncExecution(old_async);
// If the command started the target going again, we should bag out of
// running the stop hooks.
if ((result.GetStatus() == eReturnStatusSuccessContinuingNoResult) ||
@@ -2643,13 +2659,19 @@ void Target::RunStopHooks() {
StopHookCollection::iterator tmp = pos;
if (++tmp != end)
result.AppendMessageWithFormat("\nAborting stop hooks, hook %" PRIu64
- " set the program running.\n",
+ " set the program running.\n"
+ " Consider using '-G true' to make "
+ "stop hooks auto-continue.\n",
cur_hook_sp->GetID());
keep_going = false;
+ did_restart = true;
}
}
}
}
+ // Finally, if auto-continue was requested, do it now:
+ if (!did_restart && auto_continue)
+ m_process_sp->PrivateResume();
result.GetImmediateOutputStream()->Flush();
result.GetImmediateErrorStream()->Flush();
@@ -2906,17 +2928,11 @@ Status Target::Launch(ProcessLaunchInfo &launch_info, Stream *stream) {
if (state == eStateStopped) {
if (!launch_info.GetFlags().Test(eLaunchFlagStopAtEntry)) {
if (synchronous_execution) {
- error = m_process_sp->PrivateResume();
- if (error.Success()) {
- state = m_process_sp->WaitForProcessToStop(
- llvm::None, nullptr, true, hijack_listener_sp, stream);
- const bool must_be_alive =
- false; // eStateExited is ok, so this must be false
- if (!StateIsStoppedState(state, must_be_alive)) {
- error.SetErrorStringWithFormat("process isn't stopped: %s",
- StateAsCString(state));
- }
- }
+ // Now we have handled the stop-from-attach, and we are just switching
+ // to a synchronous resume. So we should switch to the SyncResume
+ // hijacker.
+ m_process_sp->RestoreProcessEvents();
+ m_process_sp->ResumeSynchronous(stream);
} else {
m_process_sp->RestoreProcessEvents();
error = m_process_sp->PrivateResume();
@@ -3130,19 +3146,18 @@ void Target::FinalizeFileActions(ProcessLaunchInfo &info) {
}
}
-//--------------------------------------------------------------
// Target::StopHook
-//--------------------------------------------------------------
Target::StopHook::StopHook(lldb::TargetSP target_sp, lldb::user_id_t uid)
: UserID(uid), m_target_sp(target_sp), m_commands(), m_specifier_sp(),
- m_thread_spec_ap(), m_active(true) {}
+ m_thread_spec_up() {}
Target::StopHook::StopHook(const StopHook &rhs)
: UserID(rhs.GetID()), m_target_sp(rhs.m_target_sp),
m_commands(rhs.m_commands), m_specifier_sp(rhs.m_specifier_sp),
- m_thread_spec_ap(), m_active(rhs.m_active) {
- if (rhs.m_thread_spec_ap)
- m_thread_spec_ap.reset(new ThreadSpec(*rhs.m_thread_spec_ap.get()));
+ m_thread_spec_up(), m_active(rhs.m_active),
+ m_auto_continue(rhs.m_auto_continue) {
+ if (rhs.m_thread_spec_up)
+ m_thread_spec_up.reset(new ThreadSpec(*rhs.m_thread_spec_up));
}
Target::StopHook::~StopHook() = default;
@@ -3152,7 +3167,7 @@ void Target::StopHook::SetSpecifier(SymbolContextSpecifier *specifier) {
}
void Target::StopHook::SetThreadSpecifier(ThreadSpec *specifier) {
- m_thread_spec_ap.reset(specifier);
+ m_thread_spec_up.reset(specifier);
}
void Target::StopHook::GetDescription(Stream *s,
@@ -3167,6 +3182,9 @@ void Target::StopHook::GetDescription(Stream *s,
else
s->Indent("State: disabled\n");
+ if (m_auto_continue)
+ s->Indent("AutoContinue on\n");
+
if (m_specifier_sp) {
s->Indent();
s->PutCString("Specifier:\n");
@@ -3175,10 +3193,10 @@ void Target::StopHook::GetDescription(Stream *s,
s->SetIndentLevel(indent_level + 2);
}
- if (m_thread_spec_ap) {
+ if (m_thread_spec_up) {
StreamString tmp;
s->Indent("Thread:\n");
- m_thread_spec_ap->GetDescription(&tmp, level);
+ m_thread_spec_up->GetDescription(&tmp, level);
s->SetIndentLevel(indent_level + 4);
s->Indent(tmp.GetString());
s->PutCString("\n");
@@ -3195,9 +3213,7 @@ void Target::StopHook::GetDescription(Stream *s,
s->SetIndentLevel(indent_level);
}
-//--------------------------------------------------------------
// class TargetProperties
-//--------------------------------------------------------------
// clang-format off
static constexpr OptionEnumValueElement g_dynamic_value_types[] = {
@@ -3225,11 +3241,11 @@ static constexpr OptionEnumValueElement g_inline_breakpoint_enums[] = {
"Always look for inline breakpoint locations when setting file and line "
"breakpoints (slower but most accurate)."} };
-typedef enum x86DisassemblyFlavor {
+enum x86DisassemblyFlavor {
eX86DisFlavorDefault,
eX86DisFlavorIntel,
eX86DisFlavorATT
-} x86DisassemblyFlavor;
+};
static constexpr OptionEnumValueElement g_x86_dis_flavor_value_types[] = {
{eX86DisFlavorDefault, "default", "Disassembler default (currently att)."},
@@ -3310,6 +3326,9 @@ static constexpr PropertyDefinition g_properties[] = {
{"auto-import-clang-modules", OptionValue::eTypeBoolean, false, true,
nullptr, {},
"Automatically load Clang modules referred to by the program."},
+ {"import-std-module", OptionValue::eTypeBoolean, false, false,
+ nullptr, {},
+ "Import the C++ std module to improve debugging STL containers."},
{"auto-apply-fixits", OptionValue::eTypeBoolean, false, true, nullptr,
{}, "Automatically apply fix-it hints to expressions."},
{"notify-about-fixits", OptionValue::eTypeBoolean, false, true, nullptr,
@@ -3448,6 +3467,7 @@ enum {
ePropertyDebugFileSearchPaths,
ePropertyClangModuleSearchPaths,
ePropertyAutoImportClangModules,
+ ePropertyImportStdModule,
ePropertyAutoApplyFixIts,
ePropertyNotifyAboutFixIts,
ePropertySaveObjects,
@@ -3485,7 +3505,7 @@ enum {
class TargetOptionValueProperties : public OptionValueProperties {
public:
- TargetOptionValueProperties(const ConstString &name)
+ TargetOptionValueProperties(ConstString name)
: OptionValueProperties(name), m_target(nullptr), m_got_host_env(false) {}
// This constructor is used when creating TargetOptionValueProperties when it
@@ -3554,9 +3574,7 @@ protected:
mutable bool m_got_host_env;
};
-//----------------------------------------------------------------------
// TargetProperties
-//----------------------------------------------------------------------
static constexpr PropertyDefinition g_experimental_properties[]{
{"inject-local-vars", OptionValue::eTypeBoolean, true, true, nullptr,
{},
@@ -3582,14 +3600,12 @@ TargetExperimentalProperties::TargetExperimentalProperties()
m_collection_sp->Initialize(g_experimental_properties);
}
-//----------------------------------------------------------------------
// TargetProperties
-//----------------------------------------------------------------------
TargetProperties::TargetProperties(Target *target)
: Properties(), m_launch_info() {
if (target) {
- m_collection_sp.reset(
- new TargetOptionValueProperties(target, Target::GetGlobalProperties()));
+ m_collection_sp = std::make_shared<TargetOptionValueProperties>(
+ target, Target::GetGlobalProperties());
// Set callbacks to update launch_info whenever "settins set" updated any
// of these properties
@@ -3637,8 +3653,8 @@ TargetProperties::TargetProperties(Target *target)
DisableASLRValueChangedCallback(this, nullptr);
DisableSTDIOValueChangedCallback(this, nullptr);
} else {
- m_collection_sp.reset(
- new TargetOptionValueProperties(ConstString("target")));
+ m_collection_sp =
+ std::make_shared<TargetOptionValueProperties>(ConstString("target"));
m_collection_sp->Initialize(g_properties);
m_experimental_properties_up.reset(new TargetExperimentalProperties());
m_collection_sp->AppendProperty(
@@ -3837,27 +3853,36 @@ PathMappingList &TargetProperties::GetSourcePathMap() const {
return option_value->GetCurrentValue();
}
-FileSpecList &TargetProperties::GetExecutableSearchPaths() {
+void TargetProperties::AppendExecutableSearchPaths(const FileSpec& dir) {
const uint32_t idx = ePropertyExecutableSearchPaths;
OptionValueFileSpecList *option_value =
m_collection_sp->GetPropertyAtIndexAsOptionValueFileSpecList(nullptr,
false, idx);
assert(option_value);
+ option_value->AppendCurrentValue(dir);
+}
+
+FileSpecList TargetProperties::GetExecutableSearchPaths() {
+ const uint32_t idx = ePropertyExecutableSearchPaths;
+ const OptionValueFileSpecList *option_value =
+ m_collection_sp->GetPropertyAtIndexAsOptionValueFileSpecList(nullptr,
+ false, idx);
+ assert(option_value);
return option_value->GetCurrentValue();
}
-FileSpecList &TargetProperties::GetDebugFileSearchPaths() {
+FileSpecList TargetProperties::GetDebugFileSearchPaths() {
const uint32_t idx = ePropertyDebugFileSearchPaths;
- OptionValueFileSpecList *option_value =
+ const OptionValueFileSpecList *option_value =
m_collection_sp->GetPropertyAtIndexAsOptionValueFileSpecList(nullptr,
false, idx);
assert(option_value);
return option_value->GetCurrentValue();
}
-FileSpecList &TargetProperties::GetClangModuleSearchPaths() {
+FileSpecList TargetProperties::GetClangModuleSearchPaths() {
const uint32_t idx = ePropertyClangModuleSearchPaths;
- OptionValueFileSpecList *option_value =
+ const OptionValueFileSpecList *option_value =
m_collection_sp->GetPropertyAtIndexAsOptionValueFileSpecList(nullptr,
false, idx);
assert(option_value);
@@ -3870,6 +3895,12 @@ bool TargetProperties::GetEnableAutoImportClangModules() const {
nullptr, idx, g_properties[idx].default_uint_value != 0);
}
+bool TargetProperties::GetEnableImportStdModule() const {
+ const uint32_t idx = ePropertyImportStdModule;
+ return m_collection_sp->GetPropertyAtIndexAsBoolean(
+ nullptr, idx, g_properties[idx].default_uint_value != 0);
+}
+
bool TargetProperties::GetEnableAutoApplyFixIts() const {
const uint32_t idx = ePropertyAutoApplyFixIts;
return m_collection_sp->GetPropertyAtIndexAsBoolean(
@@ -4176,9 +4207,7 @@ void TargetProperties::DisableSTDIOValueChangedCallback(
this_->m_launch_info.GetFlags().Clear(lldb::eLaunchFlagDisableSTDIO);
}
-//----------------------------------------------------------------------
// Target::TargetEventData
-//----------------------------------------------------------------------
Target::TargetEventData::TargetEventData(const lldb::TargetSP &target_sp)
: EventData(), m_target_sp(target_sp), m_module_list() {}
@@ -4189,7 +4218,7 @@ Target::TargetEventData::TargetEventData(const lldb::TargetSP &target_sp,
Target::TargetEventData::~TargetEventData() = default;
-const ConstString &Target::TargetEventData::GetFlavorString() {
+ConstString Target::TargetEventData::GetFlavorString() {
static ConstString g_flavor("Target::TargetEventData");
return g_flavor;
}
diff --git a/source/Target/TargetList.cpp b/source/Target/TargetList.cpp
index 5b262509cae79..7c7a36e97bbfe 100644
--- a/source/Target/TargetList.cpp
+++ b/source/Target/TargetList.cpp
@@ -1,9 +1,8 @@
//===-- TargetList.cpp ------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -35,9 +34,7 @@ ConstString &TargetList::GetStaticBroadcasterClass() {
return class_name;
}
-//----------------------------------------------------------------------
// TargetList constructor
-//----------------------------------------------------------------------
TargetList::TargetList(Debugger &debugger)
: Broadcaster(debugger.GetBroadcasterManager(),
TargetList::GetStaticBroadcasterClass().AsCString()),
@@ -45,9 +42,7 @@ TargetList::TargetList(Debugger &debugger)
CheckInWithManager();
}
-//----------------------------------------------------------------------
// Destructor
-//----------------------------------------------------------------------
TargetList::~TargetList() {
std::lock_guard<std::recursive_mutex> guard(m_target_list_mutex);
m_target_list.clear();
@@ -427,7 +422,7 @@ Status TargetList::CreateTargetInternal(Debugger &debugger,
if (file.GetDirectory()) {
FileSpec file_dir;
file_dir.GetDirectory() = file.GetDirectory();
- target_sp->GetExecutableSearchPaths().Append(file_dir);
+ target_sp->AppendExecutableSearchPaths(file_dir);
}
// Don't put the dummy target in the target list, it's held separately.
diff --git a/source/Target/Thread.cpp b/source/Target/Thread.cpp
index 569d7a0a0f9e2..7a6b49e552524 100644
--- a/source/Target/Thread.cpp
+++ b/source/Target/Thread.cpp
@@ -1,9 +1,8 @@
//===-- Thread.cpp ----------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -23,7 +22,7 @@
#include "lldb/Target/ABI.h"
#include "lldb/Target/DynamicLoader.h"
#include "lldb/Target/ExecutionContext.h"
-#include "lldb/Target/ObjCLanguageRuntime.h"
+#include "lldb/Target/LanguageRuntime.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/RegisterContext.h"
#include "lldb/Target/StackFrameRecognizer.h"
@@ -51,6 +50,8 @@
#include "lldb/Utility/StreamString.h"
#include "lldb/lldb-enumerations.h"
+#include <memory>
+
using namespace lldb;
using namespace lldb_private;
@@ -91,7 +92,7 @@ enum {
class ThreadOptionValueProperties : public OptionValueProperties {
public:
- ThreadOptionValueProperties(const ConstString &name)
+ ThreadOptionValueProperties(ConstString name)
: OptionValueProperties(name) {}
// This constructor is used when creating ThreadOptionValueProperties when it
@@ -122,12 +123,12 @@ public:
ThreadProperties::ThreadProperties(bool is_global) : Properties() {
if (is_global) {
- m_collection_sp.reset(
- new ThreadOptionValueProperties(ConstString("thread")));
+ m_collection_sp =
+ std::make_shared<ThreadOptionValueProperties>(ConstString("thread"));
m_collection_sp->Initialize(g_properties);
} else
- m_collection_sp.reset(
- new ThreadOptionValueProperties(Thread::GetGlobalProperties().get()));
+ m_collection_sp = std::make_shared<ThreadOptionValueProperties>(
+ Thread::GetGlobalProperties().get());
}
ThreadProperties::~ThreadProperties() = default;
@@ -137,9 +138,9 @@ const RegularExpression *ThreadProperties::GetSymbolsToAvoidRegexp() {
return m_collection_sp->GetPropertyAtIndexAsOptionValueRegex(nullptr, idx);
}
-FileSpecList &ThreadProperties::GetLibrariesToAvoid() const {
+FileSpecList ThreadProperties::GetLibrariesToAvoid() const {
const uint32_t idx = ePropertyStepAvoidLibraries;
- OptionValueFileSpecList *option_value =
+ const OptionValueFileSpecList *option_value =
m_collection_sp->GetPropertyAtIndexAsOptionValueFileSpecList(nullptr,
false, idx);
assert(option_value);
@@ -170,11 +171,9 @@ uint64_t ThreadProperties::GetMaxBacktraceDepth() const {
nullptr, idx, g_properties[idx].default_uint_value != 0);
}
-//------------------------------------------------------------------
// Thread Event Data
-//------------------------------------------------------------------
-const ConstString &Thread::ThreadEventData::GetFlavorString() {
+ConstString Thread::ThreadEventData::GetFlavorString() {
static ConstString g_flavor("Thread::ThreadEventData");
return g_flavor;
}
@@ -233,9 +232,7 @@ Thread::ThreadEventData::GetStackFrameFromEvent(const Event *event_ptr) {
return frame_sp;
}
-//------------------------------------------------------------------
// Thread class
-//------------------------------------------------------------------
ConstString &Thread::GetStaticBroadcasterClass() {
static ConstString class_name("lldb.thread");
@@ -255,7 +252,7 @@ Thread::Thread(Process &process, lldb::tid_t tid, bool use_invalid_index_id)
m_curr_frames_sp(), m_prev_frames_sp(),
m_resume_signal(LLDB_INVALID_SIGNAL_NUMBER),
m_resume_state(eStateRunning), m_temporary_resume_state(eStateRunning),
- m_unwinder_ap(), m_destroy_called(false),
+ m_unwinder_up(), m_destroy_called(false),
m_override_should_notify(eLazyBoolCalculate),
m_extended_info_fetched(false), m_extended_info() {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_OBJECT));
@@ -305,7 +302,7 @@ void Thread::DestroyThread() {
m_stop_info_sp.reset();
m_reg_context_sp.reset();
- m_unwinder_ap.reset();
+ m_unwinder_up.reset();
std::lock_guard<std::recursive_mutex> guard(m_frame_mutex);
m_curr_frames_sp.reset();
m_prev_frames_sp.reset();
@@ -561,8 +558,8 @@ bool Thread::RestoreRegisterStateFromCheckpoint(
// Clear out all stack frames as our world just changed.
ClearStackFrames();
reg_ctx_sp->InvalidateIfNeeded(true);
- if (m_unwinder_ap.get())
- m_unwinder_ap->Clear();
+ if (m_unwinder_up)
+ m_unwinder_up->Clear();
return ret;
}
}
@@ -856,7 +853,7 @@ bool Thread::ShouldStop(Event *event_ptr) {
// Otherwise, don't let the base plan override what the other plans say
// to do, since presumably if there were other plans they would know what
// to do...
- while (1) {
+ while (true) {
if (PlanIsBasePlan(current_plan))
break;
@@ -981,7 +978,7 @@ Vote Thread::ShouldReportStop(Event *event_ptr) {
} else {
Vote thread_vote = eVoteNoOpinion;
ThreadPlan *plan_ptr = GetCurrentPlan();
- while (1) {
+ while (true) {
if (plan_ptr->PlanExplainsStop(event_ptr)) {
thread_vote = plan_ptr->ShouldReportStop(event_ptr);
break;
@@ -1301,7 +1298,7 @@ void Thread::DiscardThreadPlans(bool force) {
return;
}
- while (1) {
+ while (true) {
int master_plan_idx;
bool discard = true;
@@ -1384,9 +1381,9 @@ ThreadPlanSP Thread::QueueThreadPlanForStepOverRange(
const SymbolContext &addr_context, lldb::RunMode stop_other_threads,
Status &status, LazyBool step_out_avoids_code_withoug_debug_info) {
ThreadPlanSP thread_plan_sp;
- thread_plan_sp.reset(new ThreadPlanStepOverRange(
+ thread_plan_sp = std::make_shared<ThreadPlanStepOverRange>(
*this, range, addr_context, stop_other_threads,
- step_out_avoids_code_withoug_debug_info));
+ step_out_avoids_code_withoug_debug_info);
status = QueueThreadPlan(thread_plan_sp, abort_other_plans);
return thread_plan_sp;
@@ -1398,10 +1395,12 @@ ThreadPlanSP Thread::QueueThreadPlanForStepOverRange(
bool abort_other_plans, const LineEntry &line_entry,
const SymbolContext &addr_context, lldb::RunMode stop_other_threads,
Status &status, LazyBool step_out_avoids_code_withoug_debug_info) {
+ const bool include_inlined_functions = true;
+ auto address_range =
+ line_entry.GetSameLineContiguousAddressRange(include_inlined_functions);
return QueueThreadPlanForStepOverRange(
- abort_other_plans, line_entry.GetSameLineContiguousAddressRange(),
- addr_context, stop_other_threads, status,
- step_out_avoids_code_withoug_debug_info);
+ abort_other_plans, address_range, addr_context, stop_other_threads,
+ status, step_out_avoids_code_withoug_debug_info);
}
ThreadPlanSP Thread::QueueThreadPlanForStepInRange(
@@ -1431,8 +1430,10 @@ ThreadPlanSP Thread::QueueThreadPlanForStepInRange(
lldb::RunMode stop_other_threads, Status &status,
LazyBool step_in_avoids_code_without_debug_info,
LazyBool step_out_avoids_code_without_debug_info) {
+ const bool include_inlined_functions = false;
return QueueThreadPlanForStepInRange(
- abort_other_plans, line_entry.GetSameLineContiguousAddressRange(),
+ abort_other_plans,
+ line_entry.GetSameLineContiguousAddressRange(include_inlined_functions),
addr_context, step_in_target, stop_other_threads, status,
step_in_avoids_code_without_debug_info,
step_out_avoids_code_without_debug_info);
@@ -1599,15 +1600,13 @@ void Thread::CalculateExecutionContext(ExecutionContext &exe_ctx) {
}
StackFrameListSP Thread::GetStackFrameList() {
- StackFrameListSP frame_list_sp;
std::lock_guard<std::recursive_mutex> guard(m_frame_mutex);
- if (m_curr_frames_sp) {
- frame_list_sp = m_curr_frames_sp;
- } else {
- frame_list_sp.reset(new StackFrameList(*this, m_prev_frames_sp, true));
- m_curr_frames_sp = frame_list_sp;
- }
- return frame_list_sp;
+
+ if (!m_curr_frames_sp)
+ m_curr_frames_sp =
+ std::make_shared<StackFrameList>(*this, m_prev_frames_sp, true);
+
+ return m_curr_frames_sp;
}
void Thread::ClearStackFrames() {
@@ -1678,7 +1677,7 @@ Status Thread::ReturnFromFrame(lldb::StackFrameSP frame_sp,
// FIXME: ValueObject::Cast doesn't currently work correctly, at least not
// for scalars.
// Turn that back on when that works.
- if (/* DISABLES CODE */ (0) && sc.function != nullptr) {
+ if (/* DISABLES CODE */ (false) && sc.function != nullptr) {
Type *function_type = sc.function->GetType();
if (function_type) {
CompilerType return_type =
@@ -2055,7 +2054,7 @@ size_t Thread::GetStackFrameStatus(Stream &strm, uint32_t first_frame,
}
Unwind *Thread::GetUnwinder() {
- if (!m_unwinder_ap) {
+ if (!m_unwinder_up) {
const ArchSpec target_arch(CalculateTarget()->GetArchitecture());
const llvm::Triple::ArchType machine = target_arch.GetMachine();
switch (machine) {
@@ -2073,16 +2072,16 @@ Unwind *Thread::GetUnwinder() {
case llvm::Triple::ppc64le:
case llvm::Triple::systemz:
case llvm::Triple::hexagon:
- m_unwinder_ap.reset(new UnwindLLDB(*this));
+ m_unwinder_up.reset(new UnwindLLDB(*this));
break;
default:
if (target_arch.GetTriple().getVendor() == llvm::Triple::Apple)
- m_unwinder_ap.reset(new UnwindMacOSXFrameBackchain(*this));
+ m_unwinder_up.reset(new UnwindMacOSXFrameBackchain(*this));
break;
}
}
- return m_unwinder_ap.get();
+ return m_unwinder_up.get();
}
void Thread::Flush() {
@@ -2210,25 +2209,27 @@ ValueObjectSP Thread::GetCurrentException() {
if (auto e = recognized_frame->GetExceptionObject())
return e;
- // FIXME: For now, only ObjC exceptions are supported. This should really
- // iterate over all language runtimes and ask them all to give us the current
- // exception.
- if (auto runtime = GetProcess()->GetObjCLanguageRuntime())
+ // NOTE: Even though this behavior is generalized, only ObjC is actually
+ // supported at the moment.
+ for (LanguageRuntime *runtime : GetProcess()->GetLanguageRuntimes()) {
if (auto e = runtime->GetExceptionObjectForThread(shared_from_this()))
return e;
+ }
return ValueObjectSP();
}
ThreadSP Thread::GetCurrentExceptionBacktrace() {
ValueObjectSP exception = GetCurrentException();
- if (!exception) return ThreadSP();
+ if (!exception)
+ return ThreadSP();
- // FIXME: For now, only ObjC exceptions are supported. This should really
- // iterate over all language runtimes and ask them all to give us the current
- // exception.
- auto runtime = GetProcess()->GetObjCLanguageRuntime();
- if (!runtime) return ThreadSP();
+ // NOTE: Even though this behavior is generalized, only ObjC is actually
+ // supported at the moment.
+ for (LanguageRuntime *runtime : GetProcess()->GetLanguageRuntimes()) {
+ if (auto bt = runtime->GetBacktraceThreadFromException(exception))
+ return bt;
+ }
- return runtime->GetBacktraceThreadFromException(exception);
+ return ThreadSP();
}
diff --git a/source/Target/ThreadCollection.cpp b/source/Target/ThreadCollection.cpp
index 2d63b67a6dbeb..cf3c1e2429999 100644
--- a/source/Target/ThreadCollection.cpp
+++ b/source/Target/ThreadCollection.cpp
@@ -1,9 +1,8 @@
//===-- ThreadCollection.cpp ------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include <stdlib.h>
diff --git a/source/Target/ThreadList.cpp b/source/Target/ThreadList.cpp
index 20c285963882e..afdfda3b0ae1a 100644
--- a/source/Target/ThreadList.cpp
+++ b/source/Target/ThreadList.cpp
@@ -1,9 +1,8 @@
//===-- ThreadList.cpp ------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -38,8 +37,10 @@ const ThreadList &ThreadList::operator=(const ThreadList &rhs) {
if (this != &rhs) {
// Lock both mutexes to make sure neither side changes anyone on us while
// the assignment occurs
- std::lock_guard<std::recursive_mutex> guard(GetMutex());
- std::lock_guard<std::recursive_mutex> rhs_guard(rhs.GetMutex());
+ std::lock(GetMutex(), rhs.GetMutex());
+ std::lock_guard<std::recursive_mutex> guard(GetMutex(), std::adopt_lock);
+ std::lock_guard<std::recursive_mutex> rhs_guard(rhs.GetMutex(),
+ std::adopt_lock);
m_process = rhs.m_process;
m_stop_id = rhs.m_stop_id;
diff --git a/source/Target/ThreadPlan.cpp b/source/Target/ThreadPlan.cpp
index 1f2c69c6e8a6b..1d8cc18db4d65 100644
--- a/source/Target/ThreadPlan.cpp
+++ b/source/Target/ThreadPlan.cpp
@@ -1,9 +1,8 @@
//===-- ThreadPlan.cpp ------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -19,9 +18,7 @@
using namespace lldb;
using namespace lldb_private;
-//----------------------------------------------------------------------
// ThreadPlan constructor
-//----------------------------------------------------------------------
ThreadPlan::ThreadPlan(ThreadPlanKind kind, const char *name, Thread &thread,
Vote stop_vote, Vote run_vote)
: m_thread(thread), m_stop_vote(stop_vote), m_run_vote(run_vote),
@@ -33,9 +30,7 @@ ThreadPlan::ThreadPlan(ThreadPlanKind kind, const char *name, Thread &thread,
SetID(GetNextID());
}
-//----------------------------------------------------------------------
// Destructor
-//----------------------------------------------------------------------
ThreadPlan::~ThreadPlan() = default;
bool ThreadPlan::PlanExplainsStop(Event *event_ptr) {
@@ -161,9 +156,7 @@ bool ThreadPlan::IsUsuallyUnexplainedStopReason(lldb::StopReason reason) {
}
}
-//----------------------------------------------------------------------
// ThreadPlanNull
-//----------------------------------------------------------------------
ThreadPlanNull::ThreadPlanNull(Thread &thread)
: ThreadPlan(ThreadPlan::eKindNull, "Null Thread Plan", thread,
diff --git a/source/Target/ThreadPlanBase.cpp b/source/Target/ThreadPlanBase.cpp
index 058d1468e2413..9cd4bcb455be9 100644
--- a/source/Target/ThreadPlanBase.cpp
+++ b/source/Target/ThreadPlanBase.cpp
@@ -1,9 +1,8 @@
//===-- ThreadPlanBase.cpp --------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -23,11 +22,9 @@
using namespace lldb;
using namespace lldb_private;
-//----------------------------------------------------------------------
// ThreadPlanBase: This one always stops, and never has anything particular to
// do.
// FIXME: The "signal handling" policies should probably go here.
-//----------------------------------------------------------------------
ThreadPlanBase::ThreadPlanBase(Thread &thread)
: ThreadPlan(ThreadPlan::eKindBase, "base plan", thread, eVoteYes,
diff --git a/source/Target/ThreadPlanCallFunction.cpp b/source/Target/ThreadPlanCallFunction.cpp
index 1131ec939b896..68d771c37946a 100644
--- a/source/Target/ThreadPlanCallFunction.cpp
+++ b/source/Target/ThreadPlanCallFunction.cpp
@@ -1,9 +1,8 @@
//===-- ThreadPlanCallFunction.cpp ------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -25,12 +24,12 @@
#include "lldb/Utility/Log.h"
#include "lldb/Utility/Stream.h"
+#include <memory>
+
using namespace lldb;
using namespace lldb_private;
-//----------------------------------------------------------------------
// ThreadPlanCallFunction: Plan to call a single function
-//----------------------------------------------------------------------
bool ThreadPlanCallFunction::ConstructorSetup(
Thread &thread, ABI *&abi, lldb::addr_t &start_load_addr,
lldb::addr_t &function_load_addr) {
@@ -405,8 +404,8 @@ void ThreadPlanCallFunction::DidPush() {
GetThread().SetStopInfoToNothing();
#ifndef SINGLE_STEP_EXPRESSIONS
- m_subplan_sp.reset(
- new ThreadPlanRunToAddress(m_thread, m_start_addr, m_stop_other_threads));
+ m_subplan_sp = std::make_shared<ThreadPlanRunToAddress>(
+ m_thread, m_start_addr, m_stop_other_threads);
m_thread.QueueThreadPlan(m_subplan_sp, false);
m_subplan_sp->SetPrivate(true);
diff --git a/source/Target/ThreadPlanCallFunctionUsingABI.cpp b/source/Target/ThreadPlanCallFunctionUsingABI.cpp
index 08604d2c411a4..3155e6f7965f9 100644
--- a/source/Target/ThreadPlanCallFunctionUsingABI.cpp
+++ b/source/Target/ThreadPlanCallFunctionUsingABI.cpp
@@ -1,9 +1,8 @@
//===-- ThreadPlanCallFunctionUsingABI.cpp ----------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -19,10 +18,8 @@
using namespace lldb;
using namespace lldb_private;
-//--------------------------------------------------------------------------------------------
// ThreadPlanCallFunctionUsingABI: Plan to call a single function using the ABI
// instead of JIT
-//-------------------------------------------------------------------------------------------
ThreadPlanCallFunctionUsingABI::ThreadPlanCallFunctionUsingABI(
Thread &thread, const Address &function, llvm::Type &prototype,
llvm::Type &return_type, llvm::ArrayRef<ABI::CallArgument> args,
diff --git a/source/Target/ThreadPlanCallOnFunctionExit.cpp b/source/Target/ThreadPlanCallOnFunctionExit.cpp
index 2ea083dac45e9..3330adc0c2afc 100644
--- a/source/Target/ThreadPlanCallOnFunctionExit.cpp
+++ b/source/Target/ThreadPlanCallOnFunctionExit.cpp
@@ -1,9 +1,8 @@
//===-- ThreadPlanCallOnFunctionExit.cpp ------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -41,9 +40,7 @@ void ThreadPlanCallOnFunctionExit::DidPush() {
);
}
-// -------------------------------------------------------------------------
// ThreadPlan API
-// -------------------------------------------------------------------------
void ThreadPlanCallOnFunctionExit::GetDescription(
Stream *s, lldb::DescriptionLevel level) {
diff --git a/source/Target/ThreadPlanCallUserExpression.cpp b/source/Target/ThreadPlanCallUserExpression.cpp
index 1fbd346feeead..864808a4b5ea3 100644
--- a/source/Target/ThreadPlanCallUserExpression.cpp
+++ b/source/Target/ThreadPlanCallUserExpression.cpp
@@ -1,9 +1,8 @@
//===-- ThreadPlanCallUserExpression.cpp -------------------------*- C++-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -14,7 +13,7 @@
#include "lldb/Breakpoint/BreakpointLocation.h"
#include "lldb/Core/Address.h"
#include "lldb/Expression/DiagnosticManager.h"
-#include "lldb/Expression/IRDynamicChecks.h"
+#include "lldb/Expression/DynamicCheckerFunctions.h"
#include "lldb/Expression/UserExpression.h"
#include "lldb/Host/HostInfo.h"
#include "lldb/Target/LanguageRuntime.h"
@@ -30,9 +29,7 @@
using namespace lldb;
using namespace lldb_private;
-//----------------------------------------------------------------------
// ThreadPlanCallUserExpression: Plan to call a single function
-//----------------------------------------------------------------------
ThreadPlanCallUserExpression::ThreadPlanCallUserExpression(
Thread &thread, Address &function, llvm::ArrayRef<lldb::addr_t> args,
diff --git a/source/Target/ThreadPlanPython.cpp b/source/Target/ThreadPlanPython.cpp
index 84b93bdc65833..8b30c4ea7cb15 100644
--- a/source/Target/ThreadPlanPython.cpp
+++ b/source/Target/ThreadPlanPython.cpp
@@ -1,9 +1,8 @@
//===-- ThreadPlanPython.cpp ------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -24,9 +23,7 @@
using namespace lldb;
using namespace lldb_private;
-//----------------------------------------------------------------------
// ThreadPlanPython
-//----------------------------------------------------------------------
ThreadPlanPython::ThreadPlanPython(Thread &thread, const char *class_name)
: ThreadPlan(ThreadPlan::eKindPython, "Python based Thread Plan", thread,
@@ -63,7 +60,6 @@ void ThreadPlanPython::DidPush() {
ScriptInterpreter *script_interp = m_thread.GetProcess()
->GetTarget()
.GetDebugger()
- .GetCommandInterpreter()
.GetScriptInterpreter();
if (script_interp) {
m_implementation_sp = script_interp->CreateScriptedThreadPlan(
@@ -83,7 +79,6 @@ bool ThreadPlanPython::ShouldStop(Event *event_ptr) {
ScriptInterpreter *script_interp = m_thread.GetProcess()
->GetTarget()
.GetDebugger()
- .GetCommandInterpreter()
.GetScriptInterpreter();
if (script_interp) {
bool script_error;
@@ -107,7 +102,6 @@ bool ThreadPlanPython::IsPlanStale() {
ScriptInterpreter *script_interp = m_thread.GetProcess()
->GetTarget()
.GetDebugger()
- .GetCommandInterpreter()
.GetScriptInterpreter();
if (script_interp) {
bool script_error;
@@ -131,7 +125,6 @@ bool ThreadPlanPython::DoPlanExplainsStop(Event *event_ptr) {
ScriptInterpreter *script_interp = m_thread.GetProcess()
->GetTarget()
.GetDebugger()
- .GetCommandInterpreter()
.GetScriptInterpreter();
if (script_interp) {
bool script_error;
@@ -170,7 +163,6 @@ lldb::StateType ThreadPlanPython::GetPlanRunState() {
ScriptInterpreter *script_interp = m_thread.GetProcess()
->GetTarget()
.GetDebugger()
- .GetCommandInterpreter()
.GetScriptInterpreter();
if (script_interp) {
bool script_error;
diff --git a/source/Target/ThreadPlanRunToAddress.cpp b/source/Target/ThreadPlanRunToAddress.cpp
index bd11f8b82f780..a973bd112796a 100644
--- a/source/Target/ThreadPlanRunToAddress.cpp
+++ b/source/Target/ThreadPlanRunToAddress.cpp
@@ -1,9 +1,8 @@
//===-- ThreadPlanRunToAddress.cpp ------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -18,9 +17,7 @@
using namespace lldb;
using namespace lldb_private;
-//----------------------------------------------------------------------
// ThreadPlanRunToAddress: Continue plan
-//----------------------------------------------------------------------
ThreadPlanRunToAddress::ThreadPlanRunToAddress(Thread &thread, Address &address,
bool stop_others)
diff --git a/source/Target/ThreadPlanShouldStopHere.cpp b/source/Target/ThreadPlanShouldStopHere.cpp
index 8062d8059c148..a0b7072a10719 100644
--- a/source/Target/ThreadPlanShouldStopHere.cpp
+++ b/source/Target/ThreadPlanShouldStopHere.cpp
@@ -1,9 +1,8 @@
//===-- ThreadPlanShouldStopHere.cpp ----------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -16,9 +15,7 @@
using namespace lldb;
using namespace lldb_private;
-//----------------------------------------------------------------------
// ThreadPlanShouldStopHere constructor
-//----------------------------------------------------------------------
ThreadPlanShouldStopHere::ThreadPlanShouldStopHere(ThreadPlan *owner)
: m_callbacks(), m_baton(nullptr), m_owner(owner),
m_flags(ThreadPlanShouldStopHere::eNone) {
@@ -133,7 +130,7 @@ ThreadPlanSP ThreadPlanShouldStopHere::DefaultStepFromHereCallback(
"Queueing StepInRange plan to step through line 0 code.");
return_plan_sp = current_plan->GetThread().QueueThreadPlanForStepInRange(
- false, range, sc, NULL, eOnlyDuringStepping, status,
+ false, range, sc, nullptr, eOnlyDuringStepping, status,
eLazyBoolCalculate, eLazyBoolNo);
}
}
diff --git a/source/Target/ThreadPlanStepInRange.cpp b/source/Target/ThreadPlanStepInRange.cpp
index 8f9889a9d68c3..2065fa55fa6aa 100644
--- a/source/Target/ThreadPlanStepInRange.cpp
+++ b/source/Target/ThreadPlanStepInRange.cpp
@@ -1,9 +1,8 @@
//===-- ThreadPlanStepInRange.cpp -------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -29,10 +28,8 @@ using namespace lldb_private;
uint32_t ThreadPlanStepInRange::s_default_flag_values =
ThreadPlanShouldStopHere::eStepInAvoidNoDebug;
-//----------------------------------------------------------------------
// ThreadPlanStepInRange: Step through a stack range, either stepping over or
// into based on the value of \a type.
-//----------------------------------------------------------------------
ThreadPlanStepInRange::ThreadPlanStepInRange(
Thread &thread, const AddressRange &range,
@@ -315,10 +312,10 @@ bool ThreadPlanStepInRange::ShouldStop(Event *event_ptr) {
void ThreadPlanStepInRange::SetAvoidRegexp(const char *name) {
auto name_ref = llvm::StringRef::withNullAsEmpty(name);
- if (!m_avoid_regexp_ap)
- m_avoid_regexp_ap.reset(new RegularExpression(name_ref));
+ if (!m_avoid_regexp_up)
+ m_avoid_regexp_up.reset(new RegularExpression(name_ref));
- m_avoid_regexp_ap->Compile(name_ref);
+ m_avoid_regexp_up->Compile(name_ref);
}
void ThreadPlanStepInRange::SetDefaultFlagValue(uint32_t new_value) {
@@ -351,7 +348,7 @@ bool ThreadPlanStepInRange::FrameMatchesAvoidCriteria() {
if (libraries_say_avoid)
return true;
- const RegularExpression *avoid_regexp_to_use = m_avoid_regexp_ap.get();
+ const RegularExpression *avoid_regexp_to_use = m_avoid_regexp_up.get();
if (avoid_regexp_to_use == nullptr)
avoid_regexp_to_use = GetThread().GetSymbolsToAvoidRegexp();
diff --git a/source/Target/ThreadPlanStepInstruction.cpp b/source/Target/ThreadPlanStepInstruction.cpp
index 7707454c97988..a11b623c8acfb 100644
--- a/source/Target/ThreadPlanStepInstruction.cpp
+++ b/source/Target/ThreadPlanStepInstruction.cpp
@@ -1,9 +1,8 @@
//===-- ThreadPlanStepInstruction.cpp ---------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -19,9 +18,7 @@
using namespace lldb;
using namespace lldb_private;
-//----------------------------------------------------------------------
// ThreadPlanStepInstruction: Step over the current instruction
-//----------------------------------------------------------------------
ThreadPlanStepInstruction::ThreadPlanStepInstruction(Thread &thread,
bool step_over,
diff --git a/source/Target/ThreadPlanStepOut.cpp b/source/Target/ThreadPlanStepOut.cpp
index 378de53fafd7d..bf55c376513dc 100644
--- a/source/Target/ThreadPlanStepOut.cpp
+++ b/source/Target/ThreadPlanStepOut.cpp
@@ -1,9 +1,8 @@
//===-- ThreadPlanStepOut.cpp -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -24,14 +23,14 @@
#include "lldb/Target/ThreadPlanStepThrough.h"
#include "lldb/Utility/Log.h"
+#include <memory>
+
using namespace lldb;
using namespace lldb_private;
uint32_t ThreadPlanStepOut::s_default_flag_values = 0;
-//----------------------------------------------------------------------
// ThreadPlanStepOut: Step out of the current frame
-//----------------------------------------------------------------------
ThreadPlanStepOut::ThreadPlanStepOut(
Thread &thread, SymbolContext *context, bool first_insn, bool stop_others,
Vote stop_vote, Vote run_vote, uint32_t frame_idx,
@@ -85,9 +84,9 @@ ThreadPlanStepOut::ThreadPlanStepOut(
if (frame_idx > 0) {
// First queue a plan that gets us to this inlined frame, and when we get
// there we'll queue a second plan that walks us out of this frame.
- m_step_out_to_inline_plan_sp.reset(new ThreadPlanStepOut(
+ m_step_out_to_inline_plan_sp = std::make_shared<ThreadPlanStepOut>(
m_thread, nullptr, false, stop_others, eVoteNoOpinion, eVoteNoOpinion,
- frame_idx - 1, eLazyBoolNo, continue_to_next_branch));
+ frame_idx - 1, eLazyBoolNo, continue_to_next_branch);
static_cast<ThreadPlanStepOut *>(m_step_out_to_inline_plan_sp.get())
->SetShouldStopHereCallbacks(nullptr, nullptr);
m_step_out_to_inline_plan_sp->SetPrivate(true);
@@ -111,8 +110,9 @@ ThreadPlanStepOut::ThreadPlanStepOut(
return_address_decr_pc.CalculateSymbolContext(
&return_address_sc, lldb::eSymbolContextLineEntry);
if (return_address_sc.line_entry.IsValid()) {
- range =
- return_address_sc.line_entry.GetSameLineContiguousAddressRange();
+ const bool include_inlined_functions = false;
+ range = return_address_sc.line_entry.GetSameLineContiguousAddressRange(
+ include_inlined_functions);
if (range.GetByteSize() > 0) {
return_address =
m_thread.GetProcess()->AdvanceAddressToNextBranchInstruction(
@@ -450,8 +450,9 @@ bool ThreadPlanStepOut::QueueInlinedStepPlan(bool queue_now) {
m_stop_others ? lldb::eOnlyThisThread : lldb::eAllThreads;
const LazyBool avoid_no_debug = eLazyBoolNo;
- m_step_through_inline_plan_sp.reset(new ThreadPlanStepOverRange(
- m_thread, inline_range, inlined_sc, run_mode, avoid_no_debug));
+ m_step_through_inline_plan_sp =
+ std::make_shared<ThreadPlanStepOverRange>(
+ m_thread, inline_range, inlined_sc, run_mode, avoid_no_debug);
ThreadPlanStepOverRange *step_through_inline_plan_ptr =
static_cast<ThreadPlanStepOverRange *>(
m_step_through_inline_plan_sp.get());
diff --git a/source/Target/ThreadPlanStepOverBreakpoint.cpp b/source/Target/ThreadPlanStepOverBreakpoint.cpp
index 8b24bf94973b5..4770b57ab7f2e 100644
--- a/source/Target/ThreadPlanStepOverBreakpoint.cpp
+++ b/source/Target/ThreadPlanStepOverBreakpoint.cpp
@@ -1,9 +1,8 @@
//===-- ThreadPlanStepOverBreakpoint.cpp ------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -17,10 +16,8 @@
using namespace lldb;
using namespace lldb_private;
-//----------------------------------------------------------------------
// ThreadPlanStepOverBreakpoint: Single steps over a breakpoint bp_site_sp at
// the pc.
-//----------------------------------------------------------------------
ThreadPlanStepOverBreakpoint::ThreadPlanStepOverBreakpoint(Thread &thread)
: ThreadPlan(
diff --git a/source/Target/ThreadPlanStepOverRange.cpp b/source/Target/ThreadPlanStepOverRange.cpp
index 129f30371f8d2..3aaeac9f5b21b 100644
--- a/source/Target/ThreadPlanStepOverRange.cpp
+++ b/source/Target/ThreadPlanStepOverRange.cpp
@@ -1,9 +1,8 @@
//===-- ThreadPlanStepOverRange.cpp -----------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -26,10 +25,8 @@ using namespace lldb;
uint32_t ThreadPlanStepOverRange::s_default_flag_values = 0;
-//----------------------------------------------------------------------
// ThreadPlanStepOverRange: Step through a stack range, either stepping over or
// into based on the value of \a type.
-//----------------------------------------------------------------------
ThreadPlanStepOverRange::ThreadPlanStepOverRange(
Thread &thread, const AddressRange &range,
diff --git a/source/Target/ThreadPlanStepRange.cpp b/source/Target/ThreadPlanStepRange.cpp
index 7ba68ee84981b..49c72dbf09115 100644
--- a/source/Target/ThreadPlanStepRange.cpp
+++ b/source/Target/ThreadPlanStepRange.cpp
@@ -1,9 +1,8 @@
//===-- ThreadPlanStepRange.cpp ---------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -26,10 +25,8 @@
using namespace lldb;
using namespace lldb_private;
-//----------------------------------------------------------------------
// ThreadPlanStepRange: Step through a stack range, either stepping over or
// into based on the value of \a type.
-//----------------------------------------------------------------------
ThreadPlanStepRange::ThreadPlanStepRange(ThreadPlanKind kind, const char *name,
Thread &thread,
@@ -129,8 +126,10 @@ bool ThreadPlanStepRange::InRange() {
new_context.line_entry.original_file) {
if (m_addr_context.line_entry.line == new_context.line_entry.line) {
m_addr_context = new_context;
- AddRange(
- m_addr_context.line_entry.GetSameLineContiguousAddressRange());
+ const bool include_inlined_functions =
+ GetKind() == eKindStepOverRange;
+ AddRange(m_addr_context.line_entry.GetSameLineContiguousAddressRange(
+ include_inlined_functions));
ret_value = true;
if (log) {
StreamString s;
@@ -145,8 +144,10 @@ bool ThreadPlanStepRange::InRange() {
} else if (new_context.line_entry.line == 0) {
new_context.line_entry.line = m_addr_context.line_entry.line;
m_addr_context = new_context;
- AddRange(
- m_addr_context.line_entry.GetSameLineContiguousAddressRange());
+ const bool include_inlined_functions =
+ GetKind() == eKindStepOverRange;
+ AddRange(m_addr_context.line_entry.GetSameLineContiguousAddressRange(
+ include_inlined_functions));
ret_value = true;
if (log) {
StreamString s;
@@ -314,9 +315,10 @@ bool ThreadPlanStepRange::SetNextBranchBreakpoint() {
return false;
else {
Target &target = GetThread().GetProcess()->GetTarget();
- uint32_t branch_index;
- branch_index =
- instructions->GetIndexOfNextBranchInstruction(pc_index, target);
+ const bool ignore_calls = GetKind() == eKindStepOverRange;
+ uint32_t branch_index =
+ instructions->GetIndexOfNextBranchInstruction(pc_index, target,
+ ignore_calls);
Address run_to_address;
diff --git a/source/Target/ThreadPlanStepThrough.cpp b/source/Target/ThreadPlanStepThrough.cpp
index d1f3c2219f6d7..e46eba00184e1 100644
--- a/source/Target/ThreadPlanStepThrough.cpp
+++ b/source/Target/ThreadPlanStepThrough.cpp
@@ -1,17 +1,15 @@
//===-- ThreadPlanStepThrough.cpp -------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "lldb/Target/ThreadPlanStepThrough.h"
#include "lldb/Breakpoint/Breakpoint.h"
-#include "lldb/Target/CPPLanguageRuntime.h"
#include "lldb/Target/DynamicLoader.h"
-#include "lldb/Target/ObjCLanguageRuntime.h"
+#include "lldb/Target/LanguageRuntime.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/RegisterContext.h"
#include "lldb/Target/Target.h"
@@ -21,12 +19,10 @@
using namespace lldb;
using namespace lldb_private;
-//----------------------------------------------------------------------
// ThreadPlanStepThrough: If the current instruction is a trampoline, step
// through it If it is the beginning of the prologue of a function, step
// through that as well.
// FIXME: At present only handles DYLD trampolines.
-//----------------------------------------------------------------------
ThreadPlanStepThrough::ThreadPlanStepThrough(Thread &thread,
StackID &m_stack_id,
@@ -88,22 +84,17 @@ void ThreadPlanStepThrough::LookForPlanToStepThroughFromCurrentPC() {
m_sub_plan_sp =
loader->GetStepThroughTrampolinePlan(m_thread, m_stop_others);
- // If that didn't come up with anything, try the ObjC runtime plugin:
- if (!m_sub_plan_sp.get()) {
- ObjCLanguageRuntime *objc_runtime =
- m_thread.GetProcess()->GetObjCLanguageRuntime();
- if (objc_runtime)
+ // If the DynamicLoader was unable to provide us with a ThreadPlan, then we
+ // try the LanguageRuntimes.
+ if (!m_sub_plan_sp) {
+ for (LanguageRuntime *runtime :
+ m_thread.GetProcess()->GetLanguageRuntimes()) {
m_sub_plan_sp =
- objc_runtime->GetStepThroughTrampolinePlan(m_thread, m_stop_others);
+ runtime->GetStepThroughTrampolinePlan(m_thread, m_stop_others);
- CPPLanguageRuntime *cpp_runtime =
- m_thread.GetProcess()->GetCPPLanguageRuntime();
-
- // If the ObjC runtime did not provide us with a step though plan then if we
- // have it check the C++ runtime for a step though plan.
- if (!m_sub_plan_sp.get() && cpp_runtime)
- m_sub_plan_sp =
- cpp_runtime->GetStepThroughTrampolinePlan(m_thread, m_stop_others);
+ if (m_sub_plan_sp)
+ break;
+ }
}
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
diff --git a/source/Target/ThreadPlanStepUntil.cpp b/source/Target/ThreadPlanStepUntil.cpp
index 1335c62ba94cf..d4109c3d38daa 100644
--- a/source/Target/ThreadPlanStepUntil.cpp
+++ b/source/Target/ThreadPlanStepUntil.cpp
@@ -1,9 +1,8 @@
//===-- ThreadPlanStepUntil.cpp ---------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -20,10 +19,8 @@
using namespace lldb;
using namespace lldb_private;
-//----------------------------------------------------------------------
// ThreadPlanStepUntil: Run until we reach a given line number or step out of
// the current frame
-//----------------------------------------------------------------------
ThreadPlanStepUntil::ThreadPlanStepUntil(Thread &thread,
lldb::addr_t *address_list,
diff --git a/source/Target/ThreadPlanTracer.cpp b/source/Target/ThreadPlanTracer.cpp
index 04e29fd260805..4e79b6b1e59d0 100644
--- a/source/Target/ThreadPlanTracer.cpp
+++ b/source/Target/ThreadPlanTracer.cpp
@@ -1,9 +1,8 @@
//===-- ThreadPlanTracer.cpp ------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -188,8 +187,6 @@ void ThreadPlanAssemblyTracer::Log() {
for (int arg_index = 0; arg_index < num_args; ++arg_index) {
Value value;
value.SetValueType(Value::eValueTypeScalar);
- // value.SetContext (Value::eContextTypeClangType,
- // intptr_type.GetOpaqueQualType());
value.SetCompilerType(intptr_type);
value_list.PushValue(value);
}
diff --git a/source/Target/ThreadSpec.cpp b/source/Target/ThreadSpec.cpp
index bae3d0b2238fb..1a733cb551e57 100644
--- a/source/Target/ThreadSpec.cpp
+++ b/source/Target/ThreadSpec.cpp
@@ -1,9 +1,8 @@
//===-- ThreadSpec.cpp ------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -22,18 +21,6 @@ ThreadSpec::ThreadSpec()
: m_index(UINT32_MAX), m_tid(LLDB_INVALID_THREAD_ID), m_name(),
m_queue_name() {}
-ThreadSpec::ThreadSpec(const ThreadSpec &rhs)
- : m_index(rhs.m_index), m_tid(rhs.m_tid), m_name(rhs.m_name),
- m_queue_name(rhs.m_queue_name) {}
-
-const ThreadSpec &ThreadSpec::operator=(const ThreadSpec &rhs) {
- m_index = rhs.m_index;
- m_tid = rhs.m_tid;
- m_name = rhs.m_name;
- m_queue_name = rhs.m_queue_name;
- return *this;
-}
-
std::unique_ptr<ThreadSpec> ThreadSpec::CreateFromStructuredData(
const StructuredData::Dictionary &spec_dict, Status &error) {
uint32_t index = UINT32_MAX;
diff --git a/source/Target/UnixSignals.cpp b/source/Target/UnixSignals.cpp
index 1448535b8be46..33090a72df54e 100644
--- a/source/Target/UnixSignals.cpp
+++ b/source/Target/UnixSignals.cpp
@@ -1,9 +1,8 @@
//===-- UnixSignals.cpp -----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -12,6 +11,7 @@
#include "Plugins/Process/Utility/LinuxSignals.h"
#include "Plugins/Process/Utility/MipsLinuxSignals.h"
#include "Plugins/Process/Utility/NetBSDSignals.h"
+#include "lldb/Host/HostInfo.h"
#include "lldb/Host/StringConvert.h"
#include "lldb/Utility/ArchSpec.h"
@@ -51,9 +51,13 @@ lldb::UnixSignalsSP UnixSignals::Create(const ArchSpec &arch) {
}
}
-//----------------------------------------------------------------------
+lldb::UnixSignalsSP UnixSignals::CreateForHost() {
+ static lldb::UnixSignalsSP s_unix_signals_sp =
+ Create(HostInfo::GetArchitecture());
+ return s_unix_signals_sp;
+}
+
// UnixSignals constructor
-//----------------------------------------------------------------------
UnixSignals::UnixSignals() { Reset(); }
UnixSignals::UnixSignals(const UnixSignals &rhs) : m_signals(rhs.m_signals) {}
diff --git a/source/Target/UnwindAssembly.cpp b/source/Target/UnwindAssembly.cpp
index 06b6aef28da70..d3d8068687c03 100644
--- a/source/Target/UnwindAssembly.cpp
+++ b/source/Target/UnwindAssembly.cpp
@@ -1,9 +1,8 @@
//===-- UnwindAssembly.cpp --------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -22,9 +21,9 @@ UnwindAssemblySP UnwindAssembly::FindPlugin(const ArchSpec &arch) {
(create_callback = PluginManager::GetUnwindAssemblyCreateCallbackAtIndex(
idx)) != nullptr;
++idx) {
- UnwindAssemblySP assembly_profiler_ap(create_callback(arch));
- if (assembly_profiler_ap)
- return assembly_profiler_ap;
+ UnwindAssemblySP assembly_profiler_up(create_callback(arch));
+ if (assembly_profiler_up)
+ return assembly_profiler_up;
}
return nullptr;
}