summaryrefslogtreecommitdiff
path: root/source/Target
diff options
context:
space:
mode:
Diffstat (limited to 'source/Target')
-rw-r--r--source/Target/ABI.cpp19
-rw-r--r--source/Target/CPPLanguageRuntime.cpp372
-rw-r--r--source/Target/ExecutionContext.cpp2
-rw-r--r--source/Target/Language.cpp458
-rw-r--r--source/Target/LanguageRuntime.cpp144
-rw-r--r--source/Target/Memory.cpp26
-rw-r--r--source/Target/ObjCLanguageRuntime.cpp299
-rw-r--r--source/Target/Platform.cpp167
-rw-r--r--source/Target/Process.cpp1033
-rw-r--r--source/Target/ProcessLaunchInfo.cpp3
-rw-r--r--source/Target/RegisterContext.cpp30
-rw-r--r--source/Target/StackFrame.cpp86
-rw-r--r--source/Target/StackFrameList.cpp14
-rw-r--r--source/Target/StopInfo.cpp237
-rw-r--r--source/Target/Target.cpp1088
-rw-r--r--source/Target/TargetList.cpp63
-rw-r--r--source/Target/Thread.cpp323
-rw-r--r--source/Target/ThreadList.cpp38
-rw-r--r--source/Target/ThreadPlan.cpp38
-rw-r--r--source/Target/ThreadPlanCallFunction.cpp32
-rw-r--r--source/Target/ThreadPlanCallFunctionUsingABI.cpp13
-rw-r--r--source/Target/ThreadPlanCallUserExpression.cpp6
-rw-r--r--source/Target/ThreadPlanRunToAddress.cpp7
-rw-r--r--source/Target/ThreadPlanShouldStopHere.cpp40
-rw-r--r--source/Target/ThreadPlanStepInRange.cpp62
-rw-r--r--source/Target/ThreadPlanStepInstruction.cpp30
-rw-r--r--source/Target/ThreadPlanStepOut.cpp79
-rw-r--r--source/Target/ThreadPlanStepOverRange.cpp69
-rw-r--r--source/Target/ThreadPlanStepRange.cpp65
-rw-r--r--source/Target/ThreadPlanStepThrough.cpp14
-rw-r--r--source/Target/ThreadPlanStepUntil.cpp211
-rw-r--r--source/Target/ThreadPlanTracer.cpp63
-rw-r--r--source/Target/ThreadSpec.cpp24
-rw-r--r--source/Target/UnixSignals.cpp95
34 files changed, 2726 insertions, 2524 deletions
diff --git a/source/Target/ABI.cpp b/source/Target/ABI.cpp
index 8809c1e51d0c2..4d67cb46abe45 100644
--- a/source/Target/ABI.cpp
+++ b/source/Target/ABI.cpp
@@ -11,8 +11,9 @@
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/Value.h"
#include "lldb/Core/ValueObjectConstResult.h"
-#include "lldb/Expression/ClangPersistentVariables.h"
-#include "lldb/Symbol/ClangASTType.h"
+#include "Plugins/ExpressionParser/Clang/ClangPersistentVariables.h"
+#include "lldb/Symbol/CompilerType.h"
+#include "lldb/Symbol/TypeSystem.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
@@ -84,7 +85,7 @@ ABI::GetRegisterInfoByName (const ConstString &name, RegisterInfo &info)
bool
ABI::GetRegisterInfoByKind (RegisterKind reg_kind, uint32_t reg_num, RegisterInfo &info)
{
- if (reg_kind < eRegisterKindGCC || reg_kind >= kNumRegisterKinds)
+ if (reg_kind < eRegisterKindEHFrame || reg_kind >= kNumRegisterKinds)
return false;
uint32_t count = 0;
@@ -105,7 +106,7 @@ ABI::GetRegisterInfoByKind (RegisterKind reg_kind, uint32_t reg_num, RegisterInf
ValueObjectSP
ABI::GetReturnValueObject (Thread &thread,
- ClangASTType &ast_type,
+ CompilerType &ast_type,
bool persistent) const
{
if (!ast_type.IsValid())
@@ -123,8 +124,12 @@ ABI::GetReturnValueObject (Thread &thread,
if (persistent)
{
- ClangPersistentVariables& persistent_variables = thread.CalculateTarget()->GetPersistentVariables();
- ConstString persistent_variable_name (persistent_variables.GetNextPersistentVariableName());
+ PersistentExpressionState *persistent_expression_state = thread.CalculateTarget()->GetPersistentExpressionStateForLanguage(ast_type.GetMinimumLanguage());
+
+ if (!persistent_expression_state)
+ return ValueObjectSP();
+
+ ConstString persistent_variable_name (persistent_expression_state->GetNextPersistentVariableName());
lldb::ValueObjectSP const_valobj_sp;
@@ -141,7 +146,7 @@ ABI::GetReturnValueObject (Thread &thread,
return_valobj_sp = const_valobj_sp;
- ClangExpressionVariableSP clang_expr_variable_sp(persistent_variables.CreatePersistentVariable(return_valobj_sp));
+ ExpressionVariableSP clang_expr_variable_sp(persistent_expression_state->CreatePersistentVariable(return_valobj_sp));
assert (clang_expr_variable_sp.get());
diff --git a/source/Target/CPPLanguageRuntime.cpp b/source/Target/CPPLanguageRuntime.cpp
index f048c6706a9b8..28cfab1cefd7c 100644
--- a/source/Target/CPPLanguageRuntime.cpp
+++ b/source/Target/CPPLanguageRuntime.cpp
@@ -20,137 +20,6 @@
using namespace lldb;
using namespace lldb_private;
-class CPPRuntimeEquivalents
-{
-public:
- CPPRuntimeEquivalents ()
- {
-
- m_impl.Append(ConstString("std::basic_string<char, std::char_traits<char>, std::allocator<char> >").AsCString(), ConstString("basic_string<char>"));
-
- // these two (with a prefixed std::) occur when c++stdlib string class occurs as a template argument in some STL container
- m_impl.Append(ConstString("std::basic_string<char, std::char_traits<char>, std::allocator<char> >").AsCString(), ConstString("std::basic_string<char>"));
-
- m_impl.Sort();
- }
-
- void
- Add (ConstString& type_name,
- ConstString& type_equivalent)
- {
- m_impl.Insert(type_name.AsCString(), type_equivalent);
- }
-
- uint32_t
- FindExactMatches (ConstString& type_name,
- std::vector<ConstString>& equivalents)
- {
-
- uint32_t count = 0;
-
- for (ImplData match = m_impl.FindFirstValueForName(type_name.AsCString());
- match != NULL;
- match = m_impl.FindNextValueForName(match))
- {
- equivalents.push_back(match->value);
- count++;
- }
-
- return count;
- }
-
- // partial matches can occur when a name with equivalents is a template argument.
- // e.g. we may have "class Foo" be a match for "struct Bar". if we have a typename
- // such as "class Templatized<class Foo, Anything>" we want this to be replaced with
- // "class Templatized<struct Bar, Anything>". Since partial matching is time consuming
- // once we get a partial match, we add it to the exact matches list for faster retrieval
- uint32_t
- FindPartialMatches (ConstString& type_name,
- std::vector<ConstString>& equivalents)
- {
-
- uint32_t count = 0;
-
- const char* type_name_cstr = type_name.AsCString();
-
- size_t items_count = m_impl.GetSize();
-
- for (size_t item = 0; item < items_count; item++)
- {
- const char* key_cstr = m_impl.GetCStringAtIndex(item);
- if ( strstr(type_name_cstr,key_cstr) )
- {
- count += AppendReplacements(type_name_cstr,
- key_cstr,
- equivalents);
- }
- }
-
- return count;
-
- }
-
-private:
-
- std::string& replace (std::string& target,
- std::string& pattern,
- std::string& with)
- {
- size_t pos;
- size_t pattern_len = pattern.size();
-
- while ( (pos = target.find(pattern)) != std::string::npos )
- target.replace(pos, pattern_len, with);
-
- return target;
- }
-
- uint32_t
- AppendReplacements (const char* original,
- const char *matching_key,
- std::vector<ConstString>& equivalents)
- {
-
- std::string matching_key_str(matching_key);
- ConstString original_const(original);
-
- uint32_t count = 0;
-
- for (ImplData match = m_impl.FindFirstValueForName(matching_key);
- match != NULL;
- match = m_impl.FindNextValueForName(match))
- {
- std::string target(original);
- std::string equiv_class(match->value.AsCString());
-
- replace (target, matching_key_str, equiv_class);
-
- ConstString target_const(target.c_str());
-
-// you will most probably want to leave this off since it might make this map grow indefinitely
-#ifdef ENABLE_CPP_EQUIVALENTS_MAP_TO_GROW
- Add(original_const, target_const);
-#endif
- equivalents.push_back(target_const);
-
- count++;
- }
-
- return count;
- }
-
- typedef UniqueCStringMap<ConstString> Impl;
- typedef const Impl::Entry* ImplData;
- Impl m_impl;
-};
-
-static CPPRuntimeEquivalents&
-GetEquivalentsMap ()
-{
- static CPPRuntimeEquivalents g_equivalents_map;
- return g_equivalents_map;
-}
-
//----------------------------------------------------------------------
// Destructor
//----------------------------------------------------------------------
@@ -177,244 +46,3 @@ CPPLanguageRuntime::GetObjectDescription (Stream &str, Value &value, ExecutionCo
// C++ has no generic way to do this.
return false;
}
-
-bool
-CPPLanguageRuntime::IsCPPMangledName (const char *name)
-{
- // FIXME, we should really run through all the known C++ Language plugins and ask each one if
- // this is a C++ mangled name, but we can put that off till there is actually more than one
- // we care about.
-
- if (name && name[0] == '_' && name[1] == 'Z')
- return true;
- else
- return false;
-}
-
-bool
-CPPLanguageRuntime::ExtractContextAndIdentifier (const char *name, llvm::StringRef &context, llvm::StringRef &identifier)
-{
- static RegularExpression g_basename_regex("^(([A-Za-z_][A-Za-z_0-9]*::)*)([A-Za-z_][A-Za-z_0-9]*)$");
- RegularExpression::Match match(4);
- if (g_basename_regex.Execute (name, &match))
- {
- match.GetMatchAtIndex(name, 1, context);
- match.GetMatchAtIndex(name, 3, identifier);
- return true;
- }
- return false;
-}
-
-uint32_t
-CPPLanguageRuntime::FindEquivalentNames(ConstString type_name, std::vector<ConstString>& equivalents)
-{
- uint32_t count = GetEquivalentsMap().FindExactMatches(type_name, equivalents);
-
- bool might_have_partials=
- ( count == 0 ) // if we have a full name match just use it
- && (strchr(type_name.AsCString(), '<') != NULL // we should only have partial matches when templates are involved, check that we have
- && strchr(type_name.AsCString(), '>') != NULL); // angle brackets in the type_name before trying to scan for partial matches
-
- if ( might_have_partials )
- count = GetEquivalentsMap().FindPartialMatches(type_name, equivalents);
-
- return count;
-}
-
-void
-CPPLanguageRuntime::MethodName::Clear()
-{
- m_full.Clear();
- m_basename = llvm::StringRef();
- m_context = llvm::StringRef();
- m_arguments = llvm::StringRef();
- m_qualifiers = llvm::StringRef();
- m_type = eTypeInvalid;
- m_parsed = false;
- m_parse_error = false;
-}
-
-bool
-ReverseFindMatchingChars (const llvm::StringRef &s,
- const llvm::StringRef &left_right_chars,
- size_t &left_pos,
- size_t &right_pos,
- size_t pos = llvm::StringRef::npos)
-{
- assert (left_right_chars.size() == 2);
- left_pos = llvm::StringRef::npos;
- const char left_char = left_right_chars[0];
- const char right_char = left_right_chars[1];
- pos = s.find_last_of(left_right_chars, pos);
- if (pos == llvm::StringRef::npos || s[pos] == left_char)
- return false;
- right_pos = pos;
- uint32_t depth = 1;
- while (pos > 0 && depth > 0)
- {
- pos = s.find_last_of(left_right_chars, pos);
- if (pos == llvm::StringRef::npos)
- return false;
- if (s[pos] == left_char)
- {
- if (--depth == 0)
- {
- left_pos = pos;
- return left_pos < right_pos;
- }
- }
- else if (s[pos] == right_char)
- {
- ++depth;
- }
- }
- return false;
-}
-
-
-void
-CPPLanguageRuntime::MethodName::Parse()
-{
- if (!m_parsed && m_full)
- {
-// ConstString mangled;
-// m_full.GetMangledCounterpart(mangled);
-// printf ("\n parsing = '%s'\n", m_full.GetCString());
-// if (mangled)
-// printf (" mangled = '%s'\n", mangled.GetCString());
- m_parse_error = false;
- m_parsed = true;
- llvm::StringRef full (m_full.GetCString());
-
- size_t arg_start, arg_end;
- llvm::StringRef parens("()", 2);
- if (ReverseFindMatchingChars (full, parens, arg_start, arg_end))
- {
- m_arguments = full.substr(arg_start, arg_end - arg_start + 1);
- if (arg_end + 1 < full.size())
- m_qualifiers = full.substr(arg_end + 1);
- if (arg_start > 0)
- {
- size_t basename_end = arg_start;
- size_t context_start = 0;
- size_t context_end = llvm::StringRef::npos;
- if (basename_end > 0 && full[basename_end-1] == '>')
- {
- // TODO: handle template junk...
- // Templated function
- size_t template_start, template_end;
- llvm::StringRef lt_gt("<>", 2);
- if (ReverseFindMatchingChars (full, lt_gt, template_start, template_end, basename_end))
- {
- context_end = full.rfind(':', template_start);
- if (context_end == llvm::StringRef::npos)
- {
- // Check for templated functions that include return type like:
- // 'void foo<Int>()'
- context_end = full.rfind(' ', template_start);
- if (context_end != llvm::StringRef::npos)
- {
- context_start = context_end;
- }
- }
- }
- else
- {
- context_end = full.rfind(':', basename_end);
- }
- }
- else if (context_end == llvm::StringRef::npos)
- {
- context_end = full.rfind(':', basename_end);
- }
-
- if (context_end == llvm::StringRef::npos)
- m_basename = full.substr(0, basename_end);
- else
- {
- if (context_start < context_end)
- m_context = full.substr(context_start, context_end - 1);
- const size_t basename_begin = context_end + 1;
- m_basename = full.substr(basename_begin, basename_end - basename_begin);
- }
- m_type = eTypeUnknownMethod;
- }
- else
- {
- m_parse_error = true;
- return;
- }
-
-// if (!m_context.empty())
-// printf (" context = '%s'\n", m_context.str().c_str());
-// if (m_basename)
-// printf (" basename = '%s'\n", m_basename.GetCString());
-// if (!m_arguments.empty())
-// printf (" arguments = '%s'\n", m_arguments.str().c_str());
-// if (!m_qualifiers.empty())
-// printf ("qualifiers = '%s'\n", m_qualifiers.str().c_str());
-
- // Make sure we have a valid C++ basename with optional template args
- static RegularExpression g_identifier_regex("^~?([A-Za-z_][A-Za-z_0-9]*)(<.*>)?$");
- std::string basename_str(m_basename.str());
- bool basename_is_valid = g_identifier_regex.Execute (basename_str.c_str(), NULL);
- if (!basename_is_valid)
- {
- // Check for C++ operators
- if (m_basename.startswith("operator"))
- {
- static RegularExpression g_operator_regex("^(operator)( ?)([A-Za-z_][A-Za-z_0-9]*|\\(\\)|\\[\\]|[\\^<>=!\\/*+-]+)(<.*>)?(\\[\\])?$");
- basename_is_valid = g_operator_regex.Execute(basename_str.c_str(), NULL);
- }
- }
- if (!basename_is_valid)
- {
- // The C++ basename doesn't match our regular expressions so this can't
- // be a valid C++ method, clear everything out and indicate an error
- m_context = llvm::StringRef();
- m_basename = llvm::StringRef();
- m_arguments = llvm::StringRef();
- m_qualifiers = llvm::StringRef();
- m_parse_error = true;
- }
- }
- else
- {
- m_parse_error = true;
-// printf ("error: didn't find matching parens for arguments\n");
- }
- }
-}
-
-llvm::StringRef
-CPPLanguageRuntime::MethodName::GetBasename ()
-{
- if (!m_parsed)
- Parse();
- return m_basename;
-}
-
-llvm::StringRef
-CPPLanguageRuntime::MethodName::GetContext ()
-{
- if (!m_parsed)
- Parse();
- return m_context;
-}
-
-llvm::StringRef
-CPPLanguageRuntime::MethodName::GetArguments ()
-{
- if (!m_parsed)
- Parse();
- return m_arguments;
-}
-
-llvm::StringRef
-CPPLanguageRuntime::MethodName::GetQualifiers ()
-{
- if (!m_parsed)
- Parse();
- return m_qualifiers;
-}
-
diff --git a/source/Target/ExecutionContext.cpp b/source/Target/ExecutionContext.cpp
index 03714728559cb..ff584361c2963 100644
--- a/source/Target/ExecutionContext.cpp
+++ b/source/Target/ExecutionContext.cpp
@@ -262,7 +262,7 @@ ExecutionContext::GetByteOrder() const
m_target_sp->GetArchitecture().GetByteOrder();
if (m_process_sp)
m_process_sp->GetByteOrder();
- return lldb::endian::InlHostByteOrder();
+ return endian::InlHostByteOrder();
}
RegisterContext *
diff --git a/source/Target/Language.cpp b/source/Target/Language.cpp
new file mode 100644
index 0000000000000..d6c7e0a4c4bb9
--- /dev/null
+++ b/source/Target/Language.cpp
@@ -0,0 +1,458 @@
+//===-- Language.cpp -------------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include <functional>
+#include <map>
+#include <mutex>
+
+#include "lldb/Target/Language.h"
+
+#include "lldb/Host/Mutex.h"
+#include "lldb/Core/PluginManager.h"
+#include "lldb/Core/Stream.h"
+
+using namespace lldb;
+using namespace lldb_private;
+using namespace lldb_private::formatters;
+
+typedef std::unique_ptr<Language> LanguageUP;
+typedef std::map<lldb::LanguageType, LanguageUP> LanguagesMap;
+
+static LanguagesMap&
+GetLanguagesMap ()
+{
+ static LanguagesMap *g_map = nullptr;
+ static std::once_flag g_initialize;
+
+ std::call_once(g_initialize, [] {
+ g_map = new LanguagesMap(); // NOTE: INTENTIONAL LEAK due to global destructor chain
+ });
+
+ return *g_map;
+}
+static Mutex&
+GetLanguagesMutex ()
+{
+ static Mutex *g_mutex = nullptr;
+ static std::once_flag g_initialize;
+
+ std::call_once(g_initialize, [] {
+ g_mutex = new Mutex(); // NOTE: INTENTIONAL LEAK due to global destructor chain
+ });
+
+ return *g_mutex;
+}
+
+Language*
+Language::FindPlugin (lldb::LanguageType language)
+{
+ Mutex::Locker locker(GetLanguagesMutex());
+ LanguagesMap& map(GetLanguagesMap());
+ auto iter = map.find(language), end = map.end();
+ if (iter != end)
+ return iter->second.get();
+
+ Language *language_ptr = nullptr;
+ LanguageCreateInstance create_callback;
+
+ for (uint32_t idx = 0;
+ (create_callback = PluginManager::GetLanguageCreateCallbackAtIndex(idx)) != nullptr;
+ ++idx)
+ {
+ language_ptr = create_callback(language);
+
+ if (language_ptr)
+ {
+ map[language] = std::unique_ptr<Language>(language_ptr);
+ return language_ptr;
+ }
+ }
+
+ return nullptr;
+}
+
+void
+Language::ForEach (std::function<bool(Language*)> callback)
+{
+ Mutex::Locker locker(GetLanguagesMutex());
+ LanguagesMap& map(GetLanguagesMap());
+ for (const auto& entry : map)
+ {
+ if (!callback(entry.second.get()))
+ break;
+ }
+}
+
+bool
+Language::IsTopLevelFunction (Function& function)
+{
+ return false;
+}
+
+lldb::TypeCategoryImplSP
+Language::GetFormatters ()
+{
+ return nullptr;
+}
+
+HardcodedFormatters::HardcodedFormatFinder
+Language::GetHardcodedFormats ()
+{
+ return {};
+}
+
+HardcodedFormatters::HardcodedSummaryFinder
+Language::GetHardcodedSummaries ()
+{
+ return {};
+}
+
+HardcodedFormatters::HardcodedSyntheticFinder
+Language::GetHardcodedSynthetics ()
+{
+ return {};
+}
+
+HardcodedFormatters::HardcodedValidatorFinder
+Language::GetHardcodedValidators ()
+{
+ return {};
+}
+
+std::vector<ConstString>
+Language::GetPossibleFormattersMatches (ValueObject& valobj, lldb::DynamicValueType use_dynamic)
+{
+ return {};
+}
+
+lldb_private::formatters::StringPrinter::EscapingHelper
+Language::GetStringPrinterEscapingHelper (lldb_private::formatters::StringPrinter::GetPrintableElementType elem_type)
+{
+ return StringPrinter::GetDefaultEscapingHelper(elem_type);
+}
+
+struct language_name_pair {
+ const char *name;
+ LanguageType type;
+};
+
+struct language_name_pair language_names[] =
+{
+ // To allow GetNameForLanguageType to be a simple array lookup, the first
+ // part of this array must follow enum LanguageType exactly.
+ { "unknown", eLanguageTypeUnknown },
+ { "c89", eLanguageTypeC89 },
+ { "c", eLanguageTypeC },
+ { "ada83", eLanguageTypeAda83 },
+ { "c++", eLanguageTypeC_plus_plus },
+ { "cobol74", eLanguageTypeCobol74 },
+ { "cobol85", eLanguageTypeCobol85 },
+ { "fortran77", eLanguageTypeFortran77 },
+ { "fortran90", eLanguageTypeFortran90 },
+ { "pascal83", eLanguageTypePascal83 },
+ { "modula2", eLanguageTypeModula2 },
+ { "java", eLanguageTypeJava },
+ { "c99", eLanguageTypeC99 },
+ { "ada95", eLanguageTypeAda95 },
+ { "fortran95", eLanguageTypeFortran95 },
+ { "pli", eLanguageTypePLI },
+ { "objective-c", eLanguageTypeObjC },
+ { "objective-c++", eLanguageTypeObjC_plus_plus },
+ { "upc", eLanguageTypeUPC },
+ { "d", eLanguageTypeD },
+ { "python", eLanguageTypePython },
+ { "opencl", eLanguageTypeOpenCL },
+ { "go", eLanguageTypeGo },
+ { "modula3", eLanguageTypeModula3 },
+ { "haskell", eLanguageTypeHaskell },
+ { "c++03", eLanguageTypeC_plus_plus_03 },
+ { "c++11", eLanguageTypeC_plus_plus_11 },
+ { "ocaml", eLanguageTypeOCaml },
+ { "rust", eLanguageTypeRust },
+ { "c11", eLanguageTypeC11 },
+ { "swift", eLanguageTypeSwift },
+ { "julia", eLanguageTypeJulia },
+ { "dylan", eLanguageTypeDylan },
+ { "c++14", eLanguageTypeC_plus_plus_14 },
+ { "fortran03", eLanguageTypeFortran03 },
+ { "fortran08", eLanguageTypeFortran08 },
+ // Vendor Extensions
+ { "mipsassem", eLanguageTypeMipsAssembler },
+ { "renderscript", eLanguageTypeExtRenderScript},
+ // Now synonyms, in arbitrary order
+ { "objc", eLanguageTypeObjC },
+ { "objc++", eLanguageTypeObjC_plus_plus },
+ { "pascal", eLanguageTypePascal83 }
+};
+
+static uint32_t num_languages = sizeof(language_names) / sizeof (struct language_name_pair);
+
+LanguageType
+Language::GetLanguageTypeFromString (const char *string)
+{
+ for (uint32_t i = 0; i < num_languages; i++)
+ {
+ if (strcasecmp (language_names[i].name, string) == 0)
+ return (LanguageType) language_names[i].type;
+ }
+ return eLanguageTypeUnknown;
+}
+
+const char *
+Language::GetNameForLanguageType (LanguageType language)
+{
+ if (language < num_languages)
+ return language_names[language].name;
+ else
+ return language_names[eLanguageTypeUnknown].name;
+}
+
+void
+Language::PrintAllLanguages (Stream &s, const char *prefix, const char *suffix)
+{
+ for (uint32_t i = 1; i < num_languages; i++)
+ {
+ s.Printf("%s%s%s", prefix, language_names[i].name, suffix);
+ }
+}
+
+void
+Language::ForAllLanguages (std::function<bool(lldb::LanguageType)> callback)
+{
+ for (uint32_t i = 1; i < num_languages; i++)
+ {
+ if (!callback(language_names[i].type))
+ break;
+ }
+}
+
+bool
+Language::LanguageIsCPlusPlus (LanguageType language)
+{
+ switch (language)
+ {
+ case eLanguageTypeC_plus_plus:
+ case eLanguageTypeC_plus_plus_03:
+ case eLanguageTypeC_plus_plus_11:
+ case eLanguageTypeC_plus_plus_14:
+ return true;
+ default:
+ return false;
+ }
+}
+
+bool
+Language::LanguageIsObjC (LanguageType language)
+{
+ switch (language)
+ {
+ case eLanguageTypeObjC:
+ case eLanguageTypeObjC_plus_plus:
+ return true;
+ default:
+ return false;
+ }
+}
+
+bool
+Language::LanguageIsC (LanguageType language)
+{
+ switch (language)
+ {
+ case eLanguageTypeC:
+ case eLanguageTypeC89:
+ case eLanguageTypeC99:
+ case eLanguageTypeC11:
+ return true;
+ default:
+ return false;
+ }
+}
+
+bool
+Language::LanguageIsPascal (LanguageType language)
+{
+ switch (language)
+ {
+ case eLanguageTypePascal83:
+ return true;
+ default:
+ return false;
+ }
+}
+
+LanguageType
+Language::GetPrimaryLanguage (LanguageType language)
+{
+ switch (language)
+ {
+ case eLanguageTypeC_plus_plus:
+ case eLanguageTypeC_plus_plus_03:
+ case eLanguageTypeC_plus_plus_11:
+ case eLanguageTypeC_plus_plus_14:
+ return eLanguageTypeC_plus_plus;
+ case eLanguageTypeC:
+ case eLanguageTypeC89:
+ case eLanguageTypeC99:
+ case eLanguageTypeC11:
+ return eLanguageTypeC;
+ case eLanguageTypeObjC:
+ case eLanguageTypeObjC_plus_plus:
+ return eLanguageTypeObjC;
+ case eLanguageTypePascal83:
+ case eLanguageTypeCobol74:
+ case eLanguageTypeCobol85:
+ case eLanguageTypeFortran77:
+ case eLanguageTypeFortran90:
+ case eLanguageTypeFortran95:
+ case eLanguageTypeFortran03:
+ case eLanguageTypeFortran08:
+ case eLanguageTypeAda83:
+ case eLanguageTypeAda95:
+ case eLanguageTypeModula2:
+ case eLanguageTypeJava:
+ case eLanguageTypePLI:
+ case eLanguageTypeUPC:
+ case eLanguageTypeD:
+ case eLanguageTypePython:
+ case eLanguageTypeOpenCL:
+ case eLanguageTypeGo:
+ case eLanguageTypeModula3:
+ case eLanguageTypeHaskell:
+ case eLanguageTypeOCaml:
+ case eLanguageTypeRust:
+ case eLanguageTypeSwift:
+ case eLanguageTypeJulia:
+ case eLanguageTypeDylan:
+ case eLanguageTypeMipsAssembler:
+ case eLanguageTypeExtRenderScript:
+ case eLanguageTypeUnknown:
+ default:
+ return language;
+ }
+}
+
+void
+Language::GetLanguagesSupportingTypeSystems (std::set<lldb::LanguageType> &languages,
+ std::set<lldb::LanguageType> &languages_for_expressions)
+{
+ uint32_t idx = 0;
+
+ while (TypeSystemEnumerateSupportedLanguages enumerate = PluginManager::GetTypeSystemEnumerateSupportedLanguagesCallbackAtIndex(idx++))
+ {
+ (*enumerate)(languages, languages_for_expressions);
+ }
+}
+
+void
+Language::GetLanguagesSupportingREPLs (std::set<lldb::LanguageType> &languages)
+{
+ uint32_t idx = 0;
+
+ while (REPLEnumerateSupportedLanguages enumerate = PluginManager::GetREPLEnumerateSupportedLanguagesCallbackAtIndex(idx++))
+ {
+ (*enumerate)(languages);
+ }
+}
+
+std::unique_ptr<Language::TypeScavenger>
+Language::GetTypeScavenger ()
+{
+ return nullptr;
+}
+
+size_t
+Language::TypeScavenger::Find (ExecutionContextScope *exe_scope,
+ const char *key,
+ ResultSet &results,
+ bool append)
+{
+ if (!exe_scope || !exe_scope->CalculateTarget().get())
+ return false;
+
+ if (!key || !key[0])
+ return false;
+
+ if (!append)
+ results.clear();
+
+ size_t old_size = results.size();
+
+ if (this->Find_Impl(exe_scope, key, results))
+ return results.size() - old_size;
+ return 0;
+}
+
+bool
+Language::GetFormatterPrefixSuffix (ValueObject& valobj, ConstString type_hint,
+ std::string& prefix, std::string& suffix)
+{
+ return false;
+}
+
+DumpValueObjectOptions::DeclPrintingHelper
+Language::GetDeclPrintingHelper ()
+{
+ return nullptr;
+}
+
+LazyBool
+Language::IsLogicalTrue (ValueObject& valobj,
+ Error& error)
+{
+ return eLazyBoolCalculate;
+}
+
+bool
+Language::IsNilReference (ValueObject& valobj)
+{
+ return false;
+}
+
+bool
+Language::IsUninitializedReference (ValueObject& valobj)
+{
+ return false;
+}
+
+bool
+Language::GetFunctionDisplayName (const SymbolContext *sc,
+ const ExecutionContext *exe_ctx,
+ FunctionNameRepresentation representation,
+ Stream& s)
+{
+ return false;
+}
+
+void
+Language::GetExceptionResolverDescription(bool catch_on, bool throw_on, Stream &s)
+{
+ GetDefaultExceptionResolverDescription(catch_on, throw_on, s);
+}
+
+void
+Language::GetDefaultExceptionResolverDescription(bool catch_on, bool throw_on, Stream &s)
+{
+ 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 9c7b441d4c539..b1e2b3eb04fc7 100644
--- a/source/Target/LanguageRuntime.cpp
+++ b/source/Target/LanguageRuntime.cpp
@@ -1,4 +1,4 @@
-//===-- LanguageRuntime.cpp -------------------------------------------------*- C++ -*-===//
+//===-- LanguageRuntime.cpp -------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -7,7 +7,13 @@
//
//===----------------------------------------------------------------------===//
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
#include "lldb/Target/LanguageRuntime.h"
+#include "Plugins/Language/CPlusPlus/CPlusPlusLanguage.h"
+#include "Plugins/Language/ObjC/ObjCLanguage.h"
#include "lldb/Target/ObjCLanguageRuntime.h"
#include "lldb/Target/Target.h"
#include "lldb/Core/PluginManager.h"
@@ -17,7 +23,6 @@
using namespace lldb;
using namespace lldb_private;
-
class ExceptionSearchFilter : public SearchFilter
{
public:
@@ -33,8 +38,7 @@ public:
UpdateModuleListIfNeeded ();
}
- virtual
- ~ExceptionSearchFilter() {};
+ ~ExceptionSearchFilter() override = default;
bool
ModulePasses (const lldb::ModuleSP &module_sp) override
@@ -52,7 +56,6 @@ public:
if (m_filter_sp)
return m_filter_sp->ModulePasses (spec);
return false;
-
}
void
@@ -133,11 +136,8 @@ public:
{
}
- virtual
- ~ExceptionBreakpointResolver()
- {
- }
-
+ ~ExceptionBreakpointResolver() override = default;
+
Searcher::CallbackReturn
SearchCallback (SearchFilter &filter,
SymbolContext &context,
@@ -163,10 +163,12 @@ public:
void
GetDescription (Stream *s) override
{
- s->Printf ("Exception breakpoint (catch: %s throw: %s)",
- m_catch_bp ? "on" : "off",
- m_throw_bp ? "on" : "off");
-
+ Language *language_plugin = Language::FindPlugin(m_language);
+ if (language_plugin)
+ language_plugin->GetExceptionResolverDescription(m_catch_bp, m_throw_bp, *s);
+ else
+ Language::GetDefaultExceptionResolverDescription(m_catch_bp, m_throw_bp, *s);
+
SetActualResolver();
if (m_actual_resolver_sp)
{
@@ -187,6 +189,7 @@ public:
static inline bool classof(const BreakpointResolver *V) {
return V->getResolverID() == BreakpointResolver::ExceptionResolver;
}
+
protected:
BreakpointResolverSP
CopyForBreakpoint (Breakpoint &breakpoint) override
@@ -244,7 +247,6 @@ protected:
bool m_throw_bp;
};
-
LanguageRuntime*
LanguageRuntime::FindPlugin (Process *process, lldb::LanguageType language)
{
@@ -264,20 +266,12 @@ LanguageRuntime::FindPlugin (Process *process, lldb::LanguageType language)
return NULL;
}
-//----------------------------------------------------------------------
-// Constructor
-//----------------------------------------------------------------------
LanguageRuntime::LanguageRuntime(Process *process) :
m_process (process)
{
}
-//----------------------------------------------------------------------
-// Destructor
-//----------------------------------------------------------------------
-LanguageRuntime::~LanguageRuntime()
-{
-}
+LanguageRuntime::~LanguageRuntime() = default;
Breakpoint::BreakpointPreconditionSP
LanguageRuntime::CreateExceptionPrecondition (lldb::LanguageType language,
@@ -321,105 +315,6 @@ LanguageRuntime::CreateExceptionBreakpoint (Target &target,
return exc_breakpt_sp;
}
-struct language_name_pair {
- const char *name;
- LanguageType type;
-};
-
-struct language_name_pair language_names[] =
-{
- // To allow GetNameForLanguageType to be a simple array lookup, the first
- // part of this array must follow enum LanguageType exactly.
- { "unknown", eLanguageTypeUnknown },
- { "c89", eLanguageTypeC89 },
- { "c", eLanguageTypeC },
- { "ada83", eLanguageTypeAda83 },
- { "c++", eLanguageTypeC_plus_plus },
- { "cobol74", eLanguageTypeCobol74 },
- { "cobol85", eLanguageTypeCobol85 },
- { "fortran77", eLanguageTypeFortran77 },
- { "fortran90", eLanguageTypeFortran90 },
- { "pascal83", eLanguageTypePascal83 },
- { "modula2", eLanguageTypeModula2 },
- { "java", eLanguageTypeJava },
- { "c99", eLanguageTypeC99 },
- { "ada95", eLanguageTypeAda95 },
- { "fortran95", eLanguageTypeFortran95 },
- { "pli", eLanguageTypePLI },
- { "objective-c", eLanguageTypeObjC },
- { "objective-c++", eLanguageTypeObjC_plus_plus },
- { "upc", eLanguageTypeUPC },
- { "d", eLanguageTypeD },
- { "python", eLanguageTypePython },
- { "opencl", eLanguageTypeOpenCL },
- { "go", eLanguageTypeGo },
- { "modula3", eLanguageTypeModula3 },
- { "haskell", eLanguageTypeHaskell },
- { "c++03", eLanguageTypeC_plus_plus_03 },
- { "c++11", eLanguageTypeC_plus_plus_11 },
- { "ocaml", eLanguageTypeOCaml },
- { "rust", eLanguageTypeRust },
- { "c11", eLanguageTypeC11 },
- { "swift", eLanguageTypeSwift },
- { "julia", eLanguageTypeJulia },
- { "dylan", eLanguageTypeDylan },
- { "c++14", eLanguageTypeC_plus_plus_14 },
- { "fortran03", eLanguageTypeFortran03 },
- { "fortran08", eLanguageTypeFortran08 },
- // Vendor Extensions
- { "mipsassem", eLanguageTypeMipsAssembler },
- { "renderscript", eLanguageTypeExtRenderScript},
- // Now synonyms, in arbitrary order
- { "objc", eLanguageTypeObjC },
- { "objc++", eLanguageTypeObjC_plus_plus }
-};
-
-static uint32_t num_languages = sizeof(language_names) / sizeof (struct language_name_pair);
-
-LanguageType
-LanguageRuntime::GetLanguageTypeFromString (const char *string)
-{
- for (uint32_t i = 0; i < num_languages; i++)
- {
- if (strcasecmp (language_names[i].name, string) == 0)
- return (LanguageType) language_names[i].type;
- }
- return eLanguageTypeUnknown;
-}
-
-const char *
-LanguageRuntime::GetNameForLanguageType (LanguageType language)
-{
- if (language < num_languages)
- return language_names[language].name;
- else
- return language_names[eLanguageTypeUnknown].name;
-}
-
-void
-LanguageRuntime::PrintAllLanguages (Stream &s, const char *prefix, const char *suffix)
-{
- for (uint32_t i = 1; i < num_languages; i++)
- {
- s.Printf("%s%s%s", prefix, language_names[i].name, suffix);
- }
-}
-
-bool
-LanguageRuntime::LanguageIsCPlusPlus (LanguageType language)
-{
- switch (language)
- {
- case eLanguageTypeC_plus_plus:
- case eLanguageTypeC_plus_plus_03:
- case eLanguageTypeC_plus_plus_11:
- case eLanguageTypeC_plus_plus_14:
- return true;
- default:
- return false;
- }
-}
-
void
LanguageRuntime::InitializeCommands (CommandObject* parent)
{
@@ -452,6 +347,3 @@ LanguageRuntime::CreateExceptionSearchFilter ()
{
return m_process->GetTarget().GetSearchFilterForModule(NULL);
}
-
-
-
diff --git a/source/Target/Memory.cpp b/source/Target/Memory.cpp
index e61b3ab91e7ba..c89fd5101147a 100644
--- a/source/Target/Memory.cpp
+++ b/source/Target/Memory.cpp
@@ -164,24 +164,16 @@ MemoryCache::Read (addr_t addr,
if (!m_L1_cache.empty())
{
AddrRange read_range(addr, dst_len);
- BlockMap::iterator pos = m_L1_cache.lower_bound(addr);
- if (pos != m_L1_cache.end())
+ BlockMap::iterator pos = m_L1_cache.upper_bound(addr);
+ if (pos != m_L1_cache.begin ())
{
- AddrRange chunk_range(pos->first, pos->second->GetByteSize());
- bool match = chunk_range.Contains(read_range);
- if (!match && pos != m_L1_cache.begin())
- {
- --pos;
- chunk_range.SetRangeBase(pos->first);
- chunk_range.SetByteSize(pos->second->GetByteSize());
- match = chunk_range.Contains(read_range);
- }
-
- if (match)
- {
- memcpy(dst, pos->second->GetBytes() + addr - chunk_range.GetRangeBase(), dst_len);
- return dst_len;
- }
+ --pos;
+ }
+ AddrRange chunk_range(pos->first, pos->second->GetByteSize());
+ if (chunk_range.Contains(read_range))
+ {
+ memcpy(dst, pos->second->GetBytes() + addr - chunk_range.GetRangeBase(), dst_len);
+ return dst_len;
}
}
diff --git a/source/Target/ObjCLanguageRuntime.cpp b/source/Target/ObjCLanguageRuntime.cpp
index e54dd5b4920a4..a18e4c69c5716 100644
--- a/source/Target/ObjCLanguageRuntime.cpp
+++ b/source/Target/ObjCLanguageRuntime.cpp
@@ -136,7 +136,7 @@ ObjCLanguageRuntime::LookupInCompleteClassCache (ConstString &name)
{
TypeSP type_sp (types.GetTypeAtIndex(i));
- if (type_sp->GetClangForwardType().IsObjCObjectOrInterfaceType())
+ if (ClangASTContext::IsObjCObjectOrInterfaceType(type_sp->GetForwardCompilerType ()))
{
if (type_sp->IsCompleteObjCClass())
{
@@ -152,288 +152,11 @@ ObjCLanguageRuntime::LookupInCompleteClassCache (ConstString &name)
}
size_t
-ObjCLanguageRuntime::GetByteOffsetForIvar (ClangASTType &parent_qual_type, const char *ivar_name)
+ObjCLanguageRuntime::GetByteOffsetForIvar (CompilerType &parent_qual_type, const char *ivar_name)
{
return LLDB_INVALID_IVAR_OFFSET;
}
-void
-ObjCLanguageRuntime::MethodName::Clear()
-{
- m_full.Clear();
- m_class.Clear();
- m_category.Clear();
- m_selector.Clear();
- m_type = eTypeUnspecified;
- m_category_is_valid = false;
-}
-
-//bool
-//ObjCLanguageRuntime::MethodName::SetName (const char *name, bool strict)
-//{
-// Clear();
-// if (name && name[0])
-// {
-// // If "strict" is true. then the method must be specified with a
-// // '+' or '-' at the beginning. If "strict" is false, then the '+'
-// // or '-' can be omitted
-// bool valid_prefix = false;
-//
-// if (name[0] == '+' || name[0] == '-')
-// {
-// valid_prefix = name[1] == '[';
-// }
-// else if (!strict)
-// {
-// // "strict" is false, the name just needs to start with '['
-// valid_prefix = name[0] == '[';
-// }
-//
-// if (valid_prefix)
-// {
-// static RegularExpression g_regex("^([-+]?)\\[([A-Za-z_][A-Za-z_0-9]*)(\\([A-Za-z_][A-Za-z_0-9]*\\))? ([A-Za-z_][A-Za-z_0-9:]*)\\]$");
-// llvm::StringRef matches[4];
-// // Since we are using a global regular expression, we must use the threadsafe version of execute
-// if (g_regex.ExecuteThreadSafe(name, matches, 4))
-// {
-// m_full.SetCString(name);
-// if (matches[0].empty())
-// m_type = eTypeUnspecified;
-// else if (matches[0][0] == '+')
-// m_type = eTypeClassMethod;
-// else
-// m_type = eTypeInstanceMethod;
-// m_class.SetString(matches[1]);
-// m_selector.SetString(matches[3]);
-// if (!matches[2].empty())
-// m_category.SetString(matches[2]);
-// }
-// }
-// }
-// return IsValid(strict);
-//}
-
-bool
-ObjCLanguageRuntime::MethodName::SetName (const char *name, bool strict)
-{
- Clear();
- if (name && name[0])
- {
- // If "strict" is true. then the method must be specified with a
- // '+' or '-' at the beginning. If "strict" is false, then the '+'
- // or '-' can be omitted
- bool valid_prefix = false;
-
- if (name[0] == '+' || name[0] == '-')
- {
- valid_prefix = name[1] == '[';
- if (name[0] == '+')
- m_type = eTypeClassMethod;
- else
- m_type = eTypeInstanceMethod;
- }
- else if (!strict)
- {
- // "strict" is false, the name just needs to start with '['
- valid_prefix = name[0] == '[';
- }
-
- if (valid_prefix)
- {
- int name_len = strlen (name);
- // Objective C methods must have at least:
- // "-[" or "+[" prefix
- // One character for a class name
- // One character for the space between the class name
- // One character for the method name
- // "]" suffix
- if (name_len >= (5 + (strict ? 1 : 0)) && name[name_len - 1] == ']')
- {
- m_full.SetCStringWithLength(name, name_len);
- }
- }
- }
- return IsValid(strict);
-}
-
-const ConstString &
-ObjCLanguageRuntime::MethodName::GetClassName ()
-{
- if (!m_class)
- {
- if (IsValid(false))
- {
- const char *full = m_full.GetCString();
- const char *class_start = (full[0] == '[' ? full + 1 : full + 2);
- const char *paren_pos = strchr (class_start, '(');
- if (paren_pos)
- {
- m_class.SetCStringWithLength (class_start, paren_pos - class_start);
- }
- else
- {
- // No '(' was found in the full name, we can definitively say
- // that our category was valid (and empty).
- m_category_is_valid = true;
- const char *space_pos = strchr (full, ' ');
- if (space_pos)
- {
- m_class.SetCStringWithLength (class_start, space_pos - class_start);
- if (!m_class_category)
- {
- // No category in name, so we can also fill in the m_class_category
- m_class_category = m_class;
- }
- }
- }
- }
- }
- return m_class;
-}
-
-const ConstString &
-ObjCLanguageRuntime::MethodName::GetClassNameWithCategory ()
-{
- if (!m_class_category)
- {
- if (IsValid(false))
- {
- const char *full = m_full.GetCString();
- const char *class_start = (full[0] == '[' ? full + 1 : full + 2);
- const char *space_pos = strchr (full, ' ');
- if (space_pos)
- {
- m_class_category.SetCStringWithLength (class_start, space_pos - class_start);
- // If m_class hasn't been filled in and the class with category doesn't
- // contain a '(', then we can also fill in the m_class
- if (!m_class && strchr (m_class_category.GetCString(), '(') == NULL)
- {
- m_class = m_class_category;
- // No '(' was found in the full name, we can definitively say
- // that our category was valid (and empty).
- m_category_is_valid = true;
-
- }
- }
- }
- }
- return m_class_category;
-}
-
-const ConstString &
-ObjCLanguageRuntime::MethodName::GetSelector ()
-{
- if (!m_selector)
- {
- if (IsValid(false))
- {
- const char *full = m_full.GetCString();
- const char *space_pos = strchr (full, ' ');
- if (space_pos)
- {
- ++space_pos; // skip the space
- m_selector.SetCStringWithLength (space_pos, m_full.GetLength() - (space_pos - full) - 1);
- }
- }
- }
- return m_selector;
-}
-
-const ConstString &
-ObjCLanguageRuntime::MethodName::GetCategory ()
-{
- if (!m_category_is_valid && !m_category)
- {
- if (IsValid(false))
- {
- m_category_is_valid = true;
- const char *full = m_full.GetCString();
- const char *class_start = (full[0] == '[' ? full + 1 : full + 2);
- const char *open_paren_pos = strchr (class_start, '(');
- if (open_paren_pos)
- {
- ++open_paren_pos; // Skip the open paren
- const char *close_paren_pos = strchr (open_paren_pos, ')');
- if (close_paren_pos)
- m_category.SetCStringWithLength (open_paren_pos, close_paren_pos - open_paren_pos);
- }
- }
- }
- return m_category;
-}
-
-ConstString
-ObjCLanguageRuntime::MethodName::GetFullNameWithoutCategory (bool empty_if_no_category)
-{
- if (IsValid(false))
- {
- if (HasCategory())
- {
- StreamString strm;
- if (m_type == eTypeClassMethod)
- strm.PutChar('+');
- else if (m_type == eTypeInstanceMethod)
- strm.PutChar('-');
- strm.Printf("[%s %s]", GetClassName().GetCString(), GetSelector().GetCString());
- return ConstString(strm.GetString().c_str());
- }
-
- if (!empty_if_no_category)
- {
- // Just return the full name since it doesn't have a category
- return GetFullName();
- }
- }
- return ConstString();
-}
-
-size_t
-ObjCLanguageRuntime::MethodName::GetFullNames (std::vector<ConstString> &names, bool append)
-{
- if (!append)
- names.clear();
- if (IsValid(false))
- {
- StreamString strm;
- const bool is_class_method = m_type == eTypeClassMethod;
- const bool is_instance_method = m_type == eTypeInstanceMethod;
- const ConstString &category = GetCategory();
- if (is_class_method || is_instance_method)
- {
- names.push_back (m_full);
- if (category)
- {
- strm.Printf("%c[%s %s]",
- is_class_method ? '+' : '-',
- GetClassName().GetCString(),
- GetSelector().GetCString());
- names.push_back(ConstString(strm.GetString().c_str()));
- }
- }
- else
- {
- const ConstString &class_name = GetClassName();
- const ConstString &selector = GetSelector();
- strm.Printf("+[%s %s]", class_name.GetCString(), selector.GetCString());
- names.push_back(ConstString(strm.GetString().c_str()));
- strm.Clear();
- strm.Printf("-[%s %s]", class_name.GetCString(), selector.GetCString());
- names.push_back(ConstString(strm.GetString().c_str()));
- strm.Clear();
- if (category)
- {
- strm.Printf("+[%s(%s) %s]", class_name.GetCString(), category.GetCString(), selector.GetCString());
- names.push_back(ConstString(strm.GetString().c_str()));
- strm.Clear();
- strm.Printf("-[%s(%s) %s]", class_name.GetCString(), category.GetCString(), selector.GetCString());
- names.push_back(ConstString(strm.GetString().c_str()));
- }
- }
- }
- return names.size();
-}
-
-
bool
ObjCLanguageRuntime::ClassDescriptor::IsPointerValid (lldb::addr_t value,
uint32_t ptr_size,
@@ -549,7 +272,7 @@ ObjCLanguageRuntime::GetClassDescriptor (ValueObject& valobj)
// 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.GetClangType().IsValid())
+ if (valobj.GetCompilerType().IsValid())
{
addr_t isa_pointer = valobj.GetPointerValue();
if (isa_pointer != LLDB_INVALID_ADDRESS)
@@ -619,20 +342,20 @@ ObjCLanguageRuntime::GetNonKVOClassDescriptor (ObjCISA isa)
}
-ClangASTType
+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 ClangASTType();
+ return CompilerType();
}
-ClangASTType
+CompilerType
ObjCLanguageRuntime::EncodingToType::RealizeType (ClangASTContext& ast_ctx, const char* name, bool for_expression)
{
clang::ASTContext *clang_ast = ast_ctx.getASTContext();
if (!clang_ast)
- return ClangASTType();
+ return CompilerType();
return RealizeType(*clang_ast, name, for_expression);
}
@@ -645,16 +368,16 @@ ObjCLanguageRuntime::GetEncodingToType ()
}
bool
-ObjCLanguageRuntime::GetTypeBitSize (const ClangASTType& clang_type,
+ObjCLanguageRuntime::GetTypeBitSize (const CompilerType& compiler_type,
uint64_t &size)
{
- void *opaque_ptr = clang_type.GetQualType().getAsOpaquePtr();
+ 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(clang_type.GetTypeName());
+ ClassDescriptorSP class_descriptor_sp = GetClassDescriptorFromClassName(compiler_type.GetTypeName());
if (!class_descriptor_sp)
return false;
@@ -703,7 +426,7 @@ ObjCLanguageRuntime::ObjCExceptionPrecondition::EvaluatePrecondition(StoppointCa
}
void
-ObjCLanguageRuntime::ObjCExceptionPrecondition::DescribePrecondition(Stream &stream, lldb::DescriptionLevel level)
+ObjCLanguageRuntime::ObjCExceptionPrecondition::GetDescription(Stream &stream, lldb::DescriptionLevel level)
{
}
diff --git a/source/Target/Platform.cpp b/source/Target/Platform.cpp
index 2b586933ccd41..5077ca23bf746 100644
--- a/source/Target/Platform.cpp
+++ b/source/Target/Platform.cpp
@@ -26,6 +26,7 @@
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/PluginManager.h"
+#include "lldb/Core/StreamFile.h"
#include "lldb/Core/StructuredData.h"
#include "lldb/Host/FileSpec.h"
#include "lldb/Host/FileSystem.h"
@@ -39,9 +40,11 @@
#include "lldb/Target/UnixSignals.h"
#include "lldb/Utility/Utils.h"
#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Path.h"
#include "Utility/ModuleCache.h"
+
// Define these constants from POSIX mman.h rather than include the file
// so that they will be correct even when compiled on Linux.
#define MAP_PRIVATE 2
@@ -99,13 +102,17 @@ PlatformProperties::PlatformProperties ()
m_collection_sp->Initialize (g_properties);
auto module_cache_dir = GetModuleCacheDirectory ();
- if (!module_cache_dir)
- {
- if (!HostInfo::GetLLDBPath (ePathTypeGlobalLLDBTempSystemDir, module_cache_dir))
- module_cache_dir = FileSpec ("/tmp/lldb", false);
- module_cache_dir.AppendPathComponent ("module_cache");
- SetModuleCacheDirectory (module_cache_dir);
- }
+ if (module_cache_dir)
+ return;
+
+ llvm::SmallString<64> user_home_dir;
+ if (!llvm::sys::path::home_directory (user_home_dir))
+ return;
+
+ module_cache_dir = FileSpec (user_home_dir.c_str(), false);
+ module_cache_dir.AppendPathComponent (".lldb");
+ module_cache_dir.AppendPathComponent ("module_cache");
+ SetModuleCacheDirectory (module_cache_dir);
}
bool
@@ -272,8 +279,11 @@ Platform::GetSharedModule (const ModuleSpec &module_spec,
module_sp,
[&](const ModuleSpec &spec)
{
- return ModuleList::GetSharedModule (
+ Error error = ModuleList::GetSharedModule (
spec, module_sp, module_search_paths_ptr, old_module_sp_ptr, did_create_ptr, false);
+ if (error.Success() && module_sp)
+ module_sp->SetPlatformFileSpec(spec.GetFileSpec());
+ return error;
},
did_create_ptr);
}
@@ -466,7 +476,11 @@ Platform::GetStatus (Stream &strm)
if (arch.IsValid())
{
if (!arch.GetTriple().str().empty())
- strm.Printf(" Triple: %s\n", arch.GetTriple().str().c_str());
+ {
+ strm.Printf(" Triple: ");
+ arch.DumpTriple(strm);
+ strm.EOL();
+ }
}
if (GetOSVersion(major, minor, update))
@@ -515,7 +529,8 @@ Platform::GetStatus (Stream &strm)
bool
Platform::GetOSVersion (uint32_t &major,
uint32_t &minor,
- uint32_t &update)
+ uint32_t &update,
+ Process *process)
{
Mutex::Locker locker (m_mutex);
@@ -566,6 +581,12 @@ Platform::GetOSVersion (uint32_t &major,
minor = m_minor_os_version;
update = m_update_os_version;
}
+ else if (process)
+ {
+ // Check with the process in case it can answer the question if
+ // a process was provided
+ return process->GetHostOSVersion(major, minor, update);
+ }
return success;
}
@@ -947,6 +968,12 @@ Platform::GetHostname ()
return m_name.c_str();
}
+ConstString
+Platform::GetFullNameForDylib (ConstString basename)
+{
+ return basename;
+}
+
bool
Platform::SetRemoteWorkingDirectory(const FileSpec &working_dir)
{
@@ -1811,7 +1838,7 @@ Platform::GetRemoteSharedModule (const ModuleSpec &module_spec,
{
// Try to get module information from the process
if (process->GetModuleSpec (module_spec.GetFileSpec (), module_spec.GetArchitecture (), resolved_module_spec))
- got_module_spec = true;
+ got_module_spec = true;
}
if (!got_module_spec)
@@ -1838,7 +1865,8 @@ Platform::GetCachedSharedModule (const ModuleSpec &module_spec,
bool *did_create_ptr)
{
if (IsHost() ||
- !GetGlobalPlatformProperties ()->GetUseModuleCache ())
+ !GetGlobalPlatformProperties ()->GetUseModuleCache () ||
+ !GetGlobalPlatformProperties ()->GetModuleCacheDirectory ())
return false;
Log *log = GetLogIfAnyCategoriesSet (LIBLLDB_LOG_PLATFORM);
@@ -1848,7 +1876,7 @@ Platform::GetCachedSharedModule (const ModuleSpec &module_spec,
GetModuleCacheRoot (),
GetCacheHostname (),
module_spec,
- [=](const ModuleSpec &module_spec, const FileSpec &tmp_download_file_spec)
+ [this](const ModuleSpec &module_spec, const FileSpec &tmp_download_file_spec)
{
return DownloadModuleSlice (module_spec.GetFileSpec (),
module_spec.GetObjectOffset (),
@@ -1856,6 +1884,10 @@ Platform::GetCachedSharedModule (const ModuleSpec &module_spec,
tmp_download_file_spec);
},
+ [this](const ModuleSP& module_sp, const FileSpec& tmp_download_file_spec)
+ {
+ return DownloadSymbolFile (module_sp, tmp_download_file_spec);
+ },
module_sp,
did_create_ptr);
if (error.Success ())
@@ -1918,6 +1950,12 @@ Platform::DownloadModuleSlice (const FileSpec& src_file_spec,
return error;
}
+Error
+Platform::DownloadSymbolFile (const lldb::ModuleSP& module_sp, const FileSpec& dst_file_spec)
+{
+ return Error ("Symbol file downloading not supported by the default platform.");
+}
+
FileSpec
Platform::GetModuleCacheRoot ()
{
@@ -1946,3 +1984,106 @@ Platform::GetUnixSignals()
return Host::GetUnixSignals();
return GetRemoteUnixSignals();
}
+
+uint32_t
+Platform::LoadImage(lldb_private::Process* process,
+ const lldb_private::FileSpec& local_file,
+ const lldb_private::FileSpec& remote_file,
+ lldb_private::Error& error)
+{
+ if (local_file && remote_file)
+ {
+ // Both local and remote file was specified. Install the local file to the given location.
+ if (IsRemote() || local_file != remote_file)
+ {
+ error = Install(local_file, remote_file);
+ if (error.Fail())
+ return LLDB_INVALID_IMAGE_TOKEN;
+ }
+ return DoLoadImage(process, remote_file, error);
+ }
+
+ if (local_file)
+ {
+ // Only local file was specified. Install it to the current working directory.
+ FileSpec target_file = GetWorkingDirectory();
+ target_file.AppendPathComponent(local_file.GetFilename().AsCString());
+ if (IsRemote() || local_file != target_file)
+ {
+ error = Install(local_file, target_file);
+ if (error.Fail())
+ return LLDB_INVALID_IMAGE_TOKEN;
+ }
+ return DoLoadImage(process, target_file, error);
+ }
+
+ if (remote_file)
+ {
+ // Only remote file was specified so we don't have to do any copying
+ return DoLoadImage(process, remote_file, error);
+ }
+
+ error.SetErrorString("Neither local nor remote file was specified");
+ return LLDB_INVALID_IMAGE_TOKEN;
+}
+
+uint32_t
+Platform::DoLoadImage (lldb_private::Process* process,
+ const lldb_private::FileSpec& remote_file,
+ lldb_private::Error& error)
+{
+ error.SetErrorString("LoadImage is not supported on the current platform");
+ return LLDB_INVALID_IMAGE_TOKEN;
+}
+
+Error
+Platform::UnloadImage(lldb_private::Process* process, uint32_t image_token)
+{
+ return Error("UnloadImage is not supported on the current platform");
+}
+
+lldb::ProcessSP
+Platform::ConnectProcess(const char* connect_url,
+ const char* plugin_name,
+ lldb_private::Debugger &debugger,
+ lldb_private::Target *target,
+ lldb_private::Error &error)
+{
+ error.Clear();
+
+ if (!target)
+ {
+ TargetSP new_target_sp;
+ error = debugger.GetTargetList().CreateTarget(debugger,
+ nullptr,
+ nullptr,
+ false,
+ nullptr,
+ new_target_sp);
+ target = new_target_sp.get();
+ }
+
+ if (!target || error.Fail())
+ return nullptr;
+
+ debugger.GetTargetList().SetSelectedTarget(target);
+
+ lldb::ProcessSP process_sp = target->CreateProcess(debugger.GetListener(),
+ plugin_name,
+ nullptr);
+ if (!process_sp)
+ return nullptr;
+
+ error = process_sp->ConnectRemote(debugger.GetOutputFile().get(), connect_url);
+ if (error.Fail())
+ return nullptr;
+
+ return process_sp;
+}
+
+size_t
+Platform::ConnectToWaitingProcesses(lldb_private::Debugger& debugger, lldb_private::Error& error)
+{
+ error.Clear();
+ return 0;
+}
diff --git a/source/Target/Process.cpp b/source/Target/Process.cpp
index 3abae4fce5b1d..6bc9f2b0c9d81 100644
--- a/source/Target/Process.cpp
+++ b/source/Target/Process.cpp
@@ -7,6 +7,10 @@
//
//===----------------------------------------------------------------------===//
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
#include "lldb/Target/Process.h"
#include "lldb/Breakpoint/StoppointCallbackContext.h"
#include "lldb/Breakpoint/BreakpointLocation.h"
@@ -18,9 +22,10 @@
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/State.h"
#include "lldb/Core/StreamFile.h"
-#include "lldb/Expression/ClangUserExpression.h"
+#include "lldb/Expression/UserExpression.h"
#include "lldb/Expression/IRDynamicChecks.h"
#include "lldb/Host/ConnectionFileDescriptor.h"
+#include "lldb/Host/FileSystem.h"
#include "lldb/Host/Host.h"
#include "lldb/Host/HostInfo.h"
#include "lldb/Host/Pipe.h"
@@ -28,6 +33,7 @@
#include "lldb/Host/ThreadLauncher.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/OptionValueProperties.h"
+#include "lldb/Symbol/Function.h"
#include "lldb/Symbol/Symbol.h"
#include "lldb/Target/ABI.h"
#include "lldb/Target/DynamicLoader.h"
@@ -56,7 +62,6 @@
using namespace lldb;
using namespace lldb_private;
-
// Comment out line below to disable memory caching, overriding the process setting
// target.process.disable-memory-cache
#define ENABLE_MEMORY_CACHING
@@ -83,8 +88,8 @@ public:
{
}
- virtual const Property *
- GetPropertyAtIndex (const ExecutionContext *exe_ctx, bool will_modify, uint32_t idx) const
+ const Property *
+ GetPropertyAtIndex(const ExecutionContext *exe_ctx, bool will_modify, uint32_t idx) const override
{
// When getting the value for a key from the process options, we will always
// try and grab the setting from the current process if there is one. Else we just
@@ -115,6 +120,7 @@ g_properties[] =
{ "stop-on-sharedlibrary-events" , OptionValue::eTypeBoolean, true, false, NULL, NULL, "If true, stop when a shared library is loaded or unloaded." },
{ "detach-keeps-stopped" , OptionValue::eTypeBoolean, true, false, NULL, NULL, "If true, detach will attempt to keep the process stopped." },
{ "memory-cache-line-size" , OptionValue::eTypeUInt64, false, 512, NULL, NULL, "The memory cache line size" },
+ { "optimization-warnings" , OptionValue::eTypeBoolean, false, true, NULL, NULL, "If true, warn when stopped in code that is optimized where stepping and variable availability may not behave as expected." },
{ NULL , OptionValue::eTypeInvalid, false, 0, NULL, NULL, NULL }
};
@@ -126,7 +132,8 @@ enum {
ePropertyPythonOSPluginPath,
ePropertyStopOnSharedLibraryEvents,
ePropertyDetachKeepsStopped,
- ePropertyMemCacheLineSize
+ ePropertyMemCacheLineSize,
+ ePropertyWarningOptimization
};
ProcessProperties::ProcessProperties (lldb_private::Process *process) :
@@ -150,9 +157,7 @@ ProcessProperties::ProcessProperties (lldb_private::Process *process) :
}
}
-ProcessProperties::~ProcessProperties()
-{
-}
+ProcessProperties::~ProcessProperties() = default;
void
ProcessProperties::OptionValueChangedCallback (void *baton, OptionValue *option_value)
@@ -206,7 +211,6 @@ ProcessProperties::SetPythonOSPluginPath (const FileSpec &file)
m_collection_sp->SetPropertyAtIndexAsFileSpec(NULL, idx, file);
}
-
bool
ProcessProperties::GetIgnoreBreakpointsInExpressions () const
{
@@ -263,6 +267,13 @@ ProcessProperties::SetDetachKeepsStopped (bool stop)
m_collection_sp->SetPropertyAtIndexAsBoolean(NULL, idx, stop);
}
+bool
+ProcessProperties::GetWarningsOptimization () const
+{
+ const uint32_t idx = ePropertyWarningOptimization;
+ return m_collection_sp->GetPropertyAtIndexAsBoolean (NULL, idx, g_properties[idx].default_uint_value != 0);
+}
+
void
ProcessInstanceInfo::Dump (Stream &s, Platform *platform) const
{
@@ -306,8 +317,12 @@ ProcessInstanceInfo::Dump (Stream &s, Platform *platform) const
}
}
- if (m_arch.IsValid())
- s.Printf (" arch = %s\n", m_arch.GetTriple().str().c_str());
+ if (m_arch.IsValid())
+ {
+ s.Printf (" arch = ");
+ m_arch.DumpTriple(s);
+ s.EOL();
+ }
if (m_uid != UINT32_MAX)
{
@@ -360,7 +375,10 @@ ProcessInstanceInfo::DumpAsTableRow (Stream &s, Platform *platform, bool show_ar
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);
@@ -386,13 +404,14 @@ ProcessInstanceInfo::DumpAsTableRow (Stream &s, Platform *platform, bool show_ar
s.Printf ("%-10s ", cstr);
else
s.Printf ("%-10u ", m_egid);
- s.Printf ("%-24s ", m_arch.IsValid() ? m_arch.GetTriple().str().c_str() : "");
+
+ s.Printf ("%-24s ", arch_strm.GetString().c_str());
}
else
{
s.Printf ("%-10s %-24s ",
platform->GetUserName (m_euid),
- m_arch.IsValid() ? m_arch.GetTriple().str().c_str() : "");
+ arch_strm.GetString().c_str());
}
if (verbose || show_args)
@@ -460,7 +479,7 @@ ProcessLaunchCommandOptions::SetOptionValue (uint32_t option_idx, const char *op
case 'n': // Disable STDIO
{
FileAction action;
- const FileSpec dev_null{"/dev/null", false};
+ const FileSpec dev_null{FileSystem::DEV_NULL, false};
if (action.Open(STDIN_FILENO, dev_null, true, false))
launch_info.AppendFileAction (action);
if (action.Open(STDOUT_FILENO, dev_null, false, true))
@@ -545,8 +564,6 @@ ProcessLaunchCommandOptions::g_option_table[] =
{ 0 , false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL }
};
-
-
bool
ProcessInstanceInfoMatch::NameMatches (const char *process_name) const
{
@@ -626,7 +643,6 @@ ProcessInstanceInfoMatch::MatchAllProcesses () const
return false;
return true;
-
}
void
@@ -638,7 +654,7 @@ ProcessInstanceInfoMatch::Clear()
}
ProcessSP
-Process::FindPlugin (Target &target, const char *plugin_name, Listener &listener, const FileSpec *crash_file_path)
+Process::FindPlugin (lldb::TargetSP target_sp, const char *plugin_name, Listener &listener, const FileSpec *crash_file_path)
{
static uint32_t g_process_unique_id = 0;
@@ -650,10 +666,10 @@ Process::FindPlugin (Target &target, const char *plugin_name, Listener &listener
create_callback = PluginManager::GetProcessCreateCallbackForPluginName (const_plugin_name);
if (create_callback)
{
- process_sp = create_callback(target, listener, crash_file_path);
+ process_sp = create_callback(target_sp, listener, crash_file_path);
if (process_sp)
{
- if (process_sp->CanDebug(target, true))
+ if (process_sp->CanDebug(target_sp, true))
{
process_sp->m_process_unique_id = ++g_process_unique_id;
}
@@ -666,10 +682,10 @@ Process::FindPlugin (Target &target, const char *plugin_name, Listener &listener
{
for (uint32_t idx = 0; (create_callback = PluginManager::GetProcessCreateCallbackAtIndex(idx)) != NULL; ++idx)
{
- process_sp = create_callback(target, listener, crash_file_path);
+ process_sp = create_callback(target_sp, listener, crash_file_path);
if (process_sp)
{
- if (process_sp->CanDebug(target, false))
+ if (process_sp->CanDebug(target_sp, false))
{
process_sp->m_process_unique_id = ++g_process_unique_id;
break;
@@ -689,21 +705,18 @@ Process::GetStaticBroadcasterClass ()
return class_name;
}
-//----------------------------------------------------------------------
-// Process constructor
-//----------------------------------------------------------------------
-Process::Process(Target &target, Listener &listener) :
- Process(target, listener, UnixSignals::Create(HostInfo::GetArchitecture()))
+Process::Process(lldb::TargetSP target_sp, Listener &listener) :
+ Process(target_sp, listener, UnixSignals::Create(HostInfo::GetArchitecture()))
{
// This constructor just delegates to the full Process constructor,
// defaulting to using the Host's UnixSignals.
}
-Process::Process(Target &target, Listener &listener, const UnixSignalsSP &unix_signals_sp) :
+Process::Process(lldb::TargetSP target_sp, Listener &listener, const UnixSignalsSP &unix_signals_sp) :
ProcessProperties (this),
UserID (LLDB_INVALID_PROCESS_ID),
- Broadcaster (&(target.GetDebugger()), Process::GetStaticBroadcasterClass().AsCString()),
- m_target (target),
+ Broadcaster (&(target_sp->GetDebugger()), Process::GetStaticBroadcasterClass().AsCString()),
+ m_target_sp (target_sp),
m_public_state (eStateUnloaded),
m_private_state (eStateUnloaded),
m_private_state_broadcaster (NULL, "lldb.process.internal_state_broadcaster"),
@@ -746,7 +759,6 @@ Process::Process(Target &target, Listener &listener, const UnixSignalsSP &unix_s
m_next_event_action_ap(),
m_public_run_lock (),
m_private_run_lock (),
- m_currently_handling_event(false),
m_stop_info_override_callback (NULL),
m_finalizing (false),
m_finalize_called (false),
@@ -755,6 +767,7 @@ Process::Process(Target &target, Listener &listener, const UnixSignalsSP &unix_s
m_last_broadcast_state (eStateInvalid),
m_destroy_in_process (false),
m_can_interpret_function_calls(false),
+ m_warnings_issued (),
m_can_jit(eCanJITDontKnow)
{
CheckInWithManager ();
@@ -793,11 +806,15 @@ Process::Process(Target &target, Listener &listener, const UnixSignalsSP &unix_s
eBroadcastInternalStateControlResume);
// We need something valid here, even if just the default UnixSignalsSP.
assert (m_unix_signals_sp && "null m_unix_signals_sp after initialization");
+
+ // Allow the platform to override the default cache line size
+ OptionValueSP value_sp =
+ m_collection_sp->GetPropertyAtIndex(nullptr, true, ePropertyMemCacheLineSize)->GetValue();
+ uint32_t platform_cache_line_size = target_sp->GetPlatform()->GetDefaultMemoryCacheLineSize();
+ if (! value_sp->OptionWasSet() && platform_cache_line_size != 0)
+ value_sp->SetUInt64Value(platform_cache_line_size);
}
-//----------------------------------------------------------------------
-// Destructor
-//----------------------------------------------------------------------
Process::~Process()
{
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT));
@@ -974,7 +991,8 @@ Process::WaitForProcessToStop (const TimeValue *timeout,
EventSP *event_sp_ptr,
bool wait_always,
Listener *hijack_listener,
- Stream *stream)
+ Stream *stream,
+ bool use_run_lock)
{
// We can't just wait for a "stopped" event, because the stopped event may have restarted the target.
// We have to actually check each event, and in the case of a stopped event check the restarted flag
@@ -1001,7 +1019,7 @@ Process::WaitForProcessToStop (const TimeValue *timeout,
__FUNCTION__);
// We need to toggle the run lock as this won't get done in
// SetPublicState() if the process is hijacked.
- if (hijack_listener)
+ if (hijack_listener && use_run_lock)
m_public_run_lock.SetStopped();
return state;
}
@@ -1024,7 +1042,7 @@ Process::WaitForProcessToStop (const TimeValue *timeout,
case eStateUnloaded:
// We need to toggle the run lock as this won't get done in
// SetPublicState() if the process is hijacked.
- if (hijack_listener)
+ if (hijack_listener && use_run_lock)
m_public_run_lock.SetStopped();
return state;
case eStateStopped:
@@ -1034,7 +1052,7 @@ Process::WaitForProcessToStop (const TimeValue *timeout,
{
// We need to toggle the run lock as this won't get done in
// SetPublicState() if the process is hijacked.
- if (hijack_listener)
+ if (hijack_listener && use_run_lock)
m_public_run_lock.SetStopped();
return state;
}
@@ -1247,14 +1265,10 @@ Process::HandleProcessStateChangedEvent (const EventSP &event_sp,
return true;
}
-
StateType
-Process::WaitForState
-(
- const TimeValue *timeout,
- const StateType *match_states,
- const uint32_t num_match_states
-)
+Process::WaitForState(const TimeValue *timeout,
+ const StateType *match_states,
+ const uint32_t num_match_states)
{
EventSP event_sp;
uint32_t i;
@@ -1294,23 +1308,6 @@ Process::RestoreProcessEvents ()
RestoreBroadcaster();
}
-bool
-Process::HijackPrivateProcessEvents (Listener *listener)
-{
- if (listener != NULL)
- {
- return m_private_state_broadcaster.HijackBroadcaster(listener, eBroadcastBitStateChanged | eBroadcastBitInterrupt);
- }
- else
- return false;
-}
-
-void
-Process::RestorePrivateProcessEvents ()
-{
- m_private_state_broadcaster.RestoreBroadcaster();
-}
-
StateType
Process::WaitForStateChangedEvents (const TimeValue *timeout, EventSP &event_sp, Listener *hijack_listener)
{
@@ -1429,7 +1426,6 @@ Process::GetExitStatus ()
return -1;
}
-
const char *
Process::GetExitDescription ()
{
@@ -1468,12 +1464,7 @@ Process::SetExitStatus (int status, const char *cstr)
else
m_exit_string.clear();
- // When we exit, we no longer need to the communication channel
- m_stdio_communication.Disconnect();
- m_stdio_communication.StopReadThread();
- m_stdin_forward = false;
-
- // And we don't need the input reader anymore as well
+ // When we exit, we don't need the input reader anymore
if (m_process_input_reader)
{
m_process_input_reader->SetIsDone(true);
@@ -1493,6 +1484,29 @@ Process::SetExitStatus (int status, const char *cstr)
return true;
}
+bool
+Process::IsAlive ()
+{
+ switch (m_private_state.GetValue())
+ {
+ case eStateInvalid:
+ case eStateUnloaded:
+ case eStateDetached:
+ case eStateExited:
+ return false;
+
+ case eStateConnected:
+ case eStateAttaching:
+ case eStateLaunching:
+ case eStateStopped:
+ case eStateRunning:
+ case eStateStepping:
+ case eStateCrashed:
+ case eStateSuspended:
+ return true;
+ }
+}
+
// This static callback can be used to watch for local child processes on
// the current host. The child process exits, the process will be
// found in the global target list (we want to be completely sure that the
@@ -1534,7 +1548,6 @@ Process::SetProcessExitStatus (void *callback_baton,
return false;
}
-
void
Process::UpdateThreadListIfNeeded ()
{
@@ -1558,41 +1571,38 @@ Process::UpdateThreadListIfNeeded ()
// Don't call into the OperatingSystem to update the thread list if we are shutting down, since
// that may call back into the SBAPI's, requiring the API lock which is already held by whoever is
// shutting us down, causing a deadlock.
- if (!m_destroy_in_process)
+ OperatingSystem *os = GetOperatingSystem ();
+ if (os && !m_destroy_in_process)
{
- OperatingSystem *os = GetOperatingSystem ();
- if (os)
- {
- // Clear any old backing threads where memory threads might have been
- // backed by actual threads from the lldb_private::Process subclass
- size_t num_old_threads = old_thread_list.GetSize(false);
- for (size_t i=0; i<num_old_threads; ++i)
- old_thread_list.GetThreadAtIndex(i, false)->ClearBackingThread();
-
- // Turn off dynamic types to ensure we don't run any expressions. Objective C
- // can run an expression to determine if a SBValue is a dynamic type or not
- // and we need to avoid this. OperatingSystem plug-ins can't run expressions
- // that require running code...
-
- Target &target = GetTarget();
- const lldb::DynamicValueType saved_prefer_dynamic = target.GetPreferDynamicValue ();
- if (saved_prefer_dynamic != lldb::eNoDynamicValues)
- target.SetPreferDynamicValue(lldb::eNoDynamicValues);
-
- // Now let the OperatingSystem plug-in update the thread list
-
- os->UpdateThreadList (old_thread_list, // Old list full of threads created by OS plug-in
- real_thread_list, // The actual thread list full of threads created by each lldb_private::Process subclass
- new_thread_list); // The new thread list that we will show to the user that gets filled in
-
- if (saved_prefer_dynamic != lldb::eNoDynamicValues)
- target.SetPreferDynamicValue(saved_prefer_dynamic);
- }
- else
- {
- // No OS plug-in, the new thread list is the same as the real thread list
- new_thread_list = real_thread_list;
- }
+ // Clear any old backing threads where memory threads might have been
+ // backed by actual threads from the lldb_private::Process subclass
+ size_t num_old_threads = old_thread_list.GetSize(false);
+ for (size_t i=0; i<num_old_threads; ++i)
+ old_thread_list.GetThreadAtIndex(i, false)->ClearBackingThread();
+
+ // Turn off dynamic types to ensure we don't run any expressions. Objective C
+ // can run an expression to determine if a SBValue is a dynamic type or not
+ // and we need to avoid this. OperatingSystem plug-ins can't run expressions
+ // that require running code...
+
+ Target &target = GetTarget();
+ const lldb::DynamicValueType saved_prefer_dynamic = target.GetPreferDynamicValue ();
+ if (saved_prefer_dynamic != lldb::eNoDynamicValues)
+ target.SetPreferDynamicValue(lldb::eNoDynamicValues);
+
+ // Now let the OperatingSystem plug-in update the thread list
+
+ os->UpdateThreadList (old_thread_list, // Old list full of threads created by OS plug-in
+ real_thread_list, // The actual thread list full of threads created by each lldb_private::Process subclass
+ new_thread_list); // The new thread list that we will show to the user that gets filled in
+
+ if (saved_prefer_dynamic != lldb::eNoDynamicValues)
+ target.SetPreferDynamicValue(saved_prefer_dynamic);
+ }
+ else
+ {
+ // No OS plug-in, the new thread list is the same as the real thread list
+ new_thread_list = real_thread_list;
}
m_thread_list_real.Update(real_thread_list);
@@ -1648,15 +1658,7 @@ Process::GetNextThreadIndexID (uint64_t thread_id)
bool
Process::HasAssignedIndexIDToThread(uint64_t thread_id)
{
- std::map<uint64_t, uint32_t>::iterator iterator = m_thread_id_to_index_id_map.find(thread_id);
- if (iterator == m_thread_id_to_index_id_map.end())
- {
- return false;
- }
- else
- {
- return true;
- }
+ return (m_thread_id_to_index_id_map.find(thread_id) != m_thread_id_to_index_id_map.end());
}
uint32_t
@@ -1866,225 +1868,11 @@ Process::GetImageInfoAddress()
return LLDB_INVALID_ADDRESS;
}
-//----------------------------------------------------------------------
-// LoadImage
-//
-// This function provides a default implementation that works for most
-// unix variants. Any Process subclasses that need to do shared library
-// loading differently should override LoadImage and UnloadImage and
-// do what is needed.
-//----------------------------------------------------------------------
-uint32_t
-Process::LoadImage (const FileSpec &image_spec, Error &error)
-{
- if (m_finalizing)
- {
- error.SetErrorString("process is tearing itself down");
- return LLDB_INVALID_IMAGE_TOKEN;
- }
-
- char path[PATH_MAX];
- image_spec.GetPath(path, sizeof(path));
-
- DynamicLoader *loader = GetDynamicLoader();
- if (loader)
- {
- error = loader->CanLoadImage();
- if (error.Fail())
- return LLDB_INVALID_IMAGE_TOKEN;
- }
-
- if (error.Success())
- {
- ThreadSP thread_sp(GetThreadList ().GetSelectedThread());
-
- if (thread_sp)
- {
- StackFrameSP frame_sp (thread_sp->GetStackFrameAtIndex (0));
-
- if (frame_sp)
- {
- ExecutionContext exe_ctx;
- frame_sp->CalculateExecutionContext (exe_ctx);
- EvaluateExpressionOptions expr_options;
- expr_options.SetUnwindOnError(true);
- expr_options.SetIgnoreBreakpoints(true);
- expr_options.SetExecutionPolicy(eExecutionPolicyAlways);
- expr_options.SetResultIsInternal(true);
-
- StreamString expr;
- expr.Printf(R"(
- struct __lldb_dlopen_result { void *image_ptr; const char *error_str; } the_result;
- the_result.image_ptr = dlopen ("%s", 2);
- if (the_result.image_ptr == (void *) 0x0)
- {
- the_result.error_str = dlerror();
- }
- else
- {
- the_result.error_str = (const char *) 0x0;
- }
- the_result;
- )",
- path);
- const char *prefix = R"(
- extern "C" void* dlopen (const char *path, int mode);
- extern "C" const char *dlerror (void);
- )";
- lldb::ValueObjectSP result_valobj_sp;
- Error expr_error;
- ClangUserExpression::Evaluate (exe_ctx,
- expr_options,
- expr.GetData(),
- prefix,
- result_valobj_sp,
- expr_error);
- if (expr_error.Success())
- {
- error = result_valobj_sp->GetError();
- if (error.Success())
- {
- Scalar scalar;
- ValueObjectSP image_ptr_sp = result_valobj_sp->GetChildAtIndex(0, true);
- if (image_ptr_sp && image_ptr_sp->ResolveValue (scalar))
- {
- addr_t image_ptr = scalar.ULongLong(LLDB_INVALID_ADDRESS);
- if (image_ptr != 0 && image_ptr != LLDB_INVALID_ADDRESS)
- {
- uint32_t image_token = m_image_tokens.size();
- m_image_tokens.push_back (image_ptr);
- return image_token;
- }
- else if (image_ptr == 0)
- {
- ValueObjectSP error_str_sp = result_valobj_sp->GetChildAtIndex(1, true);
- if (error_str_sp)
- {
- if (error_str_sp->IsCStringContainer(true))
- {
- DataBufferSP buffer_sp(new DataBufferHeap(10240,0));
- size_t num_chars = error_str_sp->ReadPointedString (buffer_sp, error, 10240);
- if (error.Success() && num_chars > 0)
- {
- error.Clear();
- error.SetErrorStringWithFormat("dlopen error: %s", buffer_sp->GetBytes());
- }
- else
- {
- error.Clear();
- error.SetErrorStringWithFormat("dlopen failed for unknown reasons.");
- }
- }
- }
- }
- }
- }
- }
- else
- error = expr_error;
- }
- }
- }
- if (!error.AsCString())
- error.SetErrorStringWithFormat("unable to load '%s'", path);
- return LLDB_INVALID_IMAGE_TOKEN;
-}
-
-//----------------------------------------------------------------------
-// UnloadImage
-//
-// This function provides a default implementation that works for most
-// unix variants. Any Process subclasses that need to do shared library
-// loading differently should override LoadImage and UnloadImage and
-// do what is needed.
-//----------------------------------------------------------------------
-Error
-Process::UnloadImage (uint32_t image_token)
-{
- Error error;
-
- if (m_finalizing)
- {
- error.SetErrorString("process is tearing itself down");
- return error;
- }
-
- if (image_token < m_image_tokens.size())
- {
- const addr_t image_addr = m_image_tokens[image_token];
- if (image_addr == LLDB_INVALID_ADDRESS)
- {
- error.SetErrorString("image already unloaded");
- }
- else
- {
- DynamicLoader *loader = GetDynamicLoader();
- if (loader)
- error = loader->CanLoadImage();
-
- if (error.Success())
- {
- ThreadSP thread_sp(GetThreadList ().GetSelectedThread());
-
- if (thread_sp)
- {
- StackFrameSP frame_sp (thread_sp->GetStackFrameAtIndex (0));
-
- if (frame_sp)
- {
- ExecutionContext exe_ctx;
- frame_sp->CalculateExecutionContext (exe_ctx);
- EvaluateExpressionOptions expr_options;
- expr_options.SetUnwindOnError(true);
- expr_options.SetIgnoreBreakpoints(true);
- expr_options.SetExecutionPolicy(eExecutionPolicyAlways);
- StreamString expr;
- expr.Printf("dlclose ((void *)0x%" PRIx64 ")", image_addr);
- const char *prefix = "extern \"C\" int dlclose(void* handle);\n";
- lldb::ValueObjectSP result_valobj_sp;
- Error expr_error;
- ClangUserExpression::Evaluate (exe_ctx,
- expr_options,
- expr.GetData(),
- prefix,
- result_valobj_sp,
- expr_error);
- if (result_valobj_sp->GetError().Success())
- {
- Scalar scalar;
- if (result_valobj_sp->ResolveValue (scalar))
- {
- if (scalar.UInt(1))
- {
- error.SetErrorStringWithFormat("expression failed: \"%s\"", expr.GetData());
- }
- else
- {
- m_image_tokens[image_token] = LLDB_INVALID_ADDRESS;
- }
- }
- }
- else
- {
- error = result_valobj_sp->GetError();
- }
- }
- }
- }
- }
- }
- else
- {
- error.SetErrorString("invalid image token");
- }
- return error;
-}
-
const lldb::ABISP &
Process::GetABI()
{
if (!m_abi_sp)
- m_abi_sp = ABI::FindPlugin(m_target.GetArchitecture());
+ m_abi_sp = ABI::FindPlugin(GetTarget().GetArchitecture());
return m_abi_sp;
}
@@ -2167,7 +1955,6 @@ Process::GetBreakpointSiteList() const
return m_breakpoint_site_list;
}
-
void
Process::DisableAllBreakpointSites ()
{
@@ -2264,22 +2051,22 @@ Process::CreateBreakpointSite (const BreakpointLocationSP &owner, bool use_hardw
load_addr = ResolveIndirectFunction (&symbol_address, error);
if (!error.Success() && show_error)
{
- m_target.GetDebugger().GetErrorFile()->Printf ("warning: failed to resolve indirect function at 0x%" PRIx64 " for breakpoint %i.%i: %s\n",
- symbol->GetLoadAddress(&m_target),
- owner->GetBreakpoint().GetID(),
- owner->GetID(),
- error.AsCString() ? error.AsCString() : "unknown error");
+ GetTarget().GetDebugger().GetErrorFile()->Printf ("warning: failed to resolve indirect function at 0x%" PRIx64 " for breakpoint %i.%i: %s\n",
+ symbol->GetLoadAddress(&GetTarget()),
+ owner->GetBreakpoint().GetID(),
+ owner->GetID(),
+ error.AsCString() ? error.AsCString() : "unknown error");
return LLDB_INVALID_BREAK_ID;
}
Address resolved_address(load_addr);
- load_addr = resolved_address.GetOpcodeLoadAddress (&m_target);
+ load_addr = resolved_address.GetOpcodeLoadAddress (&GetTarget());
owner->SetIsIndirect(true);
}
else
- load_addr = owner->GetAddress().GetOpcodeLoadAddress (&m_target);
+ load_addr = owner->GetAddress().GetOpcodeLoadAddress (&GetTarget());
}
else
- load_addr = owner->GetAddress().GetOpcodeLoadAddress (&m_target);
+ load_addr = owner->GetAddress().GetOpcodeLoadAddress (&GetTarget());
if (load_addr != LLDB_INVALID_ADDRESS)
{
@@ -2312,11 +2099,11 @@ Process::CreateBreakpointSite (const BreakpointLocationSP &owner, bool use_hardw
if (show_error)
{
// Report error for setting breakpoint...
- m_target.GetDebugger().GetErrorFile()->Printf ("warning: failed to set breakpoint site at 0x%" PRIx64 " for breakpoint %i.%i: %s\n",
- load_addr,
- owner->GetBreakpoint().GetID(),
- owner->GetID(),
- error.AsCString() ? error.AsCString() : "unknown error");
+ GetTarget().GetDebugger().GetErrorFile()->Printf ("warning: failed to set breakpoint site at 0x%" PRIx64 " for breakpoint %i.%i: %s\n",
+ load_addr,
+ owner->GetBreakpoint().GetID(),
+ owner->GetID(),
+ error.AsCString() ? error.AsCString() : "unknown error");
}
}
}
@@ -2324,7 +2111,6 @@ Process::CreateBreakpointSite (const BreakpointLocationSP &owner, bool use_hardw
}
// We failed to enable the breakpoint
return LLDB_INVALID_BREAK_ID;
-
}
void
@@ -2340,7 +2126,6 @@ Process::RemoveOwnerFromBreakpointSite (lldb::user_id_t owner_id, lldb::user_id_
}
}
-
size_t
Process::RemoveBreakpointOpcodesFromBuffer (addr_t bp_addr, size_t size, uint8_t *buf) const
{
@@ -2369,14 +2154,12 @@ Process::RemoveBreakpointOpcodesFromBuffer (addr_t bp_addr, size_t size, uint8_t
return bytes_removed;
}
-
-
size_t
Process::GetSoftwareBreakpointTrapOpcode (BreakpointSite* bp_site)
{
- PlatformSP platform_sp (m_target.GetPlatform());
+ PlatformSP platform_sp (GetTarget().GetPlatform());
if (platform_sp)
- return platform_sp->GetSoftwareBreakpointTrapOpcode (m_target, bp_site);
+ return platform_sp->GetSoftwareBreakpointTrapOpcode (GetTarget(), bp_site);
return 0;
}
@@ -2550,7 +2333,6 @@ Process::DisableSoftwareBreakpoint (BreakpointSite *bp_site)
(uint64_t)bp_addr,
error.AsCString());
return error;
-
}
// Uncomment to verify memory caching works after making changes to caching code
@@ -2622,7 +2404,6 @@ Process::ReadCStringFromMemory (addr_t addr, std::string &out_str, Error &error)
return out_str.size();
}
-
size_t
Process::ReadStringFromMemory (addr_t addr, char *dst, size_t max_bytes, Error &error,
size_t type_width)
@@ -2772,7 +2553,6 @@ Process::ReadPointerFromMemory (lldb::addr_t vm_addr, Error &error)
return LLDB_INVALID_ADDRESS;
}
-
bool
Process::WritePointerToMemory (lldb::addr_t vm_addr,
lldb::addr_t ptr_value,
@@ -2843,6 +2623,7 @@ Process::WriteMemory (addr_t addr, const void *buf, size_t size, Error &error)
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);
@@ -2975,6 +2756,18 @@ Process::AllocateMemory(size_t size, uint32_t permissions, Error &error)
#endif
}
+addr_t
+Process::CallocateMemory(size_t size, uint32_t permissions, Error &error)
+{
+ addr_t return_addr = AllocateMemory(size, permissions, error);
+ if (error.Success())
+ {
+ std::string buffer(size, 0);
+ WriteMemory(return_addr, buffer.c_str(), size, error);
+ }
+ return return_addr;
+}
+
bool
Process::CanJIT ()
{
@@ -3042,12 +2835,16 @@ Process::DeallocateMemory (addr_t ptr)
return error;
}
-
ModuleSP
Process::ReadModuleFromMemory (const FileSpec& file_spec,
lldb::addr_t header_addr,
size_t size_to_read)
{
+ Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
+ if (log)
+ {
+ log->Printf ("Process::ReadModuleFromMemory reading %s binary from memory", file_spec.GetPath().c_str());
+ }
ModuleSP module_sp (new Module (file_spec, ArchSpec()));
if (module_sp)
{
@@ -3148,7 +2945,7 @@ Process::Launch (ProcessLaunchInfo &launch_info)
m_process_input_reader.reset();
m_stop_info_override_callback = NULL;
- Module *exe_module = m_target.GetExecutableModulePointer();
+ Module *exe_module = GetTarget().GetExecutableModulePointer();
if (exe_module)
{
char local_exec_file_path[PATH_MAX];
@@ -3214,7 +3011,6 @@ Process::Launch (ProcessLaunchInfo &launch_info)
}
else if (state == eStateStopped || state == eStateCrashed)
{
-
DidLaunch ();
DynamicLoader *dyld = GetDynamicLoader ();
@@ -3264,7 +3060,6 @@ Process::Launch (ProcessLaunchInfo &launch_info)
return error;
}
-
Error
Process::LoadCore ()
{
@@ -3495,7 +3290,7 @@ Process::Attach (ProcessAttachInfo &attach_info)
else
{
ProcessInstanceInfoList process_infos;
- PlatformSP platform_sp (m_target.GetPlatform ());
+ PlatformSP platform_sp (GetTarget().GetPlatform ());
if (platform_sp)
{
@@ -3597,7 +3392,7 @@ Process::CompleteAttach ()
if (process_arch.IsValid())
{
- m_target.SetArchitecture(process_arch);
+ GetTarget().SetArchitecture(process_arch);
if (log)
{
const char *triple_str = process_arch.GetTriple().getTriple().c_str ();
@@ -3609,19 +3404,19 @@ Process::CompleteAttach ()
// We just attached. If we have a platform, ask it for the process architecture, and if it isn't
// the same as the one we've already set, switch architectures.
- PlatformSP platform_sp (m_target.GetPlatform ());
+ PlatformSP platform_sp (GetTarget().GetPlatform ());
assert (platform_sp.get());
if (platform_sp)
{
- const ArchSpec &target_arch = m_target.GetArchitecture();
+ const ArchSpec &target_arch = GetTarget().GetArchitecture();
if (target_arch.IsValid() && !platform_sp->IsCompatibleArchitecture (target_arch, false, NULL))
{
ArchSpec platform_arch;
platform_sp = platform_sp->GetPlatformForArchitecture (target_arch, &platform_arch);
if (platform_sp)
{
- m_target.SetPlatform (platform_sp);
- m_target.SetArchitecture(platform_arch);
+ GetTarget().SetPlatform (platform_sp);
+ GetTarget().SetArchitecture(platform_arch);
if (log)
log->Printf ("Process::%s switching platform to %s and architecture to %s based on info from attach", __FUNCTION__, platform_sp->GetName().AsCString (""), platform_arch.GetTriple().getTriple().c_str ());
}
@@ -3631,9 +3426,9 @@ Process::CompleteAttach ()
ProcessInstanceInfo process_info;
platform_sp->GetProcessInfo (GetID(), process_info);
const ArchSpec &process_arch = process_info.GetArchitecture();
- if (process_arch.IsValid() && !m_target.GetArchitecture().IsExactMatch(process_arch))
+ if (process_arch.IsValid() && !GetTarget().GetArchitecture().IsExactMatch(process_arch))
{
- m_target.SetArchitecture (process_arch);
+ GetTarget().SetArchitecture (process_arch);
if (log)
log->Printf ("Process::%s switching architecture to %s based on info the platform retrieved for pid %" PRIu64, __FUNCTION__, process_arch.GetTriple().getTriple().c_str (), GetID ());
}
@@ -3648,7 +3443,7 @@ Process::CompleteAttach ()
dyld->DidAttach();
if (log)
{
- ModuleSP exe_module_sp = m_target.GetExecutableModule ();
+ ModuleSP exe_module_sp = GetTarget().GetExecutableModule ();
log->Printf ("Process::%s after DynamicLoader::DidAttach(), target executable is %s (using %s plugin)",
__FUNCTION__,
exe_module_sp ? exe_module_sp->GetFileSpec().GetPath().c_str () : "<none>",
@@ -3664,7 +3459,7 @@ Process::CompleteAttach ()
system_runtime->DidAttach();
if (log)
{
- ModuleSP exe_module_sp = m_target.GetExecutableModule ();
+ ModuleSP exe_module_sp = GetTarget().GetExecutableModule ();
log->Printf ("Process::%s after SystemRuntime::DidAttach(), target executable is %s (using %s plugin)",
__FUNCTION__,
exe_module_sp ? exe_module_sp->GetFileSpec().GetPath().c_str () : "<none>",
@@ -3674,7 +3469,7 @@ Process::CompleteAttach ()
m_os_ap.reset (OperatingSystem::FindPlugin (this, NULL));
// Figure out which one is the executable, and set that in our target:
- const ModuleList &target_modules = m_target.GetImages();
+ const ModuleList &target_modules = GetTarget().GetImages();
Mutex::Locker modules_locker(target_modules.GetMutex());
size_t num_modules = target_modules.GetSize();
ModuleSP new_executable_module_sp;
@@ -3684,17 +3479,17 @@ Process::CompleteAttach ()
ModuleSP module_sp (target_modules.GetModuleAtIndexUnlocked (i));
if (module_sp && module_sp->IsExecutable())
{
- if (m_target.GetExecutableModulePointer() != module_sp.get())
+ if (GetTarget().GetExecutableModulePointer() != module_sp.get())
new_executable_module_sp = module_sp;
break;
}
}
if (new_executable_module_sp)
{
- m_target.SetExecutableModule (new_executable_module_sp, false);
+ GetTarget().SetExecutableModule (new_executable_module_sp, false);
if (log)
{
- ModuleSP exe_module_sp = m_target.GetExecutableModule ();
+ ModuleSP exe_module_sp = GetTarget().GetExecutableModule ();
log->Printf ("Process::%s after looping through modules, target executable is %s",
__FUNCTION__,
exe_module_sp ? exe_module_sp->GetFileSpec().GetPath().c_str () : "<none>");
@@ -3742,7 +3537,6 @@ Process::ConnectRemote (Stream *strm, const char *remote_url)
return error;
}
-
Error
Process::PrivateResume ()
{
@@ -3803,150 +3597,99 @@ Process::PrivateResume ()
}
Error
-Process::Halt (bool clear_thread_plans)
+Process::Halt (bool clear_thread_plans, bool use_run_lock)
{
+ if (! StateIsRunningState(m_public_state.GetValue()))
+ return Error("Process is not running.");
+
// Don't clear the m_clear_thread_plans_on_stop, only set it to true if
// in case it was already set and some thread plan logic calls halt on its
// own.
m_clear_thread_plans_on_stop |= clear_thread_plans;
- // First make sure we aren't in the middle of handling an event, or we might restart. This is pretty weak, since
- // we could just straightaway get another event. It just narrows the window...
- m_currently_handling_event.WaitForValueEqualTo(false);
-
-
- // Pause our private state thread so we can ensure no one else eats
- // the stop event out from under us.
Listener halt_listener ("lldb.process.halt_listener");
- HijackPrivateProcessEvents(&halt_listener);
+ HijackProcessEvents(&halt_listener);
EventSP event_sp;
- Error error (WillHalt());
- bool restored_process_events = false;
- if (error.Success())
+ SendAsyncInterrupt();
+
+ if (m_public_state.GetValue() == eStateAttaching)
{
-
- bool caused_stop = false;
-
- // Ask the process subclass to actually halt our process
- error = DoHalt(caused_stop);
- if (error.Success())
- {
- if (m_public_state.GetValue() == eStateAttaching)
- {
- // Don't hijack and eat the eStateExited as the code that was doing
- // the attach will be waiting for this event...
- RestorePrivateProcessEvents();
- restored_process_events = true;
- SetExitStatus(SIGKILL, "Cancelled async attach.");
- Destroy (false);
- }
- else
- {
- // If "caused_stop" is true, then DoHalt stopped the process. If
- // "caused_stop" is false, the process was already stopped.
- // If the DoHalt caused the process to stop, then we want to catch
- // this event and set the interrupted bool to true before we pass
- // this along so clients know that the process was interrupted by
- // a halt command.
- if (caused_stop)
- {
- // Wait for 1 second for the process to stop.
- TimeValue timeout_time;
- timeout_time = TimeValue::Now();
- timeout_time.OffsetWithSeconds(10);
- bool got_event = halt_listener.WaitForEvent (&timeout_time, event_sp);
- StateType state = ProcessEventData::GetStateFromEvent(event_sp.get());
-
- if (!got_event || state == eStateInvalid)
- {
- // We timeout out and didn't get a stop event...
- error.SetErrorStringWithFormat ("Halt timed out. State = %s", StateAsCString(GetState()));
- }
- else
- {
- if (StateIsStoppedState (state, false))
- {
- // We caused the process to interrupt itself, so mark this
- // as such in the stop event so clients can tell an interrupted
- // process from a natural stop
- ProcessEventData::SetInterruptedInEvent (event_sp.get(), true);
- }
- else
- {
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS));
- if (log)
- log->Printf("Process::Halt() failed to stop, state is: %s", StateAsCString(state));
- error.SetErrorString ("Did not get stopped event after halt.");
- }
- }
- }
- DidHalt();
- }
- }
+ // Don't hijack and eat the eStateExited as the code that was doing
+ // the attach will be waiting for this event...
+ RestoreProcessEvents();
+ SetExitStatus(SIGKILL, "Cancelled async attach.");
+ Destroy (false);
+ return Error();
}
- // Resume our private state thread before we post the event (if any)
- if (!restored_process_events)
- RestorePrivateProcessEvents();
- // Post any event we might have consumed. If all goes well, we will have
- // stopped the process, intercepted the event and set the interrupted
- // bool in the event. Post it to the private event queue and that will end up
- // correctly setting the state.
- if (event_sp)
- m_private_state_broadcaster.BroadcastEvent(event_sp);
+ // Wait for 10 second for the process to stop.
+ TimeValue timeout_time;
+ timeout_time = TimeValue::Now();
+ timeout_time.OffsetWithSeconds(10);
+ StateType state = WaitForProcessToStop(&timeout_time, &event_sp, true, &halt_listener,
+ nullptr, use_run_lock);
+ RestoreProcessEvents();
- return error;
+ if (state == eStateInvalid || ! event_sp)
+ {
+ // We timed out and didn't get a stop event...
+ return Error("Halt timed out. State = %s", StateAsCString(GetState()));
+ }
+
+ BroadcastEvent(event_sp);
+
+ return Error();
}
Error
-Process::HaltForDestroyOrDetach(lldb::EventSP &exit_event_sp)
+Process::StopForDestroyOrDetach(lldb::EventSP &exit_event_sp)
{
Error error;
if (m_public_state.GetValue() == eStateRunning)
{
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS));
if (log)
- log->Printf("Process::Destroy() About to halt.");
- error = Halt();
- if (error.Success())
+ log->Printf("Process::%s() About to stop.", __FUNCTION__);
+
+ ListenerSP listener_sp (new Listener("lldb.Process.StopForDestroyOrDetach.hijack"));
+ HijackProcessEvents(listener_sp.get());
+
+ SendAsyncInterrupt();
+
+ // Consume the interrupt event.
+ TimeValue timeout (TimeValue::Now());
+ timeout.OffsetWithSeconds(10);
+
+ StateType state = WaitForProcessToStop (&timeout, &exit_event_sp, true, listener_sp.get());
+
+ RestoreProcessEvents();
+
+ // If the process exited while we were waiting for it to stop, put the exited event into
+ // the shared pointer passed in and return. Our caller doesn't need to do anything else, since
+ // they don't have a process anymore...
+
+ if (state == eStateExited || m_private_state.GetValue() == eStateExited)
{
- // Consume the halt event.
- TimeValue timeout (TimeValue::Now());
- timeout.OffsetWithSeconds(1);
- StateType state = WaitForProcessToStop (&timeout, &exit_event_sp);
-
- // If the process exited while we were waiting for it to stop, put the exited event into
- // the shared pointer passed in and return. Our caller doesn't need to do anything else, since
- // they don't have a process anymore...
-
- if (state == eStateExited || m_private_state.GetValue() == eStateExited)
- {
- if (log)
- log->Printf("Process::HaltForDestroyOrDetach() Process exited while waiting to Halt.");
- return error;
- }
- else
- exit_event_sp.reset(); // It is ok to consume any non-exit stop events
-
- if (state != eStateStopped)
- {
- if (log)
- log->Printf("Process::HaltForDestroyOrDetach() Halt failed to stop, state is: %s", StateAsCString(state));
- // If we really couldn't stop the process then we should just error out here, but if the
- // lower levels just bobbled sending the event and we really are stopped, then continue on.
- StateType private_state = m_private_state.GetValue();
- if (private_state != eStateStopped)
- {
- return error;
- }
- }
+ if (log)
+ log->Printf("Process::%s() Process exited while waiting to stop.", __FUNCTION__);
+ return error;
}
else
+ exit_event_sp.reset(); // It is ok to consume any non-exit stop events
+
+ if (state != eStateStopped)
{
if (log)
- log->Printf("Process::HaltForDestroyOrDetach() Halt got error: %s", error.AsCString());
+ log->Printf("Process::%s() failed to stop, state is: %s", __FUNCTION__, StateAsCString(state));
+ // If we really couldn't stop the process then we should just error out here, but if the
+ // lower levels just bobbled sending the event and we really are stopped, then continue on.
+ StateType private_state = m_private_state.GetValue();
+ if (private_state != eStateStopped)
+ {
+ return error;
+ }
}
}
return error;
@@ -3965,7 +3708,7 @@ Process::Detach (bool keep_stopped)
{
if (DetachRequiresHalt())
{
- error = HaltForDestroyOrDetach (exit_event_sp);
+ error = StopForDestroyOrDetach (exit_event_sp);
if (!error.Success())
{
m_destroy_in_process = false;
@@ -4016,7 +3759,7 @@ Process::Detach (bool keep_stopped)
Error
Process::Destroy (bool force_kill)
{
-
+
// Tell ourselves we are in the process of destroying the process, so that we don't do any unnecessary work
// that might hinder the destruction. Remember to set this back to false when we are done. That way if the attempt
// failed and the process stays around for some reason it won't be in a confused state.
@@ -4039,7 +3782,7 @@ Process::Destroy (bool force_kill)
EventSP exit_event_sp;
if (DestroyRequiresHalt())
{
- error = HaltForDestroyOrDetach(exit_event_sp);
+ error = StopForDestroyOrDetach(exit_event_sp);
}
if (m_public_state.GetValue() != eStateRunning)
@@ -4103,7 +3846,7 @@ Process::Signal (int signal)
}
void
-Process::SetUnixSignals (const UnixSignalsSP &signals_sp)
+Process::SetUnixSignals(UnixSignalsSP &&signals_sp)
{
assert (signals_sp && "null signals_sp");
m_unix_signals_sp = signals_sp;
@@ -4119,16 +3862,15 @@ Process::GetUnixSignals ()
lldb::ByteOrder
Process::GetByteOrder () const
{
- return m_target.GetArchitecture().GetByteOrder();
+ return GetTarget().GetArchitecture().GetByteOrder();
}
uint32_t
Process::GetAddressByteSize () const
{
- return m_target.GetArchitecture().GetAddressByteSize();
+ return GetTarget().GetArchitecture().GetAddressByteSize();
}
-
bool
Process::ShouldBroadcastEvent (Event *event_ptr)
{
@@ -4142,6 +3884,10 @@ Process::ShouldBroadcastEvent (Event *event_ptr)
case eStateExited:
case eStateUnloaded:
m_stdio_communication.SynchronizeWithReadThread();
+ m_stdio_communication.Disconnect();
+ m_stdio_communication.StopReadThread();
+ m_stdin_forward = false;
+
// fall-through
case eStateConnected:
case eStateAttaching:
@@ -4258,7 +4004,6 @@ Process::ShouldBroadcastEvent (Event *event_ptr)
ProcessEventData::SetRestartedInEvent(event_ptr, true);
PrivateResume ();
}
-
}
else
{
@@ -4291,7 +4036,6 @@ Process::ShouldBroadcastEvent (Event *event_ptr)
return return_value;
}
-
bool
Process::StartPrivateStateThread (bool is_secondary_thread)
{
@@ -4326,7 +4070,7 @@ Process::StartPrivateStateThread (bool is_secondary_thread)
// Create the private state thread, and start it running.
PrivateStateThreadArgs args = {this, is_secondary_thread};
- m_private_state_thread = ThreadLauncher::LaunchThread(thread_name, Process::PrivateStateThread, (void *) &args, NULL);
+ m_private_state_thread = ThreadLauncher::LaunchThread(thread_name, Process::PrivateStateThread, (void *) &args, NULL, 8 * 1024 * 1024);
if (m_private_state_thread.IsJoinable())
{
ResumePrivateStateThread();
@@ -4432,8 +4176,6 @@ Process::HandlePrivateEvent (EventSP &event_sp)
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS));
m_resume_requested = false;
- m_currently_handling_event.SetValue(true, eBroadcastNever);
-
const StateType new_state = Process::ProcessEventData::GetStateFromEvent(event_sp.get());
// First check to see if anybody wants a shot at this event:
@@ -4460,7 +4202,6 @@ Process::HandlePrivateEvent (EventSP &event_sp)
{
// FIXME: should cons up an exited event, and discard this one.
SetExitStatus(0, m_next_event_action_ap->GetExitString());
- m_currently_handling_event.SetValue(false, eBroadcastAlways);
SetNextEventAction(NULL);
return;
}
@@ -4532,7 +4273,7 @@ Process::HandlePrivateEvent (EventSP &event_sp)
// events) and we do need the IO handler to be pushed and popped
// correctly.
- if (is_hijacked || m_target.GetDebugger().IsHandlingEvents() == false)
+ if (is_hijacked || GetTarget().GetDebugger().IsHandlingEvents() == false)
PopProcessIOHandler ();
}
}
@@ -4550,7 +4291,22 @@ Process::HandlePrivateEvent (EventSP &event_sp)
StateAsCString (GetState ()));
}
}
- m_currently_handling_event.SetValue(false, eBroadcastAlways);
+}
+
+Error
+Process::HaltPrivate()
+{
+ EventSP event_sp;
+ Error error (WillHalt());
+ if (error.Fail())
+ return error;
+
+ // Ask the process subclass to actually halt our process
+ bool caused_stop;
+ error = DoHalt(caused_stop);
+
+ DidHalt();
+ return error;
}
thread_result_t
@@ -4573,6 +4329,7 @@ Process::RunPrivateStateThread (bool is_secondary_thread)
__FUNCTION__, static_cast<void*>(this), GetID());
bool exit_now = false;
+ bool interrupt_requested = false;
while (!exit_now)
{
EventSP event_sp;
@@ -4612,13 +4369,32 @@ Process::RunPrivateStateThread (bool is_secondary_thread)
GetID());
BroadcastEvent (eBroadcastBitInterrupt, NULL);
}
- else
+ else if(StateIsRunningState(m_last_broadcast_state))
{
if (log)
log->Printf ("Process::%s (arg = %p, pid = %" PRIu64 ") woke up with an interrupt - Halting.",
__FUNCTION__, static_cast<void*>(this),
GetID());
- Halt();
+ Error error = HaltPrivate();
+ if (error.Fail() && log)
+ log->Printf ("Process::%s (arg = %p, pid = %" PRIu64 ") failed to halt the process: %s",
+ __FUNCTION__, static_cast<void*>(this),
+ GetID(), error.AsCString());
+ // Halt should generate a stopped event. Make a note of the fact that we were
+ // doing the interrupt, so we can set the interrupted flag after we receive the
+ // event. We deliberately set this to true even if HaltPrivate failed, so that we
+ // can interrupt on the next natural stop.
+ interrupt_requested = true;
+ }
+ else
+ {
+ // This can happen when someone (e.g. Process::Halt) sees that we are running and
+ // sends an interrupt request, but the process actually stops before we receive
+ // it. In that case, we can just ignore the request. We use
+ // m_last_broadcast_state, because the Stopped event may not have been popped of
+ // the event queue yet, which is when the public state gets updated.
+ if (log)
+ log->Printf("Process::%s ignoring interrupt as we have already stopped.", __FUNCTION__);
}
continue;
}
@@ -4633,6 +4409,23 @@ Process::RunPrivateStateThread (bool is_secondary_thread)
m_clear_thread_plans_on_stop = false;
m_thread_list.DiscardThreadPlans();
}
+
+ if (interrupt_requested)
+ {
+ if (StateIsStoppedState (internal_state, true))
+ {
+ // We requested the interrupt, so mark this as such in the stop event so
+ // clients can tell an interrupted process from a natural stop
+ ProcessEventData::SetInterruptedInEvent (event_sp.get(), true);
+ interrupt_requested = false;
+ }
+ else if (log)
+ {
+ log->Printf("Process::%s interrupt_requested, but a non-stopped state '%s' received.",
+ __FUNCTION__, StateAsCString(internal_state));
+ }
+ }
+
HandlePrivateEvent (event_sp);
}
@@ -4690,9 +4483,7 @@ Process::ProcessEventData::ProcessEventData (const ProcessSP &process_sp, StateT
m_process_wp = process_sp;
}
-Process::ProcessEventData::~ProcessEventData()
-{
-}
+Process::ProcessEventData::~ProcessEventData() = default;
const ConstString &
Process::ProcessEventData::GetFlavorString ()
@@ -4734,7 +4525,12 @@ Process::ProcessEventData::DoOnRemoval (Event *event_ptr)
// If we're stopped and haven't restarted, then do the StopInfo actions here:
if (m_state == eStateStopped && ! m_restarted)
- {
+ {
+ // Let process subclasses know we are about to do a public stop and
+ // do anything they might need to in order to speed up register and
+ // memory accesses.
+ process_sp->WillPublicStop();
+
ThreadList &curr_thread_list = process_sp->GetThreadList();
uint32_t num_threads = curr_thread_list.GetSize();
uint32_t idx;
@@ -4818,7 +4614,6 @@ Process::ProcessEventData::DoOnRemoval (Event *event_ptr)
still_should_stop = this_thread_wants_to_stop;
}
}
-
if (!GetRestarted())
{
@@ -4967,13 +4762,13 @@ Process::ProcessEventData::SetUpdateStateOnRemoval (Event *event_ptr)
lldb::TargetSP
Process::CalculateTarget ()
{
- return m_target.shared_from_this();
+ return m_target_sp.lock();
}
void
Process::CalculateExecutionContext (ExecutionContext &exe_ctx)
{
- exe_ctx.SetTargetPtr (&m_target);
+ exe_ctx.SetTargetPtr (&GetTarget());
exe_ctx.SetProcessPtr (this);
exe_ctx.SetThreadPtr(NULL);
exe_ctx.SetFramePtr (NULL);
@@ -5052,7 +4847,6 @@ Process::GetAsyncProfileData (char *buf, size_t buf_size, Error &error)
return bytes_available;
}
-
//------------------------------------------------------------------
// Process STDIO
//------------------------------------------------------------------
@@ -5084,7 +4878,6 @@ Process::GetSTDOUT (char *buf, size_t buf_size, Error &error)
return bytes_available;
}
-
size_t
Process::GetSTDERR (char *buf, size_t buf_size, Error &error)
{
@@ -5135,12 +4928,8 @@ public:
m_read_file.SetDescriptor(GetInputFD(), false);
}
- virtual
- ~IOHandlerProcessSTDIO ()
- {
-
- }
-
+ ~IOHandlerProcessSTDIO() override = default;
+
// Each IOHandler gets to run until it is done. It should read data
// from the "in" and place output into "out" and "err and return
// when done.
@@ -5207,7 +4996,7 @@ public:
break;
case 'i':
if (StateIsRunningState(m_process->GetState()))
- m_process->Halt();
+ m_process->SendAsyncInterrupt();
break;
}
}
@@ -5232,8 +5021,8 @@ public:
// Do only things that are safe to do in an interrupt context (like in
// a SIGINT handler), like write 1 byte to a file descriptor. This will
// interrupt the IOHandlerProcessSTDIO::Run() and we can look at the byte
- // that was written to the pipe and then call m_process->Halt() from a
- // much safer location in code.
+ // that was written to the pipe and then call m_process->SendAsyncInterrupt()
+ // from a much safer location in code.
if (m_active)
{
char ch = 'i'; // Send 'i' for interrupt
@@ -5263,7 +5052,6 @@ public:
void
GotEOF() override
{
-
}
protected:
@@ -5301,7 +5089,7 @@ Process::ProcessIOHandlerIsActive ()
{
IOHandlerSP io_handler_sp (m_process_input_reader);
if (io_handler_sp)
- return m_target.GetDebugger().IsTopIOHandler (io_handler_sp);
+ return GetTarget().GetDebugger().IsTopIOHandler (io_handler_sp);
return false;
}
bool
@@ -5315,7 +5103,7 @@ Process::PushProcessIOHandler ()
log->Printf("Process::%s pushing IO handler", __FUNCTION__);
io_handler_sp->SetIsDone(false);
- m_target.GetDebugger().PushIOHandler (io_handler_sp);
+ GetTarget().GetDebugger().PushIOHandler (io_handler_sp);
return true;
}
return false;
@@ -5326,7 +5114,7 @@ Process::PopProcessIOHandler ()
{
IOHandlerSP io_handler_sp (m_process_input_reader);
if (io_handler_sp)
- return m_target.GetDebugger().PopIOHandler (io_handler_sp);
+ return GetTarget().GetDebugger().PopIOHandler (io_handler_sp);
return false;
}
@@ -5343,6 +5131,54 @@ Process::SettingsTerminate ()
Thread::SettingsTerminate ();
}
+namespace
+{
+ // RestorePlanState is used to record the "is private", "is master" and "okay to discard" fields of
+ // the plan we are running, and reset it on Clean or on destruction.
+ // It will only reset the state once, so you can call Clean and then monkey with the state and it
+ // won't get reset on you again.
+
+ class RestorePlanState
+ {
+ public:
+ RestorePlanState (lldb::ThreadPlanSP thread_plan_sp) :
+ m_thread_plan_sp(thread_plan_sp),
+ m_already_reset(false)
+ {
+ if (m_thread_plan_sp)
+ {
+ m_private = m_thread_plan_sp->GetPrivate();
+ m_is_master = m_thread_plan_sp->IsMasterPlan();
+ m_okay_to_discard = m_thread_plan_sp->OkayToDiscard();
+ }
+ }
+
+ ~RestorePlanState()
+ {
+ Clean();
+ }
+
+ void
+ Clean ()
+ {
+ if (!m_already_reset && m_thread_plan_sp)
+ {
+ m_already_reset = true;
+ m_thread_plan_sp->SetPrivate(m_private);
+ m_thread_plan_sp->SetIsMasterPlan (m_is_master);
+ m_thread_plan_sp->SetOkayToDiscard(m_okay_to_discard);
+ }
+ }
+
+ private:
+ lldb::ThreadPlanSP m_thread_plan_sp;
+ bool m_already_reset;
+ bool m_private;
+ bool m_is_master;
+ bool m_okay_to_discard;
+ };
+} // anonymous namespace
+
ExpressionResults
Process::RunThreadPlan (ExecutionContext &exe_ctx,
lldb::ThreadPlanSP &thread_plan_sp,
@@ -5376,12 +5212,22 @@ Process::RunThreadPlan (ExecutionContext &exe_ctx,
return eExpressionSetupError;
}
+ // We need to change some of the thread plan attributes for the thread plan runner. This will restore them
+ // when we are done:
+
+ RestorePlanState thread_plan_restorer(thread_plan_sp);
+
// We rely on the thread plan we are running returning "PlanCompleted" if when it successfully completes.
// For that to be true the plan can't be private - since private plans suppress themselves in the
// GetCompletedPlan call.
- bool orig_plan_private = thread_plan_sp->GetPrivate();
thread_plan_sp->SetPrivate(false);
+
+ // The plans run with RunThreadPlan also need to be terminal master plans or when they are done we will end
+ // up asking the plan above us whether we should stop, which may give the wrong answer.
+
+ thread_plan_sp->SetIsMasterPlan (true);
+ thread_plan_sp->SetOkayToDiscard(false);
if (m_private_state.GetValue() != eStateStopped)
{
@@ -5553,7 +5399,6 @@ Process::RunThreadPlan (ExecutionContext &exe_ctx,
}
one_thread_timeout_usec = computed_one_thread_timeout;
all_threads_timeout_usec = timeout_usec - one_thread_timeout_usec;
-
}
}
@@ -5595,8 +5440,7 @@ Process::RunThreadPlan (ExecutionContext &exe_ctx,
#endif
TimeValue one_thread_timeout;
TimeValue final_timeout;
-
-
+
while (1)
{
// We usually want to resume the process if we get to the top of the loop.
@@ -5664,7 +5508,9 @@ Process::RunThreadPlan (ExecutionContext &exe_ctx,
{
// This is probably an overabundance of caution, I don't think I should ever get a stopped & restarted
// event here. But if I do, the best thing is to Halt and then get out of here.
- Halt();
+ const bool clear_thread_plans = false;
+ const bool use_run_lock = false;
+ Halt(clear_thread_plans, use_run_lock);
}
errors.Printf("Didn't get running event after initial resume, got %s instead.",
@@ -5758,7 +5604,9 @@ Process::RunThreadPlan (ExecutionContext &exe_ctx,
bool keep_going = false;
if (event_sp->GetType() == eBroadcastBitInterrupt)
{
- Halt();
+ const bool clear_thread_plans = false;
+ const bool use_run_lock = false;
+ Halt(clear_thread_plans, use_run_lock);
return_value = eExpressionInterrupted;
errors.Printf ("Execution halted by user interrupt.");
if (log)
@@ -5796,7 +5644,6 @@ Process::RunThreadPlan (ExecutionContext &exe_ctx,
keep_going = true;
do_resume = false;
handle_running_event = true;
-
}
else
{
@@ -5811,10 +5658,10 @@ Process::RunThreadPlan (ExecutionContext &exe_ctx,
{
if (log)
log->PutCString ("Process::RunThreadPlan(): execution completed successfully.");
- // Now mark this plan as private so it doesn't get reported as the stop reason
- // after this point.
- if (thread_plan_sp)
- thread_plan_sp->SetPrivate (orig_plan_private);
+
+ // Restore the plan state so it will get reported as intended when we are done.
+ thread_plan_restorer.Clean();
+
return_value = eExpressionCompleted;
}
else
@@ -5827,6 +5674,13 @@ Process::RunThreadPlan (ExecutionContext &exe_ctx,
return_value = eExpressionHitBreakpoint;
if (!options.DoesIgnoreBreakpoints())
{
+ // Restore the plan state and then force Private to false. We are
+ // going to stop because of this plan so we need it to become a public
+ // plan or it won't report correctly when we continue to its termination
+ // later on.
+ thread_plan_restorer.Clean();
+ if (thread_plan_sp)
+ thread_plan_sp->SetPrivate(false);
event_to_broadcast_sp = event_sp;
}
}
@@ -5929,7 +5783,9 @@ Process::RunThreadPlan (ExecutionContext &exe_ctx,
{
if (log)
log->Printf ("Process::RunThreadPlan(): Running Halt.");
- halt_error = Halt();
+ const bool clear_thread_plans = false;
+ const bool use_run_lock = false;
+ Halt(clear_thread_plans, use_run_lock);
}
if (halt_error.Success())
{
@@ -6045,6 +5901,19 @@ Process::RunThreadPlan (ExecutionContext &exe_ctx,
m_public_state.SetValueNoLock(old_state);
}
+ if (return_value != eExpressionCompleted && log)
+ {
+ // Print a backtrace into the log so we can figure out where we are:
+ StreamString s;
+ s.PutCString("Thread state after unsuccessful completion: \n");
+ thread->GetStackFrameStatus (s,
+ 0,
+ UINT32_MAX,
+ true,
+ UINT32_MAX);
+ log->PutCString(s.GetData());
+
+ }
// Restore the thread state if we are going to discard the plan execution. There are three cases where this
// could happen:
// 1) The execution successfully completed
@@ -6133,7 +6002,8 @@ Process::RunThreadPlan (ExecutionContext &exe_ctx,
else
ts.Printf("[ip unknown] ");
- lldb::StopInfoSP stop_info_sp = thread->GetStopInfo();
+ // Show the private stop info here, the public stop info will be from the last natural stop.
+ lldb::StopInfoSP stop_info_sp = thread->GetPrivateStopInfo();
if (stop_info_sp)
{
const char *stop_desc = stop_info_sp->GetDescription();
@@ -6159,7 +6029,6 @@ Process::RunThreadPlan (ExecutionContext &exe_ctx,
log->Printf ("Process::RunThreadPlan: ExecutionInterrupted - discarding thread plans up to %p.",
static_cast<void*>(thread_plan_sp.get()));
thread->DiscardThreadPlansUpToPlan (thread_plan_sp);
- thread_plan_sp->SetPrivate (orig_plan_private);
}
else
{
@@ -6176,7 +6045,6 @@ Process::RunThreadPlan (ExecutionContext &exe_ctx,
if (options.DoesUnwindOnError())
{
thread->DiscardThreadPlansUpToPlan (thread_plan_sp);
- thread_plan_sp->SetPrivate (orig_plan_private);
}
}
else
@@ -6202,7 +6070,6 @@ Process::RunThreadPlan (ExecutionContext &exe_ctx,
if (log)
log->PutCString("Process::RunThreadPlan(): discarding thread plan 'cause unwind_on_error is set.");
thread->DiscardThreadPlansUpToPlan (thread_plan_sp);
- thread_plan_sp->SetPrivate (orig_plan_private);
}
}
}
@@ -6360,7 +6227,6 @@ Process::GetThreadStatus (Stream &strm,
Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_PROCESS));
if (log)
log->Printf("Process::GetThreadStatus - thread 0x" PRIu64 " vanished while running Thread::GetStatus.");
-
}
}
return num_thread_infos_dumped;
@@ -6529,6 +6395,65 @@ Process::ModulesDidLoad (ModuleList &module_list)
if (language_runtime_sp)
language_runtime_sp->ModulesDidLoad(module_list);
}
+
+ LoadOperatingSystemPlugin(false);
+}
+
+void
+Process::PrintWarning (uint64_t warning_type, const void *repeat_key, const char *fmt, ...)
+{
+ bool print_warning = true;
+
+ StreamSP stream_sp = GetTarget().GetDebugger().GetAsyncOutputStream();
+ if (stream_sp.get() == nullptr)
+ return;
+ if (warning_type == eWarningsOptimization
+ && GetWarningsOptimization() == false)
+ {
+ return;
+ }
+
+ if (repeat_key != nullptr)
+ {
+ WarningsCollection::iterator it = m_warnings_issued.find (warning_type);
+ if (it == m_warnings_issued.end())
+ {
+ m_warnings_issued[warning_type] = WarningsPointerSet();
+ m_warnings_issued[warning_type].insert (repeat_key);
+ }
+ else
+ {
+ if (it->second.find (repeat_key) != it->second.end())
+ {
+ print_warning = false;
+ }
+ else
+ {
+ it->second.insert (repeat_key);
+ }
+ }
+ }
+
+ if (print_warning)
+ {
+ va_list args;
+ va_start (args, fmt);
+ stream_sp->PrintfVarArg (fmt, args);
+ va_end (args);
+ }
+}
+
+void
+Process::PrintWarningOptimization (const SymbolContext &sc)
+{
+ if (GetWarningsOptimization() == true
+ && sc.module_sp.get()
+ && sc.module_sp->GetFileSpec().GetFilename().IsEmpty() == false
+ && sc.function
+ && sc.function->GetIsOptimized() == true)
+ {
+ PrintWarning (Process::Warnings::eWarningsOptimization, sc.module_sp.get(), "%s was compiled with optimization - stepping may behave oddly; variables may not be available.\n", sc.module_sp->GetFileSpec().GetFilename().GetCString());
+ }
}
ThreadCollectionSP
@@ -6568,3 +6493,25 @@ Process::GetModuleSpec(const FileSpec& module_file_spec,
module_spec.Clear();
return false;
}
+
+size_t
+Process::AddImageToken(lldb::addr_t image_ptr)
+{
+ m_image_tokens.push_back(image_ptr);
+ return m_image_tokens.size() - 1;
+}
+
+lldb::addr_t
+Process::GetImagePtrFromToken(size_t token) const
+{
+ if (token < m_image_tokens.size())
+ return m_image_tokens[token];
+ return LLDB_INVALID_IMAGE_TOKEN;
+}
+
+void
+Process::ResetImageToken(size_t token)
+{
+ if (token < m_image_tokens.size())
+ m_image_tokens[token] = LLDB_INVALID_IMAGE_TOKEN;
+}
diff --git a/source/Target/ProcessLaunchInfo.cpp b/source/Target/ProcessLaunchInfo.cpp
index bd2e1bc4c4a10..fc17fe614c5cd 100644
--- a/source/Target/ProcessLaunchInfo.cpp
+++ b/source/Target/ProcessLaunchInfo.cpp
@@ -11,6 +11,7 @@
#include "lldb/Core/Debugger.h"
#include "lldb/Core/Log.h"
+#include "lldb/Host/FileSystem.h"
#include "lldb/Target/ProcessLaunchInfo.h"
#include "lldb/Target/FileAction.h"
#include "lldb/Target/Target.h"
@@ -129,7 +130,7 @@ bool
ProcessLaunchInfo::AppendSuppressFileAction (int fd, bool read, bool write)
{
FileAction file_action;
- if (file_action.Open(fd, FileSpec{"/dev/null", false}, read, write))
+ if (file_action.Open(fd, FileSpec{FileSystem::DEV_NULL, false}, read, write))
{
AppendFileAction (file_action);
return true;
diff --git a/source/Target/RegisterContext.cpp b/source/Target/RegisterContext.cpp
index 97f6f21c53c8d..afc815ba4a4eb 100644
--- a/source/Target/RegisterContext.cpp
+++ b/source/Target/RegisterContext.cpp
@@ -20,6 +20,7 @@
#include "lldb/Target/StackFrame.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Thread.h"
+#include "lldb/Target/Target.h"
using namespace lldb;
using namespace lldb_private;
@@ -103,7 +104,20 @@ uint64_t
RegisterContext::GetPC(uint64_t fail_value)
{
uint32_t reg = ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC);
- return ReadRegisterAsUnsigned (reg, fail_value);
+ uint64_t pc = ReadRegisterAsUnsigned (reg, fail_value);
+
+ if (pc != fail_value)
+ {
+ TargetSP target_sp = m_thread.CalculateTarget();
+ if (target_sp)
+ {
+ Target *target = target_sp.get();
+ if (target)
+ pc = target->GetOpcodeLoadAddress (pc, eAddressClassCode);
+ }
+ }
+
+ return pc;
}
bool
@@ -557,7 +571,7 @@ RegisterContext::ConvertBetweenRegisterKinds (lldb::RegisterKind source_rk, uint
// case 1:
// {
// int8_t v;
-// if (data.ExtractBytes (0, sizeof (int8_t), lldb::endian::InlHostByteOrder(), &v) != sizeof (int8_t))
+// if (data.ExtractBytes (0, sizeof (int8_t), endian::InlHostByteOrder(), &v) != sizeof (int8_t))
// return false;
// value = v;
// return true;
@@ -565,7 +579,7 @@ RegisterContext::ConvertBetweenRegisterKinds (lldb::RegisterKind source_rk, uint
// case 2:
// {
// int16_t v;
-// if (data.ExtractBytes (0, sizeof (int16_t), lldb::endian::InlHostByteOrder(), &v) != sizeof (int16_t))
+// if (data.ExtractBytes (0, sizeof (int16_t), endian::InlHostByteOrder(), &v) != sizeof (int16_t))
// return false;
// value = v;
// return true;
@@ -573,7 +587,7 @@ RegisterContext::ConvertBetweenRegisterKinds (lldb::RegisterKind source_rk, uint
// case 4:
// {
// int32_t v;
-// if (data.ExtractBytes (0, sizeof (int32_t), lldb::endian::InlHostByteOrder(), &v) != sizeof (int32_t))
+// if (data.ExtractBytes (0, sizeof (int32_t), endian::InlHostByteOrder(), &v) != sizeof (int32_t))
// return false;
// value = v;
// return true;
@@ -581,7 +595,7 @@ RegisterContext::ConvertBetweenRegisterKinds (lldb::RegisterKind source_rk, uint
// case 8:
// {
// int64_t v;
-// if (data.ExtractBytes (0, sizeof (int64_t), lldb::endian::InlHostByteOrder(), &v) != sizeof (int64_t))
+// if (data.ExtractBytes (0, sizeof (int64_t), endian::InlHostByteOrder(), &v) != sizeof (int64_t))
// return false;
// value = v;
// return true;
@@ -594,7 +608,7 @@ RegisterContext::ConvertBetweenRegisterKinds (lldb::RegisterKind source_rk, uint
// case sizeof (float):
// {
// float v;
-// if (data.ExtractBytes (0, sizeof (float), lldb::endian::InlHostByteOrder(), &v) != sizeof (float))
+// if (data.ExtractBytes (0, sizeof (float), endian::InlHostByteOrder(), &v) != sizeof (float))
// return false;
// value = v;
// return true;
@@ -602,7 +616,7 @@ RegisterContext::ConvertBetweenRegisterKinds (lldb::RegisterKind source_rk, uint
// case sizeof (double):
// {
// double v;
-// if (data.ExtractBytes (0, sizeof (double), lldb::endian::InlHostByteOrder(), &v) != sizeof (double))
+// if (data.ExtractBytes (0, sizeof (double), endian::InlHostByteOrder(), &v) != sizeof (double))
// return false;
// value = v;
// return true;
@@ -610,7 +624,7 @@ RegisterContext::ConvertBetweenRegisterKinds (lldb::RegisterKind source_rk, uint
// case sizeof (long double):
// {
// double v;
-// if (data.ExtractBytes (0, sizeof (long double), lldb::endian::InlHostByteOrder(), &v) != sizeof (long double))
+// if (data.ExtractBytes (0, sizeof (long double), endian::InlHostByteOrder(), &v) != sizeof (long double))
// return false;
// value = v;
// return true;
diff --git a/source/Target/StackFrame.cpp b/source/Target/StackFrame.cpp
index 7c5b022dac7c0..e835521e78843 100644
--- a/source/Target/StackFrame.cpp
+++ b/source/Target/StackFrame.cpp
@@ -24,6 +24,7 @@
#include "lldb/Symbol/Function.h"
#include "lldb/Symbol/Symbol.h"
#include "lldb/Symbol/SymbolContextScope.h"
+#include "lldb/Symbol/Type.h"
#include "lldb/Symbol/VariableList.h"
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/Process.h"
@@ -259,7 +260,7 @@ StackFrame::GetFrameCodeAddress()
TargetSP target_sp (thread_sp->CalculateTarget());
if (target_sp)
{
- if (m_frame_code_addr.SetOpcodeLoadAddress (m_frame_code_addr.GetOffset(), target_sp.get()))
+ if (m_frame_code_addr.SetOpcodeLoadAddress (m_frame_code_addr.GetOffset(), target_sp.get(), eAddressClassCode))
{
ModuleSP module_sp (m_frame_code_addr.GetModule());
if (module_sp)
@@ -659,7 +660,7 @@ StackFrame::GetValueForVariableExpressionPath (const char *var_expr_cstr,
else
name_const_string.SetCStringWithLength (var_path.c_str(), separator_idx);
- var_sp = variable_list->FindVariable(name_const_string);
+ var_sp = variable_list->FindVariable(name_const_string, false);
bool synthetically_added_instance_object = false;
@@ -667,7 +668,8 @@ StackFrame::GetValueForVariableExpressionPath (const char *var_expr_cstr,
{
var_path.erase (0, name_const_string.GetLength ());
}
- else if (options & eExpressionPathOptionsAllowDirectIVarAccess)
+
+ if (!var_sp && (options & eExpressionPathOptionsAllowDirectIVarAccess))
{
// Check for direct ivars access which helps us with implicit
// access to ivars with the "this->" or "self->"
@@ -689,13 +691,43 @@ StackFrame::GetValueForVariableExpressionPath (const char *var_expr_cstr,
}
}
}
+
+ if (!var_sp && (options & eExpressionPathOptionsInspectAnonymousUnions))
+ {
+ // Check if any anonymous unions are there which contain a variable with the name we need
+ for (size_t i = 0;
+ i < variable_list->GetSize();
+ i++)
+ {
+ if (VariableSP variable_sp = variable_list->GetVariableAtIndex(i))
+ {
+ if (variable_sp->GetName().IsEmpty())
+ {
+ if (Type *var_type = variable_sp->GetType())
+ {
+ if (var_type->GetForwardCompilerType().IsAnonymousType())
+ {
+ valobj_sp = GetValueObjectForFrameVariable (variable_sp, use_dynamic);
+ if (!valobj_sp)
+ return valobj_sp;
+ valobj_sp = valobj_sp->GetChildMemberWithName(name_const_string, true);
+ if (valobj_sp)
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
- if (var_sp)
+ if (var_sp && !valobj_sp)
{
valobj_sp = GetValueObjectForFrameVariable (var_sp, use_dynamic);
if (!valobj_sp)
return valobj_sp;
-
+ }
+ if (valobj_sp)
+ {
// We are dumping at least one child
while (separator_idx != std::string::npos)
{
@@ -713,7 +745,7 @@ StackFrame::GetValueForVariableExpressionPath (const char *var_expr_cstr,
{
// Make sure we aren't trying to deref an objective
// C ivar if this is not allowed
- const uint32_t pointer_type_flags = valobj_sp->GetClangType().GetTypeInfo (NULL);
+ const uint32_t pointer_type_flags = valobj_sp->GetCompilerType().GetTypeInfo (NULL);
if ((pointer_type_flags & eTypeIsObjC) &&
(pointer_type_flags & eTypeIsPointer))
{
@@ -827,7 +859,7 @@ StackFrame::GetValueForVariableExpressionPath (const char *var_expr_cstr,
if (end && *end == ']'
&& *(end-1) != '[') // this code forces an error in the case of arr[]. as bitfield[] is not a good syntax we're good to go
{
- if (valobj_sp->GetClangType().IsPointerToScalarType() && deref)
+ if (valobj_sp->GetCompilerType().IsPointerToScalarType() && deref)
{
// what we have is *ptr[low]. the most similar C++ syntax is to deref ptr
// and extract bit low out of it. reading array item low
@@ -845,7 +877,7 @@ StackFrame::GetValueForVariableExpressionPath (const char *var_expr_cstr,
valobj_sp = temp;
deref = false;
}
- else if (valobj_sp->GetClangType().IsArrayOfScalarType() && deref)
+ else if (valobj_sp->GetCompilerType().IsArrayOfScalarType() && deref)
{
// what we have is *arr[low]. the most similar C++ syntax is to get arr[0]
// (an operation that is equivalent to deref-ing arr)
@@ -870,9 +902,9 @@ StackFrame::GetValueForVariableExpressionPath (const char *var_expr_cstr,
{
bool is_objc_pointer = true;
- if (valobj_sp->GetClangType().GetMinimumLanguage() != eLanguageTypeObjC)
+ if (valobj_sp->GetCompilerType().GetMinimumLanguage() != eLanguageTypeObjC)
is_objc_pointer = false;
- else if (!valobj_sp->GetClangType().IsPointerType())
+ else if (!valobj_sp->GetCompilerType().IsPointerType())
is_objc_pointer = false;
if (no_synth_child && is_objc_pointer)
@@ -929,7 +961,7 @@ StackFrame::GetValueForVariableExpressionPath (const char *var_expr_cstr,
}
}
}
- else if (valobj_sp->GetClangType().IsArrayType (NULL, NULL, &is_incomplete_array))
+ else if (valobj_sp->GetCompilerType().IsArrayType (NULL, NULL, &is_incomplete_array))
{
// Pass false to dynamic_value here so we can tell the difference between
// no dynamic value and no member of this type...
@@ -946,7 +978,7 @@ StackFrame::GetValueForVariableExpressionPath (const char *var_expr_cstr,
var_expr_path_strm.GetString().c_str());
}
}
- else if (valobj_sp->GetClangType().IsScalarType())
+ else if (valobj_sp->GetCompilerType().IsScalarType())
{
// this is a bitfield asking to display just one bit
child_valobj_sp = valobj_sp->GetSyntheticBitFieldChild(child_index, child_index, true);
@@ -1029,7 +1061,7 @@ StackFrame::GetValueForVariableExpressionPath (const char *var_expr_cstr,
final_index = temp;
}
- if (valobj_sp->GetClangType().IsPointerToScalarType() && deref)
+ if (valobj_sp->GetCompilerType().IsPointerToScalarType() && deref)
{
// what we have is *ptr[low-high]. the most similar C++ syntax is to deref ptr
// and extract bits low thru high out of it. reading array items low thru high
@@ -1047,7 +1079,7 @@ StackFrame::GetValueForVariableExpressionPath (const char *var_expr_cstr,
valobj_sp = temp;
deref = false;
}
- else if (valobj_sp->GetClangType().IsArrayOfScalarType() && deref)
+ else if (valobj_sp->GetCompilerType().IsArrayOfScalarType() && deref)
{
// what we have is *arr[low-high]. the most similar C++ syntax is to get arr[0]
// (an operation that is equivalent to deref-ing arr)
@@ -1316,6 +1348,15 @@ StackFrame::IsInlined ()
return false;
}
+lldb::LanguageType
+StackFrame::GetLanguage ()
+{
+ CompileUnit *cu = GetSymbolContext(eSymbolContextCompUnit).comp_unit;
+ if (cu)
+ return cu->GetLanguage();
+ return lldb::eLanguageTypeUnknown;
+}
+
TargetSP
StackFrame::CalculateTarget ()
{
@@ -1478,7 +1519,7 @@ StackFrame::GetStatus (Stream& strm,
if (show_source)
{
ExecutionContext exe_ctx (shared_from_this());
- bool have_source = false;
+ bool have_source = false, have_debuginfo = false;
Debugger::StopDisassemblyType disasm_display = Debugger::eStopDisassemblyTypeNever;
Target *target = exe_ctx.GetTargetPtr();
if (target)
@@ -1491,26 +1532,35 @@ StackFrame::GetStatus (Stream& strm,
GetSymbolContext(eSymbolContextCompUnit | eSymbolContextLineEntry);
if (m_sc.comp_unit && m_sc.line_entry.IsValid())
{
- have_source = true;
+ have_debuginfo = true;
if (source_lines_before > 0 || source_lines_after > 0)
{
- target->GetSourceManager().DisplaySourceLinesWithLineNumbers (m_sc.line_entry.file,
+ size_t num_lines = target->GetSourceManager().DisplaySourceLinesWithLineNumbers (m_sc.line_entry.file,
m_sc.line_entry.line,
source_lines_before,
source_lines_after,
"->",
&strm);
+ if (num_lines != 0)
+ have_source = true;
+ // TODO: Give here a one time warning if source file is missing.
}
}
switch (disasm_display)
{
case Debugger::eStopDisassemblyTypeNever:
break;
-
+
+ case Debugger::eStopDisassemblyTypeNoDebugInfo:
+ if (have_debuginfo)
+ break;
+ // Fall through to next case
+
case Debugger::eStopDisassemblyTypeNoSource:
if (have_source)
break;
// Fall through to next case
+
case Debugger::eStopDisassemblyTypeAlways:
if (target)
{
diff --git a/source/Target/StackFrameList.cpp b/source/Target/StackFrameList.cpp
index 05923d70ce424..f2f3cad471feb 100644
--- a/source/Target/StackFrameList.cpp
+++ b/source/Target/StackFrameList.cpp
@@ -105,9 +105,13 @@ StackFrameList::GetCurrentInlinedDepth ()
void
StackFrameList::ResetCurrentInlinedDepth ()
{
+ Mutex::Locker locker (m_mutex);
+
if (m_show_inlined_frames)
{
GetFramesUpTo(0);
+ if (m_frames.size() == 0)
+ return;
if (!m_frames[0]->IsInlined())
{
m_current_inlined_depth = UINT32_MAX;
@@ -362,8 +366,8 @@ StackFrameList::GetFramesUpTo(uint32_t end_idx)
// adjustment it will point to an other section. In that case resolve the
// address again to the correct section plus offset form.
TargetSP target = m_thread.CalculateTarget();
- addr_t load_addr = curr_frame_address.GetOpcodeLoadAddress(target.get());
- curr_frame_address.SetOpcodeLoadAddress(load_addr - 1, target.get());
+ addr_t load_addr = curr_frame_address.GetOpcodeLoadAddress(target.get(), eAddressClassCode);
+ curr_frame_address.SetOpcodeLoadAddress(load_addr - 1, target.get(), eAddressClassCode);
}
else
{
@@ -457,9 +461,9 @@ StackFrameList::GetFramesUpTo(uint32_t end_idx)
}
#if defined (DEBUG_STACK_FRAMES)
- s.PutCString("\n\nNew frames:\n");
- Dump (&s);
- s.EOL();
+ s.PutCString("\n\nNew frames:\n");
+ Dump (&s);
+ s.EOL();
#endif
}
else
diff --git a/source/Target/StopInfo.cpp b/source/Target/StopInfo.cpp
index 9bbb00dbf0dab..e88b6467f7c6f 100644
--- a/source/Target/StopInfo.cpp
+++ b/source/Target/StopInfo.cpp
@@ -1,4 +1,4 @@
-//===-- StopInfo.cpp ---------------------------------------------*- C++ -*-===//
+//===-- StopInfo.cpp --------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -7,14 +7,13 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/Target/StopInfo.h"
-
// C Includes
// C++ Includes
#include <string>
// Other libraries and framework includes
// Project includes
+#include "lldb/Target/StopInfo.h"
#include "lldb/Core/Log.h"
#include "lldb/Breakpoint/Breakpoint.h"
#include "lldb/Breakpoint/BreakpointLocation.h"
@@ -23,7 +22,7 @@
#include "lldb/Core/Debugger.h"
#include "lldb/Core/StreamString.h"
#include "lldb/Core/ValueObject.h"
-#include "lldb/Expression/ClangUserExpression.h"
+#include "lldb/Expression/UserExpression.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
#include "lldb/Target/ThreadPlan.h"
@@ -133,6 +132,8 @@ public:
StoreBPInfo();
}
+ ~StopInfoBreakpoint() override = default;
+
void
StoreBPInfo ()
{
@@ -156,12 +157,8 @@ public:
}
}
- virtual ~StopInfoBreakpoint ()
- {
- }
-
- virtual bool
- IsValidForOperatingSystemThread (Thread &thread)
+ bool
+ IsValidForOperatingSystemThread(Thread &thread) override
{
ProcessSP process_sp (thread.GetProcess());
if (process_sp)
@@ -173,14 +170,14 @@ public:
return false;
}
- virtual StopReason
- GetStopReason () const
+ StopReason
+ GetStopReason() const override
{
return eStopReasonBreakpoint;
}
- virtual bool
- ShouldStopSynchronous (Event *event_ptr)
+ bool
+ ShouldStopSynchronous(Event *event_ptr) override
{
ThreadSP thread_sp (m_thread_wp.lock());
if (thread_sp)
@@ -212,8 +209,8 @@ public:
return false;
}
- virtual bool
- DoShouldNotify (Event *event_ptr)
+ bool
+ DoShouldNotify(Event *event_ptr) override
{
ThreadSP thread_sp (m_thread_wp.lock());
if (thread_sp)
@@ -237,8 +234,8 @@ public:
return true;
}
- virtual const char *
- GetDescription ()
+ const char *
+ GetDescription() override
{
if (m_description.empty())
{
@@ -312,7 +309,7 @@ public:
protected:
bool
- ShouldStop (Event *event_ptr)
+ ShouldStop(Event *event_ptr) override
{
// This just reports the work done by PerformAction or the synchronous stop. It should
// only ever get called after they have had a chance to run.
@@ -320,8 +317,8 @@ protected:
return m_should_stop;
}
- virtual void
- PerformAction (Event *event_ptr)
+ void
+ PerformAction(Event *event_ptr) override
{
if (!m_should_perform_action)
return;
@@ -350,7 +347,10 @@ protected:
if (bp_site_sp)
{
- size_t num_owners = bp_site_sp->GetNumberOfOwners();
+ // Let's copy the owners list out of the site and store them in a local list. That way if
+ // one of the breakpoint actions changes the site, then we won't be operating on a bad list.
+ BreakpointLocationCollection site_locations;
+ size_t num_owners = bp_site_sp->CopyOwnersList(site_locations);
if (num_owners == 0)
{
@@ -416,20 +416,16 @@ protected:
StoppointCallbackContext context (event_ptr, exe_ctx, false);
- // Let's copy the breakpoint locations out of the site and store them in a local list. That way if
- // one of the breakpoint actions changes the site, then we won't be operating on a bad list.
// For safety's sake let's also grab an extra reference to the breakpoint owners of the locations we're
// going to examine, since the locations are going to have to get back to their breakpoints, and the
// locations don't keep their owners alive. I'm just sticking the BreakpointSP's in a vector since
- // I'm only really using it to locally increment their retain counts.
+ // I'm only using it to locally increment their retain counts.
- BreakpointLocationCollection site_locations;
std::vector<lldb::BreakpointSP> location_owners;
for (size_t j = 0; j < num_owners; j++)
{
- BreakpointLocationSP loc(bp_site_sp->GetOwnerAtIndex(j));
- site_locations.Add(loc);
+ BreakpointLocationSP loc(site_locations.GetByIndex(j));
location_owners.push_back(loc->GetBreakpoint().shared_from_this());
}
@@ -576,7 +572,6 @@ private:
bool m_was_one_shot;
};
-
//----------------------------------------------------------------------
// StopInfoWatchpoint
//----------------------------------------------------------------------
@@ -598,6 +593,7 @@ public:
process->DisableWatchpoint(watchpoint, notify);
}
}
+
~WatchpointSentry()
{
if (process && watchpoint)
@@ -610,6 +606,7 @@ public:
watchpoint->TurnOffEphemeralMode();
}
}
+
private:
Process *process;
Watchpoint *watchpoint;
@@ -622,19 +619,17 @@ public:
m_watch_hit_addr(watch_hit_addr)
{
}
-
- virtual ~StopInfoWatchpoint ()
- {
- }
- virtual StopReason
- GetStopReason () const
+ ~StopInfoWatchpoint() override = default;
+
+ StopReason
+ GetStopReason() const override
{
return eStopReasonWatchpoint;
}
- virtual const char *
- GetDescription ()
+ const char *
+ GetDescription() override
{
if (m_description.empty())
{
@@ -646,8 +641,8 @@ public:
}
protected:
- virtual bool
- ShouldStopSynchronous (Event *event_ptr)
+ bool
+ ShouldStopSynchronous(Event *event_ptr) override
{
// ShouldStop() method is idempotent and should not affect hit count.
// See Process::RunPrivateStateThread()->Process()->HandlePrivateEvent()
@@ -686,7 +681,7 @@ protected:
}
bool
- ShouldStop (Event *event_ptr)
+ ShouldStop(Event *event_ptr) override
{
// This just reports the work done by PerformAction or the synchronous stop. It should
// only ever get called after they have had a chance to run.
@@ -694,8 +689,8 @@ protected:
return m_should_stop;
}
- virtual void
- PerformAction (Event *event_ptr)
+ void
+ PerformAction(Event *event_ptr) override
{
Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_WATCHPOINTS);
// We're going to calculate if we should stop or not in some way during the course of
@@ -758,9 +753,22 @@ protected:
{
WatchpointSP wp_hit_sp = thread_sp->CalculateTarget()->GetWatchpointList().FindByAddress(m_watch_hit_addr);
if (!wp_hit_sp)
+ {
m_should_stop = false;
+ wp_sp->IncrementFalseAlarmsAndReviseHitCount();
+ }
}
-
+
+ // TODO: This condition should be checked in the synchronous part of the watchpoint code
+ // (Watchpoint::ShouldStop), so that we avoid pulling an event even if the watchpoint fails
+ // the ignore count condition. It is moved here temporarily, because for archs with
+ // watchpoint_exceptions_received=before, the code in the previous lines takes care of moving
+ // the inferior to next PC. We have to check the ignore count condition after this is done,
+ // otherwise we will hit same watchpoint multiple times until we pass ignore condition, but we
+ // won't actually be ignoring them.
+ if (wp_sp->GetHitCount() <= wp_sp->GetIgnoreCount())
+ m_should_stop = false;
+
if (m_should_stop && wp_sp->GetConditionText() != NULL)
{
// We need to make sure the user sees any parse errors in their condition, so we'll hook the
@@ -771,12 +779,13 @@ protected:
expr_options.SetIgnoreBreakpoints(true);
ValueObjectSP result_value_sp;
Error error;
- result_code = ClangUserExpression::Evaluate (exe_ctx,
- expr_options,
- wp_sp->GetConditionText(),
- NULL,
- result_value_sp,
- error);
+ result_code = UserExpression::Evaluate (exe_ctx,
+ expr_options,
+ wp_sp->GetConditionText(),
+ NULL,
+ result_value_sp,
+ error);
+
if (result_code == eExpressionCompleted)
{
if (result_value_sp)
@@ -876,8 +885,6 @@ private:
lldb::addr_t m_watch_hit_addr;
};
-
-
//----------------------------------------------------------------------
// StopInfoUnixSignal
//----------------------------------------------------------------------
@@ -885,26 +892,22 @@ private:
class StopInfoUnixSignal : public StopInfo
{
public:
-
StopInfoUnixSignal (Thread &thread, int signo, const char *description) :
StopInfo (thread, signo)
{
SetDescription (description);
}
-
- virtual ~StopInfoUnixSignal ()
- {
- }
+ ~StopInfoUnixSignal() override = default;
- virtual StopReason
- GetStopReason () const
+ StopReason
+ GetStopReason() const override
{
return eStopReasonSignal;
}
- virtual bool
- ShouldStopSynchronous (Event *event_ptr)
+ bool
+ ShouldStopSynchronous(Event *event_ptr) override
{
ThreadSP thread_sp (m_thread_wp.lock());
if (thread_sp)
@@ -912,19 +915,18 @@ public:
return false;
}
- virtual bool
- ShouldStop (Event *event_ptr)
+ bool
+ ShouldStop(Event *event_ptr) override
{
ThreadSP thread_sp (m_thread_wp.lock());
if (thread_sp)
return thread_sp->GetProcess()->GetUnixSignals()->GetShouldStop(m_value);
return false;
}
-
-
+
// If should stop returns false, check if we should notify of this event
- virtual bool
- DoShouldNotify (Event *event_ptr)
+ bool
+ DoShouldNotify(Event *event_ptr) override
{
ThreadSP thread_sp (m_thread_wp.lock());
if (thread_sp)
@@ -943,9 +945,8 @@ public:
return true;
}
-
- virtual void
- WillResume (lldb::StateType resume_state)
+ void
+ WillResume(lldb::StateType resume_state) override
{
ThreadSP thread_sp (m_thread_wp.lock());
if (thread_sp)
@@ -955,8 +956,8 @@ public:
}
}
- virtual const char *
- GetDescription ()
+ const char *
+ GetDescription() override
{
if (m_description.empty())
{
@@ -983,33 +984,29 @@ public:
class StopInfoTrace : public StopInfo
{
public:
-
StopInfoTrace (Thread &thread) :
StopInfo (thread, LLDB_INVALID_UID)
{
}
-
- virtual ~StopInfoTrace ()
- {
- }
-
- virtual StopReason
- GetStopReason () const
+
+ ~StopInfoTrace() override = default;
+
+ StopReason
+ GetStopReason() const override
{
return eStopReasonTrace;
}
- virtual const char *
- GetDescription ()
+ const char *
+ GetDescription() override
{
if (m_description.empty())
- return "trace";
+ return "trace";
else
return m_description.c_str();
}
};
-
//----------------------------------------------------------------------
// StopInfoException
//----------------------------------------------------------------------
@@ -1017,27 +1014,23 @@ public:
class StopInfoException : public StopInfo
{
public:
-
StopInfoException (Thread &thread, const char *description) :
StopInfo (thread, LLDB_INVALID_UID)
{
if (description)
SetDescription (description);
}
-
- virtual
- ~StopInfoException ()
- {
- }
-
- virtual StopReason
- GetStopReason () const
+
+ ~StopInfoException() override = default;
+
+ StopReason
+ GetStopReason() const override
{
return eStopReasonException;
}
- virtual const char *
- GetDescription ()
+ const char *
+ GetDescription() override
{
if (m_description.empty())
return "exception";
@@ -1046,7 +1039,6 @@ public:
}
};
-
//----------------------------------------------------------------------
// StopInfoThreadPlan
//----------------------------------------------------------------------
@@ -1054,27 +1046,24 @@ public:
class StopInfoThreadPlan : public StopInfo
{
public:
-
- StopInfoThreadPlan (ThreadPlanSP &plan_sp, ValueObjectSP &return_valobj_sp, ClangExpressionVariableSP &expression_variable_sp) :
+ StopInfoThreadPlan (ThreadPlanSP &plan_sp, ValueObjectSP &return_valobj_sp, ExpressionVariableSP &expression_variable_sp) :
StopInfo (plan_sp->GetThread(), LLDB_INVALID_UID),
m_plan_sp (plan_sp),
m_return_valobj_sp (return_valobj_sp),
m_expression_variable_sp (expression_variable_sp)
{
}
-
- virtual ~StopInfoThreadPlan ()
- {
- }
- virtual StopReason
- GetStopReason () const
+ ~StopInfoThreadPlan() override = default;
+
+ StopReason
+ GetStopReason() const override
{
return eStopReasonPlanComplete;
}
- virtual const char *
- GetDescription ()
+ const char *
+ GetDescription() override
{
if (m_description.empty())
{
@@ -1091,15 +1080,15 @@ public:
return m_return_valobj_sp;
}
- ClangExpressionVariableSP
+ ExpressionVariableSP
GetExpressionVariable()
{
return m_expression_variable_sp;
}
protected:
- virtual bool
- ShouldStop (Event *event_ptr)
+ bool
+ ShouldStop(Event *event_ptr) override
{
if (m_plan_sp)
return m_plan_sp->ShouldStop(event_ptr);
@@ -1110,39 +1099,35 @@ protected:
private:
ThreadPlanSP m_plan_sp;
ValueObjectSP m_return_valobj_sp;
- ClangExpressionVariableSP m_expression_variable_sp;
+ ExpressionVariableSP m_expression_variable_sp;
};
class StopInfoExec : public StopInfo
{
public:
-
StopInfoExec (Thread &thread) :
StopInfo (thread, LLDB_INVALID_UID),
m_performed_action (false)
{
}
-
- virtual
- ~StopInfoExec ()
- {
- }
-
- virtual StopReason
- GetStopReason () const
+
+ ~StopInfoExec() override = default;
+
+ StopReason
+ GetStopReason() const override
{
return eStopReasonExec;
}
- virtual const char *
- GetDescription ()
+ const char *
+ GetDescription() override
{
return "exec";
}
+
protected:
-
- virtual void
- PerformAction (Event *event_ptr)
+ void
+ PerformAction(Event *event_ptr) override
{
// Only perform the action once
if (m_performed_action)
@@ -1191,7 +1176,7 @@ StopInfo::CreateStopReasonToTrace (Thread &thread)
StopInfoSP
StopInfo::CreateStopReasonWithPlan (ThreadPlanSP &plan_sp,
ValueObjectSP return_valobj_sp,
- ClangExpressionVariableSP expression_variable_sp)
+ ExpressionVariableSP expression_variable_sp)
{
return StopInfoSP (new StopInfoThreadPlan (plan_sp, return_valobj_sp, expression_variable_sp));
}
@@ -1220,7 +1205,7 @@ StopInfo::GetReturnValueObject(StopInfoSP &stop_info_sp)
return ValueObjectSP();
}
-ClangExpressionVariableSP
+ExpressionVariableSP
StopInfo::GetExpressionVariable(StopInfoSP &stop_info_sp)
{
if (stop_info_sp && stop_info_sp->GetStopReason() == eStopReasonPlanComplete)
@@ -1229,5 +1214,5 @@ StopInfo::GetExpressionVariable(StopInfoSP &stop_info_sp)
return plan_stop_info->GetExpressionVariable();
}
else
- return ClangExpressionVariableSP();
+ return ExpressionVariableSP();
}
diff --git a/source/Target/Target.cpp b/source/Target/Target.cpp
index 6ba09f4ee9483..d2aa1bac49f6c 100644
--- a/source/Target/Target.cpp
+++ b/source/Target/Target.cpp
@@ -7,12 +7,11 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/Target/Target.h"
-
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
+#include "lldb/Target/Target.h"
#include "lldb/Breakpoint/BreakpointResolver.h"
#include "lldb/Breakpoint/BreakpointResolverAddress.h"
#include "lldb/Breakpoint/BreakpointResolverFileLine.h"
@@ -31,10 +30,11 @@
#include "lldb/Core/StreamString.h"
#include "lldb/Core/Timer.h"
#include "lldb/Core/ValueObject.h"
-#include "lldb/Expression/ClangASTSource.h"
-#include "lldb/Expression/ClangPersistentVariables.h"
-#include "lldb/Expression/ClangUserExpression.h"
-#include "lldb/Expression/ClangModulesDeclVendor.h"
+#include "lldb/Expression/REPL.h"
+#include "lldb/Expression/UserExpression.h"
+#include "Plugins/ExpressionParser/Clang/ClangASTSource.h"
+#include "Plugins/ExpressionParser/Clang/ClangPersistentVariables.h"
+#include "Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.h"
#include "lldb/Host/FileSpec.h"
#include "lldb/Host/Host.h"
#include "lldb/Interpreter/CommandInterpreter.h"
@@ -44,6 +44,9 @@
#include "lldb/Interpreter/Property.h"
#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/ObjectFile.h"
+#include "lldb/Symbol/Function.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"
@@ -52,6 +55,7 @@
#include "lldb/Target/SystemRuntime.h"
#include "lldb/Target/Thread.h"
#include "lldb/Target/ThreadSpec.h"
+#include "lldb/Utility/LLDBAssert.h"
using namespace lldb;
using namespace lldb_private;
@@ -63,9 +67,6 @@ Target::GetStaticBroadcasterClass ()
return class_name;
}
-//----------------------------------------------------------------------
-// Target constructor
-//----------------------------------------------------------------------
Target::Target(Debugger &debugger, const ArchSpec &target_arch, const lldb::PlatformSP &platform_sp, bool is_dummy_target) :
TargetProperties (this),
Broadcaster (&debugger, Target::GetStaticBroadcasterClass().AsCString()),
@@ -82,10 +83,7 @@ Target::Target(Debugger &debugger, const ArchSpec &target_arch, const lldb::Plat
m_process_sp (),
m_search_filter_sp (),
m_image_search_paths (ImageSearchPathsChanged, this),
- m_scratch_ast_context_ap (),
- m_scratch_ast_source_ap (),
- m_ast_importer_ap (),
- m_persistent_variables (new ClangPersistentVariables),
+ m_ast_importer_sp (),
m_source_manager_ap(),
m_stop_hooks (),
m_stop_hook_next_id (0),
@@ -111,6 +109,14 @@ Target::Target(Debugger &debugger, const ArchSpec &target_arch, const lldb::Plat
}
}
+Target::~Target()
+{
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT));
+ if (log)
+ log->Printf ("%p Target::~Target()", static_cast<void*>(this));
+ DeleteCurrentProcess ();
+}
+
void
Target::PrimeFromDummyTarget(Target *target)
{
@@ -129,17 +135,6 @@ Target::PrimeFromDummyTarget(Target *target)
}
}
-//----------------------------------------------------------------------
-// Destructor
-//----------------------------------------------------------------------
-Target::~Target()
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT));
- if (log)
- log->Printf ("%p Target::~Target()", static_cast<void*>(this));
- DeleteCurrentProcess ();
-}
-
void
Target::Dump (Stream *s, lldb::DescriptionLevel description_level)
{
@@ -183,7 +178,7 @@ Target::CleanupProcess ()
void
Target::DeleteCurrentProcess ()
{
- if (m_process_sp.get())
+ if (m_process_sp)
{
m_section_load_history.Clear();
if (m_process_sp->IsAlive())
@@ -201,7 +196,7 @@ const lldb::ProcessSP &
Target::CreateProcess (Listener &listener, const char *plugin_name, const FileSpec *crash_file)
{
DeleteCurrentProcess ();
- m_process_sp = Process::FindPlugin(*this, plugin_name, listener, crash_file);
+ m_process_sp = Process::FindPlugin(shared_from_this(), plugin_name, listener, crash_file);
return m_process_sp;
}
@@ -211,6 +206,69 @@ Target::GetProcessSP () const
return m_process_sp;
}
+lldb::REPLSP
+Target::GetREPL (Error &err, lldb::LanguageType language, const char *repl_options, bool can_create)
+{
+ if (language == eLanguageTypeUnknown)
+ {
+ std::set<LanguageType> repl_languages;
+
+ Language::GetLanguagesSupportingREPLs(repl_languages);
+
+ if (repl_languages.size() == 1)
+ {
+ language = *repl_languages.begin();
+ }
+ else if (repl_languages.size() == 0)
+ {
+ err.SetErrorStringWithFormat("LLDB isn't configured with support support for any REPLs.");
+ return REPLSP();
+ }
+ else
+ {
+ err.SetErrorStringWithFormat("Multiple possible REPL languages. Please specify a language.");
+ return REPLSP();
+ }
+ }
+
+ REPLMap::iterator pos = m_repl_map.find(language);
+
+ if (pos != m_repl_map.end())
+ {
+ return pos->second;
+ }
+
+ if (!can_create)
+ {
+ err.SetErrorStringWithFormat("Couldn't find an existing REPL for %s, and can't create a new one", Language::GetNameForLanguageType(language));
+ return lldb::REPLSP();
+ }
+
+ Debugger *const debugger = nullptr;
+ lldb::REPLSP ret = REPL::Create(err, language, debugger, this, repl_options);
+
+ if (ret)
+ {
+ m_repl_map[language] = ret;
+ return m_repl_map[language];
+ }
+
+ if (err.Success())
+ {
+ err.SetErrorStringWithFormat("Couldn't create a REPL for %s", Language::GetNameForLanguageType(language));
+ }
+
+ return lldb::REPLSP();
+}
+
+void
+Target::SetREPL (lldb::LanguageType language, lldb::REPLSP repl_sp)
+{
+ lldbassert(!m_repl_map.count(language));
+
+ m_repl_map[language] = repl_sp;
+}
+
void
Target::Destroy()
{
@@ -228,13 +286,11 @@ Target::Destroy()
m_last_created_watchpoint.reset();
m_search_filter_sp.reset();
m_image_search_paths.Clear(notify);
- m_persistent_variables->Clear();
m_stop_hooks.clear();
m_stop_hook_next_id = 0;
m_suppress_stop_hooks = false;
}
-
BreakpointList &
Target::GetBreakpointList(bool internal)
{
@@ -277,11 +333,10 @@ Target::CreateSourceRegexBreakpoint (const FileSpecList *containingModules,
SearchFilterSP filter_sp(GetSearchFilterForModuleAndCUList (containingModules, source_file_spec_list));
if (move_to_nearest_code == eLazyBoolCalculate)
move_to_nearest_code = GetMoveToNearestCode() ? eLazyBoolYes : eLazyBoolNo;
- BreakpointResolverSP resolver_sp(new BreakpointResolverFileRegex (NULL, source_regex, !static_cast<bool>(move_to_nearest_code)));
+ BreakpointResolverSP resolver_sp(new BreakpointResolverFileRegex(nullptr, source_regex, !static_cast<bool>(move_to_nearest_code)));
return CreateBreakpoint (filter_sp, resolver_sp, internal, hardware, true);
}
-
BreakpointSP
Target::CreateBreakpoint (const FileSpecList *containingModules,
const FileSpec &file,
@@ -330,20 +385,23 @@ Target::CreateBreakpoint (const FileSpecList *containingModules,
if (move_to_nearest_code == eLazyBoolCalculate)
move_to_nearest_code = GetMoveToNearestCode() ? eLazyBoolYes : eLazyBoolNo;
- BreakpointResolverSP resolver_sp(new BreakpointResolverFileLine (NULL,
- file,
- line_no,
- check_inlines,
- skip_prologue,
- !static_cast<bool>(move_to_nearest_code)));
+ BreakpointResolverSP resolver_sp(new BreakpointResolverFileLine(nullptr,
+ file,
+ line_no,
+ check_inlines,
+ skip_prologue,
+ !static_cast<bool>(move_to_nearest_code)));
return CreateBreakpoint (filter_sp, resolver_sp, internal, hardware, true);
}
-
BreakpointSP
Target::CreateBreakpoint (lldb::addr_t addr, bool internal, bool hardware)
{
Address so_addr;
+
+ // Check for any reason we want to move this breakpoint to other address.
+ addr = GetBreakableLoadAddress(addr);
+
// Attempt to resolve our load address if possible, though it is ok if
// it doesn't resolve to section/offset.
@@ -359,18 +417,30 @@ Target::CreateBreakpoint (lldb::addr_t addr, bool internal, bool hardware)
}
BreakpointSP
-Target::CreateBreakpoint (Address &addr, bool internal, bool hardware)
+Target::CreateBreakpoint (const Address &addr, bool internal, bool hardware)
{
SearchFilterSP filter_sp(new SearchFilterForUnconstrainedSearches (shared_from_this()));
- BreakpointResolverSP resolver_sp (new BreakpointResolverAddress (NULL, addr));
+ BreakpointResolverSP resolver_sp(new BreakpointResolverAddress(nullptr, addr));
return CreateBreakpoint (filter_sp, resolver_sp, internal, hardware, false);
}
+lldb::BreakpointSP
+Target::CreateAddressInModuleBreakpoint (lldb::addr_t file_addr,
+ bool internal,
+ const FileSpec *file_spec,
+ bool request_hardware)
+{
+ SearchFilterSP filter_sp(new SearchFilterForUnconstrainedSearches (shared_from_this()));
+ BreakpointResolverSP resolver_sp(new BreakpointResolverAddress(nullptr, file_addr, file_spec));
+ return CreateBreakpoint (filter_sp, resolver_sp, internal, request_hardware, false);
+}
+
BreakpointSP
Target::CreateBreakpoint (const FileSpecList *containingModules,
const FileSpecList *containingSourceFiles,
const char *func_name,
uint32_t func_name_type_mask,
+ LanguageType language,
LazyBool skip_prologue,
bool internal,
bool hardware)
@@ -382,12 +452,15 @@ Target::CreateBreakpoint (const FileSpecList *containingModules,
if (skip_prologue == eLazyBoolCalculate)
skip_prologue = GetSkipPrologue() ? eLazyBoolYes : eLazyBoolNo;
-
- BreakpointResolverSP resolver_sp (new BreakpointResolverName (NULL,
- func_name,
- func_name_type_mask,
- Breakpoint::Exact,
- skip_prologue));
+ if (language == lldb::eLanguageTypeUnknown)
+ language = GetLanguage();
+
+ BreakpointResolverSP resolver_sp(new BreakpointResolverName(nullptr,
+ func_name,
+ func_name_type_mask,
+ language,
+ Breakpoint::Exact,
+ skip_prologue));
bp_sp = CreateBreakpoint (filter_sp, resolver_sp, internal, hardware, true);
}
return bp_sp;
@@ -398,6 +471,7 @@ Target::CreateBreakpoint (const FileSpecList *containingModules,
const FileSpecList *containingSourceFiles,
const std::vector<std::string> &func_names,
uint32_t func_name_type_mask,
+ LanguageType language,
LazyBool skip_prologue,
bool internal,
bool hardware)
@@ -410,11 +484,14 @@ Target::CreateBreakpoint (const FileSpecList *containingModules,
if (skip_prologue == eLazyBoolCalculate)
skip_prologue = GetSkipPrologue() ? eLazyBoolYes : eLazyBoolNo;
-
- BreakpointResolverSP resolver_sp (new BreakpointResolverName (NULL,
- func_names,
- func_name_type_mask,
- skip_prologue));
+ if (language == lldb::eLanguageTypeUnknown)
+ language = GetLanguage();
+
+ BreakpointResolverSP resolver_sp(new BreakpointResolverName(nullptr,
+ func_names,
+ func_name_type_mask,
+ language,
+ skip_prologue));
bp_sp = CreateBreakpoint (filter_sp, resolver_sp, internal, hardware, true);
}
return bp_sp;
@@ -426,6 +503,7 @@ Target::CreateBreakpoint (const FileSpecList *containingModules,
const char *func_names[],
size_t num_names,
uint32_t func_name_type_mask,
+ LanguageType language,
LazyBool skip_prologue,
bool internal,
bool hardware)
@@ -437,12 +515,15 @@ Target::CreateBreakpoint (const FileSpecList *containingModules,
if (skip_prologue == eLazyBoolCalculate)
skip_prologue = GetSkipPrologue() ? eLazyBoolYes : eLazyBoolNo;
-
- BreakpointResolverSP resolver_sp (new BreakpointResolverName (NULL,
- func_names,
- num_names,
- func_name_type_mask,
- skip_prologue));
+ if (language == lldb::eLanguageTypeUnknown)
+ language = GetLanguage();
+
+ BreakpointResolverSP resolver_sp(new BreakpointResolverName(nullptr,
+ func_names,
+ num_names,
+ func_name_type_mask,
+ language,
+ skip_prologue));
bp_sp = CreateBreakpoint (filter_sp, resolver_sp, internal, hardware, true);
}
return bp_sp;
@@ -452,7 +533,7 @@ SearchFilterSP
Target::GetSearchFilterForModule (const FileSpec *containingModule)
{
SearchFilterSP filter_sp;
- if (containingModule != NULL)
+ 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
@@ -460,7 +541,7 @@ Target::GetSearchFilterForModule (const FileSpec *containingModule)
}
else
{
- if (m_search_filter_sp.get() == NULL)
+ if (!m_search_filter_sp)
m_search_filter_sp.reset (new SearchFilterForUnconstrainedSearches (shared_from_this()));
filter_sp = m_search_filter_sp;
}
@@ -479,7 +560,7 @@ Target::GetSearchFilterForModuleList (const FileSpecList *containingModules)
}
else
{
- if (m_search_filter_sp.get() == NULL)
+ if (!m_search_filter_sp)
m_search_filter_sp.reset (new SearchFilterForUnconstrainedSearches (shared_from_this()));
filter_sp = m_search_filter_sp;
}
@@ -490,11 +571,11 @@ SearchFilterSP
Target::GetSearchFilterForModuleAndCUList (const FileSpecList *containingModules,
const FileSpecList *containingSourceFiles)
{
- if (containingSourceFiles == NULL || containingSourceFiles->GetSize() == 0)
+ if (containingSourceFiles == nullptr || containingSourceFiles->GetSize() == 0)
return GetSearchFilterForModuleList(containingModules);
SearchFilterSP filter_sp;
- if (containingModules == NULL)
+ if (containingModules == nullptr)
{
// We could make a special "CU List only SearchFilter". Better yet was if these could be composable,
// but that will take a little reworking.
@@ -512,6 +593,7 @@ BreakpointSP
Target::CreateFuncRegexBreakpoint (const FileSpecList *containingModules,
const FileSpecList *containingSourceFiles,
RegularExpression &func_regex,
+ lldb::LanguageType requested_language,
LazyBool skip_prologue,
bool internal,
bool hardware)
@@ -520,9 +602,10 @@ Target::CreateFuncRegexBreakpoint (const FileSpecList *containingModules,
bool skip =
(skip_prologue == eLazyBoolCalculate) ? GetSkipPrologue()
: static_cast<bool>(skip_prologue);
- BreakpointResolverSP resolver_sp(new BreakpointResolverName (NULL,
- func_regex,
- skip));
+ BreakpointResolverSP resolver_sp(new BreakpointResolverName(nullptr,
+ func_regex,
+ requested_language,
+ skip));
return CreateBreakpoint (filter_sp, resolver_sp, internal, hardware, true);
}
@@ -608,7 +691,7 @@ CheckIfWatchpointsExhausted(Target *target, Error &error)
// See also Watchpoint::SetWatchpointType(uint32_t type) and
// the OptionGroupWatchpoint::WatchType enum type.
WatchpointSP
-Target::CreateWatchpoint(lldb::addr_t addr, size_t size, const ClangASTType *type, uint32_t kind, Error &error)
+Target::CreateWatchpoint(lldb::addr_t addr, size_t size, const CompilerType *type, uint32_t kind, Error &error)
{
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_WATCHPOINTS));
if (log)
@@ -1105,9 +1188,8 @@ Target::ClearModules(bool delete_locations)
ModulesDidUnload (m_images, delete_locations);
m_section_load_history.Clear();
m_images.Clear();
- m_scratch_ast_context_ap.reset();
- m_scratch_ast_source_ap.reset();
- m_ast_importer_ap.reset();
+ m_scratch_type_system_map.Clear();
+ m_ast_importer_sp.reset();
}
void
@@ -1124,7 +1206,7 @@ Target::SetExecutableModule (ModuleSP& executable_sp, bool get_dependent_files)
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TARGET));
ClearModules(false);
- if (executable_sp.get())
+ if (executable_sp)
{
Timer scoped_timer (__PRETTY_FUNCTION__,
"Target::SetExecutableModule (executable = '%s')",
@@ -1151,13 +1233,13 @@ Target::SetExecutableModule (ModuleSP& executable_sp, bool get_dependent_files)
FileSpec dependent_file_spec (dependent_files.GetFileSpecPointerAtIndex(i));
FileSpec platform_dependent_file_spec;
if (m_platform_sp)
- m_platform_sp->GetFileWithUUID (dependent_file_spec, NULL, platform_dependent_file_spec);
+ m_platform_sp->GetFileWithUUID(dependent_file_spec, nullptr, platform_dependent_file_spec);
else
platform_dependent_file_spec = dependent_file_spec;
ModuleSpec module_spec (platform_dependent_file_spec, m_arch);
ModuleSP image_module_sp(GetSharedModule (module_spec));
- if (image_module_sp.get())
+ if (image_module_sp)
{
ObjectFile *objfile = image_module_sp->GetObjectFile();
if (objfile)
@@ -1168,49 +1250,74 @@ Target::SetExecutableModule (ModuleSP& executable_sp, bool get_dependent_files)
}
}
-
bool
Target::SetArchitecture (const ArchSpec &arch_spec)
{
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TARGET));
- if (m_arch.IsCompatibleMatch(arch_spec) || !m_arch.IsValid())
+ bool missing_local_arch = !m_arch.IsValid();
+ bool replace_local_arch = true;
+ bool compatible_local_arch = false;
+ ArchSpec other(arch_spec);
+
+ if (!missing_local_arch)
+ {
+ if (m_arch.IsCompatibleMatch(arch_spec))
+ {
+ other.MergeFrom(m_arch);
+
+ if (m_arch.IsCompatibleMatch(other))
+ {
+ compatible_local_arch = true;
+ bool arch_changed, vendor_changed, os_changed, os_ver_changed, env_changed;
+
+ m_arch.PiecewiseTripleCompare(other,
+ arch_changed,
+ vendor_changed,
+ os_changed,
+ os_ver_changed,
+ env_changed);
+
+ if (!arch_changed && !vendor_changed && !os_changed)
+ replace_local_arch = false;
+ }
+ }
+ }
+
+ if (compatible_local_arch || missing_local_arch)
{
- // If we haven't got a valid arch spec, or the architectures are
- // compatible, so just update the architecture. Architectures can be
- // equal, yet the triple OS and vendor might change, so we need to do
- // the assignment here just in case.
- m_arch = arch_spec;
+ // If we haven't got a valid arch spec, or the architectures are compatible
+ // update the architecture, unless the one we already have is more specified
+ if (replace_local_arch)
+ m_arch = other;
if (log)
- log->Printf ("Target::SetArchitecture setting architecture to %s (%s)", arch_spec.GetArchitectureName(), arch_spec.GetTriple().getTriple().c_str());
+ log->Printf ("Target::SetArchitecture set architecture to %s (%s)", m_arch.GetArchitectureName(), m_arch.GetTriple().getTriple().c_str());
return true;
}
- else
+
+ // If we have an executable file, try to reset the executable to the desired architecture
+ if (log)
+ log->Printf ("Target::SetArchitecture changing architecture to %s (%s)", arch_spec.GetArchitectureName(), arch_spec.GetTriple().getTriple().c_str());
+ m_arch = other;
+ ModuleSP executable_sp = GetExecutableModule ();
+
+ ClearModules(true);
+ // Need to do something about unsetting breakpoints.
+
+ if (executable_sp)
{
- // If we have an executable file, try to reset the executable to the desired architecture
if (log)
- log->Printf ("Target::SetArchitecture changing architecture to %s (%s)", arch_spec.GetArchitectureName(), arch_spec.GetTriple().getTriple().c_str());
- m_arch = arch_spec;
- ModuleSP executable_sp = GetExecutableModule ();
-
- ClearModules(true);
- // Need to do something about unsetting breakpoints.
-
- if (executable_sp)
+ log->Printf("Target::SetArchitecture Trying to select executable file architecture %s (%s)", arch_spec.GetArchitectureName(), arch_spec.GetTriple().getTriple().c_str());
+ ModuleSpec module_spec (executable_sp->GetFileSpec(), other);
+ Error error = ModuleList::GetSharedModule(module_spec,
+ executable_sp,
+ &GetExecutableSearchPaths(),
+ nullptr,
+ nullptr);
+
+ if (!error.Fail() && executable_sp)
{
- if (log)
- log->Printf("Target::SetArchitecture Trying to select executable file architecture %s (%s)", arch_spec.GetArchitectureName(), arch_spec.GetTriple().getTriple().c_str());
- ModuleSpec module_spec (executable_sp->GetFileSpec(), arch_spec);
- Error error = ModuleList::GetSharedModule (module_spec,
- executable_sp,
- &GetExecutableSearchPaths(),
- NULL,
- NULL);
-
- if (!error.Fail() && executable_sp)
- {
- SetExecutableModule (executable_sp, true);
- return true;
- }
+ SetExecutableModule (executable_sp, true);
+ return true;
}
}
return false;
@@ -1261,7 +1368,7 @@ Target::ModuleAdded (const ModuleList& module_list, const ModuleSP &module_sp)
void
Target::ModuleRemoved (const ModuleList& module_list, const ModuleSP &module_sp)
{
- // A module is being added to this target for the first time
+ // A module is being removed from this target.
if (m_valid)
{
ModuleList my_module_list;
@@ -1275,7 +1382,10 @@ Target::ModuleUpdated (const ModuleList& module_list, const ModuleSP &old_module
{
// A module is replacing an already added module
if (m_valid)
+ {
m_breakpoint_list.UpdateBreakpointsWhenModuleIsReplaced(old_module_sp, new_module_sp);
+ m_internal_breakpoint_list.UpdateBreakpointsWhenModuleIsReplaced(old_module_sp, new_module_sp);
+ }
}
void
@@ -1284,6 +1394,7 @@ Target::ModulesDidLoad (ModuleList &module_list)
if (m_valid && module_list.GetSize())
{
m_breakpoint_list.UpdateBreakpoints (module_list, true, false);
+ m_internal_breakpoint_list.UpdateBreakpoints (module_list, true, false);
if (m_process_sp)
{
m_process_sp->ModulesDidLoad (module_list);
@@ -1308,6 +1419,7 @@ Target::SymbolsDidLoad (ModuleList &module_list)
}
m_breakpoint_list.UpdateBreakpoints (module_list, true, false);
+ m_internal_breakpoint_list.UpdateBreakpoints (module_list, true, false);
BroadcastEvent (eBroadcastBitSymbolsLoaded, new TargetEventData (this->shared_from_this(), module_list));
}
}
@@ -1319,6 +1431,7 @@ Target::ModulesDidUnload (ModuleList &module_list, bool delete_locations)
{
UnloadModuleSections (module_list);
m_breakpoint_list.UpdateBreakpoints (module_list, false, delete_locations);
+ m_internal_breakpoint_list.UpdateBreakpoints (module_list, false, delete_locations);
BroadcastEvent (eBroadcastBitModulesUnloaded, new TargetEventData (this->shared_from_this(), module_list));
}
}
@@ -1439,7 +1552,6 @@ Target::ReadMemory (const Address& addr,
}
if (!resolved_addr.IsValid())
resolved_addr = addr;
-
if (prefer_file_cache)
{
@@ -1526,7 +1638,6 @@ Target::ReadCStringFromMemory (const Address& addr, std::string &out_str, Error
return out_str.size();
}
-
size_t
Target::ReadCStringFromMemory (const Address& addr, char *dst, size_t dst_max_len, Error &result_error)
{
@@ -1575,7 +1686,7 @@ Target::ReadCStringFromMemory (const Address& addr, char *dst, size_t dst_max_le
}
else
{
- if (dst == NULL)
+ if (dst == nullptr)
result_error.SetErrorString("invalid arguments");
else
result_error.Clear();
@@ -1821,7 +1932,6 @@ Target::GetSharedModule (const ModuleSpec &module_spec, Error *error_ptr)
return module_sp;
}
-
TargetSP
Target::CalculateTarget ()
{
@@ -1860,11 +1970,8 @@ Target::GetImageSearchPathList ()
}
void
-Target::ImageSearchPathsChanged
-(
- const PathMappingList &path_list,
- void *baton
-)
+Target::ImageSearchPathsChanged(const PathMappingList &path_list,
+ void *baton)
{
Target *target = (Target *)baton;
ModuleSP exe_module_sp (target->GetExecutableModule());
@@ -1872,33 +1979,157 @@ Target::ImageSearchPathsChanged
target->SetExecutableModule (exe_module_sp, true);
}
+TypeSystem *
+Target::GetScratchTypeSystemForLanguage (Error *error, lldb::LanguageType language, bool create_on_demand)
+{
+ if (!m_valid)
+ return nullptr;
+
+ if (error)
+ {
+ error->Clear();
+ }
+
+ if (language == eLanguageTypeMipsAssembler // GNU AS and LLVM use it for all assembly code
+ || language == eLanguageTypeUnknown)
+ {
+ std::set<lldb::LanguageType> languages_for_types;
+ std::set<lldb::LanguageType> languages_for_expressions;
+
+ Language::GetLanguagesSupportingTypeSystems(languages_for_types, languages_for_expressions);
+
+ if (languages_for_expressions.count(eLanguageTypeC))
+ {
+ language = eLanguageTypeC; // LLDB's default. Override by setting the target language.
+ }
+ else
+ {
+ if (languages_for_expressions.empty())
+ {
+ return nullptr;
+ }
+ else
+ {
+ language = *languages_for_expressions.begin();
+ }
+ }
+ }
+
+ return m_scratch_type_system_map.GetTypeSystemForLanguage(language, this, create_on_demand);
+}
+
+PersistentExpressionState *
+Target::GetPersistentExpressionStateForLanguage (lldb::LanguageType language)
+{
+ TypeSystem *type_system = GetScratchTypeSystemForLanguage(nullptr, language, true);
+
+ if (type_system)
+ {
+ return type_system->GetPersistentExpressionState();
+ }
+ else
+ {
+ return nullptr;
+ }
+}
+
+UserExpression *
+Target::GetUserExpressionForLanguage(const char *expr,
+ const char *expr_prefix,
+ lldb::LanguageType language,
+ Expression::ResultType desired_type,
+ const EvaluateExpressionOptions &options,
+ Error &error)
+{
+ Error type_system_error;
+
+ TypeSystem *type_system = GetScratchTypeSystemForLanguage (&type_system_error, language);
+ UserExpression *user_expr = nullptr;
+
+ if (!type_system)
+ {
+ error.SetErrorStringWithFormat("Could not find type system for language %s: %s", Language::GetNameForLanguageType(language), type_system_error.AsCString());
+ return nullptr;
+ }
+
+ user_expr = type_system->GetUserExpression(expr, expr_prefix, language, desired_type, options);
+ if (!user_expr)
+ error.SetErrorStringWithFormat("Could not create an expression for language %s", Language::GetNameForLanguageType(language));
+
+ return user_expr;
+}
+
+FunctionCaller *
+Target::GetFunctionCallerForLanguage (lldb::LanguageType language,
+ const CompilerType &return_type,
+ const Address& function_address,
+ const ValueList &arg_value_list,
+ const char *name,
+ Error &error)
+{
+ Error type_system_error;
+ TypeSystem *type_system = GetScratchTypeSystemForLanguage (&type_system_error, language);
+ FunctionCaller *persistent_fn = nullptr;
+
+ if (!type_system)
+ {
+ error.SetErrorStringWithFormat("Could not find type system for language %s: %s", Language::GetNameForLanguageType(language), type_system_error.AsCString());
+ return persistent_fn;
+ }
+
+ persistent_fn = type_system->GetFunctionCaller (return_type, function_address, arg_value_list, name);
+ if (!persistent_fn)
+ error.SetErrorStringWithFormat("Could not create an expression for language %s", Language::GetNameForLanguageType(language));
+
+ return persistent_fn;
+}
+
+UtilityFunction *
+Target::GetUtilityFunctionForLanguage (const char *text,
+ lldb::LanguageType language,
+ const char *name,
+ Error &error)
+{
+ Error type_system_error;
+ TypeSystem *type_system = GetScratchTypeSystemForLanguage (&type_system_error, language);
+ UtilityFunction *utility_fn = nullptr;
+
+ if (!type_system)
+ {
+ error.SetErrorStringWithFormat("Could not find type system for language %s: %s", Language::GetNameForLanguageType(language), type_system_error.AsCString());
+ return utility_fn;
+ }
+
+ utility_fn = type_system->GetUtilityFunction (text, name);
+ if (!utility_fn)
+ error.SetErrorStringWithFormat("Could not create an expression for language %s", Language::GetNameForLanguageType(language));
+
+ return utility_fn;
+}
+
ClangASTContext *
Target::GetScratchClangASTContext(bool create_on_demand)
{
- // Now see if we know the target triple, and if so, create our scratch AST context:
- if (m_scratch_ast_context_ap.get() == NULL && m_arch.IsValid() && create_on_demand)
+ if (m_valid)
{
- m_scratch_ast_context_ap.reset (new ClangASTContext(m_arch.GetTriple().str().c_str()));
- m_scratch_ast_source_ap.reset (new ClangASTSource(shared_from_this()));
- m_scratch_ast_source_ap->InstallASTContext(m_scratch_ast_context_ap->getASTContext());
- llvm::IntrusiveRefCntPtr<clang::ExternalASTSource> proxy_ast_source(m_scratch_ast_source_ap->CreateProxy());
- m_scratch_ast_context_ap->SetExternalSource(proxy_ast_source);
+ if (TypeSystem* type_system = GetScratchTypeSystemForLanguage(nullptr, eLanguageTypeC, create_on_demand))
+ return llvm::dyn_cast<ClangASTContext>(type_system);
}
- return m_scratch_ast_context_ap.get();
+ return nullptr;
}
-ClangASTImporter *
+ClangASTImporterSP
Target::GetClangASTImporter()
{
- ClangASTImporter *ast_importer = m_ast_importer_ap.get();
-
- if (!ast_importer)
+ if (m_valid)
{
- ast_importer = new ClangASTImporter();
- m_ast_importer_ap.reset(ast_importer);
+ if (!m_ast_importer_sp)
+ {
+ m_ast_importer_sp.reset(new ClangASTImporter());
+ }
+ return m_ast_importer_sp;
}
-
- return ast_importer;
+ return ClangASTImporterSP();
}
void
@@ -1967,28 +2198,25 @@ Target::GetTargetFromContexts (const ExecutionContext *exe_ctx_ptr, const Symbol
// the "target_sp" member of SymbolContext. This accessor helper function
// will get the target from one of these locations.
- Target *target = NULL;
- if (sc_ptr != NULL)
+ Target *target = nullptr;
+ if (sc_ptr != nullptr)
target = sc_ptr->target_sp.get();
- if (target == NULL && exe_ctx_ptr)
+ if (target == nullptr && exe_ctx_ptr)
target = exe_ctx_ptr->GetTargetPtr();
return target;
}
ExpressionResults
-Target::EvaluateExpression
-(
- const char *expr_cstr,
- StackFrame *frame,
- lldb::ValueObjectSP &result_valobj_sp,
- const EvaluateExpressionOptions& options
-)
+Target::EvaluateExpression(const char *expr_cstr,
+ ExecutionContextScope *exe_scope,
+ lldb::ValueObjectSP &result_valobj_sp,
+ const EvaluateExpressionOptions& options)
{
result_valobj_sp.reset();
ExpressionResults execution_results = eExpressionSetupError;
- if (expr_cstr == NULL || expr_cstr[0] == '\0')
+ if (expr_cstr == nullptr || expr_cstr[0] == '\0')
return execution_results;
// We shouldn't run stop hooks in expressions.
@@ -1998,9 +2226,9 @@ Target::EvaluateExpression
ExecutionContext exe_ctx;
- if (frame)
+ if (exe_scope)
{
- frame->CalculateExecutionContext(exe_ctx);
+ exe_scope->CalculateExecutionContext(exe_ctx);
}
else if (m_process_sp)
{
@@ -2013,10 +2241,10 @@ Target::EvaluateExpression
// Make sure we aren't just trying to see the value of a persistent
// variable (something like "$0")
- lldb::ClangExpressionVariableSP persistent_var_sp;
+ lldb::ExpressionVariableSP persistent_var_sp;
// Only check for persistent variables the expression starts with a '$'
if (expr_cstr[0] == '$')
- persistent_var_sp = m_persistent_variables->GetVariable (expr_cstr);
+ persistent_var_sp = GetScratchTypeSystemForLanguage(nullptr, eLanguageTypeC)->GetPersistentExpressionState()->GetVariable (expr_cstr);
if (persistent_var_sp)
{
@@ -2027,12 +2255,12 @@ Target::EvaluateExpression
{
const char *prefix = GetExpressionPrefixContentsAsCString();
Error error;
- execution_results = ClangUserExpression::Evaluate (exe_ctx,
- options,
- expr_cstr,
- prefix,
- result_valobj_sp,
- error);
+ execution_results = UserExpression::Evaluate (exe_ctx,
+ options,
+ expr_cstr,
+ prefix,
+ result_valobj_sp,
+ error);
}
m_suppress_stop_hooks = old_suppress_value;
@@ -2040,10 +2268,40 @@ Target::EvaluateExpression
return execution_results;
}
-ClangPersistentVariables &
-Target::GetPersistentVariables()
+lldb::ExpressionVariableSP
+Target::GetPersistentVariable(const ConstString &name)
{
- return *m_persistent_variables;
+ lldb::ExpressionVariableSP variable_sp;
+ m_scratch_type_system_map.ForEach([this, name, &variable_sp](TypeSystem *type_system) -> bool
+ {
+ if (PersistentExpressionState *persistent_state = type_system->GetPersistentExpressionState())
+ {
+ variable_sp = persistent_state->GetVariable(name);
+
+ if (variable_sp)
+ return false; // Stop iterating the ForEach
+ }
+ return true; // Keep iterating the ForEach
+ });
+ return variable_sp;
+}
+
+lldb::addr_t
+Target::GetPersistentSymbol(const ConstString &name)
+{
+ lldb::addr_t address = LLDB_INVALID_ADDRESS;
+
+ m_scratch_type_system_map.ForEach([this, name, &address](TypeSystem *type_system) -> bool
+ {
+ if (PersistentExpressionState *persistent_state = type_system->GetPersistentExpressionState())
+ {
+ address = persistent_state->LookupSymbol(name);
+ if (address != LLDB_INVALID_ADDRESS)
+ return false; // Stop iterating the ForEach
+ }
+ return true; // Keep iterating the ForEach
+ });
+ return address;
}
lldb::addr_t
@@ -2052,6 +2310,27 @@ Target::GetCallableLoadAddress (lldb::addr_t load_addr, AddressClass addr_class)
addr_t code_addr = load_addr;
switch (m_arch.GetMachine())
{
+ case llvm::Triple::mips:
+ case llvm::Triple::mipsel:
+ case llvm::Triple::mips64:
+ case llvm::Triple::mips64el:
+ switch (addr_class)
+ {
+ case eAddressClassData:
+ case eAddressClassDebug:
+ return LLDB_INVALID_ADDRESS;
+
+ case eAddressClassUnknown:
+ case eAddressClassInvalid:
+ case eAddressClassCode:
+ case eAddressClassCodeAlternateISA:
+ case eAddressClassRuntime:
+ if ((code_addr & 2ull) || (addr_class == eAddressClassCodeAlternateISA))
+ code_addr |= 1ull;
+ break;
+ }
+ break;
+
case llvm::Triple::arm:
case llvm::Triple::thumb:
switch (addr_class)
@@ -2097,6 +2376,10 @@ Target::GetOpcodeLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) c
addr_t opcode_addr = load_addr;
switch (m_arch.GetMachine())
{
+ case llvm::Triple::mips:
+ case llvm::Triple::mipsel:
+ case llvm::Triple::mips64:
+ case llvm::Triple::mips64el:
case llvm::Triple::arm:
case llvm::Triple::thumb:
switch (addr_class)
@@ -2121,10 +2404,174 @@ Target::GetOpcodeLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) c
return opcode_addr;
}
+lldb::addr_t
+Target::GetBreakableLoadAddress (lldb::addr_t addr)
+{
+ addr_t breakable_addr = addr;
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS));
+
+ switch (m_arch.GetMachine())
+ {
+ default:
+ break;
+ case llvm::Triple::mips:
+ case llvm::Triple::mipsel:
+ case llvm::Triple::mips64:
+ case llvm::Triple::mips64el:
+ {
+ addr_t function_start = 0;
+ addr_t current_offset = 0;
+ uint32_t loop_count = 0;
+ Address resolved_addr;
+ uint32_t arch_flags = m_arch.GetFlags ();
+ bool IsMips16 = arch_flags & ArchSpec::eMIPSAse_mips16;
+ bool IsMicromips = arch_flags & ArchSpec::eMIPSAse_micromips;
+ SectionLoadList &section_load_list = GetSectionLoadList();
+
+ if (section_load_list.IsEmpty())
+ // No sections are loaded, so we must assume we are not running yet
+ // and need to operate only on file address.
+ m_images.ResolveFileAddress (addr, resolved_addr);
+ else
+ section_load_list.ResolveLoadAddress(addr, resolved_addr);
+
+ // Get the function boundaries to make sure we don't scan back before the beginning of the current function.
+ ModuleSP temp_addr_module_sp (resolved_addr.GetModule());
+ if (temp_addr_module_sp)
+ {
+ SymbolContext sc;
+ uint32_t resolve_scope = eSymbolContextFunction | eSymbolContextSymbol;
+ temp_addr_module_sp->ResolveSymbolContextForAddress(resolved_addr, resolve_scope, sc);
+ if (sc.function)
+ {
+ function_start = sc.function->GetAddressRange().GetBaseAddress().GetLoadAddress(this);
+ if (function_start == LLDB_INVALID_ADDRESS)
+ function_start = sc.function->GetAddressRange().GetBaseAddress().GetFileAddress();
+ }
+ else if (sc.symbol)
+ {
+ Address sym_addr = sc.symbol->GetAddress();
+ function_start = sym_addr.GetFileAddress();
+ }
+ current_offset = addr - function_start;
+ }
+
+ // If breakpoint address is start of function then we dont have to do anything.
+ if (current_offset == 0)
+ return breakable_addr;
+ else
+ loop_count = current_offset / 2;
+
+ if (loop_count > 3)
+ {
+ // Scan previous 6 bytes
+ if (IsMips16 | IsMicromips)
+ loop_count = 3;
+ // For mips-only, instructions are always 4 bytes, so scan previous 4 bytes only.
+ else
+ loop_count = 2;
+ }
+
+ // Create Disassembler Instance
+ lldb::DisassemblerSP disasm_sp(Disassembler::FindPlugin(m_arch, nullptr, nullptr));
+
+ ExecutionContext exe_ctx;
+ CalculateExecutionContext(exe_ctx);
+ InstructionList instruction_list;
+ InstructionSP prev_insn;
+ bool prefer_file_cache = true; // Read from file
+ uint32_t inst_to_choose = 0;
+
+ for (uint32_t i = 1; i <= loop_count; i++)
+ {
+ // Adjust the address to read from.
+ resolved_addr.Slide (-2);
+ AddressRange range(resolved_addr, i*2);
+ uint32_t insn_size = 0;
+
+ disasm_sp->ParseInstructions(&exe_ctx, range, nullptr, prefer_file_cache);
+
+ uint32_t num_insns = disasm_sp->GetInstructionList().GetSize();
+ if (num_insns)
+ {
+ prev_insn = disasm_sp->GetInstructionList().GetInstructionAtIndex(0);
+ insn_size = prev_insn->GetOpcode().GetByteSize();
+ if (i == 1 && insn_size == 2)
+ {
+ // This looks like a valid 2-byte instruction (but it could be a part of upper 4 byte instruction).
+ instruction_list.Append(prev_insn);
+ inst_to_choose = 1;
+ }
+ else if (i == 2)
+ {
+ // Here we may get one 4-byte instruction or two 2-byte instructions.
+ if (num_insns == 2)
+ {
+ // Looks like there are two 2-byte instructions above our breakpoint target address.
+ // Now the upper 2-byte instruction is either a valid 2-byte instruction or could be a part of it's upper 4-byte instruction.
+ // In both cases we don't care because in this case lower 2-byte instruction is definitely a valid instruction
+ // and whatever i=1 iteration has found out is true.
+ inst_to_choose = 1;
+ break;
+ }
+ else if (insn_size == 4)
+ {
+ // This instruction claims its a valid 4-byte instruction. But it could be a part of it's upper 4-byte instruction.
+ // Lets try scanning upper 2 bytes to verify this.
+ instruction_list.Append(prev_insn);
+ inst_to_choose = 2;
+ }
+ }
+ else if (i == 3)
+ {
+ if (insn_size == 4)
+ // FIXME: We reached here that means instruction at [target - 4] has already claimed to be a 4-byte instruction,
+ // and now instruction at [target - 6] is also claiming that it's a 4-byte instruction. This can not be true.
+ // In this case we can not decide the valid previous instruction so we let lldb set the breakpoint at the address given by user.
+ inst_to_choose = 0;
+ else
+ // This is straight-forward
+ inst_to_choose = 2;
+ break;
+ }
+ }
+ else
+ {
+ // Decode failed, bytes do not form a valid instruction. So whatever previous iteration has found out is true.
+ if (i > 1)
+ {
+ inst_to_choose = i - 1;
+ break;
+ }
+ }
+ }
+
+ // Check if we are able to find any valid instruction.
+ if (inst_to_choose)
+ {
+ if (inst_to_choose > instruction_list.GetSize())
+ inst_to_choose--;
+ prev_insn = instruction_list.GetInstructionAtIndex(inst_to_choose - 1);
+
+ if (prev_insn->HasDelaySlot())
+ {
+ uint32_t shift_size = prev_insn->GetOpcode().GetByteSize();
+ // Adjust the breakable address
+ breakable_addr = addr - shift_size;
+ if (log)
+ log->Printf ("Target::%s Breakpoint at 0x%8.8" PRIx64 " is adjusted to 0x%8.8" PRIx64 " due to delay slot\n", __FUNCTION__, addr, breakable_addr);
+ }
+ }
+ break;
+ }
+ }
+ return breakable_addr;
+}
+
SourceManager &
Target::GetSourceManager ()
{
- if (m_source_manager_ap.get() == NULL)
+ if (!m_source_manager_ap)
m_source_manager_ap.reset (new SourceManager(shared_from_this()));
return *m_source_manager_ap;
}
@@ -2158,12 +2605,8 @@ Target::CreateStopHook ()
bool
Target::RemoveStopHookByID (lldb::user_id_t user_id)
{
- size_t num_removed;
- num_removed = m_stop_hooks.erase (user_id);
- if (num_removed == 0)
- return false;
- else
- return true;
+ size_t num_removed = m_stop_hooks.erase(user_id);
+ return (num_removed != 0);
}
void
@@ -2266,19 +2709,9 @@ Target::RunStopHooks ()
bool keep_going = true;
bool hooks_ran = false;
- bool print_hook_header;
- bool print_thread_header;
+ bool print_hook_header = (m_stop_hooks.size() != 1);
+ bool print_thread_header = (num_exe_ctx != 1);
- if (num_exe_ctx == 1)
- print_thread_header = false;
- else
- print_thread_header = true;
-
- if (m_stop_hooks.size() == 1)
- print_hook_header = false;
- else
- print_hook_header = true;
-
for (pos = m_stop_hooks.begin(); keep_going && pos != end; pos++)
{
// result.Clear();
@@ -2289,9 +2722,9 @@ Target::RunStopHooks ()
bool any_thread_matched = false;
for (size_t i = 0; keep_going && i < num_exe_ctx; i++)
{
- if ((cur_hook_sp->GetSpecifier () == NULL
+ if ((cur_hook_sp->GetSpecifier() == nullptr
|| cur_hook_sp->GetSpecifier()->SymbolContextMatches(sym_ctx_with_reasons[i]))
- && (cur_hook_sp->GetThreadSpecifier() == NULL
+ && (cur_hook_sp->GetThreadSpecifier() == nullptr
|| cur_hook_sp->GetThreadSpecifier()->ThreadPassesBasicTests(exc_ctx_with_reasons[i].GetThreadRef())))
{
if (!hooks_ran)
@@ -2302,7 +2735,7 @@ Target::RunStopHooks ()
{
const char *cmd = (cur_hook_sp->GetCommands().GetSize() == 1 ?
cur_hook_sp->GetCommands().GetStringAtIndex(0) :
- NULL);
+ nullptr);
if (cmd)
result.AppendMessageWithFormat("\n- Hook %" PRIu64 " (%s)\n", cur_hook_sp->GetID(), cmd);
else
@@ -2347,7 +2780,7 @@ Target::GetGlobalProperties()
static TargetPropertiesSP g_settings_sp;
if (!g_settings_sp)
{
- g_settings_sp.reset (new TargetProperties (NULL));
+ g_settings_sp.reset(new TargetProperties(nullptr));
}
return g_settings_sp;
}
@@ -2439,7 +2872,6 @@ Target::SetSectionLoadAddress (const SectionSP &section_sp, addr_t new_section_l
return true; // Return true if the section load address was changed...
}
return false; // Return false to indicate nothing changed
-
}
size_t
@@ -2506,7 +2938,6 @@ Target::ClearAllLoadedSections ()
m_section_load_history.Clear();
}
-
Error
Target::Launch (ProcessLaunchInfo &launch_info, Stream *stream)
{
@@ -2609,7 +3040,7 @@ Target::Launch (ProcessLaunchInfo &launch_info, Stream *stream)
{
// Use a Process plugin to construct the process.
const char *plugin_name = launch_info.GetProcessPluginName();
- CreateProcess (launch_info.GetListenerForProcess(debugger), plugin_name, NULL);
+ CreateProcess(launch_info.GetListenerForProcess(debugger), plugin_name, nullptr);
}
// Since we didn't have a platform launch the process, launch it here.
@@ -2626,7 +3057,7 @@ Target::Launch (ProcessLaunchInfo &launch_info, Stream *stream)
if (error.Success())
{
- if (synchronous_execution || launch_info.GetFlags().Test(eLaunchFlagStopAtEntry) == false)
+ if (synchronous_execution || !launch_info.GetFlags().Test(eLaunchFlagStopAtEntry))
{
ListenerSP hijack_listener_sp (launch_info.GetHijackListener());
if (!hijack_listener_sp)
@@ -2636,7 +3067,7 @@ Target::Launch (ProcessLaunchInfo &launch_info, Stream *stream)
m_process_sp->HijackProcessEvents(hijack_listener_sp.get());
}
- StateType state = m_process_sp->WaitForProcessToStop (NULL, NULL, false, hijack_listener_sp.get(), NULL);
+ StateType state = m_process_sp->WaitForProcessToStop(nullptr, nullptr, false, hijack_listener_sp.get(), nullptr);
if (state == eStateStopped)
{
@@ -2647,7 +3078,7 @@ Target::Launch (ProcessLaunchInfo &launch_info, Stream *stream)
error = m_process_sp->PrivateResume();
if (error.Success())
{
- state = m_process_sp->WaitForProcessToStop (NULL, NULL, true, hijack_listener_sp.get(), stream);
+ state = m_process_sp->WaitForProcessToStop(nullptr, nullptr, true, hijack_listener_sp.get(), stream);
const bool must_be_alive = false; // eStateExited is ok, so this must be false
if (!StateIsStoppedState(state, must_be_alive))
{
@@ -2721,9 +3152,6 @@ Target::Attach (ProcessAttachInfo &attach_info, Stream *stream)
}
}
- ListenerSP hijack_listener_sp (new Listener ("lldb.Target.Attach.attach.hijack"));
- attach_info.SetHijackListener (hijack_listener_sp);
-
const ModuleSP old_exec_module_sp = GetExecutableModule ();
// If no process info was specified, then use the target executable
@@ -2740,6 +3168,13 @@ Target::Attach (ProcessAttachInfo &attach_info, Stream *stream)
}
const auto platform_sp = GetDebugger ().GetPlatformList ().GetSelectedPlatform ();
+ ListenerSP hijack_listener_sp;
+ const bool async = attach_info.GetAsync();
+ if (!async)
+ {
+ hijack_listener_sp.reset (new Listener ("lldb.Target.Attach.attach.hijack"));
+ attach_info.SetHijackListener (hijack_listener_sp);
+ }
Error error;
if (state != eStateConnected && platform_sp != nullptr && platform_sp->CanDebugProcess ())
@@ -2759,23 +3194,31 @@ Target::Attach (ProcessAttachInfo &attach_info, Stream *stream)
return error;
}
}
- process_sp->HijackProcessEvents (hijack_listener_sp.get ());
+ if (hijack_listener_sp)
+ process_sp->HijackProcessEvents (hijack_listener_sp.get ());
error = process_sp->Attach (attach_info);
}
if (error.Success () && process_sp)
{
- state = process_sp->WaitForProcessToStop (nullptr, nullptr, false, attach_info.GetHijackListener ().get (), stream);
- process_sp->RestoreProcessEvents ();
-
- if (state != eStateStopped)
+ if (async)
{
- const char *exit_desc = process_sp->GetExitDescription ();
- if (exit_desc)
- error.SetErrorStringWithFormat ("attach failed: %s", exit_desc);
- else
- error.SetErrorString ("attach failed: process did not stop (no such process or permission problem?)");
- process_sp->Destroy (false);
+ process_sp->RestoreProcessEvents ();
+ }
+ else
+ {
+ state = process_sp->WaitForProcessToStop (nullptr, nullptr, false, attach_info.GetHijackListener ().get (), stream);
+ process_sp->RestoreProcessEvents ();
+
+ if (state != eStateStopped)
+ {
+ const char *exit_desc = process_sp->GetExitDescription ();
+ if (exit_desc)
+ error.SetErrorStringWithFormat ("%s", exit_desc);
+ else
+ error.SetErrorString ("process did not stop (no such process or permission problem?)");
+ process_sp->Destroy (false);
+ }
}
}
return error;
@@ -2802,14 +3245,11 @@ Target::StopHook::StopHook (const StopHook &rhs) :
m_thread_spec_ap (),
m_active (rhs.m_active)
{
- if (rhs.m_thread_spec_ap.get() != NULL)
+ if (rhs.m_thread_spec_ap)
m_thread_spec_ap.reset (new ThreadSpec(*rhs.m_thread_spec_ap.get()));
}
-
-Target::StopHook::~StopHook ()
-{
-}
+Target::StopHook::~StopHook() = default;
void
Target::StopHook::SetSpecifier(SymbolContextSpecifier *specifier)
@@ -2822,7 +3262,6 @@ Target::StopHook::SetThreadSpecifier (ThreadSpec *specifier)
{
m_thread_spec_ap.reset (specifier);
}
-
void
Target::StopHook::GetDescription (Stream *s, lldb::DescriptionLevel level) const
@@ -2846,7 +3285,7 @@ Target::StopHook::GetDescription (Stream *s, lldb::DescriptionLevel level) const
s->SetIndentLevel (indent_level + 2);
}
- if (m_thread_spec_ap.get() != NULL)
+ if (m_thread_spec_ap)
{
StreamString tmp;
s->Indent("Thread:\n");
@@ -2878,7 +3317,7 @@ lldb_private::g_dynamic_value_types[] =
{ eNoDynamicValues, "no-dynamic-values", "Don't calculate the dynamic type of values"},
{ eDynamicCanRunTarget, "run-target", "Calculate the dynamic type of values even if you have to run the target."},
{ eDynamicDontRunTarget, "no-run-target", "Calculate the dynamic type of values, but don't run the target."},
- { 0, NULL, NULL }
+ { 0, nullptr, nullptr }
};
static OptionEnumValueElement
@@ -2887,7 +3326,7 @@ g_inline_breakpoint_enums[] =
{ eInlineBreakpointsNever, "never", "Never look for inline breakpoint locations (fastest). This setting should only be used if you know that no inlining occurs in your programs."},
{ eInlineBreakpointsHeaders, "headers", "Only check for inline breakpoint locations when setting breakpoints in header files, but not when setting breakpoint in implementation source files (default)."},
{ eInlineBreakpointsAlways, "always", "Always look for inline breakpoint locations when setting file and line breakpoints (slower but most accurate)."},
- { 0, NULL, NULL }
+ { 0, nullptr, nullptr }
};
typedef enum x86DisassemblyFlavor
@@ -2903,7 +3342,7 @@ g_x86_dis_flavor_value_types[] =
{ eX86DisFlavorDefault, "default", "Disassembler default (currently att)."},
{ eX86DisFlavorIntel, "intel", "Intel disassembler flavor."},
{ eX86DisFlavorATT, "att", "AT&T disassembler flavor."},
- { 0, NULL, NULL }
+ { 0, nullptr, nullptr }
};
static OptionEnumValueElement
@@ -2911,7 +3350,7 @@ g_hex_immediate_style_values[] =
{
{ Disassembler::eHexStyleC, "c", "C-style (0xffff)."},
{ Disassembler::eHexStyleAsm, "asm", "Asm-style (0ffffh)."},
- { 0, NULL, NULL }
+ { 0, nullptr, nullptr }
};
static OptionEnumValueElement
@@ -2920,52 +3359,52 @@ g_load_script_from_sym_file_values[] =
{ eLoadScriptFromSymFileTrue, "true", "Load debug scripts inside symbol files"},
{ eLoadScriptFromSymFileFalse, "false", "Do not load debug scripts inside symbol files."},
{ eLoadScriptFromSymFileWarn, "warn", "Warn about debug scripts inside symbol files but do not load them."},
- { 0, NULL, NULL }
+ { 0, nullptr, nullptr }
};
-
static OptionEnumValueElement
g_memory_module_load_level_values[] =
{
{ eMemoryModuleLoadLevelMinimal, "minimal" , "Load minimal information when loading modules from memory. Currently this setting loads sections only."},
{ eMemoryModuleLoadLevelPartial, "partial" , "Load partial information when loading modules from memory. Currently this setting loads sections and function bounds."},
{ eMemoryModuleLoadLevelComplete, "complete", "Load complete information when loading modules from memory. Currently this setting loads sections and all symbols."},
- { 0, NULL, NULL }
+ { 0, nullptr, nullptr }
};
static PropertyDefinition
g_properties[] =
{
- { "default-arch" , OptionValue::eTypeArch , true , 0 , NULL, NULL, "Default architecture to choose, when there's a choice." },
- { "move-to-nearest-code" , OptionValue::eTypeBoolean , false, true , NULL, NULL, "Move breakpoints to nearest code." },
- { "expr-prefix" , OptionValue::eTypeFileSpec , false, 0 , NULL, NULL, "Path to a file containing expressions to be prepended to all expressions." },
- { "prefer-dynamic-value" , OptionValue::eTypeEnum , false, eDynamicDontRunTarget , NULL, g_dynamic_value_types, "Should printed values be shown as their dynamic value." },
- { "enable-synthetic-value" , OptionValue::eTypeBoolean , false, true , NULL, NULL, "Should synthetic values be used by default whenever available." },
- { "skip-prologue" , OptionValue::eTypeBoolean , false, true , NULL, NULL, "Skip function prologues when setting breakpoints by name." },
- { "source-map" , OptionValue::eTypePathMap , false, 0 , NULL, NULL, "Source path remappings used to track the change of location between a source file when built, and "
+ { "default-arch" , OptionValue::eTypeArch , true , 0 , nullptr, nullptr, "Default architecture to choose, when there's a choice." },
+ { "move-to-nearest-code" , OptionValue::eTypeBoolean , false, true , nullptr, nullptr, "Move breakpoints to nearest code." },
+ { "language" , OptionValue::eTypeLanguage , false, eLanguageTypeUnknown , nullptr, nullptr, "The language to use when interpreting expressions entered in commands." },
+ { "expr-prefix" , OptionValue::eTypeFileSpec , false, 0 , nullptr, nullptr, "Path to a file containing expressions to be prepended to all expressions." },
+ { "prefer-dynamic-value" , OptionValue::eTypeEnum , false, eDynamicDontRunTarget , nullptr, g_dynamic_value_types, "Should printed values be shown as their dynamic value." },
+ { "enable-synthetic-value" , OptionValue::eTypeBoolean , false, true , nullptr, nullptr, "Should synthetic values be used by default whenever available." },
+ { "skip-prologue" , OptionValue::eTypeBoolean , false, true , nullptr, nullptr, "Skip function prologues when setting breakpoints by name." },
+ { "source-map" , OptionValue::eTypePathMap , false, 0 , nullptr, nullptr, "Source path remappings are used to track the change of location between a source file when built, and "
"where it exists on the current system. It consists of an array of duples, the first element of each duple is "
"some part (starting at the root) of the path to the file when it was built, "
"and the second is where the remainder of the original build hierarchy is rooted on the local system. "
"Each element of the array is checked in order and the first one that results in a match wins." },
- { "exec-search-paths" , OptionValue::eTypeFileSpecList, false, 0 , NULL, NULL, "Executable search paths to use when locating executable files whose paths don't match the local file system." },
- { "debug-file-search-paths" , OptionValue::eTypeFileSpecList, false, 0 , NULL, NULL, "List of directories to be searched when locating debug symbol files." },
- { "clang-module-search-paths" , OptionValue::eTypeFileSpecList, false, 0 , NULL, NULL, "List of directories to be searched when locating modules for Clang." },
- { "auto-import-clang-modules" , OptionValue::eTypeBoolean , false, false , NULL, NULL, "Automatically load Clang modules referred to by the program." },
- { "max-children-count" , OptionValue::eTypeSInt64 , false, 256 , NULL, NULL, "Maximum number of children to expand in any level of depth." },
- { "max-string-summary-length" , OptionValue::eTypeSInt64 , false, 1024 , NULL, NULL, "Maximum number of characters to show when using %s in summary strings." },
- { "max-memory-read-size" , OptionValue::eTypeSInt64 , false, 1024 , NULL, NULL, "Maximum number of bytes that 'memory read' will fetch before --force must be specified." },
- { "breakpoints-use-platform-avoid-list", OptionValue::eTypeBoolean , false, true , NULL, NULL, "Consult the platform module avoid list when setting non-module specific breakpoints." },
- { "arg0" , OptionValue::eTypeString , false, 0 , NULL, NULL, "The first argument passed to the program in the argument array which can be different from the executable itself." },
- { "run-args" , OptionValue::eTypeArgs , false, 0 , NULL, NULL, "A list containing all the arguments to be passed to the executable when it is run. Note that this does NOT include the argv[0] which is in target.arg0." },
- { "env-vars" , OptionValue::eTypeDictionary, false, OptionValue::eTypeString , NULL, NULL, "A list of all the environment variables to be passed to the executable's environment, and their values." },
- { "inherit-env" , OptionValue::eTypeBoolean , false, true , NULL, NULL, "Inherit the environment from the process that is running LLDB." },
- { "input-path" , OptionValue::eTypeFileSpec , false, 0 , NULL, NULL, "The file/path to be used by the executable program for reading its standard input." },
- { "output-path" , OptionValue::eTypeFileSpec , false, 0 , NULL, NULL, "The file/path to be used by the executable program for writing its standard output." },
- { "error-path" , OptionValue::eTypeFileSpec , false, 0 , NULL, NULL, "The file/path to be used by the executable program for writing its standard error." },
- { "detach-on-error" , OptionValue::eTypeBoolean , false, true , NULL, NULL, "debugserver will detach (rather than killing) a process if it loses connection with lldb." },
- { "disable-aslr" , OptionValue::eTypeBoolean , false, true , NULL, NULL, "Disable Address Space Layout Randomization (ASLR)" },
- { "disable-stdio" , OptionValue::eTypeBoolean , false, false , NULL, NULL, "Disable stdin/stdout for process (e.g. for a GUI application)" },
- { "inline-breakpoint-strategy" , OptionValue::eTypeEnum , false, eInlineBreakpointsAlways , NULL, g_inline_breakpoint_enums, "The strategy to use when settings breakpoints by file and line. "
+ { "exec-search-paths" , OptionValue::eTypeFileSpecList, false, 0 , nullptr, nullptr, "Executable search paths to use when locating executable files whose paths don't match the local file system." },
+ { "debug-file-search-paths" , OptionValue::eTypeFileSpecList, false, 0 , nullptr, nullptr, "List of directories to be searched when locating debug symbol files." },
+ { "clang-module-search-paths" , OptionValue::eTypeFileSpecList, false, 0 , nullptr, nullptr, "List of directories to be searched when locating modules for Clang." },
+ { "auto-import-clang-modules" , OptionValue::eTypeBoolean , false, false , nullptr, nullptr, "Automatically load Clang modules referred to by the program." },
+ { "max-children-count" , OptionValue::eTypeSInt64 , false, 256 , nullptr, nullptr, "Maximum number of children to expand in any level of depth." },
+ { "max-string-summary-length" , OptionValue::eTypeSInt64 , false, 1024 , nullptr, nullptr, "Maximum number of characters to show when using %s in summary strings." },
+ { "max-memory-read-size" , OptionValue::eTypeSInt64 , false, 1024 , nullptr, nullptr, "Maximum number of bytes that 'memory read' will fetch before --force must be specified." },
+ { "breakpoints-use-platform-avoid-list", OptionValue::eTypeBoolean , false, true , nullptr, nullptr, "Consult the platform module avoid list when setting non-module specific breakpoints." },
+ { "arg0" , OptionValue::eTypeString , false, 0 , nullptr, nullptr, "The first argument passed to the program in the argument array which can be different from the executable itself." },
+ { "run-args" , OptionValue::eTypeArgs , false, 0 , nullptr, nullptr, "A list containing all the arguments to be passed to the executable when it is run. Note that this does NOT include the argv[0] which is in target.arg0." },
+ { "env-vars" , OptionValue::eTypeDictionary, false, OptionValue::eTypeString , nullptr, nullptr, "A list of all the environment variables to be passed to the executable's environment, and their values." },
+ { "inherit-env" , OptionValue::eTypeBoolean , false, true , nullptr, nullptr, "Inherit the environment from the process that is running LLDB." },
+ { "input-path" , OptionValue::eTypeFileSpec , false, 0 , nullptr, nullptr, "The file/path to be used by the executable program for reading its standard input." },
+ { "output-path" , OptionValue::eTypeFileSpec , false, 0 , nullptr, nullptr, "The file/path to be used by the executable program for writing its standard output." },
+ { "error-path" , OptionValue::eTypeFileSpec , false, 0 , nullptr, nullptr, "The file/path to be used by the executable program for writing its standard error." },
+ { "detach-on-error" , OptionValue::eTypeBoolean , false, true , nullptr, nullptr, "debugserver will detach (rather than killing) a process if it loses connection with lldb." },
+ { "disable-aslr" , OptionValue::eTypeBoolean , false, true , nullptr, nullptr, "Disable Address Space Layout Randomization (ASLR)" },
+ { "disable-stdio" , OptionValue::eTypeBoolean , false, false , nullptr, nullptr, "Disable stdin/stdout for process (e.g. for a GUI application)" },
+ { "inline-breakpoint-strategy" , OptionValue::eTypeEnum , false, eInlineBreakpointsAlways , nullptr, g_inline_breakpoint_enums, "The strategy to use when settings breakpoints by file and line. "
"Breakpoint locations can end up being inlined by the compiler, so that a compile unit 'a.c' might contain an inlined function from another source file. "
"Usually this is limited to breakpoint locations from inlined functions from header or other include files, or more accurately non-implementation source files. "
"Sometimes code might #include implementation files and cause inlined breakpoint locations in inlined implementation files. "
@@ -2974,28 +3413,29 @@ g_properties[] =
"This setting allows you to control exactly which strategy is used when setting "
"file and line breakpoints." },
// FIXME: This is the wrong way to do per-architecture settings, but we don't have a general per architecture settings system in place yet.
- { "x86-disassembly-flavor" , OptionValue::eTypeEnum , false, eX86DisFlavorDefault, NULL, g_x86_dis_flavor_value_types, "The default disassembly flavor to use for x86 or x86-64 targets." },
- { "use-hex-immediates" , OptionValue::eTypeBoolean , false, true, NULL, NULL, "Show immediates in disassembly as hexadecimal." },
- { "hex-immediate-style" , OptionValue::eTypeEnum , false, Disassembler::eHexStyleC, NULL, g_hex_immediate_style_values, "Which style to use for printing hexadecimal disassembly values." },
- { "use-fast-stepping" , OptionValue::eTypeBoolean , false, true, NULL, NULL, "Use a fast stepping algorithm based on running from branch to branch rather than instruction single-stepping." },
- { "load-script-from-symbol-file" , OptionValue::eTypeEnum , false, eLoadScriptFromSymFileWarn, NULL, g_load_script_from_sym_file_values, "Allow LLDB to load scripting resources embedded in symbol files when available." },
- { "memory-module-load-level" , OptionValue::eTypeEnum , false, eMemoryModuleLoadLevelComplete, NULL, g_memory_module_load_level_values,
+ { "x86-disassembly-flavor" , OptionValue::eTypeEnum , false, eX86DisFlavorDefault, nullptr, g_x86_dis_flavor_value_types, "The default disassembly flavor to use for x86 or x86-64 targets." },
+ { "use-hex-immediates" , OptionValue::eTypeBoolean , false, true, nullptr, nullptr, "Show immediates in disassembly as hexadecimal." },
+ { "hex-immediate-style" , OptionValue::eTypeEnum , false, Disassembler::eHexStyleC, nullptr, g_hex_immediate_style_values, "Which style to use for printing hexadecimal disassembly values." },
+ { "use-fast-stepping" , OptionValue::eTypeBoolean , false, true, nullptr, nullptr, "Use a fast stepping algorithm based on running from branch to branch rather than instruction single-stepping." },
+ { "load-script-from-symbol-file" , OptionValue::eTypeEnum , false, eLoadScriptFromSymFileWarn, nullptr, g_load_script_from_sym_file_values, "Allow LLDB to load scripting resources embedded in symbol files when available." },
+ { "memory-module-load-level" , OptionValue::eTypeEnum , false, eMemoryModuleLoadLevelComplete, nullptr, g_memory_module_load_level_values,
"Loading modules from memory can be slow as reading the symbol tables and other data can take a long time depending on your connection to the debug target. "
"This setting helps users control how much information gets loaded when loading modules from memory."
"'complete' is the default value for this setting which will load all sections and symbols by reading them from memory (slowest, most accurate). "
"'partial' will load sections and attempt to find function bounds without downloading the symbol table (faster, still accurate, missing symbol names). "
"'minimal' is the fastest setting and will load section data with no symbols, but should rarely be used as stack frames in these memory regions will be inaccurate and not provide any context (fastest). " },
- { "display-expression-in-crashlogs" , OptionValue::eTypeBoolean , false, false, NULL, NULL, "Expressions that crash will show up in crash logs if the host system supports executable specific crash log strings and this setting is set to true." },
- { "trap-handler-names" , OptionValue::eTypeArray , true, OptionValue::eTypeString, NULL, NULL, "A list of trap handler function names, e.g. a common Unix user process one is _sigtramp." },
- { "display-runtime-support-values" , OptionValue::eTypeBoolean , false, false, NULL, NULL, "If true, LLDB will show variables that are meant to support the operation of a language's runtime support." },
- { "non-stop-mode" , OptionValue::eTypeBoolean , false, 0, NULL, NULL, "Disable lock-step debugging, instead control threads independently." },
- { NULL , OptionValue::eTypeInvalid , false, 0 , NULL, NULL, NULL }
+ { "display-expression-in-crashlogs" , OptionValue::eTypeBoolean , false, false, nullptr, nullptr, "Expressions that crash will show up in crash logs if the host system supports executable specific crash log strings and this setting is set to true." },
+ { "trap-handler-names" , OptionValue::eTypeArray , true, OptionValue::eTypeString, nullptr, nullptr, "A list of trap handler function names, e.g. a common Unix user process one is _sigtramp." },
+ { "display-runtime-support-values" , OptionValue::eTypeBoolean , false, false, nullptr, nullptr, "If true, LLDB will show variables that are meant to support the operation of a language's runtime support." },
+ { "non-stop-mode" , OptionValue::eTypeBoolean , false, 0, nullptr, nullptr, "Disable lock-step debugging, instead control threads independently." },
+ { nullptr , OptionValue::eTypeInvalid , false, 0 , nullptr, nullptr, nullptr }
};
enum
{
ePropertyDefaultArch,
ePropertyMoveToNearestCode,
+ ePropertyLanguage,
ePropertyExprPrefix,
ePropertyPreferDynamic,
ePropertyEnableSynthetic,
@@ -3032,13 +3472,12 @@ enum
ePropertyNonStopModeEnabled
};
-
class TargetOptionValueProperties : public OptionValueProperties
{
public:
TargetOptionValueProperties (const ConstString &name) :
OptionValueProperties (name),
- m_target (NULL),
+ m_target(nullptr),
m_got_host_env (false)
{
}
@@ -3053,8 +3492,8 @@ public:
{
}
- virtual const Property *
- GetPropertyAtIndex (const ExecutionContext *exe_ctx, bool will_modify, uint32_t idx) const
+ const Property *
+ GetPropertyAtIndex(const ExecutionContext *exe_ctx, bool will_modify, uint32_t idx) const override
{
// When getting the value for a key from the target options, we will always
// try and grab the setting from the current target if there is one. Else we just
@@ -3082,7 +3521,6 @@ public:
}
protected:
-
void
GetHostEnvironmentIfNeeded () const
{
@@ -3092,7 +3530,7 @@ protected:
{
m_got_host_env = true;
const uint32_t idx = ePropertyInheritEnv;
- if (GetPropertyAtIndexAsBoolean (NULL, idx, g_properties[idx].default_uint_value != 0))
+ if (GetPropertyAtIndexAsBoolean(nullptr, idx, g_properties[idx].default_uint_value != 0))
{
PlatformSP platform_sp (m_target->GetPlatform());
if (platform_sp)
@@ -3100,7 +3538,7 @@ protected:
StringList env;
if (platform_sp->GetEnvironment(env))
{
- OptionValueDictionary *env_dict = GetPropertyAtIndexAsOptionValueDictionary (NULL, ePropertyEnvVars);
+ OptionValueDictionary *env_dict = GetPropertyAtIndexAsOptionValueDictionary(nullptr, ePropertyEnvVars);
if (env_dict)
{
const bool can_replace = false;
@@ -3113,7 +3551,7 @@ protected:
const char *equal_pos = ::strchr(env_entry, '=');
ConstString key;
// It is ok to have environment variables with no values
- const char *value = NULL;
+ const char *value = nullptr;
if (equal_pos)
{
key.SetCStringWithLength(env_entry, equal_pos - env_entry);
@@ -3162,15 +3600,15 @@ TargetProperties::TargetProperties (Target *target) :
m_collection_sp->SetValueChangedCallback(ePropertyDisableSTDIO, TargetProperties::DisableSTDIOValueChangedCallback, this);
// Update m_launch_info once it was created
- Arg0ValueChangedCallback(this, NULL);
- RunArgsValueChangedCallback(this, NULL);
- //EnvVarsValueChangedCallback(this, NULL); // FIXME: cause segfault in Target::GetPlatform()
- InputPathValueChangedCallback(this, NULL);
- OutputPathValueChangedCallback(this, NULL);
- ErrorPathValueChangedCallback(this, NULL);
- DetachOnErrorValueChangedCallback(this, NULL);
- DisableASLRValueChangedCallback(this, NULL);
- DisableSTDIOValueChangedCallback(this, NULL);
+ Arg0ValueChangedCallback(this, nullptr);
+ RunArgsValueChangedCallback(this, nullptr);
+ //EnvVarsValueChangedCallback(this, nullptr); // FIXME: cause segfault in Target::GetPlatform()
+ InputPathValueChangedCallback(this, nullptr);
+ OutputPathValueChangedCallback(this, nullptr);
+ ErrorPathValueChangedCallback(this, nullptr);
+ DetachOnErrorValueChangedCallback(this, nullptr);
+ DisableASLRValueChangedCallback(this, nullptr);
+ DisableSTDIOValueChangedCallback(this, nullptr);
}
else
{
@@ -3181,16 +3619,14 @@ TargetProperties::TargetProperties (Target *target) :
true,
Process::GetGlobalProperties()->GetValueProperties());
}
-
}
-TargetProperties::~TargetProperties ()
-{
-}
+TargetProperties::~TargetProperties() = default;
+
ArchSpec
TargetProperties::GetDefaultArchitecture () const
{
- OptionValueArch *value = m_collection_sp->GetPropertyAtIndexAsOptionValueArch (NULL, ePropertyDefaultArch);
+ OptionValueArch *value = m_collection_sp->GetPropertyAtIndexAsOptionValueArch(nullptr, ePropertyDefaultArch);
if (value)
return value->GetCurrentValue();
return ArchSpec();
@@ -3199,7 +3635,7 @@ TargetProperties::GetDefaultArchitecture () const
void
TargetProperties::SetDefaultArchitecture (const ArchSpec& arch)
{
- OptionValueArch *value = m_collection_sp->GetPropertyAtIndexAsOptionValueArch (NULL, ePropertyDefaultArch);
+ OptionValueArch *value = m_collection_sp->GetPropertyAtIndexAsOptionValueArch(nullptr, ePropertyDefaultArch);
if (value)
return value->SetCurrentValue(arch, true);
}
@@ -3208,64 +3644,63 @@ bool
TargetProperties::GetMoveToNearestCode() const
{
const uint32_t idx = ePropertyMoveToNearestCode;
- return m_collection_sp->GetPropertyAtIndexAsBoolean (NULL, idx, g_properties[idx].default_uint_value != 0);
+ return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx, g_properties[idx].default_uint_value != 0);
}
lldb::DynamicValueType
TargetProperties::GetPreferDynamicValue() const
{
const uint32_t idx = ePropertyPreferDynamic;
- return (lldb::DynamicValueType)m_collection_sp->GetPropertyAtIndexAsEnumeration (NULL, idx, g_properties[idx].default_uint_value);
+ return (lldb::DynamicValueType)m_collection_sp->GetPropertyAtIndexAsEnumeration(nullptr, idx, g_properties[idx].default_uint_value);
}
bool
TargetProperties::SetPreferDynamicValue (lldb::DynamicValueType d)
{
const uint32_t idx = ePropertyPreferDynamic;
- return m_collection_sp->SetPropertyAtIndexAsEnumeration(NULL, idx, d);
+ return m_collection_sp->SetPropertyAtIndexAsEnumeration(nullptr, idx, d);
}
-
bool
TargetProperties::GetDisableASLR () const
{
const uint32_t idx = ePropertyDisableASLR;
- return m_collection_sp->GetPropertyAtIndexAsBoolean (NULL, idx, g_properties[idx].default_uint_value != 0);
+ return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx, g_properties[idx].default_uint_value != 0);
}
void
TargetProperties::SetDisableASLR (bool b)
{
const uint32_t idx = ePropertyDisableASLR;
- m_collection_sp->SetPropertyAtIndexAsBoolean (NULL, idx, b);
+ m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, b);
}
bool
TargetProperties::GetDetachOnError () const
{
const uint32_t idx = ePropertyDetachOnError;
- return m_collection_sp->GetPropertyAtIndexAsBoolean (NULL, idx, g_properties[idx].default_uint_value != 0);
+ return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx, g_properties[idx].default_uint_value != 0);
}
void
TargetProperties::SetDetachOnError (bool b)
{
const uint32_t idx = ePropertyDetachOnError;
- m_collection_sp->SetPropertyAtIndexAsBoolean (NULL, idx, b);
+ m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, b);
}
bool
TargetProperties::GetDisableSTDIO () const
{
const uint32_t idx = ePropertyDisableSTDIO;
- return m_collection_sp->GetPropertyAtIndexAsBoolean (NULL, idx, g_properties[idx].default_uint_value != 0);
+ return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx, g_properties[idx].default_uint_value != 0);
}
void
TargetProperties::SetDisableSTDIO (bool b)
{
const uint32_t idx = ePropertyDisableSTDIO;
- m_collection_sp->SetPropertyAtIndexAsBoolean (NULL, idx, b);
+ m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, b);
}
const char *
@@ -3274,7 +3709,7 @@ TargetProperties::GetDisassemblyFlavor () const
const uint32_t idx = ePropertyDisassemblyFlavor;
const char *return_value;
- x86DisassemblyFlavor flavor_value = (x86DisassemblyFlavor) m_collection_sp->GetPropertyAtIndexAsEnumeration (NULL, idx, g_properties[idx].default_uint_value);
+ x86DisassemblyFlavor flavor_value = (x86DisassemblyFlavor) m_collection_sp->GetPropertyAtIndexAsEnumeration(nullptr, idx, g_properties[idx].default_uint_value);
return_value = g_x86_dis_flavor_value_types[flavor_value].string_value;
return return_value;
}
@@ -3283,21 +3718,21 @@ InlineStrategy
TargetProperties::GetInlineStrategy () const
{
const uint32_t idx = ePropertyInlineStrategy;
- return (InlineStrategy)m_collection_sp->GetPropertyAtIndexAsEnumeration (NULL, idx, g_properties[idx].default_uint_value);
+ return (InlineStrategy)m_collection_sp->GetPropertyAtIndexAsEnumeration(nullptr, idx, g_properties[idx].default_uint_value);
}
const char *
TargetProperties::GetArg0 () const
{
const uint32_t idx = ePropertyArg0;
- return m_collection_sp->GetPropertyAtIndexAsString (NULL, idx, NULL);
+ return m_collection_sp->GetPropertyAtIndexAsString(nullptr, idx, nullptr);
}
void
TargetProperties::SetArg0 (const char *arg)
{
const uint32_t idx = ePropertyArg0;
- m_collection_sp->SetPropertyAtIndexAsString (NULL, idx, arg);
+ m_collection_sp->SetPropertyAtIndexAsString(nullptr, idx, arg);
m_launch_info.SetArg0(arg);
}
@@ -3305,14 +3740,14 @@ bool
TargetProperties::GetRunArguments (Args &args) const
{
const uint32_t idx = ePropertyRunArgs;
- return m_collection_sp->GetPropertyAtIndexAsArgs (NULL, idx, args);
+ return m_collection_sp->GetPropertyAtIndexAsArgs(nullptr, idx, args);
}
void
TargetProperties::SetRunArguments (const Args &args)
{
const uint32_t idx = ePropertyRunArgs;
- m_collection_sp->SetPropertyAtIndexFromArgs (NULL, idx, args);
+ m_collection_sp->SetPropertyAtIndexFromArgs(nullptr, idx, args);
m_launch_info.GetArguments() = args;
}
@@ -3320,14 +3755,14 @@ size_t
TargetProperties::GetEnvironmentAsArgs (Args &env) const
{
const uint32_t idx = ePropertyEnvVars;
- return m_collection_sp->GetPropertyAtIndexAsArgs (NULL, idx, env);
+ return m_collection_sp->GetPropertyAtIndexAsArgs(nullptr, idx, env);
}
void
TargetProperties::SetEnvironmentFromArgs (const Args &env)
{
const uint32_t idx = ePropertyEnvVars;
- m_collection_sp->SetPropertyAtIndexFromArgs (NULL, idx, env);
+ m_collection_sp->SetPropertyAtIndexFromArgs(nullptr, idx, env);
m_launch_info.GetEnvironmentEntries() = env;
}
@@ -3335,14 +3770,14 @@ bool
TargetProperties::GetSkipPrologue() const
{
const uint32_t idx = ePropertySkipPrologue;
- return m_collection_sp->GetPropertyAtIndexAsBoolean (NULL, idx, g_properties[idx].default_uint_value != 0);
+ return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx, g_properties[idx].default_uint_value != 0);
}
PathMappingList &
TargetProperties::GetSourcePathMap () const
{
const uint32_t idx = ePropertySourceMap;
- OptionValuePathMappings *option_value = m_collection_sp->GetPropertyAtIndexAsOptionValuePathMappings (NULL, false, idx);
+ OptionValuePathMappings *option_value = m_collection_sp->GetPropertyAtIndexAsOptionValuePathMappings(nullptr, false, idx);
assert(option_value);
return option_value->GetCurrentValue();
}
@@ -3351,7 +3786,7 @@ FileSpecList &
TargetProperties::GetExecutableSearchPaths ()
{
const uint32_t idx = ePropertyExecutableSearchPaths;
- OptionValueFileSpecList *option_value = m_collection_sp->GetPropertyAtIndexAsOptionValueFileSpecList (NULL, false, idx);
+ OptionValueFileSpecList *option_value = m_collection_sp->GetPropertyAtIndexAsOptionValueFileSpecList(nullptr, false, idx);
assert(option_value);
return option_value->GetCurrentValue();
}
@@ -3360,7 +3795,7 @@ FileSpecList &
TargetProperties::GetDebugFileSearchPaths ()
{
const uint32_t idx = ePropertyDebugFileSearchPaths;
- OptionValueFileSpecList *option_value = m_collection_sp->GetPropertyAtIndexAsOptionValueFileSpecList (NULL, false, idx);
+ OptionValueFileSpecList *option_value = m_collection_sp->GetPropertyAtIndexAsOptionValueFileSpecList(nullptr, false, idx);
assert(option_value);
return option_value->GetCurrentValue();
}
@@ -3369,7 +3804,7 @@ FileSpecList &
TargetProperties::GetClangModuleSearchPaths ()
{
const uint32_t idx = ePropertyClangModuleSearchPaths;
- OptionValueFileSpecList *option_value = m_collection_sp->GetPropertyAtIndexAsOptionValueFileSpecList (NULL, false, idx);
+ OptionValueFileSpecList *option_value = m_collection_sp->GetPropertyAtIndexAsOptionValueFileSpecList(nullptr, false, idx);
assert(option_value);
return option_value->GetCurrentValue();
}
@@ -3378,77 +3813,86 @@ bool
TargetProperties::GetEnableAutoImportClangModules() const
{
const uint32_t idx = ePropertyAutoImportClangModules;
- return m_collection_sp->GetPropertyAtIndexAsBoolean (NULL, idx, g_properties[idx].default_uint_value != 0);
+ return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx, g_properties[idx].default_uint_value != 0);
}
bool
TargetProperties::GetEnableSyntheticValue () const
{
const uint32_t idx = ePropertyEnableSynthetic;
- return m_collection_sp->GetPropertyAtIndexAsBoolean (NULL, idx, g_properties[idx].default_uint_value != 0);
+ return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx, g_properties[idx].default_uint_value != 0);
}
uint32_t
TargetProperties::GetMaximumNumberOfChildrenToDisplay() const
{
const uint32_t idx = ePropertyMaxChildrenCount;
- return m_collection_sp->GetPropertyAtIndexAsSInt64 (NULL, idx, g_properties[idx].default_uint_value);
+ return m_collection_sp->GetPropertyAtIndexAsSInt64(nullptr, idx, g_properties[idx].default_uint_value);
}
uint32_t
TargetProperties::GetMaximumSizeOfStringSummary() const
{
const uint32_t idx = ePropertyMaxSummaryLength;
- return m_collection_sp->GetPropertyAtIndexAsSInt64 (NULL, idx, g_properties[idx].default_uint_value);
+ return m_collection_sp->GetPropertyAtIndexAsSInt64(nullptr, idx, g_properties[idx].default_uint_value);
}
uint32_t
TargetProperties::GetMaximumMemReadSize () const
{
const uint32_t idx = ePropertyMaxMemReadSize;
- return m_collection_sp->GetPropertyAtIndexAsSInt64 (NULL, idx, g_properties[idx].default_uint_value);
+ return m_collection_sp->GetPropertyAtIndexAsSInt64(nullptr, idx, g_properties[idx].default_uint_value);
}
FileSpec
TargetProperties::GetStandardInputPath () const
{
const uint32_t idx = ePropertyInputPath;
- return m_collection_sp->GetPropertyAtIndexAsFileSpec (NULL, idx);
+ return m_collection_sp->GetPropertyAtIndexAsFileSpec(nullptr, idx);
}
void
TargetProperties::SetStandardInputPath (const char *p)
{
const uint32_t idx = ePropertyInputPath;
- m_collection_sp->SetPropertyAtIndexAsString (NULL, idx, p);
+ m_collection_sp->SetPropertyAtIndexAsString(nullptr, idx, p);
}
FileSpec
TargetProperties::GetStandardOutputPath () const
{
const uint32_t idx = ePropertyOutputPath;
- return m_collection_sp->GetPropertyAtIndexAsFileSpec (NULL, idx);
+ return m_collection_sp->GetPropertyAtIndexAsFileSpec(nullptr, idx);
}
void
TargetProperties::SetStandardOutputPath (const char *p)
{
const uint32_t idx = ePropertyOutputPath;
- m_collection_sp->SetPropertyAtIndexAsString (NULL, idx, p);
+ m_collection_sp->SetPropertyAtIndexAsString(nullptr, idx, p);
}
FileSpec
TargetProperties::GetStandardErrorPath () const
{
const uint32_t idx = ePropertyErrorPath;
- return m_collection_sp->GetPropertyAtIndexAsFileSpec(NULL, idx);
+ return m_collection_sp->GetPropertyAtIndexAsFileSpec(nullptr, idx);
+}
+
+LanguageType
+TargetProperties::GetLanguage () const
+{
+ OptionValueLanguage *value = m_collection_sp->GetPropertyAtIndexAsOptionValueLanguage(nullptr, ePropertyLanguage);
+ if (value)
+ return value->GetCurrentValue();
+ return LanguageType();
}
const char *
TargetProperties::GetExpressionPrefixContentsAsCString ()
{
const uint32_t idx = ePropertyExprPrefix;
- OptionValueFileSpec *file = m_collection_sp->GetPropertyAtIndexAsOptionValueFileSpec (NULL, false, idx);
+ OptionValueFileSpec *file = m_collection_sp->GetPropertyAtIndexAsOptionValueFileSpec(nullptr, false, idx);
if (file)
{
const bool null_terminate = true;
@@ -3456,105 +3900,105 @@ TargetProperties::GetExpressionPrefixContentsAsCString ()
if (data_sp)
return (const char *) data_sp->GetBytes();
}
- return NULL;
+ return nullptr;
}
void
TargetProperties::SetStandardErrorPath (const char *p)
{
const uint32_t idx = ePropertyErrorPath;
- m_collection_sp->SetPropertyAtIndexAsString (NULL, idx, p);
+ m_collection_sp->SetPropertyAtIndexAsString(nullptr, idx, p);
}
bool
TargetProperties::GetBreakpointsConsultPlatformAvoidList ()
{
const uint32_t idx = ePropertyBreakpointUseAvoidList;
- return m_collection_sp->GetPropertyAtIndexAsBoolean (NULL, idx, g_properties[idx].default_uint_value != 0);
+ return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx, g_properties[idx].default_uint_value != 0);
}
bool
TargetProperties::GetUseHexImmediates () const
{
const uint32_t idx = ePropertyUseHexImmediates;
- return m_collection_sp->GetPropertyAtIndexAsBoolean (NULL, idx, g_properties[idx].default_uint_value != 0);
+ return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx, g_properties[idx].default_uint_value != 0);
}
bool
TargetProperties::GetUseFastStepping () const
{
const uint32_t idx = ePropertyUseFastStepping;
- return m_collection_sp->GetPropertyAtIndexAsBoolean (NULL, idx, g_properties[idx].default_uint_value != 0);
+ return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx, g_properties[idx].default_uint_value != 0);
}
bool
TargetProperties::GetDisplayExpressionsInCrashlogs () const
{
const uint32_t idx = ePropertyDisplayExpressionsInCrashlogs;
- return m_collection_sp->GetPropertyAtIndexAsBoolean (NULL, idx, g_properties[idx].default_uint_value != 0);
+ return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx, g_properties[idx].default_uint_value != 0);
}
LoadScriptFromSymFile
TargetProperties::GetLoadScriptFromSymbolFile () const
{
const uint32_t idx = ePropertyLoadScriptFromSymbolFile;
- return (LoadScriptFromSymFile)m_collection_sp->GetPropertyAtIndexAsEnumeration(NULL, idx, g_properties[idx].default_uint_value);
+ return (LoadScriptFromSymFile)m_collection_sp->GetPropertyAtIndexAsEnumeration(nullptr, idx, g_properties[idx].default_uint_value);
}
Disassembler::HexImmediateStyle
TargetProperties::GetHexImmediateStyle () const
{
const uint32_t idx = ePropertyHexImmediateStyle;
- return (Disassembler::HexImmediateStyle)m_collection_sp->GetPropertyAtIndexAsEnumeration(NULL, idx, g_properties[idx].default_uint_value);
+ return (Disassembler::HexImmediateStyle)m_collection_sp->GetPropertyAtIndexAsEnumeration(nullptr, idx, g_properties[idx].default_uint_value);
}
MemoryModuleLoadLevel
TargetProperties::GetMemoryModuleLoadLevel() const
{
const uint32_t idx = ePropertyMemoryModuleLoadLevel;
- return (MemoryModuleLoadLevel)m_collection_sp->GetPropertyAtIndexAsEnumeration(NULL, idx, g_properties[idx].default_uint_value);
+ return (MemoryModuleLoadLevel)m_collection_sp->GetPropertyAtIndexAsEnumeration(nullptr, idx, g_properties[idx].default_uint_value);
}
bool
TargetProperties::GetUserSpecifiedTrapHandlerNames (Args &args) const
{
const uint32_t idx = ePropertyTrapHandlerNames;
- return m_collection_sp->GetPropertyAtIndexAsArgs (NULL, idx, args);
+ return m_collection_sp->GetPropertyAtIndexAsArgs(nullptr, idx, args);
}
void
TargetProperties::SetUserSpecifiedTrapHandlerNames (const Args &args)
{
const uint32_t idx = ePropertyTrapHandlerNames;
- m_collection_sp->SetPropertyAtIndexFromArgs (NULL, idx, args);
+ m_collection_sp->SetPropertyAtIndexFromArgs(nullptr, idx, args);
}
bool
TargetProperties::GetDisplayRuntimeSupportValues () const
{
const uint32_t idx = ePropertyDisplayRuntimeSupportValues;
- return m_collection_sp->GetPropertyAtIndexAsBoolean (NULL, idx, false);
+ return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx, false);
}
void
TargetProperties::SetDisplayRuntimeSupportValues (bool b)
{
const uint32_t idx = ePropertyDisplayRuntimeSupportValues;
- m_collection_sp->SetPropertyAtIndexAsBoolean (NULL, idx, b);
+ m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, b);
}
bool
TargetProperties::GetNonStopModeEnabled () const
{
const uint32_t idx = ePropertyNonStopModeEnabled;
- return m_collection_sp->GetPropertyAtIndexAsBoolean (NULL, idx, false);
+ return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx, false);
}
void
TargetProperties::SetNonStopModeEnabled (bool b)
{
const uint32_t idx = ePropertyNonStopModeEnabled;
- m_collection_sp->SetPropertyAtIndexAsBoolean (NULL, idx, b);
+ m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, b);
}
const ProcessLaunchInfo &
@@ -3691,9 +4135,7 @@ Target::TargetEventData::TargetEventData (const lldb::TargetSP &target_sp, const
{
}
-Target::TargetEventData::~TargetEventData()
-{
-}
+Target::TargetEventData::~TargetEventData() = default;
const ConstString &
Target::TargetEventData::GetFlavorString ()
@@ -3716,7 +4158,7 @@ Target::TargetEventData::GetEventDataFromEvent (const Event *event_ptr)
if (event_data && event_data->GetFlavor() == TargetEventData::GetFlavorString())
return static_cast <const TargetEventData *> (event_ptr->GetData());
}
- return NULL;
+ return nullptr;
}
TargetSP
diff --git a/source/Target/TargetList.cpp b/source/Target/TargetList.cpp
index 552e951496f2b..ffec758ac215f 100644
--- a/source/Target/TargetList.cpp
+++ b/source/Target/TargetList.cpp
@@ -10,6 +10,8 @@
// C Includes
// C++ Includes
// Other libraries and framework includes
+#include "llvm/ADT/SmallString.h"
+
// Project includes
#include "lldb/Core/Broadcaster.h"
#include "lldb/Core/Debugger.h"
@@ -27,8 +29,6 @@
#include "lldb/Target/Process.h"
#include "lldb/Target/TargetList.h"
-#include "llvm/ADT/SmallString.h"
-
using namespace lldb;
using namespace lldb_private;
@@ -179,9 +179,14 @@ TargetList::CreateTargetInternal (Debugger &debugger,
}
else
{
+ StreamString platform_arch_strm;
+ StreamString module_arch_strm;
+
+ platform_arch.DumpTriple(platform_arch_strm);
+ matching_module_spec.GetArchitecture().DumpTriple(module_arch_strm);
error.SetErrorStringWithFormat("the specified architecture '%s' is not compatible with '%s' in '%s'",
- platform_arch.GetTriple().str().c_str(),
- matching_module_spec.GetArchitecture().GetTriple().str().c_str(),
+ platform_arch_strm.GetString().c_str(),
+ module_arch_strm.GetString().c_str(),
module_spec.GetFileSpec().GetPath().c_str());
return error;
}
@@ -222,7 +227,7 @@ TargetList::CreateTargetInternal (Debugger &debugger,
// since the user may have specified it.
if (platform_sp)
{
- if (platform_sp->IsCompatibleArchitecture(module_spec.GetArchitecture(), false, NULL))
+ if (platform_sp->IsCompatibleArchitecture(module_spec.GetArchitecture(), false, nullptr))
{
platforms.push_back(platform_sp);
continue;
@@ -232,7 +237,7 @@ TargetList::CreateTargetInternal (Debugger &debugger,
// Next check the host platform it if wasn't already checked above
if (host_platform_sp && (!platform_sp || host_platform_sp->GetName() != platform_sp->GetName()))
{
- if (host_platform_sp->IsCompatibleArchitecture(module_spec.GetArchitecture(), false, NULL))
+ if (host_platform_sp->IsCompatibleArchitecture(module_spec.GetArchitecture(), false, nullptr))
{
platforms.push_back(host_platform_sp);
continue;
@@ -240,18 +245,24 @@ TargetList::CreateTargetInternal (Debugger &debugger,
}
// Just find a platform that matches the architecture in the executable file
- platforms.push_back(Platform::GetPlatformForArchitecture(module_spec.GetArchitecture(), nullptr));
+ PlatformSP fallback_platform_sp (Platform::GetPlatformForArchitecture(module_spec.GetArchitecture(), nullptr));
+ if (fallback_platform_sp)
+ {
+ platforms.push_back(fallback_platform_sp);
+ }
}
}
- Platform *platform_ptr = NULL;
+ Platform *platform_ptr = nullptr;
+ bool more_than_one_platforms = false;
for (const auto &the_platform_sp : platforms)
{
if (platform_ptr)
{
if (platform_ptr->GetName() != the_platform_sp->GetName())
{
- platform_ptr = NULL;
+ more_than_one_platforms = true;
+ platform_ptr = nullptr;
break;
}
}
@@ -266,6 +277,12 @@ TargetList::CreateTargetInternal (Debugger &debugger,
// All platforms for all modules in the exectuable match, so we can select this platform
platform_sp = platforms.front();
}
+ else if (more_than_one_platforms == false)
+ {
+ // No platforms claim to support this file
+ error.SetErrorString ("No matching platforms found for this file, specify one with the --platform option");
+ return error;
+ }
else
{
// More than one platform claims to support this file, so the --platform option must be specified
@@ -369,7 +386,6 @@ TargetList::CreateTargetInternal (Debugger &debugger,
lldb::TargetSP &target_sp,
bool is_dummy_target)
{
-
Timer scoped_timer (__PRETTY_FUNCTION__,
"TargetList::CreateTarget (file = '%s', arch = '%s')",
user_exe_path,
@@ -380,7 +396,7 @@ TargetList::CreateTargetInternal (Debugger &debugger,
if (arch.IsValid())
{
- if (!platform_sp || !platform_sp->IsCompatibleArchitecture(arch, false, NULL))
+ if (!platform_sp || !platform_sp->IsCompatibleArchitecture(arch, false, nullptr))
platform_sp = Platform::GetPlatformForArchitecture(specified_arch, &arch);
}
@@ -436,14 +452,14 @@ TargetList::CreateTargetInternal (Debugger &debugger,
{
FileSpecList executable_search_paths (Target::GetDefaultExecutableSearchPaths());
ModuleSpec module_spec(file, arch);
- error = platform_sp->ResolveExecutable (module_spec,
- exe_module_sp,
- executable_search_paths.GetSize() ? &executable_search_paths : NULL);
+ error = platform_sp->ResolveExecutable(module_spec,
+ exe_module_sp,
+ executable_search_paths.GetSize() ? &executable_search_paths : nullptr);
}
if (error.Success() && exe_module_sp)
{
- if (exe_module_sp->GetObjectFile() == NULL)
+ if (exe_module_sp->GetObjectFile() == nullptr)
{
if (arch.IsValid())
{
@@ -531,13 +547,9 @@ TargetList::DeleteTarget (TargetSP &target_sp)
return false;
}
-
TargetSP
-TargetList::FindTargetWithExecutableAndArchitecture
-(
- const FileSpec &exe_file_spec,
- const ArchSpec *exe_arch_ptr
-) const
+TargetList::FindTargetWithExecutableAndArchitecture(const FileSpec &exe_file_spec,
+ const ArchSpec *exe_arch_ptr) const
{
Mutex::Locker locker (m_target_list_mutex);
TargetSP target_sp;
@@ -583,7 +595,6 @@ TargetList::FindTargetWithProcessID (lldb::pid_t pid) const
return target_sp;
}
-
TargetSP
TargetList::FindTargetWithProcess (Process *process) const
{
@@ -632,7 +643,7 @@ TargetList::SendAsyncInterrupt (lldb::pid_t pid)
if (pid != LLDB_INVALID_PROCESS_ID)
{
TargetSP target_sp(FindTargetWithProcessID (pid));
- if (target_sp.get())
+ if (target_sp)
{
Process* process = target_sp->GetProcessSP().get();
if (process)
@@ -646,7 +657,7 @@ TargetList::SendAsyncInterrupt (lldb::pid_t pid)
{
// We don't have a valid pid to broadcast to, so broadcast to the target
// list's async broadcaster...
- BroadcastEvent (Process::eBroadcastBitInterrupt, NULL);
+ BroadcastEvent(Process::eBroadcastBitInterrupt, nullptr);
}
return num_async_interrupts_sent;
@@ -656,7 +667,7 @@ uint32_t
TargetList::SignalIfRunning (lldb::pid_t pid, int signo)
{
uint32_t num_signals_sent = 0;
- Process *process = NULL;
+ Process *process = nullptr;
if (pid == LLDB_INVALID_PROCESS_ID)
{
// Signal all processes with signal
@@ -679,7 +690,7 @@ TargetList::SignalIfRunning (lldb::pid_t pid, int signo)
{
// Signal a specific process with signal
TargetSP target_sp(FindTargetWithProcessID (pid));
- if (target_sp.get())
+ if (target_sp)
{
process = target_sp->GetProcessSP().get();
if (process)
diff --git a/source/Target/Thread.cpp b/source/Target/Thread.cpp
index 29ba86a7e84d5..9f9da97266050 100644
--- a/source/Target/Thread.cpp
+++ b/source/Target/Thread.cpp
@@ -7,14 +7,20 @@
//
//===----------------------------------------------------------------------===//
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
#include "lldb/Breakpoint/BreakpointLocation.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/Log.h"
#include "lldb/Core/FormatEntity.h"
+#include "lldb/Core/Module.h"
#include "lldb/Core/State.h"
#include "lldb/Core/Stream.h"
#include "lldb/Core/StreamString.h"
#include "lldb/Core/RegularExpression.h"
+#include "lldb/Core/ValueObject.h"
#include "lldb/Host/Host.h"
#include "lldb/Interpreter/OptionValueFileSpecList.h"
#include "lldb/Interpreter/OptionValueProperties.h"
@@ -23,7 +29,6 @@
#include "lldb/Target/ABI.h"
#include "lldb/Target/DynamicLoader.h"
#include "lldb/Target/ExecutionContext.h"
-#include "lldb/Target/ObjCLanguageRuntime.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/RegisterContext.h"
#include "lldb/Target/StopInfo.h"
@@ -47,11 +52,9 @@
#include "Plugins/Process/Utility/UnwindLLDB.h"
#include "Plugins/Process/Utility/UnwindMacOSXFrameBackchain.h"
-
using namespace lldb;
using namespace lldb_private;
-
const ThreadPropertiesSP &
Thread::GetGlobalProperties()
{
@@ -64,13 +67,13 @@ Thread::GetGlobalProperties()
static PropertyDefinition
g_properties[] =
{
- { "step-in-avoid-nodebug", OptionValue::eTypeBoolean, true, true, NULL, NULL, "If true, step-in will not stop in functions with no debug information." },
- { "step-out-avoid-nodebug", OptionValue::eTypeBoolean, true, false, NULL, NULL, "If true, when step-in/step-out/step-over leave the current frame, they will continue to step out till they come to a function with "
+ { "step-in-avoid-nodebug", OptionValue::eTypeBoolean, true, true, nullptr, nullptr, "If true, step-in will not stop in functions with no debug information." },
+ { "step-out-avoid-nodebug", OptionValue::eTypeBoolean, true, false, nullptr, nullptr, "If true, when step-in/step-out/step-over leave the current frame, they will continue to step out till they come to a function with "
"debug information. Passing a frame argument to step-out will override this option." },
- { "step-avoid-regexp", OptionValue::eTypeRegex , true , 0, "^std::", NULL, "A regular expression defining functions step-in won't stop in." },
- { "step-avoid-libraries", OptionValue::eTypeFileSpecList , true , 0, NULL, NULL, "A list of libraries that source stepping won't stop in." },
- { "trace-thread", OptionValue::eTypeBoolean, false, false, NULL, NULL, "If true, this thread will single-step and log execution." },
- { NULL , OptionValue::eTypeInvalid, false, 0 , NULL, NULL, NULL }
+ { "step-avoid-regexp", OptionValue::eTypeRegex , true , 0, "^std::", nullptr, "A regular expression defining functions step-in won't stop in." },
+ { "step-avoid-libraries", OptionValue::eTypeFileSpecList , true , 0, nullptr, nullptr, "A list of libraries that source stepping won't stop in." },
+ { "trace-thread", OptionValue::eTypeBoolean, false, false, nullptr, nullptr, "If true, this thread will single-step and log execution." },
+ { nullptr , OptionValue::eTypeInvalid, false, 0 , nullptr, nullptr, nullptr }
};
enum {
@@ -81,7 +84,6 @@ enum {
ePropertyEnableThreadTrace
};
-
class ThreadOptionValueProperties : public OptionValueProperties
{
public:
@@ -98,8 +100,8 @@ public:
{
}
- virtual const Property *
- GetPropertyAtIndex (const ExecutionContext *exe_ctx, bool will_modify, uint32_t idx) const
+ const Property *
+ GetPropertyAtIndex(const ExecutionContext *exe_ctx, bool will_modify, uint32_t idx) const override
{
// When getting the value for a key from the thread options, we will always
// try and grab the setting from the current thread if there is one. Else we just
@@ -118,8 +120,6 @@ public:
}
};
-
-
ThreadProperties::ThreadProperties (bool is_global) :
Properties ()
{
@@ -132,22 +132,20 @@ ThreadProperties::ThreadProperties (bool is_global) :
m_collection_sp.reset (new ThreadOptionValueProperties(Thread::GetGlobalProperties().get()));
}
-ThreadProperties::~ThreadProperties()
-{
-}
+ThreadProperties::~ThreadProperties() = default;
const RegularExpression *
ThreadProperties::GetSymbolsToAvoidRegexp()
{
const uint32_t idx = ePropertyStepAvoidRegex;
- return m_collection_sp->GetPropertyAtIndexAsOptionValueRegex (NULL, idx);
+ return m_collection_sp->GetPropertyAtIndexAsOptionValueRegex(nullptr, idx);
}
FileSpecList &
ThreadProperties::GetLibrariesToAvoid() const
{
const uint32_t idx = ePropertyStepAvoidLibraries;
- OptionValueFileSpecList *option_value = m_collection_sp->GetPropertyAtIndexAsOptionValueFileSpecList (NULL, false, idx);
+ OptionValueFileSpecList *option_value = m_collection_sp->GetPropertyAtIndexAsOptionValueFileSpecList(nullptr, false, idx);
assert(option_value);
return option_value->GetCurrentValue();
}
@@ -156,29 +154,27 @@ bool
ThreadProperties::GetTraceEnabledState() const
{
const uint32_t idx = ePropertyEnableThreadTrace;
- return m_collection_sp->GetPropertyAtIndexAsBoolean (NULL, idx, g_properties[idx].default_uint_value != 0);
+ return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx, g_properties[idx].default_uint_value != 0);
}
bool
ThreadProperties::GetStepInAvoidsNoDebug() const
{
const uint32_t idx = ePropertyStepInAvoidsNoDebug;
- return m_collection_sp->GetPropertyAtIndexAsBoolean (NULL, idx, g_properties[idx].default_uint_value != 0);
+ return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx, g_properties[idx].default_uint_value != 0);
}
bool
ThreadProperties::GetStepOutAvoidsNoDebug() const
{
const uint32_t idx = ePropertyStepOutAvoidsNoDebug;
- return m_collection_sp->GetPropertyAtIndexAsBoolean (NULL, idx, g_properties[idx].default_uint_value != 0);
+ return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx, g_properties[idx].default_uint_value != 0);
}
-
//------------------------------------------------------------------
// Thread Event Data
//------------------------------------------------------------------
-
const ConstString &
Thread::ThreadEventData::GetFlavorString ()
{
@@ -204,14 +200,11 @@ Thread::ThreadEventData::ThreadEventData () :
{
}
-Thread::ThreadEventData::~ThreadEventData ()
-{
-}
+Thread::ThreadEventData::~ThreadEventData() = default;
void
Thread::ThreadEventData::Dump (Stream *s) const
{
-
}
const Thread::ThreadEventData *
@@ -223,7 +216,7 @@ Thread::ThreadEventData::GetEventDataFromEvent (const Event *event_ptr)
if (event_data && event_data->GetFlavor() == ThreadEventData::GetFlavorString())
return static_cast <const ThreadEventData *> (event_ptr->GetData());
}
- return NULL;
+ return nullptr;
}
ThreadSP
@@ -308,7 +301,6 @@ Thread::Thread (Process &process, lldb::tid_t tid, bool use_invalid_index_id) :
QueueFundamentalPlan(true);
}
-
Thread::~Thread()
{
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT));
@@ -360,12 +352,22 @@ Thread::BroadcastSelectedFrameChange(StackID &new_frame_id)
BroadcastEvent(eBroadcastBitSelectedFrameChanged, new ThreadEventData (this->shared_from_this(), new_frame_id));
}
+lldb::StackFrameSP
+Thread::GetSelectedFrame()
+{
+ StackFrameListSP stack_frame_list_sp(GetStackFrameList());
+ StackFrameSP frame_sp = stack_frame_list_sp->GetFrameAtIndex (stack_frame_list_sp->GetSelectedFrameIndex());
+ FunctionOptimizationWarning (frame_sp.get());
+ return frame_sp;
+}
+
uint32_t
Thread::SetSelectedFrame (lldb_private::StackFrame *frame, bool broadcast)
{
uint32_t ret_value = GetStackFrameList()->SetSelectedFrame(frame);
if (broadcast)
BroadcastSelectedFrameChange(frame->GetStackID());
+ FunctionOptimizationWarning (frame);
return ret_value;
}
@@ -378,6 +380,7 @@ Thread::SetSelectedFrameByIndex (uint32_t frame_idx, bool broadcast)
GetStackFrameList()->SetSelectedFrame(frame_sp.get());
if (broadcast)
BroadcastSelectedFrameChange(frame_sp->GetStackID());
+ FunctionOptimizationWarning (frame_sp.get());
return true;
}
else
@@ -403,6 +406,7 @@ Thread::SetSelectedFrameByIndexNoisily (uint32_t frame_idx, Stream &output_strea
bool show_frame_info = true;
bool show_source = !already_shown;
+ FunctionOptimizationWarning (frame_sp.get());
return frame_sp->GetStatus (output_stream, show_frame_info, show_source);
}
return false;
@@ -411,6 +415,15 @@ Thread::SetSelectedFrameByIndexNoisily (uint32_t frame_idx, Stream &output_strea
return false;
}
+void
+Thread::FunctionOptimizationWarning (StackFrame *frame)
+{
+ if (frame && frame->HasDebugInformation() && GetProcess()->GetWarningsOptimization())
+ {
+ SymbolContext sc = frame->GetSymbolContext (eSymbolContextFunction | eSymbolContextModule);
+ GetProcess()->PrintWarningOptimization (sc);
+ }
+}
lldb::StopInfoSP
Thread::GetStopInfo ()
@@ -464,7 +477,7 @@ Thread::GetPrivateStopInfo ()
if (!m_stop_info_sp)
{
- if (CalculateStopInfo() == false)
+ if (!CalculateStopInfo())
SetStopInfo (StopInfoSP());
}
}
@@ -490,7 +503,6 @@ Thread::GetPrivateStopInfo ()
return m_stop_info_sp;
}
-
lldb::StopReason
Thread::GetStopReason()
{
@@ -500,7 +512,15 @@ Thread::GetStopReason()
return eStopReasonNone;
}
-
+bool
+Thread::StopInfoIsUpToDate() const
+{
+ ProcessSP process_sp (GetProcess());
+ if (process_sp)
+ return m_stop_info_stop_id == process_sp->GetStopID();
+ else
+ return true; // Process is no longer around so stop info is always up to date...
+}
void
Thread::SetStopInfo (const lldb::StopInfoSP &stop_info_sp)
@@ -650,7 +670,6 @@ Thread::SetupForResume ()
{
if (GetResumeState() != eStateSuspended)
{
-
// If we're at a breakpoint push the step-over breakpoint plan. Do this before
// telling the current plan it will resume, since we might change what the current
// plan is.
@@ -707,14 +726,17 @@ Thread::ShouldResume (StateType resume_state)
m_discarded_plan_stack.clear();
m_override_should_notify = eLazyBoolCalculate;
- m_temporary_resume_state = resume_state;
+ StateType prev_resume_state = GetTemporaryResumeState();
+
+ SetTemporaryResumeState(resume_state);
lldb::ThreadSP backing_thread_sp (GetBackingThread ());
if (backing_thread_sp)
- backing_thread_sp->m_temporary_resume_state = resume_state;
+ backing_thread_sp->SetTemporaryResumeState(resume_state);
- // Make sure m_stop_info_sp is valid
- GetPrivateStopInfo();
+ // Make sure m_stop_info_sp is valid. Don't do this for threads we suspended in the previous run.
+ if (prev_resume_state != eStateSuspended)
+ GetPrivateStopInfo();
// This is a little dubious, but we are trying to limit how often we actually fetch stop info from
// the target, 'cause that slows down single stepping. So assume that if we got to the point where
@@ -739,7 +761,7 @@ Thread::ShouldResume (StateType resume_state)
{
need_to_resume = plan_ptr->WillResume(resume_state, true);
- while ((plan_ptr = GetPreviousPlan(plan_ptr)) != NULL)
+ while ((plan_ptr = GetPreviousPlan(plan_ptr)) != nullptr)
{
plan_ptr->WillResume (resume_state, false);
}
@@ -804,7 +826,7 @@ Thread::ShouldStop (Event* event_ptr)
// thread caused the process to stop. NOTE: this must take place before
// the plan is moved from the current plan stack to the completed plan
// stack.
- if (ThreadStoppedForAReason() == false)
+ if (!ThreadStoppedForAReason())
{
if (log)
log->Printf ("Thread::%s for tid = 0x%4.4" PRIx64 " 0x%4.4" PRIx64 ", pc = 0x%16.16" PRIx64 ", should_stop = 0 (ignore since no stop reason)",
@@ -835,7 +857,7 @@ Thread::ShouldStop (Event* event_ptr)
// command on internal breakpoints. If a synchronous stop reason says we should not stop, then we don't have to
// do any more work on this stop.
StopInfoSP private_stop_info (GetPrivateStopInfo());
- if (private_stop_info && private_stop_info->ShouldStopSynchronous(event_ptr) == false)
+ if (private_stop_info && !private_stop_info->ShouldStopSynchronous(event_ptr))
{
if (log)
log->Printf ("StopInfo::ShouldStop async callback says we should not stop, returning ShouldStop of false.");
@@ -868,7 +890,7 @@ Thread::ShouldStop (Event* event_ptr)
// If the current plan doesn't explain the stop, then find one that
// does and let it handle the situation.
ThreadPlan *plan_ptr = current_plan;
- while ((plan_ptr = GetPreviousPlan(plan_ptr)) != NULL)
+ while ((plan_ptr = GetPreviousPlan(plan_ptr)) != nullptr)
{
if (plan_ptr->PlanExplainsStop(event_ptr))
{
@@ -891,17 +913,13 @@ Thread::ShouldStop (Event* event_ptr)
while ((current_plan = GetCurrentPlan()) != prev_plan_ptr);
// Now, if the responsible plan was not "Okay to discard" then we're done,
// otherwise we forward this to the next plan in the stack below.
- if (plan_ptr->IsMasterPlan() && !plan_ptr->OkayToDiscard())
- done_processing_current_plan = true;
- else
- done_processing_current_plan = false;
+ done_processing_current_plan = (plan_ptr->IsMasterPlan() && !plan_ptr->OkayToDiscard());
}
else
done_processing_current_plan = true;
break;
}
-
}
}
}
@@ -949,11 +967,10 @@ Thread::ShouldStop (Event* event_ptr)
}
else
{
-
PopPlan();
current_plan = GetCurrentPlan();
- if (current_plan == NULL)
+ if (current_plan == nullptr)
{
break;
}
@@ -968,7 +985,6 @@ Thread::ShouldStop (Event* event_ptr)
if (over_ride_stop)
should_stop = false;
-
}
// One other potential problem is that we set up a master plan, then stop in before it is complete - for instance
@@ -1103,10 +1119,7 @@ Thread::ShouldReportRun (Event* event_ptr)
bool
Thread::MatchesSpec (const ThreadSpec *spec)
{
- if (spec == NULL)
- return true;
-
- return spec->ThreadPassesBasicTests(*this);
+ return (spec == nullptr) ? true : spec->ThreadPassesBasicTests(*this);
}
void
@@ -1174,9 +1187,7 @@ Thread::GetCurrentPlan ()
{
// There will always be at least the base plan. If somebody is mucking with a
// thread with an empty plan stack, we should assert right away.
- if (m_plan_stack.empty())
- return NULL;
- return m_plan_stack.back().get();
+ return m_plan_stack.empty() ? nullptr : m_plan_stack.back().get();
}
ThreadPlanSP
@@ -1212,20 +1223,20 @@ Thread::GetReturnValueObject ()
return ValueObjectSP();
}
-ClangExpressionVariableSP
+ExpressionVariableSP
Thread::GetExpressionVariable ()
{
if (!m_completed_plan_stack.empty())
{
for (int i = m_completed_plan_stack.size() - 1; i >= 0; i--)
{
- ClangExpressionVariableSP expression_variable_sp;
+ ExpressionVariableSP expression_variable_sp;
expression_variable_sp = m_completed_plan_stack[i]->GetExpressionVariable();
if (expression_variable_sp)
return expression_variable_sp;
}
}
- return ClangExpressionVariableSP();
+ return ExpressionVariableSP();
}
bool
@@ -1259,8 +1270,8 @@ Thread::WasThreadPlanDiscarded (ThreadPlan *plan)
ThreadPlan *
Thread::GetPreviousPlan (ThreadPlan *current_plan)
{
- if (current_plan == NULL)
- return NULL;
+ if (current_plan == nullptr)
+ return nullptr;
int stack_size = m_completed_plan_stack.size();
for (int i = stack_size - 1; i > 0; i--)
@@ -1271,10 +1282,7 @@ Thread::GetPreviousPlan (ThreadPlan *current_plan)
if (stack_size > 0 && m_completed_plan_stack[0].get() == current_plan)
{
- if (m_plan_stack.size() > 0)
- return m_plan_stack.back().get();
- else
- return NULL;
+ return GetCurrentPlan();
}
stack_size = m_plan_stack.size();
@@ -1283,7 +1291,7 @@ Thread::GetPreviousPlan (ThreadPlan *current_plan)
if (current_plan == m_plan_stack[i].get())
return m_plan_stack[i-1].get();
}
- return NULL;
+ return nullptr;
}
void
@@ -1295,7 +1303,6 @@ Thread::QueueThreadPlan (ThreadPlanSP &thread_plan_sp, bool abort_other_plans)
PushPlan (thread_plan_sp);
}
-
void
Thread::EnableTracer (bool value, bool single_stepping)
{
@@ -1346,7 +1353,6 @@ Thread::DiscardUserThreadPlansUpToIndex (uint32_t thread_index)
DiscardThreadPlansUpToPlan(up_to_plan_ptr);
return true;
}
-
void
Thread::DiscardThreadPlansUpToPlan (lldb::ThreadPlanSP &up_to_plan_sp)
@@ -1364,10 +1370,10 @@ Thread::DiscardThreadPlansUpToPlan (ThreadPlan *up_to_plan_ptr)
int stack_size = m_plan_stack.size();
- // If the input plan is NULL, discard all plans. Otherwise make sure this plan is in the
+ // If the input plan is nullptr, discard all plans. Otherwise make sure this plan is in the
// stack, and if so discard up to and including it.
- if (up_to_plan_ptr == NULL)
+ if (up_to_plan_ptr == nullptr)
{
for (int i = stack_size - 1; i > 0; i--)
DiscardPlan();
@@ -1391,7 +1397,6 @@ Thread::DiscardThreadPlansUpToPlan (ThreadPlan *up_to_plan_ptr)
}
}
}
- return;
}
void
@@ -1415,7 +1420,6 @@ Thread::DiscardThreadPlans(bool force)
while (1)
{
-
int master_plan_idx;
bool discard = true;
@@ -1434,7 +1438,6 @@ Thread::DiscardThreadPlans(bool force)
// First pop all the dependent plans:
for (int i = m_plan_stack.size() - 1; i > master_plan_idx; i--)
{
-
// FIXME: Do we need a finalize here, or is the rule that "PrepareForStop"
// for the plan leaves it in a state that it is safe to pop the plan
// with no more notice?
@@ -1454,7 +1457,6 @@ Thread::DiscardThreadPlans(bool force)
// If the master plan doesn't want to get discarded, then we're done.
break;
}
-
}
}
@@ -1475,7 +1477,7 @@ Thread::UnwindInnermostExpression()
Error error;
int stack_size = m_plan_stack.size();
- // If the input plan is NULL, discard all plans. Otherwise make sure this plan is in the
+ // If the input plan is nullptr, discard all plans. Otherwise make sure this plan is in the
// stack, and if so discard up to and including it.
for (int i = stack_size - 1; i > 0; i--)
@@ -1490,7 +1492,6 @@ Thread::UnwindInnermostExpression()
return error;
}
-
ThreadPlanSP
Thread::QueueFundamentalPlan (bool abort_other_plans)
{
@@ -1500,12 +1501,9 @@ Thread::QueueFundamentalPlan (bool abort_other_plans)
}
ThreadPlanSP
-Thread::QueueThreadPlanForStepSingleInstruction
-(
- bool step_over,
- bool abort_other_plans,
- bool stop_other_threads
-)
+Thread::QueueThreadPlanForStepSingleInstruction(bool step_over,
+ bool abort_other_plans,
+ bool stop_other_threads)
{
ThreadPlanSP thread_plan_sp (new ThreadPlanStepInstruction (*this, step_over, stop_other_threads, eVoteNoOpinion, eVoteNoOpinion));
QueueThreadPlan (thread_plan_sp, abort_other_plans);
@@ -1513,14 +1511,11 @@ Thread::QueueThreadPlanForStepSingleInstruction
}
ThreadPlanSP
-Thread::QueueThreadPlanForStepOverRange
-(
- bool abort_other_plans,
- const AddressRange &range,
- const SymbolContext &addr_context,
- lldb::RunMode stop_other_threads,
- LazyBool step_out_avoids_code_withoug_debug_info
-)
+Thread::QueueThreadPlanForStepOverRange(bool abort_other_plans,
+ const AddressRange &range,
+ const SymbolContext &addr_context,
+ lldb::RunMode stop_other_threads,
+ LazyBool step_out_avoids_code_withoug_debug_info)
{
ThreadPlanSP thread_plan_sp;
thread_plan_sp.reset (new ThreadPlanStepOverRange (*this, range, addr_context, stop_other_threads, step_out_avoids_code_withoug_debug_info));
@@ -1529,17 +1524,29 @@ Thread::QueueThreadPlanForStepOverRange
return thread_plan_sp;
}
+// Call the QueueThreadPlanForStepOverRange method which takes an address range.
ThreadPlanSP
-Thread::QueueThreadPlanForStepInRange
-(
- bool abort_other_plans,
- const AddressRange &range,
- const SymbolContext &addr_context,
- const char *step_in_target,
- lldb::RunMode stop_other_threads,
- LazyBool step_in_avoids_code_without_debug_info,
- LazyBool step_out_avoids_code_without_debug_info
-)
+Thread::QueueThreadPlanForStepOverRange(bool abort_other_plans,
+ const LineEntry &line_entry,
+ const SymbolContext &addr_context,
+ lldb::RunMode stop_other_threads,
+ LazyBool step_out_avoids_code_withoug_debug_info)
+{
+ return QueueThreadPlanForStepOverRange (abort_other_plans,
+ line_entry.GetSameLineContiguousAddressRange(),
+ addr_context,
+ stop_other_threads,
+ step_out_avoids_code_withoug_debug_info);
+}
+
+ThreadPlanSP
+Thread::QueueThreadPlanForStepInRange(bool abort_other_plans,
+ const AddressRange &range,
+ const SymbolContext &addr_context,
+ const char *step_in_target,
+ lldb::RunMode stop_other_threads,
+ LazyBool step_in_avoids_code_without_debug_info,
+ LazyBool step_out_avoids_code_without_debug_info)
{
ThreadPlanSP thread_plan_sp (new ThreadPlanStepInRange (*this,
range,
@@ -1556,19 +1563,35 @@ Thread::QueueThreadPlanForStepInRange
return thread_plan_sp;
}
+// Call the QueueThreadPlanForStepInRange method which takes an address range.
+ThreadPlanSP
+Thread::QueueThreadPlanForStepInRange(bool abort_other_plans,
+ const LineEntry &line_entry,
+ const SymbolContext &addr_context,
+ const char *step_in_target,
+ lldb::RunMode stop_other_threads,
+ LazyBool step_in_avoids_code_without_debug_info,
+ LazyBool step_out_avoids_code_without_debug_info)
+{
+ return QueueThreadPlanForStepInRange (abort_other_plans,
+ line_entry.GetSameLineContiguousAddressRange(),
+ addr_context,
+ step_in_target,
+ stop_other_threads,
+ step_in_avoids_code_without_debug_info,
+ step_out_avoids_code_without_debug_info);
+}
+
ThreadPlanSP
-Thread::QueueThreadPlanForStepOut
-(
- bool abort_other_plans,
- SymbolContext *addr_context,
- bool first_insn,
- bool stop_other_threads,
- Vote stop_vote,
- Vote run_vote,
- uint32_t frame_idx,
- LazyBool step_out_avoids_code_withoug_debug_info
-)
+Thread::QueueThreadPlanForStepOut(bool abort_other_plans,
+ SymbolContext *addr_context,
+ bool first_insn,
+ bool stop_other_threads,
+ Vote stop_vote,
+ Vote run_vote,
+ uint32_t frame_idx,
+ LazyBool step_out_avoids_code_withoug_debug_info)
{
ThreadPlanSP thread_plan_sp (new ThreadPlanStepOut (*this,
addr_context,
@@ -1579,7 +1602,7 @@ Thread::QueueThreadPlanForStepOut
frame_idx,
step_out_avoids_code_withoug_debug_info));
- if (thread_plan_sp->ValidatePlan(NULL))
+ if (thread_plan_sp->ValidatePlan(nullptr))
{
QueueThreadPlan (thread_plan_sp, abort_other_plans);
return thread_plan_sp;
@@ -1591,16 +1614,13 @@ Thread::QueueThreadPlanForStepOut
}
ThreadPlanSP
-Thread::QueueThreadPlanForStepOutNoShouldStop
-(
- bool abort_other_plans,
- SymbolContext *addr_context,
- bool first_insn,
- bool stop_other_threads,
- Vote stop_vote,
- Vote run_vote,
- uint32_t frame_idx
-)
+Thread::QueueThreadPlanForStepOutNoShouldStop(bool abort_other_plans,
+ SymbolContext *addr_context,
+ bool first_insn,
+ bool stop_other_threads,
+ Vote stop_vote,
+ Vote run_vote,
+ uint32_t frame_idx)
{
ThreadPlanSP thread_plan_sp(new ThreadPlanStepOut (*this,
addr_context,
@@ -1614,7 +1634,7 @@ Thread::QueueThreadPlanForStepOutNoShouldStop
ThreadPlanStepOut *new_plan = static_cast<ThreadPlanStepOut *>(thread_plan_sp.get());
new_plan->ClearShouldStopHereCallbacks();
- if (thread_plan_sp->ValidatePlan(NULL))
+ if (thread_plan_sp->ValidatePlan(nullptr))
{
QueueThreadPlan (thread_plan_sp, abort_other_plans);
return thread_plan_sp;
@@ -1629,7 +1649,7 @@ ThreadPlanSP
Thread::QueueThreadPlanForStepThrough (StackID &return_stack_id, bool abort_other_plans, bool stop_other_threads)
{
ThreadPlanSP thread_plan_sp(new ThreadPlanStepThrough (*this, return_stack_id, stop_other_threads));
- if (!thread_plan_sp || !thread_plan_sp->ValidatePlan (NULL))
+ if (!thread_plan_sp || !thread_plan_sp->ValidatePlan(nullptr))
return ThreadPlanSP();
QueueThreadPlan (thread_plan_sp, abort_other_plans);
@@ -1677,7 +1697,6 @@ Thread::QueueThreadPlanForStepScripted (bool abort_other_plans,
}
else
return thread_plan_sp;
-
}
uint32_t
@@ -1768,7 +1787,6 @@ Thread::CalculateTarget ()
if (process_sp)
target_sp = process_sp->CalculateTarget();
return target_sp;
-
}
ProcessSP
@@ -1795,7 +1813,6 @@ Thread::CalculateExecutionContext (ExecutionContext &exe_ctx)
exe_ctx.SetContext (shared_from_this());
}
-
StackFrameListSP
Thread::GetStackFrameList ()
{
@@ -1839,7 +1856,6 @@ Thread::GetFrameWithConcreteFrameIndex (uint32_t unwind_idx)
return GetStackFrameList()->GetFrameWithConcreteFrameIndex (unwind_idx);
}
-
Error
Thread::ReturnFromFrameWithIndex (uint32_t frame_idx, lldb::ValueObjectSP return_value_sp, bool broadcast)
{
@@ -1886,12 +1902,12 @@ Thread::ReturnFromFrame (lldb::StackFrameSP frame_sp, lldb::ValueObjectSP return
// 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 != NULL)
+ if (/* DISABLES CODE */ (0) && sc.function != nullptr)
{
Type *function_type = sc.function->GetType();
if (function_type)
{
- ClangASTType return_type = sc.function->GetClangType().GetFunctionReturnType();
+ CompilerType return_type = sc.function->GetCompilerType().GetFunctionReturnType();
if (return_type)
{
StreamString s;
@@ -2024,7 +2040,7 @@ Thread::DumpUsingSettingsFormat (Stream &strm, uint32_t frame_idx)
{
ExecutionContext exe_ctx (shared_from_this());
Process *process = exe_ctx.GetProcessPtr();
- if (process == NULL)
+ if (process == nullptr)
return;
StackFrameSP frame_sp;
@@ -2044,10 +2060,10 @@ Thread::DumpUsingSettingsFormat (Stream &strm, uint32_t frame_idx)
FormatEntity::Format(*thread_format,
strm,
- frame_sp ? &frame_sc : NULL,
+ frame_sp ? &frame_sc : nullptr,
&exe_ctx,
- NULL,
- NULL,
+ nullptr,
+ nullptr,
false,
false);
}
@@ -2119,7 +2135,6 @@ Thread::StopReasonAsCString (lldb::StopReason reason)
case eStopReasonInstrumentation: return "instrumentation break";
}
-
static char unknown_state_string[64];
snprintf(unknown_state_string, sizeof (unknown_state_string), "StopReason = %i", reason);
return unknown_state_string;
@@ -2176,7 +2191,7 @@ Thread::GetStatus (Stream &strm, uint32_t start_frame, uint32_t num_frames, uint
const bool show_frame_info = true;
- const char *selected_frame_marker = NULL;
+ const char *selected_frame_marker = nullptr;
if (num_frames == 1 || (GetID() != GetProcess()->GetThreadList().GetSelectedThread()->GetID()))
strm.IndentMore ();
else
@@ -2302,7 +2317,7 @@ Thread::GetStackFrameStatus (Stream& strm,
Unwind *
Thread::GetUnwinder ()
{
- if (m_unwinder_ap.get() == NULL)
+ if (!m_unwinder_ap)
{
const ArchSpec target_arch (CalculateTarget()->GetArchitecture ());
const llvm::Triple::ArchType machine = target_arch.GetMachine();
@@ -2332,7 +2347,6 @@ Thread::GetUnwinder ()
return m_unwinder_ap.get();
}
-
void
Thread::Flush ()
{
@@ -2364,7 +2378,6 @@ Thread::IsStillAtLastBreakpointHit ()
return false;
}
-
Error
Thread::StepIn (bool source_step,
LazyBool step_in_avoids_code_without_debug_info,
@@ -2383,13 +2396,13 @@ Thread::StepIn (bool source_step,
if (source_step && frame_sp && frame_sp->HasDebugInformation ())
{
SymbolContext sc(frame_sp->GetSymbolContext(eSymbolContextEverything));
- new_plan_sp = QueueThreadPlanForStepInRange (abort_other_plans,
- sc.line_entry.range,
- sc,
- NULL,
- run_mode,
- step_in_avoids_code_without_debug_info,
- step_out_avoids_code_without_debug_info);
+ new_plan_sp = QueueThreadPlanForStepInRange(abort_other_plans,
+ sc.line_entry,
+ sc,
+ nullptr,
+ run_mode,
+ step_in_avoids_code_without_debug_info,
+ step_out_avoids_code_without_debug_info);
}
else
{
@@ -2430,7 +2443,7 @@ Thread::StepOver (bool source_step,
{
SymbolContext sc(frame_sp->GetSymbolContext(eSymbolContextEverything));
new_plan_sp = QueueThreadPlanForStepOverRange (abort_other_plans,
- sc.line_entry.range,
+ sc.line_entry,
sc,
run_mode,
step_out_avoids_code_without_debug_info);
@@ -2467,13 +2480,13 @@ Thread::StepOut ()
const bool stop_other_threads = false;
const bool abort_other_plans = false;
- ThreadPlanSP new_plan_sp(QueueThreadPlanForStepOut (abort_other_plans,
- NULL,
- first_instruction,
- stop_other_threads,
- eVoteYes,
- eVoteNoOpinion,
- 0));
+ ThreadPlanSP new_plan_sp(QueueThreadPlanForStepOut(abort_other_plans,
+ nullptr,
+ first_instruction,
+ stop_other_threads,
+ eVoteYes,
+ eVoteNoOpinion,
+ 0));
new_plan_sp->SetIsMasterPlan(true);
new_plan_sp->SetOkayToDiscard(false);
diff --git a/source/Target/ThreadList.cpp b/source/Target/ThreadList.cpp
index d581a7c96060f..a34cb0fa143ad 100644
--- a/source/Target/ThreadList.cpp
+++ b/source/Target/ThreadList.cpp
@@ -6,10 +6,15 @@
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
+
+// C Includes
#include <stdlib.h>
+// C++ Includes
#include <algorithm>
+// Other libraries and framework includes
+// Project includes
#include "lldb/Core/Log.h"
#include "lldb/Core/State.h"
#include "lldb/Target/RegisterContext.h"
@@ -18,6 +23,7 @@
#include "lldb/Target/ThreadPlan.h"
#include "lldb/Target/Process.h"
#include "lldb/Utility/ConvertEnum.h"
+#include "lldb/Utility/LLDBAssert.h"
using namespace lldb;
using namespace lldb_private;
@@ -46,7 +52,7 @@ ThreadList::operator = (const ThreadList& rhs)
if (this != &rhs)
{
// Lock both mutexes to make sure neither side changes anyone on us
- // while the assignement occurs
+ // while the assignment occurs
Mutex::Locker locker(GetMutex());
m_process = rhs.m_process;
m_stop_id = rhs.m_stop_id;
@@ -257,7 +263,24 @@ ThreadList::ShouldStop (Event *event_ptr)
Mutex::Locker locker(GetMutex());
m_process->UpdateThreadListIfNeeded();
- threads_copy = m_threads;
+ for (lldb::ThreadSP thread_sp : m_threads)
+ {
+ // This is an optimization... If we didn't let a thread run in between the previous stop and this
+ // one, we shouldn't have to consult it for ShouldStop. So just leave it off the list we are going to
+ // inspect.
+ // On Linux, if a thread-specific conditional breakpoint was hit, it won't necessarily be the thread
+ // that hit the breakpoint itself that evaluates the conditional expression, so the thread that hit
+ // the breakpoint could still be asked to stop, even though it hasn't been allowed to run since the
+ // previous stop.
+ if (thread_sp->GetTemporaryResumeState () != eStateSuspended || thread_sp->IsStillAtLastBreakpointHit())
+ threads_copy.push_back(thread_sp);
+ }
+
+ // It is possible the threads we were allowing to run all exited and then maybe the user interrupted
+ // or something, then fall back on looking at all threads:
+
+ if (threads_copy.size() == 0)
+ threads_copy = m_threads;
}
collection::iterator pos, end = threads_copy.end();
@@ -265,7 +288,10 @@ ThreadList::ShouldStop (Event *event_ptr)
if (log)
{
log->PutCString("");
- log->Printf ("ThreadList::%s: %" PRIu64 " threads", __FUNCTION__, (uint64_t)m_threads.size());
+ log->Printf ("ThreadList::%s: %" PRIu64 " threads, %" PRIu64 " unsuspended threads",
+ __FUNCTION__,
+ (uint64_t)m_threads.size(),
+ (uint64_t)threads_copy.size());
}
bool did_anybody_stop_for_a_reason = false;
@@ -518,6 +544,7 @@ ThreadList::WillResume ()
for (pos = m_threads.begin(); pos != end; ++pos)
{
+ lldbassert((*pos)->GetCurrentPlan() && "thread should not have null thread plan");
if ((*pos)->GetResumeState() != eStateSuspended &&
(*pos)->GetCurrentPlan()->StopOthers())
{
@@ -750,7 +777,7 @@ ThreadList::Update (ThreadList &rhs)
if (this != &rhs)
{
// Lock both mutexes to make sure neither side changes anyone on us
- // while the assignement occurs
+ // while the assignment occurs
Mutex::Locker locker(GetMutex());
m_process = rhs.m_process;
m_stop_id = rhs.m_stop_id;
@@ -773,7 +800,8 @@ ThreadList::Update (ThreadList &rhs)
const uint32_t num_threads = m_threads.size();
for (uint32_t idx = 0; idx < num_threads; ++idx)
{
- if (m_threads[idx]->GetID() == tid)
+ ThreadSP backing_thread = m_threads[idx]->GetBackingThread();
+ if (m_threads[idx]->GetID() == tid || (backing_thread && backing_thread->GetID() == tid))
{
thread_is_alive = true;
break;
diff --git a/source/Target/ThreadPlan.cpp b/source/Target/ThreadPlan.cpp
index 094a6bff3722f..24323337accbf 100644
--- a/source/Target/ThreadPlan.cpp
+++ b/source/Target/ThreadPlan.cpp
@@ -7,12 +7,11 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/Target/ThreadPlan.h"
-
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
+#include "lldb/Target/ThreadPlan.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/Log.h"
#include "lldb/Core/State.h"
@@ -48,9 +47,7 @@ ThreadPlan::ThreadPlan(ThreadPlanKind kind, const char *name, Thread &thread, Vo
//----------------------------------------------------------------------
// Destructor
//----------------------------------------------------------------------
-ThreadPlan::~ThreadPlan()
-{
-}
+ThreadPlan::~ThreadPlan() = default;
bool
ThreadPlan::PlanExplainsStop (Event *event_ptr)
@@ -130,10 +127,7 @@ ThreadPlan::StopOthers ()
{
ThreadPlan *prev_plan;
prev_plan = GetPreviousPlan ();
- if (prev_plan == NULL)
- return false;
- else
- return prev_plan->StopOthers();
+ return (prev_plan == nullptr) ? false : prev_plan->StopOthers();
}
void
@@ -191,10 +185,7 @@ ThreadPlan::WillPop()
bool
ThreadPlan::OkayToDiscard()
{
- if (!IsMasterPlan())
- return true;
- else
- return m_okay_to_discard;
+ return IsMasterPlan() ? m_okay_to_discard : true;
}
lldb::StateType
@@ -206,6 +197,23 @@ ThreadPlan::RunState ()
return GetPlanRunState();
}
+bool
+ThreadPlan::IsUsuallyUnexplainedStopReason(lldb::StopReason reason)
+{
+ switch (reason)
+ {
+ case eStopReasonWatchpoint:
+ case eStopReasonSignal:
+ case eStopReasonException:
+ case eStopReasonExec:
+ case eStopReasonThreadExiting:
+ case eStopReasonInstrumentation:
+ return true;
+ default:
+ return false;
+ }
+}
+
//----------------------------------------------------------------------
// ThreadPlanNull
//----------------------------------------------------------------------
@@ -219,9 +227,7 @@ ThreadPlanNull::ThreadPlanNull (Thread &thread) :
{
}
-ThreadPlanNull::~ThreadPlanNull ()
-{
-}
+ThreadPlanNull::~ThreadPlanNull() = default;
void
ThreadPlanNull::GetDescription (Stream *s,
diff --git a/source/Target/ThreadPlanCallFunction.cpp b/source/Target/ThreadPlanCallFunction.cpp
index e7b3abd3c9412..01ca1267dd92b 100644
--- a/source/Target/ThreadPlanCallFunction.cpp
+++ b/source/Target/ThreadPlanCallFunction.cpp
@@ -7,13 +7,11 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/Target/ThreadPlanCallFunction.h"
-
// C Includes
// C++ Includes
// Other libraries and framework includes
-
// Project includes
+#include "lldb/Target/ThreadPlanCallFunction.h"
#include "lldb/Breakpoint/Breakpoint.h"
#include "lldb/Breakpoint/BreakpointLocation.h"
#include "lldb/Core/Address.h"
@@ -76,7 +74,7 @@ ThreadPlanCallFunction::ConstructorSetup (Thread &thread,
Module *exe_module = GetTarget().GetExecutableModulePointer();
- if (exe_module == NULL)
+ if (exe_module == nullptr)
{
m_constructor_errors.Printf ("Can't execute code without an executable module.");
if (log)
@@ -135,7 +133,7 @@ ThreadPlanCallFunction::ConstructorSetup (Thread &thread,
ThreadPlanCallFunction::ThreadPlanCallFunction (Thread &thread,
const Address &function,
- const ClangASTType &return_type,
+ const CompilerType &return_type,
llvm::ArrayRef<addr_t> args,
const EvaluateExpressionOptions &options) :
ThreadPlan (ThreadPlan::eKindCallFunction, "Call function plan", thread, eVoteNoOpinion, eVoteNoOpinion),
@@ -188,9 +186,8 @@ ThreadPlanCallFunction::ThreadPlanCallFunction(Thread &thread,
m_should_clear_objc_exception_bp(false),
m_should_clear_cxx_exception_bp(false),
m_stop_address(LLDB_INVALID_ADDRESS),
- m_return_type(ClangASTType())
+ m_return_type(CompilerType())
{
-
}
ThreadPlanCallFunction::~ThreadPlanCallFunction ()
@@ -263,7 +260,6 @@ ThreadPlanCallFunction::DoTakedown (bool success)
ClearBreakpoints();
if (log && log->GetVerbose())
ReportRegisterState ("Restoring thread state after function call. Restored register state:");
-
}
else
{
@@ -312,7 +308,6 @@ ThreadPlanCallFunction::ValidatePlan (Stream *error)
return true;
}
-
Vote
ThreadPlanCallFunction::ShouldReportStop(Event *event_ptr)
{
@@ -330,7 +325,7 @@ ThreadPlanCallFunction::DoPlanExplainsStop (Event *event_ptr)
// If our subplan knows why we stopped, even if it's done (which would forward the question to us)
// we answer yes.
- if (m_subplan_sp.get() != NULL && m_subplan_sp->PlanExplainsStop(event_ptr))
+ if (m_subplan_sp && m_subplan_sp->PlanExplainsStop(event_ptr))
{
SetPlanComplete();
return true;
@@ -360,8 +355,7 @@ ThreadPlanCallFunction::DoPlanExplainsStop (Event *event_ptr)
// We control breakpoints separately from other "stop reasons." So first,
// check the case where we stopped for an internal breakpoint, in that case, continue on.
// If it is not an internal breakpoint, consult m_ignore_breakpoints.
-
-
+
if (stop_reason == eStopReasonBreakpoint)
{
ProcessSP process_sp (m_thread.CalculateProcess());
@@ -426,15 +420,7 @@ ThreadPlanCallFunction::DoPlanExplainsStop (Event *event_ptr)
if (m_real_stop_info_sp && m_real_stop_info_sp->ShouldStopSynchronous(event_ptr))
{
SetPlanComplete(false);
- if (m_subplan_sp)
- {
- if (m_unwind_on_error)
- return true;
- else
- return false;
- }
- else
- return false;
+ return m_subplan_sp ? m_unwind_on_error : false;
}
else
return true;
@@ -583,19 +569,17 @@ ThreadPlanCallFunction::SetStopOthers (bool new_value)
m_subplan_sp->SetStopOthers(new_value);
}
-
bool
ThreadPlanCallFunction::RestoreThreadState()
{
return GetThread().RestoreThreadStateFromCheckpoint(m_stored_thread_state);
}
-
void
ThreadPlanCallFunction::SetReturnValue()
{
ProcessSP process_sp(m_thread.GetProcess());
- const ABI *abi = process_sp ? process_sp->GetABI().get() : NULL;
+ const ABI *abi = process_sp ? process_sp->GetABI().get() : nullptr;
if (abi && m_return_type.IsValid())
{
const bool persistent = false;
diff --git a/source/Target/ThreadPlanCallFunctionUsingABI.cpp b/source/Target/ThreadPlanCallFunctionUsingABI.cpp
index 53fabd2464e68..df23edc0fd14a 100644
--- a/source/Target/ThreadPlanCallFunctionUsingABI.cpp
+++ b/source/Target/ThreadPlanCallFunctionUsingABI.cpp
@@ -1,4 +1,4 @@
-//===-- ThreadPlanCallFunctionUsingABI.cpp ------------------------------*- C++ -*-===//
+//===-- ThreadPlanCallFunctionUsingABI.cpp ----------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -7,13 +7,11 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/Target/ThreadPlanCallFunctionUsingABI.h"
-
// C Includes
// C++ Includes
// Other libraries and framework includes
-
// Project includes
+#include "lldb/Target/ThreadPlanCallFunctionUsingABI.h"
#include "lldb/Core/Address.h"
#include "lldb/Core/Log.h"
#include "lldb/Core/Stream.h"
@@ -57,10 +55,7 @@ ThreadPlanCallFunctionUsingABI::ThreadPlanCallFunctionUsingABI (Thread &thread,
m_valid = true;
}
-ThreadPlanCallFunctionUsingABI::~ThreadPlanCallFunctionUsingABI()
-{
-
-}
+ThreadPlanCallFunctionUsingABI::~ThreadPlanCallFunctionUsingABI() = default;
void
ThreadPlanCallFunctionUsingABI::GetDescription(Stream *s, DescriptionLevel level)
@@ -80,7 +75,7 @@ void
ThreadPlanCallFunctionUsingABI::SetReturnValue()
{
ProcessSP process_sp(m_thread.GetProcess());
- const ABI *abi = process_sp ? process_sp->GetABI().get() : NULL;
+ const ABI *abi = process_sp ? process_sp->GetABI().get() : nullptr;
// Ask the abi for the return value
if (abi)
diff --git a/source/Target/ThreadPlanCallUserExpression.cpp b/source/Target/ThreadPlanCallUserExpression.cpp
index 1773777cc4dac..b24f74b10dfa5 100644
--- a/source/Target/ThreadPlanCallUserExpression.cpp
+++ b/source/Target/ThreadPlanCallUserExpression.cpp
@@ -19,7 +19,7 @@
#include "lldb/Core/Address.h"
#include "lldb/Core/Log.h"
#include "lldb/Core/Stream.h"
-#include "lldb/Expression/ClangUserExpression.h"
+#include "lldb/Expression/UserExpression.h"
#include "lldb/Expression/IRDynamicChecks.h"
#include "lldb/Host/HostInfo.h"
#include "lldb/Target/LanguageRuntime.h"
@@ -41,8 +41,8 @@ ThreadPlanCallUserExpression::ThreadPlanCallUserExpression (Thread &thread,
Address &function,
llvm::ArrayRef<lldb::addr_t> args,
const EvaluateExpressionOptions &options,
- lldb::ClangUserExpressionSP &user_expression_sp) :
- ThreadPlanCallFunction (thread, function, ClangASTType(), args, options),
+ lldb::UserExpressionSP &user_expression_sp) :
+ ThreadPlanCallFunction (thread, function, CompilerType(), args, options),
m_user_expression_sp (user_expression_sp)
{
// User expressions are generally "User generated" so we should set them up to stop when done.
diff --git a/source/Target/ThreadPlanRunToAddress.cpp b/source/Target/ThreadPlanRunToAddress.cpp
index 54ae1dc22981c..18c43dafd7b37 100644
--- a/source/Target/ThreadPlanRunToAddress.cpp
+++ b/source/Target/ThreadPlanRunToAddress.cpp
@@ -7,12 +7,11 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/Target/ThreadPlanRunToAddress.h"
-
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
+#include "lldb/Target/ThreadPlanRunToAddress.h"
#include "lldb/Core/Log.h"
#include "lldb/Core/Stream.h"
#include "lldb/Target/Target.h"
@@ -88,7 +87,7 @@ ThreadPlanRunToAddress::SetInitialBreakpoints ()
{
Breakpoint *breakpoint;
breakpoint = m_thread.CalculateTarget()->CreateBreakpoint (m_addresses[i], true, false).get();
- if (breakpoint != NULL)
+ if (breakpoint != nullptr)
{
m_break_ids[i] = breakpoint->GetID();
breakpoint->SetThreadID(m_thread.GetID());
@@ -195,7 +194,7 @@ ThreadPlanRunToAddress::DoPlanExplainsStop (Event *event_ptr)
bool
ThreadPlanRunToAddress::ShouldStop (Event *event_ptr)
{
- return false;
+ return AtOurAddress();
}
bool
diff --git a/source/Target/ThreadPlanShouldStopHere.cpp b/source/Target/ThreadPlanShouldStopHere.cpp
index e89f5d2bde1bd..88f8db2bd7e7a 100644
--- a/source/Target/ThreadPlanShouldStopHere.cpp
+++ b/source/Target/ThreadPlanShouldStopHere.cpp
@@ -7,6 +7,10 @@
//
//===----------------------------------------------------------------------===//
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
#include "lldb/Target/RegisterContext.h"
#include "lldb/Target/Thread.h"
#include "lldb/Target/ThreadPlanShouldStopHere.h"
@@ -15,19 +19,14 @@
using namespace lldb;
using namespace lldb_private;
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
-
//----------------------------------------------------------------------
// ThreadPlanShouldStopHere constructor
//----------------------------------------------------------------------
ThreadPlanShouldStopHere::ThreadPlanShouldStopHere(ThreadPlan *owner) :
- m_callbacks (),
- m_baton (NULL),
- m_owner (owner),
- m_flags (ThreadPlanShouldStopHere::eNone)
+ m_callbacks(),
+ m_baton(nullptr),
+ m_owner(owner),
+ m_flags(ThreadPlanShouldStopHere::eNone)
{
m_callbacks.should_stop_here_callback = ThreadPlanShouldStopHere::DefaultShouldStopHereCallback;
m_callbacks.step_from_here_callback = ThreadPlanShouldStopHere::DefaultStepFromHereCallback;
@@ -42,12 +41,7 @@ ThreadPlanShouldStopHere::ThreadPlanShouldStopHere(ThreadPlan *owner, const Thre
SetShouldStopHereCallbacks(callbacks, baton);
}
-//----------------------------------------------------------------------
-// Destructor
-//----------------------------------------------------------------------
-ThreadPlanShouldStopHere::~ThreadPlanShouldStopHere()
-{
-}
+ThreadPlanShouldStopHere::~ThreadPlanShouldStopHere() = default;
bool
ThreadPlanShouldStopHere::InvokeShouldStopHereCallback (FrameComparison operation)
@@ -135,13 +129,13 @@ ThreadPlanShouldStopHere::DefaultStepFromHereCallback (ThreadPlan *current_plan,
}
if (!return_plan_sp)
- return_plan_sp = current_plan->GetThread().QueueThreadPlanForStepOutNoShouldStop (false,
- NULL,
- true,
- stop_others,
- eVoteNo,
- eVoteNoOpinion,
- frame_index);
+ return_plan_sp = current_plan->GetThread().QueueThreadPlanForStepOutNoShouldStop(false,
+ nullptr,
+ true,
+ stop_others,
+ eVoteNo,
+ eVoteNoOpinion,
+ frame_index);
return return_plan_sp;
}
@@ -154,7 +148,6 @@ ThreadPlanShouldStopHere::QueueStepOutFromHerePlan(lldb_private::Flags &flags, l
return_plan_sp = m_callbacks.step_from_here_callback (m_owner, flags, operation, m_baton);
}
return return_plan_sp;
-
}
lldb::ThreadPlanSP
@@ -165,4 +158,3 @@ ThreadPlanShouldStopHere::CheckShouldStopHereAndQueueStepOut (lldb::FrameCompari
else
return ThreadPlanSP();
}
-
diff --git a/source/Target/ThreadPlanStepInRange.cpp b/source/Target/ThreadPlanStepInRange.cpp
index 3ee57928b1db6..3771e210c1a42 100644
--- a/source/Target/ThreadPlanStepInRange.cpp
+++ b/source/Target/ThreadPlanStepInRange.cpp
@@ -7,12 +7,11 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/Target/ThreadPlanStepInRange.h"
-
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
+#include "lldb/Target/ThreadPlanStepInRange.h"
#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/Stream.h"
@@ -76,9 +75,7 @@ ThreadPlanStepInRange::ThreadPlanStepInRange
SetupAvoidNoDebug(step_in_avoids_code_without_debug_info, step_out_avoids_code_without_debug_info);
}
-ThreadPlanStepInRange::~ThreadPlanStepInRange ()
-{
-}
+ThreadPlanStepInRange::~ThreadPlanStepInRange() = default;
void
ThreadPlanStepInRange::SetupAvoidNoDebug(LazyBool step_in_avoids_code_without_debug_info,
@@ -193,11 +190,7 @@ ThreadPlanStepInRange::ShouldStop (Event *event_ptr)
// Stepping through should be done running other threads in general, since we're setting a breakpoint and
// continuing. So only stop others if we are explicitly told to do so.
- bool stop_others;
- if (m_stop_others == lldb::eOnlyThisThread)
- stop_others = true;
- else
- stop_others = false;
+ bool stop_others = (m_stop_others == lldb::eOnlyThisThread);
FrameComparison frame_order = CompareCurrentFrameToStartFrame();
@@ -220,7 +213,6 @@ ThreadPlanStepInRange::ShouldStop (Event *event_ptr)
{
log->Printf("Thought I stepped out, but in fact arrived at a trampoline.");
}
-
}
else if (frame_order == eFrameCompareEqual && InSymbol())
{
@@ -322,7 +314,7 @@ ThreadPlanStepInRange::ShouldStop (Event *event_ptr)
void
ThreadPlanStepInRange::SetAvoidRegexp(const char *name)
{
- if (m_avoid_regexp_ap.get() == NULL)
+ if (!m_avoid_regexp_ap)
m_avoid_regexp_ap.reset (new RegularExpression(name));
m_avoid_regexp_ap->Compile (name);
@@ -367,15 +359,15 @@ ThreadPlanStepInRange::FrameMatchesAvoidCriteria ()
return true;
const RegularExpression *avoid_regexp_to_use = m_avoid_regexp_ap.get();
- if (avoid_regexp_to_use == NULL)
+ if (avoid_regexp_to_use == nullptr)
avoid_regexp_to_use = GetThread().GetSymbolsToAvoidRegexp();
- if (avoid_regexp_to_use != NULL)
+ if (avoid_regexp_to_use != nullptr)
{
SymbolContext sc = frame->GetSymbolContext(eSymbolContextFunction|eSymbolContextBlock|eSymbolContextSymbol);
- if (sc.symbol != NULL)
+ if (sc.symbol != nullptr)
{
- const char *frame_function_name = sc.GetFunctionName().GetCString();
+ const char *frame_function_name = sc.GetFunctionName(Mangled::ePreferDemangledWithoutArguments).GetCString();
if (frame_function_name)
{
size_t num_matches = 0;
@@ -424,7 +416,7 @@ ThreadPlanStepInRange::DefaultShouldStopHereCallback (ThreadPlan *current_plan,
if (step_in_range_plan->m_step_into_target)
{
SymbolContext sc = frame->GetSymbolContext(eSymbolContextFunction|eSymbolContextBlock|eSymbolContextSymbol);
- if (sc.symbol != NULL)
+ if (sc.symbol != nullptr)
{
// First try an exact match, since that's cheap with ConstStrings. Then do a strstr compare.
if (step_in_range_plan->m_step_into_target == sc.GetFunctionName())
@@ -436,9 +428,9 @@ ThreadPlanStepInRange::DefaultShouldStopHereCallback (ThreadPlan *current_plan,
const char *target_name = step_in_range_plan->m_step_into_target.AsCString();
const char *function_name = sc.GetFunctionName().AsCString();
- if (function_name == NULL)
+ if (function_name == nullptr)
should_stop_here = false;
- else if (strstr (function_name, target_name) == NULL)
+ else if (strstr(function_name, target_name) == nullptr)
should_stop_here = false;
}
if (log && !should_stop_here)
@@ -476,7 +468,7 @@ ThreadPlanStepInRange::DoPlanExplainsStop (Event *event_ptr)
// The only variation is that if we are doing "step by running to next branch" in which case
// if we hit our branch breakpoint we don't set the plan to complete.
- bool return_value;
+ bool return_value = false;
if (m_virtual_step)
{
@@ -488,30 +480,24 @@ ThreadPlanStepInRange::DoPlanExplainsStop (Event *event_ptr)
if (stop_info_sp)
{
StopReason reason = stop_info_sp->GetStopReason();
-
- switch (reason)
+
+ if (reason == eStopReasonBreakpoint)
{
- case eStopReasonBreakpoint:
if (NextRangeBreakpointExplainsStop(stop_info_sp))
{
return_value = true;
- break;
- }
- case eStopReasonWatchpoint:
- case eStopReasonSignal:
- case eStopReasonException:
- case eStopReasonExec:
- case eStopReasonThreadExiting:
- {
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
- if (log)
- log->PutCString ("ThreadPlanStepInRange got asked if it explains the stop for some reason other than step.");
}
+ }
+ else if (IsUsuallyUnexplainedStopReason(reason))
+ {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
+ if (log)
+ log->PutCString ("ThreadPlanStepInRange got asked if it explains the stop for some reason other than step.");
return_value = false;
- break;
- default:
+ }
+ else
+ {
return_value = true;
- break;
}
}
else
@@ -549,5 +535,5 @@ ThreadPlanStepInRange::DoWillResume (lldb::StateType resume_state, bool current_
bool
ThreadPlanStepInRange::IsVirtualStep()
{
- return m_virtual_step;
+ return m_virtual_step;
}
diff --git a/source/Target/ThreadPlanStepInstruction.cpp b/source/Target/ThreadPlanStepInstruction.cpp
index 1ce26df78fe63..9d7d52167ffcb 100644
--- a/source/Target/ThreadPlanStepInstruction.cpp
+++ b/source/Target/ThreadPlanStepInstruction.cpp
@@ -7,13 +7,11 @@
//
//===----------------------------------------------------------------------===//
-
-#include "lldb/Target/ThreadPlanStepInstruction.h"
-
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
+#include "lldb/Target/ThreadPlanStepInstruction.h"
#include "lldb/Core/Log.h"
#include "lldb/Core/Stream.h"
#include "lldb/Target/Process.h"
@@ -46,9 +44,7 @@ ThreadPlanStepInstruction::ThreadPlanStepInstruction
SetUpState();
}
-ThreadPlanStepInstruction::~ThreadPlanStepInstruction ()
-{
-}
+ThreadPlanStepInstruction::~ThreadPlanStepInstruction() = default;
void
ThreadPlanStepInstruction::SetUpState()
@@ -57,7 +53,7 @@ ThreadPlanStepInstruction::SetUpState()
StackFrameSP start_frame_sp(m_thread.GetStackFrameAtIndex(0));
m_stack_id = start_frame_sp->GetStackID();
- m_start_has_symbol = start_frame_sp->GetSymbolContext(eSymbolContextSymbol).symbol != NULL;
+ m_start_has_symbol = start_frame_sp->GetSymbolContext(eSymbolContextSymbol).symbol != nullptr;
StackFrameSP parent_frame_sp = m_thread.GetStackFrameAtIndex(1);
if (parent_frame_sp)
@@ -103,10 +99,7 @@ ThreadPlanStepInstruction::DoPlanExplainsStop (Event *event_ptr)
if (stop_info_sp)
{
StopReason reason = stop_info_sp->GetStopReason();
- if (reason == eStopReasonTrace || reason == eStopReasonNone)
- return true;
- else
- return false;
+ return (reason == eStopReasonTrace || reason == eStopReasonNone);
}
return false;
}
@@ -118,19 +111,13 @@ ThreadPlanStepInstruction::IsPlanStale ()
StackID cur_frame_id = m_thread.GetStackFrameAtIndex(0)->GetStackID();
if (cur_frame_id == m_stack_id)
{
- if (m_thread.GetRegisterContext()->GetPC(0) != m_instruction_addr)
- return true;
- else
- return false;
+ return (m_thread.GetRegisterContext()->GetPC(0) != m_instruction_addr);
}
else if (cur_frame_id < m_stack_id)
{
// If the current frame is younger than the start frame and we are stepping over, then we need to continue,
// but if we are doing just one step, we're done.
- if (m_step_over)
- return false;
- else
- return true;
+ return !m_step_over;
}
else
{
@@ -222,7 +209,7 @@ ThreadPlanStepInstruction::ShouldStop (Event *event_ptr)
// run others.
const bool stop_others = false;
m_thread.QueueThreadPlanForStepOutNoShouldStop(false,
- NULL,
+ nullptr,
true,
stop_others,
eVoteNo,
@@ -248,9 +235,7 @@ ThreadPlanStepInstruction::ShouldStop (Event *event_ptr)
SetPlanComplete();
return true;
}
-
}
-
}
else
{
@@ -308,4 +293,3 @@ ThreadPlanStepInstruction::MischiefManaged ()
return false;
}
}
-
diff --git a/source/Target/ThreadPlanStepOut.cpp b/source/Target/ThreadPlanStepOut.cpp
index 8b702a20ccd23..92403cb92ed34 100644
--- a/source/Target/ThreadPlanStepOut.cpp
+++ b/source/Target/ThreadPlanStepOut.cpp
@@ -7,12 +7,11 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/Target/ThreadPlanStepOut.h"
-
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
+#include "lldb/Target/ThreadPlanStepOut.h"
#include "lldb/Breakpoint/Breakpoint.h"
#include "lldb/Core/Log.h"
#include "lldb/Core/Value.h"
@@ -53,7 +52,7 @@ ThreadPlanStepOut::ThreadPlanStepOut
m_return_bp_id (LLDB_INVALID_BREAK_ID),
m_return_addr (LLDB_INVALID_ADDRESS),
m_stop_others (stop_others),
- m_immediate_step_from_function(NULL)
+ m_immediate_step_from_function(nullptr)
{
SetFlagsToDefault();
SetupAvoidNoDebug(step_out_avoids_code_without_debug_info);
@@ -80,14 +79,14 @@ ThreadPlanStepOut::ThreadPlanStepOut
{
// 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_thread,
- NULL,
- false,
- stop_others,
- eVoteNoOpinion,
- eVoteNoOpinion,
- frame_idx - 1,
- eLazyBoolNo));
+ m_step_out_to_inline_plan_sp.reset(new ThreadPlanStepOut(m_thread,
+ nullptr,
+ false,
+ stop_others,
+ eVoteNoOpinion,
+ eVoteNoOpinion,
+ frame_idx - 1,
+ eLazyBoolNo));
static_cast<ThreadPlanStepOut *>(m_step_out_to_inline_plan_sp.get())->SetShouldStopHereCallbacks(nullptr, nullptr);
m_step_out_to_inline_plan_sp->SetPrivate(true);
}
@@ -96,7 +95,6 @@ ThreadPlanStepOut::ThreadPlanStepOut
// If we're already at the inlined frame we're stepping through, then just do that now.
QueueInlinedStepPlan(false);
}
-
}
else if (return_frame_sp)
{
@@ -109,7 +107,7 @@ ThreadPlanStepOut::ThreadPlanStepOut
return;
Breakpoint *return_bp = m_thread.CalculateTarget()->CreateBreakpoint (m_return_addr, true, false).get();
- if (return_bp != NULL)
+ if (return_bp != nullptr)
{
return_bp->SetThreadID(m_thread.GetID());
m_return_bp_id = return_bp->GetID();
@@ -125,7 +123,6 @@ ThreadPlanStepOut::ThreadPlanStepOut
}
}
}
-
}
void
@@ -192,7 +189,7 @@ ThreadPlanStepOut::GetDescription (Stream *s, lldb::DescriptionLevel level)
// FIXME: find some useful way to present the m_return_id, since there may be multiple copies of the
// same function on the stack.
- s->Printf ("returning to frame at ");
+ s->Printf (" returning to frame at ");
if (tmp_address.SetLoadAddress (m_return_addr, &GetTarget()))
{
tmp_address.Dump(s, &GetThread(), Address::DumpStyleResolvedDescription, Address::DumpStyleLoadAddress);
@@ -231,10 +228,7 @@ ThreadPlanStepOut::DoPlanExplainsStop (Event *event_ptr)
// If the step out plan is done, then we just need to step through the inlined frame.
if (m_step_out_to_inline_plan_sp)
{
- if (m_step_out_to_inline_plan_sp->MischiefManaged())
- return true;
- else
- return false;
+ return m_step_out_to_inline_plan_sp->MischiefManaged();
}
else if (m_step_through_inline_plan_sp)
{
@@ -249,10 +243,7 @@ ThreadPlanStepOut::DoPlanExplainsStop (Event *event_ptr)
}
else if (m_step_out_further_plan_sp)
{
- if (m_step_out_further_plan_sp->MischiefManaged())
- return true;
- else
- return false;
+ return m_step_out_further_plan_sp->MischiefManaged();
}
// We don't explain signals or breakpoints (breakpoints that handle stepping in or
@@ -262,9 +253,7 @@ ThreadPlanStepOut::DoPlanExplainsStop (Event *event_ptr)
if (stop_info_sp)
{
StopReason reason = stop_info_sp->GetStopReason();
- switch (reason)
- {
- case eStopReasonBreakpoint:
+ if (reason == eStopReasonBreakpoint)
{
// If this is OUR breakpoint, we're fine, otherwise we don't know why this happened...
BreakpointSiteSP site_sp (m_thread.GetProcess()->GetBreakpointSiteList().FindByID (stop_info_sp->GetValue()));
@@ -284,10 +273,7 @@ ThreadPlanStepOut::DoPlanExplainsStop (Event *event_ptr)
}
else
{
- if (m_immediate_step_from_id < frame_zero_id)
- done = true;
- else
- done = false;
+ done = (m_immediate_step_from_id < frame_zero_id);
}
if (done)
@@ -306,20 +292,13 @@ ThreadPlanStepOut::DoPlanExplainsStop (Event *event_ptr)
if (site_sp->GetNumberOfOwners() == 1)
return true;
-
}
return false;
}
- case eStopReasonWatchpoint:
- case eStopReasonSignal:
- case eStopReasonException:
- case eStopReasonExec:
- case eStopReasonThreadExiting:
+ else if (IsUsuallyUnexplainedStopReason(reason))
return false;
-
- default:
+ else
return true;
- }
}
return true;
}
@@ -367,10 +346,7 @@ ThreadPlanStepOut::ShouldStop (Event *event_ptr)
if (!done)
{
StackID frame_zero_id = m_thread.GetStackFrameAtIndex(0)->GetStackID();
- if (frame_zero_id < m_step_out_to_id)
- done = false;
- else
- done = true;
+ done = !(frame_zero_id < m_step_out_to_id);
}
// The normal step out computations think we are done, so all we need to do is consult the ShouldStopHere,
@@ -417,7 +393,7 @@ ThreadPlanStepOut::DoWillResume (StateType resume_state, bool current_plan)
if (current_plan)
{
Breakpoint *return_bp = m_thread.CalculateTarget()->GetBreakpointByID(m_return_bp_id).get();
- if (return_bp != NULL)
+ if (return_bp != nullptr)
return_bp->SetEnabled (true);
}
return true;
@@ -429,7 +405,7 @@ ThreadPlanStepOut::WillStop ()
if (m_return_bp_id != LLDB_INVALID_BREAK_ID)
{
Breakpoint *return_bp = m_thread.CalculateTarget()->GetBreakpointByID(m_return_bp_id).get();
- if (return_bp != NULL)
+ if (return_bp != nullptr)
return_bp->SetEnabled (false);
}
@@ -539,14 +515,14 @@ ThreadPlanStepOut::CalculateReturnValue ()
if (m_return_valobj_sp)
return;
- if (m_immediate_step_from_function != NULL)
+ if (m_immediate_step_from_function != nullptr)
{
- ClangASTType return_clang_type = m_immediate_step_from_function->GetClangType().GetFunctionReturnType();
- if (return_clang_type)
+ CompilerType return_compiler_type = m_immediate_step_from_function->GetCompilerType().GetFunctionReturnType();
+ if (return_compiler_type)
{
lldb::ABISP abi_sp = m_thread.GetProcess()->GetABI();
if (abi_sp)
- m_return_valobj_sp = abi_sp->GetReturnValueObject(m_thread, return_clang_type);
+ m_return_valobj_sp = abi_sp->GetReturnValueObject(m_thread, return_compiler_type);
}
}
}
@@ -558,8 +534,5 @@ ThreadPlanStepOut::IsPlanStale()
// there's something for us to do. Otherwise, we're stale.
StackID frame_zero_id = m_thread.GetStackFrameAtIndex(0)->GetStackID();
- if (frame_zero_id < m_step_out_to_id)
- return false;
- else
- return true;
+ return !(frame_zero_id < m_step_out_to_id);
}
diff --git a/source/Target/ThreadPlanStepOverRange.cpp b/source/Target/ThreadPlanStepOverRange.cpp
index aba89224239cf..08655be24395b 100644
--- a/source/Target/ThreadPlanStepOverRange.cpp
+++ b/source/Target/ThreadPlanStepOverRange.cpp
@@ -7,12 +7,11 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/Target/ThreadPlanStepOverRange.h"
-
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
+#include "lldb/Target/ThreadPlanStepOverRange.h"
#include "lldb/Core/Log.h"
#include "lldb/Core/Stream.h"
#include "lldb/Symbol/Block.h"
@@ -52,9 +51,7 @@ ThreadPlanStepOverRange::ThreadPlanStepOverRange
SetupAvoidNoDebug(step_out_avoids_code_without_debug_info);
}
-ThreadPlanStepOverRange::~ThreadPlanStepOverRange ()
-{
-}
+ThreadPlanStepOverRange::~ThreadPlanStepOverRange() = default;
void
ThreadPlanStepOverRange::GetDescription (Stream *s, lldb::DescriptionLevel level)
@@ -111,7 +108,6 @@ ThreadPlanStepOverRange::SetupAvoidNoDebug(LazyBool step_out_avoids_code_without
bool
ThreadPlanStepOverRange::IsEquivalentContext(const SymbolContext &context)
{
-
// Match as much as is specified in the m_addr_context:
// This is a fairly loose sanity check. Note, sometimes the target doesn't get filled
// in so I left out the target check. And sometimes the module comes in as the .o file from the
@@ -150,14 +146,8 @@ ThreadPlanStepOverRange::ShouldStop (Event *event_ptr)
// If we're out of the range but in the same frame or in our caller's frame
// then we should stop.
// When stepping out we only stop others if we are forcing running one thread.
- bool stop_others;
- if (m_stop_others == lldb::eOnlyThisThread)
- stop_others = true;
- else
- stop_others = false;
-
+ bool stop_others = (m_stop_others == lldb::eOnlyThisThread);
ThreadPlanSP new_plan_sp;
-
FrameComparison frame_order = CompareCurrentFrameToStartFrame();
if (frame_order == eFrameCompareOlder)
@@ -189,13 +179,13 @@ ThreadPlanStepOverRange::ShouldStop (Event *event_ptr)
const SymbolContext &older_context = older_frame_sp->GetSymbolContext(eSymbolContextEverything);
if (IsEquivalentContext(older_context))
{
- new_plan_sp = m_thread.QueueThreadPlanForStepOutNoShouldStop (false,
- NULL,
- true,
- stop_others,
- eVoteNo,
- eVoteNoOpinion,
- 0);
+ new_plan_sp = m_thread.QueueThreadPlanForStepOutNoShouldStop(false,
+ nullptr,
+ true,
+ stop_others,
+ eVoteNo,
+ eVoteNoOpinion,
+ 0);
break;
}
else
@@ -216,7 +206,6 @@ ThreadPlanStepOverRange::ShouldStop (Event *event_ptr)
return false;
}
-
if (!InSymbol())
{
// This one is a little tricky. Sometimes we may be in a stub or something similar,
@@ -283,7 +272,6 @@ ThreadPlanStepOverRange::ShouldStop (Event *event_ptr)
step_past_remaining_inline = true;
}
-
}
}
}
@@ -303,10 +291,14 @@ ThreadPlanStepOverRange::ShouldStop (Event *event_ptr)
if (next_line_entry.file == m_addr_context.line_entry.file)
{
const bool abort_other_plans = false;
- const bool stop_other_threads = false;
- new_plan_sp = m_thread.QueueThreadPlanForRunToAddress(abort_other_plans,
- next_line_address,
- stop_other_threads);
+ const RunMode stop_other_threads = RunMode::eAllThreads;
+ lldb::addr_t cur_pc = m_thread.GetStackFrameAtIndex(0)->GetRegisterContext()->GetPC();
+ AddressRange step_range(cur_pc, next_line_address.GetLoadAddress(&GetTarget()) - cur_pc);
+
+ new_plan_sp = m_thread.QueueThreadPlanForStepOverRange (abort_other_plans,
+ step_range,
+ sc,
+ stop_other_threads);
break;
}
look_ahead_step++;
@@ -368,27 +360,19 @@ ThreadPlanStepOverRange::DoPlanExplainsStop (Event *event_ptr)
{
StopReason reason = stop_info_sp->GetStopReason();
- switch (reason)
+ if (reason == eStopReasonTrace)
{
- case eStopReasonTrace:
return_value = true;
- break;
- case eStopReasonBreakpoint:
- if (NextRangeBreakpointExplainsStop(stop_info_sp))
- return_value = true;
- else
- return_value = false;
- break;
- case eStopReasonWatchpoint:
- case eStopReasonSignal:
- case eStopReasonException:
- case eStopReasonExec:
- case eStopReasonThreadExiting:
- default:
+ }
+ else if (reason == eStopReasonBreakpoint)
+ {
+ return_value = NextRangeBreakpointExplainsStop(stop_info_sp);
+ }
+ else
+ {
if (log)
log->PutCString ("ThreadPlanStepInRange got asked if it explains the stop for some reason other than step.");
return_value = false;
- break;
}
}
else
@@ -447,4 +431,3 @@ ThreadPlanStepOverRange::DoWillResume (lldb::StateType resume_state, bool curren
return true;
}
-
diff --git a/source/Target/ThreadPlanStepRange.cpp b/source/Target/ThreadPlanStepRange.cpp
index 3aed85859507a..02667f8236ea2 100644
--- a/source/Target/ThreadPlanStepRange.cpp
+++ b/source/Target/ThreadPlanStepRange.cpp
@@ -7,12 +7,11 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/Target/ThreadPlanStepRange.h"
-
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
+#include "lldb/Target/ThreadPlanStepRange.h"
#include "lldb/Breakpoint/BreakpointLocation.h"
#include "lldb/Breakpoint/BreakpointSite.h"
#include "lldb/Core/Disassembler.h"
@@ -31,7 +30,6 @@
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.
@@ -127,7 +125,7 @@ ThreadPlanStepRange::DumpRanges(Stream *s)
{
for (size_t i = 0; i < num_ranges; i++)
{
- s->PutCString("%d: ");
+ s->Printf(" %" PRIu64 ": ", uint64_t(i));
m_address_ranges[i].Dump (s, m_thread.CalculateTarget().get(), Address::DumpStyleLoadAddress);
}
}
@@ -162,7 +160,7 @@ ThreadPlanStepRange::InRange ()
if (m_addr_context.line_entry.line == new_context.line_entry.line)
{
m_addr_context = new_context;
- AddRange(m_addr_context.line_entry.range);
+ AddRange(m_addr_context.line_entry.GetSameLineContiguousAddressRange());
ret_value = true;
if (log)
{
@@ -181,7 +179,7 @@ ThreadPlanStepRange::InRange ()
{
new_context.line_entry.line = m_addr_context.line_entry.line;
m_addr_context = new_context;
- AddRange(m_addr_context.line_entry.range);
+ AddRange(m_addr_context.line_entry.GetSameLineContiguousAddressRange());
ret_value = true;
if (log)
{
@@ -221,12 +219,9 @@ ThreadPlanStepRange::InRange ()
new_context.line_entry.line,
s.GetData());
}
-
}
}
-
}
-
}
if (!ret_value && log)
@@ -239,7 +234,7 @@ bool
ThreadPlanStepRange::InSymbol()
{
lldb::addr_t cur_pc = m_thread.GetRegisterContext()->GetPC();
- if (m_addr_context.function != NULL)
+ if (m_addr_context.function != nullptr)
{
return m_addr_context.function->GetAddressRange().ContainsLoadAddress (cur_pc, m_thread.CalculateTarget().get());
}
@@ -291,11 +286,7 @@ ThreadPlanStepRange::CompareCurrentFrameToStartFrame()
bool
ThreadPlanStepRange::StopOthers ()
{
- if (m_stop_others == lldb::eOnlyThisThread
- || m_stop_others == lldb::eOnlyDuringStepping)
- return true;
- else
- return false;
+ return (m_stop_others == lldb::eOnlyThisThread || m_stop_others == lldb::eOnlyDuringStepping);
}
InstructionList *
@@ -308,14 +299,14 @@ ThreadPlanStepRange::GetInstructionsForAddress(lldb::addr_t addr, size_t &range_
{
// Some joker added a zero size range to the stepping range...
if (m_address_ranges[i].GetByteSize() == 0)
- return NULL;
+ return nullptr;
if (!m_instruction_ranges[i])
{
//Disassemble the address range given:
ExecutionContext exe_ctx (m_thread.GetProcess());
- const char *plugin_name = NULL;
- const char *flavor = NULL;
+ const char *plugin_name = nullptr;
+ const char *flavor = nullptr;
const bool prefer_file_cache = true;
m_instruction_ranges[i] = Disassembler::DisassembleRange(GetTarget().GetArchitecture(),
plugin_name,
@@ -323,18 +314,17 @@ ThreadPlanStepRange::GetInstructionsForAddress(lldb::addr_t addr, size_t &range_
exe_ctx,
m_address_ranges[i],
prefer_file_cache);
-
}
if (!m_instruction_ranges[i])
- return NULL;
+ return nullptr;
else
{
// Find where we are in the instruction list as well. If we aren't at an instruction,
- // return NULL. In this case, we're probably lost, and shouldn't try to do anything fancy.
+ // return nullptr. In this case, we're probably lost, and shouldn't try to do anything fancy.
insn_offset = m_instruction_ranges[i]->GetInstructionList().GetIndexOfInstructionAtLoadAddress(addr, GetTarget());
if (insn_offset == UINT32_MAX)
- return NULL;
+ return nullptr;
else
{
range_index = i;
@@ -343,7 +333,7 @@ ThreadPlanStepRange::GetInstructionsForAddress(lldb::addr_t addr, size_t &range_
}
}
}
- return NULL;
+ return nullptr;
}
void
@@ -376,7 +366,7 @@ ThreadPlanStepRange::SetNextBranchBreakpoint ()
size_t pc_index;
size_t range_index;
InstructionList *instructions = GetInstructionsForAddress (cur_addr, range_index, pc_index);
- if (instructions == NULL)
+ if (instructions == nullptr)
return false;
else
{
@@ -389,13 +379,23 @@ ThreadPlanStepRange::SetNextBranchBreakpoint ()
// If we didn't find a branch, run to the end of the range.
if (branch_index == UINT32_MAX)
{
- branch_index = instructions->GetSize() - 1;
+ uint32_t last_index = instructions->GetSize() - 1;
+ if (last_index - pc_index > 1)
+ {
+ InstructionSP last_inst = instructions->GetInstructionAtIndex(last_index);
+ size_t last_inst_size = last_inst->GetOpcode().GetByteSize();
+ run_to_address = last_inst->GetAddress();
+ run_to_address.Slide(last_inst_size);
+ }
+ }
+ else if (branch_index - pc_index > 1)
+ {
+ run_to_address = instructions->GetInstructionAtIndex(branch_index)->GetAddress();
}
- if (branch_index - pc_index > 1)
+ if (run_to_address.IsValid())
{
const bool is_internal = true;
- run_to_address = instructions->GetInstructionAtIndex(branch_index)->GetAddress();
m_next_branch_bp_sp = GetTarget().CreateBreakpoint(run_to_address, is_internal, false);
if (m_next_branch_bp_sp)
{
@@ -501,15 +501,7 @@ ThreadPlanStepRange::MischiefManaged ()
else
{
FrameComparison frame_order = CompareCurrentFrameToStartFrame();
- if (frame_order != eFrameCompareOlder)
- {
- if (m_no_more_plans)
- done = true;
- else
- done = false;
- }
- else
- done = true;
+ done = (frame_order != eFrameCompareOlder) ? m_no_more_plans : true;
}
}
@@ -526,7 +518,6 @@ ThreadPlanStepRange::MischiefManaged ()
{
return false;
}
-
}
bool
diff --git a/source/Target/ThreadPlanStepThrough.cpp b/source/Target/ThreadPlanStepThrough.cpp
index 068d8e6584fde..a5346a4cddee8 100644
--- a/source/Target/ThreadPlanStepThrough.cpp
+++ b/source/Target/ThreadPlanStepThrough.cpp
@@ -7,12 +7,11 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/Target/ThreadPlanStepThrough.h"
-
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
+#include "lldb/Target/ThreadPlanStepThrough.h"
#include "lldb/Core/Log.h"
#include "lldb/Core/Stream.h"
#include "lldb/Target/DynamicLoader.h"
@@ -39,7 +38,6 @@ ThreadPlanStepThrough::ThreadPlanStepThrough (Thread &thread, StackID &m_stack_i
m_return_stack_id (m_stack_id),
m_stop_others (stop_others)
{
-
LookForPlanToStepThroughFromCurrentPC();
// If we don't get a valid step through plan, don't bother to set up a backstop.
@@ -56,7 +54,7 @@ ThreadPlanStepThrough::ThreadPlanStepThrough (Thread &thread, StackID &m_stack_i
{
m_backstop_addr = return_frame_sp->GetFrameCodeAddress().GetLoadAddress(m_thread.CalculateTarget().get());
Breakpoint *return_bp = m_thread.GetProcess()->GetTarget().CreateBreakpoint (m_backstop_addr, true, false).get();
- if (return_bp != NULL)
+ if (return_bp != nullptr)
{
return_bp->SetThreadID(m_thread.GetID());
m_backstop_bkpt_id = return_bp->GetID();
@@ -137,7 +135,7 @@ ThreadPlanStepThrough::GetDescription (Stream *s, lldb::DescriptionLevel level)
bool
ThreadPlanStepThrough::ValidatePlan (Stream *error)
{
- return m_sub_plan_sp.get() != NULL;
+ return m_sub_plan_sp.get() != nullptr;
}
bool
@@ -147,10 +145,7 @@ ThreadPlanStepThrough::DoPlanExplainsStop (Event *event_ptr)
// we won't get asked. The only time we would be the one directly asked this question
// is if we hit our backstop breakpoint.
- if (HitOurBackstopBreakpoint())
- return true;
- else
- return false;
+ return HitOurBackstopBreakpoint();
}
bool
@@ -289,4 +284,3 @@ ThreadPlanStepThrough::HitOurBackstopBreakpoint()
}
return false;
}
-
diff --git a/source/Target/ThreadPlanStepUntil.cpp b/source/Target/ThreadPlanStepUntil.cpp
index 4c3d4a6a049e4..2581fc7b522f3 100644
--- a/source/Target/ThreadPlanStepUntil.cpp
+++ b/source/Target/ThreadPlanStepUntil.cpp
@@ -6,17 +6,12 @@
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-//m_should_stop
-
-//
-//===----------------------------------------------------------------------===//
-
-#include "lldb/Target/ThreadPlanStepUntil.h"
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
+#include "lldb/Target/ThreadPlanStepUntil.h"
#include "lldb/Breakpoint/Breakpoint.h"
#include "lldb/Core/Log.h"
#include "lldb/Target/Process.h"
@@ -68,7 +63,7 @@ ThreadPlanStepUntil::ThreadPlanStepUntil
// TODO: add inline functionality
m_return_addr = return_frame_sp->GetStackID().GetPC();
Breakpoint *return_bp = target_sp->CreateBreakpoint (m_return_addr, true, false).get();
- if (return_bp != NULL)
+ if (return_bp != nullptr)
{
return_bp->SetThreadID(thread_id);
m_return_bp_id = return_bp->GetID();
@@ -82,7 +77,7 @@ ThreadPlanStepUntil::ThreadPlanStepUntil
for (size_t i = 0; i < num_addresses; i++)
{
Breakpoint *until_bp = target_sp->CreateBreakpoint (address_list[i], true, false).get();
- if (until_bp != NULL)
+ if (until_bp != nullptr)
{
until_bp->SetThreadID(thread_id);
m_until_points[address_list[i]] = until_bp->GetID();
@@ -183,122 +178,111 @@ ThreadPlanStepUntil::AnalyzeStop()
{
StopReason reason = stop_info_sp->GetStopReason();
- switch (reason)
+ if (reason == eStopReasonBreakpoint)
{
- case eStopReasonBreakpoint:
+ // If this is OUR breakpoint, we're fine, otherwise we don't know why this happened...
+ BreakpointSiteSP this_site = m_thread.GetProcess()->GetBreakpointSiteList().FindByID (stop_info_sp->GetValue());
+ if (!this_site)
{
- // If this is OUR breakpoint, we're fine, otherwise we don't know why this happened...
- BreakpointSiteSP this_site = m_thread.GetProcess()->GetBreakpointSiteList().FindByID (stop_info_sp->GetValue());
- if (!this_site)
- {
- m_explains_stop = false;
- return;
- }
+ m_explains_stop = false;
+ return;
+ }
- if (this_site->IsBreakpointAtThisSite (m_return_bp_id))
+ if (this_site->IsBreakpointAtThisSite (m_return_bp_id))
+ {
+ // If we are at our "step out" breakpoint, and the stack depth has shrunk, then
+ // this is indeed our stop.
+ // If the stack depth has grown, then we've hit our step out breakpoint recursively.
+ // If we are the only breakpoint at that location, then we do explain the stop, and
+ // we'll just continue.
+ // If there was another breakpoint here, then we don't explain the stop, but we won't
+ // mark ourselves Completed, because maybe that breakpoint will continue, and then
+ // we'll finish the "until".
+ bool done;
+ StackID cur_frame_zero_id;
+
+ done = (m_stack_id < cur_frame_zero_id);
+
+ if (done)
{
- // If we are at our "step out" breakpoint, and the stack depth has shrunk, then
- // this is indeed our stop.
- // If the stack depth has grown, then we've hit our step out breakpoint recursively.
- // If we are the only breakpoint at that location, then we do explain the stop, and
- // we'll just continue.
- // If there was another breakpoint here, then we don't explain the stop, but we won't
- // mark ourselves Completed, because maybe that breakpoint will continue, and then
- // we'll finish the "until".
- bool done;
- StackID cur_frame_zero_id;
-
- if (m_stack_id < cur_frame_zero_id)
- done = true;
- else
- done = false;
-
- if (done)
- {
- m_stepped_out = true;
- SetPlanComplete();
- }
- else
- m_should_stop = false;
-
- if (this_site->GetNumberOfOwners() == 1)
- m_explains_stop = true;
- else
- m_explains_stop = false;
- return;
+ m_stepped_out = true;
+ SetPlanComplete();
}
else
+ m_should_stop = false;
+
+ if (this_site->GetNumberOfOwners() == 1)
+ m_explains_stop = true;
+ else
+ m_explains_stop = false;
+ return;
+ }
+ else
+ {
+ // Check if we've hit one of our "until" breakpoints.
+ until_collection::iterator pos, end = m_until_points.end();
+ for (pos = m_until_points.begin(); pos != end; pos++)
{
- // Check if we've hit one of our "until" breakpoints.
- until_collection::iterator pos, end = m_until_points.end();
- for (pos = m_until_points.begin(); pos != end; pos++)
+ if (this_site->IsBreakpointAtThisSite ((*pos).second))
{
- if (this_site->IsBreakpointAtThisSite ((*pos).second))
+ // If we're at the right stack depth, then we're done.
+
+ bool done;
+ StackID frame_zero_id = m_thread.GetStackFrameAtIndex(0)->GetStackID();
+
+ if (frame_zero_id == m_stack_id)
+ done = true;
+ else if (frame_zero_id < m_stack_id)
+ done = false;
+ else
{
- // If we're at the right stack depth, then we're done.
-
- bool done;
- StackID frame_zero_id = m_thread.GetStackFrameAtIndex(0)->GetStackID();
-
- if (frame_zero_id == m_stack_id)
- done = true;
- else if (frame_zero_id < m_stack_id)
- done = false;
- else
+ StackFrameSP older_frame_sp = m_thread.GetStackFrameAtIndex(1);
+
+ // But if we can't even unwind one frame we should just get out of here & stop...
+ if (older_frame_sp)
{
- StackFrameSP older_frame_sp = m_thread.GetStackFrameAtIndex(1);
-
- // But if we can't even unwind one frame we should just get out of here & stop...
- if (older_frame_sp)
- {
- const SymbolContext &older_context
- = older_frame_sp->GetSymbolContext(eSymbolContextEverything);
- SymbolContext stack_context;
- m_stack_id.GetSymbolContextScope()->CalculateSymbolContext(&stack_context);
-
- if (older_context == stack_context)
- done = true;
- else
- done = false;
- }
- else
- done = false;
+ const SymbolContext &older_context
+ = older_frame_sp->GetSymbolContext(eSymbolContextEverything);
+ SymbolContext stack_context;
+ m_stack_id.GetSymbolContextScope()->CalculateSymbolContext(&stack_context);
+
+ done = (older_context == stack_context);
}
-
- if (done)
- SetPlanComplete();
- else
- m_should_stop = false;
-
- // Otherwise we've hit this breakpoint recursively. If we're the
- // only breakpoint here, then we do explain the stop, and we'll continue.
- // If not then we should let higher plans handle this stop.
- if (this_site->GetNumberOfOwners() == 1)
- m_explains_stop = true;
else
- {
- m_should_stop = true;
- m_explains_stop = false;
- }
- return;
+ done = false;
+ }
+
+ if (done)
+ SetPlanComplete();
+ else
+ m_should_stop = false;
+
+ // Otherwise we've hit this breakpoint recursively. If we're the
+ // only breakpoint here, then we do explain the stop, and we'll continue.
+ // If not then we should let higher plans handle this stop.
+ if (this_site->GetNumberOfOwners() == 1)
+ m_explains_stop = true;
+ else
+ {
+ m_should_stop = true;
+ m_explains_stop = false;
}
+ return;
}
}
- // If we get here we haven't hit any of our breakpoints, so let the higher
- // plans take care of the stop.
- m_explains_stop = false;
- return;
}
- case eStopReasonWatchpoint:
- case eStopReasonSignal:
- case eStopReasonException:
- case eStopReasonExec:
- case eStopReasonThreadExiting:
- m_explains_stop = false;
- break;
- default:
- m_explains_stop = true;
- break;
+ // If we get here we haven't hit any of our breakpoints, so let the higher
+ // plans take care of the stop.
+ m_explains_stop = false;
+ return;
+ }
+ else if (IsUsuallyUnexplainedStopReason(reason))
+ {
+ m_explains_stop = false;
+ }
+ else
+ {
+ m_explains_stop = true;
}
}
}
@@ -348,14 +332,14 @@ ThreadPlanStepUntil::DoWillResume (StateType resume_state, bool current_plan)
if (target_sp)
{
Breakpoint *return_bp = target_sp->GetBreakpointByID(m_return_bp_id).get();
- if (return_bp != NULL)
+ if (return_bp != nullptr)
return_bp->SetEnabled (true);
until_collection::iterator pos, end = m_until_points.end();
for (pos = m_until_points.begin(); pos != end; pos++)
{
Breakpoint *until_bp = target_sp->GetBreakpointByID((*pos).second).get();
- if (until_bp != NULL)
+ if (until_bp != nullptr)
until_bp->SetEnabled (true);
}
}
@@ -374,14 +358,14 @@ ThreadPlanStepUntil::WillStop ()
if (target_sp)
{
Breakpoint *return_bp = target_sp->GetBreakpointByID(m_return_bp_id).get();
- if (return_bp != NULL)
+ if (return_bp != nullptr)
return_bp->SetEnabled (false);
until_collection::iterator pos, end = m_until_points.end();
for (pos = m_until_points.begin(); pos != end; pos++)
{
Breakpoint *until_bp = target_sp->GetBreakpointByID((*pos).second).get();
- if (until_bp != NULL)
+ if (until_bp != nullptr)
until_bp->SetEnabled (false);
}
}
@@ -391,7 +375,6 @@ ThreadPlanStepUntil::WillStop ()
bool
ThreadPlanStepUntil::MischiefManaged ()
{
-
// I'm letting "PlanExplainsStop" do all the work, and just reporting that here.
bool done = false;
if (IsPlanComplete())
@@ -407,6 +390,4 @@ ThreadPlanStepUntil::MischiefManaged ()
ThreadPlan::MischiefManaged ();
return done;
-
}
-
diff --git a/source/Target/ThreadPlanTracer.cpp b/source/Target/ThreadPlanTracer.cpp
index 406708f8c3965..e3fcbaaaef75a 100644
--- a/source/Target/ThreadPlanTracer.cpp
+++ b/source/Target/ThreadPlanTracer.cpp
@@ -7,13 +7,13 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/Target/ThreadPlan.h"
-
// C Includes
-#include <string.h>
// C++ Includes
+#include <cstring>
+
// Other libraries and framework includes
// Project includes
+#include "lldb/Target/ThreadPlan.h"
#include "lldb/Core/ArchSpec.h"
#include "lldb/Core/DataBufferHeap.h"
#include "lldb/Core/DataExtractor.h"
@@ -24,8 +24,8 @@
#include "lldb/Core/State.h"
#include "lldb/Core/StreamFile.h"
#include "lldb/Core/Value.h"
-#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/TypeList.h"
+#include "lldb/Symbol/TypeSystem.h"
#include "lldb/Target/ABI.h"
#include "lldb/Target/RegisterContext.h"
#include "lldb/Target/Thread.h"
@@ -57,8 +57,7 @@ ThreadPlanTracer::ThreadPlanTracer (Thread &thread) :
Stream *
ThreadPlanTracer::GetLogStream ()
{
-
- if (m_stream_sp.get())
+ if (m_stream_sp)
return m_stream_sp.get();
else
{
@@ -66,7 +65,7 @@ ThreadPlanTracer::GetLogStream ()
if (target_sp)
return target_sp->GetDebugger().GetOutputFile().get();
}
- return NULL;
+ return nullptr;
}
void
@@ -83,7 +82,6 @@ ThreadPlanTracer::Log()
stream->Printf("\n");
stream->Flush();
}
-
}
bool
@@ -92,10 +90,7 @@ ThreadPlanTracer::TracerExplainsStop ()
if (m_enabled && m_single_step)
{
lldb::StopInfoSP stop_info = m_thread.GetStopInfo();
- if (stop_info->GetStopReason() == eStopReasonTrace)
- return true;
- else
- return false;
+ return (stop_info->GetStopReason() == eStopReasonTrace);
}
else
return false;
@@ -122,8 +117,8 @@ ThreadPlanAssemblyTracer::ThreadPlanAssemblyTracer (Thread &thread) :
Disassembler *
ThreadPlanAssemblyTracer::GetDisassembler ()
{
- if (m_disassembler_sp.get() == NULL)
- m_disassembler_sp = Disassembler::FindPlugin(m_thread.GetProcess()->GetTarget().GetArchitecture(), NULL, NULL);
+ if (!m_disassembler_sp)
+ m_disassembler_sp = Disassembler::FindPlugin(m_thread.GetProcess()->GetTarget().GetArchitecture(), nullptr, nullptr);
return m_disassembler_sp.get();
}
@@ -135,29 +130,22 @@ ThreadPlanAssemblyTracer::GetIntPointerType()
TargetSP target_sp (m_thread.CalculateTarget());
if (target_sp)
{
- Module *exe_module = target_sp->GetExecutableModulePointer();
-
- if (exe_module)
- {
- m_intptr_type = TypeFromUser(exe_module->GetClangASTContext().GetBuiltinTypeForEncodingAndBitSize(eEncodingUint, target_sp->GetArchitecture().GetAddressByteSize() * 8));
- }
+ TypeSystem *type_system = target_sp->GetScratchTypeSystemForLanguage(nullptr, eLanguageTypeC);
+ if (type_system)
+ m_intptr_type = TypeFromUser(type_system->GetBuiltinTypeForEncodingAndBitSize(eEncodingUint, target_sp->GetArchitecture().GetAddressByteSize() * 8));
}
}
return m_intptr_type;
}
-
-
-ThreadPlanAssemblyTracer::~ThreadPlanAssemblyTracer()
-{
-}
+ThreadPlanAssemblyTracer::~ThreadPlanAssemblyTracer() = default;
void
ThreadPlanAssemblyTracer::TracingStarted ()
{
RegisterContext *reg_ctx = m_thread.GetRegisterContext().get();
- if (m_register_values.size() == 0)
+ if (m_register_values.empty())
m_register_values.resize (reg_ctx->GetRegisterCount());
}
@@ -214,15 +202,15 @@ ThreadPlanAssemblyTracer::Log ()
const bool show_address = true;
Instruction *instruction = instruction_list.GetInstructionAtIndex(0).get();
const FormatEntity::Entry *disassemble_format = m_thread.GetProcess()->GetTarget().GetDebugger().GetDisassemblyFormat();
- instruction->Dump (stream,
- max_opcode_byte_size,
- show_address,
- show_bytes,
- NULL,
- NULL,
- NULL,
- disassemble_format,
- 0);
+ instruction->Dump(stream,
+ max_opcode_byte_size,
+ show_address,
+ show_bytes,
+ nullptr,
+ nullptr,
+ nullptr,
+ disassemble_format,
+ 0);
}
}
}
@@ -240,7 +228,7 @@ ThreadPlanAssemblyTracer::Log ()
Value value;
value.SetValueType (Value::eValueTypeScalar);
// value.SetContext (Value::eContextTypeClangType, intptr_type.GetOpaqueQualType());
- value.SetClangType (intptr_type);
+ value.SetCompilerType (intptr_type);
value_list.PushValue (value);
}
@@ -255,8 +243,7 @@ ThreadPlanAssemblyTracer::Log ()
}
}
}
-
-
+
RegisterValue reg_value;
for (uint32_t reg_num = 0, num_registers = reg_ctx->GetRegisterCount();
reg_num < num_registers;
diff --git a/source/Target/ThreadSpec.cpp b/source/Target/ThreadSpec.cpp
index cb54469ba9014..f877f521bd511 100644
--- a/source/Target/ThreadSpec.cpp
+++ b/source/Target/ThreadSpec.cpp
@@ -1,4 +1,4 @@
-//===-- ThreadSpec.cpp ----------------------------------------------*- C++ -*-===//
+//===-- ThreadSpec.cpp ------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -7,6 +7,10 @@
//
//===----------------------------------------------------------------------===//
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
#include "lldb/Target/Thread.h"
#include "lldb/Target/ThreadSpec.h"
@@ -21,7 +25,7 @@ ThreadSpec::ThreadSpec() :
{
}
-ThreadSpec::ThreadSpec (const ThreadSpec &rhs) :
+ThreadSpec::ThreadSpec(const ThreadSpec &rhs) :
m_index(rhs.m_index),
m_tid(rhs.m_tid),
m_name(rhs.m_name),
@@ -42,19 +46,13 @@ ThreadSpec::operator=(const ThreadSpec &rhs)
const char *
ThreadSpec::GetName () const
{
- if (m_name.empty())
- return NULL;
- else
- return m_name.c_str();
+ return m_name.empty() ? nullptr : m_name.c_str();
}
const char *
ThreadSpec::GetQueueName () const
{
- if (m_queue_name.empty())
- return NULL;
- else
- return m_queue_name.c_str();
+ return m_queue_name.empty() ? nullptr : m_queue_name.c_str();
}
bool
@@ -66,6 +64,7 @@ ThreadSpec::TIDMatches (Thread &thread) const
lldb::tid_t thread_id = thread.GetID();
return TIDMatches (thread_id);
}
+
bool
ThreadSpec::IndexMatches (Thread &thread) const
{
@@ -74,6 +73,7 @@ ThreadSpec::IndexMatches (Thread &thread) const
uint32_t index = thread.GetIndexID();
return IndexMatches (index);
}
+
bool
ThreadSpec::NameMatches (Thread &thread) const
{
@@ -83,6 +83,7 @@ ThreadSpec::NameMatches (Thread &thread) const
const char *name = thread.GetName();
return NameMatches (name);
}
+
bool
ThreadSpec::QueueNameMatches (Thread &thread) const
{
@@ -96,7 +97,6 @@ ThreadSpec::QueueNameMatches (Thread &thread) const
bool
ThreadSpec::ThreadPassesBasicTests (Thread &thread) const
{
-
if (!HasSpecification())
return true;
@@ -113,7 +113,6 @@ ThreadSpec::ThreadPassesBasicTests (Thread &thread) const
return false;
return true;
-
}
bool
@@ -121,6 +120,7 @@ ThreadSpec::HasSpecification() const
{
return (m_index != UINT32_MAX || m_tid != LLDB_INVALID_THREAD_ID || !m_name.empty() || !m_queue_name.empty());
}
+
void
ThreadSpec::GetDescription (Stream *s, lldb::DescriptionLevel level) const
{
diff --git a/source/Target/UnixSignals.cpp b/source/Target/UnixSignals.cpp
index 91579e8d78520..8a98c21560d79 100644
--- a/source/Target/UnixSignals.cpp
+++ b/source/Target/UnixSignals.cpp
@@ -19,20 +19,21 @@
#include "Plugins/Process/Utility/FreeBSDSignals.h"
#include "Plugins/Process/Utility/LinuxSignals.h"
#include "Plugins/Process/Utility/MipsLinuxSignals.h"
+#include "Plugins/Process/Utility/NetBSDSignals.h"
using namespace lldb_private;
UnixSignals::Signal::Signal
(
const char *name,
- const char *short_name,
bool default_suppress,
bool default_stop,
bool default_notify,
- const char *description
+ const char *description,
+ const char *alias
) :
m_name (name),
- m_short_name (short_name),
+ m_alias (alias),
m_description (),
m_suppress (default_suppress),
m_stop (default_stop),
@@ -63,8 +64,9 @@ UnixSignals::Create(const ArchSpec &arch)
}
case llvm::Triple::FreeBSD:
case llvm::Triple::OpenBSD:
- case llvm::Triple::NetBSD:
return std::make_shared<FreeBSDSignals>();
+ case llvm::Triple::NetBSD:
+ return std::make_shared<NetBSDSignals>();
default:
return std::make_shared<UnixSignals>();
}
@@ -97,39 +99,39 @@ UnixSignals::Reset ()
// order, you can either subclass this class, and use Add & Remove to change them
// or you can subclass and build them afresh in your constructor;
m_signals.clear();
- // SIGNO NAME SHORT NAME SUPPRESS STOP NOTIFY DESCRIPTION
- // ====== ============ ========== ======== ====== ====== ===================================================
- AddSignal (1, "SIGHUP", "HUP", false, true , true , "hangup");
- AddSignal (2, "SIGINT", "INT", true , true , true , "interrupt");
- AddSignal (3, "SIGQUIT", "QUIT", false, true , true , "quit");
- AddSignal (4, "SIGILL", "ILL", false, true , true , "illegal instruction");
- AddSignal (5, "SIGTRAP", "TRAP", true , true , true , "trace trap (not reset when caught)");
- AddSignal (6, "SIGABRT", "ABRT", false, true , true , "abort()");
- AddSignal (7, "SIGEMT", "EMT", false, true , true , "pollable event");
- AddSignal (8, "SIGFPE", "FPE", false, true , true , "floating point exception");
- AddSignal (9, "SIGKILL", "KILL", false, true , true , "kill");
- AddSignal (10, "SIGBUS", "BUS", false, true , true , "bus error");
- AddSignal (11, "SIGSEGV", "SEGV", false, true , true , "segmentation violation");
- AddSignal (12, "SIGSYS", "SYS", false, true , true , "bad argument to system call");
- AddSignal (13, "SIGPIPE", "PIPE", false, true , true , "write on a pipe with no one to read it");
- AddSignal (14, "SIGALRM", "ALRM", false, false, false, "alarm clock");
- AddSignal (15, "SIGTERM", "TERM", false, true , true , "software termination signal from kill");
- AddSignal (16, "SIGURG", "URG", false, false, false, "urgent condition on IO channel");
- AddSignal (17, "SIGSTOP", "STOP", true , true , true , "sendable stop signal not from tty");
- AddSignal (18, "SIGTSTP", "TSTP", false, true , true , "stop signal from tty");
- AddSignal (19, "SIGCONT", "CONT", false, true , true , "continue a stopped process");
- AddSignal (20, "SIGCHLD", "CHLD", false, false, false, "to parent on child stop or exit");
- AddSignal (21, "SIGTTIN", "TTIN", false, true , true , "to readers process group upon background tty read");
- AddSignal (22, "SIGTTOU", "TTOU", false, true , true , "to readers process group upon background tty write");
- AddSignal (23, "SIGIO", "IO", false, false, false, "input/output possible signal");
- AddSignal (24, "SIGXCPU", "XCPU", false, true , true , "exceeded CPU time limit");
- AddSignal (25, "SIGXFSZ", "XFSZ", false, true , true , "exceeded file size limit");
- AddSignal (26, "SIGVTALRM", "VTALRM", false, false, false, "virtual time alarm");
- AddSignal (27, "SIGPROF", "PROF", false, false, false, "profiling time alarm");
- AddSignal (28, "SIGWINCH", "WINCH", false, false, false, "window size changes");
- AddSignal (29, "SIGINFO", "INFO", false, true , true , "information request");
- AddSignal (30, "SIGUSR1", "USR1", false, true , true , "user defined signal 1");
- AddSignal (31, "SIGUSR2", "USR2", false, true , true , "user defined signal 2");
+ // SIGNO NAME SUPPRESS STOP NOTIFY DESCRIPTION
+ // ====== ============ ======== ====== ====== ===================================================
+ AddSignal (1, "SIGHUP", false, true , true , "hangup");
+ AddSignal (2, "SIGINT", true , true , true , "interrupt");
+ AddSignal (3, "SIGQUIT", false, true , true , "quit");
+ AddSignal (4, "SIGILL", false, true , true , "illegal instruction");
+ AddSignal (5, "SIGTRAP", true , true , true , "trace trap (not reset when caught)");
+ AddSignal (6, "SIGABRT", false, true , true , "abort()");
+ AddSignal (7, "SIGEMT", false, true , true , "pollable event");
+ AddSignal (8, "SIGFPE", false, true , true , "floating point exception");
+ AddSignal (9, "SIGKILL", false, true , true , "kill");
+ AddSignal (10, "SIGBUS", false, true , true , "bus error");
+ AddSignal (11, "SIGSEGV", false, true , true , "segmentation violation");
+ AddSignal (12, "SIGSYS", false, true , true , "bad argument to system call");
+ AddSignal (13, "SIGPIPE", false, true , true , "write on a pipe with no one to read it");
+ AddSignal (14, "SIGALRM", false, false, false, "alarm clock");
+ AddSignal (15, "SIGTERM", false, true , true , "software termination signal from kill");
+ AddSignal (16, "SIGURG", false, false, false, "urgent condition on IO channel");
+ AddSignal (17, "SIGSTOP", true , true , true , "sendable stop signal not from tty");
+ AddSignal (18, "SIGTSTP", false, true , true , "stop signal from tty");
+ AddSignal (19, "SIGCONT", false, true , true , "continue a stopped process");
+ AddSignal (20, "SIGCHLD", false, false, false, "to parent on child stop or exit");
+ AddSignal (21, "SIGTTIN", false, true , true , "to readers process group upon background tty read");
+ AddSignal (22, "SIGTTOU", false, true , true , "to readers process group upon background tty write");
+ AddSignal (23, "SIGIO", false, false, false, "input/output possible signal");
+ AddSignal (24, "SIGXCPU", false, true , true , "exceeded CPU time limit");
+ AddSignal (25, "SIGXFSZ", false, true , true , "exceeded file size limit");
+ AddSignal (26, "SIGVTALRM", false, false, false, "virtual time alarm");
+ AddSignal (27, "SIGPROF", false, false, false, "profiling time alarm");
+ AddSignal (28, "SIGWINCH", false, false, false, "window size changes");
+ AddSignal (29, "SIGINFO", false, true , true , "information request");
+ AddSignal (30, "SIGUSR1", false, true , true , "user defined signal 1");
+ AddSignal (31, "SIGUSR2", false, true , true , "user defined signal 2");
}
void
@@ -137,14 +139,14 @@ UnixSignals::AddSignal
(
int signo,
const char *name,
- const char *short_name,
bool default_suppress,
bool default_stop,
bool default_notify,
- const char *description
+ const char *description,
+ const char *alias
)
{
- Signal new_signal (name, short_name, default_suppress, default_stop, default_notify, description);
+ Signal new_signal (name, default_suppress, default_stop, default_notify, description, alias);
m_signals.insert (std::make_pair(signo, new_signal));
}
@@ -173,6 +175,16 @@ UnixSignals::SignalIsValid (int32_t signo) const
return m_signals.find (signo) != m_signals.end();
}
+ConstString
+UnixSignals::GetShortName(ConstString name) const
+{
+ if (name)
+ {
+ char* signame = (char*)(name.AsCString());
+ return ConstString(signame + 3); // Remove "SIG" from name
+ }
+ return name;
+}
int32_t
UnixSignals::GetSignalNumberFromName (const char *name) const
@@ -182,7 +194,8 @@ UnixSignals::GetSignalNumberFromName (const char *name) const
collection::const_iterator pos, end = m_signals.end ();
for (pos = m_signals.begin (); pos != end; pos++)
{
- if ((const_name == pos->second.m_name) || (const_name == pos->second.m_short_name))
+ if ((const_name == pos->second.m_name) || (const_name == pos->second.m_alias) ||
+ (const_name == GetShortName(pos->second.m_name)) || (const_name == GetShortName(pos->second.m_alias)))
return pos->first;
}