[Lldb-commits] [lldb] r280751 - *** This commit represents a complete reformatting of the LLDB source code

Kate Stone via lldb-commits lldb-commits at lists.llvm.org
Tue Sep 6 13:58:36 PDT 2016


Modified: lldb/trunk/source/Target/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Target/Target.cpp (original)
+++ lldb/trunk/source/Target/Target.cpp Tue Sep  6 15:57:50 2016
@@ -12,7 +12,9 @@
 #include <mutex>
 // Other libraries and framework includes
 // Project includes
-#include "lldb/Target/Target.h"
+#include "Plugins/ExpressionParser/Clang/ClangASTSource.h"
+#include "Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.h"
+#include "Plugins/ExpressionParser/Clang/ClangPersistentVariables.h"
 #include "lldb/Breakpoint/BreakpointResolver.h"
 #include "lldb/Breakpoint/BreakpointResolverAddress.h"
 #include "lldb/Breakpoint/BreakpointResolverFileLine.h"
@@ -33,9 +35,6 @@
 #include "lldb/Core/ValueObject.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,8 +43,8 @@
 #include "lldb/Interpreter/OptionValues.h"
 #include "lldb/Interpreter/Property.h"
 #include "lldb/Symbol/ClangASTContext.h"
-#include "lldb/Symbol/ObjectFile.h"
 #include "lldb/Symbol/Function.h"
+#include "lldb/Symbol/ObjectFile.h"
 #include "lldb/Symbol/Symbol.h"
 #include "lldb/Target/Language.h"
 #include "lldb/Target/LanguageRuntime.h"
@@ -54,6 +53,7 @@
 #include "lldb/Target/SectionLoadList.h"
 #include "lldb/Target/StackFrame.h"
 #include "lldb/Target/SystemRuntime.h"
+#include "lldb/Target/Target.h"
 #include "lldb/Target/Thread.h"
 #include "lldb/Target/ThreadSpec.h"
 #include "lldb/Utility/LLDBAssert.h"
@@ -61,862 +61,737 @@
 using namespace lldb;
 using namespace lldb_private;
 
-ConstString &
-Target::GetStaticBroadcasterClass ()
-{
-    static ConstString class_name ("lldb.target");
-    return class_name;
+ConstString &Target::GetStaticBroadcasterClass() {
+  static ConstString class_name("lldb.target");
+  return class_name;
 }
 
-Target::Target(Debugger &debugger, const ArchSpec &target_arch, const lldb::PlatformSP &platform_sp,
-               bool is_dummy_target)
+Target::Target(Debugger &debugger, const ArchSpec &target_arch,
+               const lldb::PlatformSP &platform_sp, bool is_dummy_target)
     : TargetProperties(this),
-      Broadcaster(debugger.GetBroadcasterManager(), Target::GetStaticBroadcasterClass().AsCString()),
-      ExecutionContextScope(),
-      m_debugger(debugger),
-      m_platform_sp(platform_sp),
-      m_mutex(),
-      m_arch(target_arch),
-      m_images(this),
-      m_section_load_history(),
-      m_breakpoint_list(false),
-      m_internal_breakpoint_list(true),
-      m_watchpoint_list(),
-      m_process_sp(),
-      m_search_filter_sp(),
-      m_image_search_paths(ImageSearchPathsChanged, this),
-      m_ast_importer_sp(),
-      m_source_manager_ap(),
-      m_stop_hooks(),
-      m_stop_hook_next_id(0),
-      m_valid(true),
-      m_suppress_stop_hooks(false),
+      Broadcaster(debugger.GetBroadcasterManager(),
+                  Target::GetStaticBroadcasterClass().AsCString()),
+      ExecutionContextScope(), m_debugger(debugger), m_platform_sp(platform_sp),
+      m_mutex(), m_arch(target_arch), m_images(this), m_section_load_history(),
+      m_breakpoint_list(false), m_internal_breakpoint_list(true),
+      m_watchpoint_list(), m_process_sp(), m_search_filter_sp(),
+      m_image_search_paths(ImageSearchPathsChanged, this), m_ast_importer_sp(),
+      m_source_manager_ap(), m_stop_hooks(), m_stop_hook_next_id(0),
+      m_valid(true), m_suppress_stop_hooks(false),
       m_is_dummy_target(is_dummy_target)
 
 {
-    SetEventName(eBroadcastBitBreakpointChanged, "breakpoint-changed");
-    SetEventName(eBroadcastBitModulesLoaded, "modules-loaded");
-    SetEventName(eBroadcastBitModulesUnloaded, "modules-unloaded");
-    SetEventName(eBroadcastBitWatchpointChanged, "watchpoint-changed");
-    SetEventName(eBroadcastBitSymbolsLoaded, "symbols-loaded");
-
-    CheckInWithManager();
-
-    Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_OBJECT));
-    if (log)
-        log->Printf("%p Target::Target()", static_cast<void *>(this));
-    if (m_arch.IsValid())
-    {
-        LogIfAnyCategoriesSet(LIBLLDB_LOG_TARGET, "Target::Target created with architecture %s (%s)",
-                              m_arch.GetArchitectureName(), m_arch.GetTriple().getTriple().c_str());
-    }
+  SetEventName(eBroadcastBitBreakpointChanged, "breakpoint-changed");
+  SetEventName(eBroadcastBitModulesLoaded, "modules-loaded");
+  SetEventName(eBroadcastBitModulesUnloaded, "modules-unloaded");
+  SetEventName(eBroadcastBitWatchpointChanged, "watchpoint-changed");
+  SetEventName(eBroadcastBitSymbolsLoaded, "symbols-loaded");
+
+  CheckInWithManager();
+
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_OBJECT));
+  if (log)
+    log->Printf("%p Target::Target()", static_cast<void *>(this));
+  if (m_arch.IsValid()) {
+    LogIfAnyCategoriesSet(
+        LIBLLDB_LOG_TARGET, "Target::Target created with architecture %s (%s)",
+        m_arch.GetArchitectureName(), m_arch.GetTriple().getTriple().c_str());
+  }
+}
+
+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) {
+  if (!target)
+    return;
+
+  m_stop_hooks = target->m_stop_hooks;
+
+  for (BreakpointSP breakpoint_sp : target->m_breakpoint_list.Breakpoints()) {
+    if (breakpoint_sp->IsInternal())
+      continue;
+
+    BreakpointSP new_bp(new Breakpoint(*this, *breakpoint_sp.get()));
+    AddBreakpoint(new_bp, false);
+  }
+}
+
+void Target::Dump(Stream *s, lldb::DescriptionLevel description_level) {
+  //    s->Printf("%.*p: ", (int)sizeof(void*) * 2, this);
+  if (description_level != lldb::eDescriptionLevelBrief) {
+    s->Indent();
+    s->PutCString("Target\n");
+    s->IndentMore();
+    m_images.Dump(s);
+    m_breakpoint_list.Dump(s);
+    m_internal_breakpoint_list.Dump(s);
+    s->IndentLess();
+  } else {
+    Module *exe_module = GetExecutableModulePointer();
+    if (exe_module)
+      s->PutCString(exe_module->GetFileSpec().GetFilename().GetCString());
+    else
+      s->PutCString("No executable module.");
+  }
+}
+
+void Target::CleanupProcess() {
+  // Do any cleanup of the target we need to do between process instances.
+  // NB It is better to do this before destroying the process in case the
+  // clean up needs some help from the process.
+  m_breakpoint_list.ClearAllBreakpointSites();
+  m_internal_breakpoint_list.ClearAllBreakpointSites();
+  // Disable watchpoints just on the debugger side.
+  std::unique_lock<std::recursive_mutex> lock;
+  this->GetWatchpointList().GetListMutex(lock);
+  DisableAllWatchpoints(false);
+  ClearAllWatchpointHitCounts();
+  ClearAllWatchpointHistoricValues();
 }
 
-Target::~Target()
-{
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT));
-    if (log)
-        log->Printf ("%p Target::~Target()", static_cast<void*>(this));
-    DeleteCurrentProcess ();
-}
+void Target::DeleteCurrentProcess() {
+  if (m_process_sp) {
+    m_section_load_history.Clear();
+    if (m_process_sp->IsAlive())
+      m_process_sp->Destroy(false);
 
-void
-Target::PrimeFromDummyTarget(Target *target)
-{
-    if (!target)
-        return;
+    m_process_sp->Finalize();
 
-    m_stop_hooks = target->m_stop_hooks;
-    
-    for (BreakpointSP breakpoint_sp : target->m_breakpoint_list.Breakpoints())
-    {
-        if (breakpoint_sp->IsInternal())
-            continue;
-            
-        BreakpointSP new_bp (new Breakpoint (*this, *breakpoint_sp.get()));
-        AddBreakpoint (new_bp, false);
-    }
-}
+    CleanupProcess();
 
-void
-Target::Dump (Stream *s, lldb::DescriptionLevel description_level)
-{
-//    s->Printf("%.*p: ", (int)sizeof(void*) * 2, this);
-    if (description_level != lldb::eDescriptionLevelBrief)
-    {
-        s->Indent();
-        s->PutCString("Target\n");
-        s->IndentMore();
-            m_images.Dump(s);
-            m_breakpoint_list.Dump(s);
-            m_internal_breakpoint_list.Dump(s);
-        s->IndentLess();
-    }
-    else
-    {
-        Module *exe_module = GetExecutableModulePointer();
-        if (exe_module)
-            s->PutCString (exe_module->GetFileSpec().GetFilename().GetCString());
-        else
-            s->PutCString ("No executable module.");
-    }
+    m_process_sp.reset();
+  }
 }
 
-void
-Target::CleanupProcess ()
-{
-    // Do any cleanup of the target we need to do between process instances.
-    // NB It is better to do this before destroying the process in case the
-    // clean up needs some help from the process.
-    m_breakpoint_list.ClearAllBreakpointSites();
-    m_internal_breakpoint_list.ClearAllBreakpointSites();
-    // Disable watchpoints just on the debugger side.
-    std::unique_lock<std::recursive_mutex> lock;
-    this->GetWatchpointList().GetListMutex(lock);
-    DisableAllWatchpoints(false);
-    ClearAllWatchpointHitCounts();
-    ClearAllWatchpointHistoricValues();
+const lldb::ProcessSP &Target::CreateProcess(ListenerSP listener_sp,
+                                             const char *plugin_name,
+                                             const FileSpec *crash_file) {
+  DeleteCurrentProcess();
+  m_process_sp = Process::FindPlugin(shared_from_this(), plugin_name,
+                                     listener_sp, crash_file);
+  return m_process_sp;
 }
 
-void
-Target::DeleteCurrentProcess ()
-{
-    if (m_process_sp)
-    {
-        m_section_load_history.Clear();
-        if (m_process_sp->IsAlive())
-            m_process_sp->Destroy(false);
-        
-        m_process_sp->Finalize();
-
-        CleanupProcess ();
-
-        m_process_sp.reset();
-    }
-}
+const lldb::ProcessSP &Target::GetProcessSP() const { return m_process_sp; }
 
-const lldb::ProcessSP &
-Target::CreateProcess (ListenerSP listener_sp, const char *plugin_name, const FileSpec *crash_file)
-{
-    DeleteCurrentProcess ();
-    m_process_sp = Process::FindPlugin(shared_from_this(), plugin_name, listener_sp, crash_file);
-    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;
 
-const lldb::ProcessSP &
-Target::GetProcessSP () const
-{
-    return m_process_sp;
-}
+    Language::GetLanguagesSupportingREPLs(repl_languages);
 
-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 REPL support for any languages.");
-            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));
+    if (repl_languages.size() == 1) {
+      language = *repl_languages.begin();
+    } else if (repl_languages.size() == 0) {
+      err.SetErrorStringWithFormat(
+          "LLDB isn't configured with REPL support for any languages.");
+      return REPLSP();
+    } else {
+      err.SetErrorStringWithFormat(
+          "Multiple possible REPL languages.  Please specify a language.");
+      return REPLSP();
     }
-    
-    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()
-{
-    std::lock_guard<std::recursive_mutex> guard(m_mutex);
-    m_valid = false;
-    DeleteCurrentProcess ();
-    m_platform_sp.reset();
-    m_arch.Clear();
-    ClearModules(true);
-    m_section_load_history.Clear();
-    const bool notify = false;
-    m_breakpoint_list.RemoveAll(notify);
-    m_internal_breakpoint_list.RemoveAll(notify);
-    m_last_created_breakpoint.reset();
-    m_last_created_watchpoint.reset();
-    m_search_filter_sp.reset();
-    m_image_search_paths.Clear(notify);
-    m_stop_hooks.clear();
-    m_stop_hook_next_id = 0;
-    m_suppress_stop_hooks = false;
-}
+  }
 
-BreakpointList &
-Target::GetBreakpointList(bool internal)
-{
-    if (internal)
-        return m_internal_breakpoint_list;
-    else
-        return m_breakpoint_list;
-}
+  REPLMap::iterator pos = m_repl_map.find(language);
 
-const BreakpointList &
-Target::GetBreakpointList(bool internal) const
-{
-    if (internal)
-        return m_internal_breakpoint_list;
-    else
-        return m_breakpoint_list;
-}
+  if (pos != m_repl_map.end()) {
+    return pos->second;
+  }
 
-BreakpointSP
-Target::GetBreakpointByID (break_id_t break_id)
-{
-    BreakpointSP bp_sp;
+  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();
+  }
 
-    if (LLDB_BREAK_ID_IS_INTERNAL (break_id))
-        bp_sp = m_internal_breakpoint_list.FindBreakpointByID (break_id);
-    else
-        bp_sp = m_breakpoint_list.FindBreakpointByID (break_id);
+  Debugger *const debugger = nullptr;
+  lldb::REPLSP ret = REPL::Create(err, language, debugger, this, repl_options);
 
-    return bp_sp;
+  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() {
+  std::lock_guard<std::recursive_mutex> guard(m_mutex);
+  m_valid = false;
+  DeleteCurrentProcess();
+  m_platform_sp.reset();
+  m_arch.Clear();
+  ClearModules(true);
+  m_section_load_history.Clear();
+  const bool notify = false;
+  m_breakpoint_list.RemoveAll(notify);
+  m_internal_breakpoint_list.RemoveAll(notify);
+  m_last_created_breakpoint.reset();
+  m_last_created_watchpoint.reset();
+  m_search_filter_sp.reset();
+  m_image_search_paths.Clear(notify);
+  m_stop_hooks.clear();
+  m_stop_hook_next_id = 0;
+  m_suppress_stop_hooks = false;
+}
+
+BreakpointList &Target::GetBreakpointList(bool internal) {
+  if (internal)
+    return m_internal_breakpoint_list;
+  else
+    return m_breakpoint_list;
+}
+
+const BreakpointList &Target::GetBreakpointList(bool internal) const {
+  if (internal)
+    return m_internal_breakpoint_list;
+  else
+    return m_breakpoint_list;
+}
+
+BreakpointSP Target::GetBreakpointByID(break_id_t break_id) {
+  BreakpointSP bp_sp;
+
+  if (LLDB_BREAK_ID_IS_INTERNAL(break_id))
+    bp_sp = m_internal_breakpoint_list.FindBreakpointByID(break_id);
+  else
+    bp_sp = m_breakpoint_list.FindBreakpointByID(break_id);
+
+  return bp_sp;
+}
+
+BreakpointSP Target::CreateSourceRegexBreakpoint(
+    const FileSpecList *containingModules,
+    const FileSpecList *source_file_spec_list,
+    const std::unordered_set<std::string> &function_names,
+    RegularExpression &source_regex, bool internal, bool hardware,
+    LazyBool move_to_nearest_code) {
+  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(
+      nullptr, source_regex, function_names,
+      !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, uint32_t line_no,
+                                      lldb::addr_t offset,
+                                      LazyBool check_inlines,
+                                      LazyBool skip_prologue, bool internal,
+                                      bool hardware,
+                                      LazyBool move_to_nearest_code) {
+  FileSpec remapped_file;
+  ConstString remapped_path;
+  if (GetSourcePathMap().ReverseRemapPath(ConstString(file.GetPath().c_str()),
+                                          remapped_path))
+    remapped_file.SetFile(remapped_path.AsCString(), true);
+  else
+    remapped_file = file;
+
+  if (check_inlines == eLazyBoolCalculate) {
+    const InlineStrategy inline_strategy = GetInlineStrategy();
+    switch (inline_strategy) {
+    case eInlineBreakpointsNever:
+      check_inlines = eLazyBoolNo;
+      break;
+
+    case eInlineBreakpointsHeaders:
+      if (remapped_file.IsSourceImplementationFile())
+        check_inlines = eLazyBoolNo;
+      else
+        check_inlines = eLazyBoolYes;
+      break;
+
+    case eInlineBreakpointsAlways:
+      check_inlines = eLazyBoolYes;
+      break;
+    }
+  }
+  SearchFilterSP filter_sp;
+  if (check_inlines == eLazyBoolNo) {
+    // Not checking for inlines, we are looking only for matching compile units
+    FileSpecList compile_unit_list;
+    compile_unit_list.Append(remapped_file);
+    filter_sp = GetSearchFilterForModuleAndCUList(containingModules,
+                                                  &compile_unit_list);
+  } else {
+    filter_sp = GetSearchFilterForModuleList(containingModules);
+  }
+  if (skip_prologue == eLazyBoolCalculate)
+    skip_prologue = GetSkipPrologue() ? eLazyBoolYes : eLazyBoolNo;
+  if (move_to_nearest_code == eLazyBoolCalculate)
+    move_to_nearest_code = GetMoveToNearestCode() ? eLazyBoolYes : eLazyBoolNo;
+
+  BreakpointResolverSP resolver_sp(new BreakpointResolverFileLine(
+      nullptr, remapped_file, line_no, offset, 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.
+
+  // Try and resolve as a load address if possible
+  GetSectionLoadList().ResolveLoadAddress(addr, so_addr);
+  if (!so_addr.IsValid()) {
+    // The address didn't resolve, so just set this as an absolute address
+    so_addr.SetOffset(addr);
+  }
+  BreakpointSP bp_sp(CreateBreakpoint(so_addr, internal, hardware));
+  return bp_sp;
+}
+
+BreakpointSP Target::CreateBreakpoint(const Address &addr, bool internal,
+                                      bool hardware) {
+  SearchFilterSP filter_sp(
+      new SearchFilterForUnconstrainedSearches(shared_from_this()));
+  BreakpointResolverSP resolver_sp(
+      new BreakpointResolverAddress(nullptr, addr));
+  return CreateBreakpoint(filter_sp, resolver_sp, internal, hardware, false);
 }
 
-BreakpointSP
-Target::CreateSourceRegexBreakpoint (const FileSpecList *containingModules,
-                                     const FileSpecList *source_file_spec_list,
-                                     const std::unordered_set<std::string> &function_names,
-                                     RegularExpression &source_regex,
-                                     bool internal,
-                                     bool hardware,
-                                     LazyBool move_to_nearest_code)
-{
-    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(nullptr,
-                                                                     source_regex,
-                                                                     function_names,
-                                                                     !static_cast<bool>(move_to_nearest_code)));
-    
-    return CreateBreakpoint (filter_sp, resolver_sp, internal, hardware, true);
+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 FileSpec &file,
-                          uint32_t line_no,
-                          lldb::addr_t offset,
-                          LazyBool check_inlines,
-                          LazyBool skip_prologue,
-                          bool internal,
-                          bool hardware,
-                          LazyBool move_to_nearest_code)
-{
-    FileSpec remapped_file;
-    ConstString remapped_path;
-    if (GetSourcePathMap().ReverseRemapPath(ConstString(file.GetPath().c_str()), remapped_path))
-        remapped_file.SetFile(remapped_path.AsCString(), true);
-    else
-        remapped_file = file;
+Target::CreateBreakpoint(const FileSpecList *containingModules,
+                         const FileSpecList *containingSourceFiles,
+                         const char *func_name, uint32_t func_name_type_mask,
+                         LanguageType language, lldb::addr_t offset,
+                         LazyBool skip_prologue, bool internal, bool hardware) {
+  BreakpointSP bp_sp;
+  if (func_name) {
+    SearchFilterSP filter_sp(GetSearchFilterForModuleAndCUList(
+        containingModules, containingSourceFiles));
 
-    if (check_inlines == eLazyBoolCalculate)
-    {
-        const InlineStrategy inline_strategy = GetInlineStrategy();
-        switch (inline_strategy)
-        {
-            case eInlineBreakpointsNever:
-                check_inlines = eLazyBoolNo;
-                break;
-                
-            case eInlineBreakpointsHeaders:
-                if (remapped_file.IsSourceImplementationFile())
-                    check_inlines = eLazyBoolNo;
-                else
-                    check_inlines = eLazyBoolYes;
-                break;
-
-            case eInlineBreakpointsAlways:
-                check_inlines = eLazyBoolYes;
-                break;
-        }
-    }
-    SearchFilterSP filter_sp;
-    if (check_inlines == eLazyBoolNo)
-    {
-        // Not checking for inlines, we are looking only for matching compile units
-        FileSpecList compile_unit_list;
-        compile_unit_list.Append (remapped_file);
-        filter_sp = GetSearchFilterForModuleAndCUList (containingModules, &compile_unit_list);
-    }
-    else
-    {
-        filter_sp = GetSearchFilterForModuleList (containingModules);
-    }
     if (skip_prologue == eLazyBoolCalculate)
-        skip_prologue = GetSkipPrologue() ? eLazyBoolYes : eLazyBoolNo;
-    if (move_to_nearest_code == eLazyBoolCalculate)
-        move_to_nearest_code = GetMoveToNearestCode() ? eLazyBoolYes : eLazyBoolNo;
-
-    BreakpointResolverSP resolver_sp(new BreakpointResolverFileLine (nullptr,
-                                                                     remapped_file,
-                                                                     line_no,
-                                                                     offset,
-                                                                     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.
-
-    // Try and resolve as a load address if possible
-    GetSectionLoadList().ResolveLoadAddress(addr, so_addr);
-    if (!so_addr.IsValid())
-    {
-        // The address didn't resolve, so just set this as an absolute address
-        so_addr.SetOffset (addr);
-    }
-    BreakpointSP bp_sp (CreateBreakpoint(so_addr, internal, hardware));
-    return bp_sp;
-}
-
-BreakpointSP
-Target::CreateBreakpoint (const Address &addr, bool internal, bool hardware)
-{
-    SearchFilterSP filter_sp(new SearchFilterForUnconstrainedSearches (shared_from_this()));
-    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,
-                          lldb::addr_t offset,
-                          LazyBool skip_prologue,
-                          bool internal,
-                          bool hardware)
-{
-    BreakpointSP bp_sp;
-    if (func_name)
-    {
-        SearchFilterSP filter_sp(GetSearchFilterForModuleAndCUList (containingModules, containingSourceFiles));
-
-        if (skip_prologue == eLazyBoolCalculate)
-            skip_prologue = GetSkipPrologue() ? eLazyBoolYes : eLazyBoolNo;
-        if (language == lldb::eLanguageTypeUnknown)
-            language = GetLanguage();
-
-        BreakpointResolverSP resolver_sp (new BreakpointResolverName (nullptr, 
-                                                                      func_name, 
-                                                                      func_name_type_mask, 
-                                                                      language,
-                                                                      Breakpoint::Exact, 
-                                                                      offset,
-                                                                      skip_prologue));
-        bp_sp = CreateBreakpoint (filter_sp, resolver_sp, internal, hardware, true);
-    }
-    return bp_sp;
+      skip_prologue = GetSkipPrologue() ? eLazyBoolYes : eLazyBoolNo;
+    if (language == lldb::eLanguageTypeUnknown)
+      language = GetLanguage();
+
+    BreakpointResolverSP resolver_sp(new BreakpointResolverName(
+        nullptr, func_name, func_name_type_mask, language, Breakpoint::Exact,
+        offset, skip_prologue));
+    bp_sp = CreateBreakpoint(filter_sp, resolver_sp, internal, hardware, true);
+  }
+  return bp_sp;
 }
 
 lldb::BreakpointSP
-Target::CreateBreakpoint (const FileSpecList *containingModules,
-                          const FileSpecList *containingSourceFiles,
-                          const std::vector<std::string> &func_names,
-                          uint32_t func_name_type_mask,
-                          LanguageType language,
-                          lldb::addr_t offset,
-                          LazyBool skip_prologue,
-                          bool internal,
-                          bool hardware)
-{
-    BreakpointSP bp_sp;
-    size_t num_names = func_names.size();
-    if (num_names > 0)
-    {
-        SearchFilterSP filter_sp(GetSearchFilterForModuleAndCUList (containingModules, containingSourceFiles));
-
-        if (skip_prologue == eLazyBoolCalculate)
-            skip_prologue = GetSkipPrologue() ? eLazyBoolYes : eLazyBoolNo;
-        if (language == lldb::eLanguageTypeUnknown)
-            language = GetLanguage();
-
-
-        BreakpointResolverSP resolver_sp (new BreakpointResolverName (nullptr,
-                                                                      func_names,
-                                                                      func_name_type_mask,
-                                                                      language,
-                                                                      offset,
-                                                                      skip_prologue));
-        bp_sp = CreateBreakpoint (filter_sp, resolver_sp, internal, hardware, true);
-    }
-    return bp_sp;
-}
+Target::CreateBreakpoint(const FileSpecList *containingModules,
+                         const FileSpecList *containingSourceFiles,
+                         const std::vector<std::string> &func_names,
+                         uint32_t func_name_type_mask, LanguageType language,
+                         lldb::addr_t offset, LazyBool skip_prologue,
+                         bool internal, bool hardware) {
+  BreakpointSP bp_sp;
+  size_t num_names = func_names.size();
+  if (num_names > 0) {
+    SearchFilterSP filter_sp(GetSearchFilterForModuleAndCUList(
+        containingModules, containingSourceFiles));
 
-BreakpointSP
-Target::CreateBreakpoint (const FileSpecList *containingModules,
-                          const FileSpecList *containingSourceFiles,
-                          const char *func_names[],
-                          size_t num_names, 
-                          uint32_t func_name_type_mask,
-                          LanguageType language,
-                          lldb::addr_t offset,
-                          LazyBool skip_prologue,
-                          bool internal,
-                          bool hardware)
-{
-    BreakpointSP bp_sp;
-    if (num_names > 0)
-    {
-        SearchFilterSP filter_sp(GetSearchFilterForModuleAndCUList (containingModules, containingSourceFiles));
-        
-        if (skip_prologue == eLazyBoolCalculate)
-        {
-            if (offset == 0)
-                skip_prologue = GetSkipPrologue() ? eLazyBoolYes : eLazyBoolNo;
-            else
-                skip_prologue = eLazyBoolNo;
-        }
-        if (language == lldb::eLanguageTypeUnknown)
-            language = GetLanguage();
+    if (skip_prologue == eLazyBoolCalculate)
+      skip_prologue = GetSkipPrologue() ? eLazyBoolYes : eLazyBoolNo;
+    if (language == lldb::eLanguageTypeUnknown)
+      language = GetLanguage();
+
+    BreakpointResolverSP resolver_sp(
+        new BreakpointResolverName(nullptr, func_names, func_name_type_mask,
+                                   language, offset, skip_prologue));
+    bp_sp = CreateBreakpoint(filter_sp, resolver_sp, internal, hardware, true);
+  }
+  return bp_sp;
+}
+
+BreakpointSP Target::CreateBreakpoint(
+    const FileSpecList *containingModules,
+    const FileSpecList *containingSourceFiles, const char *func_names[],
+    size_t num_names, uint32_t func_name_type_mask, LanguageType language,
+    lldb::addr_t offset, LazyBool skip_prologue, bool internal, bool hardware) {
+  BreakpointSP bp_sp;
+  if (num_names > 0) {
+    SearchFilterSP filter_sp(GetSearchFilterForModuleAndCUList(
+        containingModules, containingSourceFiles));
 
-        BreakpointResolverSP resolver_sp (new BreakpointResolverName (nullptr,
-                                                                      func_names,
-                                                                      num_names, 
-                                                                      func_name_type_mask,
-                                                                      language,
-                                                                      offset,
-                                                                      skip_prologue));
-        resolver_sp->SetOffset(offset);
-        bp_sp = CreateBreakpoint (filter_sp, resolver_sp, internal, hardware, true);
+    if (skip_prologue == eLazyBoolCalculate) {
+      if (offset == 0)
+        skip_prologue = GetSkipPrologue() ? eLazyBoolYes : eLazyBoolNo;
+      else
+        skip_prologue = eLazyBoolNo;
     }
-    return bp_sp;
-}
+    if (language == lldb::eLanguageTypeUnknown)
+      language = GetLanguage();
 
-SearchFilterSP
-Target::GetSearchFilterForModule (const FileSpec *containingModule)
-{
-    SearchFilterSP filter_sp;
-    if (containingModule != nullptr)
-    {
-        // TODO: We should look into sharing module based search filters
-        // across many breakpoints like we do for the simple target based one
-        filter_sp.reset (new SearchFilterByModule (shared_from_this(), *containingModule));
-    }
-    else
-    {
-        if (!m_search_filter_sp)
-            m_search_filter_sp.reset (new SearchFilterForUnconstrainedSearches (shared_from_this()));
-        filter_sp = m_search_filter_sp;
-    }
-    return filter_sp;
+    BreakpointResolverSP resolver_sp(new BreakpointResolverName(
+        nullptr, func_names, num_names, func_name_type_mask, language, offset,
+        skip_prologue));
+    resolver_sp->SetOffset(offset);
+    bp_sp = CreateBreakpoint(filter_sp, resolver_sp, internal, hardware, true);
+  }
+  return bp_sp;
 }
 
 SearchFilterSP
-Target::GetSearchFilterForModuleList (const FileSpecList *containingModules)
-{
-    SearchFilterSP filter_sp;
-    if (containingModules && containingModules->GetSize() != 0)
-    {
-        // TODO: We should look into sharing module based search filters
-        // across many breakpoints like we do for the simple target based one
-        filter_sp.reset (new SearchFilterByModuleList (shared_from_this(), *containingModules));
-    }
-    else
-    {
-        if (!m_search_filter_sp)
-            m_search_filter_sp.reset (new SearchFilterForUnconstrainedSearches (shared_from_this()));
-        filter_sp = m_search_filter_sp;
-    }
-    return filter_sp;
+Target::GetSearchFilterForModule(const FileSpec *containingModule) {
+  SearchFilterSP filter_sp;
+  if (containingModule != nullptr) {
+    // TODO: We should look into sharing module based search filters
+    // across many breakpoints like we do for the simple target based one
+    filter_sp.reset(
+        new SearchFilterByModule(shared_from_this(), *containingModule));
+  } else {
+    if (!m_search_filter_sp)
+      m_search_filter_sp.reset(
+          new SearchFilterForUnconstrainedSearches(shared_from_this()));
+    filter_sp = m_search_filter_sp;
+  }
+  return filter_sp;
 }
 
 SearchFilterSP
-Target::GetSearchFilterForModuleAndCUList (const FileSpecList *containingModules,
-                                           const FileSpecList *containingSourceFiles)
-{
-    if (containingSourceFiles == nullptr || containingSourceFiles->GetSize() == 0)
-        return GetSearchFilterForModuleList(containingModules);
-        
-    SearchFilterSP filter_sp;
-    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.
-        
-        filter_sp.reset (new SearchFilterByModuleListAndCU (shared_from_this(), FileSpecList(), *containingSourceFiles));
-    }
-    else
-    {
-        filter_sp.reset (new SearchFilterByModuleListAndCU (shared_from_this(), *containingModules, *containingSourceFiles));
-    }
-    return filter_sp;
-}
-
-BreakpointSP
-Target::CreateFuncRegexBreakpoint (const FileSpecList *containingModules, 
-                                   const FileSpecList *containingSourceFiles,
-                                   RegularExpression &func_regex, 
-                                   lldb::LanguageType requested_language,
-                                   LazyBool skip_prologue,
-                                   bool internal,
-                                   bool hardware)
-{
-    SearchFilterSP filter_sp(GetSearchFilterForModuleAndCUList (containingModules, containingSourceFiles));
-    bool skip =
-      (skip_prologue == eLazyBoolCalculate) ? GetSkipPrologue()
-                                            : static_cast<bool>(skip_prologue);
-    BreakpointResolverSP resolver_sp(new BreakpointResolverName (nullptr, 
-                                                                 func_regex,
-                                                                 requested_language,
-                                                                 0,
-                                                                 skip));
+Target::GetSearchFilterForModuleList(const FileSpecList *containingModules) {
+  SearchFilterSP filter_sp;
+  if (containingModules && containingModules->GetSize() != 0) {
+    // TODO: We should look into sharing module based search filters
+    // across many breakpoints like we do for the simple target based one
+    filter_sp.reset(
+        new SearchFilterByModuleList(shared_from_this(), *containingModules));
+  } else {
+    if (!m_search_filter_sp)
+      m_search_filter_sp.reset(
+          new SearchFilterForUnconstrainedSearches(shared_from_this()));
+    filter_sp = m_search_filter_sp;
+  }
+  return filter_sp;
+}
+
+SearchFilterSP Target::GetSearchFilterForModuleAndCUList(
+    const FileSpecList *containingModules,
+    const FileSpecList *containingSourceFiles) {
+  if (containingSourceFiles == nullptr || containingSourceFiles->GetSize() == 0)
+    return GetSearchFilterForModuleList(containingModules);
+
+  SearchFilterSP filter_sp;
+  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.
+
+    filter_sp.reset(new SearchFilterByModuleListAndCU(
+        shared_from_this(), FileSpecList(), *containingSourceFiles));
+  } else {
+    filter_sp.reset(new SearchFilterByModuleListAndCU(
+        shared_from_this(), *containingModules, *containingSourceFiles));
+  }
+  return filter_sp;
+}
+
+BreakpointSP Target::CreateFuncRegexBreakpoint(
+    const FileSpecList *containingModules,
+    const FileSpecList *containingSourceFiles, RegularExpression &func_regex,
+    lldb::LanguageType requested_language, LazyBool skip_prologue,
+    bool internal, bool hardware) {
+  SearchFilterSP filter_sp(GetSearchFilterForModuleAndCUList(
+      containingModules, containingSourceFiles));
+  bool skip = (skip_prologue == eLazyBoolCalculate)
+                  ? GetSkipPrologue()
+                  : static_cast<bool>(skip_prologue);
+  BreakpointResolverSP resolver_sp(new BreakpointResolverName(
+      nullptr, func_regex, requested_language, 0, skip));
 
-    return CreateBreakpoint (filter_sp, resolver_sp, internal, hardware, true);
+  return CreateBreakpoint(filter_sp, resolver_sp, internal, hardware, true);
 }
 
 lldb::BreakpointSP
-Target::CreateExceptionBreakpoint (enum lldb::LanguageType language, bool catch_bp, bool throw_bp, bool internal, Args *additional_args, Error *error)
-{
-    BreakpointSP exc_bkpt_sp = LanguageRuntime::CreateExceptionBreakpoint (*this, language, catch_bp, throw_bp, internal);
-    if (exc_bkpt_sp && additional_args)
-    {
-        Breakpoint::BreakpointPreconditionSP precondition_sp = exc_bkpt_sp->GetPrecondition();
-        if (precondition_sp && additional_args)
-        {
-            if (error)
-                *error = precondition_sp->ConfigurePrecondition(*additional_args);
-            else
-                precondition_sp->ConfigurePrecondition(*additional_args);
-        }
-    }
-    return exc_bkpt_sp;
-}
-
-BreakpointSP
-Target::CreateBreakpoint (SearchFilterSP &filter_sp, BreakpointResolverSP &resolver_sp, bool internal, bool request_hardware, bool resolve_indirect_symbols)
-{
-    BreakpointSP bp_sp;
-    if (filter_sp && resolver_sp)
-    {
-        bp_sp.reset(new Breakpoint (*this, filter_sp, resolver_sp, request_hardware, resolve_indirect_symbols));
-        resolver_sp->SetBreakpoint (bp_sp.get());
-        AddBreakpoint (bp_sp, internal);
-    }
-    return bp_sp;
-}
-
-void
-Target::AddBreakpoint (lldb::BreakpointSP bp_sp, bool internal)
-{
-    if (!bp_sp)
-        return;
-    if (internal)
-        m_internal_breakpoint_list.Add (bp_sp, false);
-    else
-        m_breakpoint_list.Add (bp_sp, true);
-
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS));
-    if (log)
-    {
-        StreamString s;
-        bp_sp->GetDescription(&s, lldb::eDescriptionLevelVerbose);
-        log->Printf ("Target::%s (internal = %s) => break_id = %s\n", __FUNCTION__, bp_sp->IsInternal() ? "yes" : "no", s.GetData());
-    }
-
-    bp_sp->ResolveBreakpoint();
-
-    if (!internal)
-    {
-        m_last_created_breakpoint = bp_sp;
-    }
-}
-
-bool
-Target::ProcessIsValid()
-{
-    return (m_process_sp && m_process_sp->IsAlive());
-}
-
-static bool
-CheckIfWatchpointsExhausted(Target *target, Error &error)
-{
-    uint32_t num_supported_hardware_watchpoints;
-    Error rc = target->GetProcessSP()->GetWatchpointSupportInfo(num_supported_hardware_watchpoints);
-    if (num_supported_hardware_watchpoints == 0)
-    {
-        error.SetErrorStringWithFormat ("Target supports (%u) hardware watchpoint slots.\n",
-                    num_supported_hardware_watchpoints);
-        return false;
-    }
-    return true;
+Target::CreateExceptionBreakpoint(enum lldb::LanguageType language,
+                                  bool catch_bp, bool throw_bp, bool internal,
+                                  Args *additional_args, Error *error) {
+  BreakpointSP exc_bkpt_sp = LanguageRuntime::CreateExceptionBreakpoint(
+      *this, language, catch_bp, throw_bp, internal);
+  if (exc_bkpt_sp && additional_args) {
+    Breakpoint::BreakpointPreconditionSP precondition_sp =
+        exc_bkpt_sp->GetPrecondition();
+    if (precondition_sp && additional_args) {
+      if (error)
+        *error = precondition_sp->ConfigurePrecondition(*additional_args);
+      else
+        precondition_sp->ConfigurePrecondition(*additional_args);
+    }
+  }
+  return exc_bkpt_sp;
+}
+
+BreakpointSP Target::CreateBreakpoint(SearchFilterSP &filter_sp,
+                                      BreakpointResolverSP &resolver_sp,
+                                      bool internal, bool request_hardware,
+                                      bool resolve_indirect_symbols) {
+  BreakpointSP bp_sp;
+  if (filter_sp && resolver_sp) {
+    bp_sp.reset(new Breakpoint(*this, filter_sp, resolver_sp, request_hardware,
+                               resolve_indirect_symbols));
+    resolver_sp->SetBreakpoint(bp_sp.get());
+    AddBreakpoint(bp_sp, internal);
+  }
+  return bp_sp;
+}
+
+void Target::AddBreakpoint(lldb::BreakpointSP bp_sp, bool internal) {
+  if (!bp_sp)
+    return;
+  if (internal)
+    m_internal_breakpoint_list.Add(bp_sp, false);
+  else
+    m_breakpoint_list.Add(bp_sp, true);
+
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
+  if (log) {
+    StreamString s;
+    bp_sp->GetDescription(&s, lldb::eDescriptionLevelVerbose);
+    log->Printf("Target::%s (internal = %s) => break_id = %s\n", __FUNCTION__,
+                bp_sp->IsInternal() ? "yes" : "no", s.GetData());
+  }
+
+  bp_sp->ResolveBreakpoint();
+
+  if (!internal) {
+    m_last_created_breakpoint = bp_sp;
+  }
+}
+
+bool Target::ProcessIsValid() {
+  return (m_process_sp && m_process_sp->IsAlive());
+}
+
+static bool CheckIfWatchpointsExhausted(Target *target, Error &error) {
+  uint32_t num_supported_hardware_watchpoints;
+  Error rc = target->GetProcessSP()->GetWatchpointSupportInfo(
+      num_supported_hardware_watchpoints);
+  if (num_supported_hardware_watchpoints == 0) {
+    error.SetErrorStringWithFormat(
+        "Target supports (%u) hardware watchpoint slots.\n",
+        num_supported_hardware_watchpoints);
+    return false;
+  }
+  return true;
 }
 
 // See also Watchpoint::SetWatchpointType(uint32_t type) and
 // the OptionGroupWatchpoint::WatchType enum type.
-WatchpointSP
-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)
-        log->Printf("Target::%s (addr = 0x%8.8" PRIx64 " size = %" PRIu64 " type = %u)\n",
-                    __FUNCTION__, addr, (uint64_t)size, kind);
-
-    WatchpointSP wp_sp;
-    if (!ProcessIsValid())
-    {
-        error.SetErrorString("process is not alive");
-        return wp_sp;
-    }
-    
-    if (addr == LLDB_INVALID_ADDRESS || size == 0)
-    {
-        if (size == 0)
-            error.SetErrorString("cannot set a watchpoint with watch_size of 0");
-        else
-            error.SetErrorStringWithFormat("invalid watch address: %" PRIu64, addr);
-        return wp_sp;
-    }
-    
-    if (!LLDB_WATCH_TYPE_IS_VALID(kind))
-    {
-        error.SetErrorStringWithFormat ("invalid watchpoint type: %d", kind);
-    }
-
-    if (!CheckIfWatchpointsExhausted (this, error))
-        return wp_sp;
-
-    // Currently we only support one watchpoint per address, with total number
-    // of watchpoints limited by the hardware which the inferior is running on.
-
-    // Grab the list mutex while doing operations.
-    const bool notify = false;   // Don't notify about all the state changes we do on creating the watchpoint.
-    std::unique_lock<std::recursive_mutex> lock;
-    this->GetWatchpointList().GetListMutex(lock);
-    WatchpointSP matched_sp = m_watchpoint_list.FindByAddress(addr);
-    if (matched_sp)
-    {
-        size_t old_size = matched_sp->GetByteSize();
-        uint32_t old_type =
-            (matched_sp->WatchpointRead() ? LLDB_WATCH_TYPE_READ : 0) |
-            (matched_sp->WatchpointWrite() ? LLDB_WATCH_TYPE_WRITE : 0);
-        // Return the existing watchpoint if both size and type match.
-        if (size == old_size && kind == old_type)
-        {
-            wp_sp = matched_sp;
-            wp_sp->SetEnabled(false, notify);
-        }
-        else
-        {
-            // Nil the matched watchpoint; we will be creating a new one.
-            m_process_sp->DisableWatchpoint(matched_sp.get(), notify);
-            m_watchpoint_list.Remove(matched_sp->GetID(), true);
-        }
-    }
-
-    if (!wp_sp) 
-    {
-        wp_sp.reset(new Watchpoint(*this, addr, size, type));
-        wp_sp->SetWatchpointType(kind, notify);
-        m_watchpoint_list.Add (wp_sp, true);
-    }
-
-    error = m_process_sp->EnableWatchpoint(wp_sp.get(), notify);
-    if (log)
-        log->Printf("Target::%s (creation of watchpoint %s with id = %u)\n",
-                    __FUNCTION__,
-                    error.Success() ? "succeeded" : "failed",
-                    wp_sp->GetID());
-
-    if (error.Fail()) 
-    {
-        // Enabling the watchpoint on the device side failed.
-        // Remove the said watchpoint from the list maintained by the target instance.
-        m_watchpoint_list.Remove (wp_sp->GetID(), true);
-        // See if we could provide more helpful error message.
-        if (!OptionGroupWatchpoint::IsWatchSizeSupported(size))
-            error.SetErrorStringWithFormat("watch size of %" PRIu64 " is not supported", (uint64_t)size);
+WatchpointSP 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)
+    log->Printf("Target::%s (addr = 0x%8.8" PRIx64 " size = %" PRIu64
+                " type = %u)\n",
+                __FUNCTION__, addr, (uint64_t)size, kind);
+
+  WatchpointSP wp_sp;
+  if (!ProcessIsValid()) {
+    error.SetErrorString("process is not alive");
+    return wp_sp;
+  }
 
-        wp_sp.reset();
-    }
+  if (addr == LLDB_INVALID_ADDRESS || size == 0) {
+    if (size == 0)
+      error.SetErrorString("cannot set a watchpoint with watch_size of 0");
     else
-        m_last_created_watchpoint = wp_sp;
+      error.SetErrorStringWithFormat("invalid watch address: %" PRIu64, addr);
     return wp_sp;
-}
-
-void
-Target::RemoveAllBreakpoints (bool internal_also)
-{
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS));
-    if (log)
-        log->Printf ("Target::%s (internal_also = %s)\n", __FUNCTION__, internal_also ? "yes" : "no");
-
-    m_breakpoint_list.RemoveAll (true);
-    if (internal_also)
-        m_internal_breakpoint_list.RemoveAll (false);
-        
-    m_last_created_breakpoint.reset();
-}
+  }
 
-void
-Target::DisableAllBreakpoints (bool internal_also)
-{
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS));
-    if (log)
-        log->Printf ("Target::%s (internal_also = %s)\n", __FUNCTION__, internal_also ? "yes" : "no");
-
-    m_breakpoint_list.SetEnabledAll (false);
-    if (internal_also)
-        m_internal_breakpoint_list.SetEnabledAll (false);
-}
+  if (!LLDB_WATCH_TYPE_IS_VALID(kind)) {
+    error.SetErrorStringWithFormat("invalid watchpoint type: %d", kind);
+  }
 
-void
-Target::EnableAllBreakpoints (bool internal_also)
-{
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS));
-    if (log)
-        log->Printf ("Target::%s (internal_also = %s)\n", __FUNCTION__, internal_also ? "yes" : "no");
-
-    m_breakpoint_list.SetEnabledAll (true);
-    if (internal_also)
-        m_internal_breakpoint_list.SetEnabledAll (true);
-}
+  if (!CheckIfWatchpointsExhausted(this, error))
+    return wp_sp;
 
-bool
-Target::RemoveBreakpointByID (break_id_t break_id)
-{
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS));
-    if (log)
-        log->Printf ("Target::%s (break_id = %i, internal = %s)\n", __FUNCTION__, break_id, LLDB_BREAK_ID_IS_INTERNAL (break_id) ? "yes" : "no");
+  // Currently we only support one watchpoint per address, with total number
+  // of watchpoints limited by the hardware which the inferior is running on.
 
-    if (DisableBreakpointByID (break_id))
-    {
-        if (LLDB_BREAK_ID_IS_INTERNAL (break_id))
-            m_internal_breakpoint_list.Remove(break_id, false);
-        else
-        {
-            if (m_last_created_breakpoint)
-            {
-                if (m_last_created_breakpoint->GetID() == break_id)
-                    m_last_created_breakpoint.reset();
-            }
-            m_breakpoint_list.Remove(break_id, true);
-        }
-        return true;
+  // Grab the list mutex while doing operations.
+  const bool notify = false; // Don't notify about all the state changes we do
+                             // on creating the watchpoint.
+  std::unique_lock<std::recursive_mutex> lock;
+  this->GetWatchpointList().GetListMutex(lock);
+  WatchpointSP matched_sp = m_watchpoint_list.FindByAddress(addr);
+  if (matched_sp) {
+    size_t old_size = matched_sp->GetByteSize();
+    uint32_t old_type =
+        (matched_sp->WatchpointRead() ? LLDB_WATCH_TYPE_READ : 0) |
+        (matched_sp->WatchpointWrite() ? LLDB_WATCH_TYPE_WRITE : 0);
+    // Return the existing watchpoint if both size and type match.
+    if (size == old_size && kind == old_type) {
+      wp_sp = matched_sp;
+      wp_sp->SetEnabled(false, notify);
+    } else {
+      // Nil the matched watchpoint; we will be creating a new one.
+      m_process_sp->DisableWatchpoint(matched_sp.get(), notify);
+      m_watchpoint_list.Remove(matched_sp->GetID(), true);
+    }
+  }
+
+  if (!wp_sp) {
+    wp_sp.reset(new Watchpoint(*this, addr, size, type));
+    wp_sp->SetWatchpointType(kind, notify);
+    m_watchpoint_list.Add(wp_sp, true);
+  }
+
+  error = m_process_sp->EnableWatchpoint(wp_sp.get(), notify);
+  if (log)
+    log->Printf("Target::%s (creation of watchpoint %s with id = %u)\n",
+                __FUNCTION__, error.Success() ? "succeeded" : "failed",
+                wp_sp->GetID());
+
+  if (error.Fail()) {
+    // Enabling the watchpoint on the device side failed.
+    // Remove the said watchpoint from the list maintained by the target
+    // instance.
+    m_watchpoint_list.Remove(wp_sp->GetID(), true);
+    // See if we could provide more helpful error message.
+    if (!OptionGroupWatchpoint::IsWatchSizeSupported(size))
+      error.SetErrorStringWithFormat(
+          "watch size of %" PRIu64 " is not supported", (uint64_t)size);
+
+    wp_sp.reset();
+  } else
+    m_last_created_watchpoint = wp_sp;
+  return wp_sp;
+}
+
+void Target::RemoveAllBreakpoints(bool internal_also) {
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
+  if (log)
+    log->Printf("Target::%s (internal_also = %s)\n", __FUNCTION__,
+                internal_also ? "yes" : "no");
+
+  m_breakpoint_list.RemoveAll(true);
+  if (internal_also)
+    m_internal_breakpoint_list.RemoveAll(false);
+
+  m_last_created_breakpoint.reset();
+}
+
+void Target::DisableAllBreakpoints(bool internal_also) {
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
+  if (log)
+    log->Printf("Target::%s (internal_also = %s)\n", __FUNCTION__,
+                internal_also ? "yes" : "no");
+
+  m_breakpoint_list.SetEnabledAll(false);
+  if (internal_also)
+    m_internal_breakpoint_list.SetEnabledAll(false);
+}
+
+void Target::EnableAllBreakpoints(bool internal_also) {
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
+  if (log)
+    log->Printf("Target::%s (internal_also = %s)\n", __FUNCTION__,
+                internal_also ? "yes" : "no");
+
+  m_breakpoint_list.SetEnabledAll(true);
+  if (internal_also)
+    m_internal_breakpoint_list.SetEnabledAll(true);
+}
+
+bool Target::RemoveBreakpointByID(break_id_t break_id) {
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
+  if (log)
+    log->Printf("Target::%s (break_id = %i, internal = %s)\n", __FUNCTION__,
+                break_id, LLDB_BREAK_ID_IS_INTERNAL(break_id) ? "yes" : "no");
+
+  if (DisableBreakpointByID(break_id)) {
+    if (LLDB_BREAK_ID_IS_INTERNAL(break_id))
+      m_internal_breakpoint_list.Remove(break_id, false);
+    else {
+      if (m_last_created_breakpoint) {
+        if (m_last_created_breakpoint->GetID() == break_id)
+          m_last_created_breakpoint.reset();
+      }
+      m_breakpoint_list.Remove(break_id, true);
     }
-    return false;
+    return true;
+  }
+  return false;
 }
 
-bool
-Target::DisableBreakpointByID (break_id_t break_id)
-{
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS));
-    if (log)
-        log->Printf ("Target::%s (break_id = %i, internal = %s)\n", __FUNCTION__, break_id, LLDB_BREAK_ID_IS_INTERNAL (break_id) ? "yes" : "no");
-
-    BreakpointSP bp_sp;
-
-    if (LLDB_BREAK_ID_IS_INTERNAL (break_id))
-        bp_sp = m_internal_breakpoint_list.FindBreakpointByID (break_id);
-    else
-        bp_sp = m_breakpoint_list.FindBreakpointByID (break_id);
-    if (bp_sp)
-    {
-        bp_sp->SetEnabled (false);
-        return true;
-    }
-    return false;
+bool Target::DisableBreakpointByID(break_id_t break_id) {
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
+  if (log)
+    log->Printf("Target::%s (break_id = %i, internal = %s)\n", __FUNCTION__,
+                break_id, LLDB_BREAK_ID_IS_INTERNAL(break_id) ? "yes" : "no");
+
+  BreakpointSP bp_sp;
+
+  if (LLDB_BREAK_ID_IS_INTERNAL(break_id))
+    bp_sp = m_internal_breakpoint_list.FindBreakpointByID(break_id);
+  else
+    bp_sp = m_breakpoint_list.FindBreakpointByID(break_id);
+  if (bp_sp) {
+    bp_sp->SetEnabled(false);
+    return true;
+  }
+  return false;
 }
 
-bool
-Target::EnableBreakpointByID (break_id_t break_id)
-{
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS));
-    if (log)
-        log->Printf ("Target::%s (break_id = %i, internal = %s)\n",
-                     __FUNCTION__,
-                     break_id,
-                     LLDB_BREAK_ID_IS_INTERNAL (break_id) ? "yes" : "no");
+bool Target::EnableBreakpointByID(break_id_t break_id) {
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
+  if (log)
+    log->Printf("Target::%s (break_id = %i, internal = %s)\n", __FUNCTION__,
+                break_id, LLDB_BREAK_ID_IS_INTERNAL(break_id) ? "yes" : "no");
 
-    BreakpointSP bp_sp;
+  BreakpointSP bp_sp;
 
-    if (LLDB_BREAK_ID_IS_INTERNAL (break_id))
-        bp_sp = m_internal_breakpoint_list.FindBreakpointByID (break_id);
-    else
-        bp_sp = m_breakpoint_list.FindBreakpointByID (break_id);
+  if (LLDB_BREAK_ID_IS_INTERNAL(break_id))
+    bp_sp = m_internal_breakpoint_list.FindBreakpointByID(break_id);
+  else
+    bp_sp = m_breakpoint_list.FindBreakpointByID(break_id);
 
-    if (bp_sp)
-    {
-        bp_sp->SetEnabled (true);
-        return true;
-    }
-    return false;
+  if (bp_sp) {
+    bp_sp->SetEnabled(true);
+    return true;
+  }
+  return false;
 }
 
 // The flag 'end_to_end', default to true, signifies that the operation is
@@ -924,3404 +799,3162 @@ Target::EnableBreakpointByID (break_id_t
 
 // Assumption: Caller holds the list mutex lock for m_watchpoint_list for end
 // to end operations.
-bool
-Target::RemoveAllWatchpoints (bool end_to_end)
-{
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_WATCHPOINTS));
-    if (log)
-        log->Printf ("Target::%s\n", __FUNCTION__);
+bool Target::RemoveAllWatchpoints(bool end_to_end) {
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
+  if (log)
+    log->Printf("Target::%s\n", __FUNCTION__);
 
-    if (!end_to_end) {
-        m_watchpoint_list.RemoveAll(true);
-        return true;
-    }
-
-    // Otherwise, it's an end to end operation.
+  if (!end_to_end) {
+    m_watchpoint_list.RemoveAll(true);
+    return true;
+  }
 
-    if (!ProcessIsValid())
-        return false;
+  // Otherwise, it's an end to end operation.
 
-    size_t num_watchpoints = m_watchpoint_list.GetSize();
-    for (size_t i = 0; i < num_watchpoints; ++i)
-    {
-        WatchpointSP wp_sp = m_watchpoint_list.GetByIndex(i);
-        if (!wp_sp)
-            return false;
+  if (!ProcessIsValid())
+    return false;
 
-        Error rc = m_process_sp->DisableWatchpoint(wp_sp.get());
-        if (rc.Fail())
-            return false;
-    }
-    m_watchpoint_list.RemoveAll (true);
-    m_last_created_watchpoint.reset();
-    return true; // Success!
+  size_t num_watchpoints = m_watchpoint_list.GetSize();
+  for (size_t i = 0; i < num_watchpoints; ++i) {
+    WatchpointSP wp_sp = m_watchpoint_list.GetByIndex(i);
+    if (!wp_sp)
+      return false;
+
+    Error rc = m_process_sp->DisableWatchpoint(wp_sp.get());
+    if (rc.Fail())
+      return false;
+  }
+  m_watchpoint_list.RemoveAll(true);
+  m_last_created_watchpoint.reset();
+  return true; // Success!
 }
 
 // Assumption: Caller holds the list mutex lock for m_watchpoint_list for end to
 // end operations.
-bool
-Target::DisableAllWatchpoints (bool end_to_end)
-{
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_WATCHPOINTS));
-    if (log)
-        log->Printf ("Target::%s\n", __FUNCTION__);
+bool Target::DisableAllWatchpoints(bool end_to_end) {
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
+  if (log)
+    log->Printf("Target::%s\n", __FUNCTION__);
 
-    if (!end_to_end) {
-        m_watchpoint_list.SetEnabledAll(false);
-        return true;
-    }
-
-    // Otherwise, it's an end to end operation.
+  if (!end_to_end) {
+    m_watchpoint_list.SetEnabledAll(false);
+    return true;
+  }
 
-    if (!ProcessIsValid())
-        return false;
+  // Otherwise, it's an end to end operation.
 
-    size_t num_watchpoints = m_watchpoint_list.GetSize();
-    for (size_t i = 0; i < num_watchpoints; ++i)
-    {
-        WatchpointSP wp_sp = m_watchpoint_list.GetByIndex(i);
-        if (!wp_sp)
-            return false;
+  if (!ProcessIsValid())
+    return false;
 
-        Error rc = m_process_sp->DisableWatchpoint(wp_sp.get());
-        if (rc.Fail())
-            return false;
-    }
-    return true; // Success!
+  size_t num_watchpoints = m_watchpoint_list.GetSize();
+  for (size_t i = 0; i < num_watchpoints; ++i) {
+    WatchpointSP wp_sp = m_watchpoint_list.GetByIndex(i);
+    if (!wp_sp)
+      return false;
+
+    Error rc = m_process_sp->DisableWatchpoint(wp_sp.get());
+    if (rc.Fail())
+      return false;
+  }
+  return true; // Success!
 }
 
 // Assumption: Caller holds the list mutex lock for m_watchpoint_list for end to
 // end operations.
-bool
-Target::EnableAllWatchpoints (bool end_to_end)
-{
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_WATCHPOINTS));
-    if (log)
-        log->Printf ("Target::%s\n", __FUNCTION__);
-
-    if (!end_to_end) {
-        m_watchpoint_list.SetEnabledAll(true);
-        return true;
-    }
+bool Target::EnableAllWatchpoints(bool end_to_end) {
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
+  if (log)
+    log->Printf("Target::%s\n", __FUNCTION__);
 
-    // Otherwise, it's an end to end operation.
+  if (!end_to_end) {
+    m_watchpoint_list.SetEnabledAll(true);
+    return true;
+  }
 
-    if (!ProcessIsValid())
-        return false;
+  // Otherwise, it's an end to end operation.
 
-    size_t num_watchpoints = m_watchpoint_list.GetSize();
-    for (size_t i = 0; i < num_watchpoints; ++i)
-    {
-        WatchpointSP wp_sp = m_watchpoint_list.GetByIndex(i);
-        if (!wp_sp)
-            return false;
+  if (!ProcessIsValid())
+    return false;
 
-        Error rc = m_process_sp->EnableWatchpoint(wp_sp.get());
-        if (rc.Fail())
-            return false;
-    }
-    return true; // Success!
+  size_t num_watchpoints = m_watchpoint_list.GetSize();
+  for (size_t i = 0; i < num_watchpoints; ++i) {
+    WatchpointSP wp_sp = m_watchpoint_list.GetByIndex(i);
+    if (!wp_sp)
+      return false;
+
+    Error rc = m_process_sp->EnableWatchpoint(wp_sp.get());
+    if (rc.Fail())
+      return false;
+  }
+  return true; // Success!
 }
 
 // Assumption: Caller holds the list mutex lock for m_watchpoint_list.
-bool
-Target::ClearAllWatchpointHitCounts ()
-{
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_WATCHPOINTS));
-    if (log)
-        log->Printf ("Target::%s\n", __FUNCTION__);
-
-    size_t num_watchpoints = m_watchpoint_list.GetSize();
-    for (size_t i = 0; i < num_watchpoints; ++i)
-    {
-        WatchpointSP wp_sp = m_watchpoint_list.GetByIndex(i);
-        if (!wp_sp)
-            return false;
-
-        wp_sp->ResetHitCount();
-    }
-    return true; // Success!
+bool Target::ClearAllWatchpointHitCounts() {
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
+  if (log)
+    log->Printf("Target::%s\n", __FUNCTION__);
+
+  size_t num_watchpoints = m_watchpoint_list.GetSize();
+  for (size_t i = 0; i < num_watchpoints; ++i) {
+    WatchpointSP wp_sp = m_watchpoint_list.GetByIndex(i);
+    if (!wp_sp)
+      return false;
+
+    wp_sp->ResetHitCount();
+  }
+  return true; // Success!
 }
 
 // Assumption: Caller holds the list mutex lock for m_watchpoint_list.
-bool
-Target::ClearAllWatchpointHistoricValues ()
-{
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_WATCHPOINTS));
-    if (log)
-        log->Printf ("Target::%s\n", __FUNCTION__);
-    
-    size_t num_watchpoints = m_watchpoint_list.GetSize();
-    for (size_t i = 0; i < num_watchpoints; ++i)
-    {
-        WatchpointSP wp_sp = m_watchpoint_list.GetByIndex(i);
-        if (!wp_sp)
-            return false;
-        
-        wp_sp->ResetHistoricValues();
-    }
-    return true; // Success!
+bool Target::ClearAllWatchpointHistoricValues() {
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
+  if (log)
+    log->Printf("Target::%s\n", __FUNCTION__);
+
+  size_t num_watchpoints = m_watchpoint_list.GetSize();
+  for (size_t i = 0; i < num_watchpoints; ++i) {
+    WatchpointSP wp_sp = m_watchpoint_list.GetByIndex(i);
+    if (!wp_sp)
+      return false;
+
+    wp_sp->ResetHistoricValues();
+  }
+  return true; // Success!
 }
 
 // Assumption: Caller holds the list mutex lock for m_watchpoint_list
 // during these operations.
-bool
-Target::IgnoreAllWatchpoints (uint32_t ignore_count)
-{
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_WATCHPOINTS));
-    if (log)
-        log->Printf ("Target::%s\n", __FUNCTION__);
+bool Target::IgnoreAllWatchpoints(uint32_t ignore_count) {
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
+  if (log)
+    log->Printf("Target::%s\n", __FUNCTION__);
 
-    if (!ProcessIsValid())
-        return false;
-
-    size_t num_watchpoints = m_watchpoint_list.GetSize();
-    for (size_t i = 0; i < num_watchpoints; ++i)
-    {
-        WatchpointSP wp_sp = m_watchpoint_list.GetByIndex(i);
-        if (!wp_sp)
-            return false;
+  if (!ProcessIsValid())
+    return false;
 
-        wp_sp->SetIgnoreCount(ignore_count);
-    }
-    return true; // Success!
+  size_t num_watchpoints = m_watchpoint_list.GetSize();
+  for (size_t i = 0; i < num_watchpoints; ++i) {
+    WatchpointSP wp_sp = m_watchpoint_list.GetByIndex(i);
+    if (!wp_sp)
+      return false;
+
+    wp_sp->SetIgnoreCount(ignore_count);
+  }
+  return true; // Success!
 }
 
 // Assumption: Caller holds the list mutex lock for m_watchpoint_list.
-bool
-Target::DisableWatchpointByID (lldb::watch_id_t watch_id)
-{
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_WATCHPOINTS));
-    if (log)
-        log->Printf ("Target::%s (watch_id = %i)\n", __FUNCTION__, watch_id);
-
-    if (!ProcessIsValid())
-        return false;
+bool Target::DisableWatchpointByID(lldb::watch_id_t watch_id) {
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
+  if (log)
+    log->Printf("Target::%s (watch_id = %i)\n", __FUNCTION__, watch_id);
 
-    WatchpointSP wp_sp = m_watchpoint_list.FindByID (watch_id);
-    if (wp_sp)
-    {
-        Error rc = m_process_sp->DisableWatchpoint(wp_sp.get());
-        if (rc.Success())
-            return true;
-
-        // Else, fallthrough.
-    }
+  if (!ProcessIsValid())
     return false;
+
+  WatchpointSP wp_sp = m_watchpoint_list.FindByID(watch_id);
+  if (wp_sp) {
+    Error rc = m_process_sp->DisableWatchpoint(wp_sp.get());
+    if (rc.Success())
+      return true;
+
+    // Else, fallthrough.
+  }
+  return false;
 }
 
 // Assumption: Caller holds the list mutex lock for m_watchpoint_list.
-bool
-Target::EnableWatchpointByID (lldb::watch_id_t watch_id)
-{
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_WATCHPOINTS));
-    if (log)
-        log->Printf ("Target::%s (watch_id = %i)\n", __FUNCTION__, watch_id);
-
-    if (!ProcessIsValid())
-        return false;
+bool Target::EnableWatchpointByID(lldb::watch_id_t watch_id) {
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
+  if (log)
+    log->Printf("Target::%s (watch_id = %i)\n", __FUNCTION__, watch_id);
 
-    WatchpointSP wp_sp = m_watchpoint_list.FindByID (watch_id);
-    if (wp_sp)
-    {
-        Error rc = m_process_sp->EnableWatchpoint(wp_sp.get());
-        if (rc.Success())
-            return true;
-
-        // Else, fallthrough.
-    }
+  if (!ProcessIsValid())
     return false;
+
+  WatchpointSP wp_sp = m_watchpoint_list.FindByID(watch_id);
+  if (wp_sp) {
+    Error rc = m_process_sp->EnableWatchpoint(wp_sp.get());
+    if (rc.Success())
+      return true;
+
+    // Else, fallthrough.
+  }
+  return false;
 }
 
 // Assumption: Caller holds the list mutex lock for m_watchpoint_list.
-bool
-Target::RemoveWatchpointByID (lldb::watch_id_t watch_id)
-{
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_WATCHPOINTS));
-    if (log)
-        log->Printf ("Target::%s (watch_id = %i)\n", __FUNCTION__, watch_id);
+bool Target::RemoveWatchpointByID(lldb::watch_id_t watch_id) {
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
+  if (log)
+    log->Printf("Target::%s (watch_id = %i)\n", __FUNCTION__, watch_id);
 
-    WatchpointSP watch_to_remove_sp = m_watchpoint_list.FindByID(watch_id);
-    if (watch_to_remove_sp == m_last_created_watchpoint)
-        m_last_created_watchpoint.reset();
-        
-    if (DisableWatchpointByID (watch_id))
-    {
-        m_watchpoint_list.Remove(watch_id, true);
-        return true;
-    }
-    return false;
+  WatchpointSP watch_to_remove_sp = m_watchpoint_list.FindByID(watch_id);
+  if (watch_to_remove_sp == m_last_created_watchpoint)
+    m_last_created_watchpoint.reset();
+
+  if (DisableWatchpointByID(watch_id)) {
+    m_watchpoint_list.Remove(watch_id, true);
+    return true;
+  }
+  return false;
 }
 
 // Assumption: Caller holds the list mutex lock for m_watchpoint_list.
-bool
-Target::IgnoreWatchpointByID (lldb::watch_id_t watch_id, uint32_t ignore_count)
-{
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_WATCHPOINTS));
-    if (log)
-        log->Printf ("Target::%s (watch_id = %i)\n", __FUNCTION__, watch_id);
+bool Target::IgnoreWatchpointByID(lldb::watch_id_t watch_id,
+                                  uint32_t ignore_count) {
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
+  if (log)
+    log->Printf("Target::%s (watch_id = %i)\n", __FUNCTION__, watch_id);
 
-    if (!ProcessIsValid())
-        return false;
-
-    WatchpointSP wp_sp = m_watchpoint_list.FindByID (watch_id);
-    if (wp_sp)
-    {
-        wp_sp->SetIgnoreCount(ignore_count);
-        return true;
-    }
+  if (!ProcessIsValid())
     return false;
-}
 
-ModuleSP
-Target::GetExecutableModule ()
-{
-    // search for the first executable in the module list
-    for (size_t i = 0; i < m_images.GetSize(); ++i)
-    {
-        ModuleSP module_sp = m_images.GetModuleAtIndex (i);
-        lldb_private::ObjectFile * obj = module_sp->GetObjectFile();
-        if (obj == nullptr)
-            continue;
-        if (obj->GetType() == ObjectFile::Type::eTypeExecutable)
-            return module_sp;
-    }
-    // as fall back return the first module loaded
-    return m_images.GetModuleAtIndex (0);
-}
-
-Module*
-Target::GetExecutableModulePointer ()
-{
-    return GetExecutableModule().get();
-}
-
-static void
-LoadScriptingResourceForModule (const ModuleSP &module_sp, Target *target)
-{
-    Error error;
-    StreamString feedback_stream;
-    if (module_sp && !module_sp->LoadScriptingResourceInTarget(target, error, &feedback_stream))
-    {
-        if (error.AsCString())
-            target->GetDebugger().GetErrorFile()->Printf("unable to load scripting data for module %s - error reported was %s\n",
-                                                           module_sp->GetFileSpec().GetFileNameStrippingExtension().GetCString(),
-                                                           error.AsCString());
-    }
-    if (feedback_stream.GetSize())
-        target->GetDebugger().GetErrorFile()->Printf("%s\n",
-                                                     feedback_stream.GetData());
-}
-
-void
-Target::ClearModules(bool delete_locations)
-{
-    ModulesDidUnload (m_images, delete_locations);
-    m_section_load_history.Clear();
-    m_images.Clear();
-    m_scratch_type_system_map.Clear();
-    m_ast_importer_sp.reset();
-}
-
-void
-Target::DidExec ()
-{
-    // When a process exec's we need to know about it so we can do some cleanup. 
-    m_breakpoint_list.RemoveInvalidLocations(m_arch);
-    m_internal_breakpoint_list.RemoveInvalidLocations(m_arch);
-}
-
-void
-Target::SetExecutableModule (ModuleSP& executable_sp, bool get_dependent_files)
-{
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TARGET));
-    ClearModules(false);
-    
-    if (executable_sp)
-    {
-        Timer scoped_timer (LLVM_PRETTY_FUNCTION,
-                            "Target::SetExecutableModule (executable = '%s')",
-                            executable_sp->GetFileSpec().GetPath().c_str());
-
-        m_images.Append(executable_sp); // The first image is our executable file
-
-        // If we haven't set an architecture yet, reset our architecture based on what we found in the executable module.
-        if (!m_arch.IsValid())
-        {
-            m_arch = executable_sp->GetArchitecture();
-            if (log)
-              log->Printf ("Target::SetExecutableModule setting architecture to %s (%s) based on executable file", m_arch.GetArchitectureName(), m_arch.GetTriple().getTriple().c_str());
-        }
-
-        FileSpecList dependent_files;
-        ObjectFile *executable_objfile = executable_sp->GetObjectFile();
-
-        if (executable_objfile && get_dependent_files)
-        {
-            executable_objfile->GetDependentModules(dependent_files);
-            for (uint32_t i=0; i<dependent_files.GetSize(); i++)
-            {
-                FileSpec dependent_file_spec (dependent_files.GetFileSpecPointerAtIndex(i));
-                FileSpec platform_dependent_file_spec;
-                if (m_platform_sp)
-                    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)
-                {
-                    ObjectFile *objfile = image_module_sp->GetObjectFile();
-                    if (objfile)
-                        objfile->GetDependentModules(dependent_files);
-                }
-            }
-        }
-    }
-}
-
-bool
-Target::SetArchitecture (const ArchSpec &arch_spec)
-{
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TARGET));
-    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 && !env_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
-        // 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 set architecture to %s (%s)", m_arch.GetArchitectureName(), m_arch.GetTriple().getTriple().c_str());
-        return true;
-    }
-    
-    // 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 (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(), other);
-        Error error = ModuleList::GetSharedModule(module_spec, 
-                                                  executable_sp, 
-                                                  &GetExecutableSearchPaths(),
-                                                  nullptr, 
-                                                  nullptr);
-                                      
-        if (!error.Fail() && executable_sp)
-        {
-            SetExecutableModule (executable_sp, true);
-            return true;
-        }
-    }
-    return false;
-}
-
-bool
-Target::MergeArchitecture (const ArchSpec &arch_spec)
-{
-    if (arch_spec.IsValid())
-    {
-        if (m_arch.IsCompatibleMatch(arch_spec))
-        {
-            // The current target arch is compatible with "arch_spec", see if we
-            // can improve our current architecture using bits from "arch_spec"
-
-            // Merge bits from arch_spec into "merged_arch" and set our architecture
-            ArchSpec merged_arch (m_arch);
-            merged_arch.MergeFrom (arch_spec);
-            return SetArchitecture(merged_arch);
-        }
-        else
-        {
-            // The new architecture is different, we just need to replace it
-            return SetArchitecture(arch_spec);
-        }
-    }
-    return false;
-}
-
-void
-Target::WillClearList (const ModuleList& module_list)
-{
-}
-
-void
-Target::ModuleAdded (const ModuleList& module_list, const ModuleSP &module_sp)
-{
-    // A module is being added to this target for the first time
-    if (m_valid)
-    {
-        ModuleList my_module_list;
-        my_module_list.Append(module_sp);
-        LoadScriptingResourceForModule(module_sp, this);
-        ModulesDidLoad (my_module_list);
-    }
-}
-
-void
-Target::ModuleRemoved (const ModuleList& module_list, const ModuleSP &module_sp)
-{
-    // A module is being removed from this target.
-    if (m_valid)
-    {
-        ModuleList my_module_list;
-        my_module_list.Append(module_sp);
-        ModulesDidUnload (my_module_list, false);
-    }
-}
-
-void
-Target::ModuleUpdated (const ModuleList& module_list, const ModuleSP &old_module_sp, const ModuleSP &new_module_sp)
-{
-    // 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
-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);
-        }
-        BroadcastEvent (eBroadcastBitModulesLoaded, new TargetEventData (this->shared_from_this(), module_list));
-    }
-}
-
-void
-Target::SymbolsDidLoad (ModuleList &module_list)
-{
-    if (m_valid && module_list.GetSize())
-    {
-        if (m_process_sp)
-        {
-            LanguageRuntime* runtime = m_process_sp->GetLanguageRuntime(lldb::eLanguageTypeObjC);
-            if (runtime)
-            {
-                ObjCLanguageRuntime *objc_runtime = (ObjCLanguageRuntime*)runtime;
-                objc_runtime->SymbolsDidLoad(module_list);
-            }
-        }
-        
-        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));
-    }
-}
-
-void
-Target::ModulesDidUnload (ModuleList &module_list, bool delete_locations)
-{
-    if (m_valid && module_list.GetSize())
-    {
-        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));
-    }
-}
-
-bool
-Target::ModuleIsExcludedForUnconstrainedSearches (const FileSpec &module_file_spec)
-{
-    if (GetBreakpointsConsultPlatformAvoidList())
-    {
-        ModuleList matchingModules;
-        ModuleSpec module_spec (module_file_spec);
-        size_t num_modules = GetImages().FindModules(module_spec, matchingModules);
-        
-        // If there is more than one module for this file spec, only return true if ALL the modules are on the
-        // black list.
-        if (num_modules > 0)
-        {
-            for (size_t i  = 0; i < num_modules; i++)
-            {
-                if (!ModuleIsExcludedForUnconstrainedSearches (matchingModules.GetModuleAtIndex(i)))
-                    return false;
-            }
-            return true;
-        }
-    }
-    return false;
+  WatchpointSP wp_sp = m_watchpoint_list.FindByID(watch_id);
+  if (wp_sp) {
+    wp_sp->SetIgnoreCount(ignore_count);
+    return true;
+  }
+  return false;
 }
 
-bool
-Target::ModuleIsExcludedForUnconstrainedSearches (const lldb::ModuleSP &module_sp)
-{
-    if (GetBreakpointsConsultPlatformAvoidList())
-    {
+ModuleSP Target::GetExecutableModule() {
+  // search for the first executable in the module list
+  for (size_t i = 0; i < m_images.GetSize(); ++i) {
+    ModuleSP module_sp = m_images.GetModuleAtIndex(i);
+    lldb_private::ObjectFile *obj = module_sp->GetObjectFile();
+    if (obj == nullptr)
+      continue;
+    if (obj->GetType() == ObjectFile::Type::eTypeExecutable)
+      return module_sp;
+  }
+  // as fall back return the first module loaded
+  return m_images.GetModuleAtIndex(0);
+}
+
+Module *Target::GetExecutableModulePointer() {
+  return GetExecutableModule().get();
+}
+
+static void LoadScriptingResourceForModule(const ModuleSP &module_sp,
+                                           Target *target) {
+  Error error;
+  StreamString feedback_stream;
+  if (module_sp &&
+      !module_sp->LoadScriptingResourceInTarget(target, error,
+                                                &feedback_stream)) {
+    if (error.AsCString())
+      target->GetDebugger().GetErrorFile()->Printf(
+          "unable to load scripting data for module %s - error reported was "
+          "%s\n",
+          module_sp->GetFileSpec().GetFileNameStrippingExtension().GetCString(),
+          error.AsCString());
+  }
+  if (feedback_stream.GetSize())
+    target->GetDebugger().GetErrorFile()->Printf("%s\n",
+                                                 feedback_stream.GetData());
+}
+
+void Target::ClearModules(bool delete_locations) {
+  ModulesDidUnload(m_images, delete_locations);
+  m_section_load_history.Clear();
+  m_images.Clear();
+  m_scratch_type_system_map.Clear();
+  m_ast_importer_sp.reset();
+}
+
+void Target::DidExec() {
+  // When a process exec's we need to know about it so we can do some cleanup.
+  m_breakpoint_list.RemoveInvalidLocations(m_arch);
+  m_internal_breakpoint_list.RemoveInvalidLocations(m_arch);
+}
+
+void Target::SetExecutableModule(ModuleSP &executable_sp,
+                                 bool get_dependent_files) {
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_TARGET));
+  ClearModules(false);
+
+  if (executable_sp) {
+    Timer scoped_timer(LLVM_PRETTY_FUNCTION,
+                       "Target::SetExecutableModule (executable = '%s')",
+                       executable_sp->GetFileSpec().GetPath().c_str());
+
+    m_images.Append(executable_sp); // The first image is our executable file
+
+    // If we haven't set an architecture yet, reset our architecture based on
+    // what we found in the executable module.
+    if (!m_arch.IsValid()) {
+      m_arch = executable_sp->GetArchitecture();
+      if (log)
+        log->Printf("Target::SetExecutableModule setting architecture to %s "
+                    "(%s) based on executable file",
+                    m_arch.GetArchitectureName(),
+                    m_arch.GetTriple().getTriple().c_str());
+    }
+
+    FileSpecList dependent_files;
+    ObjectFile *executable_objfile = executable_sp->GetObjectFile();
+
+    if (executable_objfile && get_dependent_files) {
+      executable_objfile->GetDependentModules(dependent_files);
+      for (uint32_t i = 0; i < dependent_files.GetSize(); i++) {
+        FileSpec dependent_file_spec(
+            dependent_files.GetFileSpecPointerAtIndex(i));
+        FileSpec platform_dependent_file_spec;
         if (m_platform_sp)
-            return m_platform_sp->ModuleIsExcludedForUnconstrainedSearches (*this, module_sp);
-    }
-    return false;
-}
-
-size_t
-Target::ReadMemoryFromFileCache (const Address& addr, void *dst, size_t dst_len, Error &error)
-{
-    SectionSP section_sp (addr.GetSection());
-    if (section_sp)
-    {
-        // If the contents of this section are encrypted, the on-disk file is unusable.  Read only from live memory.
-        if (section_sp->IsEncrypted())
-        {
-            error.SetErrorString("section is encrypted");
-            return 0;
-        }
-        ModuleSP module_sp (section_sp->GetModule());
-        if (module_sp)
-        {
-            ObjectFile *objfile = section_sp->GetModule()->GetObjectFile();
-            if (objfile)
-            {
-                size_t bytes_read = objfile->ReadSectionData (section_sp.get(), 
-                                                              addr.GetOffset(), 
-                                                              dst, 
-                                                              dst_len);
-                if (bytes_read > 0)
-                    return bytes_read;
-                else
-                    error.SetErrorStringWithFormat("error reading data from section %s", section_sp->GetName().GetCString());
-            }
-            else
-                error.SetErrorString("address isn't from a object file");
-        }
+          m_platform_sp->GetFileWithUUID(dependent_file_spec, nullptr,
+                                         platform_dependent_file_spec);
         else
-            error.SetErrorString("address isn't in a module");
-    }
-    else
-        error.SetErrorString("address doesn't contain a section that points to a section in a object file");
-
-    return 0;
-}
-
-size_t
-Target::ReadMemory (const Address& addr,
-                    bool prefer_file_cache,
-                    void *dst,
-                    size_t dst_len,
-                    Error &error,
-                    lldb::addr_t *load_addr_ptr)
-{
-    error.Clear();
-    
-    // if we end up reading this from process memory, we will fill this
-    // with the actual load address
-    if (load_addr_ptr)
-        *load_addr_ptr = LLDB_INVALID_ADDRESS;
-    
-    size_t bytes_read = 0;
+          platform_dependent_file_spec = dependent_file_spec;
 
-    addr_t load_addr = LLDB_INVALID_ADDRESS;
-    addr_t file_addr = LLDB_INVALID_ADDRESS;
-    Address resolved_addr;
-    if (!addr.IsSectionOffset())
-    {
-        SectionLoadList &section_load_list = GetSectionLoadList();
-        if (section_load_list.IsEmpty())
-        {
-            // No sections are loaded, so we must assume we are not running
-            // yet and anything we are given is a file address.
-            file_addr = addr.GetOffset(); // "addr" doesn't have a section, so its offset is the file address
-            m_images.ResolveFileAddress (file_addr, resolved_addr);            
-        }
-        else
-        {
-            // We have at least one section loaded. This can be because
-            // we have manually loaded some sections with "target modules load ..."
-            // or because we have have a live process that has sections loaded
-            // through the dynamic loader
-            load_addr = addr.GetOffset(); // "addr" doesn't have a section, so its offset is the load address
-            section_load_list.ResolveLoadAddress (load_addr, resolved_addr);
-        }
-    }
-    if (!resolved_addr.IsValid())
-        resolved_addr = addr;
+        ModuleSpec module_spec(platform_dependent_file_spec, m_arch);
+        ModuleSP image_module_sp(GetSharedModule(module_spec));
+        if (image_module_sp) {
+          ObjectFile *objfile = image_module_sp->GetObjectFile();
+          if (objfile)
+            objfile->GetDependentModules(dependent_files);
+        }
+      }
+    }
+  }
+}
+
+bool Target::SetArchitecture(const ArchSpec &arch_spec) {
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_TARGET));
+  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 && !env_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
+    // 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 set architecture to %s (%s)",
+                  m_arch.GetArchitectureName(),
+                  m_arch.GetTriple().getTriple().c_str());
+    return true;
+  }
 
-    if (prefer_file_cache)
-    {
-        bytes_read = ReadMemoryFromFileCache (resolved_addr, dst, dst_len, error);
+  // 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 (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(), other);
+    Error error = ModuleList::GetSharedModule(module_spec, executable_sp,
+                                              &GetExecutableSearchPaths(),
+                                              nullptr, nullptr);
+
+    if (!error.Fail() && executable_sp) {
+      SetExecutableModule(executable_sp, true);
+      return true;
+    }
+  }
+  return false;
+}
+
+bool Target::MergeArchitecture(const ArchSpec &arch_spec) {
+  if (arch_spec.IsValid()) {
+    if (m_arch.IsCompatibleMatch(arch_spec)) {
+      // The current target arch is compatible with "arch_spec", see if we
+      // can improve our current architecture using bits from "arch_spec"
+
+      // Merge bits from arch_spec into "merged_arch" and set our architecture
+      ArchSpec merged_arch(m_arch);
+      merged_arch.MergeFrom(arch_spec);
+      return SetArchitecture(merged_arch);
+    } else {
+      // The new architecture is different, we just need to replace it
+      return SetArchitecture(arch_spec);
+    }
+  }
+  return false;
+}
+
+void Target::WillClearList(const ModuleList &module_list) {}
+
+void Target::ModuleAdded(const ModuleList &module_list,
+                         const ModuleSP &module_sp) {
+  // A module is being added to this target for the first time
+  if (m_valid) {
+    ModuleList my_module_list;
+    my_module_list.Append(module_sp);
+    LoadScriptingResourceForModule(module_sp, this);
+    ModulesDidLoad(my_module_list);
+  }
+}
+
+void Target::ModuleRemoved(const ModuleList &module_list,
+                           const ModuleSP &module_sp) {
+  // A module is being removed from this target.
+  if (m_valid) {
+    ModuleList my_module_list;
+    my_module_list.Append(module_sp);
+    ModulesDidUnload(my_module_list, false);
+  }
+}
+
+void Target::ModuleUpdated(const ModuleList &module_list,
+                           const ModuleSP &old_module_sp,
+                           const ModuleSP &new_module_sp) {
+  // 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 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);
+    }
+    BroadcastEvent(eBroadcastBitModulesLoaded,
+                   new TargetEventData(this->shared_from_this(), module_list));
+  }
+}
+
+void Target::SymbolsDidLoad(ModuleList &module_list) {
+  if (m_valid && module_list.GetSize()) {
+    if (m_process_sp) {
+      LanguageRuntime *runtime =
+          m_process_sp->GetLanguageRuntime(lldb::eLanguageTypeObjC);
+      if (runtime) {
+        ObjCLanguageRuntime *objc_runtime = (ObjCLanguageRuntime *)runtime;
+        objc_runtime->SymbolsDidLoad(module_list);
+      }
+    }
+
+    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));
+  }
+}
+
+void Target::ModulesDidUnload(ModuleList &module_list, bool delete_locations) {
+  if (m_valid && module_list.GetSize()) {
+    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));
+  }
+}
+
+bool Target::ModuleIsExcludedForUnconstrainedSearches(
+    const FileSpec &module_file_spec) {
+  if (GetBreakpointsConsultPlatformAvoidList()) {
+    ModuleList matchingModules;
+    ModuleSpec module_spec(module_file_spec);
+    size_t num_modules = GetImages().FindModules(module_spec, matchingModules);
+
+    // If there is more than one module for this file spec, only return true if
+    // ALL the modules are on the
+    // black list.
+    if (num_modules > 0) {
+      for (size_t i = 0; i < num_modules; i++) {
+        if (!ModuleIsExcludedForUnconstrainedSearches(
+                matchingModules.GetModuleAtIndex(i)))
+          return false;
+      }
+      return true;
+    }
+  }
+  return false;
+}
+
+bool Target::ModuleIsExcludedForUnconstrainedSearches(
+    const lldb::ModuleSP &module_sp) {
+  if (GetBreakpointsConsultPlatformAvoidList()) {
+    if (m_platform_sp)
+      return m_platform_sp->ModuleIsExcludedForUnconstrainedSearches(*this,
+                                                                     module_sp);
+  }
+  return false;
+}
+
+size_t Target::ReadMemoryFromFileCache(const Address &addr, void *dst,
+                                       size_t dst_len, Error &error) {
+  SectionSP section_sp(addr.GetSection());
+  if (section_sp) {
+    // If the contents of this section are encrypted, the on-disk file is
+    // unusable.  Read only from live memory.
+    if (section_sp->IsEncrypted()) {
+      error.SetErrorString("section is encrypted");
+      return 0;
+    }
+    ModuleSP module_sp(section_sp->GetModule());
+    if (module_sp) {
+      ObjectFile *objfile = section_sp->GetModule()->GetObjectFile();
+      if (objfile) {
+        size_t bytes_read = objfile->ReadSectionData(
+            section_sp.get(), addr.GetOffset(), dst, dst_len);
         if (bytes_read > 0)
-            return bytes_read;
-    }
-    
-    if (ProcessIsValid())
-    {
-        if (load_addr == LLDB_INVALID_ADDRESS)
-            load_addr = resolved_addr.GetLoadAddress (this);
-
-        if (load_addr == LLDB_INVALID_ADDRESS)
-        {
-            ModuleSP addr_module_sp (resolved_addr.GetModule());
-            if (addr_module_sp && addr_module_sp->GetFileSpec())
-                error.SetErrorStringWithFormat("%s[0x%" PRIx64 "] can't be resolved, %s in not currently loaded",
-                                               addr_module_sp->GetFileSpec().GetFilename().AsCString("<Unknown>"),
-                                               resolved_addr.GetFileAddress(),
-                                               addr_module_sp->GetFileSpec().GetFilename().AsCString("<Unknonw>"));
-            else
-                error.SetErrorStringWithFormat("0x%" PRIx64 " can't be resolved", resolved_addr.GetFileAddress());
-        }
+          return bytes_read;
         else
-        {
-            bytes_read = m_process_sp->ReadMemory(load_addr, dst, dst_len, error);
-            if (bytes_read != dst_len)
-            {
-                if (error.Success())
-                {
-                    if (bytes_read == 0)
-                        error.SetErrorStringWithFormat("read memory from 0x%" PRIx64 " failed", load_addr);
-                    else
-                        error.SetErrorStringWithFormat("only %" PRIu64 " of %" PRIu64 " bytes were read from memory at 0x%" PRIx64, (uint64_t)bytes_read, (uint64_t)dst_len, load_addr);
-                }
-            }
-            if (bytes_read)
-            {
-                if (load_addr_ptr)
-                    *load_addr_ptr = load_addr;
-                return bytes_read;
-            }
-            // If the address is not section offset we have an address that
-            // doesn't resolve to any address in any currently loaded shared
-            // libraries and we failed to read memory so there isn't anything
-            // more we can do. If it is section offset, we might be able to
-            // read cached memory from the object file.
-            if (!resolved_addr.IsSectionOffset())
-                return 0;
-        }
-    }
-    
-    if (!prefer_file_cache && resolved_addr.IsSectionOffset())
-    {
-        // If we didn't already try and read from the object file cache, then
-        // try it after failing to read from the process.
-        return ReadMemoryFromFileCache (resolved_addr, dst, dst_len, error);
-    }
-    return 0;
-}
-
-size_t
-Target::ReadCStringFromMemory (const Address& addr, std::string &out_str, Error &error)
-{
-    char buf[256];
-    out_str.clear();
+          error.SetErrorStringWithFormat("error reading data from section %s",
+                                         section_sp->GetName().GetCString());
+      } else
+        error.SetErrorString("address isn't from a object file");
+    } else
+      error.SetErrorString("address isn't in a module");
+  } else
+    error.SetErrorString("address doesn't contain a section that points to a "
+                         "section in a object file");
+
+  return 0;
+}
+
+size_t Target::ReadMemory(const Address &addr, bool prefer_file_cache,
+                          void *dst, size_t dst_len, Error &error,
+                          lldb::addr_t *load_addr_ptr) {
+  error.Clear();
+
+  // if we end up reading this from process memory, we will fill this
+  // with the actual load address
+  if (load_addr_ptr)
+    *load_addr_ptr = LLDB_INVALID_ADDRESS;
+
+  size_t bytes_read = 0;
+
+  addr_t load_addr = LLDB_INVALID_ADDRESS;
+  addr_t file_addr = LLDB_INVALID_ADDRESS;
+  Address resolved_addr;
+  if (!addr.IsSectionOffset()) {
+    SectionLoadList &section_load_list = GetSectionLoadList();
+    if (section_load_list.IsEmpty()) {
+      // No sections are loaded, so we must assume we are not running
+      // yet and anything we are given is a file address.
+      file_addr = addr.GetOffset(); // "addr" doesn't have a section, so its
+                                    // offset is the file address
+      m_images.ResolveFileAddress(file_addr, resolved_addr);
+    } else {
+      // We have at least one section loaded. This can be because
+      // we have manually loaded some sections with "target modules load ..."
+      // or because we have have a live process that has sections loaded
+      // through the dynamic loader
+      load_addr = addr.GetOffset(); // "addr" doesn't have a section, so its
+                                    // offset is the load address
+      section_load_list.ResolveLoadAddress(load_addr, resolved_addr);
+    }
+  }
+  if (!resolved_addr.IsValid())
+    resolved_addr = addr;
+
+  if (prefer_file_cache) {
+    bytes_read = ReadMemoryFromFileCache(resolved_addr, dst, dst_len, error);
+    if (bytes_read > 0)
+      return bytes_read;
+  }
+
+  if (ProcessIsValid()) {
+    if (load_addr == LLDB_INVALID_ADDRESS)
+      load_addr = resolved_addr.GetLoadAddress(this);
+
+    if (load_addr == LLDB_INVALID_ADDRESS) {
+      ModuleSP addr_module_sp(resolved_addr.GetModule());
+      if (addr_module_sp && addr_module_sp->GetFileSpec())
+        error.SetErrorStringWithFormat(
+            "%s[0x%" PRIx64 "] can't be resolved, %s in not currently loaded",
+            addr_module_sp->GetFileSpec().GetFilename().AsCString("<Unknown>"),
+            resolved_addr.GetFileAddress(),
+            addr_module_sp->GetFileSpec().GetFilename().AsCString("<Unknonw>"));
+      else
+        error.SetErrorStringWithFormat("0x%" PRIx64 " can't be resolved",
+                                       resolved_addr.GetFileAddress());
+    } else {
+      bytes_read = m_process_sp->ReadMemory(load_addr, dst, dst_len, error);
+      if (bytes_read != dst_len) {
+        if (error.Success()) {
+          if (bytes_read == 0)
+            error.SetErrorStringWithFormat(
+                "read memory from 0x%" PRIx64 " failed", load_addr);
+          else
+            error.SetErrorStringWithFormat(
+                "only %" PRIu64 " of %" PRIu64
+                " bytes were read from memory at 0x%" PRIx64,
+                (uint64_t)bytes_read, (uint64_t)dst_len, load_addr);
+        }
+      }
+      if (bytes_read) {
+        if (load_addr_ptr)
+          *load_addr_ptr = load_addr;
+        return bytes_read;
+      }
+      // If the address is not section offset we have an address that
+      // doesn't resolve to any address in any currently loaded shared
+      // libraries and we failed to read memory so there isn't anything
+      // more we can do. If it is section offset, we might be able to
+      // read cached memory from the object file.
+      if (!resolved_addr.IsSectionOffset())
+        return 0;
+    }
+  }
+
+  if (!prefer_file_cache && resolved_addr.IsSectionOffset()) {
+    // If we didn't already try and read from the object file cache, then
+    // try it after failing to read from the process.
+    return ReadMemoryFromFileCache(resolved_addr, dst, dst_len, error);
+  }
+  return 0;
+}
+
+size_t Target::ReadCStringFromMemory(const Address &addr, std::string &out_str,
+                                     Error &error) {
+  char buf[256];
+  out_str.clear();
+  addr_t curr_addr = addr.GetLoadAddress(this);
+  Address address(addr);
+  while (1) {
+    size_t length = ReadCStringFromMemory(address, buf, sizeof(buf), error);
+    if (length == 0)
+      break;
+    out_str.append(buf, length);
+    // If we got "length - 1" bytes, we didn't get the whole C string, we
+    // need to read some more characters
+    if (length == sizeof(buf) - 1)
+      curr_addr += length;
+    else
+      break;
+    address = Address(curr_addr);
+  }
+  return out_str.size();
+}
+
+size_t Target::ReadCStringFromMemory(const Address &addr, char *dst,
+                                     size_t dst_max_len, Error &result_error) {
+  size_t total_cstr_len = 0;
+  if (dst && dst_max_len) {
+    result_error.Clear();
+    // NULL out everything just to be safe
+    memset(dst, 0, dst_max_len);
+    Error error;
     addr_t curr_addr = addr.GetLoadAddress(this);
     Address address(addr);
-    while (1)
-    {
-        size_t length = ReadCStringFromMemory (address, buf, sizeof(buf), error);
-        if (length == 0)
-            break;
-        out_str.append(buf, length);
-        // If we got "length - 1" bytes, we didn't get the whole C string, we
-        // need to read some more characters
-        if (length == sizeof(buf) - 1)
-            curr_addr += length;
-        else
-            break;
-        address = Address(curr_addr);
-    }
-    return out_str.size();
-}
-
-size_t
-Target::ReadCStringFromMemory (const Address& addr, char *dst, size_t dst_max_len, Error &result_error)
-{
-    size_t total_cstr_len = 0;
-    if (dst && dst_max_len)
-    {
-        result_error.Clear();
-        // NULL out everything just to be safe
-        memset (dst, 0, dst_max_len);
-        Error error;
-        addr_t curr_addr = addr.GetLoadAddress(this);
-        Address address(addr);
-
-        // We could call m_process_sp->GetMemoryCacheLineSize() but I don't
-        // think this really needs to be tied to the memory cache subsystem's
-        // cache line size, so leave this as a fixed constant.
-        const size_t cache_line_size = 512;
-
-        size_t bytes_left = dst_max_len - 1;
-        char *curr_dst = dst;
-        
-        while (bytes_left > 0)
-        {
-            addr_t cache_line_bytes_left = cache_line_size - (curr_addr % cache_line_size);
-            addr_t bytes_to_read = std::min<addr_t>(bytes_left, cache_line_bytes_left);
-            size_t bytes_read = ReadMemory (address, false, curr_dst, bytes_to_read, error);
-            
-            if (bytes_read == 0)
-            {
-                result_error = error;
-                dst[total_cstr_len] = '\0';
-                break;
-            }
-            const size_t len = strlen(curr_dst);
-            
-            total_cstr_len += len;
-            
-            if (len < bytes_to_read)
-                break;
-            
-            curr_dst += bytes_read;
-            curr_addr += bytes_read;
-            bytes_left -= bytes_read;
-            address = Address(curr_addr);
-        }
-    }
-    else
-    {
-        if (dst == nullptr)
-            result_error.SetErrorString("invalid arguments");
-        else
-            result_error.Clear();
-    }
-    return total_cstr_len;
-}
-
-size_t
-Target::ReadScalarIntegerFromMemory (const Address& addr, 
-                                     bool prefer_file_cache,
-                                     uint32_t byte_size, 
-                                     bool is_signed, 
-                                     Scalar &scalar, 
-                                     Error &error)
-{
-    uint64_t uval;
-    
-    if (byte_size <= sizeof(uval))
-    {
-        size_t bytes_read = ReadMemory (addr, prefer_file_cache, &uval, byte_size, error);
-        if (bytes_read == byte_size)
-        {
-            DataExtractor data (&uval, sizeof(uval), m_arch.GetByteOrder(), m_arch.GetAddressByteSize());
-            lldb::offset_t offset = 0;
-            if (byte_size <= 4)
-                scalar = data.GetMaxU32 (&offset, byte_size);
-            else
-                scalar = data.GetMaxU64 (&offset, byte_size);
-            
-            if (is_signed)
-                scalar.SignExtend(byte_size * 8);
-            return bytes_read;
-        }
-    }
-    else
-    {
-        error.SetErrorStringWithFormat ("byte size of %u is too large for integer scalar type", byte_size);
-    }
-    return 0;
-}
-
-uint64_t
-Target::ReadUnsignedIntegerFromMemory (const Address& addr, 
-                                       bool prefer_file_cache,
-                                       size_t integer_byte_size, 
-                                       uint64_t fail_value, 
-                                       Error &error)
-{
-    Scalar scalar;
-    if (ReadScalarIntegerFromMemory (addr, 
-                                     prefer_file_cache, 
-                                     integer_byte_size, 
-                                     false, 
-                                     scalar, 
-                                     error))
-        return scalar.ULongLong(fail_value);
-    return fail_value;
-}
-
-bool
-Target::ReadPointerFromMemory (const Address& addr, 
-                               bool prefer_file_cache,
-                               Error &error,
-                               Address &pointer_addr)
-{
-    Scalar scalar;
-    if (ReadScalarIntegerFromMemory (addr, 
-                                     prefer_file_cache, 
-                                     m_arch.GetAddressByteSize(), 
-                                     false, 
-                                     scalar, 
-                                     error))
-    {
-        addr_t pointer_vm_addr = scalar.ULongLong(LLDB_INVALID_ADDRESS);
-        if (pointer_vm_addr != LLDB_INVALID_ADDRESS)
-        {
-            SectionLoadList &section_load_list = GetSectionLoadList();
-            if (section_load_list.IsEmpty())
-            {
-                // No sections are loaded, so we must assume we are not running
-                // yet and anything we are given is a file address.
-                m_images.ResolveFileAddress (pointer_vm_addr, pointer_addr);
-            }
-            else
-            {
-                // We have at least one section loaded. This can be because
-                // we have manually loaded some sections with "target modules load ..."
-                // or because we have have a live process that has sections loaded
-                // through the dynamic loader
-                section_load_list.ResolveLoadAddress (pointer_vm_addr, pointer_addr);
-            }
-            // We weren't able to resolve the pointer value, so just return
-            // an address with no section
-            if (!pointer_addr.IsValid())
-                pointer_addr.SetOffset (pointer_vm_addr);
-            return true;
-            
-        }
-    }
-    return false;
-}
-
-ModuleSP
-Target::GetSharedModule (const ModuleSpec &module_spec, Error *error_ptr)
-{
-    ModuleSP module_sp;
-
-    Error error;
-
-    // First see if we already have this module in our module list.  If we do, then we're done, we don't need
-    // to consult the shared modules list.  But only do this if we are passed a UUID.
-    
-    if (module_spec.GetUUID().IsValid())
-        module_sp = m_images.FindFirstModule(module_spec);
-        
-    if (!module_sp)
-    {
-        ModuleSP old_module_sp; // This will get filled in if we have a new version of the library
-        bool did_create_module = false;
-    
-        // If there are image search path entries, try to use them first to acquire a suitable image.
-        if (m_image_search_paths.GetSize())
-        {
-            ModuleSpec transformed_spec (module_spec);
-            if (m_image_search_paths.RemapPath (module_spec.GetFileSpec().GetDirectory(), transformed_spec.GetFileSpec().GetDirectory()))
-            {
-                transformed_spec.GetFileSpec().GetFilename() = module_spec.GetFileSpec().GetFilename();
-                error = ModuleList::GetSharedModule (transformed_spec, 
-                                                     module_sp, 
-                                                     &GetExecutableSearchPaths(),
-                                                     &old_module_sp, 
-                                                     &did_create_module);
-            }
-        }
-        
-        if (!module_sp)
-        {
-            // If we have a UUID, we can check our global shared module list in case
-            // we already have it. If we don't have a valid UUID, then we can't since
-            // the path in "module_spec" will be a platform path, and we will need to
-            // let the platform find that file. For example, we could be asking for
-            // "/usr/lib/dyld" and if we do not have a UUID, we don't want to pick
-            // the local copy of "/usr/lib/dyld" since our platform could be a remote
-            // platform that has its own "/usr/lib/dyld" in an SDK or in a local file
-            // cache.
-            if (module_spec.GetUUID().IsValid())
-            {
-                // We have a UUID, it is OK to check the global module list...
-                error = ModuleList::GetSharedModule (module_spec,
-                                                     module_sp, 
-                                                     &GetExecutableSearchPaths(),
-                                                     &old_module_sp,
-                                                     &did_create_module);
-            }
-
-            if (!module_sp)
-            {
-                // The platform is responsible for finding and caching an appropriate
-                // module in the shared module cache.
-                if (m_platform_sp)
-                {
-                    error = m_platform_sp->GetSharedModule (module_spec,
-                                                            m_process_sp.get(),
-                                                            module_sp,
-                                                            &GetExecutableSearchPaths(),
-                                                            &old_module_sp,
-                                                            &did_create_module);
-                }
-                else
-                {
-                    error.SetErrorString("no platform is currently set");
-                }
-            }
-        }
-
-        // We found a module that wasn't in our target list.  Let's make sure that there wasn't an equivalent
-        // module in the list already, and if there was, let's remove it.
-        if (module_sp)
-        {
-            ObjectFile *objfile = module_sp->GetObjectFile();
-            if (objfile)
-            {
-                switch (objfile->GetType())
-                {
-                    case ObjectFile::eTypeCoreFile:      /// A core file that has a checkpoint of a program's execution state
-                    case ObjectFile::eTypeExecutable:    /// A normal executable
-                    case ObjectFile::eTypeDynamicLinker: /// The platform's dynamic linker executable
-                    case ObjectFile::eTypeObjectFile:    /// An intermediate object file
-                    case ObjectFile::eTypeSharedLibrary: /// A shared library that can be used during execution
-                        break;
-                    case ObjectFile::eTypeDebugInfo:     /// An object file that contains only debug information
-                        if (error_ptr)
-                            error_ptr->SetErrorString("debug info files aren't valid target modules, please specify an executable");
-                        return ModuleSP();
-                    case ObjectFile::eTypeStubLibrary:   /// A library that can be linked against but not used for execution
-                        if (error_ptr)
-                            error_ptr->SetErrorString("stub libraries aren't valid target modules, please specify an executable");
-                        return ModuleSP();
-                    default:
-                        if (error_ptr)
-                            error_ptr->SetErrorString("unsupported file type, please specify an executable");
-                        return ModuleSP();
-                }
-                // GetSharedModule is not guaranteed to find the old shared module, for instance
-                // in the common case where you pass in the UUID, it is only going to find the one
-                // module matching the UUID.  In fact, it has no good way to know what the "old module"
-                // relevant to this target is, since there might be many copies of a module with this file spec
-                // in various running debug sessions, but only one of them will belong to this target.
-                // So let's remove the UUID from the module list, and look in the target's module list.
-                // Only do this if there is SOMETHING else in the module spec...
-                if (!old_module_sp)
-                {
-                    if (module_spec.GetUUID().IsValid() && !module_spec.GetFileSpec().GetFilename().IsEmpty() && !module_spec.GetFileSpec().GetDirectory().IsEmpty())
-                    {
-                        ModuleSpec module_spec_copy(module_spec.GetFileSpec());
-                        module_spec_copy.GetUUID().Clear();
-                        
-                        ModuleList found_modules;
-                        size_t num_found = m_images.FindModules (module_spec_copy, found_modules);
-                        if (num_found == 1)
-                        {
-                            old_module_sp = found_modules.GetModuleAtIndex(0);
-                        }
-                    }
-                }
-                
-                if (old_module_sp && m_images.GetIndexForModule (old_module_sp.get()) != LLDB_INVALID_INDEX32)
-                {
-                    m_images.ReplaceModule(old_module_sp, module_sp);
-                    Module *old_module_ptr = old_module_sp.get();
-                    old_module_sp.reset();
-                    ModuleList::RemoveSharedModuleIfOrphaned (old_module_ptr);
-                }
-                else
-                    m_images.Append(module_sp);
-            }
-            else
-                module_sp.reset();
-        }
-    }
-    if (error_ptr)
-        *error_ptr = error;
-    return module_sp;
-}
-
-TargetSP
-Target::CalculateTarget ()
-{
-    return shared_from_this();
-}
-
-ProcessSP
-Target::CalculateProcess ()
-{
-    return m_process_sp;
-}
-
-ThreadSP
-Target::CalculateThread ()
-{
-    return ThreadSP();
-}
 
-StackFrameSP
-Target::CalculateStackFrame ()
-{
-    return StackFrameSP();
-}
+    // We could call m_process_sp->GetMemoryCacheLineSize() but I don't
+    // think this really needs to be tied to the memory cache subsystem's
+    // cache line size, so leave this as a fixed constant.
+    const size_t cache_line_size = 512;
+
+    size_t bytes_left = dst_max_len - 1;
+    char *curr_dst = dst;
+
+    while (bytes_left > 0) {
+      addr_t cache_line_bytes_left =
+          cache_line_size - (curr_addr % cache_line_size);
+      addr_t bytes_to_read =
+          std::min<addr_t>(bytes_left, cache_line_bytes_left);
+      size_t bytes_read =
+          ReadMemory(address, false, curr_dst, bytes_to_read, error);
+
+      if (bytes_read == 0) {
+        result_error = error;
+        dst[total_cstr_len] = '\0';
+        break;
+      }
+      const size_t len = strlen(curr_dst);
 
-void
-Target::CalculateExecutionContext (ExecutionContext &exe_ctx)
-{
-    exe_ctx.Clear();
-    exe_ctx.SetTargetPtr(this);
-}
+      total_cstr_len += len;
 
-PathMappingList &
-Target::GetImageSearchPathList ()
-{
-    return m_image_search_paths;
-}
+      if (len < bytes_to_read)
+        break;
 
-void
-Target::ImageSearchPathsChanged(const PathMappingList &path_list,
-                                void *baton)
-{
-    Target *target = (Target *)baton;
-    ModuleSP exe_module_sp (target->GetExecutableModule());
-    if (exe_module_sp)
-        target->SetExecutableModule (exe_module_sp, true);
-}
+      curr_dst += bytes_read;
+      curr_addr += bytes_read;
+      bytes_left -= bytes_read;
+      address = Address(curr_addr);
+    }
+  } else {
+    if (dst == nullptr)
+      result_error.SetErrorString("invalid arguments");
+    else
+      result_error.Clear();
+  }
+  return total_cstr_len;
+}
+
+size_t Target::ReadScalarIntegerFromMemory(const Address &addr,
+                                           bool prefer_file_cache,
+                                           uint32_t byte_size, bool is_signed,
+                                           Scalar &scalar, Error &error) {
+  uint64_t uval;
+
+  if (byte_size <= sizeof(uval)) {
+    size_t bytes_read =
+        ReadMemory(addr, prefer_file_cache, &uval, byte_size, error);
+    if (bytes_read == byte_size) {
+      DataExtractor data(&uval, sizeof(uval), m_arch.GetByteOrder(),
+                         m_arch.GetAddressByteSize());
+      lldb::offset_t offset = 0;
+      if (byte_size <= 4)
+        scalar = data.GetMaxU32(&offset, byte_size);
+      else
+        scalar = data.GetMaxU64(&offset, byte_size);
+
+      if (is_signed)
+        scalar.SignExtend(byte_size * 8);
+      return bytes_read;
+    }
+  } else {
+    error.SetErrorStringWithFormat(
+        "byte size of %u is too large for integer scalar type", byte_size);
+  }
+  return 0;
+}
+
+uint64_t Target::ReadUnsignedIntegerFromMemory(const Address &addr,
+                                               bool prefer_file_cache,
+                                               size_t integer_byte_size,
+                                               uint64_t fail_value,
+                                               Error &error) {
+  Scalar scalar;
+  if (ReadScalarIntegerFromMemory(addr, prefer_file_cache, integer_byte_size,
+                                  false, scalar, error))
+    return scalar.ULongLong(fail_value);
+  return fail_value;
+}
+
+bool Target::ReadPointerFromMemory(const Address &addr, bool prefer_file_cache,
+                                   Error &error, Address &pointer_addr) {
+  Scalar scalar;
+  if (ReadScalarIntegerFromMemory(addr, prefer_file_cache,
+                                  m_arch.GetAddressByteSize(), false, scalar,
+                                  error)) {
+    addr_t pointer_vm_addr = scalar.ULongLong(LLDB_INVALID_ADDRESS);
+    if (pointer_vm_addr != LLDB_INVALID_ADDRESS) {
+      SectionLoadList &section_load_list = GetSectionLoadList();
+      if (section_load_list.IsEmpty()) {
+        // No sections are loaded, so we must assume we are not running
+        // yet and anything we are given is a file address.
+        m_images.ResolveFileAddress(pointer_vm_addr, pointer_addr);
+      } else {
+        // We have at least one section loaded. This can be because
+        // we have manually loaded some sections with "target modules load ..."
+        // or because we have have a live process that has sections loaded
+        // through the dynamic loader
+        section_load_list.ResolveLoadAddress(pointer_vm_addr, pointer_addr);
+      }
+      // We weren't able to resolve the pointer value, so just return
+      // an address with no section
+      if (!pointer_addr.IsValid())
+        pointer_addr.SetOffset(pointer_vm_addr);
+      return true;
+    }
+  }
+  return false;
+}
+
+ModuleSP Target::GetSharedModule(const ModuleSpec &module_spec,
+                                 Error *error_ptr) {
+  ModuleSP module_sp;
+
+  Error error;
+
+  // First see if we already have this module in our module list.  If we do,
+  // then we're done, we don't need
+  // to consult the shared modules list.  But only do this if we are passed a
+  // UUID.
+
+  if (module_spec.GetUUID().IsValid())
+    module_sp = m_images.FindFirstModule(module_spec);
+
+  if (!module_sp) {
+    ModuleSP old_module_sp; // This will get filled in if we have a new version
+                            // of the library
+    bool did_create_module = false;
+
+    // If there are image search path entries, try to use them first to acquire
+    // a suitable image.
+    if (m_image_search_paths.GetSize()) {
+      ModuleSpec transformed_spec(module_spec);
+      if (m_image_search_paths.RemapPath(
+              module_spec.GetFileSpec().GetDirectory(),
+              transformed_spec.GetFileSpec().GetDirectory())) {
+        transformed_spec.GetFileSpec().GetFilename() =
+            module_spec.GetFileSpec().GetFilename();
+        error = ModuleList::GetSharedModule(transformed_spec, module_sp,
+                                            &GetExecutableSearchPaths(),
+                                            &old_module_sp, &did_create_module);
+      }
+    }
+
+    if (!module_sp) {
+      // If we have a UUID, we can check our global shared module list in case
+      // we already have it. If we don't have a valid UUID, then we can't since
+      // the path in "module_spec" will be a platform path, and we will need to
+      // let the platform find that file. For example, we could be asking for
+      // "/usr/lib/dyld" and if we do not have a UUID, we don't want to pick
+      // the local copy of "/usr/lib/dyld" since our platform could be a remote
+      // platform that has its own "/usr/lib/dyld" in an SDK or in a local file
+      // cache.
+      if (module_spec.GetUUID().IsValid()) {
+        // We have a UUID, it is OK to check the global module list...
+        error = ModuleList::GetSharedModule(module_spec, module_sp,
+                                            &GetExecutableSearchPaths(),
+                                            &old_module_sp, &did_create_module);
+      }
+
+      if (!module_sp) {
+        // The platform is responsible for finding and caching an appropriate
+        // module in the shared module cache.
+        if (m_platform_sp) {
+          error = m_platform_sp->GetSharedModule(
+              module_spec, m_process_sp.get(), module_sp,
+              &GetExecutableSearchPaths(), &old_module_sp, &did_create_module);
+        } else {
+          error.SetErrorString("no platform is currently set");
+        }
+      }
+    }
+
+    // We found a module that wasn't in our target list.  Let's make sure that
+    // there wasn't an equivalent
+    // module in the list already, and if there was, let's remove it.
+    if (module_sp) {
+      ObjectFile *objfile = module_sp->GetObjectFile();
+      if (objfile) {
+        switch (objfile->GetType()) {
+        case ObjectFile::eTypeCoreFile: /// A core file that has a checkpoint of
+                                        /// a program's execution state
+        case ObjectFile::eTypeExecutable:    /// A normal executable
+        case ObjectFile::eTypeDynamicLinker: /// The platform's dynamic linker
+                                             /// executable
+        case ObjectFile::eTypeObjectFile:    /// An intermediate object file
+        case ObjectFile::eTypeSharedLibrary: /// A shared library that can be
+                                             /// used during execution
+          break;
+        case ObjectFile::eTypeDebugInfo: /// An object file that contains only
+                                         /// debug information
+          if (error_ptr)
+            error_ptr->SetErrorString("debug info files aren't valid target "
+                                      "modules, please specify an executable");
+          return ModuleSP();
+        case ObjectFile::eTypeStubLibrary: /// A library that can be linked
+                                           /// against but not used for
+                                           /// execution
+          if (error_ptr)
+            error_ptr->SetErrorString("stub libraries aren't valid target "
+                                      "modules, please specify an executable");
+          return ModuleSP();
+        default:
+          if (error_ptr)
+            error_ptr->SetErrorString(
+                "unsupported file type, please specify an executable");
+          return ModuleSP();
+        }
+        // GetSharedModule is not guaranteed to find the old shared module, for
+        // instance
+        // in the common case where you pass in the UUID, it is only going to
+        // find the one
+        // module matching the UUID.  In fact, it has no good way to know what
+        // the "old module"
+        // relevant to this target is, since there might be many copies of a
+        // module with this file spec
+        // in various running debug sessions, but only one of them will belong
+        // to this target.
+        // So let's remove the UUID from the module list, and look in the
+        // target's module list.
+        // Only do this if there is SOMETHING else in the module spec...
+        if (!old_module_sp) {
+          if (module_spec.GetUUID().IsValid() &&
+              !module_spec.GetFileSpec().GetFilename().IsEmpty() &&
+              !module_spec.GetFileSpec().GetDirectory().IsEmpty()) {
+            ModuleSpec module_spec_copy(module_spec.GetFileSpec());
+            module_spec_copy.GetUUID().Clear();
+
+            ModuleList found_modules;
+            size_t num_found =
+                m_images.FindModules(module_spec_copy, found_modules);
+            if (num_found == 1) {
+              old_module_sp = found_modules.GetModuleAtIndex(0);
+            }
+          }
+        }
+
+        if (old_module_sp &&
+            m_images.GetIndexForModule(old_module_sp.get()) !=
+                LLDB_INVALID_INDEX32) {
+          m_images.ReplaceModule(old_module_sp, module_sp);
+          Module *old_module_ptr = old_module_sp.get();
+          old_module_sp.reset();
+          ModuleList::RemoveSharedModuleIfOrphaned(old_module_ptr);
+        } else
+          m_images.Append(module_sp);
+      } else
+        module_sp.reset();
+    }
+  }
+  if (error_ptr)
+    *error_ptr = error;
+  return module_sp;
+}
+
+TargetSP Target::CalculateTarget() { return shared_from_this(); }
+
+ProcessSP Target::CalculateProcess() { return m_process_sp; }
+
+ThreadSP Target::CalculateThread() { return ThreadSP(); }
+
+StackFrameSP Target::CalculateStackFrame() { return StackFrameSP(); }
+
+void Target::CalculateExecutionContext(ExecutionContext &exe_ctx) {
+  exe_ctx.Clear();
+  exe_ctx.SetTargetPtr(this);
+}
+
+PathMappingList &Target::GetImageSearchPathList() {
+  return m_image_search_paths;
+}
+
+void Target::ImageSearchPathsChanged(const PathMappingList &path_list,
+                                     void *baton) {
+  Target *target = (Target *)baton;
+  ModuleSP exe_module_sp(target->GetExecutableModule());
+  if (exe_module_sp)
+    target->SetExecutableModule(exe_module_sp, true);
+}
+
+TypeSystem *Target::GetScratchTypeSystemForLanguage(Error *error,
+                                                    lldb::LanguageType language,
+                                                    bool create_on_demand) {
+  if (!m_valid)
+    return nullptr;
 
-TypeSystem *
-Target::GetScratchTypeSystemForLanguage (Error *error, lldb::LanguageType language, bool create_on_demand)
-{
-    if (!m_valid)
+  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;
-
-    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();
-            }
-        }
+      } else {
+        language = *languages_for_expressions.begin();
+      }
     }
+  }
 
-    return m_scratch_type_system_map.GetTypeSystemForLanguage(language, this, create_on_demand);
+  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)
-{
-    if (m_valid)
-    {
-        if (TypeSystem* type_system = GetScratchTypeSystemForLanguage(nullptr, eLanguageTypeC, create_on_demand))
-            return llvm::dyn_cast<ClangASTContext>(type_system);
-    }
+Target::GetPersistentExpressionStateForLanguage(lldb::LanguageType language) {
+  TypeSystem *type_system =
+      GetScratchTypeSystemForLanguage(nullptr, language, true);
+
+  if (type_system) {
+    return type_system->GetPersistentExpressionState();
+  } else {
     return nullptr;
+  }
 }
 
-ClangASTImporterSP
-Target::GetClangASTImporter()
-{
-    if (m_valid)
-    {
-        if (!m_ast_importer_sp)
-        {
-            m_ast_importer_sp.reset(new ClangASTImporter());
-        }
-        return m_ast_importer_sp;
-    }
-    return ClangASTImporterSP();
-}
-
-void
-Target::SettingsInitialize ()
-{
-    Process::SettingsInitialize ();
-}
-
-void
-Target::SettingsTerminate ()
-{
-    Process::SettingsTerminate ();
-}
-
-FileSpecList
-Target::GetDefaultExecutableSearchPaths ()
-{
-    TargetPropertiesSP properties_sp(Target::GetGlobalProperties());
-    if (properties_sp)
-        return properties_sp->GetExecutableSearchPaths();
-    return FileSpecList();
-}
-
-FileSpecList
-Target::GetDefaultDebugFileSearchPaths ()
-{
-    TargetPropertiesSP properties_sp(Target::GetGlobalProperties());
-    if (properties_sp)
-        return properties_sp->GetDebugFileSearchPaths();
-    return FileSpecList();
-}
-
-FileSpecList
-Target::GetDefaultClangModuleSearchPaths ()
-{
-    TargetPropertiesSP properties_sp(Target::GetGlobalProperties());
-    if (properties_sp)
-        return properties_sp->GetClangModuleSearchPaths();
-    return FileSpecList();
-}
-
-ArchSpec
-Target::GetDefaultArchitecture ()
-{
-    TargetPropertiesSP properties_sp(Target::GetGlobalProperties());
-    if (properties_sp)
-        return properties_sp->GetDefaultArchitecture();
-    return ArchSpec();
-}
-
-void
-Target::SetDefaultArchitecture (const ArchSpec &arch)
-{
-    TargetPropertiesSP properties_sp(Target::GetGlobalProperties());
-    if (properties_sp)
-    {
-        LogIfAnyCategoriesSet(LIBLLDB_LOG_TARGET, "Target::SetDefaultArchitecture setting target's default architecture to  %s (%s)", arch.GetArchitectureName(), arch.GetTriple().getTriple().c_str());
-        return properties_sp->SetDefaultArchitecture(arch);
-    }
-}
-
-Target *
-Target::GetTargetFromContexts (const ExecutionContext *exe_ctx_ptr, const SymbolContext *sc_ptr)
-{
-    // The target can either exist in the "process" of ExecutionContext, or in 
-    // the "target_sp" member of SymbolContext. This accessor helper function
-    // will get the target from one of these locations.
-
-    Target *target = nullptr;
-    if (sc_ptr != nullptr)
-        target = sc_ptr->target_sp.get();
-    if (target == nullptr && exe_ctx_ptr)
-        target = exe_ctx_ptr->GetTargetPtr();
-    return target;
-}
-
-ExpressionResults
-Target::EvaluateExpression(const char *expr_cstr,
-                           ExecutionContextScope *exe_scope,
-                           lldb::ValueObjectSP &result_valobj_sp,
-                           const EvaluateExpressionOptions& options,
-                           std::string *fixed_expression)
-{
-    result_valobj_sp.reset();
-    
-    ExpressionResults execution_results = eExpressionSetupError;
-
-    if (expr_cstr == nullptr || expr_cstr[0] == '\0')
-        return execution_results;
-
-    // We shouldn't run stop hooks in expressions.
-    // Be sure to reset this if you return anywhere within this function.
-    bool old_suppress_value = m_suppress_stop_hooks;
-    m_suppress_stop_hooks = true;
-
-    ExecutionContext exe_ctx;
-    
-    if (exe_scope)
-    {
-        exe_scope->CalculateExecutionContext(exe_ctx);
-    }
-    else if (m_process_sp)
-    {
-        m_process_sp->CalculateExecutionContext(exe_ctx);
-    }
-    else
-    {
-        CalculateExecutionContext(exe_ctx);
-    }
-    
-    // Make sure we aren't just trying to see the value of a persistent
-    // variable (something like "$0")
-    lldb::ExpressionVariableSP persistent_var_sp;
-    // Only check for persistent variables the expression starts with a '$' 
-    if (expr_cstr[0] == '$')
-        persistent_var_sp = GetScratchTypeSystemForLanguage(nullptr, eLanguageTypeC)->GetPersistentExpressionState()->GetVariable (expr_cstr);
-
-    if (persistent_var_sp)
-    {
-        result_valobj_sp = persistent_var_sp->GetValueObject ();
-        execution_results = eExpressionCompleted;
-    }
-    else
-    {
-        const char *prefix = GetExpressionPrefixContentsAsCString();
-        Error error;
-        execution_results = UserExpression::Evaluate (exe_ctx,
-                                                      options,
-                                                      expr_cstr,
-                                                      prefix,
-                                                      result_valobj_sp,
-                                                      error,
-                                                      0, // Line Number
-                                                      fixed_expression);
-    }
-    
-    m_suppress_stop_hooks = old_suppress_value;
-    
-    return execution_results;
-}
-
-lldb::ExpressionVariableSP
-Target::GetPersistentVariable(const ConstString &name)
-{
-    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
-Target::GetCallableLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const
-{
-    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)
-        {
-        case eAddressClassData:
-        case eAddressClassDebug:
-            return LLDB_INVALID_ADDRESS;
-            
-        case eAddressClassUnknown:
-        case eAddressClassInvalid:
-        case eAddressClassCode:
-        case eAddressClassCodeAlternateISA:
-        case eAddressClassRuntime:
-            // Check if bit zero it no set?
-            if ((code_addr & 1ull) == 0)
-            {
-                // Bit zero isn't set, check if the address is a multiple of 2?
-                if (code_addr & 2ull)
-                {
-                    // The address is a multiple of 2 so it must be thumb, set bit zero
-                    code_addr |= 1ull;
-                }
-                else if (addr_class == eAddressClassCodeAlternateISA)
-                {
-                    // We checked the address and the address claims to be the alternate ISA
-                    // which means thumb, so set bit zero.
-                    code_addr |= 1ull;
-                }
-            }
-            break;
-        }
-        break;
-            
-    default:
-        break;
-    }
-    return code_addr;
-}
-
-lldb::addr_t
-Target::GetOpcodeLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const
-{
-    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)
-        {
-        case eAddressClassData:
-        case eAddressClassDebug:
-            return LLDB_INVALID_ADDRESS;
-            
-        case eAddressClassInvalid:
-        case eAddressClassUnknown:
-        case eAddressClassCode:
-        case eAddressClassCodeAlternateISA:
-        case eAddressClassRuntime:
-            opcode_addr &= ~(1ull);
-            break;
-        }
-        break;
-            
-    default:
-        break;
-    }
-    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);
-            Address sym_addr;
-            if (sc.function)
-                sym_addr = sc.function->GetAddressRange().GetBaseAddress();
-            else if (sc.symbol)
-                sym_addr = sc.symbol->GetAddress();
-
-            function_start = sym_addr.GetLoadAddress(this);
-            if (function_start == LLDB_INVALID_ADDRESS)
-                function_start = sym_addr.GetFileAddress();
-
-            if (function_start)
-                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)
-        m_source_manager_ap.reset (new SourceManager(shared_from_this()));
-    return *m_source_manager_ap;
-}
-
-ClangModulesDeclVendor *
-Target::GetClangModulesDeclVendor ()
-{
-    static std::mutex s_clang_modules_decl_vendor_mutex; // If this is contended we can make it per-target
+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;
+  }
 
-    {
-        std::lock_guard<std::mutex> guard(s_clang_modules_decl_vendor_mutex);
+  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;
+  }
 
-        if (!m_clang_modules_decl_vendor_ap)
-        {
-            m_clang_modules_decl_vendor_ap.reset(ClangModulesDeclVendor::Create(*this));
-        }
-    }
-    
-    return m_clang_modules_decl_vendor_ap.get();
-}
+  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));
 
-Target::StopHookSP
-Target::CreateStopHook ()
-{
-    lldb::user_id_t new_uid = ++m_stop_hook_next_id;
-    Target::StopHookSP stop_hook_sp (new StopHook(shared_from_this(), new_uid));
-    m_stop_hooks[new_uid] = stop_hook_sp;
-    return stop_hook_sp;
+  return persistent_fn;
 }
 
-bool
-Target::RemoveStopHookByID (lldb::user_id_t user_id)
-{
-    size_t num_removed = m_stop_hooks.erase(user_id);
-    return (num_removed != 0);
-}
+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;
+  }
 
-void
-Target::RemoveAllStopHooks ()
-{
-    m_stop_hooks.clear();
-}
+  utility_fn = type_system->GetUtilityFunction(text, name);
+  if (!utility_fn)
+    error.SetErrorStringWithFormat(
+        "Could not create an expression for language %s",
+        Language::GetNameForLanguageType(language));
 
-Target::StopHookSP
-Target::GetStopHookByID (lldb::user_id_t user_id)
-{
-    StopHookSP found_hook;
-    
-    StopHookCollection::iterator specified_hook_iter;
-    specified_hook_iter = m_stop_hooks.find (user_id);
-    if (specified_hook_iter != m_stop_hooks.end())
-        found_hook = (*specified_hook_iter).second;
-    return found_hook;
+  return utility_fn;
 }
 
-bool
-Target::SetStopHookActiveStateByID (lldb::user_id_t user_id, bool active_state)
-{
-    StopHookCollection::iterator specified_hook_iter;
-    specified_hook_iter = m_stop_hooks.find (user_id);
-    if (specified_hook_iter == m_stop_hooks.end())
-        return false;
-        
-    (*specified_hook_iter).second->SetIsActive (active_state);
-    return true;
+ClangASTContext *Target::GetScratchClangASTContext(bool create_on_demand) {
+  if (m_valid) {
+    if (TypeSystem *type_system = GetScratchTypeSystemForLanguage(
+            nullptr, eLanguageTypeC, create_on_demand))
+      return llvm::dyn_cast<ClangASTContext>(type_system);
+  }
+  return nullptr;
 }
 
-void
-Target::SetAllStopHooksActiveState (bool active_state)
-{
-    StopHookCollection::iterator pos, end = m_stop_hooks.end();
-    for (pos = m_stop_hooks.begin(); pos != end; pos++)
-    {
-        (*pos).second->SetIsActive (active_state);
+ClangASTImporterSP Target::GetClangASTImporter() {
+  if (m_valid) {
+    if (!m_ast_importer_sp) {
+      m_ast_importer_sp.reset(new ClangASTImporter());
     }
+    return m_ast_importer_sp;
+  }
+  return ClangASTImporterSP();
 }
 
-void
-Target::RunStopHooks ()
-{
-    if (m_suppress_stop_hooks)
-        return;
-        
-    if (!m_process_sp)
-        return;
-    
-    // <rdar://problem/12027563> make sure we check that we are not stopped because of us running a user expression
-    // since in that case we do not want to run the stop-hooks
-    if (m_process_sp->GetModIDRef().IsLastResumeForUserExpression())
-        return;
-    
-    if (m_stop_hooks.empty())
-        return;
-        
-    StopHookCollection::iterator pos, end = m_stop_hooks.end();
-        
-    // If there aren't any active stop hooks, don't bother either:
-    bool any_active_hooks = false;
-    for (pos = m_stop_hooks.begin(); pos != end; pos++)
-    {
-        if ((*pos).second->IsActive())
-        {
-            any_active_hooks = true;
-            break;
-        }
-    }
-    if (!any_active_hooks)
-        return;
-    
-    CommandReturnObject result;
-    
-    std::vector<ExecutionContext> exc_ctx_with_reasons;
-    std::vector<SymbolContext> sym_ctx_with_reasons;
-    
-    ThreadList &cur_threadlist = m_process_sp->GetThreadList();
-    size_t num_threads = cur_threadlist.GetSize();
-    for (size_t i = 0; i < num_threads; i++)
-    {
-        lldb::ThreadSP cur_thread_sp = cur_threadlist.GetThreadAtIndex (i);
-        if (cur_thread_sp->ThreadStoppedForAReason())
-        {
-            lldb::StackFrameSP cur_frame_sp = cur_thread_sp->GetStackFrameAtIndex(0);
-            exc_ctx_with_reasons.push_back(ExecutionContext(m_process_sp.get(), cur_thread_sp.get(), cur_frame_sp.get()));
-            sym_ctx_with_reasons.push_back(cur_frame_sp->GetSymbolContext(eSymbolContextEverything));
-        }
-    }
-    
-    // If no threads stopped for a reason, don't run the stop-hooks.
-    size_t num_exe_ctx = exc_ctx_with_reasons.size();
-    if (num_exe_ctx == 0)
-        return;
-    
-    result.SetImmediateOutputStream (m_debugger.GetAsyncOutputStream());
-    result.SetImmediateErrorStream (m_debugger.GetAsyncErrorStream());
-    
-    bool keep_going = true;
-    bool hooks_ran = false;
-    bool print_hook_header = (m_stop_hooks.size() != 1);
-    bool print_thread_header = (num_exe_ctx != 1);
-    
-    for (pos = m_stop_hooks.begin(); keep_going && pos != end; pos++)
-    {
-        // result.Clear();
-        StopHookSP cur_hook_sp = (*pos).second;
-        if (!cur_hook_sp->IsActive())
-            continue;
-        
-        bool any_thread_matched = false;
-        for (size_t i = 0; keep_going && i < num_exe_ctx; i++)
-        {
-            if ((cur_hook_sp->GetSpecifier() == nullptr 
-                  || cur_hook_sp->GetSpecifier()->SymbolContextMatches(sym_ctx_with_reasons[i]))
-                && (cur_hook_sp->GetThreadSpecifier() == nullptr
-                    || cur_hook_sp->GetThreadSpecifier()->ThreadPassesBasicTests(exc_ctx_with_reasons[i].GetThreadRef())))
-            {
-                if (!hooks_ran)
-                {
-                    hooks_ran = true;
-                }
-                if (print_hook_header && !any_thread_matched)
-                {
-                    const char *cmd = (cur_hook_sp->GetCommands().GetSize() == 1 ?
-                                       cur_hook_sp->GetCommands().GetStringAtIndex(0) :
-                                       nullptr);
-                    if (cmd)
-                        result.AppendMessageWithFormat("\n- Hook %" PRIu64 " (%s)\n", cur_hook_sp->GetID(), cmd);
-                    else
-                        result.AppendMessageWithFormat("\n- Hook %" PRIu64 "\n", cur_hook_sp->GetID());
-                    any_thread_matched = true;
-                }
-                
-                if (print_thread_header)
-                    result.AppendMessageWithFormat("-- Thread %d\n", exc_ctx_with_reasons[i].GetThreadPtr()->GetIndexID());
-
-                CommandInterpreterRunOptions options;
-                options.SetStopOnContinue (true);
-                options.SetStopOnError (true);
-                options.SetEchoCommands (false);
-                options.SetPrintResults (true);
-                options.SetAddToHistory (false);
-
-                GetDebugger().GetCommandInterpreter().HandleCommands (cur_hook_sp->GetCommands(),
-                                                                      &exc_ctx_with_reasons[i],
-                                                                      options,
-                                                                      result);
-
-                // If the command started the target going again, we should bag out of
-                // running the stop hooks.
-                if ((result.GetStatus() == eReturnStatusSuccessContinuingNoResult) || 
-                    (result.GetStatus() == eReturnStatusSuccessContinuingResult))
-                {
-                    result.AppendMessageWithFormat ("Aborting stop hooks, hook %" PRIu64 " set the program running.", cur_hook_sp->GetID());
-                    keep_going = false;
-                }
-            }
-        }
-    }
-
-    result.GetImmediateOutputStream()->Flush();
-    result.GetImmediateErrorStream()->Flush();
-}
+void Target::SettingsInitialize() { Process::SettingsInitialize(); }
 
-const TargetPropertiesSP &
-Target::GetGlobalProperties()
-{
-    // NOTE: intentional leak so we don't crash if global destructor chain gets
-    // called as other threads still use the result of this function
-    static TargetPropertiesSP *g_settings_sp_ptr = nullptr;
-    static std::once_flag g_once_flag;
-    std::call_once(g_once_flag,  []() {
-        g_settings_sp_ptr = new TargetPropertiesSP(new TargetProperties(nullptr));
-    });
-    return *g_settings_sp_ptr;
-}
+void Target::SettingsTerminate() { Process::SettingsTerminate(); }
 
-Error
-Target::Install (ProcessLaunchInfo *launch_info)
-{
-    Error error;
-    PlatformSP platform_sp (GetPlatform());
-    if (platform_sp)
-    {
-        if (platform_sp->IsRemote())
-        {
-            if (platform_sp->IsConnected())
-            {
-                // Install all files that have an install path, and always install the
-                // main executable when connected to a remote platform
-                const ModuleList& modules = GetImages();
-                const size_t num_images = modules.GetSize();
-                for (size_t idx = 0; idx < num_images; ++idx)
-                {
-                    ModuleSP module_sp(modules.GetModuleAtIndex(idx));
-                    if (module_sp)
-                    {
-                        const bool is_main_executable = module_sp == GetExecutableModule();
-                        FileSpec local_file (module_sp->GetFileSpec());
-                        if (local_file)
-                        {
-                            FileSpec remote_file (module_sp->GetRemoteInstallFileSpec());
-                            if (!remote_file)
-                            {
-                                if (is_main_executable) // TODO: add setting for always installing main executable???
-                                {
-                                    // Always install the main executable
-                                    remote_file = platform_sp->GetRemoteWorkingDirectory();
-                                    remote_file.AppendPathComponent(module_sp->GetFileSpec().GetFilename().GetCString());
-                                }
-                            }
-                            if (remote_file)
-                            {
-                                error = platform_sp->Install(local_file, remote_file);
-                                if (error.Success())
-                                {
-                                    module_sp->SetPlatformFileSpec(remote_file);
-                                    if (is_main_executable)
-                                    {
-                                        platform_sp->SetFilePermissions(remote_file, 0700);
-                                        if (launch_info)
-                                            launch_info->SetExecutableFile(remote_file, false);
-                                    }
-                                }
-                                else
-                                    break;
-                            }
-                        }
-                    }
-                }
-            }
-        }
-    }
-    return error;
+FileSpecList Target::GetDefaultExecutableSearchPaths() {
+  TargetPropertiesSP properties_sp(Target::GetGlobalProperties());
+  if (properties_sp)
+    return properties_sp->GetExecutableSearchPaths();
+  return FileSpecList();
 }
 
-bool
-Target::ResolveLoadAddress (addr_t load_addr, Address &so_addr, uint32_t stop_id)
-{
-    return m_section_load_history.ResolveLoadAddress(stop_id, load_addr, so_addr);
+FileSpecList Target::GetDefaultDebugFileSearchPaths() {
+  TargetPropertiesSP properties_sp(Target::GetGlobalProperties());
+  if (properties_sp)
+    return properties_sp->GetDebugFileSearchPaths();
+  return FileSpecList();
 }
 
-bool
-Target::ResolveFileAddress (lldb::addr_t file_addr, Address &resolved_addr)
-{
-    return m_images.ResolveFileAddress(file_addr, resolved_addr);
+FileSpecList Target::GetDefaultClangModuleSearchPaths() {
+  TargetPropertiesSP properties_sp(Target::GetGlobalProperties());
+  if (properties_sp)
+    return properties_sp->GetClangModuleSearchPaths();
+  return FileSpecList();
 }
 
-bool
-Target::SetSectionLoadAddress (const SectionSP &section_sp, addr_t new_section_load_addr, bool warn_multiple)
-{
-    const addr_t old_section_load_addr = m_section_load_history.GetSectionLoadAddress (SectionLoadHistory::eStopIDNow, section_sp);
-    if (old_section_load_addr != new_section_load_addr)
-    {
-        uint32_t stop_id = 0;
-        ProcessSP process_sp(GetProcessSP());
-        if (process_sp)
-            stop_id = process_sp->GetStopID();
-        else
-            stop_id = m_section_load_history.GetLastStopID();
-        if (m_section_load_history.SetSectionLoadAddress (stop_id, section_sp, new_section_load_addr, warn_multiple))
-            return true; // Return true if the section load address was changed...
-    }
-    return false; // Return false to indicate nothing changed
+ArchSpec Target::GetDefaultArchitecture() {
+  TargetPropertiesSP properties_sp(Target::GetGlobalProperties());
+  if (properties_sp)
+    return properties_sp->GetDefaultArchitecture();
+  return ArchSpec();
 }
 
-size_t
-Target::UnloadModuleSections (const ModuleList &module_list)
-{
-    size_t section_unload_count = 0;
-    size_t num_modules = module_list.GetSize();
-    for (size_t i=0; i<num_modules; ++i)
-    {
-        section_unload_count += UnloadModuleSections (module_list.GetModuleAtIndex(i));
-    }
-    return section_unload_count;
+void Target::SetDefaultArchitecture(const ArchSpec &arch) {
+  TargetPropertiesSP properties_sp(Target::GetGlobalProperties());
+  if (properties_sp) {
+    LogIfAnyCategoriesSet(
+        LIBLLDB_LOG_TARGET, "Target::SetDefaultArchitecture setting target's "
+                            "default architecture to  %s (%s)",
+        arch.GetArchitectureName(), arch.GetTriple().getTriple().c_str());
+    return properties_sp->SetDefaultArchitecture(arch);
+  }
 }
 
-size_t
-Target::UnloadModuleSections (const lldb::ModuleSP &module_sp)
-{
-    uint32_t stop_id = 0;
-    ProcessSP process_sp(GetProcessSP());
-    if (process_sp)
-        stop_id = process_sp->GetStopID();
-    else
-        stop_id = m_section_load_history.GetLastStopID();
-    SectionList *sections = module_sp->GetSectionList();
-    size_t section_unload_count = 0;
-    if (sections)
-    {
-        const uint32_t num_sections = sections->GetNumSections(0);
-        for (uint32_t i = 0; i < num_sections; ++i)
-        {
-            section_unload_count += m_section_load_history.SetSectionUnloaded(stop_id, sections->GetSectionAtIndex(i));
-        }
-    }
-    return section_unload_count;
+Target *Target::GetTargetFromContexts(const ExecutionContext *exe_ctx_ptr,
+                                      const SymbolContext *sc_ptr) {
+  // The target can either exist in the "process" of ExecutionContext, or in
+  // the "target_sp" member of SymbolContext. This accessor helper function
+  // will get the target from one of these locations.
+
+  Target *target = nullptr;
+  if (sc_ptr != nullptr)
+    target = sc_ptr->target_sp.get();
+  if (target == nullptr && exe_ctx_ptr)
+    target = exe_ctx_ptr->GetTargetPtr();
+  return target;
 }
 
-bool
-Target::SetSectionUnloaded (const lldb::SectionSP &section_sp)
-{
-    uint32_t stop_id = 0;
-    ProcessSP process_sp(GetProcessSP());
-    if (process_sp)
-        stop_id = process_sp->GetStopID();
-    else
-        stop_id = m_section_load_history.GetLastStopID();
-    return m_section_load_history.SetSectionUnloaded (stop_id, section_sp);
+ExpressionResults Target::EvaluateExpression(
+    const char *expr_cstr, ExecutionContextScope *exe_scope,
+    lldb::ValueObjectSP &result_valobj_sp,
+    const EvaluateExpressionOptions &options, std::string *fixed_expression) {
+  result_valobj_sp.reset();
+
+  ExpressionResults execution_results = eExpressionSetupError;
+
+  if (expr_cstr == nullptr || expr_cstr[0] == '\0')
+    return execution_results;
+
+  // We shouldn't run stop hooks in expressions.
+  // Be sure to reset this if you return anywhere within this function.
+  bool old_suppress_value = m_suppress_stop_hooks;
+  m_suppress_stop_hooks = true;
+
+  ExecutionContext exe_ctx;
+
+  if (exe_scope) {
+    exe_scope->CalculateExecutionContext(exe_ctx);
+  } else if (m_process_sp) {
+    m_process_sp->CalculateExecutionContext(exe_ctx);
+  } else {
+    CalculateExecutionContext(exe_ctx);
+  }
+
+  // Make sure we aren't just trying to see the value of a persistent
+  // variable (something like "$0")
+  lldb::ExpressionVariableSP persistent_var_sp;
+  // Only check for persistent variables the expression starts with a '$'
+  if (expr_cstr[0] == '$')
+    persistent_var_sp = GetScratchTypeSystemForLanguage(nullptr, eLanguageTypeC)
+                            ->GetPersistentExpressionState()
+                            ->GetVariable(expr_cstr);
+
+  if (persistent_var_sp) {
+    result_valobj_sp = persistent_var_sp->GetValueObject();
+    execution_results = eExpressionCompleted;
+  } else {
+    const char *prefix = GetExpressionPrefixContentsAsCString();
+    Error error;
+    execution_results = UserExpression::Evaluate(
+        exe_ctx, options, expr_cstr, prefix, result_valobj_sp, error,
+        0, // Line Number
+        fixed_expression);
+  }
+
+  m_suppress_stop_hooks = old_suppress_value;
+
+  return execution_results;
 }
 
-bool
-Target::SetSectionUnloaded (const lldb::SectionSP &section_sp, addr_t load_addr)
-{
-    uint32_t stop_id = 0;
-    ProcessSP process_sp(GetProcessSP());
-    if (process_sp)
-        stop_id = process_sp->GetStopID();
-    else
-        stop_id = m_section_load_history.GetLastStopID();
-    return m_section_load_history.SetSectionUnloaded (stop_id, section_sp, load_addr);
+lldb::ExpressionVariableSP
+Target::GetPersistentVariable(const ConstString &name) {
+  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 Target::GetCallableLoadAddress(lldb::addr_t load_addr,
+                                            AddressClass addr_class) const {
+  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) {
+    case eAddressClassData:
+    case eAddressClassDebug:
+      return LLDB_INVALID_ADDRESS;
+
+    case eAddressClassUnknown:
+    case eAddressClassInvalid:
+    case eAddressClassCode:
+    case eAddressClassCodeAlternateISA:
+    case eAddressClassRuntime:
+      // Check if bit zero it no set?
+      if ((code_addr & 1ull) == 0) {
+        // Bit zero isn't set, check if the address is a multiple of 2?
+        if (code_addr & 2ull) {
+          // The address is a multiple of 2 so it must be thumb, set bit zero
+          code_addr |= 1ull;
+        } else if (addr_class == eAddressClassCodeAlternateISA) {
+          // We checked the address and the address claims to be the alternate
+          // ISA
+          // which means thumb, so set bit zero.
+          code_addr |= 1ull;
+        }
+      }
+      break;
+    }
+    break;
+
+  default:
+    break;
+  }
+  return code_addr;
+}
+
+lldb::addr_t Target::GetOpcodeLoadAddress(lldb::addr_t load_addr,
+                                          AddressClass addr_class) const {
+  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) {
+    case eAddressClassData:
+    case eAddressClassDebug:
+      return LLDB_INVALID_ADDRESS;
+
+    case eAddressClassInvalid:
+    case eAddressClassUnknown:
+    case eAddressClassCode:
+    case eAddressClassCodeAlternateISA:
+    case eAddressClassRuntime:
+      opcode_addr &= ~(1ull);
+      break;
+    }
+    break;
+
+  default:
+    break;
+  }
+  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);
+      Address sym_addr;
+      if (sc.function)
+        sym_addr = sc.function->GetAddressRange().GetBaseAddress();
+      else if (sc.symbol)
+        sym_addr = sc.symbol->GetAddress();
+
+      function_start = sym_addr.GetLoadAddress(this);
+      if (function_start == LLDB_INVALID_ADDRESS)
+        function_start = sym_addr.GetFileAddress();
+
+      if (function_start)
+        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;
 }
 
-void
-Target::ClearAllLoadedSections ()
-{
-    m_section_load_history.Clear();
+SourceManager &Target::GetSourceManager() {
+  if (!m_source_manager_ap)
+    m_source_manager_ap.reset(new SourceManager(shared_from_this()));
+  return *m_source_manager_ap;
 }
 
-Error
-Target::Launch (ProcessLaunchInfo &launch_info, Stream *stream)
-{
-    Error error;
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TARGET));
+ClangModulesDeclVendor *Target::GetClangModulesDeclVendor() {
+  static std::mutex s_clang_modules_decl_vendor_mutex; // If this is contended
+                                                       // we can make it
+                                                       // per-target
 
-    if (log)
-        log->Printf ("Target::%s() called for %s", __FUNCTION__, launch_info.GetExecutableFile().GetPath().c_str ());
+  {
+    std::lock_guard<std::mutex> guard(s_clang_modules_decl_vendor_mutex);
 
-    StateType state = eStateInvalid;
-    
-    // Scope to temporarily get the process state in case someone has manually
-    // remotely connected already to a process and we can skip the platform
-    // launching.
-    {
-        ProcessSP process_sp (GetProcessSP());
-    
-        if (process_sp)
-        {
-            state = process_sp->GetState();
-            if (log)
-                log->Printf ("Target::%s the process exists, and its current state is %s", __FUNCTION__, StateAsCString (state));
-        }
-        else
-        {
-            if (log)
-                log->Printf ("Target::%s the process instance doesn't currently exist.", __FUNCTION__);
-        }
+    if (!m_clang_modules_decl_vendor_ap) {
+      m_clang_modules_decl_vendor_ap.reset(
+          ClangModulesDeclVendor::Create(*this));
     }
+  }
 
-    launch_info.GetFlags().Set (eLaunchFlagDebug);
-    
-    // Get the value of synchronous execution here.  If you wait till after you have started to
-    // run, then you could have hit a breakpoint, whose command might switch the value, and
-    // then you'll pick up that incorrect value.
-    Debugger &debugger = GetDebugger();
-    const bool synchronous_execution = debugger.GetCommandInterpreter().GetSynchronous ();
-    
-    PlatformSP platform_sp (GetPlatform());
-    
-    // Finalize the file actions, and if none were given, default to opening
-    // up a pseudo terminal
-    const bool default_to_use_pty = platform_sp ? platform_sp->IsHost() : false;
-    if (log)
-        log->Printf ("Target::%s have platform=%s, platform_sp->IsHost()=%s, default_to_use_pty=%s",
-                     __FUNCTION__,
-                     platform_sp ? "true" : "false",
-                     platform_sp ? (platform_sp->IsHost () ? "true" : "false") : "n/a",
-                     default_to_use_pty ? "true" : "false");
-
-    launch_info.FinalizeFileActions (this, default_to_use_pty);
-    
-    if (state == eStateConnected)
-    {
-        if (launch_info.GetFlags().Test (eLaunchFlagLaunchInTTY))
-        {
-            error.SetErrorString("can't launch in tty when launching through a remote connection");
-            return error;
-        }
-    }
-    
-    if (!launch_info.GetArchitecture().IsValid())
-        launch_info.GetArchitecture() = GetArchitecture();
-
-    // If we're not already connected to the process, and if we have a platform that can launch a process for debugging, go ahead and do that here.
-    if (state != eStateConnected && platform_sp && platform_sp->CanDebugProcess ())
-    {
-        if (log)
-            log->Printf ("Target::%s asking the platform to debug the process", __FUNCTION__);
+  return m_clang_modules_decl_vendor_ap.get();
+}
 
-        // Get a weak pointer to the previous process if we have one
-        ProcessWP process_wp;
-        if (m_process_sp)
-            process_wp = m_process_sp;
-        m_process_sp = GetPlatform()->DebugProcess (launch_info,
-                                                    debugger,
-                                                    this,
-                                                    error);
-
-        // Cleanup the old process since someone might still have a strong
-        // reference to this process and we would like to allow it to cleanup
-        // as much as it can without the object being destroyed. We try to
-        // lock the shared pointer and if that works, then someone else still
-        // has a strong reference to the process.
-
-        ProcessSP old_process_sp(process_wp.lock());
-        if (old_process_sp)
-            old_process_sp->Finalize();
-    }
-    else
-    {
-        if (log)
-            log->Printf ("Target::%s the platform doesn't know how to debug a process, getting a process plugin to do this for us.", __FUNCTION__);
+Target::StopHookSP Target::CreateStopHook() {
+  lldb::user_id_t new_uid = ++m_stop_hook_next_id;
+  Target::StopHookSP stop_hook_sp(new StopHook(shared_from_this(), new_uid));
+  m_stop_hooks[new_uid] = stop_hook_sp;
+  return stop_hook_sp;
+}
 
-        if (state == eStateConnected)
-        {
-            assert(m_process_sp);
-        }
-        else
-        {
-            // Use a Process plugin to construct the process.
-            const char *plugin_name = launch_info.GetProcessPluginName();
-            CreateProcess(launch_info.GetListenerForProcess(debugger), plugin_name, nullptr);
-        }
+bool Target::RemoveStopHookByID(lldb::user_id_t user_id) {
+  size_t num_removed = m_stop_hooks.erase(user_id);
+  return (num_removed != 0);
+}
 
-        // Since we didn't have a platform launch the process, launch it here.
-        if (m_process_sp)
-            error = m_process_sp->Launch (launch_info);
-    }
-    
-    if (!m_process_sp)
-    {
-        if (error.Success())
-            error.SetErrorString("failed to launch or debug process");
-        return error;
-    }
+void Target::RemoveAllStopHooks() { m_stop_hooks.clear(); }
 
-    if (error.Success())
-    {
-        if (synchronous_execution || !launch_info.GetFlags().Test(eLaunchFlagStopAtEntry))
-        {
-            ListenerSP hijack_listener_sp (launch_info.GetHijackListener());
-            if (!hijack_listener_sp)
-            {
-                hijack_listener_sp = Listener::MakeListener("lldb.Target.Launch.hijack");
-                launch_info.SetHijackListener(hijack_listener_sp);
-                m_process_sp->HijackProcessEvents(hijack_listener_sp);
-            }
+Target::StopHookSP Target::GetStopHookByID(lldb::user_id_t user_id) {
+  StopHookSP found_hook;
+
+  StopHookCollection::iterator specified_hook_iter;
+  specified_hook_iter = m_stop_hooks.find(user_id);
+  if (specified_hook_iter != m_stop_hooks.end())
+    found_hook = (*specified_hook_iter).second;
+  return found_hook;
+}
 
-            StateType state = m_process_sp->WaitForProcessToStop(std::chrono::microseconds(0), nullptr, false,
-                                                                 hijack_listener_sp, nullptr);
+bool Target::SetStopHookActiveStateByID(lldb::user_id_t user_id,
+                                        bool active_state) {
+  StopHookCollection::iterator specified_hook_iter;
+  specified_hook_iter = m_stop_hooks.find(user_id);
+  if (specified_hook_iter == m_stop_hooks.end())
+    return false;
 
-            if (state == eStateStopped)
-            {
-                if (!launch_info.GetFlags().Test(eLaunchFlagStopAtEntry))
-                {
-                    if (synchronous_execution)
-                    {
-                        error = m_process_sp->PrivateResume();
-                        if (error.Success())
-                        {
-                            state = m_process_sp->WaitForProcessToStop(std::chrono::microseconds(0), nullptr, true,
-                                                                       hijack_listener_sp, stream);
-                            const bool must_be_alive = false; // eStateExited is ok, so this must be false
-                            if (!StateIsStoppedState(state, must_be_alive))
-                            {
-                                error.SetErrorStringWithFormat("process isn't stopped: %s", StateAsCString(state));
-                            }
-                        }
-                    }
-                    else
-                    {
-                        m_process_sp->RestoreProcessEvents();
-                        error = m_process_sp->PrivateResume();
-                    }
-                    if (!error.Success())
-                    {
-                        Error error2;
-                        error2.SetErrorStringWithFormat("process resume at entry point failed: %s", error.AsCString());
-                        error = error2;
-                    }
-                }
-            }
-            else if (state == eStateExited)
-            {
-                bool with_shell = !!launch_info.GetShell();
-                const int exit_status = m_process_sp->GetExitStatus();
-                const char *exit_desc = m_process_sp->GetExitDescription();
-#define LAUNCH_SHELL_MESSAGE "\n'r' and 'run' are aliases that default to launching through a shell.\nTry launching without going through a shell by using 'process launch'."
-                if (exit_desc && exit_desc[0])
-                {
-                    if (with_shell)
-                        error.SetErrorStringWithFormat ("process exited with status %i (%s)" LAUNCH_SHELL_MESSAGE, exit_status, exit_desc);
-                    else
-                        error.SetErrorStringWithFormat ("process exited with status %i (%s)", exit_status, exit_desc);
-                }
-                else
-                {
-                    if (with_shell)
-                        error.SetErrorStringWithFormat ("process exited with status %i" LAUNCH_SHELL_MESSAGE, exit_status);
-                    else
-                        error.SetErrorStringWithFormat ("process exited with status %i", exit_status);
-                }
-            }
-            else
-            {
-                error.SetErrorStringWithFormat ("initial process state wasn't stopped: %s", StateAsCString(state));
-            }
-        }
-        m_process_sp->RestoreProcessEvents ();
-    }
-    else
-    {
-        Error error2;
-        error2.SetErrorStringWithFormat ("process launch failed: %s", error.AsCString());
-        error = error2;
-    }
-    return error;
+  (*specified_hook_iter).second->SetIsActive(active_state);
+  return true;
 }
 
-Error
-Target::Attach (ProcessAttachInfo &attach_info, Stream *stream)
-{
-    auto state = eStateInvalid;
-    auto process_sp = GetProcessSP ();
+void Target::SetAllStopHooksActiveState(bool active_state) {
+  StopHookCollection::iterator pos, end = m_stop_hooks.end();
+  for (pos = m_stop_hooks.begin(); pos != end; pos++) {
+    (*pos).second->SetIsActive(active_state);
+  }
+}
+
+void Target::RunStopHooks() {
+  if (m_suppress_stop_hooks)
+    return;
+
+  if (!m_process_sp)
+    return;
+
+  // <rdar://problem/12027563> make sure we check that we are not stopped
+  // because of us running a user expression
+  // since in that case we do not want to run the stop-hooks
+  if (m_process_sp->GetModIDRef().IsLastResumeForUserExpression())
+    return;
+
+  if (m_stop_hooks.empty())
+    return;
+
+  StopHookCollection::iterator pos, end = m_stop_hooks.end();
+
+  // If there aren't any active stop hooks, don't bother either:
+  bool any_active_hooks = false;
+  for (pos = m_stop_hooks.begin(); pos != end; pos++) {
+    if ((*pos).second->IsActive()) {
+      any_active_hooks = true;
+      break;
+    }
+  }
+  if (!any_active_hooks)
+    return;
+
+  CommandReturnObject result;
+
+  std::vector<ExecutionContext> exc_ctx_with_reasons;
+  std::vector<SymbolContext> sym_ctx_with_reasons;
+
+  ThreadList &cur_threadlist = m_process_sp->GetThreadList();
+  size_t num_threads = cur_threadlist.GetSize();
+  for (size_t i = 0; i < num_threads; i++) {
+    lldb::ThreadSP cur_thread_sp = cur_threadlist.GetThreadAtIndex(i);
+    if (cur_thread_sp->ThreadStoppedForAReason()) {
+      lldb::StackFrameSP cur_frame_sp = cur_thread_sp->GetStackFrameAtIndex(0);
+      exc_ctx_with_reasons.push_back(ExecutionContext(
+          m_process_sp.get(), cur_thread_sp.get(), cur_frame_sp.get()));
+      sym_ctx_with_reasons.push_back(
+          cur_frame_sp->GetSymbolContext(eSymbolContextEverything));
+    }
+  }
+
+  // If no threads stopped for a reason, don't run the stop-hooks.
+  size_t num_exe_ctx = exc_ctx_with_reasons.size();
+  if (num_exe_ctx == 0)
+    return;
+
+  result.SetImmediateOutputStream(m_debugger.GetAsyncOutputStream());
+  result.SetImmediateErrorStream(m_debugger.GetAsyncErrorStream());
+
+  bool keep_going = true;
+  bool hooks_ran = false;
+  bool print_hook_header = (m_stop_hooks.size() != 1);
+  bool print_thread_header = (num_exe_ctx != 1);
+
+  for (pos = m_stop_hooks.begin(); keep_going && pos != end; pos++) {
+    // result.Clear();
+    StopHookSP cur_hook_sp = (*pos).second;
+    if (!cur_hook_sp->IsActive())
+      continue;
+
+    bool any_thread_matched = false;
+    for (size_t i = 0; keep_going && i < num_exe_ctx; i++) {
+      if ((cur_hook_sp->GetSpecifier() == nullptr ||
+           cur_hook_sp->GetSpecifier()->SymbolContextMatches(
+               sym_ctx_with_reasons[i])) &&
+          (cur_hook_sp->GetThreadSpecifier() == nullptr ||
+           cur_hook_sp->GetThreadSpecifier()->ThreadPassesBasicTests(
+               exc_ctx_with_reasons[i].GetThreadRef()))) {
+        if (!hooks_ran) {
+          hooks_ran = true;
+        }
+        if (print_hook_header && !any_thread_matched) {
+          const char *cmd =
+              (cur_hook_sp->GetCommands().GetSize() == 1
+                   ? cur_hook_sp->GetCommands().GetStringAtIndex(0)
+                   : nullptr);
+          if (cmd)
+            result.AppendMessageWithFormat("\n- Hook %" PRIu64 " (%s)\n",
+                                           cur_hook_sp->GetID(), cmd);
+          else
+            result.AppendMessageWithFormat("\n- Hook %" PRIu64 "\n",
+                                           cur_hook_sp->GetID());
+          any_thread_matched = true;
+        }
+
+        if (print_thread_header)
+          result.AppendMessageWithFormat(
+              "-- Thread %d\n",
+              exc_ctx_with_reasons[i].GetThreadPtr()->GetIndexID());
+
+        CommandInterpreterRunOptions options;
+        options.SetStopOnContinue(true);
+        options.SetStopOnError(true);
+        options.SetEchoCommands(false);
+        options.SetPrintResults(true);
+        options.SetAddToHistory(false);
+
+        GetDebugger().GetCommandInterpreter().HandleCommands(
+            cur_hook_sp->GetCommands(), &exc_ctx_with_reasons[i], options,
+            result);
+
+        // If the command started the target going again, we should bag out of
+        // running the stop hooks.
+        if ((result.GetStatus() == eReturnStatusSuccessContinuingNoResult) ||
+            (result.GetStatus() == eReturnStatusSuccessContinuingResult)) {
+          result.AppendMessageWithFormat("Aborting stop hooks, hook %" PRIu64
+                                         " set the program running.",
+                                         cur_hook_sp->GetID());
+          keep_going = false;
+        }
+      }
+    }
+  }
+
+  result.GetImmediateOutputStream()->Flush();
+  result.GetImmediateErrorStream()->Flush();
+}
+
+const TargetPropertiesSP &Target::GetGlobalProperties() {
+  // NOTE: intentional leak so we don't crash if global destructor chain gets
+  // called as other threads still use the result of this function
+  static TargetPropertiesSP *g_settings_sp_ptr = nullptr;
+  static std::once_flag g_once_flag;
+  std::call_once(g_once_flag, []() {
+    g_settings_sp_ptr = new TargetPropertiesSP(new TargetProperties(nullptr));
+  });
+  return *g_settings_sp_ptr;
+}
+
+Error Target::Install(ProcessLaunchInfo *launch_info) {
+  Error error;
+  PlatformSP platform_sp(GetPlatform());
+  if (platform_sp) {
+    if (platform_sp->IsRemote()) {
+      if (platform_sp->IsConnected()) {
+        // Install all files that have an install path, and always install the
+        // main executable when connected to a remote platform
+        const ModuleList &modules = GetImages();
+        const size_t num_images = modules.GetSize();
+        for (size_t idx = 0; idx < num_images; ++idx) {
+          ModuleSP module_sp(modules.GetModuleAtIndex(idx));
+          if (module_sp) {
+            const bool is_main_executable = module_sp == GetExecutableModule();
+            FileSpec local_file(module_sp->GetFileSpec());
+            if (local_file) {
+              FileSpec remote_file(module_sp->GetRemoteInstallFileSpec());
+              if (!remote_file) {
+                if (is_main_executable) // TODO: add setting for always
+                                        // installing main executable???
+                {
+                  // Always install the main executable
+                  remote_file = platform_sp->GetRemoteWorkingDirectory();
+                  remote_file.AppendPathComponent(
+                      module_sp->GetFileSpec().GetFilename().GetCString());
+                }
+              }
+              if (remote_file) {
+                error = platform_sp->Install(local_file, remote_file);
+                if (error.Success()) {
+                  module_sp->SetPlatformFileSpec(remote_file);
+                  if (is_main_executable) {
+                    platform_sp->SetFilePermissions(remote_file, 0700);
+                    if (launch_info)
+                      launch_info->SetExecutableFile(remote_file, false);
+                  }
+                } else
+                  break;
+              }
+            }
+          }
+        }
+      }
+    }
+  }
+  return error;
+}
+
+bool Target::ResolveLoadAddress(addr_t load_addr, Address &so_addr,
+                                uint32_t stop_id) {
+  return m_section_load_history.ResolveLoadAddress(stop_id, load_addr, so_addr);
+}
+
+bool Target::ResolveFileAddress(lldb::addr_t file_addr,
+                                Address &resolved_addr) {
+  return m_images.ResolveFileAddress(file_addr, resolved_addr);
+}
+
+bool Target::SetSectionLoadAddress(const SectionSP &section_sp,
+                                   addr_t new_section_load_addr,
+                                   bool warn_multiple) {
+  const addr_t old_section_load_addr =
+      m_section_load_history.GetSectionLoadAddress(
+          SectionLoadHistory::eStopIDNow, section_sp);
+  if (old_section_load_addr != new_section_load_addr) {
+    uint32_t stop_id = 0;
+    ProcessSP process_sp(GetProcessSP());
     if (process_sp)
-    {
-        state = process_sp->GetState ();
-        if (process_sp->IsAlive () && state != eStateConnected)
-        {
-            if (state == eStateAttaching)
-                return Error ("process attach is in progress");
-            return Error ("a process is already being debugged");
-        }
-    }
+      stop_id = process_sp->GetStopID();
+    else
+      stop_id = m_section_load_history.GetLastStopID();
+    if (m_section_load_history.SetSectionLoadAddress(
+            stop_id, section_sp, new_section_load_addr, warn_multiple))
+      return true; // Return true if the section load address was changed...
+  }
+  return false; // Return false to indicate nothing changed
+}
+
+size_t Target::UnloadModuleSections(const ModuleList &module_list) {
+  size_t section_unload_count = 0;
+  size_t num_modules = module_list.GetSize();
+  for (size_t i = 0; i < num_modules; ++i) {
+    section_unload_count +=
+        UnloadModuleSections(module_list.GetModuleAtIndex(i));
+  }
+  return section_unload_count;
+}
+
+size_t Target::UnloadModuleSections(const lldb::ModuleSP &module_sp) {
+  uint32_t stop_id = 0;
+  ProcessSP process_sp(GetProcessSP());
+  if (process_sp)
+    stop_id = process_sp->GetStopID();
+  else
+    stop_id = m_section_load_history.GetLastStopID();
+  SectionList *sections = module_sp->GetSectionList();
+  size_t section_unload_count = 0;
+  if (sections) {
+    const uint32_t num_sections = sections->GetNumSections(0);
+    for (uint32_t i = 0; i < num_sections; ++i) {
+      section_unload_count += m_section_load_history.SetSectionUnloaded(
+          stop_id, sections->GetSectionAtIndex(i));
+    }
+  }
+  return section_unload_count;
+}
+
+bool Target::SetSectionUnloaded(const lldb::SectionSP &section_sp) {
+  uint32_t stop_id = 0;
+  ProcessSP process_sp(GetProcessSP());
+  if (process_sp)
+    stop_id = process_sp->GetStopID();
+  else
+    stop_id = m_section_load_history.GetLastStopID();
+  return m_section_load_history.SetSectionUnloaded(stop_id, section_sp);
+}
+
+bool Target::SetSectionUnloaded(const lldb::SectionSP &section_sp,
+                                addr_t load_addr) {
+  uint32_t stop_id = 0;
+  ProcessSP process_sp(GetProcessSP());
+  if (process_sp)
+    stop_id = process_sp->GetStopID();
+  else
+    stop_id = m_section_load_history.GetLastStopID();
+  return m_section_load_history.SetSectionUnloaded(stop_id, section_sp,
+                                                   load_addr);
+}
+
+void Target::ClearAllLoadedSections() { m_section_load_history.Clear(); }
+
+Error Target::Launch(ProcessLaunchInfo &launch_info, Stream *stream) {
+  Error error;
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_TARGET));
+
+  if (log)
+    log->Printf("Target::%s() called for %s", __FUNCTION__,
+                launch_info.GetExecutableFile().GetPath().c_str());
+
+  StateType state = eStateInvalid;
+
+  // Scope to temporarily get the process state in case someone has manually
+  // remotely connected already to a process and we can skip the platform
+  // launching.
+  {
+    ProcessSP process_sp(GetProcessSP());
 
-    const ModuleSP old_exec_module_sp = GetExecutableModule ();
+    if (process_sp) {
+      state = process_sp->GetState();
+      if (log)
+        log->Printf(
+            "Target::%s the process exists, and its current state is %s",
+            __FUNCTION__, StateAsCString(state));
+    } else {
+      if (log)
+        log->Printf("Target::%s the process instance doesn't currently exist.",
+                    __FUNCTION__);
+    }
+  }
+
+  launch_info.GetFlags().Set(eLaunchFlagDebug);
+
+  // Get the value of synchronous execution here.  If you wait till after you
+  // have started to
+  // run, then you could have hit a breakpoint, whose command might switch the
+  // value, and
+  // then you'll pick up that incorrect value.
+  Debugger &debugger = GetDebugger();
+  const bool synchronous_execution =
+      debugger.GetCommandInterpreter().GetSynchronous();
+
+  PlatformSP platform_sp(GetPlatform());
+
+  // Finalize the file actions, and if none were given, default to opening
+  // up a pseudo terminal
+  const bool default_to_use_pty = platform_sp ? platform_sp->IsHost() : false;
+  if (log)
+    log->Printf("Target::%s have platform=%s, platform_sp->IsHost()=%s, "
+                "default_to_use_pty=%s",
+                __FUNCTION__, platform_sp ? "true" : "false",
+                platform_sp ? (platform_sp->IsHost() ? "true" : "false")
+                            : "n/a",
+                default_to_use_pty ? "true" : "false");
+
+  launch_info.FinalizeFileActions(this, default_to_use_pty);
+
+  if (state == eStateConnected) {
+    if (launch_info.GetFlags().Test(eLaunchFlagLaunchInTTY)) {
+      error.SetErrorString(
+          "can't launch in tty when launching through a remote connection");
+      return error;
+    }
+  }
+
+  if (!launch_info.GetArchitecture().IsValid())
+    launch_info.GetArchitecture() = GetArchitecture();
+
+  // If we're not already connected to the process, and if we have a platform
+  // that can launch a process for debugging, go ahead and do that here.
+  if (state != eStateConnected && platform_sp &&
+      platform_sp->CanDebugProcess()) {
+    if (log)
+      log->Printf("Target::%s asking the platform to debug the process",
+                  __FUNCTION__);
 
-    // If no process info was specified, then use the target executable
-    // name as the process to attach to by default
-    if (!attach_info.ProcessInfoSpecified ())
-    {
-        if (old_exec_module_sp)
-            attach_info.GetExecutableFile ().GetFilename () = old_exec_module_sp->GetPlatformFileSpec ().GetFilename ();
-
-        if (!attach_info.ProcessInfoSpecified ())
-        {
-            return Error ("no process specified, create a target with a file, or specify the --pid or --name");
-        }
+    // Get a weak pointer to the previous process if we have one
+    ProcessWP process_wp;
+    if (m_process_sp)
+      process_wp = m_process_sp;
+    m_process_sp =
+        GetPlatform()->DebugProcess(launch_info, debugger, this, error);
+
+    // Cleanup the old process since someone might still have a strong
+    // reference to this process and we would like to allow it to cleanup
+    // as much as it can without the object being destroyed. We try to
+    // lock the shared pointer and if that works, then someone else still
+    // has a strong reference to the process.
+
+    ProcessSP old_process_sp(process_wp.lock());
+    if (old_process_sp)
+      old_process_sp->Finalize();
+  } else {
+    if (log)
+      log->Printf("Target::%s the platform doesn't know how to debug a "
+                  "process, getting a process plugin to do this for us.",
+                  __FUNCTION__);
+
+    if (state == eStateConnected) {
+      assert(m_process_sp);
+    } else {
+      // Use a Process plugin to construct the process.
+      const char *plugin_name = launch_info.GetProcessPluginName();
+      CreateProcess(launch_info.GetListenerForProcess(debugger), plugin_name,
+                    nullptr);
     }
 
-    const auto platform_sp = GetDebugger ().GetPlatformList ().GetSelectedPlatform ();
-    ListenerSP hijack_listener_sp;
-    const bool async = attach_info.GetAsync();
-    if (!async)
-    {
-        hijack_listener_sp = Listener::MakeListener("lldb.Target.Attach.attach.hijack");
-        attach_info.SetHijackListener (hijack_listener_sp);
-    }
+    // Since we didn't have a platform launch the process, launch it here.
+    if (m_process_sp)
+      error = m_process_sp->Launch(launch_info);
+  }
 
-    Error error;
-    if (state != eStateConnected && platform_sp != nullptr && platform_sp->CanDebugProcess ())
-    {
-        SetPlatform (platform_sp);
-        process_sp = platform_sp->Attach (attach_info, GetDebugger (), this, error);
-    }
-    else
-    {
-        if (state != eStateConnected)
-        {
-            const char *plugin_name = attach_info.GetProcessPluginName ();
-            process_sp = CreateProcess (attach_info.GetListenerForProcess (GetDebugger ()), plugin_name, nullptr);
-            if (process_sp == nullptr)
-            {
-                error.SetErrorStringWithFormat ("failed to create process using plugin %s", (plugin_name) ? plugin_name : "null");
-                return error;
-            }
-        }
-        if (hijack_listener_sp)
-            process_sp->HijackProcessEvents (hijack_listener_sp);
-        error = process_sp->Attach (attach_info);
-    }
+  if (!m_process_sp) {
+    if (error.Success())
+      error.SetErrorString("failed to launch or debug process");
+    return error;
+  }
 
-    if (error.Success () && process_sp)
-    {
-        if (async)
-        {
-            process_sp->RestoreProcessEvents ();
-        }
+  if (error.Success()) {
+    if (synchronous_execution ||
+        !launch_info.GetFlags().Test(eLaunchFlagStopAtEntry)) {
+      ListenerSP hijack_listener_sp(launch_info.GetHijackListener());
+      if (!hijack_listener_sp) {
+        hijack_listener_sp =
+            Listener::MakeListener("lldb.Target.Launch.hijack");
+        launch_info.SetHijackListener(hijack_listener_sp);
+        m_process_sp->HijackProcessEvents(hijack_listener_sp);
+      }
+
+      StateType state = m_process_sp->WaitForProcessToStop(
+          std::chrono::microseconds(0), nullptr, false, hijack_listener_sp,
+          nullptr);
+
+      if (state == eStateStopped) {
+        if (!launch_info.GetFlags().Test(eLaunchFlagStopAtEntry)) {
+          if (synchronous_execution) {
+            error = m_process_sp->PrivateResume();
+            if (error.Success()) {
+              state = m_process_sp->WaitForProcessToStop(
+                  std::chrono::microseconds(0), nullptr, true,
+                  hijack_listener_sp, stream);
+              const bool must_be_alive =
+                  false; // eStateExited is ok, so this must be false
+              if (!StateIsStoppedState(state, must_be_alive)) {
+                error.SetErrorStringWithFormat("process isn't stopped: %s",
+                                               StateAsCString(state));
+              }
+            }
+          } else {
+            m_process_sp->RestoreProcessEvents();
+            error = m_process_sp->PrivateResume();
+          }
+          if (!error.Success()) {
+            Error error2;
+            error2.SetErrorStringWithFormat(
+                "process resume at entry point failed: %s", error.AsCString());
+            error = error2;
+          }
+        }
+      } else if (state == eStateExited) {
+        bool with_shell = !!launch_info.GetShell();
+        const int exit_status = m_process_sp->GetExitStatus();
+        const char *exit_desc = m_process_sp->GetExitDescription();
+#define LAUNCH_SHELL_MESSAGE                                                   \
+  "\n'r' and 'run' are aliases that default to launching through a "           \
+  "shell.\nTry launching without going through a shell by using 'process "     \
+  "launch'."
+        if (exit_desc && exit_desc[0]) {
+          if (with_shell)
+            error.SetErrorStringWithFormat(
+                "process exited with status %i (%s)" LAUNCH_SHELL_MESSAGE,
+                exit_status, exit_desc);
+          else
+            error.SetErrorStringWithFormat("process exited with status %i (%s)",
+                                           exit_status, exit_desc);
+        } else {
+          if (with_shell)
+            error.SetErrorStringWithFormat(
+                "process exited with status %i" LAUNCH_SHELL_MESSAGE,
+                exit_status);
+          else
+            error.SetErrorStringWithFormat("process exited with status %i",
+                                           exit_status);
+        }
+      } else {
+        error.SetErrorStringWithFormat(
+            "initial process state wasn't stopped: %s", StateAsCString(state));
+      }
+    }
+    m_process_sp->RestoreProcessEvents();
+  } else {
+    Error error2;
+    error2.SetErrorStringWithFormat("process launch failed: %s",
+                                    error.AsCString());
+    error = error2;
+  }
+  return error;
+}
+
+Error Target::Attach(ProcessAttachInfo &attach_info, Stream *stream) {
+  auto state = eStateInvalid;
+  auto process_sp = GetProcessSP();
+  if (process_sp) {
+    state = process_sp->GetState();
+    if (process_sp->IsAlive() && state != eStateConnected) {
+      if (state == eStateAttaching)
+        return Error("process attach is in progress");
+      return Error("a process is already being debugged");
+    }
+  }
+
+  const ModuleSP old_exec_module_sp = GetExecutableModule();
+
+  // If no process info was specified, then use the target executable
+  // name as the process to attach to by default
+  if (!attach_info.ProcessInfoSpecified()) {
+    if (old_exec_module_sp)
+      attach_info.GetExecutableFile().GetFilename() =
+          old_exec_module_sp->GetPlatformFileSpec().GetFilename();
+
+    if (!attach_info.ProcessInfoSpecified()) {
+      return Error("no process specified, create a target with a file, or "
+                   "specify the --pid or --name");
+    }
+  }
+
+  const auto platform_sp =
+      GetDebugger().GetPlatformList().GetSelectedPlatform();
+  ListenerSP hijack_listener_sp;
+  const bool async = attach_info.GetAsync();
+  if (!async) {
+    hijack_listener_sp =
+        Listener::MakeListener("lldb.Target.Attach.attach.hijack");
+    attach_info.SetHijackListener(hijack_listener_sp);
+  }
+
+  Error error;
+  if (state != eStateConnected && platform_sp != nullptr &&
+      platform_sp->CanDebugProcess()) {
+    SetPlatform(platform_sp);
+    process_sp = platform_sp->Attach(attach_info, GetDebugger(), this, error);
+  } else {
+    if (state != eStateConnected) {
+      const char *plugin_name = attach_info.GetProcessPluginName();
+      process_sp =
+          CreateProcess(attach_info.GetListenerForProcess(GetDebugger()),
+                        plugin_name, nullptr);
+      if (process_sp == nullptr) {
+        error.SetErrorStringWithFormat(
+            "failed to create process using plugin %s",
+            (plugin_name) ? plugin_name : "null");
+        return error;
+      }
+    }
+    if (hijack_listener_sp)
+      process_sp->HijackProcessEvents(hijack_listener_sp);
+    error = process_sp->Attach(attach_info);
+  }
+
+  if (error.Success() && process_sp) {
+    if (async) {
+      process_sp->RestoreProcessEvents();
+    } else {
+      state = process_sp->WaitForProcessToStop(
+          std::chrono::microseconds(0), nullptr, false,
+          attach_info.GetHijackListener(), stream);
+      process_sp->RestoreProcessEvents();
+
+      if (state != eStateStopped) {
+        const char *exit_desc = process_sp->GetExitDescription();
+        if (exit_desc)
+          error.SetErrorStringWithFormat("%s", exit_desc);
         else
-        {
-            state = process_sp->WaitForProcessToStop(std::chrono::microseconds(0), nullptr, false,
-                                                     attach_info.GetHijackListener(), 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);
-            }
-        }
+          error.SetErrorString(
+              "process did not stop (no such process or permission problem?)");
+        process_sp->Destroy(false);
+      }
     }
-    return error;
+  }
+  return error;
 }
 
 //--------------------------------------------------------------
 // Target::StopHook
 //--------------------------------------------------------------
-Target::StopHook::StopHook (lldb::TargetSP target_sp, lldb::user_id_t uid) :
-        UserID (uid),
-        m_target_sp (target_sp),
-        m_commands (),
-        m_specifier_sp (),
-        m_thread_spec_ap(),
-        m_active (true)
-{
+Target::StopHook::StopHook(lldb::TargetSP target_sp, lldb::user_id_t uid)
+    : UserID(uid), m_target_sp(target_sp), m_commands(), m_specifier_sp(),
+      m_thread_spec_ap(), m_active(true) {}
+
+Target::StopHook::StopHook(const StopHook &rhs)
+    : UserID(rhs.GetID()), m_target_sp(rhs.m_target_sp),
+      m_commands(rhs.m_commands), m_specifier_sp(rhs.m_specifier_sp),
+      m_thread_spec_ap(), m_active(rhs.m_active) {
+  if (rhs.m_thread_spec_ap)
+    m_thread_spec_ap.reset(new ThreadSpec(*rhs.m_thread_spec_ap.get()));
 }
 
-Target::StopHook::StopHook (const StopHook &rhs) :
-        UserID (rhs.GetID()),
-        m_target_sp (rhs.m_target_sp),
-        m_commands (rhs.m_commands),
-        m_specifier_sp (rhs.m_specifier_sp),
-        m_thread_spec_ap (),
-        m_active (rhs.m_active)
-{
-    if (rhs.m_thread_spec_ap)
-        m_thread_spec_ap.reset (new ThreadSpec(*rhs.m_thread_spec_ap.get()));
-}
-        
 Target::StopHook::~StopHook() = default;
 
-void
-Target::StopHook::SetSpecifier(SymbolContextSpecifier *specifier)
-{
-    m_specifier_sp.reset(specifier);
+void Target::StopHook::SetSpecifier(SymbolContextSpecifier *specifier) {
+  m_specifier_sp.reset(specifier);
 }
 
-void
-Target::StopHook::SetThreadSpecifier (ThreadSpec *specifier)
-{
-    m_thread_spec_ap.reset (specifier);
+void Target::StopHook::SetThreadSpecifier(ThreadSpec *specifier) {
+  m_thread_spec_ap.reset(specifier);
 }
 
-void
-Target::StopHook::GetDescription (Stream *s, lldb::DescriptionLevel level) const
-{
-    int indent_level = s->GetIndentLevel();
+void Target::StopHook::GetDescription(Stream *s,
+                                      lldb::DescriptionLevel level) const {
+  int indent_level = s->GetIndentLevel();
+
+  s->SetIndentLevel(indent_level + 2);
 
+  s->Printf("Hook: %" PRIu64 "\n", GetID());
+  if (m_active)
+    s->Indent("State: enabled\n");
+  else
+    s->Indent("State: disabled\n");
+
+  if (m_specifier_sp) {
+    s->Indent();
+    s->PutCString("Specifier:\n");
+    s->SetIndentLevel(indent_level + 4);
+    m_specifier_sp->GetDescription(s, level);
     s->SetIndentLevel(indent_level + 2);
+  }
 
-    s->Printf ("Hook: %" PRIu64 "\n", GetID());
-    if (m_active)
-        s->Indent ("State: enabled\n");
-    else
-        s->Indent ("State: disabled\n");    
-    
-    if (m_specifier_sp)
-    {
-        s->Indent();
-        s->PutCString ("Specifier:\n");
-        s->SetIndentLevel (indent_level + 4);
-        m_specifier_sp->GetDescription (s, level);
-        s->SetIndentLevel (indent_level + 2);
-    }
-
-    if (m_thread_spec_ap)
-    {
-        StreamString tmp;
-        s->Indent("Thread:\n");
-        m_thread_spec_ap->GetDescription (&tmp, level);
-        s->SetIndentLevel (indent_level + 4);
-        s->Indent (tmp.GetData());
-        s->PutCString ("\n");
-        s->SetIndentLevel (indent_level + 2);
-    }
-
-    s->Indent ("Commands: \n");
-    s->SetIndentLevel (indent_level + 4);
-    uint32_t num_commands = m_commands.GetSize();
-    for (uint32_t i = 0; i < num_commands; i++)
-    {
-        s->Indent(m_commands.GetStringAtIndex(i));
-        s->PutCString ("\n");
-    }
-    s->SetIndentLevel (indent_level);
+  if (m_thread_spec_ap) {
+    StreamString tmp;
+    s->Indent("Thread:\n");
+    m_thread_spec_ap->GetDescription(&tmp, level);
+    s->SetIndentLevel(indent_level + 4);
+    s->Indent(tmp.GetData());
+    s->PutCString("\n");
+    s->SetIndentLevel(indent_level + 2);
+  }
+
+  s->Indent("Commands: \n");
+  s->SetIndentLevel(indent_level + 4);
+  uint32_t num_commands = m_commands.GetSize();
+  for (uint32_t i = 0; i < num_commands; i++) {
+    s->Indent(m_commands.GetStringAtIndex(i));
+    s->PutCString("\n");
+  }
+  s->SetIndentLevel(indent_level);
 }
 
 //--------------------------------------------------------------
 // class TargetProperties
 //--------------------------------------------------------------
 
-OptionEnumValueElement
-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, nullptr, nullptr }
-};
-
-static OptionEnumValueElement
-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, nullptr, nullptr }
-};
-
-typedef enum x86DisassemblyFlavor
-{
-    eX86DisFlavorDefault,
-    eX86DisFlavorIntel,
-    eX86DisFlavorATT
+OptionEnumValueElement 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, nullptr, nullptr}};
+
+static OptionEnumValueElement 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, nullptr, nullptr}};
+
+typedef enum x86DisassemblyFlavor {
+  eX86DisFlavorDefault,
+  eX86DisFlavorIntel,
+  eX86DisFlavorATT
 } x86DisassemblyFlavor;
 
-static OptionEnumValueElement
-g_x86_dis_flavor_value_types[] =
-{
-    { eX86DisFlavorDefault, "default", "Disassembler default (currently att)."},
-    { eX86DisFlavorIntel,   "intel",   "Intel disassembler flavor."},
-    { eX86DisFlavorATT,     "att",     "AT&T disassembler flavor."},
-    { 0, nullptr, nullptr }
-};
-
-static OptionEnumValueElement
-g_hex_immediate_style_values[] =
-{
-    { Disassembler::eHexStyleC,        "c",      "C-style (0xffff)."},
-    { Disassembler::eHexStyleAsm,      "asm",    "Asm-style (0ffffh)."},
-    { 0, nullptr, nullptr }
-};
-
-static OptionEnumValueElement
-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, nullptr, nullptr }
-};
-
-static OptionEnumValueElement
-g_load_current_working_dir_lldbinit_values[] =
-{
-    { eLoadCWDlldbinitTrue,    "true",    "Load .lldbinit files from current directory"},
-    { eLoadCWDlldbinitFalse,   "false",   "Do not load .lldbinit files from current directory"},
-    { eLoadCWDlldbinitWarn,    "warn",    "Warn about loading .lldbinit files from current directory"},
-    { 0, nullptr, nullptr }
+static OptionEnumValueElement g_x86_dis_flavor_value_types[] = {
+    {eX86DisFlavorDefault, "default", "Disassembler default (currently att)."},
+    {eX86DisFlavorIntel, "intel", "Intel disassembler flavor."},
+    {eX86DisFlavorATT, "att", "AT&T disassembler flavor."},
+    {0, nullptr, nullptr}};
+
+static OptionEnumValueElement g_hex_immediate_style_values[] = {
+    {Disassembler::eHexStyleC, "c", "C-style (0xffff)."},
+    {Disassembler::eHexStyleAsm, "asm", "Asm-style (0ffffh)."},
+    {0, nullptr, nullptr}};
+
+static OptionEnumValueElement 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, nullptr, nullptr}};
+
+static OptionEnumValueElement g_load_current_working_dir_lldbinit_values[] = {
+    {eLoadCWDlldbinitTrue, "true",
+     "Load .lldbinit files from current directory"},
+    {eLoadCWDlldbinitFalse, "false",
+     "Do not load .lldbinit files from current directory"},
+    {eLoadCWDlldbinitWarn, "warn",
+     "Warn about loading .lldbinit files from current directory"},
+    {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, nullptr, nullptr}};
+
+static PropertyDefinition g_properties[] = {
+    {"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, 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, true,
+     nullptr, nullptr,
+     "Automatically load Clang modules referred to by the program."},
+    {"auto-apply-fixits", OptionValue::eTypeBoolean, false, true, nullptr,
+     nullptr, "Automatically apply fix-it hints to expressions."},
+    {"notify-about-fixits", OptionValue::eTypeBoolean, false, true, nullptr,
+     nullptr, "Print the fixed expression text."},
+    {"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. "
+     "Always checking for inlined breakpoint locations can be expensive "
+     "(memory and time), so if you have a project with many headers "
+     "and find that setting breakpoints is slow, then you can change this "
+     "setting to headers. "
+     "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, 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."},
+    {"load-cwd-lldbinit", OptionValue::eTypeEnum, false, eLoadCWDlldbinitWarn,
+     nullptr, g_load_current_working_dir_lldbinit_values,
+     "Allow LLDB to .lldbinit files from the current directory automatically."},
+    {"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,
+     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,
+  ePropertySkipPrologue,
+  ePropertySourceMap,
+  ePropertyExecutableSearchPaths,
+  ePropertyDebugFileSearchPaths,
+  ePropertyClangModuleSearchPaths,
+  ePropertyAutoImportClangModules,
+  ePropertyAutoApplyFixIts,
+  ePropertyNotifyAboutFixIts,
+  ePropertyMaxChildrenCount,
+  ePropertyMaxSummaryLength,
+  ePropertyMaxMemReadSize,
+  ePropertyBreakpointUseAvoidList,
+  ePropertyArg0,
+  ePropertyRunArgs,
+  ePropertyEnvVars,
+  ePropertyInheritEnv,
+  ePropertyInputPath,
+  ePropertyOutputPath,
+  ePropertyErrorPath,
+  ePropertyDetachOnError,
+  ePropertyDisableASLR,
+  ePropertyDisableSTDIO,
+  ePropertyInlineStrategy,
+  ePropertyDisassemblyFlavor,
+  ePropertyUseHexImmediates,
+  ePropertyHexImmediateStyle,
+  ePropertyUseFastStepping,
+  ePropertyLoadScriptFromSymbolFile,
+  ePropertyLoadCWDlldbinitFile,
+  ePropertyMemoryModuleLoadLevel,
+  ePropertyDisplayExpressionsInCrashlogs,
+  ePropertyTrapHandlerNames,
+  ePropertyDisplayRuntimeSupportValues,
+  ePropertyNonStopModeEnabled,
+  ePropertyExperimental
 };
 
-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, nullptr, nullptr }
-};
+class TargetOptionValueProperties : public OptionValueProperties {
+public:
+  TargetOptionValueProperties(const ConstString &name)
+      : OptionValueProperties(name), m_target(nullptr), m_got_host_env(false) {}
 
-static PropertyDefinition
-g_properties[] =
-{
-    { "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                       , 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, true                      , nullptr, nullptr, "Automatically load Clang modules referred to by the program." },
-    { "auto-apply-fixits"                  , OptionValue::eTypeBoolean   , false, true                      , nullptr, nullptr, "Automatically apply fix-it hints to expressions." },
-    { "notify-about-fixits"                , OptionValue::eTypeBoolean   , false, true                      , nullptr, nullptr, "Print the fixed expression text." },
-    { "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. "
-        "Always checking for inlined breakpoint locations can be expensive (memory and time), so if you have a project with many headers "
-        "and find that setting breakpoints is slow, then you can change this setting to headers. "
-        "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,       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." },
-    { "load-cwd-lldbinit"                  , OptionValue::eTypeEnum   ,    false, eLoadCWDlldbinitWarn,       nullptr, g_load_current_working_dir_lldbinit_values, "Allow LLDB to .lldbinit files from the current directory automatically." },
-    { "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,                      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 }
-};
+  // This constructor is used when creating TargetOptionValueProperties when it
+  // is part of a new lldb_private::Target instance. It will copy all current
+  // global property values as needed
+  TargetOptionValueProperties(Target *target,
+                              const TargetPropertiesSP &target_properties_sp)
+      : OptionValueProperties(*target_properties_sp->GetValueProperties()),
+        m_target(target), m_got_host_env(false) {}
+
+  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
+    // use the one from this instance.
+    if (idx == ePropertyEnvVars)
+      GetHostEnvironmentIfNeeded();
+
+    if (exe_ctx) {
+      Target *target = exe_ctx->GetTargetPtr();
+      if (target) {
+        TargetOptionValueProperties *target_properties =
+            static_cast<TargetOptionValueProperties *>(
+                target->GetValueProperties().get());
+        if (this != target_properties)
+          return target_properties->ProtectedGetPropertyAtIndex(idx);
+      }
+    }
+    return ProtectedGetPropertyAtIndex(idx);
+  }
 
-enum
-{
-    ePropertyDefaultArch,
-    ePropertyMoveToNearestCode,
-    ePropertyLanguage,
-    ePropertyExprPrefix,
-    ePropertyPreferDynamic,
-    ePropertyEnableSynthetic,
-    ePropertySkipPrologue,
-    ePropertySourceMap,
-    ePropertyExecutableSearchPaths,
-    ePropertyDebugFileSearchPaths,
-    ePropertyClangModuleSearchPaths,
-    ePropertyAutoImportClangModules,
-    ePropertyAutoApplyFixIts,
-    ePropertyNotifyAboutFixIts,
-    ePropertyMaxChildrenCount,
-    ePropertyMaxSummaryLength,
-    ePropertyMaxMemReadSize,
-    ePropertyBreakpointUseAvoidList,
-    ePropertyArg0,
-    ePropertyRunArgs,
-    ePropertyEnvVars,
-    ePropertyInheritEnv,
-    ePropertyInputPath,
-    ePropertyOutputPath,
-    ePropertyErrorPath,
-    ePropertyDetachOnError,
-    ePropertyDisableASLR,
-    ePropertyDisableSTDIO,
-    ePropertyInlineStrategy,
-    ePropertyDisassemblyFlavor,
-    ePropertyUseHexImmediates,
-    ePropertyHexImmediateStyle,
-    ePropertyUseFastStepping,
-    ePropertyLoadScriptFromSymbolFile,
-    ePropertyLoadCWDlldbinitFile,
-    ePropertyMemoryModuleLoadLevel,
-    ePropertyDisplayExpressionsInCrashlogs,
-    ePropertyTrapHandlerNames,
-    ePropertyDisplayRuntimeSupportValues,
-    ePropertyNonStopModeEnabled,
-    ePropertyExperimental
-};
+  lldb::TargetSP GetTargetSP() { return m_target->shared_from_this(); }
 
-class TargetOptionValueProperties : public OptionValueProperties
-{
-public:
-    TargetOptionValueProperties (const ConstString &name) :
-        OptionValueProperties (name),
-        m_target(nullptr),
-        m_got_host_env (false)
-    {
-    }
-
-    // This constructor is used when creating TargetOptionValueProperties when it
-    // is part of a new lldb_private::Target instance. It will copy all current
-    // global property values as needed
-    TargetOptionValueProperties (Target *target, const TargetPropertiesSP &target_properties_sp) :
-        OptionValueProperties(*target_properties_sp->GetValueProperties()),
-        m_target (target),
-        m_got_host_env (false)
-    {
-    }
-
-    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
-        // use the one from this instance.
-        if (idx == ePropertyEnvVars)
-            GetHostEnvironmentIfNeeded ();
-            
-        if (exe_ctx)
-        {
-            Target *target = exe_ctx->GetTargetPtr();
-            if (target)
-            {
-                TargetOptionValueProperties *target_properties = static_cast<TargetOptionValueProperties *>(target->GetValueProperties().get());
-                if (this != target_properties)
-                    return target_properties->ProtectedGetPropertyAtIndex (idx);
-            }
-        }
-        return ProtectedGetPropertyAtIndex (idx);
-    }
-    
-    lldb::TargetSP
-    GetTargetSP ()
-    {
-        return m_target->shared_from_this();
-    }
-    
 protected:
-    void
-    GetHostEnvironmentIfNeeded () const
-    {
-        if (!m_got_host_env)
-        {
-            if (m_target)
-            {
-                m_got_host_env = true;
-                const uint32_t idx = ePropertyInheritEnv;
-                if (GetPropertyAtIndexAsBoolean(nullptr, idx, g_properties[idx].default_uint_value != 0))
-                {
-                    PlatformSP platform_sp (m_target->GetPlatform());
-                    if (platform_sp)
-                    {
-                        StringList env;
-                        if (platform_sp->GetEnvironment(env))
-                        {
-                            OptionValueDictionary *env_dict = GetPropertyAtIndexAsOptionValueDictionary(nullptr, ePropertyEnvVars);
-                            if (env_dict)
-                            {
-                                const bool can_replace = false;
-                                const size_t envc = env.GetSize();
-                                for (size_t idx=0; idx<envc; idx++)
-                                {
-                                    const char *env_entry = env.GetStringAtIndex (idx);
-                                    if (env_entry)
-                                    {
-                                        const char *equal_pos = ::strchr(env_entry, '=');
-                                        ConstString key;
-                                        // It is ok to have environment variables with no values
-                                        const char *value = nullptr;
-                                        if (equal_pos)
-                                        {
-                                            key.SetCStringWithLength(env_entry, equal_pos - env_entry);
-                                            if (equal_pos[1])
-                                                value = equal_pos + 1;
-                                        }
-                                        else
-                                        {
-                                            key.SetCString(env_entry);
-                                        }
-                                        // Don't allow existing keys to be replaced with ones we get from the platform environment
-                                        env_dict->SetValueForKey(key, OptionValueSP(new OptionValueString(value)), can_replace);
-                                    }
-                                }
-                            }
-                        }
+  void GetHostEnvironmentIfNeeded() const {
+    if (!m_got_host_env) {
+      if (m_target) {
+        m_got_host_env = true;
+        const uint32_t idx = ePropertyInheritEnv;
+        if (GetPropertyAtIndexAsBoolean(
+                nullptr, idx, g_properties[idx].default_uint_value != 0)) {
+          PlatformSP platform_sp(m_target->GetPlatform());
+          if (platform_sp) {
+            StringList env;
+            if (platform_sp->GetEnvironment(env)) {
+              OptionValueDictionary *env_dict =
+                  GetPropertyAtIndexAsOptionValueDictionary(nullptr,
+                                                            ePropertyEnvVars);
+              if (env_dict) {
+                const bool can_replace = false;
+                const size_t envc = env.GetSize();
+                for (size_t idx = 0; idx < envc; idx++) {
+                  const char *env_entry = env.GetStringAtIndex(idx);
+                  if (env_entry) {
+                    const char *equal_pos = ::strchr(env_entry, '=');
+                    ConstString key;
+                    // It is ok to have environment variables with no values
+                    const char *value = nullptr;
+                    if (equal_pos) {
+                      key.SetCStringWithLength(env_entry,
+                                               equal_pos - env_entry);
+                      if (equal_pos[1])
+                        value = equal_pos + 1;
+                    } else {
+                      key.SetCString(env_entry);
                     }
-                }
-            }
-        }
-    }
-    Target *m_target;
-    mutable bool m_got_host_env;
+                    // Don't allow existing keys to be replaced with ones we get
+                    // from the platform environment
+                    env_dict->SetValueForKey(
+                        key, OptionValueSP(new OptionValueString(value)),
+                        can_replace);
+                  }
+                }
+              }
+            }
+          }
+        }
+      }
+    }
+  }
+  Target *m_target;
+  mutable bool m_got_host_env;
 };
 
 //----------------------------------------------------------------------
 // TargetProperties
 //----------------------------------------------------------------------
-static PropertyDefinition
-g_experimental_properties[] 
-{
-{   "inject-local-vars",        OptionValue::eTypeBoolean     , true, true, nullptr, nullptr, "If true, inject local variables explicitly into the expression text.  "
-                                                                                               "This will fix symbol resolution when there are name collisions between ivars and local variables.  "
-                                                                                               "But it can make expressions run much more slowly." },
-{   nullptr,                    OptionValue::eTypeInvalid     , true, 0    , nullptr, nullptr, nullptr }
-};
+static PropertyDefinition g_experimental_properties[]{
+    {"inject-local-vars", OptionValue::eTypeBoolean, true, true, nullptr,
+     nullptr,
+     "If true, inject local variables explicitly into the expression text.  "
+     "This will fix symbol resolution when there are name collisions between "
+     "ivars and local variables.  "
+     "But it can make expressions run much more slowly."},
+    {nullptr, OptionValue::eTypeInvalid, true, 0, nullptr, nullptr, nullptr}};
 
-enum
-{
-    ePropertyInjectLocalVars = 0
-};
+enum { ePropertyInjectLocalVars = 0 };
 
-class TargetExperimentalOptionValueProperties : public OptionValueProperties
-{
+class TargetExperimentalOptionValueProperties : public OptionValueProperties {
 public:
-    TargetExperimentalOptionValueProperties () :
-        OptionValueProperties (ConstString(Properties::GetExperimentalSettingsName()))
-    {
-    }
+  TargetExperimentalOptionValueProperties()
+      : OptionValueProperties(
+            ConstString(Properties::GetExperimentalSettingsName())) {}
 };
 
-TargetExperimentalProperties::TargetExperimentalProperties() :
-    Properties(OptionValuePropertiesSP(new TargetExperimentalOptionValueProperties()))
-{
-    m_collection_sp->Initialize(g_experimental_properties);
+TargetExperimentalProperties::TargetExperimentalProperties()
+    : Properties(OptionValuePropertiesSP(
+          new TargetExperimentalOptionValueProperties())) {
+  m_collection_sp->Initialize(g_experimental_properties);
 }
 
 //----------------------------------------------------------------------
 // TargetProperties
 //----------------------------------------------------------------------
-TargetProperties::TargetProperties (Target *target) :
-    Properties (),
-    m_launch_info ()
-{
-    if (target)
-    {
-        m_collection_sp.reset (new TargetOptionValueProperties(target, Target::GetGlobalProperties()));
-
-        // Set callbacks to update launch_info whenever "settins set" updated any of these properties
-        m_collection_sp->SetValueChangedCallback(ePropertyArg0, TargetProperties::Arg0ValueChangedCallback, this);
-        m_collection_sp->SetValueChangedCallback(ePropertyRunArgs, TargetProperties::RunArgsValueChangedCallback, this);
-        m_collection_sp->SetValueChangedCallback(ePropertyEnvVars, TargetProperties::EnvVarsValueChangedCallback, this);
-        m_collection_sp->SetValueChangedCallback(ePropertyInputPath, TargetProperties::InputPathValueChangedCallback, this);
-        m_collection_sp->SetValueChangedCallback(ePropertyOutputPath, TargetProperties::OutputPathValueChangedCallback, this);
-        m_collection_sp->SetValueChangedCallback(ePropertyErrorPath, TargetProperties::ErrorPathValueChangedCallback, this);
-        m_collection_sp->SetValueChangedCallback(ePropertyDetachOnError, TargetProperties::DetachOnErrorValueChangedCallback, this);
-        m_collection_sp->SetValueChangedCallback(ePropertyDisableASLR, TargetProperties::DisableASLRValueChangedCallback, this);
-        m_collection_sp->SetValueChangedCallback(ePropertyDisableSTDIO, TargetProperties::DisableSTDIOValueChangedCallback, this);
-
-        m_experimental_properties_up.reset(new TargetExperimentalProperties());
-        m_collection_sp->AppendProperty (ConstString(Properties::GetExperimentalSettingsName()),
-                                         ConstString("Experimental settings - setting these won't produce errors if the setting is not present."),
-                                         true,
-                                         m_experimental_properties_up->GetValueProperties());
-
-        // Update m_launch_info once it was created
-        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
-    {
-        m_collection_sp.reset (new TargetOptionValueProperties(ConstString("target")));
-        m_collection_sp->Initialize(g_properties);
-        m_experimental_properties_up.reset(new TargetExperimentalProperties());
-        m_collection_sp->AppendProperty (ConstString(Properties::GetExperimentalSettingsName()),
-                                         ConstString("Experimental settings - setting these won't produce errors if the setting is not present."),
-                                         true,
-                                         m_experimental_properties_up->GetValueProperties());
-        m_collection_sp->AppendProperty(ConstString("process"),
-                                        ConstString("Settings specific to processes."),
-                                        true,
-                                        Process::GetGlobalProperties()->GetValueProperties());
-    }
+TargetProperties::TargetProperties(Target *target)
+    : Properties(), m_launch_info() {
+  if (target) {
+    m_collection_sp.reset(
+        new TargetOptionValueProperties(target, Target::GetGlobalProperties()));
+
+    // Set callbacks to update launch_info whenever "settins set" updated any of
+    // these properties
+    m_collection_sp->SetValueChangedCallback(
+        ePropertyArg0, TargetProperties::Arg0ValueChangedCallback, this);
+    m_collection_sp->SetValueChangedCallback(
+        ePropertyRunArgs, TargetProperties::RunArgsValueChangedCallback, this);
+    m_collection_sp->SetValueChangedCallback(
+        ePropertyEnvVars, TargetProperties::EnvVarsValueChangedCallback, this);
+    m_collection_sp->SetValueChangedCallback(
+        ePropertyInputPath, TargetProperties::InputPathValueChangedCallback,
+        this);
+    m_collection_sp->SetValueChangedCallback(
+        ePropertyOutputPath, TargetProperties::OutputPathValueChangedCallback,
+        this);
+    m_collection_sp->SetValueChangedCallback(
+        ePropertyErrorPath, TargetProperties::ErrorPathValueChangedCallback,
+        this);
+    m_collection_sp->SetValueChangedCallback(
+        ePropertyDetachOnError,
+        TargetProperties::DetachOnErrorValueChangedCallback, this);
+    m_collection_sp->SetValueChangedCallback(
+        ePropertyDisableASLR, TargetProperties::DisableASLRValueChangedCallback,
+        this);
+    m_collection_sp->SetValueChangedCallback(
+        ePropertyDisableSTDIO,
+        TargetProperties::DisableSTDIOValueChangedCallback, this);
+
+    m_experimental_properties_up.reset(new TargetExperimentalProperties());
+    m_collection_sp->AppendProperty(
+        ConstString(Properties::GetExperimentalSettingsName()),
+        ConstString("Experimental settings - setting these won't produce "
+                    "errors if the setting is not present."),
+        true, m_experimental_properties_up->GetValueProperties());
+
+    // Update m_launch_info once it was created
+    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 {
+    m_collection_sp.reset(
+        new TargetOptionValueProperties(ConstString("target")));
+    m_collection_sp->Initialize(g_properties);
+    m_experimental_properties_up.reset(new TargetExperimentalProperties());
+    m_collection_sp->AppendProperty(
+        ConstString(Properties::GetExperimentalSettingsName()),
+        ConstString("Experimental settings - setting these won't produce "
+                    "errors if the setting is not present."),
+        true, m_experimental_properties_up->GetValueProperties());
+    m_collection_sp->AppendProperty(
+        ConstString("process"), ConstString("Settings specific to processes."),
+        true, Process::GetGlobalProperties()->GetValueProperties());
+  }
 }
 
 TargetProperties::~TargetProperties() = default;
 
-bool
-TargetProperties::GetInjectLocalVariables(ExecutionContext *exe_ctx) const
-{
-    const Property *exp_property = m_collection_sp->GetPropertyAtIndex(exe_ctx, false, ePropertyExperimental);
-    OptionValueProperties *exp_values = exp_property->GetValue()->GetAsProperties();
-    if (exp_values)
-        return exp_values->GetPropertyAtIndexAsBoolean(exe_ctx, ePropertyInjectLocalVars, true);
-    else
-        return true;
+bool TargetProperties::GetInjectLocalVariables(
+    ExecutionContext *exe_ctx) const {
+  const Property *exp_property = m_collection_sp->GetPropertyAtIndex(
+      exe_ctx, false, ePropertyExperimental);
+  OptionValueProperties *exp_values =
+      exp_property->GetValue()->GetAsProperties();
+  if (exp_values)
+    return exp_values->GetPropertyAtIndexAsBoolean(
+        exe_ctx, ePropertyInjectLocalVars, true);
+  else
+    return true;
 }
 
-void
-TargetProperties::SetInjectLocalVariables(ExecutionContext *exe_ctx, bool b)
-{
-    const Property *exp_property = m_collection_sp->GetPropertyAtIndex(exe_ctx, true, ePropertyExperimental);
-    OptionValueProperties *exp_values = exp_property->GetValue()->GetAsProperties();
-    if (exp_values)
-        exp_values->SetPropertyAtIndexAsBoolean(exe_ctx, ePropertyInjectLocalVars, true);
+void TargetProperties::SetInjectLocalVariables(ExecutionContext *exe_ctx,
+                                               bool b) {
+  const Property *exp_property =
+      m_collection_sp->GetPropertyAtIndex(exe_ctx, true, ePropertyExperimental);
+  OptionValueProperties *exp_values =
+      exp_property->GetValue()->GetAsProperties();
+  if (exp_values)
+    exp_values->SetPropertyAtIndexAsBoolean(exe_ctx, ePropertyInjectLocalVars,
+                                            true);
 }
 
-ArchSpec
-TargetProperties::GetDefaultArchitecture () const
-{
-    OptionValueArch *value = m_collection_sp->GetPropertyAtIndexAsOptionValueArch(nullptr, ePropertyDefaultArch);
-    if (value)
-        return value->GetCurrentValue();
-    return ArchSpec();
+ArchSpec TargetProperties::GetDefaultArchitecture() const {
+  OptionValueArch *value = m_collection_sp->GetPropertyAtIndexAsOptionValueArch(
+      nullptr, ePropertyDefaultArch);
+  if (value)
+    return value->GetCurrentValue();
+  return ArchSpec();
 }
 
-void
-TargetProperties::SetDefaultArchitecture (const ArchSpec& arch)
-{
-    OptionValueArch *value = m_collection_sp->GetPropertyAtIndexAsOptionValueArch(nullptr, ePropertyDefaultArch);
-    if (value)
-        return value->SetCurrentValue(arch, true);
+void TargetProperties::SetDefaultArchitecture(const ArchSpec &arch) {
+  OptionValueArch *value = m_collection_sp->GetPropertyAtIndexAsOptionValueArch(
+      nullptr, ePropertyDefaultArch);
+  if (value)
+    return value->SetCurrentValue(arch, true);
 }
 
-bool
-TargetProperties::GetMoveToNearestCode() const
-{
-    const uint32_t idx = ePropertyMoveToNearestCode;
-    return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx, g_properties[idx].default_uint_value != 0);
+bool TargetProperties::GetMoveToNearestCode() const {
+  const uint32_t idx = ePropertyMoveToNearestCode;
+  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(nullptr, idx, g_properties[idx].default_uint_value);
+lldb::DynamicValueType TargetProperties::GetPreferDynamicValue() const {
+  const uint32_t idx = ePropertyPreferDynamic;
+  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(nullptr, idx, d);
+bool TargetProperties::SetPreferDynamicValue(lldb::DynamicValueType d) {
+  const uint32_t idx = ePropertyPreferDynamic;
+  return m_collection_sp->SetPropertyAtIndexAsEnumeration(nullptr, idx, d);
 }
 
-bool
-TargetProperties::GetDisableASLR () const
-{
-    const uint32_t idx = ePropertyDisableASLR;
-    return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx, g_properties[idx].default_uint_value != 0);
+bool TargetProperties::GetDisableASLR() const {
+  const uint32_t idx = ePropertyDisableASLR;
+  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(nullptr, idx, b);
+void TargetProperties::SetDisableASLR(bool b) {
+  const uint32_t idx = ePropertyDisableASLR;
+  m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, b);
 }
 
-bool
-TargetProperties::GetDetachOnError () const
-{
-    const uint32_t idx = ePropertyDetachOnError;
-    return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx, g_properties[idx].default_uint_value != 0);
+bool TargetProperties::GetDetachOnError() const {
+  const uint32_t idx = ePropertyDetachOnError;
+  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(nullptr, idx, b);
+void TargetProperties::SetDetachOnError(bool b) {
+  const uint32_t idx = ePropertyDetachOnError;
+  m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, b);
 }
 
-bool
-TargetProperties::GetDisableSTDIO () const
-{
-    const uint32_t idx = ePropertyDisableSTDIO;
-    return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx, g_properties[idx].default_uint_value != 0);
+bool TargetProperties::GetDisableSTDIO() const {
+  const uint32_t idx = ePropertyDisableSTDIO;
+  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(nullptr, idx, b);
+void TargetProperties::SetDisableSTDIO(bool b) {
+  const uint32_t idx = ePropertyDisableSTDIO;
+  m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, b);
 }
 
-const char *
-TargetProperties::GetDisassemblyFlavor () const
-{
-    const uint32_t idx = ePropertyDisassemblyFlavor;
-    const char *return_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;
+const char *TargetProperties::GetDisassemblyFlavor() const {
+  const uint32_t idx = ePropertyDisassemblyFlavor;
+  const char *return_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;
 }
 
-InlineStrategy
-TargetProperties::GetInlineStrategy () const
-{
-    const uint32_t idx = ePropertyInlineStrategy;
-    return (InlineStrategy)m_collection_sp->GetPropertyAtIndexAsEnumeration(nullptr, idx, g_properties[idx].default_uint_value);
+InlineStrategy TargetProperties::GetInlineStrategy() const {
+  const uint32_t idx = ePropertyInlineStrategy;
+  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(nullptr, idx, nullptr);
+const char *TargetProperties::GetArg0() const {
+  const uint32_t idx = ePropertyArg0;
+  return m_collection_sp->GetPropertyAtIndexAsString(nullptr, idx, nullptr);
 }
 
-void
-TargetProperties::SetArg0 (const char *arg)
-{
-    const uint32_t idx = ePropertyArg0;
-    m_collection_sp->SetPropertyAtIndexAsString(nullptr, idx, arg);
-    m_launch_info.SetArg0(arg);
+void TargetProperties::SetArg0(const char *arg) {
+  const uint32_t idx = ePropertyArg0;
+  m_collection_sp->SetPropertyAtIndexAsString(nullptr, idx, arg);
+  m_launch_info.SetArg0(arg);
 }
 
-bool
-TargetProperties::GetRunArguments (Args &args) const
-{
-    const uint32_t idx = ePropertyRunArgs;
-    return m_collection_sp->GetPropertyAtIndexAsArgs(nullptr, idx, args);
+bool TargetProperties::GetRunArguments(Args &args) const {
+  const uint32_t idx = ePropertyRunArgs;
+  return m_collection_sp->GetPropertyAtIndexAsArgs(nullptr, idx, args);
 }
 
-void
-TargetProperties::SetRunArguments (const Args &args)
-{
-    const uint32_t idx = ePropertyRunArgs;
-    m_collection_sp->SetPropertyAtIndexFromArgs(nullptr, idx, args);
-    m_launch_info.GetArguments() = args;
+void TargetProperties::SetRunArguments(const Args &args) {
+  const uint32_t idx = ePropertyRunArgs;
+  m_collection_sp->SetPropertyAtIndexFromArgs(nullptr, idx, args);
+  m_launch_info.GetArguments() = args;
 }
 
-size_t
-TargetProperties::GetEnvironmentAsArgs (Args &env) const
-{
-    const uint32_t idx = ePropertyEnvVars;
-    return m_collection_sp->GetPropertyAtIndexAsArgs(nullptr, idx, env);
+size_t TargetProperties::GetEnvironmentAsArgs(Args &env) const {
+  const uint32_t idx = ePropertyEnvVars;
+  return m_collection_sp->GetPropertyAtIndexAsArgs(nullptr, idx, env);
 }
 
-void
-TargetProperties::SetEnvironmentFromArgs (const Args &env)
-{
-    const uint32_t idx = ePropertyEnvVars;
-    m_collection_sp->SetPropertyAtIndexFromArgs(nullptr, idx, env);
-    m_launch_info.GetEnvironmentEntries() = env;
+void TargetProperties::SetEnvironmentFromArgs(const Args &env) {
+  const uint32_t idx = ePropertyEnvVars;
+  m_collection_sp->SetPropertyAtIndexFromArgs(nullptr, idx, env);
+  m_launch_info.GetEnvironmentEntries() = env;
 }
 
-bool
-TargetProperties::GetSkipPrologue() const
-{
-    const uint32_t idx = ePropertySkipPrologue;
-    return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx, g_properties[idx].default_uint_value != 0);
+bool TargetProperties::GetSkipPrologue() const {
+  const uint32_t idx = ePropertySkipPrologue;
+  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(nullptr, false, idx);
-    assert(option_value);
-    return option_value->GetCurrentValue();
+PathMappingList &TargetProperties::GetSourcePathMap() const {
+  const uint32_t idx = ePropertySourceMap;
+  OptionValuePathMappings *option_value =
+      m_collection_sp->GetPropertyAtIndexAsOptionValuePathMappings(nullptr,
+                                                                   false, idx);
+  assert(option_value);
+  return option_value->GetCurrentValue();
 }
 
-FileSpecList &
-TargetProperties::GetExecutableSearchPaths ()
-{
-    const uint32_t idx = ePropertyExecutableSearchPaths;
-    OptionValueFileSpecList *option_value = m_collection_sp->GetPropertyAtIndexAsOptionValueFileSpecList(nullptr, false, idx);
-    assert(option_value);
-    return option_value->GetCurrentValue();
+FileSpecList &TargetProperties::GetExecutableSearchPaths() {
+  const uint32_t idx = ePropertyExecutableSearchPaths;
+  OptionValueFileSpecList *option_value =
+      m_collection_sp->GetPropertyAtIndexAsOptionValueFileSpecList(nullptr,
+                                                                   false, idx);
+  assert(option_value);
+  return option_value->GetCurrentValue();
 }
 
-FileSpecList &
-TargetProperties::GetDebugFileSearchPaths ()
-{
-    const uint32_t idx = ePropertyDebugFileSearchPaths;
-    OptionValueFileSpecList *option_value = m_collection_sp->GetPropertyAtIndexAsOptionValueFileSpecList(nullptr, false, idx);
-    assert(option_value);
-    return option_value->GetCurrentValue();
+FileSpecList &TargetProperties::GetDebugFileSearchPaths() {
+  const uint32_t idx = ePropertyDebugFileSearchPaths;
+  OptionValueFileSpecList *option_value =
+      m_collection_sp->GetPropertyAtIndexAsOptionValueFileSpecList(nullptr,
+                                                                   false, idx);
+  assert(option_value);
+  return option_value->GetCurrentValue();
 }
 
-FileSpecList &
-TargetProperties::GetClangModuleSearchPaths ()
-{
-    const uint32_t idx = ePropertyClangModuleSearchPaths;
-    OptionValueFileSpecList *option_value = m_collection_sp->GetPropertyAtIndexAsOptionValueFileSpecList(nullptr, false, idx);
-    assert(option_value);
-    return option_value->GetCurrentValue();
+FileSpecList &TargetProperties::GetClangModuleSearchPaths() {
+  const uint32_t idx = ePropertyClangModuleSearchPaths;
+  OptionValueFileSpecList *option_value =
+      m_collection_sp->GetPropertyAtIndexAsOptionValueFileSpecList(nullptr,
+                                                                   false, idx);
+  assert(option_value);
+  return option_value->GetCurrentValue();
 }
 
-bool
-TargetProperties::GetEnableAutoImportClangModules() const
-{
-    const uint32_t idx = ePropertyAutoImportClangModules;
-    return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx, g_properties[idx].default_uint_value != 0);
+bool TargetProperties::GetEnableAutoImportClangModules() const {
+  const uint32_t idx = ePropertyAutoImportClangModules;
+  return m_collection_sp->GetPropertyAtIndexAsBoolean(
+      nullptr, idx, g_properties[idx].default_uint_value != 0);
 }
 
-bool
-TargetProperties::GetEnableAutoApplyFixIts() const
-{
-    const uint32_t idx = ePropertyAutoApplyFixIts;
-    return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx, g_properties[idx].default_uint_value != 0);
+bool TargetProperties::GetEnableAutoApplyFixIts() const {
+  const uint32_t idx = ePropertyAutoApplyFixIts;
+  return m_collection_sp->GetPropertyAtIndexAsBoolean(
+      nullptr, idx, g_properties[idx].default_uint_value != 0);
 }
 
-bool
-TargetProperties::GetEnableNotifyAboutFixIts() const
-{
-    const uint32_t idx = ePropertyNotifyAboutFixIts;
-    return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx, g_properties[idx].default_uint_value != 0);
+bool TargetProperties::GetEnableNotifyAboutFixIts() const {
+  const uint32_t idx = ePropertyNotifyAboutFixIts;
+  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(nullptr, idx, g_properties[idx].default_uint_value != 0);
+bool TargetProperties::GetEnableSyntheticValue() const {
+  const uint32_t idx = ePropertyEnableSynthetic;
+  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(nullptr, idx, g_properties[idx].default_uint_value);
+uint32_t TargetProperties::GetMaximumNumberOfChildrenToDisplay() const {
+  const uint32_t idx = ePropertyMaxChildrenCount;
+  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(nullptr, idx, g_properties[idx].default_uint_value);
+uint32_t TargetProperties::GetMaximumSizeOfStringSummary() const {
+  const uint32_t idx = ePropertyMaxSummaryLength;
+  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(nullptr, idx, g_properties[idx].default_uint_value);
+uint32_t TargetProperties::GetMaximumMemReadSize() const {
+  const uint32_t idx = ePropertyMaxMemReadSize;
+  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(nullptr, idx);
+FileSpec TargetProperties::GetStandardInputPath() const {
+  const uint32_t idx = ePropertyInputPath;
+  return m_collection_sp->GetPropertyAtIndexAsFileSpec(nullptr, idx);
 }
 
-void
-TargetProperties::SetStandardInputPath (const char *p)
-{
-    const uint32_t idx = ePropertyInputPath;
-    m_collection_sp->SetPropertyAtIndexAsString(nullptr, idx, p);
+void TargetProperties::SetStandardInputPath(const char *p) {
+  const uint32_t idx = ePropertyInputPath;
+  m_collection_sp->SetPropertyAtIndexAsString(nullptr, idx, p);
 }
 
-FileSpec
-TargetProperties::GetStandardOutputPath () const
-{
-    const uint32_t idx = ePropertyOutputPath;
-    return m_collection_sp->GetPropertyAtIndexAsFileSpec(nullptr, idx);
+FileSpec TargetProperties::GetStandardOutputPath() const {
+  const uint32_t idx = ePropertyOutputPath;
+  return m_collection_sp->GetPropertyAtIndexAsFileSpec(nullptr, idx);
 }
 
-void
-TargetProperties::SetStandardOutputPath (const char *p)
-{
-    const uint32_t idx = ePropertyOutputPath;
-    m_collection_sp->SetPropertyAtIndexAsString(nullptr, idx, p);
+void TargetProperties::SetStandardOutputPath(const char *p) {
+  const uint32_t idx = ePropertyOutputPath;
+  m_collection_sp->SetPropertyAtIndexAsString(nullptr, idx, p);
 }
 
-FileSpec
-TargetProperties::GetStandardErrorPath () const
-{
-    const uint32_t idx = ePropertyErrorPath;
-    return m_collection_sp->GetPropertyAtIndexAsFileSpec(nullptr, idx);
+FileSpec TargetProperties::GetStandardErrorPath() const {
+  const uint32_t idx = ePropertyErrorPath;
+  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();
+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(nullptr, false, idx);
-    if (file)
-    {
-        const bool null_terminate = true;
-        DataBufferSP data_sp(file->GetFileContents(null_terminate));
-        if (data_sp)
-            return (const char *) data_sp->GetBytes();
-    }
-    return nullptr;
+const char *TargetProperties::GetExpressionPrefixContentsAsCString() {
+  const uint32_t idx = ePropertyExprPrefix;
+  OptionValueFileSpec *file =
+      m_collection_sp->GetPropertyAtIndexAsOptionValueFileSpec(nullptr, false,
+                                                               idx);
+  if (file) {
+    const bool null_terminate = true;
+    DataBufferSP data_sp(file->GetFileContents(null_terminate));
+    if (data_sp)
+      return (const char *)data_sp->GetBytes();
+  }
+  return nullptr;
 }
 
-void
-TargetProperties::SetStandardErrorPath (const char *p)
-{
-    const uint32_t idx = ePropertyErrorPath;
-    m_collection_sp->SetPropertyAtIndexAsString(nullptr, idx, p);
+void TargetProperties::SetStandardErrorPath(const char *p) {
+  const uint32_t idx = ePropertyErrorPath;
+  m_collection_sp->SetPropertyAtIndexAsString(nullptr, idx, p);
 }
 
-bool
-TargetProperties::GetBreakpointsConsultPlatformAvoidList ()
-{
-    const uint32_t idx = ePropertyBreakpointUseAvoidList;
-    return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx, g_properties[idx].default_uint_value != 0);
+bool TargetProperties::GetBreakpointsConsultPlatformAvoidList() {
+  const uint32_t idx = ePropertyBreakpointUseAvoidList;
+  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(nullptr, idx, g_properties[idx].default_uint_value != 0);
+bool TargetProperties::GetUseHexImmediates() const {
+  const uint32_t idx = ePropertyUseHexImmediates;
+  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(nullptr, idx, g_properties[idx].default_uint_value != 0);
+bool TargetProperties::GetUseFastStepping() const {
+  const uint32_t idx = ePropertyUseFastStepping;
+  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(nullptr, idx, g_properties[idx].default_uint_value != 0);
+bool TargetProperties::GetDisplayExpressionsInCrashlogs() const {
+  const uint32_t idx = ePropertyDisplayExpressionsInCrashlogs;
+  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(nullptr, idx, g_properties[idx].default_uint_value);
+LoadScriptFromSymFile TargetProperties::GetLoadScriptFromSymbolFile() const {
+  const uint32_t idx = ePropertyLoadScriptFromSymbolFile;
+  return (LoadScriptFromSymFile)
+      m_collection_sp->GetPropertyAtIndexAsEnumeration(
+          nullptr, idx, g_properties[idx].default_uint_value);
 }
 
-LoadCWDlldbinitFile
-TargetProperties::GetLoadCWDlldbinitFile () const
-{
-    const uint32_t idx = ePropertyLoadCWDlldbinitFile;
-    return (LoadCWDlldbinitFile) m_collection_sp->GetPropertyAtIndexAsEnumeration(nullptr, idx, g_properties[idx].default_uint_value);
+LoadCWDlldbinitFile TargetProperties::GetLoadCWDlldbinitFile() const {
+  const uint32_t idx = ePropertyLoadCWDlldbinitFile;
+  return (LoadCWDlldbinitFile)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(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(
+          nullptr, idx, g_properties[idx].default_uint_value);
 }
 
-MemoryModuleLoadLevel
-TargetProperties::GetMemoryModuleLoadLevel() const
-{
-    const uint32_t idx = ePropertyMemoryModuleLoadLevel;
-    return (MemoryModuleLoadLevel)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(
+          nullptr, idx, g_properties[idx].default_uint_value);
 }
 
-bool
-TargetProperties::GetUserSpecifiedTrapHandlerNames (Args &args) const
-{
-    const uint32_t idx = ePropertyTrapHandlerNames;
-    return m_collection_sp->GetPropertyAtIndexAsArgs(nullptr, idx, args);
+bool TargetProperties::GetUserSpecifiedTrapHandlerNames(Args &args) const {
+  const uint32_t idx = ePropertyTrapHandlerNames;
+  return m_collection_sp->GetPropertyAtIndexAsArgs(nullptr, idx, args);
 }
 
-void
-TargetProperties::SetUserSpecifiedTrapHandlerNames (const Args &args)
-{
-    const uint32_t idx = ePropertyTrapHandlerNames;
-    m_collection_sp->SetPropertyAtIndexFromArgs(nullptr, idx, args);
+void TargetProperties::SetUserSpecifiedTrapHandlerNames(const Args &args) {
+  const uint32_t idx = ePropertyTrapHandlerNames;
+  m_collection_sp->SetPropertyAtIndexFromArgs(nullptr, idx, args);
 }
 
-bool
-TargetProperties::GetDisplayRuntimeSupportValues () const
-{
-    const uint32_t idx = ePropertyDisplayRuntimeSupportValues;
-    return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx, false);
+bool TargetProperties::GetDisplayRuntimeSupportValues() const {
+  const uint32_t idx = ePropertyDisplayRuntimeSupportValues;
+  return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx, false);
 }
 
-void
-TargetProperties::SetDisplayRuntimeSupportValues (bool b)
-{
-    const uint32_t idx = ePropertyDisplayRuntimeSupportValues;
-    m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, b);
+void TargetProperties::SetDisplayRuntimeSupportValues(bool b) {
+  const uint32_t idx = ePropertyDisplayRuntimeSupportValues;
+  m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, b);
 }
 
-bool
-TargetProperties::GetNonStopModeEnabled () const
-{
-    const uint32_t idx = ePropertyNonStopModeEnabled;
-    return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx, false);
+bool TargetProperties::GetNonStopModeEnabled() const {
+  const uint32_t idx = ePropertyNonStopModeEnabled;
+  return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx, false);
 }
 
-void
-TargetProperties::SetNonStopModeEnabled (bool b)
-{
-    const uint32_t idx = ePropertyNonStopModeEnabled;
-    m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, b);
+void TargetProperties::SetNonStopModeEnabled(bool b) {
+  const uint32_t idx = ePropertyNonStopModeEnabled;
+  m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, b);
 }
 
-const ProcessLaunchInfo &
-TargetProperties::GetProcessLaunchInfo ()
-{
-    m_launch_info.SetArg0(GetArg0()); // FIXME: Arg0 callback doesn't work
-    return m_launch_info;
+const ProcessLaunchInfo &TargetProperties::GetProcessLaunchInfo() {
+  m_launch_info.SetArg0(GetArg0()); // FIXME: Arg0 callback doesn't work
+  return m_launch_info;
 }
 
-void
-TargetProperties::SetProcessLaunchInfo(const ProcessLaunchInfo &launch_info)
-{
-    m_launch_info = launch_info;
-    SetArg0(launch_info.GetArg0());
-    SetRunArguments(launch_info.GetArguments());
-    SetEnvironmentFromArgs(launch_info.GetEnvironmentEntries());
-    const FileAction *input_file_action = launch_info.GetFileActionForFD(STDIN_FILENO);
-    if (input_file_action)
-    {
-        const char *input_path = input_file_action->GetPath();
-        if (input_path)
-            SetStandardInputPath(input_path);
-    }
-    const FileAction *output_file_action = launch_info.GetFileActionForFD(STDOUT_FILENO);
-    if (output_file_action)
-    {
-        const char *output_path = output_file_action->GetPath();
-        if (output_path)
-            SetStandardOutputPath(output_path);
-    }
-    const FileAction *error_file_action = launch_info.GetFileActionForFD(STDERR_FILENO);
-    if (error_file_action)
-    {
-        const char *error_path = error_file_action->GetPath();
-        if (error_path)
-            SetStandardErrorPath(error_path);
-    }
-    SetDetachOnError(launch_info.GetFlags().Test(lldb::eLaunchFlagDetachOnError));
-    SetDisableASLR(launch_info.GetFlags().Test(lldb::eLaunchFlagDisableASLR));
-    SetDisableSTDIO(launch_info.GetFlags().Test(lldb::eLaunchFlagDisableSTDIO));
+void TargetProperties::SetProcessLaunchInfo(
+    const ProcessLaunchInfo &launch_info) {
+  m_launch_info = launch_info;
+  SetArg0(launch_info.GetArg0());
+  SetRunArguments(launch_info.GetArguments());
+  SetEnvironmentFromArgs(launch_info.GetEnvironmentEntries());
+  const FileAction *input_file_action =
+      launch_info.GetFileActionForFD(STDIN_FILENO);
+  if (input_file_action) {
+    const char *input_path = input_file_action->GetPath();
+    if (input_path)
+      SetStandardInputPath(input_path);
+  }
+  const FileAction *output_file_action =
+      launch_info.GetFileActionForFD(STDOUT_FILENO);
+  if (output_file_action) {
+    const char *output_path = output_file_action->GetPath();
+    if (output_path)
+      SetStandardOutputPath(output_path);
+  }
+  const FileAction *error_file_action =
+      launch_info.GetFileActionForFD(STDERR_FILENO);
+  if (error_file_action) {
+    const char *error_path = error_file_action->GetPath();
+    if (error_path)
+      SetStandardErrorPath(error_path);
+  }
+  SetDetachOnError(launch_info.GetFlags().Test(lldb::eLaunchFlagDetachOnError));
+  SetDisableASLR(launch_info.GetFlags().Test(lldb::eLaunchFlagDisableASLR));
+  SetDisableSTDIO(launch_info.GetFlags().Test(lldb::eLaunchFlagDisableSTDIO));
 }
 
-void
-TargetProperties::Arg0ValueChangedCallback(void *target_property_ptr, OptionValue *)
-{
-    TargetProperties *this_ = reinterpret_cast<TargetProperties *>(target_property_ptr);
-    this_->m_launch_info.SetArg0(this_->GetArg0());
+void TargetProperties::Arg0ValueChangedCallback(void *target_property_ptr,
+                                                OptionValue *) {
+  TargetProperties *this_ =
+      reinterpret_cast<TargetProperties *>(target_property_ptr);
+  this_->m_launch_info.SetArg0(this_->GetArg0());
 }
 
-void
-TargetProperties::RunArgsValueChangedCallback(void *target_property_ptr, OptionValue *)
-{
-    TargetProperties *this_ = reinterpret_cast<TargetProperties *>(target_property_ptr);
-    Args args;
-    if (this_->GetRunArguments(args))
-        this_->m_launch_info.GetArguments() = args;
+void TargetProperties::RunArgsValueChangedCallback(void *target_property_ptr,
+                                                   OptionValue *) {
+  TargetProperties *this_ =
+      reinterpret_cast<TargetProperties *>(target_property_ptr);
+  Args args;
+  if (this_->GetRunArguments(args))
+    this_->m_launch_info.GetArguments() = args;
 }
 
-void
-TargetProperties::EnvVarsValueChangedCallback(void *target_property_ptr, OptionValue *)
-{
-    TargetProperties *this_ = reinterpret_cast<TargetProperties *>(target_property_ptr);
-    Args args;
-    if (this_->GetEnvironmentAsArgs(args))
-        this_->m_launch_info.GetEnvironmentEntries() = args;
+void TargetProperties::EnvVarsValueChangedCallback(void *target_property_ptr,
+                                                   OptionValue *) {
+  TargetProperties *this_ =
+      reinterpret_cast<TargetProperties *>(target_property_ptr);
+  Args args;
+  if (this_->GetEnvironmentAsArgs(args))
+    this_->m_launch_info.GetEnvironmentEntries() = args;
 }
 
-void
-TargetProperties::InputPathValueChangedCallback(void *target_property_ptr, OptionValue *)
-{
-    TargetProperties *this_ = reinterpret_cast<TargetProperties *>(target_property_ptr);
-    this_->m_launch_info.AppendOpenFileAction(STDIN_FILENO, this_->GetStandardInputPath(), true, false);
+void TargetProperties::InputPathValueChangedCallback(void *target_property_ptr,
+                                                     OptionValue *) {
+  TargetProperties *this_ =
+      reinterpret_cast<TargetProperties *>(target_property_ptr);
+  this_->m_launch_info.AppendOpenFileAction(
+      STDIN_FILENO, this_->GetStandardInputPath(), true, false);
 }
 
-void
-TargetProperties::OutputPathValueChangedCallback(void *target_property_ptr, OptionValue *)
-{
-    TargetProperties *this_ = reinterpret_cast<TargetProperties *>(target_property_ptr);
-    this_->m_launch_info.AppendOpenFileAction(STDOUT_FILENO, this_->GetStandardOutputPath(), false, true);
+void TargetProperties::OutputPathValueChangedCallback(void *target_property_ptr,
+                                                      OptionValue *) {
+  TargetProperties *this_ =
+      reinterpret_cast<TargetProperties *>(target_property_ptr);
+  this_->m_launch_info.AppendOpenFileAction(
+      STDOUT_FILENO, this_->GetStandardOutputPath(), false, true);
 }
 
-void
-TargetProperties::ErrorPathValueChangedCallback(void *target_property_ptr, OptionValue *)
-{
-    TargetProperties *this_ = reinterpret_cast<TargetProperties *>(target_property_ptr);
-    this_->m_launch_info.AppendOpenFileAction(STDERR_FILENO, this_->GetStandardErrorPath(), false, true);
+void TargetProperties::ErrorPathValueChangedCallback(void *target_property_ptr,
+                                                     OptionValue *) {
+  TargetProperties *this_ =
+      reinterpret_cast<TargetProperties *>(target_property_ptr);
+  this_->m_launch_info.AppendOpenFileAction(
+      STDERR_FILENO, this_->GetStandardErrorPath(), false, true);
 }
 
-void
-TargetProperties::DetachOnErrorValueChangedCallback(void *target_property_ptr, OptionValue *)
-{
-    TargetProperties *this_ = reinterpret_cast<TargetProperties *>(target_property_ptr);
-    if (this_->GetDetachOnError())
-        this_->m_launch_info.GetFlags().Set(lldb::eLaunchFlagDetachOnError);
-    else
-        this_->m_launch_info.GetFlags().Clear(lldb::eLaunchFlagDetachOnError);
+void TargetProperties::DetachOnErrorValueChangedCallback(
+    void *target_property_ptr, OptionValue *) {
+  TargetProperties *this_ =
+      reinterpret_cast<TargetProperties *>(target_property_ptr);
+  if (this_->GetDetachOnError())
+    this_->m_launch_info.GetFlags().Set(lldb::eLaunchFlagDetachOnError);
+  else
+    this_->m_launch_info.GetFlags().Clear(lldb::eLaunchFlagDetachOnError);
 }
 
-void
-TargetProperties::DisableASLRValueChangedCallback(void *target_property_ptr, OptionValue *)
-{
-    TargetProperties *this_ = reinterpret_cast<TargetProperties *>(target_property_ptr);
-    if (this_->GetDisableASLR())
-        this_->m_launch_info.GetFlags().Set(lldb::eLaunchFlagDisableASLR);
-    else
-        this_->m_launch_info.GetFlags().Clear(lldb::eLaunchFlagDisableASLR);
+void TargetProperties::DisableASLRValueChangedCallback(
+    void *target_property_ptr, OptionValue *) {
+  TargetProperties *this_ =
+      reinterpret_cast<TargetProperties *>(target_property_ptr);
+  if (this_->GetDisableASLR())
+    this_->m_launch_info.GetFlags().Set(lldb::eLaunchFlagDisableASLR);
+  else
+    this_->m_launch_info.GetFlags().Clear(lldb::eLaunchFlagDisableASLR);
 }
 
-void
-TargetProperties::DisableSTDIOValueChangedCallback(void *target_property_ptr, OptionValue *)
-{
-    TargetProperties *this_ = reinterpret_cast<TargetProperties *>(target_property_ptr);
-    if (this_->GetDisableSTDIO())
-        this_->m_launch_info.GetFlags().Set(lldb::eLaunchFlagDisableSTDIO);
-    else
-        this_->m_launch_info.GetFlags().Clear(lldb::eLaunchFlagDisableSTDIO);
+void TargetProperties::DisableSTDIOValueChangedCallback(
+    void *target_property_ptr, OptionValue *) {
+  TargetProperties *this_ =
+      reinterpret_cast<TargetProperties *>(target_property_ptr);
+  if (this_->GetDisableSTDIO())
+    this_->m_launch_info.GetFlags().Set(lldb::eLaunchFlagDisableSTDIO);
+  else
+    this_->m_launch_info.GetFlags().Clear(lldb::eLaunchFlagDisableSTDIO);
 }
 
 //----------------------------------------------------------------------
 // Target::TargetEventData
 //----------------------------------------------------------------------
 
-Target::TargetEventData::TargetEventData (const lldb::TargetSP &target_sp) :
-    EventData (),
-    m_target_sp (target_sp),
-    m_module_list ()
-{
-}
+Target::TargetEventData::TargetEventData(const lldb::TargetSP &target_sp)
+    : EventData(), m_target_sp(target_sp), m_module_list() {}
 
-Target::TargetEventData::TargetEventData (const lldb::TargetSP &target_sp, const ModuleList &module_list) :
-    EventData (),
-    m_target_sp (target_sp),
-    m_module_list (module_list)
-{
-}
+Target::TargetEventData::TargetEventData(const lldb::TargetSP &target_sp,
+                                         const ModuleList &module_list)
+    : EventData(), m_target_sp(target_sp), m_module_list(module_list) {}
 
 Target::TargetEventData::~TargetEventData() = default;
 
-const ConstString &
-Target::TargetEventData::GetFlavorString ()
-{
-    static ConstString g_flavor ("Target::TargetEventData");
-    return g_flavor;
+const ConstString &Target::TargetEventData::GetFlavorString() {
+  static ConstString g_flavor("Target::TargetEventData");
+  return g_flavor;
 }
 
-void
-Target::TargetEventData::Dump (Stream *s) const
-{
-    for (size_t i = 0; i < m_module_list.GetSize(); ++i)
-    {
-        if (i != 0)
-             *s << ", ";
-        m_module_list.GetModuleAtIndex(i)->GetDescription(s, lldb::eDescriptionLevelBrief);
-    }
+void Target::TargetEventData::Dump(Stream *s) const {
+  for (size_t i = 0; i < m_module_list.GetSize(); ++i) {
+    if (i != 0)
+      *s << ", ";
+    m_module_list.GetModuleAtIndex(i)->GetDescription(
+        s, lldb::eDescriptionLevelBrief);
+  }
 }
 
 const Target::TargetEventData *
-Target::TargetEventData::GetEventDataFromEvent (const Event *event_ptr)
-{
-    if (event_ptr)
-    {
-        const EventData *event_data = event_ptr->GetData();
-        if (event_data && event_data->GetFlavor() == TargetEventData::GetFlavorString())
-            return static_cast <const TargetEventData *> (event_ptr->GetData());
-    }
-    return nullptr;
-}
-
-TargetSP
-Target::TargetEventData::GetTargetFromEvent (const Event *event_ptr)
-{
-    TargetSP target_sp;
-    const TargetEventData *event_data = GetEventDataFromEvent (event_ptr);
-    if (event_data)
-        target_sp = event_data->m_target_sp;
-    return target_sp;
+Target::TargetEventData::GetEventDataFromEvent(const Event *event_ptr) {
+  if (event_ptr) {
+    const EventData *event_data = event_ptr->GetData();
+    if (event_data &&
+        event_data->GetFlavor() == TargetEventData::GetFlavorString())
+      return static_cast<const TargetEventData *>(event_ptr->GetData());
+  }
+  return nullptr;
+}
+
+TargetSP Target::TargetEventData::GetTargetFromEvent(const Event *event_ptr) {
+  TargetSP target_sp;
+  const TargetEventData *event_data = GetEventDataFromEvent(event_ptr);
+  if (event_data)
+    target_sp = event_data->m_target_sp;
+  return target_sp;
 }
 
 ModuleList
-Target::TargetEventData::GetModuleListFromEvent (const Event *event_ptr)
-{
-    ModuleList module_list;
-    const TargetEventData *event_data = GetEventDataFromEvent (event_ptr);
-    if (event_data)
-        module_list = event_data->m_module_list;
-    return module_list;
+Target::TargetEventData::GetModuleListFromEvent(const Event *event_ptr) {
+  ModuleList module_list;
+  const TargetEventData *event_data = GetEventDataFromEvent(event_ptr);
+  if (event_data)
+    module_list = event_data->m_module_list;
+  return module_list;
 }

Modified: lldb/trunk/source/Target/TargetList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/TargetList.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Target/TargetList.cpp (original)
+++ lldb/trunk/source/Target/TargetList.cpp Tue Sep  6 15:57:50 2016
@@ -32,734 +32,598 @@
 using namespace lldb;
 using namespace lldb_private;
 
-ConstString &
-TargetList::GetStaticBroadcasterClass ()
-{
-    static ConstString class_name ("lldb.targetList");
-    return class_name;
+ConstString &TargetList::GetStaticBroadcasterClass() {
+  static ConstString class_name("lldb.targetList");
+  return class_name;
 }
 
 //----------------------------------------------------------------------
 // TargetList constructor
 //----------------------------------------------------------------------
 TargetList::TargetList(Debugger &debugger)
-    : Broadcaster(debugger.GetBroadcasterManager(), TargetList::GetStaticBroadcasterClass().AsCString()),
-      m_target_list(),
-      m_target_list_mutex(),
-      m_selected_target_idx(0)
-{
-    CheckInWithManager();
+    : Broadcaster(debugger.GetBroadcasterManager(),
+                  TargetList::GetStaticBroadcasterClass().AsCString()),
+      m_target_list(), m_target_list_mutex(), m_selected_target_idx(0) {
+  CheckInWithManager();
 }
 
 //----------------------------------------------------------------------
 // Destructor
 //----------------------------------------------------------------------
-TargetList::~TargetList()
-{
-    std::lock_guard<std::recursive_mutex> guard(m_target_list_mutex);
-    m_target_list.clear();
-}
-
-Error
-TargetList::CreateTarget (Debugger &debugger,
-                          const char *user_exe_path,
-                          const char *triple_cstr,
-                          bool get_dependent_files,
-                          const OptionGroupPlatform *platform_options,
-                          TargetSP &target_sp)
-{
-    return CreateTargetInternal (debugger,
-                                 user_exe_path,
-                                 triple_cstr,
-                                 get_dependent_files,
-                                 platform_options,
-                                 target_sp,
-                                 false);
-}
-
-Error
-TargetList::CreateTarget (Debugger &debugger,
-                          const char *user_exe_path,
-                          const ArchSpec& specified_arch,
-                          bool get_dependent_files,
-                          PlatformSP &platform_sp,
-                          TargetSP &target_sp)
-{
-    return CreateTargetInternal (debugger,
-                                 user_exe_path,
-                                 specified_arch,
-                                 get_dependent_files,
-                                 platform_sp,
-                                 target_sp,
-                                 false);
-}
-
-Error
-TargetList::CreateTargetInternal (Debugger &debugger,
-                                  const char *user_exe_path,
-                                  const char *triple_cstr,
-                                  bool get_dependent_files,
-                                  const OptionGroupPlatform *platform_options,
-                                  TargetSP &target_sp,
-                                  bool is_dummy_target)
-{
-    Error error;
-    PlatformSP platform_sp;
-    
-    // This is purposely left empty unless it is specified by triple_cstr.
-    // If not initialized via triple_cstr, then the currently selected platform
-    // will set the architecture correctly.
-    const ArchSpec arch(triple_cstr);
-    if (triple_cstr && triple_cstr[0])
-    {
-        if (!arch.IsValid())
-        {
-            error.SetErrorStringWithFormat("invalid triple '%s'", triple_cstr);
-            return error;
-        }
-    }
-    
-    ArchSpec platform_arch(arch);
-
-    bool prefer_platform_arch = false;
-    
-    CommandInterpreter &interpreter = debugger.GetCommandInterpreter();
-
-    // let's see if there is already an existing plaform before we go creating another...
-    platform_sp = debugger.GetPlatformList().GetSelectedPlatform();
-
-    if (platform_options && platform_options->PlatformWasSpecified ())
-    {
-        // Create a new platform if it doesn't match the selected platform
-        if (!platform_options->PlatformMatches(platform_sp))
-        {
-            const bool select_platform = true;
-            platform_sp = platform_options->CreatePlatformWithOptions (interpreter,
-                                                                       arch,
-                                                                       select_platform,
-                                                                       error,
-                                                                       platform_arch);
-            if (!platform_sp)
-                return error;
-        }
-    }
-    
-    if (user_exe_path && user_exe_path[0])
-    {
-        ModuleSpecList module_specs;
-        ModuleSpec module_spec;
-        module_spec.GetFileSpec().SetFile(user_exe_path, true);
-        
-        // Resolve the executable in case we are given a path to a application bundle
-        // like a .app bundle on MacOSX
-        Host::ResolveExecutableInBundle (module_spec.GetFileSpec());
-
-        lldb::offset_t file_offset = 0;
-        lldb::offset_t file_size = 0;
-        const size_t num_specs = ObjectFile::GetModuleSpecifications (module_spec.GetFileSpec(), file_offset, file_size, module_specs);
-        if (num_specs > 0)
-        {
-            ModuleSpec matching_module_spec;
-
-            if (num_specs == 1)
-            {
-                if (module_specs.GetModuleSpecAtIndex(0, matching_module_spec))
-                {
-                    if (platform_arch.IsValid())
-                    {
-                        if (platform_arch.IsCompatibleMatch(matching_module_spec.GetArchitecture()))
-                        {
-                            // If the OS or vendor weren't specified, then adopt the module's
-                            // architecture so that the platform matching can be more accurate
-                            if (!platform_arch.TripleOSWasSpecified() || !platform_arch.TripleVendorWasSpecified())
-                            {
-                                prefer_platform_arch = true;
-                                platform_arch = matching_module_spec.GetArchitecture();
-                            }
-                        }
-                        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_strm.GetString().c_str(),
-                                                           module_arch_strm.GetString().c_str(),
-                                                           module_spec.GetFileSpec().GetPath().c_str());
-                            return error;
-                        }
-                    }
-                    else
-                    {
-                        // Only one arch and none was specified
-                        prefer_platform_arch = true;
-                        platform_arch = matching_module_spec.GetArchitecture();
-                    }
-                }
-            }
-            else
-            {
-                if (arch.IsValid())
-                {
-                    module_spec.GetArchitecture() = arch;
-                    if (module_specs.FindMatchingModuleSpec(module_spec, matching_module_spec))
-                    {
-                        prefer_platform_arch = true;
-                        platform_arch = matching_module_spec.GetArchitecture();
-                    }
+TargetList::~TargetList() {
+  std::lock_guard<std::recursive_mutex> guard(m_target_list_mutex);
+  m_target_list.clear();
+}
+
+Error TargetList::CreateTarget(Debugger &debugger, const char *user_exe_path,
+                               const char *triple_cstr,
+                               bool get_dependent_files,
+                               const OptionGroupPlatform *platform_options,
+                               TargetSP &target_sp) {
+  return CreateTargetInternal(debugger, user_exe_path, triple_cstr,
+                              get_dependent_files, platform_options, target_sp,
+                              false);
+}
+
+Error TargetList::CreateTarget(Debugger &debugger, const char *user_exe_path,
+                               const ArchSpec &specified_arch,
+                               bool get_dependent_files,
+                               PlatformSP &platform_sp, TargetSP &target_sp) {
+  return CreateTargetInternal(debugger, user_exe_path, specified_arch,
+                              get_dependent_files, platform_sp, target_sp,
+                              false);
+}
+
+Error TargetList::CreateTargetInternal(
+    Debugger &debugger, const char *user_exe_path, const char *triple_cstr,
+    bool get_dependent_files, const OptionGroupPlatform *platform_options,
+    TargetSP &target_sp, bool is_dummy_target) {
+  Error error;
+  PlatformSP platform_sp;
+
+  // This is purposely left empty unless it is specified by triple_cstr.
+  // If not initialized via triple_cstr, then the currently selected platform
+  // will set the architecture correctly.
+  const ArchSpec arch(triple_cstr);
+  if (triple_cstr && triple_cstr[0]) {
+    if (!arch.IsValid()) {
+      error.SetErrorStringWithFormat("invalid triple '%s'", triple_cstr);
+      return error;
+    }
+  }
+
+  ArchSpec platform_arch(arch);
+
+  bool prefer_platform_arch = false;
+
+  CommandInterpreter &interpreter = debugger.GetCommandInterpreter();
+
+  // let's see if there is already an existing plaform before we go creating
+  // another...
+  platform_sp = debugger.GetPlatformList().GetSelectedPlatform();
+
+  if (platform_options && platform_options->PlatformWasSpecified()) {
+    // Create a new platform if it doesn't match the selected platform
+    if (!platform_options->PlatformMatches(platform_sp)) {
+      const bool select_platform = true;
+      platform_sp = platform_options->CreatePlatformWithOptions(
+          interpreter, arch, select_platform, error, platform_arch);
+      if (!platform_sp)
+        return error;
+    }
+  }
+
+  if (user_exe_path && user_exe_path[0]) {
+    ModuleSpecList module_specs;
+    ModuleSpec module_spec;
+    module_spec.GetFileSpec().SetFile(user_exe_path, true);
+
+    // Resolve the executable in case we are given a path to a application
+    // bundle
+    // like a .app bundle on MacOSX
+    Host::ResolveExecutableInBundle(module_spec.GetFileSpec());
+
+    lldb::offset_t file_offset = 0;
+    lldb::offset_t file_size = 0;
+    const size_t num_specs = ObjectFile::GetModuleSpecifications(
+        module_spec.GetFileSpec(), file_offset, file_size, module_specs);
+    if (num_specs > 0) {
+      ModuleSpec matching_module_spec;
+
+      if (num_specs == 1) {
+        if (module_specs.GetModuleSpecAtIndex(0, matching_module_spec)) {
+          if (platform_arch.IsValid()) {
+            if (platform_arch.IsCompatibleMatch(
+                    matching_module_spec.GetArchitecture())) {
+              // If the OS or vendor weren't specified, then adopt the module's
+              // architecture so that the platform matching can be more accurate
+              if (!platform_arch.TripleOSWasSpecified() ||
+                  !platform_arch.TripleVendorWasSpecified()) {
+                prefer_platform_arch = true;
+                platform_arch = matching_module_spec.GetArchitecture();
+              }
+            } 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_strm.GetString().c_str(),
+                  module_arch_strm.GetString().c_str(),
+                  module_spec.GetFileSpec().GetPath().c_str());
+              return error;
+            }
+          } else {
+            // Only one arch and none was specified
+            prefer_platform_arch = true;
+            platform_arch = matching_module_spec.GetArchitecture();
+          }
+        }
+      } else {
+        if (arch.IsValid()) {
+          module_spec.GetArchitecture() = arch;
+          if (module_specs.FindMatchingModuleSpec(module_spec,
+                                                  matching_module_spec)) {
+            prefer_platform_arch = true;
+            platform_arch = matching_module_spec.GetArchitecture();
+          }
+        } else {
+          // No architecture specified, check if there is only one platform for
+          // all of the architectures.
+
+          typedef std::vector<PlatformSP> PlatformList;
+          PlatformList platforms;
+          PlatformSP host_platform_sp = Platform::GetHostPlatform();
+          for (size_t i = 0; i < num_specs; ++i) {
+            ModuleSpec module_spec;
+            if (module_specs.GetModuleSpecAtIndex(i, module_spec)) {
+              // See if there was a selected platform and check that first
+              // since the user may have specified it.
+              if (platform_sp) {
+                if (platform_sp->IsCompatibleArchitecture(
+                        module_spec.GetArchitecture(), false, nullptr)) {
+                  platforms.push_back(platform_sp);
+                  continue;
                 }
-                else
-                {
-                    // No architecture specified, check if there is only one platform for
-                    // all of the architectures.
-                    
-                    typedef std::vector<PlatformSP> PlatformList;
-                    PlatformList platforms;
-                    PlatformSP host_platform_sp = Platform::GetHostPlatform();
-                    for (size_t i=0; i<num_specs; ++i)
-                    {
-                        ModuleSpec module_spec;
-                        if (module_specs.GetModuleSpecAtIndex(i, module_spec))
-                        {
-                            // See if there was a selected platform and check that first
-                            // since the user may have specified it.
-                            if (platform_sp)
-                            {
-                                if (platform_sp->IsCompatibleArchitecture(module_spec.GetArchitecture(), false, nullptr))
-                                {
-                                    platforms.push_back(platform_sp);
-                                    continue;
-                                }
-                            }
-                            
-                            // 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, nullptr))
-                                {
-                                    platforms.push_back(host_platform_sp);
-                                    continue;
-                                }
-                            }
-                            
-                            // Just find a platform that matches the architecture in the executable file
-                            PlatformSP fallback_platform_sp (Platform::GetPlatformForArchitecture(module_spec.GetArchitecture(), nullptr));
-                            if (fallback_platform_sp)
-                            {
-                                platforms.push_back(fallback_platform_sp);
-                            }
-                        }
-                    }
-                    
-                    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())
-                            {
-                                more_than_one_platforms = true;
-                                platform_ptr = nullptr;
-                                break;
-                            }
-                        }
-                        else
-                        {
-                            platform_ptr = the_platform_sp.get();
-                        }
-                    }
-                    
-                    if (platform_ptr)
-                    {
-                        // 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
-                        StreamString error_strm;
-                        std::set<Platform *> platform_set;
-                        error_strm.Printf ("more than one platform supports this executable (");
-                        for (const auto &the_platform_sp : platforms)
-                        {
-                            if (platform_set.find(the_platform_sp.get()) == platform_set.end())
-                            {
-                                if (!platform_set.empty())
-                                    error_strm.PutCString(", ");
-                                error_strm.PutCString(the_platform_sp->GetName().GetCString());
-                                platform_set.insert(the_platform_sp.get());
-                            }
-                        }
-                        error_strm.Printf("), use the --platform option to specify a platform");
-                        error.SetErrorString(error_strm.GetString().c_str());
-                        return error;
-                    }
+              }
+
+              // 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, nullptr)) {
+                  platforms.push_back(host_platform_sp);
+                  continue;
                 }
-            }
-        }
-    }
+              }
 
-    // If we have a valid architecture, make sure the current platform is
-    // compatible with that architecture
-    if (!prefer_platform_arch && arch.IsValid())
-    {
-        if (!platform_sp->IsCompatibleArchitecture(arch, false, &platform_arch))
-        {
-            platform_sp = Platform::GetPlatformForArchitecture(arch, &platform_arch);
-            if (!is_dummy_target && platform_sp)
-                debugger.GetPlatformList().SetSelectedPlatform(platform_sp);
-        }
-    }
-    else if (platform_arch.IsValid())
-    {
-        // if "arch" isn't valid, yet "platform_arch" is, it means we have an executable file with
-        // a single architecture which should be used
-        ArchSpec fixed_platform_arch;
-        if (!platform_sp->IsCompatibleArchitecture(platform_arch, false, &fixed_platform_arch))
-        {
-            platform_sp = Platform::GetPlatformForArchitecture(platform_arch, &fixed_platform_arch);
-            if (!is_dummy_target && platform_sp)
-                debugger.GetPlatformList().SetSelectedPlatform(platform_sp);
+              // Just find a platform that matches the architecture in the
+              // executable file
+              PlatformSP fallback_platform_sp(
+                  Platform::GetPlatformForArchitecture(
+                      module_spec.GetArchitecture(), nullptr));
+              if (fallback_platform_sp) {
+                platforms.push_back(fallback_platform_sp);
+              }
+            }
+          }
+
+          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()) {
+                more_than_one_platforms = true;
+                platform_ptr = nullptr;
+                break;
+              }
+            } else {
+              platform_ptr = the_platform_sp.get();
+            }
+          }
+
+          if (platform_ptr) {
+            // 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
+            StreamString error_strm;
+            std::set<Platform *> platform_set;
+            error_strm.Printf(
+                "more than one platform supports this executable (");
+            for (const auto &the_platform_sp : platforms) {
+              if (platform_set.find(the_platform_sp.get()) ==
+                  platform_set.end()) {
+                if (!platform_set.empty())
+                  error_strm.PutCString(", ");
+                error_strm.PutCString(the_platform_sp->GetName().GetCString());
+                platform_set.insert(the_platform_sp.get());
+              }
+            }
+            error_strm.Printf(
+                "), use the --platform option to specify a platform");
+            error.SetErrorString(error_strm.GetString().c_str());
+            return error;
+          }
         }
+      }
     }
-    
-    if (!platform_arch.IsValid())
-        platform_arch = arch;
-
-    error = TargetList::CreateTargetInternal (debugger,
-                                              user_exe_path,
-                                              platform_arch,
-                                              get_dependent_files,
-                                              platform_sp,
-                                              target_sp,
-                                              is_dummy_target);
-    return error;
-}
-
-lldb::TargetSP
-TargetList::GetDummyTarget (lldb_private::Debugger &debugger)
-{
-    // FIXME: Maybe the dummy target should be per-Debugger
-    if (!m_dummy_target_sp || !m_dummy_target_sp->IsValid())
-    {
-        ArchSpec arch(Target::GetDefaultArchitecture());
-        if (!arch.IsValid())
-            arch = HostInfo::GetArchitecture();
-        Error err = CreateDummyTarget(debugger,
-                                      arch.GetTriple().getTriple().c_str(),
-                                      m_dummy_target_sp);
-    }
-
-    return m_dummy_target_sp;
-}
-
-Error
-TargetList::CreateDummyTarget (Debugger &debugger,
-                               const char *specified_arch_name,
-                               lldb::TargetSP &target_sp)
-{
-    PlatformSP host_platform_sp(Platform::GetHostPlatform());
-    return CreateTargetInternal (debugger,
-                                 (const char *) nullptr,
-                                 specified_arch_name,
-                                 false,
-                                 (const OptionGroupPlatform *) nullptr,
-                                 target_sp,
-                                 true);
-}
-
-Error
-TargetList::CreateTargetInternal (Debugger &debugger,
-                                  const char *user_exe_path,
-                                  const ArchSpec& specified_arch,
-                                  bool get_dependent_files,
-                                  lldb::PlatformSP &platform_sp,
-                                  lldb::TargetSP &target_sp,
-                                  bool is_dummy_target)
-{
-    Timer scoped_timer (LLVM_PRETTY_FUNCTION,
-                        "TargetList::CreateTarget (file = '%s', arch = '%s')",
-                        user_exe_path,
-                        specified_arch.GetArchitectureName());
-    Error error;
-
-    ArchSpec arch(specified_arch);
-
-    if (arch.IsValid())
-    {
-        if (!platform_sp || !platform_sp->IsCompatibleArchitecture(arch, false, nullptr))
-            platform_sp = Platform::GetPlatformForArchitecture(specified_arch, &arch);
-    }
-    
-    if (!platform_sp)
-        platform_sp = debugger.GetPlatformList().GetSelectedPlatform();
+  }
 
+  // If we have a valid architecture, make sure the current platform is
+  // compatible with that architecture
+  if (!prefer_platform_arch && arch.IsValid()) {
+    if (!platform_sp->IsCompatibleArchitecture(arch, false, &platform_arch)) {
+      platform_sp = Platform::GetPlatformForArchitecture(arch, &platform_arch);
+      if (!is_dummy_target && platform_sp)
+        debugger.GetPlatformList().SetSelectedPlatform(platform_sp);
+    }
+  } else if (platform_arch.IsValid()) {
+    // if "arch" isn't valid, yet "platform_arch" is, it means we have an
+    // executable file with
+    // a single architecture which should be used
+    ArchSpec fixed_platform_arch;
+    if (!platform_sp->IsCompatibleArchitecture(platform_arch, false,
+                                               &fixed_platform_arch)) {
+      platform_sp = Platform::GetPlatformForArchitecture(platform_arch,
+                                                         &fixed_platform_arch);
+      if (!is_dummy_target && platform_sp)
+        debugger.GetPlatformList().SetSelectedPlatform(platform_sp);
+    }
+  }
+
+  if (!platform_arch.IsValid())
+    platform_arch = arch;
+
+  error = TargetList::CreateTargetInternal(
+      debugger, user_exe_path, platform_arch, get_dependent_files, platform_sp,
+      target_sp, is_dummy_target);
+  return error;
+}
+
+lldb::TargetSP TargetList::GetDummyTarget(lldb_private::Debugger &debugger) {
+  // FIXME: Maybe the dummy target should be per-Debugger
+  if (!m_dummy_target_sp || !m_dummy_target_sp->IsValid()) {
+    ArchSpec arch(Target::GetDefaultArchitecture());
     if (!arch.IsValid())
-        arch = specified_arch;
-
-    FileSpec file (user_exe_path, false);
-    if (!file.Exists() && user_exe_path && user_exe_path[0] == '~')
-    {
-        // we want to expand the tilde but we don't want to resolve any symbolic links
-        // so we can't use the FileSpec constructor's resolve flag
-        llvm::SmallString<64> unglobbed_path(user_exe_path);
-        FileSpec::ResolveUsername(unglobbed_path);
-
-        if (unglobbed_path.empty())
-            file = FileSpec(user_exe_path, false);
-        else
-            file = FileSpec(unglobbed_path.c_str(), false);
-    }
-
-    bool user_exe_path_is_bundle = false;
-    char resolved_bundle_exe_path[PATH_MAX];
-    resolved_bundle_exe_path[0] = '\0';
-    if (file)
-    {
-        if (file.GetFileType() == FileSpec::eFileTypeDirectory)
-            user_exe_path_is_bundle = true;
-
-        if (file.IsRelative() && user_exe_path)
-        {
-            // Ignore paths that start with "./" and "../"
-            if (!((user_exe_path[0] == '.' && user_exe_path[1] == '/') ||
-                  (user_exe_path[0] == '.' && user_exe_path[1] == '.' && user_exe_path[2] == '/')))
-            {
-                char cwd[PATH_MAX];
-                if (getcwd (cwd, sizeof(cwd)))
-                {
-                    std::string cwd_user_exe_path (cwd);
-                    cwd_user_exe_path += '/';
-                    cwd_user_exe_path += user_exe_path;
-                    FileSpec cwd_file (cwd_user_exe_path.c_str(), false);
-                    if (cwd_file.Exists())
-                        file = cwd_file;
-                }
-            }
-        }
-
-        ModuleSP exe_module_sp;
-        if (platform_sp)
-        {
-            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 : nullptr);
-        }
-
-        if (error.Success() && exe_module_sp)
-        {
-            if (exe_module_sp->GetObjectFile() == nullptr)
-            {
-                if (arch.IsValid())
-                {
-                    error.SetErrorStringWithFormat("\"%s\" doesn't contain architecture %s",
-                                                   file.GetPath().c_str(),
-                                                   arch.GetArchitectureName());
-                }
-                else
-                {
-                    error.SetErrorStringWithFormat("unsupported file type \"%s\"",
-                                                   file.GetPath().c_str());
-                }
-                return error;
-            }
-            target_sp.reset(new Target(debugger, arch, platform_sp, is_dummy_target));
-            target_sp->SetExecutableModule (exe_module_sp, get_dependent_files);
-            if (user_exe_path_is_bundle)
-                exe_module_sp->GetFileSpec().GetPath(resolved_bundle_exe_path, sizeof(resolved_bundle_exe_path));
-        }
-    }
-    else
-    {
-        // No file was specified, just create an empty target with any arch
-        // if a valid arch was specified
-        target_sp.reset(new Target(debugger, arch, platform_sp, is_dummy_target));
-    }
-
-    if (target_sp)
-    {
-        // Set argv0 with what the user typed, unless the user specified a
-        // directory. If the user specified a directory, then it is probably a
-        // bundle that was resolved and we need to use the resolved bundle path
-        if (user_exe_path)
-        {
-            // Use exactly what the user typed as the first argument when we exec or posix_spawn
-            if (user_exe_path_is_bundle && resolved_bundle_exe_path[0])
-            {
-                target_sp->SetArg0 (resolved_bundle_exe_path);
-            }
-            else
-            {
-                // Use resolved path
-                target_sp->SetArg0 (file.GetPath().c_str());
-            }
-        }
-        if (file.GetDirectory())
-        {
-            FileSpec file_dir;
-            file_dir.GetDirectory() = file.GetDirectory();
-            target_sp->GetExecutableSearchPaths ().Append (file_dir);
-        }
+      arch = HostInfo::GetArchitecture();
+    Error err = CreateDummyTarget(
+        debugger, arch.GetTriple().getTriple().c_str(), m_dummy_target_sp);
+  }
+
+  return m_dummy_target_sp;
+}
+
+Error TargetList::CreateDummyTarget(Debugger &debugger,
+                                    const char *specified_arch_name,
+                                    lldb::TargetSP &target_sp) {
+  PlatformSP host_platform_sp(Platform::GetHostPlatform());
+  return CreateTargetInternal(
+      debugger, (const char *)nullptr, specified_arch_name, false,
+      (const OptionGroupPlatform *)nullptr, target_sp, true);
+}
+
+Error TargetList::CreateTargetInternal(Debugger &debugger,
+                                       const char *user_exe_path,
+                                       const ArchSpec &specified_arch,
+                                       bool get_dependent_files,
+                                       lldb::PlatformSP &platform_sp,
+                                       lldb::TargetSP &target_sp,
+                                       bool is_dummy_target) {
+  Timer scoped_timer(LLVM_PRETTY_FUNCTION,
+                     "TargetList::CreateTarget (file = '%s', arch = '%s')",
+                     user_exe_path, specified_arch.GetArchitectureName());
+  Error error;
+
+  ArchSpec arch(specified_arch);
+
+  if (arch.IsValid()) {
+    if (!platform_sp ||
+        !platform_sp->IsCompatibleArchitecture(arch, false, nullptr))
+      platform_sp = Platform::GetPlatformForArchitecture(specified_arch, &arch);
+  }
 
-        // Don't put the dummy target in the target list, it's held separately.
-        if (!is_dummy_target)
-        {
-            std::lock_guard<std::recursive_mutex> guard(m_target_list_mutex);
-            m_selected_target_idx = m_target_list.size();
-            m_target_list.push_back(target_sp);
-            // Now prime this from the dummy target:
-            target_sp->PrimeFromDummyTarget(debugger.GetDummyTarget());
-        }
-        else
-        {
-            m_dummy_target_sp = target_sp;
-        }
-    }
+  if (!platform_sp)
+    platform_sp = debugger.GetPlatformList().GetSelectedPlatform();
 
-    return error;
-}
+  if (!arch.IsValid())
+    arch = specified_arch;
 
-bool
-TargetList::DeleteTarget (TargetSP &target_sp)
-{
-    std::lock_guard<std::recursive_mutex> guard(m_target_list_mutex);
-    collection::iterator pos, end = m_target_list.end();
+  FileSpec file(user_exe_path, false);
+  if (!file.Exists() && user_exe_path && user_exe_path[0] == '~') {
+    // we want to expand the tilde but we don't want to resolve any symbolic
+    // links
+    // so we can't use the FileSpec constructor's resolve flag
+    llvm::SmallString<64> unglobbed_path(user_exe_path);
+    FileSpec::ResolveUsername(unglobbed_path);
 
-    for (pos = m_target_list.begin(); pos != end; ++pos)
-    {
-        if (pos->get() == target_sp.get())
-        {
-            m_target_list.erase(pos);
-            return true;
-        }
-    }
-    return false;
-}
+    if (unglobbed_path.empty())
+      file = FileSpec(user_exe_path, false);
+    else
+      file = FileSpec(unglobbed_path.c_str(), false);
+  }
 
-TargetSP
-TargetList::FindTargetWithExecutableAndArchitecture(const FileSpec &exe_file_spec,
-                                                    const ArchSpec *exe_arch_ptr) const
-{
+  bool user_exe_path_is_bundle = false;
+  char resolved_bundle_exe_path[PATH_MAX];
+  resolved_bundle_exe_path[0] = '\0';
+  if (file) {
+    if (file.GetFileType() == FileSpec::eFileTypeDirectory)
+      user_exe_path_is_bundle = true;
+
+    if (file.IsRelative() && user_exe_path) {
+      // Ignore paths that start with "./" and "../"
+      if (!((user_exe_path[0] == '.' && user_exe_path[1] == '/') ||
+            (user_exe_path[0] == '.' && user_exe_path[1] == '.' &&
+             user_exe_path[2] == '/'))) {
+        char cwd[PATH_MAX];
+        if (getcwd(cwd, sizeof(cwd))) {
+          std::string cwd_user_exe_path(cwd);
+          cwd_user_exe_path += '/';
+          cwd_user_exe_path += user_exe_path;
+          FileSpec cwd_file(cwd_user_exe_path.c_str(), false);
+          if (cwd_file.Exists())
+            file = cwd_file;
+        }
+      }
+    }
+
+    ModuleSP exe_module_sp;
+    if (platform_sp) {
+      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
+                                                 : nullptr);
+    }
+
+    if (error.Success() && exe_module_sp) {
+      if (exe_module_sp->GetObjectFile() == nullptr) {
+        if (arch.IsValid()) {
+          error.SetErrorStringWithFormat(
+              "\"%s\" doesn't contain architecture %s", file.GetPath().c_str(),
+              arch.GetArchitectureName());
+        } else {
+          error.SetErrorStringWithFormat("unsupported file type \"%s\"",
+                                         file.GetPath().c_str());
+        }
+        return error;
+      }
+      target_sp.reset(new Target(debugger, arch, platform_sp, is_dummy_target));
+      target_sp->SetExecutableModule(exe_module_sp, get_dependent_files);
+      if (user_exe_path_is_bundle)
+        exe_module_sp->GetFileSpec().GetPath(resolved_bundle_exe_path,
+                                             sizeof(resolved_bundle_exe_path));
+    }
+  } else {
+    // No file was specified, just create an empty target with any arch
+    // if a valid arch was specified
+    target_sp.reset(new Target(debugger, arch, platform_sp, is_dummy_target));
+  }
+
+  if (target_sp) {
+    // Set argv0 with what the user typed, unless the user specified a
+    // directory. If the user specified a directory, then it is probably a
+    // bundle that was resolved and we need to use the resolved bundle path
+    if (user_exe_path) {
+      // Use exactly what the user typed as the first argument when we exec or
+      // posix_spawn
+      if (user_exe_path_is_bundle && resolved_bundle_exe_path[0]) {
+        target_sp->SetArg0(resolved_bundle_exe_path);
+      } else {
+        // Use resolved path
+        target_sp->SetArg0(file.GetPath().c_str());
+      }
+    }
+    if (file.GetDirectory()) {
+      FileSpec file_dir;
+      file_dir.GetDirectory() = file.GetDirectory();
+      target_sp->GetExecutableSearchPaths().Append(file_dir);
+    }
+
+    // Don't put the dummy target in the target list, it's held separately.
+    if (!is_dummy_target) {
+      std::lock_guard<std::recursive_mutex> guard(m_target_list_mutex);
+      m_selected_target_idx = m_target_list.size();
+      m_target_list.push_back(target_sp);
+      // Now prime this from the dummy target:
+      target_sp->PrimeFromDummyTarget(debugger.GetDummyTarget());
+    } else {
+      m_dummy_target_sp = target_sp;
+    }
+  }
+
+  return error;
+}
+
+bool TargetList::DeleteTarget(TargetSP &target_sp) {
+  std::lock_guard<std::recursive_mutex> guard(m_target_list_mutex);
+  collection::iterator pos, end = m_target_list.end();
+
+  for (pos = m_target_list.begin(); pos != end; ++pos) {
+    if (pos->get() == target_sp.get()) {
+      m_target_list.erase(pos);
+      return true;
+    }
+  }
+  return false;
+}
+
+TargetSP TargetList::FindTargetWithExecutableAndArchitecture(
+    const FileSpec &exe_file_spec, const ArchSpec *exe_arch_ptr) const {
+  std::lock_guard<std::recursive_mutex> guard(m_target_list_mutex);
+  TargetSP target_sp;
+  bool full_match = (bool)exe_file_spec.GetDirectory();
+
+  collection::const_iterator pos, end = m_target_list.end();
+  for (pos = m_target_list.begin(); pos != end; ++pos) {
+    Module *exe_module = (*pos)->GetExecutableModulePointer();
+
+    if (exe_module) {
+      if (FileSpec::Equal(exe_file_spec, exe_module->GetFileSpec(),
+                          full_match)) {
+        if (exe_arch_ptr) {
+          if (!exe_arch_ptr->IsCompatibleMatch(exe_module->GetArchitecture()))
+            continue;
+        }
+        target_sp = *pos;
+        break;
+      }
+    }
+  }
+  return target_sp;
+}
+
+TargetSP TargetList::FindTargetWithProcessID(lldb::pid_t pid) const {
+  std::lock_guard<std::recursive_mutex> guard(m_target_list_mutex);
+  TargetSP target_sp;
+  collection::const_iterator pos, end = m_target_list.end();
+  for (pos = m_target_list.begin(); pos != end; ++pos) {
+    Process *process = (*pos)->GetProcessSP().get();
+    if (process && process->GetID() == pid) {
+      target_sp = *pos;
+      break;
+    }
+  }
+  return target_sp;
+}
+
+TargetSP TargetList::FindTargetWithProcess(Process *process) const {
+  TargetSP target_sp;
+  if (process) {
     std::lock_guard<std::recursive_mutex> guard(m_target_list_mutex);
-    TargetSP target_sp;
-    bool full_match = (bool)exe_file_spec.GetDirectory();
-
     collection::const_iterator pos, end = m_target_list.end();
-    for (pos = m_target_list.begin(); pos != end; ++pos)
-    {
-        Module *exe_module = (*pos)->GetExecutableModulePointer();
-
-        if (exe_module)
-        {
-            if (FileSpec::Equal (exe_file_spec, exe_module->GetFileSpec(), full_match))
-            {
-                if (exe_arch_ptr)
-                {
-                    if (!exe_arch_ptr->IsCompatibleMatch(exe_module->GetArchitecture()))
-                        continue;
-                }
-                target_sp = *pos;
-                break;
-            }
-        }
-    }
-    return target_sp;
+    for (pos = m_target_list.begin(); pos != end; ++pos) {
+      if (process == (*pos)->GetProcessSP().get()) {
+        target_sp = *pos;
+        break;
+      }
+    }
+  }
+  return target_sp;
 }
 
-TargetSP
-TargetList::FindTargetWithProcessID (lldb::pid_t pid) const
-{
+TargetSP TargetList::GetTargetSP(Target *target) const {
+  TargetSP target_sp;
+  if (target) {
     std::lock_guard<std::recursive_mutex> guard(m_target_list_mutex);
-    TargetSP target_sp;
     collection::const_iterator pos, end = m_target_list.end();
-    for (pos = m_target_list.begin(); pos != end; ++pos)
-    {
-        Process* process = (*pos)->GetProcessSP().get();
-        if (process && process->GetID() == pid)
-        {
-            target_sp = *pos;
-            break;
-        }
-    }
-    return target_sp;
-}
-
-TargetSP
-TargetList::FindTargetWithProcess (Process *process) const
-{
-    TargetSP target_sp;
-    if (process)
-    {
-        std::lock_guard<std::recursive_mutex> guard(m_target_list_mutex);
-        collection::const_iterator pos, end = m_target_list.end();
-        for (pos = m_target_list.begin(); pos != end; ++pos)
-        {
-            if (process == (*pos)->GetProcessSP().get())
-            {
-                target_sp = *pos;
-                break;
-            }
-        }
-    }
-    return target_sp;
-}
-
-TargetSP
-TargetList::GetTargetSP (Target *target) const
-{
-    TargetSP target_sp;
-    if (target)
-    {
-        std::lock_guard<std::recursive_mutex> guard(m_target_list_mutex);
-        collection::const_iterator pos, end = m_target_list.end();
-        for (pos = m_target_list.begin(); pos != end; ++pos)
-        {
-            if (target == (*pos).get())
-            {
-                target_sp = *pos;
-                break;
-            }
-        }
-    }
-    return target_sp;
-}
-
-uint32_t
-TargetList::SendAsyncInterrupt (lldb::pid_t pid)
-{
-    uint32_t num_async_interrupts_sent = 0;
-
-    if (pid != LLDB_INVALID_PROCESS_ID)
-    {
-        TargetSP target_sp(FindTargetWithProcessID (pid));
-        if (target_sp)
-        {
-            Process* process = target_sp->GetProcessSP().get();
-            if (process)
-            {
-                process->SendAsyncInterrupt();
-                ++num_async_interrupts_sent;
-            }
-        }
-    }
-    else
-    {
-        // We don't have a valid pid to broadcast to, so broadcast to the target
-        // list's async broadcaster...
-        BroadcastEvent(Process::eBroadcastBitInterrupt, nullptr);
-    }
-
-    return num_async_interrupts_sent;
-}
-
-uint32_t
-TargetList::SignalIfRunning (lldb::pid_t pid, int signo)
-{
-    uint32_t num_signals_sent = 0;
-    Process *process = nullptr;
-    if (pid == LLDB_INVALID_PROCESS_ID)
-    {
-        // Signal all processes with signal
-        std::lock_guard<std::recursive_mutex> guard(m_target_list_mutex);
-        collection::iterator pos, end = m_target_list.end();
-        for (pos = m_target_list.begin(); pos != end; ++pos)
-        {
-            process = (*pos)->GetProcessSP().get();
-            if (process)
-            {
-                if (process->IsAlive())
-                {
-                    ++num_signals_sent;
-                    process->Signal (signo);
-                }
-            }
-        }
-    }
-    else
-    {
-        // Signal a specific process with signal
-        TargetSP target_sp(FindTargetWithProcessID (pid));
-        if (target_sp)
-        {
-            process = target_sp->GetProcessSP().get();
-            if (process)
-            {
-                if (process->IsAlive())
-                {
-                    ++num_signals_sent;
-                    process->Signal (signo);
-                }
-            }
-        }
-    }
-    return num_signals_sent;
-}
-
-int
-TargetList::GetNumTargets () const
-{
-    std::lock_guard<std::recursive_mutex> guard(m_target_list_mutex);
-    return m_target_list.size();
-}
-
-lldb::TargetSP
-TargetList::GetTargetAtIndex (uint32_t idx) const
-{
-    TargetSP target_sp;
+    for (pos = m_target_list.begin(); pos != end; ++pos) {
+      if (target == (*pos).get()) {
+        target_sp = *pos;
+        break;
+      }
+    }
+  }
+  return target_sp;
+}
+
+uint32_t TargetList::SendAsyncInterrupt(lldb::pid_t pid) {
+  uint32_t num_async_interrupts_sent = 0;
+
+  if (pid != LLDB_INVALID_PROCESS_ID) {
+    TargetSP target_sp(FindTargetWithProcessID(pid));
+    if (target_sp) {
+      Process *process = target_sp->GetProcessSP().get();
+      if (process) {
+        process->SendAsyncInterrupt();
+        ++num_async_interrupts_sent;
+      }
+    }
+  } else {
+    // We don't have a valid pid to broadcast to, so broadcast to the target
+    // list's async broadcaster...
+    BroadcastEvent(Process::eBroadcastBitInterrupt, nullptr);
+  }
+
+  return num_async_interrupts_sent;
+}
+
+uint32_t TargetList::SignalIfRunning(lldb::pid_t pid, int signo) {
+  uint32_t num_signals_sent = 0;
+  Process *process = nullptr;
+  if (pid == LLDB_INVALID_PROCESS_ID) {
+    // Signal all processes with signal
     std::lock_guard<std::recursive_mutex> guard(m_target_list_mutex);
-    if (idx < m_target_list.size())
-        target_sp = m_target_list[idx];
-    return target_sp;
-}
-
-uint32_t
-TargetList::GetIndexOfTarget (lldb::TargetSP target_sp) const
-{
-    std::lock_guard<std::recursive_mutex> guard(m_target_list_mutex);
-    size_t num_targets = m_target_list.size();
-    for (size_t idx = 0; idx < num_targets; idx++)
-    {
-        if (target_sp == m_target_list[idx])
-            return idx;
-    }
-    return UINT32_MAX;
-}
-
-uint32_t
-TargetList::SetSelectedTarget (Target* target)
-{
-    std::lock_guard<std::recursive_mutex> guard(m_target_list_mutex);
-    collection::const_iterator pos,
-        begin = m_target_list.begin(),
-        end = m_target_list.end();
-    for (pos = begin; pos != end; ++pos)
-    {
-        if (pos->get() == target)
-        {
-            m_selected_target_idx = std::distance (begin, pos);
-            return m_selected_target_idx;
-        }
-    }
+    collection::iterator pos, end = m_target_list.end();
+    for (pos = m_target_list.begin(); pos != end; ++pos) {
+      process = (*pos)->GetProcessSP().get();
+      if (process) {
+        if (process->IsAlive()) {
+          ++num_signals_sent;
+          process->Signal(signo);
+        }
+      }
+    }
+  } else {
+    // Signal a specific process with signal
+    TargetSP target_sp(FindTargetWithProcessID(pid));
+    if (target_sp) {
+      process = target_sp->GetProcessSP().get();
+      if (process) {
+        if (process->IsAlive()) {
+          ++num_signals_sent;
+          process->Signal(signo);
+        }
+      }
+    }
+  }
+  return num_signals_sent;
+}
+
+int TargetList::GetNumTargets() const {
+  std::lock_guard<std::recursive_mutex> guard(m_target_list_mutex);
+  return m_target_list.size();
+}
+
+lldb::TargetSP TargetList::GetTargetAtIndex(uint32_t idx) const {
+  TargetSP target_sp;
+  std::lock_guard<std::recursive_mutex> guard(m_target_list_mutex);
+  if (idx < m_target_list.size())
+    target_sp = m_target_list[idx];
+  return target_sp;
+}
+
+uint32_t TargetList::GetIndexOfTarget(lldb::TargetSP target_sp) const {
+  std::lock_guard<std::recursive_mutex> guard(m_target_list_mutex);
+  size_t num_targets = m_target_list.size();
+  for (size_t idx = 0; idx < num_targets; idx++) {
+    if (target_sp == m_target_list[idx])
+      return idx;
+  }
+  return UINT32_MAX;
+}
+
+uint32_t TargetList::SetSelectedTarget(Target *target) {
+  std::lock_guard<std::recursive_mutex> guard(m_target_list_mutex);
+  collection::const_iterator pos, begin = m_target_list.begin(),
+                                  end = m_target_list.end();
+  for (pos = begin; pos != end; ++pos) {
+    if (pos->get() == target) {
+      m_selected_target_idx = std::distance(begin, pos);
+      return m_selected_target_idx;
+    }
+  }
+  m_selected_target_idx = 0;
+  return m_selected_target_idx;
+}
+
+lldb::TargetSP TargetList::GetSelectedTarget() {
+  std::lock_guard<std::recursive_mutex> guard(m_target_list_mutex);
+  if (m_selected_target_idx >= m_target_list.size())
     m_selected_target_idx = 0;
-    return m_selected_target_idx;
-}
-
-lldb::TargetSP
-TargetList::GetSelectedTarget ()
-{
-    std::lock_guard<std::recursive_mutex> guard(m_target_list_mutex);
-    if (m_selected_target_idx >= m_target_list.size())
-        m_selected_target_idx = 0;
-    return GetTargetAtIndex (m_selected_target_idx);
+  return GetTargetAtIndex(m_selected_target_idx);
 }

Modified: lldb/trunk/source/Target/Thread.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Thread.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Target/Thread.cpp (original)
+++ lldb/trunk/source/Target/Thread.cpp Tue Sep  6 15:57:50 2016
@@ -11,15 +11,18 @@
 // C++ Includes
 // Other libraries and framework includes
 // Project includes
+#include "lldb/Target/Thread.h"
+#include "Plugins/Process/Utility/UnwindLLDB.h"
+#include "Plugins/Process/Utility/UnwindMacOSXFrameBackchain.h"
 #include "lldb/Breakpoint/BreakpointLocation.h"
 #include "lldb/Core/Debugger.h"
-#include "lldb/Core/Log.h"
 #include "lldb/Core/FormatEntity.h"
+#include "lldb/Core/Log.h"
 #include "lldb/Core/Module.h"
+#include "lldb/Core/RegularExpression.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"
@@ -34,2478 +37,2141 @@
 #include "lldb/Target/StopInfo.h"
 #include "lldb/Target/SystemRuntime.h"
 #include "lldb/Target/Target.h"
-#include "lldb/Target/Thread.h"
 #include "lldb/Target/ThreadPlan.h"
-#include "lldb/Target/ThreadPlanCallFunction.h"
 #include "lldb/Target/ThreadPlanBase.h"
+#include "lldb/Target/ThreadPlanCallFunction.h"
 #include "lldb/Target/ThreadPlanPython.h"
+#include "lldb/Target/ThreadPlanRunToAddress.h"
+#include "lldb/Target/ThreadPlanStepInRange.h"
 #include "lldb/Target/ThreadPlanStepInstruction.h"
 #include "lldb/Target/ThreadPlanStepOut.h"
 #include "lldb/Target/ThreadPlanStepOverBreakpoint.h"
-#include "lldb/Target/ThreadPlanStepThrough.h"
-#include "lldb/Target/ThreadPlanStepInRange.h"
 #include "lldb/Target/ThreadPlanStepOverRange.h"
-#include "lldb/Target/ThreadPlanRunToAddress.h"
+#include "lldb/Target/ThreadPlanStepThrough.h"
 #include "lldb/Target/ThreadPlanStepUntil.h"
 #include "lldb/Target/ThreadSpec.h"
 #include "lldb/Target/Unwind.h"
-#include "Plugins/Process/Utility/UnwindLLDB.h"
-#include "Plugins/Process/Utility/UnwindMacOSXFrameBackchain.h"
 
 using namespace lldb;
 using namespace lldb_private;
 
-const ThreadPropertiesSP &
-Thread::GetGlobalProperties()
-{
-    // NOTE: intentional leak so we don't crash if global destructor chain gets
-    // called as other threads still use the result of this function
-    static ThreadPropertiesSP *g_settings_sp_ptr = nullptr;
-    static std::once_flag g_once_flag;
-    std::call_once(g_once_flag,  []() {
-        g_settings_sp_ptr = new ThreadPropertiesSP(new ThreadProperties (true));
-    });
-    return *g_settings_sp_ptr;
-}
-
-static PropertyDefinition
-g_properties[] =
-{
-    { "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::", 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  }
-};
+const ThreadPropertiesSP &Thread::GetGlobalProperties() {
+  // NOTE: intentional leak so we don't crash if global destructor chain gets
+  // called as other threads still use the result of this function
+  static ThreadPropertiesSP *g_settings_sp_ptr = nullptr;
+  static std::once_flag g_once_flag;
+  std::call_once(g_once_flag, []() {
+    g_settings_sp_ptr = new ThreadPropertiesSP(new ThreadProperties(true));
+  });
+  return *g_settings_sp_ptr;
+}
+
+static PropertyDefinition g_properties[] = {
+    {"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::", 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 {
-    ePropertyStepInAvoidsNoDebug,
-    ePropertyStepOutAvoidsNoDebug,
-    ePropertyStepAvoidRegex,
-    ePropertyStepAvoidLibraries,
-    ePropertyEnableThreadTrace
+  ePropertyStepInAvoidsNoDebug,
+  ePropertyStepOutAvoidsNoDebug,
+  ePropertyStepAvoidRegex,
+  ePropertyStepAvoidLibraries,
+  ePropertyEnableThreadTrace
 };
 
-class ThreadOptionValueProperties : public OptionValueProperties
-{
+class ThreadOptionValueProperties : public OptionValueProperties {
 public:
-    ThreadOptionValueProperties (const ConstString &name) :
-        OptionValueProperties (name)
-    {
-    }
-    
-    // This constructor is used when creating ThreadOptionValueProperties when it
-    // is part of a new lldb_private::Thread instance. It will copy all current
-    // global property values as needed
-    ThreadOptionValueProperties (ThreadProperties *global_properties) :
-        OptionValueProperties(*global_properties->GetValueProperties())
-    {
-    }
-    
-    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
-        // use the one from this instance.
-        if (exe_ctx)
-        {
-            Thread *thread = exe_ctx->GetThreadPtr();
-            if (thread)
-            {
-                ThreadOptionValueProperties *instance_properties = static_cast<ThreadOptionValueProperties *>(thread->GetValueProperties().get());
-                if (this != instance_properties)
-                    return instance_properties->ProtectedGetPropertyAtIndex (idx);
-            }
-        }
-        return ProtectedGetPropertyAtIndex (idx);
+  ThreadOptionValueProperties(const ConstString &name)
+      : OptionValueProperties(name) {}
+
+  // This constructor is used when creating ThreadOptionValueProperties when it
+  // is part of a new lldb_private::Thread instance. It will copy all current
+  // global property values as needed
+  ThreadOptionValueProperties(ThreadProperties *global_properties)
+      : OptionValueProperties(*global_properties->GetValueProperties()) {}
+
+  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
+    // use the one from this instance.
+    if (exe_ctx) {
+      Thread *thread = exe_ctx->GetThreadPtr();
+      if (thread) {
+        ThreadOptionValueProperties *instance_properties =
+            static_cast<ThreadOptionValueProperties *>(
+                thread->GetValueProperties().get());
+        if (this != instance_properties)
+          return instance_properties->ProtectedGetPropertyAtIndex(idx);
+      }
     }
+    return ProtectedGetPropertyAtIndex(idx);
+  }
 };
 
-ThreadProperties::ThreadProperties (bool is_global) :
-    Properties ()
-{
-    if (is_global)
-    {
-        m_collection_sp.reset (new ThreadOptionValueProperties(ConstString("thread")));
-        m_collection_sp->Initialize(g_properties);
-    }
-    else
-        m_collection_sp.reset (new ThreadOptionValueProperties(Thread::GetGlobalProperties().get()));
+ThreadProperties::ThreadProperties(bool is_global) : Properties() {
+  if (is_global) {
+    m_collection_sp.reset(
+        new ThreadOptionValueProperties(ConstString("thread")));
+    m_collection_sp->Initialize(g_properties);
+  } else
+    m_collection_sp.reset(
+        new ThreadOptionValueProperties(Thread::GetGlobalProperties().get()));
 }
 
 ThreadProperties::~ThreadProperties() = default;
 
-const RegularExpression *
-ThreadProperties::GetSymbolsToAvoidRegexp()
-{
-    const uint32_t idx = ePropertyStepAvoidRegex;
-    return m_collection_sp->GetPropertyAtIndexAsOptionValueRegex(nullptr, idx);
+const RegularExpression *ThreadProperties::GetSymbolsToAvoidRegexp() {
+  const uint32_t idx = ePropertyStepAvoidRegex;
+  return m_collection_sp->GetPropertyAtIndexAsOptionValueRegex(nullptr, idx);
 }
 
-FileSpecList &
-ThreadProperties::GetLibrariesToAvoid() const
-{
-    const uint32_t idx = ePropertyStepAvoidLibraries;
-    OptionValueFileSpecList *option_value = m_collection_sp->GetPropertyAtIndexAsOptionValueFileSpecList(nullptr, false, idx);
-    assert(option_value);
-    return option_value->GetCurrentValue();
+FileSpecList &ThreadProperties::GetLibrariesToAvoid() const {
+  const uint32_t idx = ePropertyStepAvoidLibraries;
+  OptionValueFileSpecList *option_value =
+      m_collection_sp->GetPropertyAtIndexAsOptionValueFileSpecList(nullptr,
+                                                                   false, idx);
+  assert(option_value);
+  return option_value->GetCurrentValue();
 }
 
-bool
-ThreadProperties::GetTraceEnabledState() const
-{
-    const uint32_t idx = ePropertyEnableThreadTrace;
-    return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx, g_properties[idx].default_uint_value != 0);
+bool ThreadProperties::GetTraceEnabledState() const {
+  const uint32_t idx = ePropertyEnableThreadTrace;
+  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(nullptr, idx, g_properties[idx].default_uint_value != 0);
+bool ThreadProperties::GetStepInAvoidsNoDebug() const {
+  const uint32_t idx = ePropertyStepInAvoidsNoDebug;
+  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(nullptr, idx, g_properties[idx].default_uint_value != 0);
+bool ThreadProperties::GetStepOutAvoidsNoDebug() const {
+  const uint32_t idx = ePropertyStepOutAvoidsNoDebug;
+  return m_collection_sp->GetPropertyAtIndexAsBoolean(
+      nullptr, idx, g_properties[idx].default_uint_value != 0);
 }
 
 //------------------------------------------------------------------
 // Thread Event Data
 //------------------------------------------------------------------
 
-const ConstString &
-Thread::ThreadEventData::GetFlavorString ()
-{
-    static ConstString g_flavor ("Thread::ThreadEventData");
-    return g_flavor;
+const ConstString &Thread::ThreadEventData::GetFlavorString() {
+  static ConstString g_flavor("Thread::ThreadEventData");
+  return g_flavor;
 }
 
-Thread::ThreadEventData::ThreadEventData (const lldb::ThreadSP thread_sp) :
-    m_thread_sp (thread_sp),
-    m_stack_id ()
-{
-}
+Thread::ThreadEventData::ThreadEventData(const lldb::ThreadSP thread_sp)
+    : m_thread_sp(thread_sp), m_stack_id() {}
 
-Thread::ThreadEventData::ThreadEventData (const lldb::ThreadSP thread_sp, const StackID &stack_id) :
-    m_thread_sp (thread_sp),
-    m_stack_id (stack_id)
-{
-}
+Thread::ThreadEventData::ThreadEventData(const lldb::ThreadSP thread_sp,
+                                         const StackID &stack_id)
+    : m_thread_sp(thread_sp), m_stack_id(stack_id) {}
 
-Thread::ThreadEventData::ThreadEventData () :
-    m_thread_sp (),
-    m_stack_id ()
-{
-}
+Thread::ThreadEventData::ThreadEventData() : m_thread_sp(), m_stack_id() {}
 
 Thread::ThreadEventData::~ThreadEventData() = default;
 
-void
-Thread::ThreadEventData::Dump (Stream *s) const
-{
-}
+void Thread::ThreadEventData::Dump(Stream *s) const {}
 
 const Thread::ThreadEventData *
-Thread::ThreadEventData::GetEventDataFromEvent (const Event *event_ptr)
-{
-    if (event_ptr)
-    {
-        const EventData *event_data = event_ptr->GetData();
-        if (event_data && event_data->GetFlavor() == ThreadEventData::GetFlavorString())
-            return static_cast <const ThreadEventData *> (event_ptr->GetData());
-    }
-    return nullptr;
-}
-
-ThreadSP
-Thread::ThreadEventData::GetThreadFromEvent (const Event *event_ptr)
-{
-    ThreadSP thread_sp;
-    const ThreadEventData *event_data = GetEventDataFromEvent (event_ptr);
-    if (event_data)
-        thread_sp = event_data->GetThread();
-    return thread_sp;
-}
-
-StackID
-Thread::ThreadEventData::GetStackIDFromEvent (const Event *event_ptr)
-{
-    StackID stack_id;
-    const ThreadEventData *event_data = GetEventDataFromEvent (event_ptr);
-    if (event_data)
-        stack_id = event_data->GetStackID();
-    return stack_id;
+Thread::ThreadEventData::GetEventDataFromEvent(const Event *event_ptr) {
+  if (event_ptr) {
+    const EventData *event_data = event_ptr->GetData();
+    if (event_data &&
+        event_data->GetFlavor() == ThreadEventData::GetFlavorString())
+      return static_cast<const ThreadEventData *>(event_ptr->GetData());
+  }
+  return nullptr;
+}
+
+ThreadSP Thread::ThreadEventData::GetThreadFromEvent(const Event *event_ptr) {
+  ThreadSP thread_sp;
+  const ThreadEventData *event_data = GetEventDataFromEvent(event_ptr);
+  if (event_data)
+    thread_sp = event_data->GetThread();
+  return thread_sp;
+}
+
+StackID Thread::ThreadEventData::GetStackIDFromEvent(const Event *event_ptr) {
+  StackID stack_id;
+  const ThreadEventData *event_data = GetEventDataFromEvent(event_ptr);
+  if (event_data)
+    stack_id = event_data->GetStackID();
+  return stack_id;
 }
 
 StackFrameSP
-Thread::ThreadEventData::GetStackFrameFromEvent (const Event *event_ptr)
-{
-    const ThreadEventData *event_data = GetEventDataFromEvent (event_ptr);
-    StackFrameSP frame_sp;
-    if (event_data)
-    {
-        ThreadSP thread_sp = event_data->GetThread();
-        if (thread_sp)
-        {
-            frame_sp = thread_sp->GetStackFrameList()->GetFrameWithStackID (event_data->GetStackID());
-        }
+Thread::ThreadEventData::GetStackFrameFromEvent(const Event *event_ptr) {
+  const ThreadEventData *event_data = GetEventDataFromEvent(event_ptr);
+  StackFrameSP frame_sp;
+  if (event_data) {
+    ThreadSP thread_sp = event_data->GetThread();
+    if (thread_sp) {
+      frame_sp = thread_sp->GetStackFrameList()->GetFrameWithStackID(
+          event_data->GetStackID());
     }
-    return frame_sp;
+  }
+  return frame_sp;
 }
 
 //------------------------------------------------------------------
 // Thread class
 //------------------------------------------------------------------
 
-ConstString &
-Thread::GetStaticBroadcasterClass ()
-{
-    static ConstString class_name ("lldb.thread");
-    return class_name;
+ConstString &Thread::GetStaticBroadcasterClass() {
+  static ConstString class_name("lldb.thread");
+  return class_name;
 }
 
 Thread::Thread(Process &process, lldb::tid_t tid, bool use_invalid_index_id)
-    : ThreadProperties(false),
-      UserID(tid),
+    : ThreadProperties(false), UserID(tid),
       Broadcaster(process.GetTarget().GetDebugger().GetBroadcasterManager(),
                   Thread::GetStaticBroadcasterClass().AsCString()),
-      m_process_wp(process.shared_from_this()),
-      m_stop_info_sp(),
-      m_stop_info_stop_id(0),
-      m_stop_info_override_stop_id(0),
-      m_index_id(use_invalid_index_id ? LLDB_INVALID_INDEX32 : process.GetNextThreadIndexID(tid)),
-      m_reg_context_sp(),
-      m_state(eStateUnloaded),
-      m_state_mutex(),
-      m_plan_stack(),
-      m_completed_plan_stack(),
-      m_frame_mutex(),
-      m_curr_frames_sp(),
-      m_prev_frames_sp(),
+      m_process_wp(process.shared_from_this()), m_stop_info_sp(),
+      m_stop_info_stop_id(0), m_stop_info_override_stop_id(0),
+      m_index_id(use_invalid_index_id ? LLDB_INVALID_INDEX32
+                                      : process.GetNextThreadIndexID(tid)),
+      m_reg_context_sp(), m_state(eStateUnloaded), m_state_mutex(),
+      m_plan_stack(), m_completed_plan_stack(), m_frame_mutex(),
+      m_curr_frames_sp(), m_prev_frames_sp(),
       m_resume_signal(LLDB_INVALID_SIGNAL_NUMBER),
-      m_resume_state(eStateRunning),
-      m_temporary_resume_state(eStateRunning),
-      m_unwinder_ap(),
-      m_destroy_called(false),
+      m_resume_state(eStateRunning), m_temporary_resume_state(eStateRunning),
+      m_unwinder_ap(), m_destroy_called(false),
       m_override_should_notify(eLazyBoolCalculate),
-      m_extended_info_fetched(false),
-      m_extended_info()
-{
-    Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_OBJECT));
-    if (log)
-        log->Printf("%p Thread::Thread(tid = 0x%4.4" PRIx64 ")", static_cast<void *>(this), GetID());
-
-    CheckInWithManager();
-    QueueFundamentalPlan(true);
-}
-
-Thread::~Thread()
-{
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT));
-    if (log)
-        log->Printf ("%p Thread::~Thread(tid = 0x%4.4" PRIx64 ")",
-                     static_cast<void*>(this), GetID());
-    /// If you hit this assert, it means your derived class forgot to call DoDestroy in its destructor.
-    assert (m_destroy_called);
-}
-
-void 
-Thread::DestroyThread ()
-{
-    // Tell any plans on the plan stacks that the thread is being destroyed since
-    // any plans that have a thread go away in the middle of might need
-    // to do cleanup, or in some cases NOT do cleanup...
-    for (auto plan : m_plan_stack)
-        plan->ThreadDestroyed();
-
-    for (auto plan : m_discarded_plan_stack)
-        plan->ThreadDestroyed();
-
-    for (auto plan : m_completed_plan_stack)
-        plan->ThreadDestroyed();
-
-    m_destroy_called = true;
-    m_plan_stack.clear();
-    m_discarded_plan_stack.clear();
-    m_completed_plan_stack.clear();
-    
-    // Push a ThreadPlanNull on the plan stack.  That way we can continue assuming that the
-    // plan stack is never empty, but if somebody errantly asks questions of a destroyed thread
-    // without checking first whether it is destroyed, they won't crash.
-    ThreadPlanSP null_plan_sp(new ThreadPlanNull (*this));
-    m_plan_stack.push_back (null_plan_sp);
-    
-    m_stop_info_sp.reset();
-    m_reg_context_sp.reset();
-    m_unwinder_ap.reset();
-    std::lock_guard<std::recursive_mutex> guard(m_frame_mutex);
-    m_curr_frames_sp.reset();
-    m_prev_frames_sp.reset();
-}
-
-void
-Thread::BroadcastSelectedFrameChange(StackID &new_frame_id)
-{
-    if (EventTypeHasListeners(eBroadcastBitSelectedFrameChanged))
-        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);
+      m_extended_info_fetched(false), m_extended_info() {
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_OBJECT));
+  if (log)
+    log->Printf("%p Thread::Thread(tid = 0x%4.4" PRIx64 ")",
+                static_cast<void *>(this), GetID());
+
+  CheckInWithManager();
+  QueueFundamentalPlan(true);
+}
+
+Thread::~Thread() {
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_OBJECT));
+  if (log)
+    log->Printf("%p Thread::~Thread(tid = 0x%4.4" PRIx64 ")",
+                static_cast<void *>(this), GetID());
+  /// If you hit this assert, it means your derived class forgot to call
+  /// DoDestroy in its destructor.
+  assert(m_destroy_called);
+}
+
+void Thread::DestroyThread() {
+  // Tell any plans on the plan stacks that the thread is being destroyed since
+  // any plans that have a thread go away in the middle of might need
+  // to do cleanup, or in some cases NOT do cleanup...
+  for (auto plan : m_plan_stack)
+    plan->ThreadDestroyed();
+
+  for (auto plan : m_discarded_plan_stack)
+    plan->ThreadDestroyed();
+
+  for (auto plan : m_completed_plan_stack)
+    plan->ThreadDestroyed();
+
+  m_destroy_called = true;
+  m_plan_stack.clear();
+  m_discarded_plan_stack.clear();
+  m_completed_plan_stack.clear();
+
+  // Push a ThreadPlanNull on the plan stack.  That way we can continue assuming
+  // that the
+  // plan stack is never empty, but if somebody errantly asks questions of a
+  // destroyed thread
+  // without checking first whether it is destroyed, they won't crash.
+  ThreadPlanSP null_plan_sp(new ThreadPlanNull(*this));
+  m_plan_stack.push_back(null_plan_sp);
+
+  m_stop_info_sp.reset();
+  m_reg_context_sp.reset();
+  m_unwinder_ap.reset();
+  std::lock_guard<std::recursive_mutex> guard(m_frame_mutex);
+  m_curr_frames_sp.reset();
+  m_prev_frames_sp.reset();
+}
+
+void Thread::BroadcastSelectedFrameChange(StackID &new_frame_id) {
+  if (EventTypeHasListeners(eBroadcastBitSelectedFrameChanged))
+    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;
+}
+
+bool Thread::SetSelectedFrameByIndex(uint32_t frame_idx, bool broadcast) {
+  StackFrameSP frame_sp(GetStackFrameList()->GetFrameAtIndex(frame_idx));
+  if (frame_sp) {
+    GetStackFrameList()->SetSelectedFrame(frame_sp.get());
     if (broadcast)
-        BroadcastSelectedFrameChange(frame->GetStackID());
-    FunctionOptimizationWarning (frame);
-    return ret_value;
+      BroadcastSelectedFrameChange(frame_sp->GetStackID());
+    FunctionOptimizationWarning(frame_sp.get());
+    return true;
+  } else
+    return false;
 }
 
-bool
-Thread::SetSelectedFrameByIndex (uint32_t frame_idx, bool broadcast)
-{
-    StackFrameSP frame_sp(GetStackFrameList()->GetFrameAtIndex (frame_idx));
-    if (frame_sp)
-    {
-        GetStackFrameList()->SetSelectedFrame(frame_sp.get());
-        if (broadcast)
-            BroadcastSelectedFrameChange(frame_sp->GetStackID());
-        FunctionOptimizationWarning (frame_sp.get());
-        return true;
+bool Thread::SetSelectedFrameByIndexNoisily(uint32_t frame_idx,
+                                            Stream &output_stream) {
+  const bool broadcast = true;
+  bool success = SetSelectedFrameByIndex(frame_idx, broadcast);
+  if (success) {
+    StackFrameSP frame_sp = GetSelectedFrame();
+    if (frame_sp) {
+      bool already_shown = false;
+      SymbolContext frame_sc(
+          frame_sp->GetSymbolContext(eSymbolContextLineEntry));
+      if (GetProcess()->GetTarget().GetDebugger().GetUseExternalEditor() &&
+          frame_sc.line_entry.file && frame_sc.line_entry.line != 0) {
+        already_shown = Host::OpenFileInExternalEditor(
+            frame_sc.line_entry.file, frame_sc.line_entry.line);
+      }
+
+      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);
     }
-    else
-        return false;
+    return false;
+  } else
+    return false;
 }
 
-bool
-Thread::SetSelectedFrameByIndexNoisily (uint32_t frame_idx, Stream &output_stream)
-{
-    const bool broadcast = true;
-    bool success = SetSelectedFrameByIndex (frame_idx, broadcast);
-    if (success)
-    {
-        StackFrameSP frame_sp = GetSelectedFrame();
-        if (frame_sp)
-        {
-            bool already_shown = false;
-            SymbolContext frame_sc(frame_sp->GetSymbolContext(eSymbolContextLineEntry));
-            if (GetProcess()->GetTarget().GetDebugger().GetUseExternalEditor() && frame_sc.line_entry.file && frame_sc.line_entry.line != 0)
-            {
-                already_shown = Host::OpenFileInExternalEditor (frame_sc.line_entry.file, frame_sc.line_entry.line);
-            }
-
-            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;
-    }
-    else
-        return false;
+void Thread::FunctionOptimizationWarning(StackFrame *frame) {
+  if (frame && frame->HasDebugInformation() &&
+      GetProcess()->GetWarningsOptimization()) {
+    SymbolContext sc =
+        frame->GetSymbolContext(eSymbolContextFunction | eSymbolContextModule);
+    GetProcess()->PrintWarningOptimization(sc);
+  }
 }
 
-void
-Thread::FunctionOptimizationWarning (StackFrame *frame)
-{
-    if (frame && frame->HasDebugInformation() && GetProcess()->GetWarningsOptimization())
-    {
-        SymbolContext sc = frame->GetSymbolContext (eSymbolContextFunction | eSymbolContextModule);
-        GetProcess()->PrintWarningOptimization (sc);
+lldb::StopInfoSP Thread::GetStopInfo() {
+  if (m_destroy_called)
+    return m_stop_info_sp;
+
+  ThreadPlanSP plan_sp(GetCompletedPlan());
+  ProcessSP process_sp(GetProcess());
+  const uint32_t stop_id = process_sp ? process_sp->GetStopID() : UINT32_MAX;
+  if (plan_sp && plan_sp->PlanSucceeded()) {
+    return StopInfo::CreateStopReasonWithPlan(plan_sp, GetReturnValueObject(),
+                                              GetExpressionVariable());
+  } else {
+    if ((m_stop_info_stop_id == stop_id) || // Stop info is valid, just return
+                                            // what we have (even if empty)
+        (m_stop_info_sp &&
+         m_stop_info_sp
+             ->IsValid())) // Stop info is valid, just return what we have
+    {
+      return m_stop_info_sp;
+    } else {
+      GetPrivateStopInfo();
+      return m_stop_info_sp;
     }
+  }
 }
 
-lldb::StopInfoSP
-Thread::GetStopInfo ()
-{
-    if (m_destroy_called)
-        return m_stop_info_sp;
+lldb::StopInfoSP Thread::GetPrivateStopInfo() {
+  if (m_destroy_called)
+    return m_stop_info_sp;
 
-    ThreadPlanSP plan_sp (GetCompletedPlan());
-    ProcessSP process_sp (GetProcess());
-    const uint32_t stop_id = process_sp ? process_sp->GetStopID() : UINT32_MAX;
-    if (plan_sp && plan_sp->PlanSucceeded())
-    {
-        return StopInfo::CreateStopReasonWithPlan (plan_sp, GetReturnValueObject(), GetExpressionVariable());
-    }
-    else
-    {
-        if ((m_stop_info_stop_id == stop_id) ||   // Stop info is valid, just return what we have (even if empty)
-            (m_stop_info_sp && m_stop_info_sp->IsValid()))  // Stop info is valid, just return what we have
-        {
-            return m_stop_info_sp;
-        }
+  ProcessSP process_sp(GetProcess());
+  if (process_sp) {
+    const uint32_t process_stop_id = process_sp->GetStopID();
+    if (m_stop_info_stop_id != process_stop_id) {
+      if (m_stop_info_sp) {
+        if (m_stop_info_sp->IsValid() || IsStillAtLastBreakpointHit() ||
+            GetCurrentPlan()->IsVirtualStep())
+          SetStopInfo(m_stop_info_sp);
         else
-        {
-            GetPrivateStopInfo ();
-            return m_stop_info_sp;
-        }
-    }
-}
-
-lldb::StopInfoSP
-Thread::GetPrivateStopInfo ()
-{
-    if (m_destroy_called)
-        return m_stop_info_sp;
+          m_stop_info_sp.reset();
+      }
 
-    ProcessSP process_sp (GetProcess());
-    if (process_sp)
-    {
-        const uint32_t process_stop_id = process_sp->GetStopID();
-        if (m_stop_info_stop_id != process_stop_id)
-        {
-            if (m_stop_info_sp)
-            {
-                if (m_stop_info_sp->IsValid()
-                    || IsStillAtLastBreakpointHit()
-                    || GetCurrentPlan()->IsVirtualStep())
-                    SetStopInfo (m_stop_info_sp);
-                else
-                    m_stop_info_sp.reset();
-            }
+      if (!m_stop_info_sp) {
+        if (!CalculateStopInfo())
+          SetStopInfo(StopInfoSP());
+      }
+    }
+
+    // The stop info can be manually set by calling Thread::SetStopInfo()
+    // prior to this function ever getting called, so we can't rely on
+    // "m_stop_info_stop_id != process_stop_id" as the condition for
+    // the if statement below, we must also check the stop info to see
+    // if we need to override it. See the header documentation in
+    // Process::GetStopInfoOverrideCallback() for more information on
+    // the stop info override callback.
+    if (m_stop_info_override_stop_id != process_stop_id) {
+      m_stop_info_override_stop_id = process_stop_id;
+      if (m_stop_info_sp) {
+        ArchSpec::StopInfoOverrideCallbackType callback =
+            GetProcess()->GetStopInfoOverrideCallback();
+        if (callback)
+          callback(*this);
+      }
+    }
+  }
+  return m_stop_info_sp;
+}
+
+lldb::StopReason Thread::GetStopReason() {
+  lldb::StopInfoSP stop_info_sp(GetStopInfo());
+  if (stop_info_sp)
+    return stop_info_sp->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) {
+  m_stop_info_sp = stop_info_sp;
+  if (m_stop_info_sp) {
+    m_stop_info_sp->MakeStopInfoValid();
+    // If we are overriding the ShouldReportStop, do that here:
+    if (m_override_should_notify != eLazyBoolCalculate)
+      m_stop_info_sp->OverrideShouldNotify(m_override_should_notify ==
+                                           eLazyBoolYes);
+  }
+
+  ProcessSP process_sp(GetProcess());
+  if (process_sp)
+    m_stop_info_stop_id = process_sp->GetStopID();
+  else
+    m_stop_info_stop_id = UINT32_MAX;
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_THREAD));
+  if (log)
+    log->Printf("%p: tid = 0x%" PRIx64 ": stop info = %s (stop_id = %u)",
+                static_cast<void *>(this), GetID(),
+                stop_info_sp ? stop_info_sp->GetDescription() : "<NULL>",
+                m_stop_info_stop_id);
+}
+
+void Thread::SetShouldReportStop(Vote vote) {
+  if (vote == eVoteNoOpinion)
+    return;
+  else {
+    m_override_should_notify = (vote == eVoteYes ? eLazyBoolYes : eLazyBoolNo);
+    if (m_stop_info_sp)
+      m_stop_info_sp->OverrideShouldNotify(m_override_should_notify ==
+                                           eLazyBoolYes);
+  }
+}
+
+void Thread::SetStopInfoToNothing() {
+  // Note, we can't just NULL out the private reason, or the native thread
+  // implementation will try to
+  // go calculate it again.  For now, just set it to a Unix Signal with an
+  // invalid signal number.
+  SetStopInfo(
+      StopInfo::CreateStopReasonWithSignal(*this, LLDB_INVALID_SIGNAL_NUMBER));
+}
+
+bool Thread::ThreadStoppedForAReason(void) {
+  return (bool)GetPrivateStopInfo();
+}
+
+bool Thread::CheckpointThreadState(ThreadStateCheckpoint &saved_state) {
+  saved_state.register_backup_sp.reset();
+  lldb::StackFrameSP frame_sp(GetStackFrameAtIndex(0));
+  if (frame_sp) {
+    lldb::RegisterCheckpointSP reg_checkpoint_sp(
+        new RegisterCheckpoint(RegisterCheckpoint::Reason::eExpression));
+    if (reg_checkpoint_sp) {
+      lldb::RegisterContextSP reg_ctx_sp(frame_sp->GetRegisterContext());
+      if (reg_ctx_sp && reg_ctx_sp->ReadAllRegisterValues(*reg_checkpoint_sp))
+        saved_state.register_backup_sp = reg_checkpoint_sp;
+    }
+  }
+  if (!saved_state.register_backup_sp)
+    return false;
 
-            if (!m_stop_info_sp)
-            {
-                if (!CalculateStopInfo())
-                    SetStopInfo (StopInfoSP());
-            }
-        }
+  saved_state.stop_info_sp = GetStopInfo();
+  ProcessSP process_sp(GetProcess());
+  if (process_sp)
+    saved_state.orig_stop_id = process_sp->GetStopID();
+  saved_state.current_inlined_depth = GetCurrentInlinedDepth();
+
+  return true;
+}
+
+bool Thread::RestoreRegisterStateFromCheckpoint(
+    ThreadStateCheckpoint &saved_state) {
+  if (saved_state.register_backup_sp) {
+    lldb::StackFrameSP frame_sp(GetStackFrameAtIndex(0));
+    if (frame_sp) {
+      lldb::RegisterContextSP reg_ctx_sp(frame_sp->GetRegisterContext());
+      if (reg_ctx_sp) {
+        bool ret =
+            reg_ctx_sp->WriteAllRegisterValues(*saved_state.register_backup_sp);
 
-        // The stop info can be manually set by calling Thread::SetStopInfo()
-        // prior to this function ever getting called, so we can't rely on
-        // "m_stop_info_stop_id != process_stop_id" as the condition for
-        // the if statement below, we must also check the stop info to see
-        // if we need to override it. See the header documentation in
-        // Process::GetStopInfoOverrideCallback() for more information on
-        // the stop info override callback.
-        if (m_stop_info_override_stop_id != process_stop_id)
-        {
-            m_stop_info_override_stop_id = process_stop_id;
-            if (m_stop_info_sp)
-            {
-                ArchSpec::StopInfoOverrideCallbackType callback = GetProcess()->GetStopInfoOverrideCallback();
-                if (callback)
-                    callback(*this);
-            }
-        }
+        // Clear out all stack frames as our world just changed.
+        ClearStackFrames();
+        reg_ctx_sp->InvalidateIfNeeded(true);
+        if (m_unwinder_ap.get())
+          m_unwinder_ap->Clear();
+        return ret;
+      }
     }
-    return m_stop_info_sp;
+  }
+  return false;
 }
 
-lldb::StopReason
-Thread::GetStopReason()
-{
-    lldb::StopInfoSP stop_info_sp (GetStopInfo ());
-    if (stop_info_sp)
-        return stop_info_sp->GetStopReason();
-    return eStopReasonNone;
+bool Thread::RestoreThreadStateFromCheckpoint(
+    ThreadStateCheckpoint &saved_state) {
+  if (saved_state.stop_info_sp)
+    saved_state.stop_info_sp->MakeStopInfoValid();
+  SetStopInfo(saved_state.stop_info_sp);
+  GetStackFrameList()->SetCurrentInlinedDepth(
+      saved_state.current_inlined_depth);
+  return true;
 }
 
-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...
+StateType Thread::GetState() const {
+  // If any other threads access this we will need a mutex for it
+  std::lock_guard<std::recursive_mutex> guard(m_state_mutex);
+  return m_state;
 }
 
-void
-Thread::SetStopInfo (const lldb::StopInfoSP &stop_info_sp)
-{
-    m_stop_info_sp = stop_info_sp;
-    if (m_stop_info_sp)
-    {
-        m_stop_info_sp->MakeStopInfoValid();
-        // If we are overriding the ShouldReportStop, do that here:
-        if (m_override_should_notify != eLazyBoolCalculate)
-            m_stop_info_sp->OverrideShouldNotify (m_override_should_notify == eLazyBoolYes);
-    }
-    
-    ProcessSP process_sp (GetProcess());
-    if (process_sp)
-        m_stop_info_stop_id = process_sp->GetStopID();
-    else
-        m_stop_info_stop_id = UINT32_MAX;
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_THREAD));
-    if (log)
-        log->Printf("%p: tid = 0x%" PRIx64 ": stop info = %s (stop_id = %u)",
-                    static_cast<void*>(this), GetID(),
-                    stop_info_sp ? stop_info_sp->GetDescription() : "<NULL>",
-                    m_stop_info_stop_id);
+void Thread::SetState(StateType state) {
+  std::lock_guard<std::recursive_mutex> guard(m_state_mutex);
+  m_state = state;
 }
 
-void
-Thread::SetShouldReportStop (Vote vote)
-{
-    if (vote == eVoteNoOpinion)
-        return;
-    else
-    {
-        m_override_should_notify = (vote == eVoteYes ? eLazyBoolYes : eLazyBoolNo);
-        if (m_stop_info_sp)
-            m_stop_info_sp->OverrideShouldNotify (m_override_should_notify == eLazyBoolYes);
-    }
-}
+void Thread::WillStop() {
+  ThreadPlan *current_plan = GetCurrentPlan();
 
-void
-Thread::SetStopInfoToNothing()
-{
-    // Note, we can't just NULL out the private reason, or the native thread implementation will try to
-    // go calculate it again.  For now, just set it to a Unix Signal with an invalid signal number.
-    SetStopInfo (StopInfo::CreateStopReasonWithSignal (*this,  LLDB_INVALID_SIGNAL_NUMBER));
-}
+  // FIXME: I may decide to disallow threads with no plans.  In which
+  // case this should go to an assert.
 
-bool
-Thread::ThreadStoppedForAReason (void)
-{
-    return (bool) GetPrivateStopInfo ();
+  if (!current_plan)
+    return;
+
+  current_plan->WillStop();
 }
 
-bool
-Thread::CheckpointThreadState (ThreadStateCheckpoint &saved_state)
-{
-    saved_state.register_backup_sp.reset();
-    lldb::StackFrameSP frame_sp(GetStackFrameAtIndex (0));
-    if (frame_sp)
-    {
-        lldb::RegisterCheckpointSP reg_checkpoint_sp(new RegisterCheckpoint(RegisterCheckpoint::Reason::eExpression));
-        if (reg_checkpoint_sp)
-        {
-            lldb::RegisterContextSP reg_ctx_sp (frame_sp->GetRegisterContext());
-            if (reg_ctx_sp && reg_ctx_sp->ReadAllRegisterValues (*reg_checkpoint_sp))
-                saved_state.register_backup_sp = reg_checkpoint_sp;
-        }
-    }
-    if (!saved_state.register_backup_sp)
-        return false;
+void 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.
 
-    saved_state.stop_info_sp = GetStopInfo();
-    ProcessSP process_sp (GetProcess());
-    if (process_sp)
-        saved_state.orig_stop_id = process_sp->GetStopID();
-    saved_state.current_inlined_depth = GetCurrentInlinedDepth();
-    
-    return true;
-}
+    lldb::RegisterContextSP reg_ctx_sp(GetRegisterContext());
+    if (reg_ctx_sp) {
+      const addr_t thread_pc = reg_ctx_sp->GetPC();
+      BreakpointSiteSP bp_site_sp =
+          GetProcess()->GetBreakpointSiteList().FindByAddress(thread_pc);
+      if (bp_site_sp) {
+        // Note, don't assume there's a ThreadPlanStepOverBreakpoint, the target
+        // may not require anything
+        // special to step over a breakpoint.
 
-bool
-Thread::RestoreRegisterStateFromCheckpoint (ThreadStateCheckpoint &saved_state)
-{
-    if (saved_state.register_backup_sp)
-    {
-        lldb::StackFrameSP frame_sp(GetStackFrameAtIndex (0));
-        if (frame_sp)
-        {
-            lldb::RegisterContextSP reg_ctx_sp (frame_sp->GetRegisterContext());
-            if (reg_ctx_sp)
-            {
-                bool ret = reg_ctx_sp->WriteAllRegisterValues (*saved_state.register_backup_sp);
-                
-                // Clear out all stack frames as our world just changed.
-                ClearStackFrames();
-                reg_ctx_sp->InvalidateIfNeeded(true);
-                if (m_unwinder_ap.get())
-                    m_unwinder_ap->Clear();
-                return ret;
+        ThreadPlan *cur_plan = GetCurrentPlan();
+
+        bool push_step_over_bp_plan = false;
+        if (cur_plan->GetKind() == ThreadPlan::eKindStepOverBreakpoint) {
+          ThreadPlanStepOverBreakpoint *bp_plan =
+              (ThreadPlanStepOverBreakpoint *)cur_plan;
+          if (bp_plan->GetBreakpointLoadAddress() != thread_pc)
+            push_step_over_bp_plan = true;
+        } else
+          push_step_over_bp_plan = true;
+
+        if (push_step_over_bp_plan) {
+          ThreadPlanSP step_bp_plan_sp(new ThreadPlanStepOverBreakpoint(*this));
+          if (step_bp_plan_sp) {
+            step_bp_plan_sp->SetPrivate(true);
+
+            if (GetCurrentPlan()->RunState() != eStateStepping) {
+              ThreadPlanStepOverBreakpoint *step_bp_plan =
+                  static_cast<ThreadPlanStepOverBreakpoint *>(
+                      step_bp_plan_sp.get());
+              step_bp_plan->SetAutoContinue(true);
             }
+            QueueThreadPlan(step_bp_plan_sp, false);
+          }
         }
+      }
     }
-    return false;
+  }
 }
 
-bool
-Thread::RestoreThreadStateFromCheckpoint (ThreadStateCheckpoint &saved_state)
-{
-    if (saved_state.stop_info_sp)
-        saved_state.stop_info_sp->MakeStopInfoValid();
-    SetStopInfo(saved_state.stop_info_sp);
-    GetStackFrameList()->SetCurrentInlinedDepth (saved_state.current_inlined_depth);
-    return true;
-}
+bool Thread::ShouldResume(StateType resume_state) {
+  // At this point clear the completed plan stack.
+  m_completed_plan_stack.clear();
+  m_discarded_plan_stack.clear();
+  m_override_should_notify = eLazyBoolCalculate;
 
-StateType
-Thread::GetState() const
-{
-    // If any other threads access this we will need a mutex for it
-    std::lock_guard<std::recursive_mutex> guard(m_state_mutex);
-    return m_state;
-}
+  StateType prev_resume_state = GetTemporaryResumeState();
 
-void
-Thread::SetState(StateType state)
-{
-    std::lock_guard<std::recursive_mutex> guard(m_state_mutex);
-    m_state = state;
-}
+  SetTemporaryResumeState(resume_state);
 
-void
-Thread::WillStop()
-{
-    ThreadPlan *current_plan = GetCurrentPlan();
+  lldb::ThreadSP backing_thread_sp(GetBackingThread());
+  if (backing_thread_sp)
+    backing_thread_sp->SetTemporaryResumeState(resume_state);
 
-    // FIXME: I may decide to disallow threads with no plans.  In which
-    // case this should go to an assert.
+  // 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();
 
-    if (!current_plan)
-        return;
+  // 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
+  // we're about to resume, and we haven't yet had to fetch the stop reason,
+  // then it doesn't need to know
+  // about the fact that we are resuming...
+  const uint32_t process_stop_id = GetProcess()->GetStopID();
+  if (m_stop_info_stop_id == process_stop_id &&
+      (m_stop_info_sp && m_stop_info_sp->IsValid())) {
+    StopInfo *stop_info = GetPrivateStopInfo().get();
+    if (stop_info)
+      stop_info->WillResume(resume_state);
+  }
 
-    current_plan->WillStop();
-}
+  // Tell all the plans that we are about to resume in case they need to clear
+  // any state.
+  // We distinguish between the plan on the top of the stack and the lower
+  // plans in case a plan needs to do any special business before it runs.
 
-void
-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.
-
-        lldb::RegisterContextSP reg_ctx_sp (GetRegisterContext());
-        if (reg_ctx_sp)
-        {
-            const addr_t thread_pc = reg_ctx_sp->GetPC();
-            BreakpointSiteSP bp_site_sp = GetProcess()->GetBreakpointSiteList().FindByAddress(thread_pc);
-            if (bp_site_sp)
-            {
-                // Note, don't assume there's a ThreadPlanStepOverBreakpoint, the target may not require anything
-                // special to step over a breakpoint.
-                    
-                ThreadPlan *cur_plan = GetCurrentPlan();
-
-                bool push_step_over_bp_plan = false;
-                if (cur_plan->GetKind() == ThreadPlan::eKindStepOverBreakpoint)
-                {
-                    ThreadPlanStepOverBreakpoint *bp_plan = (ThreadPlanStepOverBreakpoint *)cur_plan;
-                    if (bp_plan->GetBreakpointLoadAddress() != thread_pc)
-                        push_step_over_bp_plan = true;
-                }
-                else
-                    push_step_over_bp_plan = true;
-
-                if (push_step_over_bp_plan)
-                {
-                    ThreadPlanSP step_bp_plan_sp (new ThreadPlanStepOverBreakpoint (*this));
-                    if (step_bp_plan_sp)
-                    {
-                        step_bp_plan_sp->SetPrivate (true);
-
-                        if (GetCurrentPlan()->RunState() != eStateStepping)
-                        {
-                            ThreadPlanStepOverBreakpoint *step_bp_plan
-                                    = static_cast<ThreadPlanStepOverBreakpoint *>(step_bp_plan_sp.get());
-                            step_bp_plan->SetAutoContinue(true);
-                        }
-                        QueueThreadPlan (step_bp_plan_sp, false);
-                    }
-                }
-            }
-        }
+  bool need_to_resume = false;
+  ThreadPlan *plan_ptr = GetCurrentPlan();
+  if (plan_ptr) {
+    need_to_resume = plan_ptr->WillResume(resume_state, true);
+
+    while ((plan_ptr = GetPreviousPlan(plan_ptr)) != nullptr) {
+      plan_ptr->WillResume(resume_state, false);
     }
-}
 
-bool
-Thread::ShouldResume (StateType resume_state)
-{
-    // At this point clear the completed plan stack.
-    m_completed_plan_stack.clear();
-    m_discarded_plan_stack.clear();
-    m_override_should_notify = eLazyBoolCalculate;
-
-    StateType prev_resume_state = GetTemporaryResumeState();
-
-    SetTemporaryResumeState(resume_state);
-    
-    lldb::ThreadSP backing_thread_sp (GetBackingThread ());
-    if (backing_thread_sp)
-        backing_thread_sp->SetTemporaryResumeState(resume_state);
-
-    // 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
-    // we're about to resume, and we haven't yet had to fetch the stop reason, then it doesn't need to know
-    // about the fact that we are resuming...
-    const uint32_t process_stop_id = GetProcess()->GetStopID();
-    if (m_stop_info_stop_id == process_stop_id &&
-        (m_stop_info_sp && m_stop_info_sp->IsValid()))
-    {
-        StopInfo *stop_info = GetPrivateStopInfo().get();
-        if (stop_info)
-            stop_info->WillResume (resume_state);
-    }
-    
-    // Tell all the plans that we are about to resume in case they need to clear any state.
-    // We distinguish between the plan on the top of the stack and the lower
-    // plans in case a plan needs to do any special business before it runs.
-    
-    bool need_to_resume = false;
-    ThreadPlan *plan_ptr = GetCurrentPlan();
-    if (plan_ptr)
-    {
-        need_to_resume = plan_ptr->WillResume(resume_state, true);
+    // If the WillResume for the plan says we are faking a resume, then it will
+    // have set an appropriate stop info.
+    // In that case, don't reset it here.
 
-        while ((plan_ptr = GetPreviousPlan(plan_ptr)) != nullptr)
-        {
-            plan_ptr->WillResume (resume_state, false);
-        }
-        
-        // If the WillResume for the plan says we are faking a resume, then it will have set an appropriate stop info.
-        // In that case, don't reset it here.
-        
-        if (need_to_resume && resume_state != eStateSuspended)
-        {
-            m_stop_info_sp.reset();
-        }
+    if (need_to_resume && resume_state != eStateSuspended) {
+      m_stop_info_sp.reset();
     }
+  }
 
-    if (need_to_resume)
-    {
-        ClearStackFrames();
-        // Let Thread subclasses do any special work they need to prior to resuming
-        WillResume (resume_state);
-    }
+  if (need_to_resume) {
+    ClearStackFrames();
+    // Let Thread subclasses do any special work they need to prior to resuming
+    WillResume(resume_state);
+  }
 
-    return need_to_resume;
+  return need_to_resume;
 }
 
-void
-Thread::DidResume ()
-{
-    SetResumeSignal (LLDB_INVALID_SIGNAL_NUMBER);
-}
+void Thread::DidResume() { SetResumeSignal(LLDB_INVALID_SIGNAL_NUMBER); }
 
-void
-Thread::DidStop ()
-{
-    SetState (eStateStopped);
-}
+void Thread::DidStop() { SetState(eStateStopped); }
 
-bool
-Thread::ShouldStop (Event* event_ptr)
-{
-    ThreadPlan *current_plan = GetCurrentPlan();
+bool Thread::ShouldStop(Event *event_ptr) {
+  ThreadPlan *current_plan = GetCurrentPlan();
 
-    bool should_stop = true;
+  bool should_stop = true;
 
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
 
-    if (GetResumeState () == eStateSuspended)
-    {
-        if (log)
-            log->Printf ("Thread::%s for tid = 0x%4.4" PRIx64 " 0x%4.4" PRIx64 ", should_stop = 0 (ignore since thread was suspended)",
-                         __FUNCTION__, GetID (), GetProtocolID());
-        return false;
-    }
+  if (GetResumeState() == eStateSuspended) {
+    if (log)
+      log->Printf("Thread::%s for tid = 0x%4.4" PRIx64 " 0x%4.4" PRIx64
+                  ", should_stop = 0 (ignore since thread was suspended)",
+                  __FUNCTION__, GetID(), GetProtocolID());
+    return false;
+  }
 
-    if (GetTemporaryResumeState () == eStateSuspended)
-    {
-        if (log)
-            log->Printf ("Thread::%s for tid = 0x%4.4" PRIx64 " 0x%4.4" PRIx64 ", should_stop = 0 (ignore since thread was suspended)",
-                         __FUNCTION__, GetID (), GetProtocolID());
-        return false;
-    }
+  if (GetTemporaryResumeState() == eStateSuspended) {
+    if (log)
+      log->Printf("Thread::%s for tid = 0x%4.4" PRIx64 " 0x%4.4" PRIx64
+                  ", should_stop = 0 (ignore since thread was suspended)",
+                  __FUNCTION__, GetID(), GetProtocolID());
+    return false;
+  }
 
-    // Based on the current thread plan and process stop info, check if this
-    // 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())
-    {
-        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)",
-                         __FUNCTION__, GetID (), GetProtocolID(),
-                         GetRegisterContext() ? GetRegisterContext()->GetPC() : LLDB_INVALID_ADDRESS);
-        return false;
-    }
+  // Based on the current thread plan and process stop info, check if this
+  // 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()) {
+    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)",
+                  __FUNCTION__, GetID(), GetProtocolID(),
+                  GetRegisterContext() ? GetRegisterContext()->GetPC()
+                                       : LLDB_INVALID_ADDRESS);
+    return false;
+  }
 
+  if (log) {
+    log->Printf("Thread::%s(%p) for tid = 0x%4.4" PRIx64 " 0x%4.4" PRIx64
+                ", pc = 0x%16.16" PRIx64,
+                __FUNCTION__, static_cast<void *>(this), GetID(),
+                GetProtocolID(),
+                GetRegisterContext() ? GetRegisterContext()->GetPC()
+                                     : LLDB_INVALID_ADDRESS);
+    log->Printf("^^^^^^^^ Thread::ShouldStop Begin ^^^^^^^^");
+    StreamString s;
+    s.IndentMore();
+    DumpThreadPlans(&s);
+    log->Printf("Plan stack initial state:\n%s", s.GetData());
+  }
+
+  // The top most plan always gets to do the trace log...
+  current_plan->DoTraceLog();
+
+  // First query the stop info's ShouldStopSynchronous.  This handles
+  // "synchronous" stop reasons, for example the breakpoint
+  // 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)) {
     if (log)
-    {
-        log->Printf ("Thread::%s(%p) for tid = 0x%4.4" PRIx64 " 0x%4.4" PRIx64 ", pc = 0x%16.16" PRIx64,
-                     __FUNCTION__, static_cast<void*>(this), GetID (),
-                     GetProtocolID (),
-                     GetRegisterContext()
-                        ? GetRegisterContext()->GetPC()
-                        : LLDB_INVALID_ADDRESS);
-        log->Printf ("^^^^^^^^ Thread::ShouldStop Begin ^^^^^^^^");
-        StreamString s;
-        s.IndentMore();
-        DumpThreadPlans(&s);
-        log->Printf ("Plan stack initial state:\n%s", s.GetData());
-    }
-
-    // The top most plan always gets to do the trace log...
-    current_plan->DoTraceLog ();
-
-    // First query the stop info's ShouldStopSynchronous.  This handles "synchronous" stop reasons, for example the breakpoint
-    // 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))
-    {
-        if (log)
-            log->Printf ("StopInfo::ShouldStop async callback says we should not stop, returning ShouldStop of false.");
-        return false;
-    }
+      log->Printf("StopInfo::ShouldStop async callback says we should not "
+                  "stop, returning ShouldStop of false.");
+    return false;
+  }
 
-    // If we've already been restarted, don't query the plans since the state they would examine is not current.
-    if (Process::ProcessEventData::GetRestartedFromEvent(event_ptr))
-        return false;
-
-    // Before the plans see the state of the world, calculate the current inlined depth.
-    GetStackFrameList()->CalculateCurrentInlinedDepth();
-
-    // If the base plan doesn't understand why we stopped, then we have to find a plan that does.
-    // If that plan is still working, then we don't need to do any more work.  If the plan that explains 
-    // the stop is done, then we should pop all the plans below it, and pop it, and then let the plans above it decide
-    // whether they still need to do more work.
-    
-    bool done_processing_current_plan = false;
-    
-    if (!current_plan->PlanExplainsStop(event_ptr))
-    {
-        if (current_plan->TracerExplainsStop())
-        {
+  // If we've already been restarted, don't query the plans since the state they
+  // would examine is not current.
+  if (Process::ProcessEventData::GetRestartedFromEvent(event_ptr))
+    return false;
+
+  // Before the plans see the state of the world, calculate the current inlined
+  // depth.
+  GetStackFrameList()->CalculateCurrentInlinedDepth();
+
+  // If the base plan doesn't understand why we stopped, then we have to find a
+  // plan that does.
+  // If that plan is still working, then we don't need to do any more work.  If
+  // the plan that explains
+  // the stop is done, then we should pop all the plans below it, and pop it,
+  // and then let the plans above it decide
+  // whether they still need to do more work.
+
+  bool done_processing_current_plan = false;
+
+  if (!current_plan->PlanExplainsStop(event_ptr)) {
+    if (current_plan->TracerExplainsStop()) {
+      done_processing_current_plan = true;
+      should_stop = false;
+    } else {
+      // 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)) != nullptr) {
+        if (plan_ptr->PlanExplainsStop(event_ptr)) {
+          should_stop = plan_ptr->ShouldStop(event_ptr);
+
+          // plan_ptr explains the stop, next check whether plan_ptr is done, if
+          // so, then we should take it
+          // and all the plans below it off the stack.
+
+          if (plan_ptr->MischiefManaged()) {
+            // We're going to pop the plans up to and including the plan that
+            // explains the stop.
+            ThreadPlan *prev_plan_ptr = GetPreviousPlan(plan_ptr);
+
+            do {
+              if (should_stop)
+                current_plan->WillStop();
+              PopPlan();
+            } 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.
+            done_processing_current_plan =
+                (plan_ptr->IsMasterPlan() && !plan_ptr->OkayToDiscard());
+          } else
             done_processing_current_plan = true;
-            should_stop = false;
-        }
-        else
-        {
-            // 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)) != nullptr)
-            {
-                if (plan_ptr->PlanExplainsStop(event_ptr))
-                {
-                    should_stop = plan_ptr->ShouldStop (event_ptr);
-
-                    // plan_ptr explains the stop, next check whether plan_ptr is done, if so, then we should take it 
-                    // and all the plans below it off the stack.
-
-                    if (plan_ptr->MischiefManaged())
-                    {
-                        // We're going to pop the plans up to and including the plan that explains the stop.
-                        ThreadPlan *prev_plan_ptr = GetPreviousPlan (plan_ptr);
-
-                        do 
-                        {
-                            if (should_stop)
-                                current_plan->WillStop();
-                            PopPlan();
-                        }
-                        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.
-                        done_processing_current_plan = (plan_ptr->IsMasterPlan() && !plan_ptr->OkayToDiscard());
-                    }
-                    else
-                        done_processing_current_plan = true;
 
-                    break;
-                }
-            }
+          break;
         }
+      }
     }
+  }
 
-    if (!done_processing_current_plan)
-    {
-        bool over_ride_stop = current_plan->ShouldAutoContinue(event_ptr);
+  if (!done_processing_current_plan) {
+    bool over_ride_stop = current_plan->ShouldAutoContinue(event_ptr);
 
-        if (log)
-            log->Printf("Plan %s explains stop, auto-continue %i.",
-                        current_plan->GetName(), over_ride_stop);
+    if (log)
+      log->Printf("Plan %s explains stop, auto-continue %i.",
+                  current_plan->GetName(), over_ride_stop);
 
-        // We're starting from the base plan, so just let it decide;
+    // We're starting from the base plan, so just let it decide;
+    if (PlanIsBasePlan(current_plan)) {
+      should_stop = current_plan->ShouldStop(event_ptr);
+      if (log)
+        log->Printf("Base plan says should stop: %i.", should_stop);
+    } else {
+      // Otherwise, don't let the base plan override what the other plans say to
+      // do, since
+      // presumably if there were other plans they would know what to do...
+      while (1) {
         if (PlanIsBasePlan(current_plan))
-        {
-            should_stop = current_plan->ShouldStop (event_ptr);
-            if (log)
-                log->Printf("Base plan says should stop: %i.", should_stop);
-        }
-        else
-        {
-            // Otherwise, don't let the base plan override what the other plans say to do, since
-            // presumably if there were other plans they would know what to do...
-            while (1)
-            {
-                if (PlanIsBasePlan(current_plan))
-                    break;
-
-                should_stop = current_plan->ShouldStop(event_ptr);
-                if (log)
-                    log->Printf("Plan %s should stop: %d.",
-                                current_plan->GetName(), should_stop);
-                if (current_plan->MischiefManaged())
-                {
-                    if (should_stop)
-                        current_plan->WillStop();
-
-                    // If a Master Plan wants to stop, and wants to stick on the stack, we let it.
-                    // Otherwise, see if the plan's parent wants to stop.
-
-                    if (should_stop && current_plan->IsMasterPlan() && !current_plan->OkayToDiscard())
-                    {
-                        PopPlan();
-                        break;
-                    }
-                    else
-                    {
-                        PopPlan();
-
-                        current_plan = GetCurrentPlan();
-                        if (current_plan == nullptr)
-                        {
-                            break;
-                        }
-                    }
-                }
-                else
-                {
-                    break;
-                }
-            }
-        }
-
-        if (over_ride_stop)
-            should_stop = false;
-    }
+          break;
 
-    // One other potential problem is that we set up a master plan, then stop in before it is complete - for instance
-    // by hitting a breakpoint during a step-over - then do some step/finish/etc operations that wind up
-    // past the end point condition of the initial plan.  We don't want to strand the original plan on the stack,
-    // This code clears stale plans off the stack.
+        should_stop = current_plan->ShouldStop(event_ptr);
+        if (log)
+          log->Printf("Plan %s should stop: %d.", current_plan->GetName(),
+                      should_stop);
+        if (current_plan->MischiefManaged()) {
+          if (should_stop)
+            current_plan->WillStop();
+
+          // If a Master Plan wants to stop, and wants to stick on the stack, we
+          // let it.
+          // Otherwise, see if the plan's parent wants to stop.
+
+          if (should_stop && current_plan->IsMasterPlan() &&
+              !current_plan->OkayToDiscard()) {
+            PopPlan();
+            break;
+          } else {
+            PopPlan();
 
-    if (should_stop)
-    {
-        ThreadPlan *plan_ptr = GetCurrentPlan();
-        while (!PlanIsBasePlan(plan_ptr))
-        {
-            bool stale = plan_ptr->IsPlanStale ();
-            ThreadPlan *examined_plan = plan_ptr;
-            plan_ptr = GetPreviousPlan (examined_plan);
-
-            if (stale)
-            {
-                if (log)
-                    log->Printf("Plan %s being discarded in cleanup, it says it is already done.",
-                                examined_plan->GetName());
-                DiscardThreadPlansUpToPlan(examined_plan);
+            current_plan = GetCurrentPlan();
+            if (current_plan == nullptr) {
+              break;
             }
+          }
+        } else {
+          break;
         }
+      }
     }
 
-    if (log)
-    {
-        StreamString s;
-        s.IndentMore();
-        DumpThreadPlans(&s);
-        log->Printf ("Plan stack final state:\n%s", s.GetData());
-        log->Printf ("vvvvvvvv Thread::ShouldStop End (returning %i) vvvvvvvv", should_stop);
-    }
-    return should_stop;
-}
+    if (over_ride_stop)
+      should_stop = false;
+  }
 
-Vote
-Thread::ShouldReportStop (Event* event_ptr)
-{
-    StateType thread_state = GetResumeState ();
-    StateType temp_thread_state = GetTemporaryResumeState();
-    
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
+  // One other potential problem is that we set up a master plan, then stop in
+  // before it is complete - for instance
+  // by hitting a breakpoint during a step-over - then do some step/finish/etc
+  // operations that wind up
+  // past the end point condition of the initial plan.  We don't want to strand
+  // the original plan on the stack,
+  // This code clears stale plans off the stack.
 
-    if (thread_state == eStateSuspended || thread_state == eStateInvalid)
-    {
-        if (log)
-            log->Printf ("Thread::ShouldReportStop() tid = 0x%4.4" PRIx64 ": returning vote %i (state was suspended or invalid)", GetID(), eVoteNoOpinion);
-        return eVoteNoOpinion;
-    }
+  if (should_stop) {
+    ThreadPlan *plan_ptr = GetCurrentPlan();
+    while (!PlanIsBasePlan(plan_ptr)) {
+      bool stale = plan_ptr->IsPlanStale();
+      ThreadPlan *examined_plan = plan_ptr;
+      plan_ptr = GetPreviousPlan(examined_plan);
 
-    if (temp_thread_state == eStateSuspended || temp_thread_state == eStateInvalid)
-    {
+      if (stale) {
         if (log)
-            log->Printf ("Thread::ShouldReportStop() tid = 0x%4.4" PRIx64 ": returning vote %i (temporary state was suspended or invalid)", GetID(), eVoteNoOpinion);
-        return eVoteNoOpinion;
-    }
+          log->Printf(
+              "Plan %s being discarded in cleanup, it says it is already done.",
+              examined_plan->GetName());
+        DiscardThreadPlansUpToPlan(examined_plan);
+      }
+    }
+  }
+
+  if (log) {
+    StreamString s;
+    s.IndentMore();
+    DumpThreadPlans(&s);
+    log->Printf("Plan stack final state:\n%s", s.GetData());
+    log->Printf("vvvvvvvv Thread::ShouldStop End (returning %i) vvvvvvvv",
+                should_stop);
+  }
+  return should_stop;
+}
+
+Vote Thread::ShouldReportStop(Event *event_ptr) {
+  StateType thread_state = GetResumeState();
+  StateType temp_thread_state = GetTemporaryResumeState();
 
-    if (!ThreadStoppedForAReason())
-    {
-        if (log)
-            log->Printf ("Thread::ShouldReportStop() tid = 0x%4.4" PRIx64 ": returning vote %i (thread didn't stop for a reason.)", GetID(), eVoteNoOpinion);
-        return eVoteNoOpinion;
-    }
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
 
-    if (m_completed_plan_stack.size() > 0)
-    {
-        // Don't use GetCompletedPlan here, since that suppresses private plans.
-        if (log)
-            log->Printf ("Thread::ShouldReportStop() tid = 0x%4.4" PRIx64 ": returning vote  for complete stack's back plan", GetID());
-        return m_completed_plan_stack.back()->ShouldReportStop (event_ptr);
-    }
-    else
-    {
-        Vote thread_vote = eVoteNoOpinion;
-        ThreadPlan *plan_ptr = GetCurrentPlan();
-        while (1)
-        {
-            if (plan_ptr->PlanExplainsStop(event_ptr))
-            {
-                thread_vote = plan_ptr->ShouldReportStop(event_ptr);
-                break;
-            }
-            if (PlanIsBasePlan(plan_ptr))
-                break;
-            else
-                plan_ptr = GetPreviousPlan(plan_ptr);
-        }
-        if (log)
-            log->Printf ("Thread::ShouldReportStop() tid = 0x%4.4" PRIx64 ": returning vote %i for current plan", GetID(), thread_vote);
+  if (thread_state == eStateSuspended || thread_state == eStateInvalid) {
+    if (log)
+      log->Printf("Thread::ShouldReportStop() tid = 0x%4.4" PRIx64
+                  ": returning vote %i (state was suspended or invalid)",
+                  GetID(), eVoteNoOpinion);
+    return eVoteNoOpinion;
+  }
+
+  if (temp_thread_state == eStateSuspended ||
+      temp_thread_state == eStateInvalid) {
+    if (log)
+      log->Printf(
+          "Thread::ShouldReportStop() tid = 0x%4.4" PRIx64
+          ": returning vote %i (temporary state was suspended or invalid)",
+          GetID(), eVoteNoOpinion);
+    return eVoteNoOpinion;
+  }
+
+  if (!ThreadStoppedForAReason()) {
+    if (log)
+      log->Printf("Thread::ShouldReportStop() tid = 0x%4.4" PRIx64
+                  ": returning vote %i (thread didn't stop for a reason.)",
+                  GetID(), eVoteNoOpinion);
+    return eVoteNoOpinion;
+  }
 
-        return thread_vote;
+  if (m_completed_plan_stack.size() > 0) {
+    // Don't use GetCompletedPlan here, since that suppresses private plans.
+    if (log)
+      log->Printf("Thread::ShouldReportStop() tid = 0x%4.4" PRIx64
+                  ": returning vote  for complete stack's back plan",
+                  GetID());
+    return m_completed_plan_stack.back()->ShouldReportStop(event_ptr);
+  } else {
+    Vote thread_vote = eVoteNoOpinion;
+    ThreadPlan *plan_ptr = GetCurrentPlan();
+    while (1) {
+      if (plan_ptr->PlanExplainsStop(event_ptr)) {
+        thread_vote = plan_ptr->ShouldReportStop(event_ptr);
+        break;
+      }
+      if (PlanIsBasePlan(plan_ptr))
+        break;
+      else
+        plan_ptr = GetPreviousPlan(plan_ptr);
     }
+    if (log)
+      log->Printf("Thread::ShouldReportStop() tid = 0x%4.4" PRIx64
+                  ": returning vote %i for current plan",
+                  GetID(), thread_vote);
+
+    return thread_vote;
+  }
 }
 
-Vote
-Thread::ShouldReportRun (Event* event_ptr)
-{
-    StateType thread_state = GetResumeState ();
+Vote Thread::ShouldReportRun(Event *event_ptr) {
+  StateType thread_state = GetResumeState();
 
-    if (thread_state == eStateSuspended
-            || thread_state == eStateInvalid)
-    {
-        return eVoteNoOpinion;
-    }
+  if (thread_state == eStateSuspended || thread_state == eStateInvalid) {
+    return eVoteNoOpinion;
+  }
 
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
-    if (m_completed_plan_stack.size() > 0)
-    {
-        // Don't use GetCompletedPlan here, since that suppresses private plans.
-        if (log)
-            log->Printf ("Current Plan for thread %d(%p) (0x%4.4" PRIx64 ", %s): %s being asked whether we should report run.",
-                         GetIndexID(), static_cast<void*>(this), GetID(),
-                         StateAsCString(GetTemporaryResumeState()),
-                         m_completed_plan_stack.back()->GetName());
-
-        return m_completed_plan_stack.back()->ShouldReportRun (event_ptr);
-    }
-    else
-    {
-        if (log)
-            log->Printf ("Current Plan for thread %d(%p) (0x%4.4" PRIx64 ", %s): %s being asked whether we should report run.",
-                         GetIndexID(), static_cast<void*>(this), GetID(),
-                         StateAsCString(GetTemporaryResumeState()),
-                         GetCurrentPlan()->GetName());
-
-        return GetCurrentPlan()->ShouldReportRun (event_ptr);
-     }
-}
-
-bool
-Thread::MatchesSpec (const ThreadSpec *spec)
-{
-    return (spec == nullptr) ? true : spec->ThreadPassesBasicTests(*this);
-}
-
-void
-Thread::PushPlan (ThreadPlanSP &thread_plan_sp)
-{
-    if (thread_plan_sp)
-    {
-        // If the thread plan doesn't already have a tracer, give it its parent's tracer:
-        if (!thread_plan_sp->GetThreadPlanTracer())
-            thread_plan_sp->SetThreadPlanTracer(m_plan_stack.back()->GetThreadPlanTracer());
-        m_plan_stack.push_back (thread_plan_sp);
-
-        thread_plan_sp->DidPush();
-
-        Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
-        if (log)
-        {
-            StreamString s;
-            thread_plan_sp->GetDescription (&s, lldb::eDescriptionLevelFull);
-            log->Printf("Thread::PushPlan(0x%p): \"%s\", tid = 0x%4.4" PRIx64 ".",
-                        static_cast<void*>(this), s.GetData(),
-                        thread_plan_sp->GetThread().GetID());
-        }
-    }
-}
-
-void
-Thread::PopPlan ()
-{
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
-
-    if (m_plan_stack.size() <= 1)
-        return;
-    else
-    {
-        ThreadPlanSP &plan = m_plan_stack.back();
-        if (log)
-        {
-            log->Printf("Popping plan: \"%s\", tid = 0x%4.4" PRIx64 ".", plan->GetName(), plan->GetThread().GetID());
-        }
-        m_completed_plan_stack.push_back (plan);
-        plan->WillPop();
-        m_plan_stack.pop_back();
-    }
-}
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
+  if (m_completed_plan_stack.size() > 0) {
+    // Don't use GetCompletedPlan here, since that suppresses private plans.
+    if (log)
+      log->Printf("Current Plan for thread %d(%p) (0x%4.4" PRIx64
+                  ", %s): %s being asked whether we should report run.",
+                  GetIndexID(), static_cast<void *>(this), GetID(),
+                  StateAsCString(GetTemporaryResumeState()),
+                  m_completed_plan_stack.back()->GetName());
 
-void
-Thread::DiscardPlan ()
-{
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
-    if (m_plan_stack.size() > 1)
-    {
-        ThreadPlanSP &plan = m_plan_stack.back();
-        if (log)
-            log->Printf("Discarding plan: \"%s\", tid = 0x%4.4" PRIx64 ".", plan->GetName(), plan->GetThread().GetID());
+    return m_completed_plan_stack.back()->ShouldReportRun(event_ptr);
+  } else {
+    if (log)
+      log->Printf("Current Plan for thread %d(%p) (0x%4.4" PRIx64
+                  ", %s): %s being asked whether we should report run.",
+                  GetIndexID(), static_cast<void *>(this), GetID(),
+                  StateAsCString(GetTemporaryResumeState()),
+                  GetCurrentPlan()->GetName());
+
+    return GetCurrentPlan()->ShouldReportRun(event_ptr);
+  }
+}
+
+bool Thread::MatchesSpec(const ThreadSpec *spec) {
+  return (spec == nullptr) ? true : spec->ThreadPassesBasicTests(*this);
+}
+
+void Thread::PushPlan(ThreadPlanSP &thread_plan_sp) {
+  if (thread_plan_sp) {
+    // If the thread plan doesn't already have a tracer, give it its parent's
+    // tracer:
+    if (!thread_plan_sp->GetThreadPlanTracer())
+      thread_plan_sp->SetThreadPlanTracer(
+          m_plan_stack.back()->GetThreadPlanTracer());
+    m_plan_stack.push_back(thread_plan_sp);
+
+    thread_plan_sp->DidPush();
+
+    Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
+    if (log) {
+      StreamString s;
+      thread_plan_sp->GetDescription(&s, lldb::eDescriptionLevelFull);
+      log->Printf("Thread::PushPlan(0x%p): \"%s\", tid = 0x%4.4" PRIx64 ".",
+                  static_cast<void *>(this), s.GetData(),
+                  thread_plan_sp->GetThread().GetID());
+    }
+  }
+}
+
+void Thread::PopPlan() {
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
+
+  if (m_plan_stack.size() <= 1)
+    return;
+  else {
+    ThreadPlanSP &plan = m_plan_stack.back();
+    if (log) {
+      log->Printf("Popping plan: \"%s\", tid = 0x%4.4" PRIx64 ".",
+                  plan->GetName(), plan->GetThread().GetID());
+    }
+    m_completed_plan_stack.push_back(plan);
+    plan->WillPop();
+    m_plan_stack.pop_back();
+  }
+}
+
+void Thread::DiscardPlan() {
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
+  if (m_plan_stack.size() > 1) {
+    ThreadPlanSP &plan = m_plan_stack.back();
+    if (log)
+      log->Printf("Discarding plan: \"%s\", tid = 0x%4.4" PRIx64 ".",
+                  plan->GetName(), plan->GetThread().GetID());
 
-        m_discarded_plan_stack.push_back (plan);
-        plan->WillPop();
-        m_plan_stack.pop_back();
+    m_discarded_plan_stack.push_back(plan);
+    plan->WillPop();
+    m_plan_stack.pop_back();
+  }
+}
+
+ThreadPlan *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.
+  return m_plan_stack.empty() ? nullptr : m_plan_stack.back().get();
+}
+
+ThreadPlanSP Thread::GetCompletedPlan() {
+  ThreadPlanSP empty_plan_sp;
+  if (!m_completed_plan_stack.empty()) {
+    for (int i = m_completed_plan_stack.size() - 1; i >= 0; i--) {
+      ThreadPlanSP completed_plan_sp;
+      completed_plan_sp = m_completed_plan_stack[i];
+      if (!completed_plan_sp->GetPrivate())
+        return completed_plan_sp;
+    }
+  }
+  return empty_plan_sp;
+}
+
+ValueObjectSP Thread::GetReturnValueObject() {
+  if (!m_completed_plan_stack.empty()) {
+    for (int i = m_completed_plan_stack.size() - 1; i >= 0; i--) {
+      ValueObjectSP return_valobj_sp;
+      return_valobj_sp = m_completed_plan_stack[i]->GetReturnValueObject();
+      if (return_valobj_sp)
+        return return_valobj_sp;
+    }
+  }
+  return ValueObjectSP();
+}
+
+ExpressionVariableSP Thread::GetExpressionVariable() {
+  if (!m_completed_plan_stack.empty()) {
+    for (int i = m_completed_plan_stack.size() - 1; i >= 0; i--) {
+      ExpressionVariableSP expression_variable_sp;
+      expression_variable_sp =
+          m_completed_plan_stack[i]->GetExpressionVariable();
+      if (expression_variable_sp)
+        return expression_variable_sp;
+    }
+  }
+  return ExpressionVariableSP();
+}
+
+bool Thread::IsThreadPlanDone(ThreadPlan *plan) {
+  if (!m_completed_plan_stack.empty()) {
+    for (int i = m_completed_plan_stack.size() - 1; i >= 0; i--) {
+      if (m_completed_plan_stack[i].get() == plan)
+        return true;
     }
+  }
+  return false;
 }
 
-ThreadPlan *
-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.
-    return m_plan_stack.empty() ? nullptr : m_plan_stack.back().get();
-}
-
-ThreadPlanSP
-Thread::GetCompletedPlan ()
-{
-    ThreadPlanSP empty_plan_sp;
-    if (!m_completed_plan_stack.empty())
-    {
-        for (int i = m_completed_plan_stack.size() - 1; i >= 0; i--)
-        {
-            ThreadPlanSP completed_plan_sp;
-            completed_plan_sp = m_completed_plan_stack[i];
-            if (!completed_plan_sp->GetPrivate ())
-            return completed_plan_sp;
-        }
+bool Thread::WasThreadPlanDiscarded(ThreadPlan *plan) {
+  if (!m_discarded_plan_stack.empty()) {
+    for (int i = m_discarded_plan_stack.size() - 1; i >= 0; i--) {
+      if (m_discarded_plan_stack[i].get() == plan)
+        return true;
     }
-    return empty_plan_sp;
+  }
+  return false;
 }
 
-ValueObjectSP
-Thread::GetReturnValueObject ()
-{
-    if (!m_completed_plan_stack.empty())
-    {
-        for (int i = m_completed_plan_stack.size() - 1; i >= 0; i--)
-        {
-            ValueObjectSP return_valobj_sp;
-            return_valobj_sp = m_completed_plan_stack[i]->GetReturnValueObject();
-            if (return_valobj_sp)
-                return return_valobj_sp;
-        }
-    }
-    return ValueObjectSP();
-}
+ThreadPlan *Thread::GetPreviousPlan(ThreadPlan *current_plan) {
+  if (current_plan == nullptr)
+    return nullptr;
 
-ExpressionVariableSP
-Thread::GetExpressionVariable ()
-{
-    if (!m_completed_plan_stack.empty())
-    {
-        for (int i = m_completed_plan_stack.size() - 1; i >= 0; i--)
-        {
-            ExpressionVariableSP expression_variable_sp;
-            expression_variable_sp = m_completed_plan_stack[i]->GetExpressionVariable();
-            if (expression_variable_sp)
-                return expression_variable_sp;
-        }
-    }
-    return ExpressionVariableSP();
-}
+  int stack_size = m_completed_plan_stack.size();
+  for (int i = stack_size - 1; i > 0; i--) {
+    if (current_plan == m_completed_plan_stack[i].get())
+      return m_completed_plan_stack[i - 1].get();
+  }
+
+  if (stack_size > 0 && m_completed_plan_stack[0].get() == current_plan) {
+    return GetCurrentPlan();
+  }
+
+  stack_size = m_plan_stack.size();
+  for (int i = stack_size - 1; i > 0; i--) {
+    if (current_plan == m_plan_stack[i].get())
+      return m_plan_stack[i - 1].get();
+  }
+  return nullptr;
+}
+
+void Thread::QueueThreadPlan(ThreadPlanSP &thread_plan_sp,
+                             bool abort_other_plans) {
+  if (abort_other_plans)
+    DiscardThreadPlans(true);
+
+  PushPlan(thread_plan_sp);
+}
+
+void Thread::EnableTracer(bool value, bool single_stepping) {
+  int stack_size = m_plan_stack.size();
+  for (int i = 0; i < stack_size; i++) {
+    if (m_plan_stack[i]->GetThreadPlanTracer()) {
+      m_plan_stack[i]->GetThreadPlanTracer()->EnableTracing(value);
+      m_plan_stack[i]->GetThreadPlanTracer()->EnableSingleStep(single_stepping);
+    }
+  }
+}
+
+void Thread::SetTracer(lldb::ThreadPlanTracerSP &tracer_sp) {
+  int stack_size = m_plan_stack.size();
+  for (int i = 0; i < stack_size; i++)
+    m_plan_stack[i]->SetThreadPlanTracer(tracer_sp);
+}
+
+bool Thread::DiscardUserThreadPlansUpToIndex(uint32_t thread_index) {
+  // Count the user thread plans from the back end to get the number of the one
+  // we want
+  // to discard:
+
+  uint32_t idx = 0;
+  ThreadPlan *up_to_plan_ptr = nullptr;
+
+  for (ThreadPlanSP plan_sp : m_plan_stack) {
+    if (plan_sp->GetPrivate())
+      continue;
+    if (idx == thread_index) {
+      up_to_plan_ptr = plan_sp.get();
+      break;
+    } else
+      idx++;
+  }
 
-bool
-Thread::IsThreadPlanDone (ThreadPlan *plan)
-{
-    if (!m_completed_plan_stack.empty())
-    {
-        for (int i = m_completed_plan_stack.size() - 1; i >= 0; i--)
-        {
-            if (m_completed_plan_stack[i].get() == plan)
-                return true;
-        }
-    }
+  if (up_to_plan_ptr == nullptr)
     return false;
+
+  DiscardThreadPlansUpToPlan(up_to_plan_ptr);
+  return true;
 }
 
-bool
-Thread::WasThreadPlanDiscarded (ThreadPlan *plan)
-{
-    if (!m_discarded_plan_stack.empty())
-    {
-        for (int i = m_discarded_plan_stack.size() - 1; i >= 0; i--)
-        {
-            if (m_discarded_plan_stack[i].get() == plan)
-                return true;
-        }
-    }
-    return false;
+void Thread::DiscardThreadPlansUpToPlan(lldb::ThreadPlanSP &up_to_plan_sp) {
+  DiscardThreadPlansUpToPlan(up_to_plan_sp.get());
 }
 
-ThreadPlan *
-Thread::GetPreviousPlan (ThreadPlan *current_plan)
-{
-    if (current_plan == nullptr)
-        return nullptr;
+void Thread::DiscardThreadPlansUpToPlan(ThreadPlan *up_to_plan_ptr) {
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
+  if (log)
+    log->Printf("Discarding thread plans for thread tid = 0x%4.4" PRIx64
+                ", up to %p",
+                GetID(), static_cast<void *>(up_to_plan_ptr));
 
-    int stack_size = m_completed_plan_stack.size();
-    for (int i = stack_size - 1; i > 0; i--)
-    {
-        if (current_plan == m_completed_plan_stack[i].get())
-            return m_completed_plan_stack[i-1].get();
-    }
+  int stack_size = m_plan_stack.size();
 
-    if (stack_size > 0 && m_completed_plan_stack[0].get() == current_plan)
-    {
-        return GetCurrentPlan();
-    }
+  // 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.
 
-    stack_size = m_plan_stack.size();
+  if (up_to_plan_ptr == nullptr) {
     for (int i = stack_size - 1; i > 0; i--)
-    {
-        if (current_plan == m_plan_stack[i].get())
-            return m_plan_stack[i-1].get();
-    }
-    return nullptr;
-}
-
-void
-Thread::QueueThreadPlan (ThreadPlanSP &thread_plan_sp, bool abort_other_plans)
-{
-    if (abort_other_plans)
-       DiscardThreadPlans(true);
-
-    PushPlan (thread_plan_sp);
-}
+      DiscardPlan();
+  } else {
+    bool found_it = false;
+    for (int i = stack_size - 1; i > 0; i--) {
+      if (m_plan_stack[i].get() == up_to_plan_ptr)
+        found_it = true;
+    }
+    if (found_it) {
+      bool last_one = false;
+      for (int i = stack_size - 1; i > 0 && !last_one; i--) {
+        if (GetCurrentPlan() == up_to_plan_ptr)
+          last_one = true;
+        DiscardPlan();
+      }
+    }
+  }
+}
+
+void Thread::DiscardThreadPlans(bool force) {
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
+  if (log) {
+    log->Printf("Discarding thread plans for thread (tid = 0x%4.4" PRIx64
+                ", force %d)",
+                GetID(), force);
+  }
 
-void
-Thread::EnableTracer (bool value, bool single_stepping)
-{
+  if (force) {
     int stack_size = m_plan_stack.size();
-    for (int i = 0; i < stack_size; i++)
-    {
-        if (m_plan_stack[i]->GetThreadPlanTracer())
-        {
-            m_plan_stack[i]->GetThreadPlanTracer()->EnableTracing(value);
-            m_plan_stack[i]->GetThreadPlanTracer()->EnableSingleStep(single_stepping);
-        }
+    for (int i = stack_size - 1; i > 0; i--) {
+      DiscardPlan();
     }
-}
-
-void
-Thread::SetTracer (lldb::ThreadPlanTracerSP &tracer_sp)
-{
-    int stack_size = m_plan_stack.size();
-    for (int i = 0; i < stack_size; i++)
-        m_plan_stack[i]->SetThreadPlanTracer(tracer_sp);
-}
-
-bool
-Thread::DiscardUserThreadPlansUpToIndex (uint32_t thread_index)
-{
-    // Count the user thread plans from the back end to get the number of the one we want
-    // to discard:
-
-    uint32_t idx = 0;
-    ThreadPlan *up_to_plan_ptr = nullptr;
+    return;
+  }
 
-    for (ThreadPlanSP plan_sp : m_plan_stack)
-    {
-        if (plan_sp->GetPrivate())
-            continue;
-        if (idx == thread_index)
-        {
-            up_to_plan_ptr = plan_sp.get();
-            break;
-        }
-        else
-            idx++;
+  while (1) {
+    int master_plan_idx;
+    bool discard = true;
+
+    // Find the first master plan, see if it wants discarding, and if yes
+    // discard up to it.
+    for (master_plan_idx = m_plan_stack.size() - 1; master_plan_idx >= 0;
+         master_plan_idx--) {
+      if (m_plan_stack[master_plan_idx]->IsMasterPlan()) {
+        discard = m_plan_stack[master_plan_idx]->OkayToDiscard();
+        break;
+      }
+    }
+
+    if (discard) {
+      // 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?
+        DiscardPlan();
+      }
+
+      // Now discard the master plan itself.
+      // The bottom-most plan never gets discarded.  "OkayToDiscard" for it
+      // means
+      // discard it's dependent plans, but not it...
+      if (master_plan_idx > 0) {
+        DiscardPlan();
+      }
+    } else {
+      // If the master plan doesn't want to get discarded, then we're done.
+      break;
     }
-
-    if (up_to_plan_ptr == nullptr)
-        return false;
-
-    DiscardThreadPlansUpToPlan(up_to_plan_ptr);
-    return true;
+  }
 }
 
-void
-Thread::DiscardThreadPlansUpToPlan (lldb::ThreadPlanSP &up_to_plan_sp)
-{
-    DiscardThreadPlansUpToPlan (up_to_plan_sp.get());
+bool Thread::PlanIsBasePlan(ThreadPlan *plan_ptr) {
+  if (plan_ptr->IsBasePlan())
+    return true;
+  else if (m_plan_stack.size() == 0)
+    return false;
+  else
+    return m_plan_stack[0].get() == plan_ptr;
 }
 
-void
-Thread::DiscardThreadPlansUpToPlan (ThreadPlan *up_to_plan_ptr)
-{
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
-    if (log)
-        log->Printf("Discarding thread plans for thread tid = 0x%4.4" PRIx64 ", up to %p",
-                    GetID(), static_cast<void*>(up_to_plan_ptr));
-
-    int stack_size = m_plan_stack.size();
+Error Thread::UnwindInnermostExpression() {
+  Error error;
+  int stack_size = m_plan_stack.size();
 
-    // 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 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 == nullptr)
-    {
-        for (int i = stack_size - 1; i > 0; i--)
-            DiscardPlan();
-    }
-    else
-    {
-        bool found_it = false;
-        for (int i = stack_size - 1; i > 0; i--)
-        {
-            if (m_plan_stack[i].get() == up_to_plan_ptr)
-                found_it = true;
-        }
-        if (found_it)
-        {
-            bool last_one = false;
-            for (int i = stack_size - 1; i > 0 && !last_one ; i--)
-            {
-                if (GetCurrentPlan() == up_to_plan_ptr)
-                    last_one = true;
-                DiscardPlan();
-            }
-        }
+  for (int i = stack_size - 1; i > 0; i--) {
+    if (m_plan_stack[i]->GetKind() == ThreadPlan::eKindCallFunction) {
+      DiscardThreadPlansUpToPlan(m_plan_stack[i].get());
+      return error;
     }
+  }
+  error.SetErrorString("No expressions currently active on this thread");
+  return error;
 }
 
-void
-Thread::DiscardThreadPlans(bool force)
-{
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
-    if (log)
-    {
-        log->Printf("Discarding thread plans for thread (tid = 0x%4.4" PRIx64 ", force %d)", GetID(), force);
-    }
-
-    if (force)
-    {
-        int stack_size = m_plan_stack.size();
-        for (int i = stack_size - 1; i > 0; i--)
-        {
-            DiscardPlan();
-        }
-        return;
-    }
-
-    while (1)
-    {
-        int master_plan_idx;
-        bool discard = true;
-
-        // Find the first master plan, see if it wants discarding, and if yes discard up to it.
-        for (master_plan_idx = m_plan_stack.size() - 1; master_plan_idx >= 0; master_plan_idx--)
-        {
-            if (m_plan_stack[master_plan_idx]->IsMasterPlan())
-            {
-                discard = m_plan_stack[master_plan_idx]->OkayToDiscard();
-                break;
-            }
-        }
-
-        if (discard)
-        {
-            // 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?
-                DiscardPlan();
-            }
-
-            // Now discard the master plan itself.
-            // The bottom-most plan never gets discarded.  "OkayToDiscard" for it means
-            // discard it's dependent plans, but not it...
-            if (master_plan_idx > 0)
-            {
-                DiscardPlan();
-            }
-        }
-        else
-        {
-            // If the master plan doesn't want to get discarded, then we're done.
-            break;
-        }
-    }
+ThreadPlanSP Thread::QueueFundamentalPlan(bool abort_other_plans) {
+  ThreadPlanSP thread_plan_sp(new ThreadPlanBase(*this));
+  QueueThreadPlan(thread_plan_sp, abort_other_plans);
+  return thread_plan_sp;
 }
 
-bool
-Thread::PlanIsBasePlan (ThreadPlan *plan_ptr)
-{
-    if (plan_ptr->IsBasePlan())
-        return true;
-    else if (m_plan_stack.size() == 0)
-        return false;
-    else
-       return m_plan_stack[0].get() == plan_ptr;
+ThreadPlanSP 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);
+  return thread_plan_sp;
 }
 
-Error
-Thread::UnwindInnermostExpression()
-{
-    Error error;
-    int stack_size = m_plan_stack.size();
-    
-    // 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--)
-    {
-        if (m_plan_stack[i]->GetKind() == ThreadPlan::eKindCallFunction)
-        {
-            DiscardThreadPlansUpToPlan(m_plan_stack[i].get());
-            return error;
-        }
-    }
-    error.SetErrorString("No expressions currently active on this thread");
-    return error;
-}
+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) {
+  ThreadPlanSP thread_plan_sp;
+  thread_plan_sp.reset(new ThreadPlanStepOverRange(
+      *this, range, addr_context, stop_other_threads,
+      step_out_avoids_code_withoug_debug_info));
 
-ThreadPlanSP
-Thread::QueueFundamentalPlan (bool abort_other_plans)
-{
-    ThreadPlanSP thread_plan_sp (new ThreadPlanBase(*this));
-    QueueThreadPlan (thread_plan_sp, abort_other_plans);
-    return thread_plan_sp;
-}
-
-ThreadPlanSP
-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);
-    return thread_plan_sp;
-}
-
-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)
-{
-    ThreadPlanSP thread_plan_sp;
-    thread_plan_sp.reset (new ThreadPlanStepOverRange (*this, range, addr_context, stop_other_threads, step_out_avoids_code_withoug_debug_info));
-    
-    QueueThreadPlan (thread_plan_sp, abort_other_plans);
-    return thread_plan_sp;
+  QueueThreadPlan(thread_plan_sp, abort_other_plans);
+  return thread_plan_sp;
 }
 
 // Call the QueueThreadPlanForStepOverRange method which takes an address range.
-ThreadPlanSP
-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::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, addr_context, stop_other_threads,
+                                step_in_avoids_code_without_debug_info,
+                                step_out_avoids_code_without_debug_info));
+  ThreadPlanStepInRange *plan =
+      static_cast<ThreadPlanStepInRange *>(thread_plan_sp.get());
 
-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,
-                                                             addr_context,
-                                                             stop_other_threads,
-                                                             step_in_avoids_code_without_debug_info,
-                                                             step_out_avoids_code_without_debug_info));
-    ThreadPlanStepInRange *plan = static_cast<ThreadPlanStepInRange *>(thread_plan_sp.get());
-    
-    if (step_in_target)
-        plan->SetStepInTarget(step_in_target);
+  if (step_in_target)
+    plan->SetStepInTarget(step_in_target);
 
-    QueueThreadPlan (thread_plan_sp, abort_other_plans);
-    return thread_plan_sp;
+  QueueThreadPlan(thread_plan_sp, abort_other_plans);
+  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_without_debug_info)
-{
-    ThreadPlanSP thread_plan_sp (new ThreadPlanStepOut (*this, 
-                                                        addr_context, 
-                                                        first_insn, 
-                                                        stop_other_threads, 
-                                                        stop_vote, 
-                                                        run_vote, 
-                                                        frame_idx,
-                                                        step_out_avoids_code_without_debug_info));
-    
-    if (thread_plan_sp->ValidatePlan(nullptr))
-    {
-        QueueThreadPlan (thread_plan_sp, abort_other_plans);
-        return thread_plan_sp;
-    }
-    else
-    {
-        return ThreadPlanSP();
-    }
-}
-
-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,
-                                              bool continue_to_next_branch)
-{
-    const bool calculate_return_value = false; // No need to calculate the return value here.
-    ThreadPlanSP thread_plan_sp(new ThreadPlanStepOut (*this,
-                                                        addr_context, 
-                                                        first_insn, 
-                                                        stop_other_threads, 
-                                                        stop_vote, 
-                                                        run_vote, 
-                                                        frame_idx,
-                                                        eLazyBoolNo,
-                                                        continue_to_next_branch,
-                                                        calculate_return_value));
+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_without_debug_info) {
+  ThreadPlanSP thread_plan_sp(new ThreadPlanStepOut(
+      *this, addr_context, first_insn, stop_other_threads, stop_vote, run_vote,
+      frame_idx, step_out_avoids_code_without_debug_info));
 
-    ThreadPlanStepOut *new_plan = static_cast<ThreadPlanStepOut *>(thread_plan_sp.get());
-    new_plan->ClearShouldStopHereCallbacks();
-
-    if (thread_plan_sp->ValidatePlan(nullptr))
-    {
-        QueueThreadPlan (thread_plan_sp, abort_other_plans);
-        return thread_plan_sp;
-    }
-    else
-    {
-        return ThreadPlanSP();
-    }
-}
-
-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(nullptr))
-        return ThreadPlanSP();
-
-    QueueThreadPlan (thread_plan_sp, abort_other_plans);
+  if (thread_plan_sp->ValidatePlan(nullptr)) {
+    QueueThreadPlan(thread_plan_sp, abort_other_plans);
     return thread_plan_sp;
-}
+  } else {
+    return ThreadPlanSP();
+  }
+}
+
+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,
+    bool continue_to_next_branch) {
+  const bool calculate_return_value =
+      false; // No need to calculate the return value here.
+  ThreadPlanSP thread_plan_sp(new ThreadPlanStepOut(
+      *this, addr_context, first_insn, stop_other_threads, stop_vote, run_vote,
+      frame_idx, eLazyBoolNo, continue_to_next_branch, calculate_return_value));
+
+  ThreadPlanStepOut *new_plan =
+      static_cast<ThreadPlanStepOut *>(thread_plan_sp.get());
+  new_plan->ClearShouldStopHereCallbacks();
 
-ThreadPlanSP
-Thread::QueueThreadPlanForRunToAddress (bool abort_other_plans,
-                                        Address &target_addr,
-                                        bool stop_other_threads)
-{
-    ThreadPlanSP thread_plan_sp (new ThreadPlanRunToAddress (*this, target_addr, stop_other_threads));
-    QueueThreadPlan (thread_plan_sp, abort_other_plans);
+  if (thread_plan_sp->ValidatePlan(nullptr)) {
+    QueueThreadPlan(thread_plan_sp, abort_other_plans);
     return thread_plan_sp;
-}
-
-ThreadPlanSP
-Thread::QueueThreadPlanForStepUntil (bool abort_other_plans,
-                                     lldb::addr_t *address_list,
-                                     size_t num_addresses,
-                                     bool stop_other_threads,
-                                     uint32_t frame_idx)
-{
-    ThreadPlanSP thread_plan_sp (new ThreadPlanStepUntil (*this, address_list, num_addresses, stop_other_threads, frame_idx));
-    QueueThreadPlan (thread_plan_sp, abort_other_plans);
+  } else {
+    return ThreadPlanSP();
+  }
+}
+
+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(nullptr))
+    return ThreadPlanSP();
+
+  QueueThreadPlan(thread_plan_sp, abort_other_plans);
+  return thread_plan_sp;
+}
+
+ThreadPlanSP Thread::QueueThreadPlanForRunToAddress(bool abort_other_plans,
+                                                    Address &target_addr,
+                                                    bool stop_other_threads) {
+  ThreadPlanSP thread_plan_sp(
+      new ThreadPlanRunToAddress(*this, target_addr, stop_other_threads));
+  QueueThreadPlan(thread_plan_sp, abort_other_plans);
+  return thread_plan_sp;
+}
+
+ThreadPlanSP Thread::QueueThreadPlanForStepUntil(bool abort_other_plans,
+                                                 lldb::addr_t *address_list,
+                                                 size_t num_addresses,
+                                                 bool stop_other_threads,
+                                                 uint32_t frame_idx) {
+  ThreadPlanSP thread_plan_sp(new ThreadPlanStepUntil(
+      *this, address_list, num_addresses, stop_other_threads, frame_idx));
+  QueueThreadPlan(thread_plan_sp, abort_other_plans);
+  return thread_plan_sp;
+}
+
+lldb::ThreadPlanSP Thread::QueueThreadPlanForStepScripted(
+    bool abort_other_plans, const char *class_name, bool stop_other_threads) {
+  ThreadPlanSP thread_plan_sp(new ThreadPlanPython(*this, class_name));
+  QueueThreadPlan(thread_plan_sp, abort_other_plans);
+  // This seems a little funny, but I don't want to have to split up the
+  // constructor and the
+  // DidPush in the scripted plan, that seems annoying.
+  // That means the constructor has to be in DidPush.
+  // So I have to validate the plan AFTER pushing it, and then take it off
+  // again...
+  if (!thread_plan_sp->ValidatePlan(nullptr)) {
+    DiscardThreadPlansUpToPlan(thread_plan_sp);
+    return ThreadPlanSP();
+  } else
     return thread_plan_sp;
-
-}
-
-lldb::ThreadPlanSP
-Thread::QueueThreadPlanForStepScripted (bool abort_other_plans,
-                                        const char *class_name,
-                                        bool stop_other_threads)
-{
-    ThreadPlanSP thread_plan_sp (new ThreadPlanPython (*this, class_name));
-    QueueThreadPlan (thread_plan_sp, abort_other_plans);
-    // This seems a little funny, but I don't want to have to split up the constructor and the
-    // DidPush in the scripted plan, that seems annoying.
-    // That means the constructor has to be in DidPush.
-    // So I have to validate the plan AFTER pushing it, and then take it off again...
-    if (!thread_plan_sp->ValidatePlan(nullptr))
-    {
-        DiscardThreadPlansUpToPlan(thread_plan_sp);
-        return ThreadPlanSP();
-    }
-    else
-        return thread_plan_sp;
-}
-
-uint32_t
-Thread::GetIndexID () const
-{
-    return m_index_id;
 }
 
-static void
-PrintPlanElement (Stream *s, const ThreadPlanSP &plan, lldb::DescriptionLevel desc_level, int32_t elem_idx)
-{
-        s->IndentMore();
-        s->Indent();
-        s->Printf ("Element %d: ", elem_idx);
-        plan->GetDescription (s, desc_level);
-        s->EOL();
-        s->IndentLess();
-}
+uint32_t Thread::GetIndexID() const { return m_index_id; }
 
-static void
-PrintPlanStack (Stream *s, const std::vector<lldb::ThreadPlanSP> &plan_stack, lldb::DescriptionLevel desc_level, bool include_internal)
-{
-    int32_t print_idx = 0;
-    for (ThreadPlanSP plan_sp : plan_stack)
-    {
-        if (include_internal || !plan_sp->GetPrivate())
-        {
-            PrintPlanElement (s, plan_sp, desc_level, print_idx++);
-        }
-    }
-}
-
-void
-Thread::DumpThreadPlans (Stream *s,
-                         lldb::DescriptionLevel desc_level,
-                         bool include_internal,
-                         bool ignore_boring_threads) const
-{
-    uint32_t stack_size;
+static void PrintPlanElement(Stream *s, const ThreadPlanSP &plan,
+                             lldb::DescriptionLevel desc_level,
+                             int32_t elem_idx) {
+  s->IndentMore();
+  s->Indent();
+  s->Printf("Element %d: ", elem_idx);
+  plan->GetDescription(s, desc_level);
+  s->EOL();
+  s->IndentLess();
+}
+
+static void PrintPlanStack(Stream *s,
+                           const std::vector<lldb::ThreadPlanSP> &plan_stack,
+                           lldb::DescriptionLevel desc_level,
+                           bool include_internal) {
+  int32_t print_idx = 0;
+  for (ThreadPlanSP plan_sp : plan_stack) {
+    if (include_internal || !plan_sp->GetPrivate()) {
+      PrintPlanElement(s, plan_sp, desc_level, print_idx++);
+    }
+  }
+}
+
+void Thread::DumpThreadPlans(Stream *s, lldb::DescriptionLevel desc_level,
+                             bool include_internal,
+                             bool ignore_boring_threads) const {
+  uint32_t stack_size;
+
+  if (ignore_boring_threads) {
+    uint32_t stack_size = m_plan_stack.size();
+    uint32_t completed_stack_size = m_completed_plan_stack.size();
+    uint32_t discarded_stack_size = m_discarded_plan_stack.size();
+    if (stack_size == 1 && completed_stack_size == 0 &&
+        discarded_stack_size == 0) {
+      s->Printf("thread #%u: tid = 0x%4.4" PRIx64 "\n", GetIndexID(), GetID());
+      s->IndentMore();
+      s->Indent();
+      s->Printf("No active thread plans\n");
+      s->IndentLess();
+      return;
+    }
+  }
+
+  s->Indent();
+  s->Printf("thread #%u: tid = 0x%4.4" PRIx64 ":\n", GetIndexID(), GetID());
+  s->IndentMore();
+  s->Indent();
+  s->Printf("Active plan stack:\n");
+  PrintPlanStack(s, m_plan_stack, desc_level, include_internal);
 
-    if (ignore_boring_threads)
-    {
-        uint32_t stack_size = m_plan_stack.size();
-        uint32_t completed_stack_size = m_completed_plan_stack.size();
-        uint32_t discarded_stack_size = m_discarded_plan_stack.size();
-        if (stack_size == 1 && completed_stack_size == 0 && discarded_stack_size == 0)
-        {
-            s->Printf ("thread #%u: tid = 0x%4.4" PRIx64 "\n", GetIndexID(), GetID());
-            s->IndentMore();
-            s->Indent();
-            s->Printf("No active thread plans\n");
-            s->IndentLess();
-            return;
-        }
-    }
-
-    s->Indent();
-    s->Printf ("thread #%u: tid = 0x%4.4" PRIx64 ":\n", GetIndexID(), GetID());
-    s->IndentMore();
+  stack_size = m_completed_plan_stack.size();
+  if (stack_size > 0) {
     s->Indent();
-    s->Printf ("Active plan stack:\n");
-    PrintPlanStack (s, m_plan_stack, desc_level, include_internal);
-
-    stack_size = m_completed_plan_stack.size();
-    if (stack_size > 0)
-    {
-        s->Indent();
-        s->Printf ("Completed Plan Stack:\n");
-        PrintPlanStack (s, m_completed_plan_stack, desc_level, include_internal);
-    }
+    s->Printf("Completed Plan Stack:\n");
+    PrintPlanStack(s, m_completed_plan_stack, desc_level, include_internal);
+  }
 
-    stack_size = m_discarded_plan_stack.size();
-    if (stack_size > 0)
-    {
-        s->Indent();
-        s->Printf ("Discarded Plan Stack:\n");
-        PrintPlanStack (s, m_discarded_plan_stack, desc_level, include_internal);
-    }
+  stack_size = m_discarded_plan_stack.size();
+  if (stack_size > 0) {
+    s->Indent();
+    s->Printf("Discarded Plan Stack:\n");
+    PrintPlanStack(s, m_discarded_plan_stack, desc_level, include_internal);
+  }
 
-    s->IndentLess();
+  s->IndentLess();
 }
 
-TargetSP
-Thread::CalculateTarget ()
-{
-    TargetSP target_sp;
-    ProcessSP process_sp(GetProcess());
-    if (process_sp)
-        target_sp = process_sp->CalculateTarget();
-    return target_sp;
+TargetSP Thread::CalculateTarget() {
+  TargetSP target_sp;
+  ProcessSP process_sp(GetProcess());
+  if (process_sp)
+    target_sp = process_sp->CalculateTarget();
+  return target_sp;
 }
 
-ProcessSP
-Thread::CalculateProcess ()
-{
-    return GetProcess();
-}
+ProcessSP Thread::CalculateProcess() { return GetProcess(); }
 
-ThreadSP
-Thread::CalculateThread ()
-{
-    return shared_from_this();
-}
+ThreadSP Thread::CalculateThread() { return shared_from_this(); }
 
-StackFrameSP
-Thread::CalculateStackFrame ()
-{
-    return StackFrameSP();
-}
+StackFrameSP Thread::CalculateStackFrame() { return StackFrameSP(); }
 
-void
-Thread::CalculateExecutionContext (ExecutionContext &exe_ctx)
-{
-    exe_ctx.SetContext (shared_from_this());
+void Thread::CalculateExecutionContext(ExecutionContext &exe_ctx) {
+  exe_ctx.SetContext(shared_from_this());
 }
 
-StackFrameListSP
-Thread::GetStackFrameList ()
-{
-    StackFrameListSP frame_list_sp;
-    std::lock_guard<std::recursive_mutex> guard(m_frame_mutex);
-    if (m_curr_frames_sp)
-    {
-        frame_list_sp = m_curr_frames_sp;
-    }
-    else
-    {
-        frame_list_sp.reset(new StackFrameList (*this, m_prev_frames_sp, true));
-        m_curr_frames_sp = frame_list_sp;
-    }
-    return frame_list_sp;
+StackFrameListSP Thread::GetStackFrameList() {
+  StackFrameListSP frame_list_sp;
+  std::lock_guard<std::recursive_mutex> guard(m_frame_mutex);
+  if (m_curr_frames_sp) {
+    frame_list_sp = m_curr_frames_sp;
+  } else {
+    frame_list_sp.reset(new StackFrameList(*this, m_prev_frames_sp, true));
+    m_curr_frames_sp = frame_list_sp;
+  }
+  return frame_list_sp;
 }
 
-void
-Thread::ClearStackFrames ()
-{
-    std::lock_guard<std::recursive_mutex> guard(m_frame_mutex);
+void Thread::ClearStackFrames() {
+  std::lock_guard<std::recursive_mutex> guard(m_frame_mutex);
 
-    Unwind *unwinder = GetUnwinder ();
-    if (unwinder)
-        unwinder->Clear();
-
-    // Only store away the old "reference" StackFrameList if we got all its frames:
-    // FIXME: At some point we can try to splice in the frames we have fetched into
-    // the new frame as we make it, but let's not try that now.
-    if (m_curr_frames_sp && m_curr_frames_sp->GetAllFramesFetched())
-        m_prev_frames_sp.swap (m_curr_frames_sp);
-    m_curr_frames_sp.reset();
+  Unwind *unwinder = GetUnwinder();
+  if (unwinder)
+    unwinder->Clear();
 
-    m_extended_info.reset();
-    m_extended_info_fetched = false;
-}
+  // Only store away the old "reference" StackFrameList if we got all its
+  // frames:
+  // FIXME: At some point we can try to splice in the frames we have fetched
+  // into
+  // the new frame as we make it, but let's not try that now.
+  if (m_curr_frames_sp && m_curr_frames_sp->GetAllFramesFetched())
+    m_prev_frames_sp.swap(m_curr_frames_sp);
+  m_curr_frames_sp.reset();
 
-lldb::StackFrameSP
-Thread::GetFrameWithConcreteFrameIndex (uint32_t unwind_idx)
-{
-    return GetStackFrameList()->GetFrameWithConcreteFrameIndex (unwind_idx);
+  m_extended_info.reset();
+  m_extended_info_fetched = false;
 }
 
-Error
-Thread::ReturnFromFrameWithIndex (uint32_t frame_idx, lldb::ValueObjectSP return_value_sp, bool broadcast)
-{
-    StackFrameSP frame_sp = GetStackFrameAtIndex (frame_idx);
-    Error return_error;
-    
-    if (!frame_sp)
-    {
-        return_error.SetErrorStringWithFormat("Could not find frame with index %d in thread 0x%" PRIx64 ".", frame_idx, GetID());
-    }
-    
-    return ReturnFromFrame(frame_sp, return_value_sp, broadcast);
+lldb::StackFrameSP Thread::GetFrameWithConcreteFrameIndex(uint32_t unwind_idx) {
+  return GetStackFrameList()->GetFrameWithConcreteFrameIndex(unwind_idx);
 }
 
-Error
-Thread::ReturnFromFrame (lldb::StackFrameSP frame_sp, lldb::ValueObjectSP return_value_sp, bool broadcast)
-{
-    Error return_error;
-    
-    if (!frame_sp)
-    {
-        return_error.SetErrorString("Can't return to a null frame.");
-        return return_error;
-    }
-    
-    Thread *thread = frame_sp->GetThread().get();
-    uint32_t older_frame_idx = frame_sp->GetFrameIndex() + 1;
-    StackFrameSP older_frame_sp = thread->GetStackFrameAtIndex(older_frame_idx);
-    if (!older_frame_sp)
-    {
-        return_error.SetErrorString("No older frame to return to.");
-        return return_error;
-    }
-    
-    if (return_value_sp)
-    {    
-        lldb::ABISP abi = thread->GetProcess()->GetABI();
-        if (!abi)
-        {
-            return_error.SetErrorString("Could not find ABI to set return value.");
-            return return_error;
-        }
-        SymbolContext sc = frame_sp->GetSymbolContext(eSymbolContextFunction);
-        
-        // FIXME: ValueObject::Cast doesn't currently work correctly, at least not for scalars.
-        // Turn that back on when that works.
-        if (/* DISABLES CODE */ (0) && sc.function != nullptr)
-        {
-            Type *function_type = sc.function->GetType();
-            if (function_type)
-            {
-                CompilerType return_type = sc.function->GetCompilerType().GetFunctionReturnType();
-                if (return_type)
-                {
-                    StreamString s;
-                    return_type.DumpTypeDescription(&s);
-                    ValueObjectSP cast_value_sp = return_value_sp->Cast(return_type);
-                    if (cast_value_sp)
-                    {
-                        cast_value_sp->SetFormat(eFormatHex);
-                        return_value_sp = cast_value_sp;
-                    }
-                }
-            }
-        }
-
-        return_error = abi->SetReturnValueObject(older_frame_sp, return_value_sp);
-        if (!return_error.Success())
-            return return_error;
-    }
-    
-    // Now write the return registers for the chosen frame:
-    // Note, we can't use ReadAllRegisterValues->WriteAllRegisterValues, since the read & write
-    // cook their data
-    
-    StackFrameSP youngest_frame_sp = thread->GetStackFrameAtIndex(0);
-    if (youngest_frame_sp)
-    {
-        lldb::RegisterContextSP reg_ctx_sp (youngest_frame_sp->GetRegisterContext());
-        if (reg_ctx_sp)
-        {
-            bool copy_success = reg_ctx_sp->CopyFromRegisterContext(older_frame_sp->GetRegisterContext());
-            if (copy_success)
-            {
-                thread->DiscardThreadPlans(true);
-                thread->ClearStackFrames();
-                if (broadcast && EventTypeHasListeners(eBroadcastBitStackChanged))
-                    BroadcastEvent(eBroadcastBitStackChanged, new ThreadEventData (this->shared_from_this()));
-            }
-            else
-            {
-                return_error.SetErrorString("Could not reset register values.");
-            }
-        }
-        else
-        {
-            return_error.SetErrorString("Frame has no register context.");
-        }
-    }
-    else
-    {
-        return_error.SetErrorString("Returned past top frame.");
-    }
-    return return_error;
-}
-
-static void DumpAddressList (Stream &s, const std::vector<Address> &list, ExecutionContextScope *exe_scope)
-{
-    for (size_t n=0;n<list.size();n++)
-    {
-        s << "\t";
-        list[n].Dump (&s, exe_scope, Address::DumpStyleResolvedDescription, Address::DumpStyleSectionNameOffset);
-        s << "\n";
-    }
-}
-
-Error
-Thread::JumpToLine (const FileSpec &file, uint32_t line, bool can_leave_function, std::string *warnings)
-{
-    ExecutionContext exe_ctx (GetStackFrameAtIndex(0));
-    Target *target = exe_ctx.GetTargetPtr();
-    TargetSP target_sp = exe_ctx.GetTargetSP();
-    RegisterContext *reg_ctx = exe_ctx.GetRegisterContext();
-    StackFrame *frame = exe_ctx.GetFramePtr();
-    const SymbolContext &sc = frame->GetSymbolContext(eSymbolContextFunction);
-
-    // Find candidate locations.
-    std::vector<Address> candidates, within_function, outside_function;
-    target->GetImages().FindAddressesForLine (target_sp, file, line, sc.function, within_function, outside_function);
-
-    // If possible, we try and stay within the current function.
-    // Within a function, we accept multiple locations (optimized code may do this,
-    // there's no solution here so we do the best we can).
-    // However if we're trying to leave the function, we don't know how to pick the
-    // right location, so if there's more than one then we bail.
-    if (!within_function.empty())
-        candidates = within_function;
-    else if (outside_function.size() == 1 && can_leave_function)
-        candidates = outside_function;
-
-    // Check if we got anything.
-    if (candidates.empty())
-    {
-        if (outside_function.empty())
-        {
-            return Error("Cannot locate an address for %s:%i.",
-                         file.GetFilename().AsCString(), line);
-        }
-        else if (outside_function.size() == 1)
-        {
-            return Error("%s:%i is outside the current function.",
-                         file.GetFilename().AsCString(), line);
-        }
-        else
-        {
-            StreamString sstr;
-            DumpAddressList(sstr, outside_function, target);
-            return Error("%s:%i has multiple candidate locations:\n%s",
-                         file.GetFilename().AsCString(), line, sstr.GetString().c_str());
-        }
-    }
-
-    // Accept the first location, warn about any others.
-    Address dest = candidates[0];
-    if (warnings && candidates.size() > 1)
-    {
-        StreamString sstr;
-        sstr.Printf("%s:%i appears multiple times in this function, selecting the first location:\n",
-                     file.GetFilename().AsCString(), line);
-        DumpAddressList(sstr, candidates, target);
-        *warnings = sstr.GetString();
-    }
+Error Thread::ReturnFromFrameWithIndex(uint32_t frame_idx,
+                                       lldb::ValueObjectSP return_value_sp,
+                                       bool broadcast) {
+  StackFrameSP frame_sp = GetStackFrameAtIndex(frame_idx);
+  Error return_error;
 
-    if (!reg_ctx->SetPC (dest))
-        return Error("Cannot change PC to target address.");
+  if (!frame_sp) {
+    return_error.SetErrorStringWithFormat(
+        "Could not find frame with index %d in thread 0x%" PRIx64 ".",
+        frame_idx, GetID());
+  }
 
-    return Error();
+  return ReturnFromFrame(frame_sp, return_value_sp, broadcast);
 }
 
-void
-Thread::DumpUsingSettingsFormat (Stream &strm, uint32_t frame_idx)
-{
-    ExecutionContext exe_ctx (shared_from_this());
-    Process *process = exe_ctx.GetProcessPtr();
-    if (process == nullptr)
-        return;
-
-    StackFrameSP frame_sp;
-    SymbolContext frame_sc;
-    if (frame_idx != LLDB_INVALID_FRAME_ID)
-    {
-        frame_sp = GetStackFrameAtIndex (frame_idx);
-        if (frame_sp)
-        {
-            exe_ctx.SetFrameSP(frame_sp);
-            frame_sc = frame_sp->GetSymbolContext(eSymbolContextEverything);
-        }
-    }
-
-    const FormatEntity::Entry *thread_format = exe_ctx.GetTargetRef().GetDebugger().GetThreadFormat();
-    assert (thread_format);
-    
-    FormatEntity::Format(*thread_format,
-                         strm,
-                         frame_sp ? &frame_sc : nullptr,
-                         &exe_ctx,
-                         nullptr,
-                         nullptr,
-                         false,
-                         false);
-}
+Error Thread::ReturnFromFrame(lldb::StackFrameSP frame_sp,
+                              lldb::ValueObjectSP return_value_sp,
+                              bool broadcast) {
+  Error return_error;
 
-void
-Thread::SettingsInitialize ()
-{
-}
+  if (!frame_sp) {
+    return_error.SetErrorString("Can't return to a null frame.");
+    return return_error;
+  }
 
-void
-Thread::SettingsTerminate ()
-{
-}
+  Thread *thread = frame_sp->GetThread().get();
+  uint32_t older_frame_idx = frame_sp->GetFrameIndex() + 1;
+  StackFrameSP older_frame_sp = thread->GetStackFrameAtIndex(older_frame_idx);
+  if (!older_frame_sp) {
+    return_error.SetErrorString("No older frame to return to.");
+    return return_error;
+  }
 
-lldb::addr_t
-Thread::GetThreadPointer ()
-{
+  if (return_value_sp) {
+    lldb::ABISP abi = thread->GetProcess()->GetABI();
+    if (!abi) {
+      return_error.SetErrorString("Could not find ABI to set return value.");
+      return return_error;
+    }
+    SymbolContext sc = frame_sp->GetSymbolContext(eSymbolContextFunction);
+
+    // FIXME: ValueObject::Cast doesn't currently work correctly, at least not
+    // for scalars.
+    // Turn that back on when that works.
+    if (/* DISABLES CODE */ (0) && sc.function != nullptr) {
+      Type *function_type = sc.function->GetType();
+      if (function_type) {
+        CompilerType return_type =
+            sc.function->GetCompilerType().GetFunctionReturnType();
+        if (return_type) {
+          StreamString s;
+          return_type.DumpTypeDescription(&s);
+          ValueObjectSP cast_value_sp = return_value_sp->Cast(return_type);
+          if (cast_value_sp) {
+            cast_value_sp->SetFormat(eFormatHex);
+            return_value_sp = cast_value_sp;
+          }
+        }
+      }
+    }
+
+    return_error = abi->SetReturnValueObject(older_frame_sp, return_value_sp);
+    if (!return_error.Success())
+      return return_error;
+  }
+
+  // Now write the return registers for the chosen frame:
+  // Note, we can't use ReadAllRegisterValues->WriteAllRegisterValues, since the
+  // read & write
+  // cook their data
+
+  StackFrameSP youngest_frame_sp = thread->GetStackFrameAtIndex(0);
+  if (youngest_frame_sp) {
+    lldb::RegisterContextSP reg_ctx_sp(youngest_frame_sp->GetRegisterContext());
+    if (reg_ctx_sp) {
+      bool copy_success = reg_ctx_sp->CopyFromRegisterContext(
+          older_frame_sp->GetRegisterContext());
+      if (copy_success) {
+        thread->DiscardThreadPlans(true);
+        thread->ClearStackFrames();
+        if (broadcast && EventTypeHasListeners(eBroadcastBitStackChanged))
+          BroadcastEvent(eBroadcastBitStackChanged,
+                         new ThreadEventData(this->shared_from_this()));
+      } else {
+        return_error.SetErrorString("Could not reset register values.");
+      }
+    } else {
+      return_error.SetErrorString("Frame has no register context.");
+    }
+  } else {
+    return_error.SetErrorString("Returned past top frame.");
+  }
+  return return_error;
+}
+
+static void DumpAddressList(Stream &s, const std::vector<Address> &list,
+                            ExecutionContextScope *exe_scope) {
+  for (size_t n = 0; n < list.size(); n++) {
+    s << "\t";
+    list[n].Dump(&s, exe_scope, Address::DumpStyleResolvedDescription,
+                 Address::DumpStyleSectionNameOffset);
+    s << "\n";
+  }
+}
+
+Error Thread::JumpToLine(const FileSpec &file, uint32_t line,
+                         bool can_leave_function, std::string *warnings) {
+  ExecutionContext exe_ctx(GetStackFrameAtIndex(0));
+  Target *target = exe_ctx.GetTargetPtr();
+  TargetSP target_sp = exe_ctx.GetTargetSP();
+  RegisterContext *reg_ctx = exe_ctx.GetRegisterContext();
+  StackFrame *frame = exe_ctx.GetFramePtr();
+  const SymbolContext &sc = frame->GetSymbolContext(eSymbolContextFunction);
+
+  // Find candidate locations.
+  std::vector<Address> candidates, within_function, outside_function;
+  target->GetImages().FindAddressesForLine(target_sp, file, line, sc.function,
+                                           within_function, outside_function);
+
+  // If possible, we try and stay within the current function.
+  // Within a function, we accept multiple locations (optimized code may do
+  // this,
+  // there's no solution here so we do the best we can).
+  // However if we're trying to leave the function, we don't know how to pick
+  // the
+  // right location, so if there's more than one then we bail.
+  if (!within_function.empty())
+    candidates = within_function;
+  else if (outside_function.size() == 1 && can_leave_function)
+    candidates = outside_function;
+
+  // Check if we got anything.
+  if (candidates.empty()) {
+    if (outside_function.empty()) {
+      return Error("Cannot locate an address for %s:%i.",
+                   file.GetFilename().AsCString(), line);
+    } else if (outside_function.size() == 1) {
+      return Error("%s:%i is outside the current function.",
+                   file.GetFilename().AsCString(), line);
+    } else {
+      StreamString sstr;
+      DumpAddressList(sstr, outside_function, target);
+      return Error("%s:%i has multiple candidate locations:\n%s",
+                   file.GetFilename().AsCString(), line,
+                   sstr.GetString().c_str());
+    }
+  }
+
+  // Accept the first location, warn about any others.
+  Address dest = candidates[0];
+  if (warnings && candidates.size() > 1) {
+    StreamString sstr;
+    sstr.Printf("%s:%i appears multiple times in this function, selecting the "
+                "first location:\n",
+                file.GetFilename().AsCString(), line);
+    DumpAddressList(sstr, candidates, target);
+    *warnings = sstr.GetString();
+  }
+
+  if (!reg_ctx->SetPC(dest))
+    return Error("Cannot change PC to target address.");
+
+  return Error();
+}
+
+void Thread::DumpUsingSettingsFormat(Stream &strm, uint32_t frame_idx) {
+  ExecutionContext exe_ctx(shared_from_this());
+  Process *process = exe_ctx.GetProcessPtr();
+  if (process == nullptr)
+    return;
+
+  StackFrameSP frame_sp;
+  SymbolContext frame_sc;
+  if (frame_idx != LLDB_INVALID_FRAME_ID) {
+    frame_sp = GetStackFrameAtIndex(frame_idx);
+    if (frame_sp) {
+      exe_ctx.SetFrameSP(frame_sp);
+      frame_sc = frame_sp->GetSymbolContext(eSymbolContextEverything);
+    }
+  }
+
+  const FormatEntity::Entry *thread_format =
+      exe_ctx.GetTargetRef().GetDebugger().GetThreadFormat();
+  assert(thread_format);
+
+  FormatEntity::Format(*thread_format, strm, frame_sp ? &frame_sc : nullptr,
+                       &exe_ctx, nullptr, nullptr, false, false);
+}
+
+void Thread::SettingsInitialize() {}
+
+void Thread::SettingsTerminate() {}
+
+lldb::addr_t Thread::GetThreadPointer() { return LLDB_INVALID_ADDRESS; }
+
+addr_t Thread::GetThreadLocalData(const ModuleSP module,
+                                  lldb::addr_t tls_file_addr) {
+  // The default implementation is to ask the dynamic loader for it.
+  // This can be overridden for specific platforms.
+  DynamicLoader *loader = GetProcess()->GetDynamicLoader();
+  if (loader)
+    return loader->GetThreadLocalData(module, shared_from_this(),
+                                      tls_file_addr);
+  else
     return LLDB_INVALID_ADDRESS;
 }
 
-addr_t
-Thread::GetThreadLocalData(const ModuleSP module, lldb::addr_t tls_file_addr)
-{
-    // The default implementation is to ask the dynamic loader for it.
-    // This can be overridden for specific platforms.
-    DynamicLoader *loader = GetProcess()->GetDynamicLoader();
-    if (loader)
-        return loader->GetThreadLocalData(module, shared_from_this(), tls_file_addr);
-    else
-        return LLDB_INVALID_ADDRESS;
-}
-
-bool
-Thread::SafeToCallFunctions ()
-{
-    Process *process = GetProcess().get();
-    if (process)
-    {
-        SystemRuntime *runtime = process->GetSystemRuntime ();
-        if (runtime)
-        {
-            return runtime->SafeToCallFunctionsOnThisThread (shared_from_this());
-        }
+bool Thread::SafeToCallFunctions() {
+  Process *process = GetProcess().get();
+  if (process) {
+    SystemRuntime *runtime = process->GetSystemRuntime();
+    if (runtime) {
+      return runtime->SafeToCallFunctionsOnThisThread(shared_from_this());
     }
-    return true;
+  }
+  return true;
 }
 
 lldb::StackFrameSP
-Thread::GetStackFrameSPForStackFramePtr (StackFrame *stack_frame_ptr)
-{
-    return GetStackFrameList()->GetStackFrameSPForStackFramePtr (stack_frame_ptr);
+Thread::GetStackFrameSPForStackFramePtr(StackFrame *stack_frame_ptr) {
+  return GetStackFrameList()->GetStackFrameSPForStackFramePtr(stack_frame_ptr);
 }
 
-const char *
-Thread::StopReasonAsCString (lldb::StopReason reason)
-{
-    switch (reason)
-    {
-    case eStopReasonInvalid:       return "invalid";
-    case eStopReasonNone:          return "none";
-    case eStopReasonTrace:         return "trace";
-    case eStopReasonBreakpoint:    return "breakpoint";
-    case eStopReasonWatchpoint:    return "watchpoint";
-    case eStopReasonSignal:        return "signal";
-    case eStopReasonException:     return "exception";
-    case eStopReasonExec:          return "exec";
-    case eStopReasonPlanComplete:  return "plan complete";
-    case eStopReasonThreadExiting: return "thread exiting";
-    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;
-}
-
-const char *
-Thread::RunModeAsCString (lldb::RunMode mode)
-{
-    switch (mode)
-    {
-    case eOnlyThisThread:     return "only this thread";
-    case eAllThreads:         return "all threads";
-    case eOnlyDuringStepping: return "only during stepping";
-    }
-
-    static char unknown_state_string[64];
-    snprintf(unknown_state_string, sizeof (unknown_state_string), "RunMode = %i", mode);
-    return unknown_state_string;
-}
-
-size_t
-Thread::GetStatus (Stream &strm, uint32_t start_frame, uint32_t num_frames, uint32_t num_frames_with_source)
-{
-    ExecutionContext exe_ctx (shared_from_this());
-    Target *target = exe_ctx.GetTargetPtr();
-    Process *process = exe_ctx.GetProcessPtr();
-    size_t num_frames_shown = 0;
-    strm.Indent();
-    bool is_selected = false;
-    if (process)
-    {
-        if (process->GetThreadList().GetSelectedThread().get() == this)
-            is_selected = true;
-    }
-    strm.Printf("%c ", is_selected ? '*' : ' ');
-    if (target && target->GetDebugger().GetUseExternalEditor())
-    {
-        StackFrameSP frame_sp = GetStackFrameAtIndex(start_frame);
-        if (frame_sp)
-        {
-            SymbolContext frame_sc(frame_sp->GetSymbolContext (eSymbolContextLineEntry));
-            if (frame_sc.line_entry.line != 0 && frame_sc.line_entry.file)
-            {
-                Host::OpenFileInExternalEditor (frame_sc.line_entry.file, frame_sc.line_entry.line);
-            }
-        }
-    }
-    
-    DumpUsingSettingsFormat (strm, start_frame);
-    
-    if (num_frames > 0)
-    {
-        strm.IndentMore();
-        
-        const bool show_frame_info = true;
-        
-        const char *selected_frame_marker = nullptr;
-        if (num_frames == 1 || (GetID() != GetProcess()->GetThreadList().GetSelectedThread()->GetID()))
-            strm.IndentMore ();
-        else
-            selected_frame_marker = "* ";
-
-        num_frames_shown = GetStackFrameList ()->GetStatus (strm,
-                                                            start_frame, 
-                                                            num_frames, 
-                                                            show_frame_info, 
-                                                            num_frames_with_source,
-                                                            selected_frame_marker);
-        if (num_frames == 1)
-            strm.IndentLess();
-        strm.IndentLess();
-    }
-    return num_frames_shown;
-}
-
-bool
-Thread::GetDescription (Stream &strm, lldb::DescriptionLevel level, bool print_json_thread, bool print_json_stopinfo)
-{
-    DumpUsingSettingsFormat (strm, 0);
-    strm.Printf("\n");
-
-    StructuredData::ObjectSP thread_info = GetExtendedInfo();
-
-    if (print_json_thread || print_json_stopinfo)
-    {
-        if (thread_info && print_json_thread)
-        {
-            thread_info->Dump (strm);
-            strm.Printf("\n");
-        }
-
-        if (print_json_stopinfo && m_stop_info_sp)
-        {
-            StructuredData::ObjectSP stop_info = m_stop_info_sp->GetExtendedInfo();
-            if (stop_info)
-            {
-                stop_info->Dump (strm);
-                strm.Printf("\n");
-            }
-        }
-
-        return true;
-    }
-
-    if (thread_info)
-    {
-        StructuredData::ObjectSP activity = thread_info->GetObjectForDotSeparatedPath("activity");
-        StructuredData::ObjectSP breadcrumb = thread_info->GetObjectForDotSeparatedPath("breadcrumb");
-        StructuredData::ObjectSP messages = thread_info->GetObjectForDotSeparatedPath("trace_messages");
-
-        bool printed_activity = false;
-        if (activity && activity->GetType() == StructuredData::Type::eTypeDictionary)
-        {
-            StructuredData::Dictionary *activity_dict = activity->GetAsDictionary();
-            StructuredData::ObjectSP id = activity_dict->GetValueForKey("id");
-            StructuredData::ObjectSP name = activity_dict->GetValueForKey("name");
-            if (name && name->GetType() == StructuredData::Type::eTypeString
-                && id && id->GetType() == StructuredData::Type::eTypeInteger)
-            {
-                strm.Printf("  Activity '%s', 0x%" PRIx64 "\n", name->GetAsString()->GetValue().c_str(), id->GetAsInteger()->GetValue());
-            }
-            printed_activity = true;
-        }
-        bool printed_breadcrumb = false;
-        if (breadcrumb && breadcrumb->GetType() == StructuredData::Type::eTypeDictionary)
-        {
-            if (printed_activity)
-                strm.Printf ("\n");
-            StructuredData::Dictionary *breadcrumb_dict = breadcrumb->GetAsDictionary();
-            StructuredData::ObjectSP breadcrumb_text = breadcrumb_dict->GetValueForKey ("name");
-            if (breadcrumb_text && breadcrumb_text->GetType() == StructuredData::Type::eTypeString)
-            {
-                strm.Printf ("  Current Breadcrumb: %s\n", breadcrumb_text->GetAsString()->GetValue().c_str());
-            }
-            printed_breadcrumb = true;
-        }
-        if (messages && messages->GetType() == StructuredData::Type::eTypeArray)
-        {
-            if (printed_breadcrumb)
-                strm.Printf("\n");
-            StructuredData::Array *messages_array = messages->GetAsArray();
-            const size_t msg_count = messages_array->GetSize();
-            if (msg_count > 0)
-            {
-                strm.Printf ("  %zu trace messages:\n", msg_count);
-                for (size_t i = 0; i < msg_count; i++)
-                {
-                    StructuredData::ObjectSP message = messages_array->GetItemAtIndex(i);
-                    if (message && message->GetType() == StructuredData::Type::eTypeDictionary)
-                    {
-                        StructuredData::Dictionary *message_dict = message->GetAsDictionary();
-                        StructuredData::ObjectSP message_text = message_dict->GetValueForKey ("message");
-                        if (message_text && message_text->GetType() == StructuredData::Type::eTypeString)
-                        {
-                            strm.Printf ("    %s\n", message_text->GetAsString()->GetValue().c_str());
-                        }
-                    }
-                }
-            }
-        }
+const char *Thread::StopReasonAsCString(lldb::StopReason reason) {
+  switch (reason) {
+  case eStopReasonInvalid:
+    return "invalid";
+  case eStopReasonNone:
+    return "none";
+  case eStopReasonTrace:
+    return "trace";
+  case eStopReasonBreakpoint:
+    return "breakpoint";
+  case eStopReasonWatchpoint:
+    return "watchpoint";
+  case eStopReasonSignal:
+    return "signal";
+  case eStopReasonException:
+    return "exception";
+  case eStopReasonExec:
+    return "exec";
+  case eStopReasonPlanComplete:
+    return "plan complete";
+  case eStopReasonThreadExiting:
+    return "thread exiting";
+  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;
+}
+
+const char *Thread::RunModeAsCString(lldb::RunMode mode) {
+  switch (mode) {
+  case eOnlyThisThread:
+    return "only this thread";
+  case eAllThreads:
+    return "all threads";
+  case eOnlyDuringStepping:
+    return "only during stepping";
+  }
+
+  static char unknown_state_string[64];
+  snprintf(unknown_state_string, sizeof(unknown_state_string), "RunMode = %i",
+           mode);
+  return unknown_state_string;
+}
+
+size_t Thread::GetStatus(Stream &strm, uint32_t start_frame,
+                         uint32_t num_frames, uint32_t num_frames_with_source) {
+  ExecutionContext exe_ctx(shared_from_this());
+  Target *target = exe_ctx.GetTargetPtr();
+  Process *process = exe_ctx.GetProcessPtr();
+  size_t num_frames_shown = 0;
+  strm.Indent();
+  bool is_selected = false;
+  if (process) {
+    if (process->GetThreadList().GetSelectedThread().get() == this)
+      is_selected = true;
+  }
+  strm.Printf("%c ", is_selected ? '*' : ' ');
+  if (target && target->GetDebugger().GetUseExternalEditor()) {
+    StackFrameSP frame_sp = GetStackFrameAtIndex(start_frame);
+    if (frame_sp) {
+      SymbolContext frame_sc(
+          frame_sp->GetSymbolContext(eSymbolContextLineEntry));
+      if (frame_sc.line_entry.line != 0 && frame_sc.line_entry.file) {
+        Host::OpenFileInExternalEditor(frame_sc.line_entry.file,
+                                       frame_sc.line_entry.line);
+      }
+    }
+  }
+
+  DumpUsingSettingsFormat(strm, start_frame);
+
+  if (num_frames > 0) {
+    strm.IndentMore();
+
+    const bool show_frame_info = true;
+
+    const char *selected_frame_marker = nullptr;
+    if (num_frames == 1 ||
+        (GetID() != GetProcess()->GetThreadList().GetSelectedThread()->GetID()))
+      strm.IndentMore();
+    else
+      selected_frame_marker = "* ";
+
+    num_frames_shown = GetStackFrameList()->GetStatus(
+        strm, start_frame, num_frames, show_frame_info, num_frames_with_source,
+        selected_frame_marker);
+    if (num_frames == 1)
+      strm.IndentLess();
+    strm.IndentLess();
+  }
+  return num_frames_shown;
+}
+
+bool Thread::GetDescription(Stream &strm, lldb::DescriptionLevel level,
+                            bool print_json_thread, bool print_json_stopinfo) {
+  DumpUsingSettingsFormat(strm, 0);
+  strm.Printf("\n");
+
+  StructuredData::ObjectSP thread_info = GetExtendedInfo();
+
+  if (print_json_thread || print_json_stopinfo) {
+    if (thread_info && print_json_thread) {
+      thread_info->Dump(strm);
+      strm.Printf("\n");
+    }
+
+    if (print_json_stopinfo && m_stop_info_sp) {
+      StructuredData::ObjectSP stop_info = m_stop_info_sp->GetExtendedInfo();
+      if (stop_info) {
+        stop_info->Dump(strm);
+        strm.Printf("\n");
+      }
     }
 
     return true;
-}
+  }
 
-size_t
-Thread::GetStackFrameStatus (Stream& strm,
-                             uint32_t first_frame,
-                             uint32_t num_frames,
-                             bool show_frame_info,
-                             uint32_t num_frames_with_source)
-{
-    return GetStackFrameList()->GetStatus (strm,
-                                           first_frame,
-                                           num_frames,
-                                           show_frame_info,
-                                           num_frames_with_source);
-}
-
-Unwind *
-Thread::GetUnwinder ()
-{
-    if (!m_unwinder_ap)
-    {
-        const ArchSpec target_arch (CalculateTarget()->GetArchitecture ());
-        const llvm::Triple::ArchType machine = target_arch.GetMachine();
-        switch (machine)
-        {
-            case llvm::Triple::x86_64:
-            case llvm::Triple::x86:
-            case llvm::Triple::arm:
-            case llvm::Triple::aarch64:
-            case llvm::Triple::thumb:
-            case llvm::Triple::mips:
-            case llvm::Triple::mipsel:
-            case llvm::Triple::mips64:
-            case llvm::Triple::mips64el:
-            case llvm::Triple::ppc:
-            case llvm::Triple::ppc64:
-            case llvm::Triple::systemz:
-            case llvm::Triple::hexagon:
-                m_unwinder_ap.reset (new UnwindLLDB (*this));
-                break;
-                
-            default:
-                if (target_arch.GetTriple().getVendor() == llvm::Triple::Apple)
-                    m_unwinder_ap.reset (new UnwindMacOSXFrameBackchain (*this));
-                break;
-        }
-    }
-    return m_unwinder_ap.get();
-}
-
-void
-Thread::Flush ()
-{
-    ClearStackFrames ();
-    m_reg_context_sp.reset();
-}
-
-bool
-Thread::IsStillAtLastBreakpointHit ()
-{
-    // If we are currently stopped at a breakpoint, always return that stopinfo and don't reset it.
-    // This allows threads to maintain their breakpoint stopinfo, such as when thread-stepping in
-    // multithreaded programs.
-    if (m_stop_info_sp) {
-        StopReason stop_reason = m_stop_info_sp->GetStopReason();
-        if (stop_reason == lldb::eStopReasonBreakpoint) {
-            uint64_t value = m_stop_info_sp->GetValue();
-            lldb::RegisterContextSP reg_ctx_sp (GetRegisterContext());
-            if (reg_ctx_sp)
-            {
-                lldb::addr_t pc = reg_ctx_sp->GetPC();
-                BreakpointSiteSP bp_site_sp = GetProcess()->GetBreakpointSiteList().FindByAddress(pc);
-                if (bp_site_sp &&
-                    static_cast<break_id_t>(value) == bp_site_sp->GetID())
-                    return true;
-            }
-        }
-    }
-    return false;
-}
-
-Error
-Thread::StepIn (bool source_step,
-                LazyBool step_in_avoids_code_without_debug_info,
-                LazyBool step_out_avoids_code_without_debug_info)
-
-{
-    Error error;
-    Process *process = GetProcess().get();
-    if (StateIsStoppedState (process->GetState(), true))
-    {
-        StackFrameSP frame_sp = GetStackFrameAtIndex (0);
-        ThreadPlanSP new_plan_sp;
-        const lldb::RunMode run_mode = eOnlyThisThread;
-        const bool abort_other_plans = false;
-    
-        if (source_step && frame_sp && frame_sp->HasDebugInformation ())
-        {
-            SymbolContext sc(frame_sp->GetSymbolContext(eSymbolContextEverything));
-            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
-        {
-            new_plan_sp = QueueThreadPlanForStepSingleInstruction (false,
-                                                                   abort_other_plans,
-                                                                   run_mode);
-        }
-        
-        new_plan_sp->SetIsMasterPlan(true);
-        new_plan_sp->SetOkayToDiscard(false);
-        
-        // Why do we need to set the current thread by ID here???
-        process->GetThreadList().SetSelectedThreadByID (GetID());
-        error = process->Resume();
-    }
-    else
-    {
-        error.SetErrorString("process not stopped");
-    }
-    return error;
-}
-
-Error
-Thread::StepOver (bool source_step,
-                LazyBool step_out_avoids_code_without_debug_info)
-{
-    Error error;
-    Process *process = GetProcess().get();
-    if (StateIsStoppedState (process->GetState(), true))
-    {
-        StackFrameSP frame_sp = GetStackFrameAtIndex (0);
-        ThreadPlanSP new_plan_sp;
-        
-        const lldb::RunMode run_mode = eOnlyThisThread;
-        const bool abort_other_plans = false;
-        
-        if (source_step && frame_sp && frame_sp->HasDebugInformation ())
-        {
-            SymbolContext sc(frame_sp->GetSymbolContext(eSymbolContextEverything));
-            new_plan_sp = QueueThreadPlanForStepOverRange (abort_other_plans,
-                                                           sc.line_entry,
-                                                           sc,
-                                                           run_mode,
-                                                           step_out_avoids_code_without_debug_info);
-        }
-        else
-        {
-            new_plan_sp = QueueThreadPlanForStepSingleInstruction (true,
-                                                                   abort_other_plans,
-                                                                   run_mode);
-        }
-        
-        new_plan_sp->SetIsMasterPlan(true);
-        new_plan_sp->SetOkayToDiscard(false);
-        
-        // Why do we need to set the current thread by ID here???
-        process->GetThreadList().SetSelectedThreadByID (GetID());
-        error = process->Resume();
-    }
-    else
-    {
-        error.SetErrorString("process not stopped");
-    }
-    return error;
-}
-
-Error
-Thread::StepOut ()
-{
-    Error error;
-    Process *process = GetProcess().get();
-    if (StateIsStoppedState (process->GetState(), true))
-    {
-        const bool first_instruction = false;
-        const bool stop_other_threads = false;
-        const bool abort_other_plans = false;
-
-        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);
-        
-        // Why do we need to set the current thread by ID here???
-        process->GetThreadList().SetSelectedThreadByID (GetID());
-        error = process->Resume();
-    }
-    else
-    {
-        error.SetErrorString("process not stopped");
-    }
-    return error;
+  if (thread_info) {
+    StructuredData::ObjectSP activity =
+        thread_info->GetObjectForDotSeparatedPath("activity");
+    StructuredData::ObjectSP breadcrumb =
+        thread_info->GetObjectForDotSeparatedPath("breadcrumb");
+    StructuredData::ObjectSP messages =
+        thread_info->GetObjectForDotSeparatedPath("trace_messages");
+
+    bool printed_activity = false;
+    if (activity &&
+        activity->GetType() == StructuredData::Type::eTypeDictionary) {
+      StructuredData::Dictionary *activity_dict = activity->GetAsDictionary();
+      StructuredData::ObjectSP id = activity_dict->GetValueForKey("id");
+      StructuredData::ObjectSP name = activity_dict->GetValueForKey("name");
+      if (name && name->GetType() == StructuredData::Type::eTypeString && id &&
+          id->GetType() == StructuredData::Type::eTypeInteger) {
+        strm.Printf("  Activity '%s', 0x%" PRIx64 "\n",
+                    name->GetAsString()->GetValue().c_str(),
+                    id->GetAsInteger()->GetValue());
+      }
+      printed_activity = true;
+    }
+    bool printed_breadcrumb = false;
+    if (breadcrumb &&
+        breadcrumb->GetType() == StructuredData::Type::eTypeDictionary) {
+      if (printed_activity)
+        strm.Printf("\n");
+      StructuredData::Dictionary *breadcrumb_dict =
+          breadcrumb->GetAsDictionary();
+      StructuredData::ObjectSP breadcrumb_text =
+          breadcrumb_dict->GetValueForKey("name");
+      if (breadcrumb_text &&
+          breadcrumb_text->GetType() == StructuredData::Type::eTypeString) {
+        strm.Printf("  Current Breadcrumb: %s\n",
+                    breadcrumb_text->GetAsString()->GetValue().c_str());
+      }
+      printed_breadcrumb = true;
+    }
+    if (messages && messages->GetType() == StructuredData::Type::eTypeArray) {
+      if (printed_breadcrumb)
+        strm.Printf("\n");
+      StructuredData::Array *messages_array = messages->GetAsArray();
+      const size_t msg_count = messages_array->GetSize();
+      if (msg_count > 0) {
+        strm.Printf("  %zu trace messages:\n", msg_count);
+        for (size_t i = 0; i < msg_count; i++) {
+          StructuredData::ObjectSP message = messages_array->GetItemAtIndex(i);
+          if (message &&
+              message->GetType() == StructuredData::Type::eTypeDictionary) {
+            StructuredData::Dictionary *message_dict =
+                message->GetAsDictionary();
+            StructuredData::ObjectSP message_text =
+                message_dict->GetValueForKey("message");
+            if (message_text &&
+                message_text->GetType() == StructuredData::Type::eTypeString) {
+              strm.Printf("    %s\n",
+                          message_text->GetAsString()->GetValue().c_str());
+            }
+          }
+        }
+      }
+    }
+  }
+
+  return true;
+}
+
+size_t Thread::GetStackFrameStatus(Stream &strm, uint32_t first_frame,
+                                   uint32_t num_frames, bool show_frame_info,
+                                   uint32_t num_frames_with_source) {
+  return GetStackFrameList()->GetStatus(
+      strm, first_frame, num_frames, show_frame_info, num_frames_with_source);
+}
+
+Unwind *Thread::GetUnwinder() {
+  if (!m_unwinder_ap) {
+    const ArchSpec target_arch(CalculateTarget()->GetArchitecture());
+    const llvm::Triple::ArchType machine = target_arch.GetMachine();
+    switch (machine) {
+    case llvm::Triple::x86_64:
+    case llvm::Triple::x86:
+    case llvm::Triple::arm:
+    case llvm::Triple::aarch64:
+    case llvm::Triple::thumb:
+    case llvm::Triple::mips:
+    case llvm::Triple::mipsel:
+    case llvm::Triple::mips64:
+    case llvm::Triple::mips64el:
+    case llvm::Triple::ppc:
+    case llvm::Triple::ppc64:
+    case llvm::Triple::systemz:
+    case llvm::Triple::hexagon:
+      m_unwinder_ap.reset(new UnwindLLDB(*this));
+      break;
+
+    default:
+      if (target_arch.GetTriple().getVendor() == llvm::Triple::Apple)
+        m_unwinder_ap.reset(new UnwindMacOSXFrameBackchain(*this));
+      break;
+    }
+  }
+  return m_unwinder_ap.get();
+}
+
+void Thread::Flush() {
+  ClearStackFrames();
+  m_reg_context_sp.reset();
+}
+
+bool Thread::IsStillAtLastBreakpointHit() {
+  // If we are currently stopped at a breakpoint, always return that stopinfo
+  // and don't reset it.
+  // This allows threads to maintain their breakpoint stopinfo, such as when
+  // thread-stepping in
+  // multithreaded programs.
+  if (m_stop_info_sp) {
+    StopReason stop_reason = m_stop_info_sp->GetStopReason();
+    if (stop_reason == lldb::eStopReasonBreakpoint) {
+      uint64_t value = m_stop_info_sp->GetValue();
+      lldb::RegisterContextSP reg_ctx_sp(GetRegisterContext());
+      if (reg_ctx_sp) {
+        lldb::addr_t pc = reg_ctx_sp->GetPC();
+        BreakpointSiteSP bp_site_sp =
+            GetProcess()->GetBreakpointSiteList().FindByAddress(pc);
+        if (bp_site_sp && static_cast<break_id_t>(value) == bp_site_sp->GetID())
+          return true;
+      }
+    }
+  }
+  return false;
+}
+
+Error Thread::StepIn(bool source_step,
+                     LazyBool step_in_avoids_code_without_debug_info,
+                     LazyBool step_out_avoids_code_without_debug_info)
+
+{
+  Error error;
+  Process *process = GetProcess().get();
+  if (StateIsStoppedState(process->GetState(), true)) {
+    StackFrameSP frame_sp = GetStackFrameAtIndex(0);
+    ThreadPlanSP new_plan_sp;
+    const lldb::RunMode run_mode = eOnlyThisThread;
+    const bool abort_other_plans = false;
+
+    if (source_step && frame_sp && frame_sp->HasDebugInformation()) {
+      SymbolContext sc(frame_sp->GetSymbolContext(eSymbolContextEverything));
+      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 {
+      new_plan_sp = QueueThreadPlanForStepSingleInstruction(
+          false, abort_other_plans, run_mode);
+    }
+
+    new_plan_sp->SetIsMasterPlan(true);
+    new_plan_sp->SetOkayToDiscard(false);
+
+    // Why do we need to set the current thread by ID here???
+    process->GetThreadList().SetSelectedThreadByID(GetID());
+    error = process->Resume();
+  } else {
+    error.SetErrorString("process not stopped");
+  }
+  return error;
+}
+
+Error Thread::StepOver(bool source_step,
+                       LazyBool step_out_avoids_code_without_debug_info) {
+  Error error;
+  Process *process = GetProcess().get();
+  if (StateIsStoppedState(process->GetState(), true)) {
+    StackFrameSP frame_sp = GetStackFrameAtIndex(0);
+    ThreadPlanSP new_plan_sp;
+
+    const lldb::RunMode run_mode = eOnlyThisThread;
+    const bool abort_other_plans = false;
+
+    if (source_step && frame_sp && frame_sp->HasDebugInformation()) {
+      SymbolContext sc(frame_sp->GetSymbolContext(eSymbolContextEverything));
+      new_plan_sp = QueueThreadPlanForStepOverRange(
+          abort_other_plans, sc.line_entry, sc, run_mode,
+          step_out_avoids_code_without_debug_info);
+    } else {
+      new_plan_sp = QueueThreadPlanForStepSingleInstruction(
+          true, abort_other_plans, run_mode);
+    }
+
+    new_plan_sp->SetIsMasterPlan(true);
+    new_plan_sp->SetOkayToDiscard(false);
+
+    // Why do we need to set the current thread by ID here???
+    process->GetThreadList().SetSelectedThreadByID(GetID());
+    error = process->Resume();
+  } else {
+    error.SetErrorString("process not stopped");
+  }
+  return error;
+}
+
+Error Thread::StepOut() {
+  Error error;
+  Process *process = GetProcess().get();
+  if (StateIsStoppedState(process->GetState(), true)) {
+    const bool first_instruction = false;
+    const bool stop_other_threads = false;
+    const bool abort_other_plans = false;
+
+    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);
+
+    // Why do we need to set the current thread by ID here???
+    process->GetThreadList().SetSelectedThreadByID(GetID());
+    error = process->Resume();
+  } else {
+    error.SetErrorString("process not stopped");
+  }
+  return error;
 }

Modified: lldb/trunk/source/Target/ThreadCollection.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadCollection.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Target/ThreadCollection.cpp (original)
+++ lldb/trunk/source/Target/ThreadCollection.cpp Tue Sep  6 15:57:50 2016
@@ -11,72 +11,56 @@
 #include <algorithm>
 #include <mutex>
 
-#include "lldb/Target/ThreadCollection.h"
 #include "lldb/Target/Thread.h"
+#include "lldb/Target/ThreadCollection.h"
 
 using namespace lldb;
 using namespace lldb_private;
 
-ThreadCollection::ThreadCollection() :
-    m_threads(),
-    m_mutex()
-{
-}
-
-ThreadCollection::ThreadCollection(collection threads) :
-    m_threads(threads),
-    m_mutex()
-{
-}
-
-void
-ThreadCollection::AddThread (const ThreadSP &thread_sp)
-{
-    std::lock_guard<std::recursive_mutex> guard(GetMutex());
-    m_threads.push_back (thread_sp);
-}
-
-void
-ThreadCollection::AddThreadSortedByIndexID (const ThreadSP &thread_sp)
-{
-    std::lock_guard<std::recursive_mutex> guard(GetMutex());
-    // Make sure we always keep the threads sorted by thread index ID
-    const uint32_t thread_index_id = thread_sp->GetIndexID();
-    if (m_threads.empty() || m_threads.back()->GetIndexID() < thread_index_id)
-        m_threads.push_back (thread_sp);
-    else
-    {
-        m_threads.insert(std::upper_bound(m_threads.begin(), m_threads.end(), thread_sp,
-                                          [] (const ThreadSP &lhs, const ThreadSP &rhs) -> bool
-                                          {
-                                              return lhs->GetIndexID() < rhs->GetIndexID();
-                                          }), thread_sp);
-    }
-}
+ThreadCollection::ThreadCollection() : m_threads(), m_mutex() {}
 
-void
-ThreadCollection::InsertThread (const lldb::ThreadSP &thread_sp, uint32_t idx)
-{
-    std::lock_guard<std::recursive_mutex> guard(GetMutex());
-    if (idx < m_threads.size())
-        m_threads.insert(m_threads.begin() + idx, thread_sp);
-    else
-        m_threads.push_back (thread_sp);
-}
-
-uint32_t
-ThreadCollection::GetSize ()
-{
-    std::lock_guard<std::recursive_mutex> guard(GetMutex());
-    return m_threads.size();
-}
+ThreadCollection::ThreadCollection(collection threads)
+    : m_threads(threads), m_mutex() {}
 
-ThreadSP
-ThreadCollection::GetThreadAtIndex (uint32_t idx)
-{
-    std::lock_guard<std::recursive_mutex> guard(GetMutex());
-    ThreadSP thread_sp;
-    if (idx < m_threads.size())
-        thread_sp = m_threads[idx];
-    return thread_sp;
+void ThreadCollection::AddThread(const ThreadSP &thread_sp) {
+  std::lock_guard<std::recursive_mutex> guard(GetMutex());
+  m_threads.push_back(thread_sp);
+}
+
+void ThreadCollection::AddThreadSortedByIndexID(const ThreadSP &thread_sp) {
+  std::lock_guard<std::recursive_mutex> guard(GetMutex());
+  // Make sure we always keep the threads sorted by thread index ID
+  const uint32_t thread_index_id = thread_sp->GetIndexID();
+  if (m_threads.empty() || m_threads.back()->GetIndexID() < thread_index_id)
+    m_threads.push_back(thread_sp);
+  else {
+    m_threads.insert(
+        std::upper_bound(m_threads.begin(), m_threads.end(), thread_sp,
+                         [](const ThreadSP &lhs, const ThreadSP &rhs) -> bool {
+                           return lhs->GetIndexID() < rhs->GetIndexID();
+                         }),
+        thread_sp);
+  }
+}
+
+void ThreadCollection::InsertThread(const lldb::ThreadSP &thread_sp,
+                                    uint32_t idx) {
+  std::lock_guard<std::recursive_mutex> guard(GetMutex());
+  if (idx < m_threads.size())
+    m_threads.insert(m_threads.begin() + idx, thread_sp);
+  else
+    m_threads.push_back(thread_sp);
+}
+
+uint32_t ThreadCollection::GetSize() {
+  std::lock_guard<std::recursive_mutex> guard(GetMutex());
+  return m_threads.size();
+}
+
+ThreadSP ThreadCollection::GetThreadAtIndex(uint32_t idx) {
+  std::lock_guard<std::recursive_mutex> guard(GetMutex());
+  ThreadSP thread_sp;
+  if (idx < m_threads.size())
+    thread_sp = m_threads[idx];
+  return thread_sp;
 }

Modified: lldb/trunk/source/Target/ThreadList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadList.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Target/ThreadList.cpp (original)
+++ lldb/trunk/source/Target/ThreadList.cpp Tue Sep  6 15:57:50 2016
@@ -17,856 +17,748 @@
 // Project includes
 #include "lldb/Core/Log.h"
 #include "lldb/Core/State.h"
+#include "lldb/Target/Process.h"
 #include "lldb/Target/RegisterContext.h"
-#include "lldb/Target/ThreadList.h"
 #include "lldb/Target/Thread.h"
+#include "lldb/Target/ThreadList.h"
 #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;
 
-ThreadList::ThreadList (Process *process) :
-    ThreadCollection(),
-    m_process (process),
-    m_stop_id (0),
-    m_selected_tid (LLDB_INVALID_THREAD_ID)
-{
-}
-
-ThreadList::ThreadList (const ThreadList &rhs) :
-    ThreadCollection(),
-    m_process (rhs.m_process),
-    m_stop_id (rhs.m_stop_id),
-    m_selected_tid ()
-{
-    // Use the assignment operator since it uses the mutex
-    *this = rhs;
-}
-
-const ThreadList&
-ThreadList::operator = (const ThreadList& rhs)
-{
-    if (this != &rhs)
-    {
-        // Lock both mutexes to make sure neither side changes anyone on us
-        // while the assignment occurs
-        std::lock_guard<std::recursive_mutex> guard(GetMutex());
-
-        m_process = rhs.m_process;
-        m_stop_id = rhs.m_stop_id;
-        m_threads = rhs.m_threads;
-        m_selected_tid = rhs.m_selected_tid;
-    }
-    return *this;
-}
-
+ThreadList::ThreadList(Process *process)
+    : ThreadCollection(), m_process(process), m_stop_id(0),
+      m_selected_tid(LLDB_INVALID_THREAD_ID) {}
 
-ThreadList::~ThreadList()
-{
-    // Clear the thread list. Clear will take the mutex lock
-    // which will ensure that if anyone is using the list
-    // they won't get it removed while using it.
-    Clear();
-}
-
-lldb::ThreadSP
-ThreadList::GetExpressionExecutionThread()
-{
-    if (m_expression_tid_stack.empty())
-        return GetSelectedThread();
-    ThreadSP expr_thread_sp = FindThreadByID(m_expression_tid_stack.back());
-    if (expr_thread_sp)
-        return expr_thread_sp;
-    else
-        return GetSelectedThread();
-}
-
-void
-ThreadList::PushExpressionExecutionThread(lldb::tid_t tid)
-{
-    m_expression_tid_stack.push_back(tid);
-}
-    
-void
-ThreadList::PopExpressionExecutionThread(lldb::tid_t tid)
-{
-    assert(m_expression_tid_stack.back() == tid);
-    m_expression_tid_stack.pop_back();
+ThreadList::ThreadList(const ThreadList &rhs)
+    : ThreadCollection(), m_process(rhs.m_process), m_stop_id(rhs.m_stop_id),
+      m_selected_tid() {
+  // Use the assignment operator since it uses the mutex
+  *this = rhs;
 }
 
-uint32_t
-ThreadList::GetStopID () const
-{
-    return m_stop_id;
-}
-
-void
-ThreadList::SetStopID (uint32_t stop_id)
-{
-    m_stop_id = stop_id;
-}
-
-uint32_t
-ThreadList::GetSize (bool can_update)
-{
+const ThreadList &ThreadList::operator=(const ThreadList &rhs) {
+  if (this != &rhs) {
+    // Lock both mutexes to make sure neither side changes anyone on us
+    // while the assignment occurs
     std::lock_guard<std::recursive_mutex> guard(GetMutex());
 
-    if (can_update)
-        m_process->UpdateThreadListIfNeeded();
-    return m_threads.size();
+    m_process = rhs.m_process;
+    m_stop_id = rhs.m_stop_id;
+    m_threads = rhs.m_threads;
+    m_selected_tid = rhs.m_selected_tid;
+  }
+  return *this;
 }
 
-ThreadSP
-ThreadList::GetThreadAtIndex (uint32_t idx, bool can_update)
-{
-    std::lock_guard<std::recursive_mutex> guard(GetMutex());
-
-    if (can_update)
-        m_process->UpdateThreadListIfNeeded();
-
-    ThreadSP thread_sp;
-    if (idx < m_threads.size())
-        thread_sp = m_threads[idx];
-    return thread_sp;
+ThreadList::~ThreadList() {
+  // Clear the thread list. Clear will take the mutex lock
+  // which will ensure that if anyone is using the list
+  // they won't get it removed while using it.
+  Clear();
 }
 
-ThreadSP
-ThreadList::FindThreadByID (lldb::tid_t tid, bool can_update)
-{
-    std::lock_guard<std::recursive_mutex> guard(GetMutex());
-
-    if (can_update)
-        m_process->UpdateThreadListIfNeeded();
-
-    ThreadSP thread_sp;
-    uint32_t idx = 0;
-    const uint32_t num_threads = m_threads.size();
-    for (idx = 0; idx < num_threads; ++idx)
-    {
-        if (m_threads[idx]->GetID() == tid)
-        {
-            thread_sp = m_threads[idx];
-            break;
-        }
-    }
-    return thread_sp;
+lldb::ThreadSP ThreadList::GetExpressionExecutionThread() {
+  if (m_expression_tid_stack.empty())
+    return GetSelectedThread();
+  ThreadSP expr_thread_sp = FindThreadByID(m_expression_tid_stack.back());
+  if (expr_thread_sp)
+    return expr_thread_sp;
+  else
+    return GetSelectedThread();
 }
 
-ThreadSP
-ThreadList::FindThreadByProtocolID (lldb::tid_t tid, bool can_update)
-{
-    std::lock_guard<std::recursive_mutex> guard(GetMutex());
-
-    if (can_update)
-        m_process->UpdateThreadListIfNeeded();
-    
-    ThreadSP thread_sp;
-    uint32_t idx = 0;
-    const uint32_t num_threads = m_threads.size();
-    for (idx = 0; idx < num_threads; ++idx)
-    {
-        if (m_threads[idx]->GetProtocolID() == tid)
-        {
-            thread_sp = m_threads[idx];
-            break;
-        }
-    }
-    return thread_sp;
+void ThreadList::PushExpressionExecutionThread(lldb::tid_t tid) {
+  m_expression_tid_stack.push_back(tid);
 }
 
-
-ThreadSP
-ThreadList::RemoveThreadByID (lldb::tid_t tid, bool can_update)
-{
-    std::lock_guard<std::recursive_mutex> guard(GetMutex());
-
-    if (can_update)
-        m_process->UpdateThreadListIfNeeded();
-    
-    ThreadSP thread_sp;
-    uint32_t idx = 0;
-    const uint32_t num_threads = m_threads.size();
-    for (idx = 0; idx < num_threads; ++idx)
-    {
-        if (m_threads[idx]->GetID() == tid)
-        {
-            thread_sp = m_threads[idx];
-            m_threads.erase(m_threads.begin()+idx);
-            break;
-        }
-    }
-    return thread_sp;
+void ThreadList::PopExpressionExecutionThread(lldb::tid_t tid) {
+  assert(m_expression_tid_stack.back() == tid);
+  m_expression_tid_stack.pop_back();
 }
 
-ThreadSP
-ThreadList::RemoveThreadByProtocolID (lldb::tid_t tid, bool can_update)
-{
-    std::lock_guard<std::recursive_mutex> guard(GetMutex());
-
-    if (can_update)
-        m_process->UpdateThreadListIfNeeded();
-    
-    ThreadSP thread_sp;
-    uint32_t idx = 0;
-    const uint32_t num_threads = m_threads.size();
-    for (idx = 0; idx < num_threads; ++idx)
-    {
-        if (m_threads[idx]->GetProtocolID() == tid)
-        {
-            thread_sp = m_threads[idx];
-            m_threads.erase(m_threads.begin()+idx);
-            break;
-        }
-    }
-    return thread_sp;
-}
+uint32_t ThreadList::GetStopID() const { return m_stop_id; }
 
-ThreadSP
-ThreadList::GetThreadSPForThreadPtr (Thread *thread_ptr)
-{
-    ThreadSP thread_sp;
-    if (thread_ptr)
-    {
-        std::lock_guard<std::recursive_mutex> guard(GetMutex());
-
-        uint32_t idx = 0;
-        const uint32_t num_threads = m_threads.size();
-        for (idx = 0; idx < num_threads; ++idx)
-        {
-            if (m_threads[idx].get() == thread_ptr)
-            {
-                thread_sp = m_threads[idx];
-                break;
-            }
-        }
-    }
-    return thread_sp;
-}
+void ThreadList::SetStopID(uint32_t stop_id) { m_stop_id = stop_id; }
 
+uint32_t ThreadList::GetSize(bool can_update) {
+  std::lock_guard<std::recursive_mutex> guard(GetMutex());
 
-
-ThreadSP
-ThreadList::FindThreadByIndexID (uint32_t index_id, bool can_update)
-{
-    std::lock_guard<std::recursive_mutex> guard(GetMutex());
-
-    if (can_update)
-        m_process->UpdateThreadListIfNeeded();
-
-    ThreadSP thread_sp;
-    const uint32_t num_threads = m_threads.size();
-    for (uint32_t idx = 0; idx < num_threads; ++idx)
-    {
-        if (m_threads[idx]->GetIndexID() == index_id)
-        {
-            thread_sp = m_threads[idx];
-            break;
-        }
-    }
-    return thread_sp;
+  if (can_update)
+    m_process->UpdateThreadListIfNeeded();
+  return m_threads.size();
 }
 
-bool
-ThreadList::ShouldStop (Event *event_ptr)
-{
-    // Running events should never stop, obviously...
-
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
-
-    // The ShouldStop method of the threads can do a whole lot of work,
-    // figuring out whether the thread plan conditions are met.  So we don't want
-    // to keep the ThreadList locked the whole time we are doing this.
-    // FIXME: It is possible that running code could cause new threads
-    // to be created.  If that happens, we will miss asking them whether
-    // they should stop.  This is not a big deal since we haven't had
-    // a chance to hang any interesting operations on those threads yet.
-    
-    collection threads_copy;
-    {
-        // Scope for locker
-        std::lock_guard<std::recursive_mutex> guard(GetMutex());
-
-        m_process->UpdateThreadListIfNeeded();
-        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);
-        }
+ThreadSP ThreadList::GetThreadAtIndex(uint32_t idx, bool can_update) {
+  std::lock_guard<std::recursive_mutex> guard(GetMutex());
 
-        // 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();
-
-    if (log)
-    {
-        log->PutCString("");
-        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;
-    
-    // If the event is an Interrupt event, then we're going to stop no matter what.  Otherwise, presume we won't stop.
-    bool should_stop = false;
-    if (Process::ProcessEventData::GetInterruptedFromEvent(event_ptr))
-    {
-        if (log)
-            log->Printf("ThreadList::%s handling interrupt event, should stop set to true", __FUNCTION__);
-        
-        should_stop = true;
-    }
-    
-    // Now we run through all the threads and get their stop info's.  We want to make sure to do this first before
-    // we start running the ShouldStop, because one thread's ShouldStop could destroy information (like deleting a
-    // thread specific breakpoint another thread had stopped at) which could lead us to compute the StopInfo incorrectly.
-    // We don't need to use it here, we just want to make sure it gets computed.
-    
-    for (pos = threads_copy.begin(); pos != end; ++pos)
-    {
-        ThreadSP thread_sp(*pos);
-        thread_sp->GetStopInfo();
-    }
-    
-    for (pos = threads_copy.begin(); pos != end; ++pos)
-    {
-        ThreadSP thread_sp(*pos);
-        
-        // We should never get a stop for which no thread had a stop reason, but sometimes we do see this -
-        // for instance when we first connect to a remote stub.  In that case we should stop, since we can't figure out
-        // the right thing to do and stopping gives the user control over what to do in this instance.
-        //
-        // Note, this causes a problem when you have a thread specific breakpoint, and a bunch of threads hit the breakpoint,
-        // but not the thread which we are waiting for.  All the threads that are not "supposed" to hit the breakpoint
-        // are marked as having no stop reason, which is right, they should not show a stop reason.  But that triggers this
-        // code and causes us to stop seemingly for no reason.
-        //
-        // Since the only way we ever saw this error was on first attach, I'm only going to trigger set did_anybody_stop_for_a_reason
-        // to true unless this is the first stop.
-        //
-        // If this becomes a problem, we'll have to have another StopReason like "StopInfoHidden" which will look invalid
-        // everywhere but at this check.
-    
-        if (thread_sp->GetProcess()->GetStopID() > 1)
-            did_anybody_stop_for_a_reason = true;
-        else
-            did_anybody_stop_for_a_reason |= thread_sp->ThreadStoppedForAReason();
-        
-        const bool thread_should_stop = thread_sp->ShouldStop(event_ptr);
-        if (thread_should_stop)
-            should_stop |= true;
-    }
-
-    if (!should_stop && !did_anybody_stop_for_a_reason)
-    {
-        should_stop = true;
-        if (log)
-            log->Printf ("ThreadList::%s we stopped but no threads had a stop reason, overriding should_stop and stopping.", __FUNCTION__);
-    }
-    
-    if (log)
-        log->Printf ("ThreadList::%s overall should_stop = %i", __FUNCTION__, should_stop);
-
-    if (should_stop)
-    {
-        for (pos = threads_copy.begin(); pos != end; ++pos)
-        {
-            ThreadSP thread_sp(*pos);
-            thread_sp->WillStop ();
-        }
-    }
+  if (can_update)
+    m_process->UpdateThreadListIfNeeded();
 
-    return should_stop;
+  ThreadSP thread_sp;
+  if (idx < m_threads.size())
+    thread_sp = m_threads[idx];
+  return thread_sp;
 }
 
-Vote
-ThreadList::ShouldReportStop (Event *event_ptr)
-{
-    std::lock_guard<std::recursive_mutex> guard(GetMutex());
+ThreadSP ThreadList::FindThreadByID(lldb::tid_t tid, bool can_update) {
+  std::lock_guard<std::recursive_mutex> guard(GetMutex());
 
-    Vote result = eVoteNoOpinion;
+  if (can_update)
     m_process->UpdateThreadListIfNeeded();
-    collection::iterator pos, end = m_threads.end();
 
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
-
-    if (log)
-        log->Printf ("ThreadList::%s %" PRIu64 " threads", __FUNCTION__, (uint64_t)m_threads.size());
-
-    // Run through the threads and ask whether we should report this event.
-    // For stopping, a YES vote wins over everything.  A NO vote wins over NO opinion.
-    for (pos = m_threads.begin(); pos != end; ++pos)
-    {
-        ThreadSP thread_sp(*pos);
-        const Vote vote = thread_sp->ShouldReportStop (event_ptr);
-        switch (vote)
-        {
-        case eVoteNoOpinion:
-            continue;
-
-        case eVoteYes:
-            result = eVoteYes;
-            break;
-
-        case eVoteNo:
-            if (result == eVoteNoOpinion)
-            {
-                result = eVoteNo;
-            }
-            else
-            {
-                if (log)
-                    log->Printf ("ThreadList::%s thread 0x%4.4" PRIx64 ": voted %s, but lost out because result was %s",
-                                 __FUNCTION__,
-                                 thread_sp->GetID (), 
-                                 GetVoteAsCString (vote),
-                                 GetVoteAsCString (result));
-            }
-            break;
-        }
+  ThreadSP thread_sp;
+  uint32_t idx = 0;
+  const uint32_t num_threads = m_threads.size();
+  for (idx = 0; idx < num_threads; ++idx) {
+    if (m_threads[idx]->GetID() == tid) {
+      thread_sp = m_threads[idx];
+      break;
     }
-    if (log)
-        log->Printf ("ThreadList::%s returning %s", __FUNCTION__, GetVoteAsCString (result));
-    return result;
+  }
+  return thread_sp;
 }
 
-void
-ThreadList::SetShouldReportStop (Vote vote)
-{
-    std::lock_guard<std::recursive_mutex> guard(GetMutex());
+ThreadSP ThreadList::FindThreadByProtocolID(lldb::tid_t tid, bool can_update) {
+  std::lock_guard<std::recursive_mutex> guard(GetMutex());
 
+  if (can_update)
     m_process->UpdateThreadListIfNeeded();
-    collection::iterator pos, end = m_threads.end();
-    for (pos = m_threads.begin(); pos != end; ++pos)
-    {
-        ThreadSP thread_sp(*pos);
-        thread_sp->SetShouldReportStop (vote);
+
+  ThreadSP thread_sp;
+  uint32_t idx = 0;
+  const uint32_t num_threads = m_threads.size();
+  for (idx = 0; idx < num_threads; ++idx) {
+    if (m_threads[idx]->GetProtocolID() == tid) {
+      thread_sp = m_threads[idx];
+      break;
     }
+  }
+  return thread_sp;
 }
 
-Vote
-ThreadList::ShouldReportRun (Event *event_ptr)
-{
+ThreadSP ThreadList::RemoveThreadByID(lldb::tid_t tid, bool can_update) {
+  std::lock_guard<std::recursive_mutex> guard(GetMutex());
 
-    std::lock_guard<std::recursive_mutex> guard(GetMutex());
-
-    Vote result = eVoteNoOpinion;
+  if (can_update)
     m_process->UpdateThreadListIfNeeded();
-    collection::iterator pos, end = m_threads.end();
 
-    // Run through the threads and ask whether we should report this event.
-    // The rule is NO vote wins over everything, a YES vote wins over no opinion.
+  ThreadSP thread_sp;
+  uint32_t idx = 0;
+  const uint32_t num_threads = m_threads.size();
+  for (idx = 0; idx < num_threads; ++idx) {
+    if (m_threads[idx]->GetID() == tid) {
+      thread_sp = m_threads[idx];
+      m_threads.erase(m_threads.begin() + idx);
+      break;
+    }
+  }
+  return thread_sp;
+}
+
+ThreadSP ThreadList::RemoveThreadByProtocolID(lldb::tid_t tid,
+                                              bool can_update) {
+  std::lock_guard<std::recursive_mutex> guard(GetMutex());
 
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
-    
-    for (pos = m_threads.begin(); pos != end; ++pos)
-    {
-        if ((*pos)->GetResumeState () != eStateSuspended)
-        {
-            switch ((*pos)->ShouldReportRun (event_ptr))
-            {
-                case eVoteNoOpinion:
-                    continue;
-                case eVoteYes:
-                    if (result == eVoteNoOpinion)
-                        result = eVoteYes;
-                    break;
-                case eVoteNo:
-                    if (log)
-                        log->Printf ("ThreadList::ShouldReportRun() thread %d (0x%4.4" PRIx64 ") says don't report.",
-                                     (*pos)->GetIndexID(), 
-                                     (*pos)->GetID());
-                    result = eVoteNo;
-                    break;
-            }
-        }
-    }
-    return result;
-}
+  if (can_update)
+    m_process->UpdateThreadListIfNeeded();
 
-void
-ThreadList::Clear()
-{
+  ThreadSP thread_sp;
+  uint32_t idx = 0;
+  const uint32_t num_threads = m_threads.size();
+  for (idx = 0; idx < num_threads; ++idx) {
+    if (m_threads[idx]->GetProtocolID() == tid) {
+      thread_sp = m_threads[idx];
+      m_threads.erase(m_threads.begin() + idx);
+      break;
+    }
+  }
+  return thread_sp;
+}
+
+ThreadSP ThreadList::GetThreadSPForThreadPtr(Thread *thread_ptr) {
+  ThreadSP thread_sp;
+  if (thread_ptr) {
     std::lock_guard<std::recursive_mutex> guard(GetMutex());
-    m_stop_id = 0;
-    m_threads.clear();
-    m_selected_tid = LLDB_INVALID_THREAD_ID;
-}
 
-void
-ThreadList::Destroy()
-{
-    std::lock_guard<std::recursive_mutex> guard(GetMutex());
+    uint32_t idx = 0;
     const uint32_t num_threads = m_threads.size();
-    for (uint32_t idx = 0; idx < num_threads; ++idx)
-    {
-        m_threads[idx]->DestroyThread();
+    for (idx = 0; idx < num_threads; ++idx) {
+      if (m_threads[idx].get() == thread_ptr) {
+        thread_sp = m_threads[idx];
+        break;
+      }
     }
+  }
+  return thread_sp;
 }
 
-void
-ThreadList::RefreshStateAfterStop ()
-{
-    std::lock_guard<std::recursive_mutex> guard(GetMutex());
+ThreadSP ThreadList::FindThreadByIndexID(uint32_t index_id, bool can_update) {
+  std::lock_guard<std::recursive_mutex> guard(GetMutex());
 
+  if (can_update)
     m_process->UpdateThreadListIfNeeded();
-    
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
-    if (log && log->GetVerbose())
-        log->Printf ("Turning off notification of new threads while single stepping a thread.");
 
-    collection::iterator pos, end = m_threads.end();
-    for (pos = m_threads.begin(); pos != end; ++pos)
-        (*pos)->RefreshStateAfterStop ();
-}
-
-void
-ThreadList::DiscardThreadPlans ()
-{
-    // You don't need to update the thread list here, because only threads
-    // that you currently know about have any thread plans.
+  ThreadSP thread_sp;
+  const uint32_t num_threads = m_threads.size();
+  for (uint32_t idx = 0; idx < num_threads; ++idx) {
+    if (m_threads[idx]->GetIndexID() == index_id) {
+      thread_sp = m_threads[idx];
+      break;
+    }
+  }
+  return thread_sp;
+}
+
+bool ThreadList::ShouldStop(Event *event_ptr) {
+  // Running events should never stop, obviously...
+
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
+
+  // The ShouldStop method of the threads can do a whole lot of work,
+  // figuring out whether the thread plan conditions are met.  So we don't want
+  // to keep the ThreadList locked the whole time we are doing this.
+  // FIXME: It is possible that running code could cause new threads
+  // to be created.  If that happens, we will miss asking them whether
+  // they should stop.  This is not a big deal since we haven't had
+  // a chance to hang any interesting operations on those threads yet.
+
+  collection threads_copy;
+  {
+    // Scope for locker
     std::lock_guard<std::recursive_mutex> guard(GetMutex());
 
-    collection::iterator pos, end = m_threads.end();
-    for (pos = m_threads.begin(); pos != end; ++pos)
-        (*pos)->DiscardThreadPlans (true);
-
-}
-
-bool
-ThreadList::WillResume ()
-{
-    // Run through the threads and perform their momentary actions.
-    // But we only do this for threads that are running, user suspended
-    // threads stay where they are.
-
-    std::lock_guard<std::recursive_mutex> guard(GetMutex());
     m_process->UpdateThreadListIfNeeded();
+    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();
+
+  if (log) {
+    log->PutCString("");
+    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;
+
+  // If the event is an Interrupt event, then we're going to stop no matter
+  // what.  Otherwise, presume we won't stop.
+  bool should_stop = false;
+  if (Process::ProcessEventData::GetInterruptedFromEvent(event_ptr)) {
+    if (log)
+      log->Printf(
+          "ThreadList::%s handling interrupt event, should stop set to true",
+          __FUNCTION__);
+
+    should_stop = true;
+  }
+
+  // Now we run through all the threads and get their stop info's.  We want to
+  // make sure to do this first before
+  // we start running the ShouldStop, because one thread's ShouldStop could
+  // destroy information (like deleting a
+  // thread specific breakpoint another thread had stopped at) which could lead
+  // us to compute the StopInfo incorrectly.
+  // We don't need to use it here, we just want to make sure it gets computed.
+
+  for (pos = threads_copy.begin(); pos != end; ++pos) {
+    ThreadSP thread_sp(*pos);
+    thread_sp->GetStopInfo();
+  }
+
+  for (pos = threads_copy.begin(); pos != end; ++pos) {
+    ThreadSP thread_sp(*pos);
+
+    // We should never get a stop for which no thread had a stop reason, but
+    // sometimes we do see this -
+    // for instance when we first connect to a remote stub.  In that case we
+    // should stop, since we can't figure out
+    // the right thing to do and stopping gives the user control over what to do
+    // in this instance.
+    //
+    // Note, this causes a problem when you have a thread specific breakpoint,
+    // and a bunch of threads hit the breakpoint,
+    // but not the thread which we are waiting for.  All the threads that are
+    // not "supposed" to hit the breakpoint
+    // are marked as having no stop reason, which is right, they should not show
+    // a stop reason.  But that triggers this
+    // code and causes us to stop seemingly for no reason.
+    //
+    // Since the only way we ever saw this error was on first attach, I'm only
+    // going to trigger set did_anybody_stop_for_a_reason
+    // to true unless this is the first stop.
+    //
+    // If this becomes a problem, we'll have to have another StopReason like
+    // "StopInfoHidden" which will look invalid
+    // everywhere but at this check.
 
-    collection::iterator pos, end = m_threads.end();
-
-    // See if any thread wants to run stopping others.  If it does, then we won't
-    // setup the other threads for resume, since they aren't going to get a chance
-    // to run.  This is necessary because the SetupForResume might add "StopOthers"
-    // plans which would then get to be part of the who-gets-to-run negotiation, but
-    // they're coming in after the fact, and the threads that are already set up should
-    // take priority.
-    
-    bool wants_solo_run = false;
-    
-    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())
-        {
-            if ((*pos)->IsOperatingSystemPluginThread() && !(*pos)->GetBackingThread())
-                continue;
-            wants_solo_run = true;
-            break;
-        }
-    }   
-
-    if (wants_solo_run)
-    {
-        Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
-        if (log && log->GetVerbose())
-            log->Printf ("Turning on notification of new threads while single stepping a thread.");
-        m_process->StartNoticingNewThreads();
-    }
-    else
-    {
-        Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
-        if (log && log->GetVerbose())
-            log->Printf ("Turning off notification of new threads while single stepping a thread.");
-        m_process->StopNoticingNewThreads();
-    }
-    
-    // Give all the threads that are likely to run a last chance to set up their state before we
-    // negotiate who is actually going to get a chance to run...
-    // Don't set to resume suspended threads, and if any thread wanted to stop others, only
-    // call setup on the threads that request StopOthers...
-    
-    for (pos = m_threads.begin(); pos != end; ++pos)
-    {
-        if ((*pos)->GetResumeState() != eStateSuspended
-            && (!wants_solo_run || (*pos)->GetCurrentPlan()->StopOthers()))
-        {
-            if ((*pos)->IsOperatingSystemPluginThread() && !(*pos)->GetBackingThread())
-                continue;
-            (*pos)->SetupForResume ();
-        }
-    }
-
-    // Now go through the threads and see if any thread wants to run just itself.
-    // if so then pick one and run it.
-    
-    ThreadList run_me_only_list (m_process);
-    
-    run_me_only_list.SetStopID(m_process->GetStopID());
-
-    bool run_only_current_thread = false;
-
-    for (pos = m_threads.begin(); pos != end; ++pos)
-    {
-        ThreadSP thread_sp(*pos);
-        if (thread_sp->GetResumeState() != eStateSuspended &&
-                 thread_sp->GetCurrentPlan()->StopOthers())
-        {
-            if ((*pos)->IsOperatingSystemPluginThread() && !(*pos)->GetBackingThread())
-                continue;
-
-            // You can't say "stop others" and also want yourself to be suspended.
-            assert (thread_sp->GetCurrentPlan()->RunState() != eStateSuspended);
-
-            if (thread_sp == GetSelectedThread())
-            {
-                // If the currently selected thread wants to run on its own, always let it.
-                run_only_current_thread = true;
-                run_me_only_list.Clear();
-                run_me_only_list.AddThread (thread_sp);
-                break;
-            }
-
-            run_me_only_list.AddThread (thread_sp);
-        }
-
-    }
-
-    bool need_to_resume = true;
-    
-    if (run_me_only_list.GetSize (false) == 0)
-    {
-        // Everybody runs as they wish:
-        for (pos = m_threads.begin(); pos != end; ++pos)
-        {
-            ThreadSP thread_sp(*pos);
-            StateType run_state;
-            if (thread_sp->GetResumeState() != eStateSuspended)
-                run_state = thread_sp->GetCurrentPlan()->RunState();
-            else
-                run_state = eStateSuspended;
-            if (!thread_sp->ShouldResume(run_state))
-                need_to_resume = false;
-        }
-    }
+    if (thread_sp->GetProcess()->GetStopID() > 1)
+      did_anybody_stop_for_a_reason = true;
     else
-    {
-        ThreadSP thread_to_run;
+      did_anybody_stop_for_a_reason |= thread_sp->ThreadStoppedForAReason();
 
-        if (run_only_current_thread)
-        {
-            thread_to_run = GetSelectedThread();
-        }
-        else if (run_me_only_list.GetSize (false) == 1)
-        {
-            thread_to_run = run_me_only_list.GetThreadAtIndex (0);
-        }
-        else
-        {
-            int random_thread = (int)
-                    ((run_me_only_list.GetSize (false) * (double) rand ()) / (RAND_MAX + 1.0));
-            thread_to_run = run_me_only_list.GetThreadAtIndex (random_thread);
-        }
+    const bool thread_should_stop = thread_sp->ShouldStop(event_ptr);
+    if (thread_should_stop)
+      should_stop |= true;
+  }
 
-        for (pos = m_threads.begin(); pos != end; ++pos)
-        {
-            ThreadSP thread_sp(*pos);
-            if (thread_sp == thread_to_run)
-            {
-                if (!thread_sp->ShouldResume(thread_sp->GetCurrentPlan()->RunState()))
-                    need_to_resume = false;
-            }
-            else
-                thread_sp->ShouldResume (eStateSuspended);
-        }
+  if (!should_stop && !did_anybody_stop_for_a_reason) {
+    should_stop = true;
+    if (log)
+      log->Printf("ThreadList::%s we stopped but no threads had a stop reason, "
+                  "overriding should_stop and stopping.",
+                  __FUNCTION__);
+  }
+
+  if (log)
+    log->Printf("ThreadList::%s overall should_stop = %i", __FUNCTION__,
+                should_stop);
+
+  if (should_stop) {
+    for (pos = threads_copy.begin(); pos != end; ++pos) {
+      ThreadSP thread_sp(*pos);
+      thread_sp->WillStop();
+    }
+  }
+
+  return should_stop;
+}
+
+Vote ThreadList::ShouldReportStop(Event *event_ptr) {
+  std::lock_guard<std::recursive_mutex> guard(GetMutex());
+
+  Vote result = eVoteNoOpinion;
+  m_process->UpdateThreadListIfNeeded();
+  collection::iterator pos, end = m_threads.end();
+
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
+
+  if (log)
+    log->Printf("ThreadList::%s %" PRIu64 " threads", __FUNCTION__,
+                (uint64_t)m_threads.size());
+
+  // Run through the threads and ask whether we should report this event.
+  // For stopping, a YES vote wins over everything.  A NO vote wins over NO
+  // opinion.
+  for (pos = m_threads.begin(); pos != end; ++pos) {
+    ThreadSP thread_sp(*pos);
+    const Vote vote = thread_sp->ShouldReportStop(event_ptr);
+    switch (vote) {
+    case eVoteNoOpinion:
+      continue;
+
+    case eVoteYes:
+      result = eVoteYes;
+      break;
+
+    case eVoteNo:
+      if (result == eVoteNoOpinion) {
+        result = eVoteNo;
+      } else {
+        if (log)
+          log->Printf("ThreadList::%s thread 0x%4.4" PRIx64
+                      ": voted %s, but lost out because result was %s",
+                      __FUNCTION__, thread_sp->GetID(), GetVoteAsCString(vote),
+                      GetVoteAsCString(result));
+      }
+      break;
+    }
+  }
+  if (log)
+    log->Printf("ThreadList::%s returning %s", __FUNCTION__,
+                GetVoteAsCString(result));
+  return result;
+}
+
+void ThreadList::SetShouldReportStop(Vote vote) {
+  std::lock_guard<std::recursive_mutex> guard(GetMutex());
+
+  m_process->UpdateThreadListIfNeeded();
+  collection::iterator pos, end = m_threads.end();
+  for (pos = m_threads.begin(); pos != end; ++pos) {
+    ThreadSP thread_sp(*pos);
+    thread_sp->SetShouldReportStop(vote);
+  }
+}
+
+Vote ThreadList::ShouldReportRun(Event *event_ptr) {
+
+  std::lock_guard<std::recursive_mutex> guard(GetMutex());
+
+  Vote result = eVoteNoOpinion;
+  m_process->UpdateThreadListIfNeeded();
+  collection::iterator pos, end = m_threads.end();
+
+  // Run through the threads and ask whether we should report this event.
+  // The rule is NO vote wins over everything, a YES vote wins over no opinion.
+
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
+
+  for (pos = m_threads.begin(); pos != end; ++pos) {
+    if ((*pos)->GetResumeState() != eStateSuspended) {
+      switch ((*pos)->ShouldReportRun(event_ptr)) {
+      case eVoteNoOpinion:
+        continue;
+      case eVoteYes:
+        if (result == eVoteNoOpinion)
+          result = eVoteYes;
+        break;
+      case eVoteNo:
+        if (log)
+          log->Printf("ThreadList::ShouldReportRun() thread %d (0x%4.4" PRIx64
+                      ") says don't report.",
+                      (*pos)->GetIndexID(), (*pos)->GetID());
+        result = eVoteNo;
+        break;
+      }
+    }
+  }
+  return result;
+}
+
+void ThreadList::Clear() {
+  std::lock_guard<std::recursive_mutex> guard(GetMutex());
+  m_stop_id = 0;
+  m_threads.clear();
+  m_selected_tid = LLDB_INVALID_THREAD_ID;
+}
+
+void ThreadList::Destroy() {
+  std::lock_guard<std::recursive_mutex> guard(GetMutex());
+  const uint32_t num_threads = m_threads.size();
+  for (uint32_t idx = 0; idx < num_threads; ++idx) {
+    m_threads[idx]->DestroyThread();
+  }
+}
+
+void ThreadList::RefreshStateAfterStop() {
+  std::lock_guard<std::recursive_mutex> guard(GetMutex());
+
+  m_process->UpdateThreadListIfNeeded();
+
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
+  if (log && log->GetVerbose())
+    log->Printf("Turning off notification of new threads while single stepping "
+                "a thread.");
+
+  collection::iterator pos, end = m_threads.end();
+  for (pos = m_threads.begin(); pos != end; ++pos)
+    (*pos)->RefreshStateAfterStop();
+}
+
+void ThreadList::DiscardThreadPlans() {
+  // You don't need to update the thread list here, because only threads
+  // that you currently know about have any thread plans.
+  std::lock_guard<std::recursive_mutex> guard(GetMutex());
+
+  collection::iterator pos, end = m_threads.end();
+  for (pos = m_threads.begin(); pos != end; ++pos)
+    (*pos)->DiscardThreadPlans(true);
+}
+
+bool ThreadList::WillResume() {
+  // Run through the threads and perform their momentary actions.
+  // But we only do this for threads that are running, user suspended
+  // threads stay where they are.
+
+  std::lock_guard<std::recursive_mutex> guard(GetMutex());
+  m_process->UpdateThreadListIfNeeded();
+
+  collection::iterator pos, end = m_threads.end();
+
+  // See if any thread wants to run stopping others.  If it does, then we won't
+  // setup the other threads for resume, since they aren't going to get a chance
+  // to run.  This is necessary because the SetupForResume might add
+  // "StopOthers"
+  // plans which would then get to be part of the who-gets-to-run negotiation,
+  // but
+  // they're coming in after the fact, and the threads that are already set up
+  // should
+  // take priority.
+
+  bool wants_solo_run = false;
+
+  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()) {
+      if ((*pos)->IsOperatingSystemPluginThread() &&
+          !(*pos)->GetBackingThread())
+        continue;
+      wants_solo_run = true;
+      break;
     }
+  }
 
-    return need_to_resume;
-}
+  if (wants_solo_run) {
+    Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
+    if (log && log->GetVerbose())
+      log->Printf("Turning on notification of new threads while single "
+                  "stepping a thread.");
+    m_process->StartNoticingNewThreads();
+  } else {
+    Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
+    if (log && log->GetVerbose())
+      log->Printf("Turning off notification of new threads while single "
+                  "stepping a thread.");
+    m_process->StopNoticingNewThreads();
+  }
+
+  // Give all the threads that are likely to run a last chance to set up their
+  // state before we
+  // negotiate who is actually going to get a chance to run...
+  // Don't set to resume suspended threads, and if any thread wanted to stop
+  // others, only
+  // call setup on the threads that request StopOthers...
+
+  for (pos = m_threads.begin(); pos != end; ++pos) {
+    if ((*pos)->GetResumeState() != eStateSuspended &&
+        (!wants_solo_run || (*pos)->GetCurrentPlan()->StopOthers())) {
+      if ((*pos)->IsOperatingSystemPluginThread() &&
+          !(*pos)->GetBackingThread())
+        continue;
+      (*pos)->SetupForResume();
+    }
+  }
+
+  // Now go through the threads and see if any thread wants to run just itself.
+  // if so then pick one and run it.
+
+  ThreadList run_me_only_list(m_process);
+
+  run_me_only_list.SetStopID(m_process->GetStopID());
+
+  bool run_only_current_thread = false;
+
+  for (pos = m_threads.begin(); pos != end; ++pos) {
+    ThreadSP thread_sp(*pos);
+    if (thread_sp->GetResumeState() != eStateSuspended &&
+        thread_sp->GetCurrentPlan()->StopOthers()) {
+      if ((*pos)->IsOperatingSystemPluginThread() &&
+          !(*pos)->GetBackingThread())
+        continue;
+
+      // You can't say "stop others" and also want yourself to be suspended.
+      assert(thread_sp->GetCurrentPlan()->RunState() != eStateSuspended);
+
+      if (thread_sp == GetSelectedThread()) {
+        // If the currently selected thread wants to run on its own, always let
+        // it.
+        run_only_current_thread = true;
+        run_me_only_list.Clear();
+        run_me_only_list.AddThread(thread_sp);
+        break;
+      }
+
+      run_me_only_list.AddThread(thread_sp);
+    }
+  }
+
+  bool need_to_resume = true;
+
+  if (run_me_only_list.GetSize(false) == 0) {
+    // Everybody runs as they wish:
+    for (pos = m_threads.begin(); pos != end; ++pos) {
+      ThreadSP thread_sp(*pos);
+      StateType run_state;
+      if (thread_sp->GetResumeState() != eStateSuspended)
+        run_state = thread_sp->GetCurrentPlan()->RunState();
+      else
+        run_state = eStateSuspended;
+      if (!thread_sp->ShouldResume(run_state))
+        need_to_resume = false;
+    }
+  } else {
+    ThreadSP thread_to_run;
+
+    if (run_only_current_thread) {
+      thread_to_run = GetSelectedThread();
+    } else if (run_me_only_list.GetSize(false) == 1) {
+      thread_to_run = run_me_only_list.GetThreadAtIndex(0);
+    } else {
+      int random_thread =
+          (int)((run_me_only_list.GetSize(false) * (double)rand()) /
+                (RAND_MAX + 1.0));
+      thread_to_run = run_me_only_list.GetThreadAtIndex(random_thread);
+    }
+
+    for (pos = m_threads.begin(); pos != end; ++pos) {
+      ThreadSP thread_sp(*pos);
+      if (thread_sp == thread_to_run) {
+        if (!thread_sp->ShouldResume(thread_sp->GetCurrentPlan()->RunState()))
+          need_to_resume = false;
+      } else
+        thread_sp->ShouldResume(eStateSuspended);
+    }
+  }
+
+  return need_to_resume;
+}
+
+void ThreadList::DidResume() {
+  std::lock_guard<std::recursive_mutex> guard(GetMutex());
+  collection::iterator pos, end = m_threads.end();
+  for (pos = m_threads.begin(); pos != end; ++pos) {
+    // Don't clear out threads that aren't going to get a chance to run, rather
+    // leave their state for the next time around.
+    ThreadSP thread_sp(*pos);
+    if (thread_sp->GetResumeState() != eStateSuspended)
+      thread_sp->DidResume();
+  }
+}
+
+void ThreadList::DidStop() {
+  std::lock_guard<std::recursive_mutex> guard(GetMutex());
+  collection::iterator pos, end = m_threads.end();
+  for (pos = m_threads.begin(); pos != end; ++pos) {
+    // Notify threads that the process just stopped.
+    // Note, this currently assumes that all threads in the list
+    // stop when the process stops.  In the future we will want to support
+    // a debugging model where some threads continue to run while others
+    // are stopped.  We either need to handle that somehow here or
+    // create a special thread list containing only threads which will
+    // stop in the code that calls this method (currently
+    // Process::SetPrivateState).
+    ThreadSP thread_sp(*pos);
+    if (StateIsRunningState(thread_sp->GetState()))
+      thread_sp->DidStop();
+  }
+}
+
+ThreadSP ThreadList::GetSelectedThread() {
+  std::lock_guard<std::recursive_mutex> guard(GetMutex());
+  ThreadSP thread_sp = FindThreadByID(m_selected_tid);
+  if (!thread_sp.get()) {
+    if (m_threads.size() == 0)
+      return thread_sp;
+    m_selected_tid = m_threads[0]->GetID();
+    thread_sp = m_threads[0];
+  }
+  return thread_sp;
+}
+
+bool ThreadList::SetSelectedThreadByID(lldb::tid_t tid, bool notify) {
+  std::lock_guard<std::recursive_mutex> guard(GetMutex());
+  ThreadSP selected_thread_sp(FindThreadByID(tid));
+  if (selected_thread_sp) {
+    m_selected_tid = tid;
+    selected_thread_sp->SetDefaultFileAndLineToSelectedFrame();
+  } else
+    m_selected_tid = LLDB_INVALID_THREAD_ID;
 
-void
-ThreadList::DidResume ()
-{
-    std::lock_guard<std::recursive_mutex> guard(GetMutex());
-    collection::iterator pos, end = m_threads.end();
-    for (pos = m_threads.begin(); pos != end; ++pos)
-    {
-        // Don't clear out threads that aren't going to get a chance to run, rather
-        // leave their state for the next time around.
-        ThreadSP thread_sp(*pos);
-        if (thread_sp->GetResumeState() != eStateSuspended)
-            thread_sp->DidResume ();
-    }
-}
+  if (notify)
+    NotifySelectedThreadChanged(m_selected_tid);
 
-void
-ThreadList::DidStop ()
-{
-    std::lock_guard<std::recursive_mutex> guard(GetMutex());
-    collection::iterator pos, end = m_threads.end();
-    for (pos = m_threads.begin(); pos != end; ++pos)
-    {
-        // Notify threads that the process just stopped.
-        // Note, this currently assumes that all threads in the list
-        // stop when the process stops.  In the future we will want to support
-        // a debugging model where some threads continue to run while others
-        // are stopped.  We either need to handle that somehow here or
-        // create a special thread list containing only threads which will
-        // stop in the code that calls this method (currently
-        // Process::SetPrivateState).
-        ThreadSP thread_sp(*pos);
-        if (StateIsRunningState(thread_sp->GetState()))
-            thread_sp->DidStop ();
-    }
+  return m_selected_tid != LLDB_INVALID_THREAD_ID;
 }
 
-ThreadSP
-ThreadList::GetSelectedThread ()
-{
-    std::lock_guard<std::recursive_mutex> guard(GetMutex());
-    ThreadSP thread_sp = FindThreadByID(m_selected_tid);
-    if (!thread_sp.get())
-    {
-        if (m_threads.size() == 0)
-            return thread_sp;
-        m_selected_tid = m_threads[0]->GetID();
-        thread_sp = m_threads[0];
-    }
-    return thread_sp;
-}
-
-bool
-ThreadList::SetSelectedThreadByID (lldb::tid_t tid, bool notify)
-{
-    std::lock_guard<std::recursive_mutex> guard(GetMutex());
-    ThreadSP selected_thread_sp(FindThreadByID(tid));
-    if  (selected_thread_sp)
-    {
-        m_selected_tid = tid;
-        selected_thread_sp->SetDefaultFileAndLineToSelectedFrame();
-    }
-    else
-        m_selected_tid = LLDB_INVALID_THREAD_ID;
-
-    if (notify)
-        NotifySelectedThreadChanged(m_selected_tid);
-    
-    return m_selected_tid != LLDB_INVALID_THREAD_ID;
-}
+bool ThreadList::SetSelectedThreadByIndexID(uint32_t index_id, bool notify) {
+  std::lock_guard<std::recursive_mutex> guard(GetMutex());
+  ThreadSP selected_thread_sp(FindThreadByIndexID(index_id));
+  if (selected_thread_sp.get()) {
+    m_selected_tid = selected_thread_sp->GetID();
+    selected_thread_sp->SetDefaultFileAndLineToSelectedFrame();
+  } else
+    m_selected_tid = LLDB_INVALID_THREAD_ID;
 
-bool
-ThreadList::SetSelectedThreadByIndexID (uint32_t index_id, bool notify)
-{
-    std::lock_guard<std::recursive_mutex> guard(GetMutex());
-    ThreadSP selected_thread_sp (FindThreadByIndexID(index_id));
-    if  (selected_thread_sp.get())
-    {
-        m_selected_tid = selected_thread_sp->GetID();
-        selected_thread_sp->SetDefaultFileAndLineToSelectedFrame();
-    }
-    else
-        m_selected_tid = LLDB_INVALID_THREAD_ID;
+  if (notify)
+    NotifySelectedThreadChanged(m_selected_tid);
 
-    if (notify)
-        NotifySelectedThreadChanged(m_selected_tid);
-    
-    return m_selected_tid != LLDB_INVALID_THREAD_ID;
-}
-
-void
-ThreadList::NotifySelectedThreadChanged (lldb::tid_t tid)
-{
-    ThreadSP selected_thread_sp (FindThreadByID(tid));
-    if (selected_thread_sp->EventTypeHasListeners(Thread::eBroadcastBitThreadSelected))
-        selected_thread_sp->BroadcastEvent(Thread::eBroadcastBitThreadSelected,
-                                           new Thread::ThreadEventData(selected_thread_sp));
-}
-
-void
-ThreadList::Update (ThreadList &rhs)
-{
-    if (this != &rhs)
-    {
-        // Lock both mutexes to make sure neither side changes anyone on us
-        // while the assignment occurs
-        std::lock_guard<std::recursive_mutex> guard(GetMutex());
-
-        m_process = rhs.m_process;
-        m_stop_id = rhs.m_stop_id;
-        m_threads.swap(rhs.m_threads);
-        m_selected_tid = rhs.m_selected_tid;
-        
-        
-        // Now we look for threads that we are done with and
-        // make sure to clear them up as much as possible so 
-        // anyone with a shared pointer will still have a reference,
-        // but the thread won't be of much use. Using std::weak_ptr
-        // for all backward references (such as a thread to a process)
-        // will eventually solve this issue for us, but for now, we
-        // need to work around the issue
-        collection::iterator rhs_pos, rhs_end = rhs.m_threads.end();
-        for (rhs_pos = rhs.m_threads.begin(); rhs_pos != rhs_end; ++rhs_pos)
-        {
-            const lldb::tid_t tid = (*rhs_pos)->GetID();
-            bool thread_is_alive = false;
-            const uint32_t num_threads = m_threads.size();
-            for (uint32_t idx = 0; idx < num_threads; ++idx)
-            {
-                ThreadSP backing_thread = m_threads[idx]->GetBackingThread();
-                if (m_threads[idx]->GetID() == tid || (backing_thread && backing_thread->GetID() == tid))
-                {
-                    thread_is_alive = true;
-                    break;
-                }
-            }
-            if (!thread_is_alive)
-                (*rhs_pos)->DestroyThread();
-        }        
-    }
+  return m_selected_tid != LLDB_INVALID_THREAD_ID;
 }
 
-void
-ThreadList::Flush ()
-{
-    std::lock_guard<std::recursive_mutex> guard(GetMutex());
-    collection::iterator pos, end = m_threads.end();
-    for (pos = m_threads.begin(); pos != end; ++pos)
-        (*pos)->Flush ();
-}
-
-std::recursive_mutex &
-ThreadList::GetMutex()
-{
-    return m_process->m_thread_mutex;
-}
-
-ThreadList::ExpressionExecutionThreadPusher::ExpressionExecutionThreadPusher (lldb::ThreadSP thread_sp) :
-    m_thread_list(nullptr),
-    m_tid(LLDB_INVALID_THREAD_ID)
-{
-    if (thread_sp)
-    {
-        m_tid = thread_sp->GetID();
-        m_thread_list = &thread_sp->GetProcess()->GetThreadList();
-        m_thread_list->PushExpressionExecutionThread(m_tid);
-    }
+void ThreadList::NotifySelectedThreadChanged(lldb::tid_t tid) {
+  ThreadSP selected_thread_sp(FindThreadByID(tid));
+  if (selected_thread_sp->EventTypeHasListeners(
+          Thread::eBroadcastBitThreadSelected))
+    selected_thread_sp->BroadcastEvent(
+        Thread::eBroadcastBitThreadSelected,
+        new Thread::ThreadEventData(selected_thread_sp));
+}
+
+void ThreadList::Update(ThreadList &rhs) {
+  if (this != &rhs) {
+    // Lock both mutexes to make sure neither side changes anyone on us
+    // while the assignment occurs
+    std::lock_guard<std::recursive_mutex> guard(GetMutex());
+
+    m_process = rhs.m_process;
+    m_stop_id = rhs.m_stop_id;
+    m_threads.swap(rhs.m_threads);
+    m_selected_tid = rhs.m_selected_tid;
+
+    // Now we look for threads that we are done with and
+    // make sure to clear them up as much as possible so
+    // anyone with a shared pointer will still have a reference,
+    // but the thread won't be of much use. Using std::weak_ptr
+    // for all backward references (such as a thread to a process)
+    // will eventually solve this issue for us, but for now, we
+    // need to work around the issue
+    collection::iterator rhs_pos, rhs_end = rhs.m_threads.end();
+    for (rhs_pos = rhs.m_threads.begin(); rhs_pos != rhs_end; ++rhs_pos) {
+      const lldb::tid_t tid = (*rhs_pos)->GetID();
+      bool thread_is_alive = false;
+      const uint32_t num_threads = m_threads.size();
+      for (uint32_t idx = 0; idx < num_threads; ++idx) {
+        ThreadSP backing_thread = m_threads[idx]->GetBackingThread();
+        if (m_threads[idx]->GetID() == tid ||
+            (backing_thread && backing_thread->GetID() == tid)) {
+          thread_is_alive = true;
+          break;
+        }
+      }
+      if (!thread_is_alive)
+        (*rhs_pos)->DestroyThread();
+    }
+  }
+}
+
+void ThreadList::Flush() {
+  std::lock_guard<std::recursive_mutex> guard(GetMutex());
+  collection::iterator pos, end = m_threads.end();
+  for (pos = m_threads.begin(); pos != end; ++pos)
+    (*pos)->Flush();
+}
+
+std::recursive_mutex &ThreadList::GetMutex() {
+  return m_process->m_thread_mutex;
+}
+
+ThreadList::ExpressionExecutionThreadPusher::ExpressionExecutionThreadPusher(
+    lldb::ThreadSP thread_sp)
+    : m_thread_list(nullptr), m_tid(LLDB_INVALID_THREAD_ID) {
+  if (thread_sp) {
+    m_tid = thread_sp->GetID();
+    m_thread_list = &thread_sp->GetProcess()->GetThreadList();
+    m_thread_list->PushExpressionExecutionThread(m_tid);
+  }
 }
-
-

Modified: lldb/trunk/source/Target/ThreadPlan.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlan.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Target/ThreadPlan.cpp (original)
+++ lldb/trunk/source/Target/ThreadPlan.cpp Tue Sep  6 15:57:50 2016
@@ -15,10 +15,10 @@
 #include "lldb/Core/Debugger.h"
 #include "lldb/Core/Log.h"
 #include "lldb/Core/State.h"
-#include "lldb/Target/RegisterContext.h"
-#include "lldb/Target/Thread.h"
 #include "lldb/Target/Process.h"
+#include "lldb/Target/RegisterContext.h"
 #include "lldb/Target/Target.h"
+#include "lldb/Target/Thread.h"
 #include "lldb/Utility/ConvertEnum.h"
 
 using namespace lldb;
@@ -27,21 +27,14 @@ using namespace lldb_private;
 //----------------------------------------------------------------------
 // ThreadPlan constructor
 //----------------------------------------------------------------------
-ThreadPlan::ThreadPlan(ThreadPlanKind kind, const char *name, Thread &thread, Vote stop_vote, Vote run_vote)
-    : m_thread(thread),
-      m_stop_vote(stop_vote),
-      m_run_vote(run_vote),
-      m_kind(kind),
-      m_name(name),
-      m_plan_complete_mutex(),
-      m_cached_plan_explains_stop(eLazyBoolCalculate),
-      m_plan_complete(false),
-      m_plan_private(false),
-      m_okay_to_discard(true),
-      m_is_master_plan(false),
-      m_plan_succeeded(true)
-{
-    SetID(GetNextID());
+ThreadPlan::ThreadPlan(ThreadPlanKind kind, const char *name, Thread &thread,
+                       Vote stop_vote, Vote run_vote)
+    : m_thread(thread), m_stop_vote(stop_vote), m_run_vote(run_vote),
+      m_kind(kind), m_name(name), m_plan_complete_mutex(),
+      m_cached_plan_explains_stop(eLazyBoolCalculate), m_plan_complete(false),
+      m_plan_private(false), m_okay_to_discard(true), m_is_master_plan(false),
+      m_plan_succeeded(true) {
+  SetID(GetNextID());
 }
 
 //----------------------------------------------------------------------
@@ -49,306 +42,249 @@ ThreadPlan::ThreadPlan(ThreadPlanKind ki
 //----------------------------------------------------------------------
 ThreadPlan::~ThreadPlan() = default;
 
-bool
-ThreadPlan::PlanExplainsStop (Event *event_ptr)
-{
-    if (m_cached_plan_explains_stop == eLazyBoolCalculate)
-    {
-        bool actual_value = DoPlanExplainsStop(event_ptr);
-        m_cached_plan_explains_stop = actual_value ? eLazyBoolYes : eLazyBoolNo;
-        return actual_value;
+bool ThreadPlan::PlanExplainsStop(Event *event_ptr) {
+  if (m_cached_plan_explains_stop == eLazyBoolCalculate) {
+    bool actual_value = DoPlanExplainsStop(event_ptr);
+    m_cached_plan_explains_stop = actual_value ? eLazyBoolYes : eLazyBoolNo;
+    return actual_value;
+  } else {
+    return m_cached_plan_explains_stop == eLazyBoolYes;
+  }
+}
+
+bool ThreadPlan::IsPlanComplete() {
+  std::lock_guard<std::recursive_mutex> guard(m_plan_complete_mutex);
+  return m_plan_complete;
+}
+
+void ThreadPlan::SetPlanComplete(bool success) {
+  std::lock_guard<std::recursive_mutex> guard(m_plan_complete_mutex);
+  m_plan_complete = true;
+  m_plan_succeeded = success;
+}
+
+bool ThreadPlan::MischiefManaged() {
+  std::lock_guard<std::recursive_mutex> guard(m_plan_complete_mutex);
+  // Mark the plan is complete, but don't override the success flag.
+  m_plan_complete = true;
+  return true;
+}
+
+Vote ThreadPlan::ShouldReportStop(Event *event_ptr) {
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
+
+  if (m_stop_vote == eVoteNoOpinion) {
+    ThreadPlan *prev_plan = GetPreviousPlan();
+    if (prev_plan) {
+      Vote prev_vote = prev_plan->ShouldReportStop(event_ptr);
+      if (log)
+        log->Printf("ThreadPlan::ShouldReportStop() returning previous thread "
+                    "plan vote: %s",
+                    GetVoteAsCString(prev_vote));
+      return prev_vote;
     }
-    else
-    {
-        return m_cached_plan_explains_stop == eLazyBoolYes;
+  }
+  if (log)
+    log->Printf("ThreadPlan::ShouldReportStop() returning vote: %s",
+                GetVoteAsCString(m_stop_vote));
+  return m_stop_vote;
+}
+
+Vote ThreadPlan::ShouldReportRun(Event *event_ptr) {
+  if (m_run_vote == eVoteNoOpinion) {
+    ThreadPlan *prev_plan = GetPreviousPlan();
+    if (prev_plan)
+      return prev_plan->ShouldReportRun(event_ptr);
+  }
+  return m_run_vote;
+}
+
+bool ThreadPlan::StopOthers() {
+  ThreadPlan *prev_plan;
+  prev_plan = GetPreviousPlan();
+  return (prev_plan == nullptr) ? false : prev_plan->StopOthers();
+}
+
+void ThreadPlan::SetStopOthers(bool new_value) {
+  // SetStopOthers doesn't work up the hierarchy.  You have to set the
+  // explicit ThreadPlan you want to affect.
+}
+
+bool ThreadPlan::WillResume(StateType resume_state, bool current_plan) {
+  m_cached_plan_explains_stop = eLazyBoolCalculate;
+
+  if (current_plan) {
+    Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
+
+    if (log) {
+      RegisterContext *reg_ctx = m_thread.GetRegisterContext().get();
+      assert(reg_ctx);
+      addr_t pc = reg_ctx->GetPC();
+      addr_t sp = reg_ctx->GetSP();
+      addr_t fp = reg_ctx->GetFP();
+      log->Printf(
+          "%s Thread #%u (0x%p): tid = 0x%4.4" PRIx64 ", pc = 0x%8.8" PRIx64
+          ", sp = 0x%8.8" PRIx64 ", fp = 0x%8.8" PRIx64 ", "
+          "plan = '%s', state = %s, stop others = %d",
+          __FUNCTION__, m_thread.GetIndexID(), static_cast<void *>(&m_thread),
+          m_thread.GetID(), static_cast<uint64_t>(pc),
+          static_cast<uint64_t>(sp), static_cast<uint64_t>(fp), m_name.c_str(),
+          StateAsCString(resume_state), StopOthers());
     }
+  }
+  return DoWillResume(resume_state, current_plan);
 }
 
-bool
-ThreadPlan::IsPlanComplete ()
-{
-    std::lock_guard<std::recursive_mutex> guard(m_plan_complete_mutex);
-    return m_plan_complete;
-}
-
-void
-ThreadPlan::SetPlanComplete (bool success)
-{
-    std::lock_guard<std::recursive_mutex> guard(m_plan_complete_mutex);
-    m_plan_complete = true;
-    m_plan_succeeded = success;
-}
-
-bool
-ThreadPlan::MischiefManaged ()
-{
-    std::lock_guard<std::recursive_mutex> guard(m_plan_complete_mutex);
-    // Mark the plan is complete, but don't override the success flag.
-    m_plan_complete = true;
-    return true;
+lldb::user_id_t ThreadPlan::GetNextID() {
+  static uint32_t g_nextPlanID = 0;
+  return ++g_nextPlanID;
 }
 
-Vote
-ThreadPlan::ShouldReportStop (Event *event_ptr)
-{
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
-
-    if (m_stop_vote == eVoteNoOpinion)
-    {
-        ThreadPlan *prev_plan = GetPreviousPlan ();
-        if (prev_plan)
-        {
-            Vote prev_vote = prev_plan->ShouldReportStop (event_ptr);
-            if (log)
-                log->Printf ("ThreadPlan::ShouldReportStop() returning previous thread plan vote: %s", 
-                             GetVoteAsCString (prev_vote));
-            return prev_vote;
-        }
-    }
-    if (log)
-        log->Printf ("ThreadPlan::ShouldReportStop() returning vote: %s", GetVoteAsCString (m_stop_vote));
-    return m_stop_vote;
-}
+void ThreadPlan::DidPush() {}
 
-Vote
-ThreadPlan::ShouldReportRun (Event *event_ptr)
-{
-    if (m_run_vote == eVoteNoOpinion)
-    {
-        ThreadPlan *prev_plan = GetPreviousPlan ();
-        if (prev_plan)
-            return prev_plan->ShouldReportRun (event_ptr);
-    }
-    return m_run_vote;
+void ThreadPlan::WillPop() {}
+
+bool ThreadPlan::OkayToDiscard() {
+  return IsMasterPlan() ? m_okay_to_discard : true;
 }
 
-bool
-ThreadPlan::StopOthers ()
-{
-    ThreadPlan *prev_plan;
-    prev_plan = GetPreviousPlan ();
-    return (prev_plan == nullptr) ? false : prev_plan->StopOthers();
-}
-
-void
-ThreadPlan::SetStopOthers (bool new_value)
-{
-	// SetStopOthers doesn't work up the hierarchy.  You have to set the 
-    // explicit ThreadPlan you want to affect.
-}
-
-bool
-ThreadPlan::WillResume (StateType resume_state, bool current_plan)
-{
-    m_cached_plan_explains_stop = eLazyBoolCalculate;
-    
-    if (current_plan)
-    {
-        Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
-
-        if (log)
-        {
-            RegisterContext *reg_ctx = m_thread.GetRegisterContext().get();
-            assert (reg_ctx);
-            addr_t pc = reg_ctx->GetPC();
-            addr_t sp = reg_ctx->GetSP();
-            addr_t fp = reg_ctx->GetFP();
-            log->Printf("%s Thread #%u (0x%p): tid = 0x%4.4" PRIx64 ", pc = 0x%8.8" PRIx64 ", sp = 0x%8.8" PRIx64 ", fp = 0x%8.8" PRIx64 ", "
-                        "plan = '%s', state = %s, stop others = %d", 
-                        __FUNCTION__, m_thread.GetIndexID(),
-                        static_cast<void*>(&m_thread), m_thread.GetID(),
-                        static_cast<uint64_t>(pc), static_cast<uint64_t>(sp),
-                        static_cast<uint64_t>(fp), m_name.c_str(),
-                        StateAsCString(resume_state), StopOthers());
-        }
-    }
-    return DoWillResume (resume_state, current_plan);
+lldb::StateType ThreadPlan::RunState() {
+  if (m_tracer_sp && m_tracer_sp->TracingEnabled() &&
+      m_tracer_sp->SingleStepEnabled())
+    return eStateStepping;
+  else
+    return GetPlanRunState();
 }
 
-lldb::user_id_t
-ThreadPlan::GetNextID()
-{
-    static uint32_t g_nextPlanID = 0;
-    return ++g_nextPlanID;
-}
-
-void
-ThreadPlan::DidPush()
-{
-}
-
-void
-ThreadPlan::WillPop()
-{
-}
-
-bool
-ThreadPlan::OkayToDiscard()
-{
-    return IsMasterPlan() ? m_okay_to_discard : true;
-}
-
-lldb::StateType
-ThreadPlan::RunState ()
-{
-    if (m_tracer_sp && m_tracer_sp->TracingEnabled() && m_tracer_sp->SingleStepEnabled())
-        return eStateStepping;
-    else
-        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;
-    }
+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
 //----------------------------------------------------------------------
 
-ThreadPlanNull::ThreadPlanNull (Thread &thread) :
-    ThreadPlan (ThreadPlan::eKindNull,
-                "Null Thread Plan",
-                thread,
-                eVoteNoOpinion,
-                eVoteNoOpinion)
-{
-}
+ThreadPlanNull::ThreadPlanNull(Thread &thread)
+    : ThreadPlan(ThreadPlan::eKindNull, "Null Thread Plan", thread,
+                 eVoteNoOpinion, eVoteNoOpinion) {}
 
 ThreadPlanNull::~ThreadPlanNull() = default;
 
-void
-ThreadPlanNull::GetDescription (Stream *s,
-                                lldb::DescriptionLevel level)
-{
-    s->PutCString("Null thread plan - thread has been destroyed.");
+void ThreadPlanNull::GetDescription(Stream *s, lldb::DescriptionLevel level) {
+  s->PutCString("Null thread plan - thread has been destroyed.");
 }
 
-bool
-ThreadPlanNull::ValidatePlan (Stream *error)
-{
+bool ThreadPlanNull::ValidatePlan(Stream *error) {
 #ifdef LLDB_CONFIGURATION_DEBUG
-    fprintf(stderr, "error: %s called on thread that has been destroyed (tid = 0x%" PRIx64 ", ptid = 0x%" PRIx64 ")",
-            LLVM_PRETTY_FUNCTION,
-            m_thread.GetID(),
-            m_thread.GetProtocolID());
+  fprintf(stderr,
+          "error: %s called on thread that has been destroyed (tid = 0x%" PRIx64
+          ", ptid = 0x%" PRIx64 ")",
+          LLVM_PRETTY_FUNCTION, m_thread.GetID(), m_thread.GetProtocolID());
 #else
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_THREAD));
-    if (log)
-        log->Error("%s called on thread that has been destroyed (tid = 0x%" PRIx64 ", ptid = 0x%" PRIx64 ")",
-                    LLVM_PRETTY_FUNCTION,
-                    m_thread.GetID(),
-                    m_thread.GetProtocolID());
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_THREAD));
+  if (log)
+    log->Error("%s called on thread that has been destroyed (tid = 0x%" PRIx64
+               ", ptid = 0x%" PRIx64 ")",
+               LLVM_PRETTY_FUNCTION, m_thread.GetID(),
+               m_thread.GetProtocolID());
 #endif
-    return true;
+  return true;
 }
 
-bool
-ThreadPlanNull::ShouldStop (Event *event_ptr)
-{
+bool ThreadPlanNull::ShouldStop(Event *event_ptr) {
 #ifdef LLDB_CONFIGURATION_DEBUG
-    fprintf(stderr, "error: %s called on thread that has been destroyed (tid = 0x%" PRIx64 ", ptid = 0x%" PRIx64 ")",
-            LLVM_PRETTY_FUNCTION,
-            m_thread.GetID(),
-            m_thread.GetProtocolID());
+  fprintf(stderr,
+          "error: %s called on thread that has been destroyed (tid = 0x%" PRIx64
+          ", ptid = 0x%" PRIx64 ")",
+          LLVM_PRETTY_FUNCTION, m_thread.GetID(), m_thread.GetProtocolID());
 #else
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_THREAD));
-    if (log)
-        log->Error("%s called on thread that has been destroyed (tid = 0x%" PRIx64 ", ptid = 0x%" PRIx64 ")",
-                    LLVM_PRETTY_FUNCTION,
-                    m_thread.GetID(),
-                    m_thread.GetProtocolID());
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_THREAD));
+  if (log)
+    log->Error("%s called on thread that has been destroyed (tid = 0x%" PRIx64
+               ", ptid = 0x%" PRIx64 ")",
+               LLVM_PRETTY_FUNCTION, m_thread.GetID(),
+               m_thread.GetProtocolID());
 #endif
-    return true;
+  return true;
 }
 
-bool
-ThreadPlanNull::WillStop ()
-{
+bool ThreadPlanNull::WillStop() {
 #ifdef LLDB_CONFIGURATION_DEBUG
-    fprintf(stderr, "error: %s called on thread that has been destroyed (tid = 0x%" PRIx64 ", ptid = 0x%" PRIx64 ")",
-            LLVM_PRETTY_FUNCTION,
-            m_thread.GetID(),
-            m_thread.GetProtocolID());
+  fprintf(stderr,
+          "error: %s called on thread that has been destroyed (tid = 0x%" PRIx64
+          ", ptid = 0x%" PRIx64 ")",
+          LLVM_PRETTY_FUNCTION, m_thread.GetID(), m_thread.GetProtocolID());
 #else
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_THREAD));
-    if (log)
-        log->Error("%s called on thread that has been destroyed (tid = 0x%" PRIx64 ", ptid = 0x%" PRIx64 ")",
-                    LLVM_PRETTY_FUNCTION,
-                    m_thread.GetID(),
-                    m_thread.GetProtocolID());
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_THREAD));
+  if (log)
+    log->Error("%s called on thread that has been destroyed (tid = 0x%" PRIx64
+               ", ptid = 0x%" PRIx64 ")",
+               LLVM_PRETTY_FUNCTION, m_thread.GetID(),
+               m_thread.GetProtocolID());
 #endif
-    return true;
+  return true;
 }
 
-bool
-ThreadPlanNull::DoPlanExplainsStop (Event *event_ptr)
-{
+bool ThreadPlanNull::DoPlanExplainsStop(Event *event_ptr) {
 #ifdef LLDB_CONFIGURATION_DEBUG
-    fprintf(stderr, "error: %s called on thread that has been destroyed (tid = 0x%" PRIx64 ", ptid = 0x%" PRIx64 ")",
-            LLVM_PRETTY_FUNCTION,
-            m_thread.GetID(),
-            m_thread.GetProtocolID());
+  fprintf(stderr,
+          "error: %s called on thread that has been destroyed (tid = 0x%" PRIx64
+          ", ptid = 0x%" PRIx64 ")",
+          LLVM_PRETTY_FUNCTION, m_thread.GetID(), m_thread.GetProtocolID());
 #else
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_THREAD));
-    if (log)
-        log->Error("%s called on thread that has been destroyed (tid = 0x%" PRIx64 ", ptid = 0x%" PRIx64 ")",
-                   LLVM_PRETTY_FUNCTION,
-                   m_thread.GetID(),
-                   m_thread.GetProtocolID());
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_THREAD));
+  if (log)
+    log->Error("%s called on thread that has been destroyed (tid = 0x%" PRIx64
+               ", ptid = 0x%" PRIx64 ")",
+               LLVM_PRETTY_FUNCTION, m_thread.GetID(),
+               m_thread.GetProtocolID());
 #endif
-    return true;
+  return true;
 }
 
 // The null plan is never done.
-bool
-ThreadPlanNull::MischiefManaged ()
-{
-    // The null plan is never done.
+bool ThreadPlanNull::MischiefManaged() {
+// The null plan is never done.
 #ifdef LLDB_CONFIGURATION_DEBUG
-    fprintf(stderr, "error: %s called on thread that has been destroyed (tid = 0x%" PRIx64 ", ptid = 0x%" PRIx64 ")",
-            LLVM_PRETTY_FUNCTION,
-            m_thread.GetID(),
-            m_thread.GetProtocolID());
+  fprintf(stderr,
+          "error: %s called on thread that has been destroyed (tid = 0x%" PRIx64
+          ", ptid = 0x%" PRIx64 ")",
+          LLVM_PRETTY_FUNCTION, m_thread.GetID(), m_thread.GetProtocolID());
 #else
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_THREAD));
-    if (log)
-        log->Error("%s called on thread that has been destroyed (tid = 0x%" PRIx64 ", ptid = 0x%" PRIx64 ")",
-                   LLVM_PRETTY_FUNCTION,
-                   m_thread.GetID(),
-                   m_thread.GetProtocolID());
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_THREAD));
+  if (log)
+    log->Error("%s called on thread that has been destroyed (tid = 0x%" PRIx64
+               ", ptid = 0x%" PRIx64 ")",
+               LLVM_PRETTY_FUNCTION, m_thread.GetID(),
+               m_thread.GetProtocolID());
 #endif
-    return false;
+  return false;
 }
 
-lldb::StateType
-ThreadPlanNull::GetPlanRunState ()
-{
-    // Not sure what to return here.  This is a dead thread.
+lldb::StateType ThreadPlanNull::GetPlanRunState() {
+// Not sure what to return here.  This is a dead thread.
 #ifdef LLDB_CONFIGURATION_DEBUG
-    fprintf(stderr, "error: %s called on thread that has been destroyed (tid = 0x%" PRIx64 ", ptid = 0x%" PRIx64 ")",
-            LLVM_PRETTY_FUNCTION,
-            m_thread.GetID(),
-            m_thread.GetProtocolID());
+  fprintf(stderr,
+          "error: %s called on thread that has been destroyed (tid = 0x%" PRIx64
+          ", ptid = 0x%" PRIx64 ")",
+          LLVM_PRETTY_FUNCTION, m_thread.GetID(), m_thread.GetProtocolID());
 #else
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_THREAD));
-    if (log)
-        log->Error("%s called on thread that has been destroyed (tid = 0x%" PRIx64 ", ptid = 0x%" PRIx64 ")",
-                   LLVM_PRETTY_FUNCTION,
-                   m_thread.GetID(),
-                   m_thread.GetProtocolID());
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_THREAD));
+  if (log)
+    log->Error("%s called on thread that has been destroyed (tid = 0x%" PRIx64
+               ", ptid = 0x%" PRIx64 ")",
+               LLVM_PRETTY_FUNCTION, m_thread.GetID(),
+               m_thread.GetProtocolID());
 #endif
-    return eStateRunning;
+  return eStateRunning;
 }

Modified: lldb/trunk/source/Target/ThreadPlanBase.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanBase.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Target/ThreadPlanBase.cpp (original)
+++ lldb/trunk/source/Target/ThreadPlanBase.cpp Tue Sep  6 15:57:50 2016
@@ -14,10 +14,10 @@
 // Other libraries and framework includes
 // Project includes
 //
-#include "lldb/Breakpoint/StoppointCallbackContext.h"
-#include "lldb/Breakpoint/BreakpointSite.h"
-#include "lldb/Breakpoint/BreakpointLocation.h"
 #include "lldb/Breakpoint/Breakpoint.h"
+#include "lldb/Breakpoint/BreakpointLocation.h"
+#include "lldb/Breakpoint/BreakpointSite.h"
+#include "lldb/Breakpoint/StoppointCallbackContext.h"
 #include "lldb/Core/Log.h"
 #include "lldb/Core/Stream.h"
 #include "lldb/Target/Process.h"
@@ -33,205 +33,180 @@ using namespace lldb_private;
 // FIXME: The "signal handling" policies should probably go here.
 //----------------------------------------------------------------------
 
-ThreadPlanBase::ThreadPlanBase (Thread &thread) :
-    ThreadPlan(ThreadPlan::eKindBase, "base plan", thread, eVoteYes, eVoteNoOpinion)
-{
-    // Set the tracer to a default tracer.
-    // FIXME: need to add a thread settings variable to pix various tracers...
+ThreadPlanBase::ThreadPlanBase(Thread &thread)
+    : ThreadPlan(ThreadPlan::eKindBase, "base plan", thread, eVoteYes,
+                 eVoteNoOpinion) {
+// Set the tracer to a default tracer.
+// FIXME: need to add a thread settings variable to pix various tracers...
 #define THREAD_PLAN_USE_ASSEMBLY_TRACER 1
 
 #ifdef THREAD_PLAN_USE_ASSEMBLY_TRACER
-    ThreadPlanTracerSP new_tracer_sp (new ThreadPlanAssemblyTracer (m_thread));
+  ThreadPlanTracerSP new_tracer_sp(new ThreadPlanAssemblyTracer(m_thread));
 #else
-    ThreadPlanTracerSP new_tracer_sp (new ThreadPlanTracer (m_thread));
+  ThreadPlanTracerSP new_tracer_sp(new ThreadPlanTracer(m_thread));
 #endif
-    new_tracer_sp->EnableTracing (m_thread.GetTraceEnabledState());
-    SetThreadPlanTracer(new_tracer_sp);
-    SetIsMasterPlan (true);
+  new_tracer_sp->EnableTracing(m_thread.GetTraceEnabledState());
+  SetThreadPlanTracer(new_tracer_sp);
+  SetIsMasterPlan(true);
 }
 
-ThreadPlanBase::~ThreadPlanBase ()
-{
+ThreadPlanBase::~ThreadPlanBase() {}
 
+void ThreadPlanBase::GetDescription(Stream *s, lldb::DescriptionLevel level) {
+  s->Printf("Base thread plan.");
 }
 
-void
-ThreadPlanBase::GetDescription (Stream *s, lldb::DescriptionLevel level)
-{
-    s->Printf ("Base thread plan.");
-}
+bool ThreadPlanBase::ValidatePlan(Stream *error) { return true; }
 
-bool
-ThreadPlanBase::ValidatePlan (Stream *error)
-{
+bool ThreadPlanBase::DoPlanExplainsStop(Event *event_ptr) {
+  // The base plan should defer to its tracer, since by default it
+  // always handles the stop.
+  if (TracerExplainsStop())
+    return false;
+  else
     return true;
 }
 
-bool
-ThreadPlanBase::DoPlanExplainsStop (Event *event_ptr)
-{
-    // The base plan should defer to its tracer, since by default it
-    // always handles the stop.
-    if (TracerExplainsStop())
-        return false;
+Vote ThreadPlanBase::ShouldReportStop(Event *event_ptr) {
+  StopInfoSP stop_info_sp = m_thread.GetStopInfo();
+  if (stop_info_sp) {
+    bool should_notify = stop_info_sp->ShouldNotify(event_ptr);
+    if (should_notify)
+      return eVoteYes;
     else
+      return eVoteNoOpinion;
+  } else
+    return eVoteNoOpinion;
+}
+
+bool ThreadPlanBase::ShouldStop(Event *event_ptr) {
+  m_stop_vote = eVoteYes;
+  m_run_vote = eVoteYes;
+
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
+
+  StopInfoSP stop_info_sp = GetPrivateStopInfo();
+  if (stop_info_sp) {
+    StopReason reason = stop_info_sp->GetStopReason();
+    switch (reason) {
+    case eStopReasonInvalid:
+    case eStopReasonNone:
+      // This
+      m_run_vote = eVoteNoOpinion;
+      m_stop_vote = eVoteNo;
+      return false;
+
+    case eStopReasonBreakpoint:
+    case eStopReasonWatchpoint:
+      if (stop_info_sp->ShouldStopSynchronous(event_ptr)) {
+        // If we are going to stop for a breakpoint, then unship the other plans
+        // at this point.  Don't force the discard, however, so Master plans can
+        // stay
+        // in place if they want to.
+        if (log)
+          log->Printf(
+              "Base plan discarding thread plans for thread tid = 0x%4.4" PRIx64
+              " (breakpoint hit.)",
+              m_thread.GetID());
+        m_thread.DiscardThreadPlans(false);
         return true;
-}
-
-Vote
-ThreadPlanBase::ShouldReportStop(Event *event_ptr)
-{
-    StopInfoSP stop_info_sp = m_thread.GetStopInfo ();
-    if (stop_info_sp)
-    {
-        bool should_notify = stop_info_sp->ShouldNotify(event_ptr);
-        if (should_notify)
-            return eVoteYes;
+      }
+      // If we aren't going to stop at this breakpoint, and it is internal,
+      // don't report this stop or the subsequent running event.
+      // Otherwise we will post the stopped & running, but the stopped event
+      // will get marked
+      // with "restarted" so the UI will know to wait and expect the consequent
+      // "running".
+      if (stop_info_sp->ShouldNotify(event_ptr)) {
+        m_stop_vote = eVoteYes;
+        m_run_vote = eVoteYes;
+      } else {
+        m_stop_vote = eVoteNo;
+        m_run_vote = eVoteNo;
+      }
+      return false;
+
+      // TODO: the break below was missing, was this intentional??? If so
+      // please mention it
+      break;
+
+    case eStopReasonException:
+      // If we crashed, discard thread plans and stop.  Don't force the discard,
+      // however,
+      // since on rerun the target may clean up this exception and continue
+      // normally from there.
+      if (log)
+        log->Printf(
+            "Base plan discarding thread plans for thread tid = 0x%4.4" PRIx64
+            " (exception: %s)",
+            m_thread.GetID(), stop_info_sp->GetDescription());
+      m_thread.DiscardThreadPlans(false);
+      return true;
+
+    case eStopReasonExec:
+      // If we crashed, discard thread plans and stop.  Don't force the discard,
+      // however,
+      // since on rerun the target may clean up this exception and continue
+      // normally from there.
+      if (log)
+        log->Printf(
+            "Base plan discarding thread plans for thread tid = 0x%4.4" PRIx64
+            " (exec.)",
+            m_thread.GetID());
+      m_thread.DiscardThreadPlans(false);
+      return true;
+
+    case eStopReasonThreadExiting:
+    case eStopReasonSignal:
+      if (stop_info_sp->ShouldStop(event_ptr)) {
+        if (log)
+          log->Printf(
+              "Base plan discarding thread plans for thread tid = 0x%4.4" PRIx64
+              " (signal: %s)",
+              m_thread.GetID(), stop_info_sp->GetDescription());
+        m_thread.DiscardThreadPlans(false);
+        return true;
+      } else {
+        // We're not going to stop, but while we are here, let's figure out
+        // whether to report this.
+        if (stop_info_sp->ShouldNotify(event_ptr))
+          m_stop_vote = eVoteYes;
         else
-            return eVoteNoOpinion;
-    }
-    else
-        return eVoteNoOpinion;
-}
+          m_stop_vote = eVoteNo;
+      }
+      return false;
 
-bool
-ThreadPlanBase::ShouldStop (Event *event_ptr)
-{
-    m_stop_vote = eVoteYes;
-    m_run_vote = eVoteYes;
-
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
-
-    StopInfoSP stop_info_sp = GetPrivateStopInfo ();
-    if (stop_info_sp)
-    {
-        StopReason reason = stop_info_sp->GetStopReason ();
-        switch (reason)
-        {
-        case eStopReasonInvalid:
-        case eStopReasonNone:
-            // This 
-            m_run_vote = eVoteNoOpinion;
-            m_stop_vote = eVoteNo;
-            return false;
-
-        case eStopReasonBreakpoint:
-        case eStopReasonWatchpoint:
-            if (stop_info_sp->ShouldStopSynchronous(event_ptr))
-            {
-                // If we are going to stop for a breakpoint, then unship the other plans
-                // at this point.  Don't force the discard, however, so Master plans can stay
-                // in place if they want to.
-                if (log)
-                    log->Printf("Base plan discarding thread plans for thread tid = 0x%4.4" PRIx64 " (breakpoint hit.)", m_thread.GetID());
-                m_thread.DiscardThreadPlans(false);
-                return true;
-            }
-            // If we aren't going to stop at this breakpoint, and it is internal, 
-            // don't report this stop or the subsequent running event.  
-            // Otherwise we will post the stopped & running, but the stopped event will get marked
-            // with "restarted" so the UI will know to wait and expect the consequent "running".
-            if (stop_info_sp->ShouldNotify (event_ptr))
-            {
-                m_stop_vote = eVoteYes;
-                m_run_vote = eVoteYes;
-            }
-            else
-            {
-                m_stop_vote = eVoteNo;
-                m_run_vote = eVoteNo;
-            }
-            return false;
-
-            // TODO: the break below was missing, was this intentional??? If so
-            // please mention it
-            break;
-
-        case eStopReasonException:
-            // If we crashed, discard thread plans and stop.  Don't force the discard, however,
-            // since on rerun the target may clean up this exception and continue normally from there.
-                if (log)
-                    log->Printf("Base plan discarding thread plans for thread tid = 0x%4.4" PRIx64 " (exception: %s)", m_thread.GetID(), stop_info_sp->GetDescription());
-            m_thread.DiscardThreadPlans(false);
-            return true;
-
-        case eStopReasonExec:
-            // If we crashed, discard thread plans and stop.  Don't force the discard, however,
-            // since on rerun the target may clean up this exception and continue normally from there.
-            if (log)
-                log->Printf("Base plan discarding thread plans for thread tid = 0x%4.4" PRIx64 " (exec.)", m_thread.GetID());
-            m_thread.DiscardThreadPlans(false);
-            return true;
-
-        case eStopReasonThreadExiting:
-        case eStopReasonSignal:
-            if (stop_info_sp->ShouldStop(event_ptr))
-            {
-                if (log)
-                    log->Printf("Base plan discarding thread plans for thread tid = 0x%4.4" PRIx64 " (signal: %s)", m_thread.GetID(), stop_info_sp->GetDescription());
-                m_thread.DiscardThreadPlans(false);
-                return true;
-            }
-            else
-            {
-                // We're not going to stop, but while we are here, let's figure out
-                // whether to report this.
-                 if (stop_info_sp->ShouldNotify(event_ptr))
-                    m_stop_vote = eVoteYes;
-                else
-                    m_stop_vote = eVoteNo;
-            }
-            return false;
-            
-        default:
-            return true;
-        }
-
-    }
-    else
-    {
-        m_run_vote = eVoteNoOpinion;
-        m_stop_vote = eVoteNo;
+    default:
+      return true;
     }
 
-    // If there's no explicit reason to stop, then we will continue.
-    return false;
-}
+  } else {
+    m_run_vote = eVoteNoOpinion;
+    m_stop_vote = eVoteNo;
+  }
 
-bool
-ThreadPlanBase::StopOthers ()
-{
-    return false;
+  // If there's no explicit reason to stop, then we will continue.
+  return false;
 }
 
-StateType
-ThreadPlanBase::GetPlanRunState ()
-{
-    return eStateRunning;
-}
+bool ThreadPlanBase::StopOthers() { return false; }
 
-bool
-ThreadPlanBase::WillStop ()
-{
-    return true;
-}
+StateType ThreadPlanBase::GetPlanRunState() { return eStateRunning; }
 
-bool 
-ThreadPlanBase::DoWillResume (lldb::StateType resume_state, bool current_plan)
-{
-    // Reset these to the default values so we don't set them wrong, then not get asked
-    // for a while, then return the wrong answer.
-    m_run_vote = eVoteNoOpinion;
-    m_stop_vote = eVoteNo;
-    return true;
-}
+bool ThreadPlanBase::WillStop() { return true; }
 
+bool ThreadPlanBase::DoWillResume(lldb::StateType resume_state,
+                                  bool current_plan) {
+  // Reset these to the default values so we don't set them wrong, then not get
+  // asked
+  // for a while, then return the wrong answer.
+  m_run_vote = eVoteNoOpinion;
+  m_stop_vote = eVoteNo;
+  return true;
+}
 
 // The base plan is never done.
-bool
-ThreadPlanBase::MischiefManaged ()
-{
-    // The base plan is never done.
-    return false;
+bool ThreadPlanBase::MischiefManaged() {
+  // The base plan is never done.
+  return false;
 }
-

Modified: lldb/trunk/source/Target/ThreadPlanCallFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanCallFunction.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Target/ThreadPlanCallFunction.cpp (original)
+++ lldb/trunk/source/Target/ThreadPlanCallFunction.cpp Tue Sep  6 15:57:50 2016
@@ -34,555 +34,482 @@ using namespace lldb_private;
 //----------------------------------------------------------------------
 // ThreadPlanCallFunction: Plan to call a single function
 //----------------------------------------------------------------------
-bool
-ThreadPlanCallFunction::ConstructorSetup (Thread &thread,
-                                          ABI *& abi,
-                                          lldb::addr_t &start_load_addr,
-                                          lldb::addr_t &function_load_addr)
-{
-    SetIsMasterPlan (true);
-    SetOkayToDiscard (false);
-    SetPrivate (true);
+bool ThreadPlanCallFunction::ConstructorSetup(
+    Thread &thread, ABI *&abi, lldb::addr_t &start_load_addr,
+    lldb::addr_t &function_load_addr) {
+  SetIsMasterPlan(true);
+  SetOkayToDiscard(false);
+  SetPrivate(true);
 
-    ProcessSP process_sp (thread.GetProcess());
-    if (!process_sp)
-        return false;
+  ProcessSP process_sp(thread.GetProcess());
+  if (!process_sp)
+    return false;
 
-    abi = process_sp->GetABI().get();
+  abi = process_sp->GetABI().get();
 
-    if (!abi)
-        return false;
+  if (!abi)
+    return false;
 
-    Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_STEP));
+  Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_STEP));
 
-    SetBreakpoints();
+  SetBreakpoints();
 
-    m_function_sp = thread.GetRegisterContext()->GetSP() - abi->GetRedZoneSize();
-    // If we can't read memory at the point of the process where we are planning to put our function, we're
-    // not going to get any further...
-    Error error;
-    process_sp->ReadUnsignedIntegerFromMemory(m_function_sp, 4, 0, error);
-    if (!error.Success())
-    {
-        m_constructor_errors.Printf ("Trying to put the stack in unreadable memory at: 0x%" PRIx64 ".", m_function_sp);
-        if (log)
-            log->Printf ("ThreadPlanCallFunction(%p): %s.",
-                         static_cast<void*>(this),
-                         m_constructor_errors.GetData());
-        return false;
-    }
+  m_function_sp = thread.GetRegisterContext()->GetSP() - abi->GetRedZoneSize();
+  // If we can't read memory at the point of the process where we are planning
+  // to put our function, we're
+  // not going to get any further...
+  Error error;
+  process_sp->ReadUnsignedIntegerFromMemory(m_function_sp, 4, 0, error);
+  if (!error.Success()) {
+    m_constructor_errors.Printf(
+        "Trying to put the stack in unreadable memory at: 0x%" PRIx64 ".",
+        m_function_sp);
+    if (log)
+      log->Printf("ThreadPlanCallFunction(%p): %s.", static_cast<void *>(this),
+                  m_constructor_errors.GetData());
+    return false;
+  }
 
-    Module *exe_module = GetTarget().GetExecutableModulePointer();
+  Module *exe_module = GetTarget().GetExecutableModulePointer();
 
-    if (exe_module == nullptr)
-    {
-        m_constructor_errors.Printf ("Can't execute code without an executable module.");
-        if (log)
-            log->Printf ("ThreadPlanCallFunction(%p): %s.",
-                         static_cast<void*>(this),
-                         m_constructor_errors.GetData());
-        return false;
-    }
-    else
-    {
-        ObjectFile *objectFile = exe_module->GetObjectFile();
-        if (!objectFile)
-        {
-            m_constructor_errors.Printf ("Could not find object file for module \"%s\".", 
-                                         exe_module->GetFileSpec().GetFilename().AsCString());
-
-            if (log)
-                log->Printf ("ThreadPlanCallFunction(%p): %s.",
-                             static_cast<void*>(this),
-                             m_constructor_errors.GetData());
-            return false;
-        }
+  if (exe_module == nullptr) {
+    m_constructor_errors.Printf(
+        "Can't execute code without an executable module.");
+    if (log)
+      log->Printf("ThreadPlanCallFunction(%p): %s.", static_cast<void *>(this),
+                  m_constructor_errors.GetData());
+    return false;
+  } else {
+    ObjectFile *objectFile = exe_module->GetObjectFile();
+    if (!objectFile) {
+      m_constructor_errors.Printf(
+          "Could not find object file for module \"%s\".",
+          exe_module->GetFileSpec().GetFilename().AsCString());
+
+      if (log)
+        log->Printf("ThreadPlanCallFunction(%p): %s.",
+                    static_cast<void *>(this), m_constructor_errors.GetData());
+      return false;
+    }
+
+    m_start_addr = objectFile->GetEntryPointAddress();
+    if (!m_start_addr.IsValid()) {
+      m_constructor_errors.Printf(
+          "Could not find entry point address for executable module \"%s\".",
+          exe_module->GetFileSpec().GetFilename().AsCString());
+      if (log)
+        log->Printf("ThreadPlanCallFunction(%p): %s.",
+                    static_cast<void *>(this), m_constructor_errors.GetData());
+      return false;
+    }
+  }
+
+  start_load_addr = m_start_addr.GetLoadAddress(&GetTarget());
+
+  // Checkpoint the thread state so we can restore it later.
+  if (log && log->GetVerbose())
+    ReportRegisterState("About to checkpoint thread before function call.  "
+                        "Original register state was:");
+
+  if (!thread.CheckpointThreadState(m_stored_thread_state)) {
+    m_constructor_errors.Printf("Setting up ThreadPlanCallFunction, failed to "
+                                "checkpoint thread state.");
+    if (log)
+      log->Printf("ThreadPlanCallFunction(%p): %s.", static_cast<void *>(this),
+                  m_constructor_errors.GetData());
+    return false;
+  }
+  function_load_addr = m_function_addr.GetLoadAddress(&GetTarget());
 
-        m_start_addr = objectFile->GetEntryPointAddress();
-        if (!m_start_addr.IsValid())
-        {
-            m_constructor_errors.Printf ("Could not find entry point address for executable module \"%s\".", 
-                                         exe_module->GetFileSpec().GetFilename().AsCString());
-            if (log)
-                log->Printf ("ThreadPlanCallFunction(%p): %s.",
-                             static_cast<void*>(this),
-                             m_constructor_errors.GetData());
-            return false;
-        }
-    }
+  return true;
+}
 
-    start_load_addr = m_start_addr.GetLoadAddress (&GetTarget());
+ThreadPlanCallFunction::ThreadPlanCallFunction(
+    Thread &thread, const Address &function, const CompilerType &return_type,
+    llvm::ArrayRef<addr_t> args, const EvaluateExpressionOptions &options)
+    : ThreadPlan(ThreadPlan::eKindCallFunction, "Call function plan", thread,
+                 eVoteNoOpinion, eVoteNoOpinion),
+      m_valid(false), m_stop_other_threads(options.GetStopOthers()),
+      m_unwind_on_error(options.DoesUnwindOnError()),
+      m_ignore_breakpoints(options.DoesIgnoreBreakpoints()),
+      m_debug_execution(options.GetDebug()),
+      m_trap_exceptions(options.GetTrapExceptions()), m_function_addr(function),
+      m_function_sp(0), m_takedown_done(false),
+      m_should_clear_objc_exception_bp(false),
+      m_should_clear_cxx_exception_bp(false),
+      m_stop_address(LLDB_INVALID_ADDRESS), m_return_type(return_type) {
+  lldb::addr_t start_load_addr = LLDB_INVALID_ADDRESS;
+  lldb::addr_t function_load_addr = LLDB_INVALID_ADDRESS;
+  ABI *abi = nullptr;
+
+  if (!ConstructorSetup(thread, abi, start_load_addr, function_load_addr))
+    return;
+
+  if (!abi->PrepareTrivialCall(thread, m_function_sp, function_load_addr,
+                               start_load_addr, args))
+    return;
+
+  ReportRegisterState("Function call was set up.  Register state was:");
+
+  m_valid = true;
+}
+
+ThreadPlanCallFunction::ThreadPlanCallFunction(
+    Thread &thread, const Address &function,
+    const EvaluateExpressionOptions &options)
+    : ThreadPlan(ThreadPlan::eKindCallFunction, "Call function plan", thread,
+                 eVoteNoOpinion, eVoteNoOpinion),
+      m_valid(false), m_stop_other_threads(options.GetStopOthers()),
+      m_unwind_on_error(options.DoesUnwindOnError()),
+      m_ignore_breakpoints(options.DoesIgnoreBreakpoints()),
+      m_debug_execution(options.GetDebug()),
+      m_trap_exceptions(options.GetTrapExceptions()), m_function_addr(function),
+      m_function_sp(0), m_takedown_done(false),
+      m_should_clear_objc_exception_bp(false),
+      m_should_clear_cxx_exception_bp(false),
+      m_stop_address(LLDB_INVALID_ADDRESS), m_return_type(CompilerType()) {}
+
+ThreadPlanCallFunction::~ThreadPlanCallFunction() {
+  DoTakedown(PlanSucceeded());
+}
+
+void ThreadPlanCallFunction::ReportRegisterState(const char *message) {
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP |
+                                                  LIBLLDB_LOG_VERBOSE));
+  if (log) {
+    StreamString strm;
+    RegisterContext *reg_ctx = m_thread.GetRegisterContext().get();
+
+    log->PutCString(message);
+
+    RegisterValue reg_value;
+
+    for (uint32_t reg_idx = 0, num_registers = reg_ctx->GetRegisterCount();
+         reg_idx < num_registers; ++reg_idx) {
+      const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoAtIndex(reg_idx);
+      if (reg_ctx->ReadRegister(reg_info, reg_value)) {
+        reg_value.Dump(&strm, reg_info, true, false, eFormatDefault);
+        strm.EOL();
+      }
+    }
+    log->PutCString(strm.GetData());
+  }
+}
 
-    // Checkpoint the thread state so we can restore it later.
-    if (log && log->GetVerbose())
-        ReportRegisterState ("About to checkpoint thread before function call.  Original register state was:");
+void ThreadPlanCallFunction::DoTakedown(bool success) {
+  Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_STEP));
 
-    if (!thread.CheckpointThreadState (m_stored_thread_state))
-    {
-        m_constructor_errors.Printf ("Setting up ThreadPlanCallFunction, failed to checkpoint thread state.");
-        if (log)
-            log->Printf ("ThreadPlanCallFunction(%p): %s.",
-                         static_cast<void*>(this),
-                         m_constructor_errors.GetData());
-        return false;
+  if (!m_valid) {
+    // Don't call DoTakedown if we were never valid to begin with.
+    if (log)
+      log->Printf("ThreadPlanCallFunction(%p): Log called on "
+                  "ThreadPlanCallFunction that was never valid.",
+                  static_cast<void *>(this));
+    return;
+  }
+
+  if (!m_takedown_done) {
+    if (success) {
+      SetReturnValue();
+    }
+    if (log)
+      log->Printf("ThreadPlanCallFunction(%p): DoTakedown called for thread "
+                  "0x%4.4" PRIx64 ", m_valid: %d complete: %d.\n",
+                  static_cast<void *>(this), m_thread.GetID(), m_valid,
+                  IsPlanComplete());
+    m_takedown_done = true;
+    m_stop_address =
+        m_thread.GetStackFrameAtIndex(0)->GetRegisterContext()->GetPC();
+    m_real_stop_info_sp = GetPrivateStopInfo();
+    if (!m_thread.RestoreRegisterStateFromCheckpoint(m_stored_thread_state)) {
+      if (log)
+        log->Printf("ThreadPlanCallFunction(%p): DoTakedown failed to restore "
+                    "register state",
+                    static_cast<void *>(this));
+    }
+    SetPlanComplete(success);
+    ClearBreakpoints();
+    if (log && log->GetVerbose())
+      ReportRegisterState("Restoring thread state after function call.  "
+                          "Restored register state:");
+  } else {
+    if (log)
+      log->Printf("ThreadPlanCallFunction(%p): DoTakedown called as no-op for "
+                  "thread 0x%4.4" PRIx64 ", m_valid: %d complete: %d.\n",
+                  static_cast<void *>(this), m_thread.GetID(), m_valid,
+                  IsPlanComplete());
+  }
+}
+
+void ThreadPlanCallFunction::WillPop() { DoTakedown(PlanSucceeded()); }
+
+void ThreadPlanCallFunction::GetDescription(Stream *s, DescriptionLevel level) {
+  if (level == eDescriptionLevelBrief) {
+    s->Printf("Function call thread plan");
+  } else {
+    TargetSP target_sp(m_thread.CalculateTarget());
+    s->Printf("Thread plan to call 0x%" PRIx64,
+              m_function_addr.GetLoadAddress(target_sp.get()));
+  }
+}
+
+bool ThreadPlanCallFunction::ValidatePlan(Stream *error) {
+  if (!m_valid) {
+    if (error) {
+      if (m_constructor_errors.GetSize() > 0)
+        error->PutCString(m_constructor_errors.GetData());
+      else
+        error->PutCString("Unknown error");
     }
-    function_load_addr = m_function_addr.GetLoadAddress (&GetTarget());
+    return false;
+  }
 
-    return true;
+  return true;
 }
 
-ThreadPlanCallFunction::ThreadPlanCallFunction (Thread &thread,
-                                                const Address &function,
-                                                const CompilerType &return_type,
-                                                llvm::ArrayRef<addr_t> args,
-                                                const EvaluateExpressionOptions &options) :
-    ThreadPlan (ThreadPlan::eKindCallFunction, "Call function plan", thread, eVoteNoOpinion, eVoteNoOpinion),
-    m_valid (false),
-    m_stop_other_threads (options.GetStopOthers()),
-    m_unwind_on_error (options.DoesUnwindOnError()),
-    m_ignore_breakpoints (options.DoesIgnoreBreakpoints()),
-    m_debug_execution (options.GetDebug()),
-    m_trap_exceptions (options.GetTrapExceptions()),
-    m_function_addr (function),
-    m_function_sp (0),
-    m_takedown_done (false),
-    m_should_clear_objc_exception_bp(false),
-    m_should_clear_cxx_exception_bp (false),
-    m_stop_address (LLDB_INVALID_ADDRESS),
-    m_return_type (return_type)
-{
-    lldb::addr_t start_load_addr = LLDB_INVALID_ADDRESS;
-    lldb::addr_t function_load_addr = LLDB_INVALID_ADDRESS;
-    ABI *abi = nullptr;
-
-    if (!ConstructorSetup (thread, abi, start_load_addr, function_load_addr))
-        return;
-
-    if (!abi->PrepareTrivialCall(thread,
-                                 m_function_sp,
-                                 function_load_addr,
-                                 start_load_addr,
-                                 args))
-        return;
-
-    ReportRegisterState ("Function call was set up.  Register state was:");
-
-    m_valid = true;    
-}
-
-ThreadPlanCallFunction::ThreadPlanCallFunction(Thread &thread,
-                                               const Address &function,
-                                               const EvaluateExpressionOptions &options) :
-    ThreadPlan(ThreadPlan::eKindCallFunction, "Call function plan", thread, eVoteNoOpinion, eVoteNoOpinion),
-    m_valid(false),
-    m_stop_other_threads(options.GetStopOthers()),
-    m_unwind_on_error(options.DoesUnwindOnError()),
-    m_ignore_breakpoints(options.DoesIgnoreBreakpoints()),
-    m_debug_execution(options.GetDebug()),
-    m_trap_exceptions(options.GetTrapExceptions()),
-    m_function_addr(function),
-    m_function_sp(0),
-    m_takedown_done(false),
-    m_should_clear_objc_exception_bp(false),
-    m_should_clear_cxx_exception_bp(false),
-    m_stop_address(LLDB_INVALID_ADDRESS),
-    m_return_type(CompilerType())
-{
-}
-
-ThreadPlanCallFunction::~ThreadPlanCallFunction ()
-{
-    DoTakedown(PlanSucceeded());
-}
-
-void
-ThreadPlanCallFunction::ReportRegisterState (const char *message)
-{
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP | LIBLLDB_LOG_VERBOSE));
-    if (log)
-    {
-        StreamString strm;
-        RegisterContext *reg_ctx = m_thread.GetRegisterContext().get();
-
-        log->PutCString(message);
-
-        RegisterValue reg_value;
-
-        for (uint32_t reg_idx = 0, num_registers = reg_ctx->GetRegisterCount();
-             reg_idx < num_registers;
-             ++reg_idx)
-        {
-            const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoAtIndex (reg_idx);
-            if (reg_ctx->ReadRegister(reg_info, reg_value))
-            {
-                reg_value.Dump(&strm, reg_info, true, false, eFormatDefault);
-                strm.EOL();
-            }
-        }
-        log->PutCString(strm.GetData());
-    }
+Vote ThreadPlanCallFunction::ShouldReportStop(Event *event_ptr) {
+  if (m_takedown_done || IsPlanComplete())
+    return eVoteYes;
+  else
+    return ThreadPlan::ShouldReportStop(event_ptr);
 }
 
-void
-ThreadPlanCallFunction::DoTakedown (bool success)
-{
-    Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_STEP));
+bool ThreadPlanCallFunction::DoPlanExplainsStop(Event *event_ptr) {
+  Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_STEP |
+                                                  LIBLLDB_LOG_PROCESS));
+  m_real_stop_info_sp = GetPrivateStopInfo();
 
-    if (!m_valid)
-    {
-        //Don't call DoTakedown if we were never valid to begin with.
-        if (log)
-            log->Printf ("ThreadPlanCallFunction(%p): Log called on ThreadPlanCallFunction that was never valid.",
-                         static_cast<void*>(this));
-        return;
-    }
+  // 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 && m_subplan_sp->PlanExplainsStop(event_ptr)) {
+    SetPlanComplete();
+    return true;
+  }
 
-    if (!m_takedown_done)
-    {
-        if (success)
-        {
-            SetReturnValue();
-        }
-        if (log)
-            log->Printf ("ThreadPlanCallFunction(%p): DoTakedown called for thread 0x%4.4" PRIx64 ", m_valid: %d complete: %d.\n",
-                         static_cast<void*>(this), m_thread.GetID(), m_valid,
-                         IsPlanComplete());
-        m_takedown_done = true;
-        m_stop_address = m_thread.GetStackFrameAtIndex(0)->GetRegisterContext()->GetPC();
-        m_real_stop_info_sp = GetPrivateStopInfo ();
-        if (!m_thread.RestoreRegisterStateFromCheckpoint(m_stored_thread_state))
-        {
-            if (log)
-                log->Printf("ThreadPlanCallFunction(%p): DoTakedown failed to restore register state",
-                            static_cast<void*>(this));
-        }
-        SetPlanComplete(success);
-        ClearBreakpoints();
-        if (log && log->GetVerbose())
-            ReportRegisterState ("Restoring thread state after function call.  Restored register state:");
-    }
-    else
-    {
-        if (log)
-            log->Printf ("ThreadPlanCallFunction(%p): DoTakedown called as no-op for thread 0x%4.4" PRIx64 ", m_valid: %d complete: %d.\n",
-                         static_cast<void*>(this), m_thread.GetID(), m_valid,
-                         IsPlanComplete());
-    }
-}
+  // Check if the breakpoint is one of ours.
 
-void
-ThreadPlanCallFunction::WillPop ()
-{
-    DoTakedown(PlanSucceeded());
-}
-
-void
-ThreadPlanCallFunction::GetDescription (Stream *s, DescriptionLevel level)
-{
-    if (level == eDescriptionLevelBrief)
-    {
-        s->Printf("Function call thread plan");
-    }
-    else
-    {
-        TargetSP target_sp (m_thread.CalculateTarget());
-        s->Printf("Thread plan to call 0x%" PRIx64, m_function_addr.GetLoadAddress(target_sp.get()));
-    }
-}
+  StopReason stop_reason;
+  if (!m_real_stop_info_sp)
+    stop_reason = eStopReasonNone;
+  else
+    stop_reason = m_real_stop_info_sp->GetStopReason();
+  if (log)
+    log->Printf(
+        "ThreadPlanCallFunction::PlanExplainsStop: Got stop reason - %s.",
+        Thread::StopReasonAsCString(stop_reason));
 
-bool
-ThreadPlanCallFunction::ValidatePlan (Stream *error)
-{
-    if (!m_valid)
-    {
-        if (error)
-        {
-            if (m_constructor_errors.GetSize() > 0)
-                error->PutCString (m_constructor_errors.GetData());
-            else
-                error->PutCString ("Unknown error");
+  if (stop_reason == eStopReasonBreakpoint && BreakpointsExplainStop())
+    return true;
+
+  // One more quirk here.  If this event was from Halt interrupting the target,
+  // then we should not consider
+  // ourselves complete.  Return true to acknowledge the stop.
+  if (Process::ProcessEventData::GetInterruptedFromEvent(event_ptr)) {
+    if (log)
+      log->Printf("ThreadPlanCallFunction::PlanExplainsStop: The event is an "
+                  "Interrupt, returning true.");
+    return true;
+  }
+  // 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());
+    uint64_t break_site_id = m_real_stop_info_sp->GetValue();
+    BreakpointSiteSP bp_site_sp;
+    if (process_sp)
+      bp_site_sp = process_sp->GetBreakpointSiteList().FindByID(break_site_id);
+    if (bp_site_sp) {
+      uint32_t num_owners = bp_site_sp->GetNumberOfOwners();
+      bool is_internal = true;
+      for (uint32_t i = 0; i < num_owners; i++) {
+        Breakpoint &bp = bp_site_sp->GetOwnerAtIndex(i)->GetBreakpoint();
+        if (log)
+          log->Printf("ThreadPlanCallFunction::PlanExplainsStop: hit "
+                      "breakpoint %d while calling function",
+                      bp.GetID());
+
+        if (!bp.IsInternal()) {
+          is_internal = false;
+          break;
         }
+      }
+      if (is_internal) {
+        if (log)
+          log->Printf("ThreadPlanCallFunction::PlanExplainsStop hit an "
+                      "internal breakpoint, not stopping.");
         return false;
+      }
     }
 
+    if (m_ignore_breakpoints) {
+      if (log)
+        log->Printf("ThreadPlanCallFunction::PlanExplainsStop: we are ignoring "
+                    "breakpoints, overriding breakpoint stop info ShouldStop, "
+                    "returning true");
+      m_real_stop_info_sp->OverrideShouldStop(false);
+      return true;
+    } else {
+      if (log)
+        log->Printf("ThreadPlanCallFunction::PlanExplainsStop: we are not "
+                    "ignoring breakpoints, overriding breakpoint stop info "
+                    "ShouldStop, returning true");
+      m_real_stop_info_sp->OverrideShouldStop(true);
+      return false;
+    }
+  } else if (!m_unwind_on_error) {
+    // If we don't want to discard this plan, than any stop we don't understand
+    // should be propagated up the stack.
+    return false;
+  } else {
+    // If the subplan is running, any crashes are attributable to us.
+    // If we want to discard the plan, then we say we explain the stop
+    // but if we are going to be discarded, let whoever is above us
+    // explain the stop.
+    // But don't discard the plan if the stop would restart itself (for instance
+    // if it is a
+    // signal that is set not to stop.  Check that here first.  We just say we
+    // explain the stop
+    // but aren't done and everything will continue on from there.
+
+    if (m_real_stop_info_sp &&
+        m_real_stop_info_sp->ShouldStopSynchronous(event_ptr)) {
+      SetPlanComplete(false);
+      return m_subplan_sp ? m_unwind_on_error : false;
+    } else
+      return true;
+  }
+}
+
+bool ThreadPlanCallFunction::ShouldStop(Event *event_ptr) {
+  // We do some computation in DoPlanExplainsStop that may or may not set the
+  // plan as complete.
+  // We need to do that here to make sure our state is correct.
+  DoPlanExplainsStop(event_ptr);
+
+  if (IsPlanComplete()) {
+    ReportRegisterState("Function completed.  Register state was:");
     return true;
+  } else {
+    return false;
+  }
 }
 
-Vote
-ThreadPlanCallFunction::ShouldReportStop(Event *event_ptr)
-{
-    if (m_takedown_done || IsPlanComplete())
-        return eVoteYes;
-    else
-        return ThreadPlan::ShouldReportStop(event_ptr);
-}
-
-bool
-ThreadPlanCallFunction::DoPlanExplainsStop (Event *event_ptr)
-{    
-    Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_STEP|LIBLLDB_LOG_PROCESS));
-    m_real_stop_info_sp = GetPrivateStopInfo ();
-    
-    // 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 && m_subplan_sp->PlanExplainsStop(event_ptr))
-    {
-        SetPlanComplete();
-        return true;
-    }
-    
-    // Check if the breakpoint is one of ours.
-    
-    StopReason stop_reason;
-    if (!m_real_stop_info_sp)
-        stop_reason = eStopReasonNone;
-    else
-        stop_reason = m_real_stop_info_sp->GetStopReason();
-    if (log)
-        log->Printf ("ThreadPlanCallFunction::PlanExplainsStop: Got stop reason - %s.", Thread::StopReasonAsCString(stop_reason));
+bool ThreadPlanCallFunction::StopOthers() { return m_stop_other_threads; }
 
-    if (stop_reason == eStopReasonBreakpoint && BreakpointsExplainStop())
-        return true;
-    
-    // One more quirk here.  If this event was from Halt interrupting the target, then we should not consider
-    // ourselves complete.  Return true to acknowledge the stop.
-    if (Process::ProcessEventData::GetInterruptedFromEvent(event_ptr))
-    {
-        if (log)
-            log->Printf ("ThreadPlanCallFunction::PlanExplainsStop: The event is an Interrupt, returning true.");
-        return true;
-    }
-    // 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());
-        uint64_t break_site_id = m_real_stop_info_sp->GetValue();
-        BreakpointSiteSP bp_site_sp;
-        if (process_sp)
-            bp_site_sp = process_sp->GetBreakpointSiteList().FindByID(break_site_id);
-        if (bp_site_sp)
-        {
-            uint32_t num_owners = bp_site_sp->GetNumberOfOwners();
-            bool is_internal = true;
-            for (uint32_t i = 0; i < num_owners; i++)
-            {
-                Breakpoint &bp = bp_site_sp->GetOwnerAtIndex(i)->GetBreakpoint();
-                if (log)
-                    log->Printf ("ThreadPlanCallFunction::PlanExplainsStop: hit breakpoint %d while calling function", bp.GetID());
-                
-                if (!bp.IsInternal())
-                {
-                    is_internal = false;
-                    break;
-                }
-            }
-            if (is_internal)
-            {
-                if (log)
-                    log->Printf ("ThreadPlanCallFunction::PlanExplainsStop hit an internal breakpoint, not stopping.");
-                return false;
-            }
-        }
+StateType ThreadPlanCallFunction::GetPlanRunState() { return eStateRunning; }
 
-        if (m_ignore_breakpoints)
-        {
-            if (log)
-                log->Printf("ThreadPlanCallFunction::PlanExplainsStop: we are ignoring breakpoints, overriding breakpoint stop info ShouldStop, returning true");
-            m_real_stop_info_sp->OverrideShouldStop(false);
-            return true;
-        }
-        else
-        {
-            if (log)
-                log->Printf("ThreadPlanCallFunction::PlanExplainsStop: we are not ignoring breakpoints, overriding breakpoint stop info ShouldStop, returning true");
-            m_real_stop_info_sp->OverrideShouldStop(true);
-            return false;
-        }
-    }
-    else if (!m_unwind_on_error)
-    {
-        // If we don't want to discard this plan, than any stop we don't understand should be propagated up the stack.
-        return false;
-    }
-    else
-    {
-        // If the subplan is running, any crashes are attributable to us.
-        // If we want to discard the plan, then we say we explain the stop
-        // but if we are going to be discarded, let whoever is above us
-        // explain the stop.
-        // But don't discard the plan if the stop would restart itself (for instance if it is a
-        // signal that is set not to stop.  Check that here first.  We just say we explain the stop
-        // but aren't done and everything will continue on from there.
-        
-        if (m_real_stop_info_sp && m_real_stop_info_sp->ShouldStopSynchronous(event_ptr))
-        {
-            SetPlanComplete(false);
-            return m_subplan_sp ? m_unwind_on_error : false;
-        }
-        else
-            return true;
-    }
-}
+void ThreadPlanCallFunction::DidPush() {
+  //#define SINGLE_STEP_EXPRESSIONS
 
-bool
-ThreadPlanCallFunction::ShouldStop (Event *event_ptr)
-{
-    // We do some computation in DoPlanExplainsStop that may or may not set the plan as complete.
-    // We need to do that here to make sure our state is correct.
-    DoPlanExplainsStop(event_ptr);
-    
-    if (IsPlanComplete())
-    {
-        ReportRegisterState ("Function completed.  Register state was:");
-        return true;
-    }
-    else
-    {
-        return false;
-    }
-}
+  // Now set the thread state to "no reason" so we don't run with whatever
+  // signal was outstanding...
+  // Wait till the plan is pushed so we aren't changing the stop info till we're
+  // about to run.
+
+  GetThread().SetStopInfoToNothing();
 
-bool
-ThreadPlanCallFunction::StopOthers ()
-{
-    return m_stop_other_threads;
-}
-
-StateType
-ThreadPlanCallFunction::GetPlanRunState ()
-{
-    return eStateRunning;
-}
-
-void
-ThreadPlanCallFunction::DidPush ()
-{
-//#define SINGLE_STEP_EXPRESSIONS
-    
-    // Now set the thread state to "no reason" so we don't run with whatever signal was outstanding...
-    // Wait till the plan is pushed so we aren't changing the stop info till we're about to run.
-    
-    GetThread().SetStopInfoToNothing();
-    
 #ifndef SINGLE_STEP_EXPRESSIONS
-    m_subplan_sp.reset(new ThreadPlanRunToAddress(m_thread, m_start_addr, m_stop_other_threads));
-    
-    m_thread.QueueThreadPlan(m_subplan_sp, false);
-    m_subplan_sp->SetPrivate (true);
+  m_subplan_sp.reset(
+      new ThreadPlanRunToAddress(m_thread, m_start_addr, m_stop_other_threads));
+
+  m_thread.QueueThreadPlan(m_subplan_sp, false);
+  m_subplan_sp->SetPrivate(true);
 #endif
 }
 
-bool
-ThreadPlanCallFunction::WillStop ()
-{
+bool ThreadPlanCallFunction::WillStop() { return true; }
+
+bool ThreadPlanCallFunction::MischiefManaged() {
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
+
+  if (IsPlanComplete()) {
+    if (log)
+      log->Printf("ThreadPlanCallFunction(%p): Completed call function plan.",
+                  static_cast<void *>(this));
+
+    ThreadPlan::MischiefManaged();
     return true;
+  } else {
+    return false;
+  }
 }
 
-bool
-ThreadPlanCallFunction::MischiefManaged ()
-{
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
-
-    if (IsPlanComplete())
-    {
-        if (log)
-            log->Printf("ThreadPlanCallFunction(%p): Completed call function plan.",
-                        static_cast<void*>(this));
+void ThreadPlanCallFunction::SetBreakpoints() {
+  ProcessSP process_sp(m_thread.CalculateProcess());
+  if (m_trap_exceptions && process_sp) {
+    m_cxx_language_runtime =
+        process_sp->GetLanguageRuntime(eLanguageTypeC_plus_plus);
+    m_objc_language_runtime = process_sp->GetLanguageRuntime(eLanguageTypeObjC);
 
-        ThreadPlan::MischiefManaged ();
-        return true;
+    if (m_cxx_language_runtime) {
+      m_should_clear_cxx_exception_bp =
+          !m_cxx_language_runtime->ExceptionBreakpointsAreSet();
+      m_cxx_language_runtime->SetExceptionBreakpoints();
     }
-    else
-    {
-        return false;
+    if (m_objc_language_runtime) {
+      m_should_clear_objc_exception_bp =
+          !m_objc_language_runtime->ExceptionBreakpointsAreSet();
+      m_objc_language_runtime->SetExceptionBreakpoints();
     }
+  }
 }
 
-void
-ThreadPlanCallFunction::SetBreakpoints ()
-{
-    ProcessSP process_sp (m_thread.CalculateProcess());
-    if (m_trap_exceptions && process_sp)
-    {
-        m_cxx_language_runtime = process_sp->GetLanguageRuntime(eLanguageTypeC_plus_plus);
-        m_objc_language_runtime = process_sp->GetLanguageRuntime(eLanguageTypeObjC);
-    
-        if (m_cxx_language_runtime)
-        {
-            m_should_clear_cxx_exception_bp = !m_cxx_language_runtime->ExceptionBreakpointsAreSet();
-            m_cxx_language_runtime->SetExceptionBreakpoints();
-        }
-        if (m_objc_language_runtime)
-        {
-            m_should_clear_objc_exception_bp = !m_objc_language_runtime->ExceptionBreakpointsAreSet();
-            m_objc_language_runtime->SetExceptionBreakpoints();
-        }
-    }
+void ThreadPlanCallFunction::ClearBreakpoints() {
+  if (m_trap_exceptions) {
+    if (m_cxx_language_runtime && m_should_clear_cxx_exception_bp)
+      m_cxx_language_runtime->ClearExceptionBreakpoints();
+    if (m_objc_language_runtime && m_should_clear_objc_exception_bp)
+      m_objc_language_runtime->ClearExceptionBreakpoints();
+  }
 }
 
-void
-ThreadPlanCallFunction::ClearBreakpoints ()
-{
-    if (m_trap_exceptions)
-    {
-        if (m_cxx_language_runtime && m_should_clear_cxx_exception_bp)
-            m_cxx_language_runtime->ClearExceptionBreakpoints();
-        if (m_objc_language_runtime && m_should_clear_objc_exception_bp)
-            m_objc_language_runtime->ClearExceptionBreakpoints();
+bool ThreadPlanCallFunction::BreakpointsExplainStop() {
+  StopInfoSP stop_info_sp = GetPrivateStopInfo();
+
+  if (m_trap_exceptions) {
+    if ((m_cxx_language_runtime &&
+         m_cxx_language_runtime->ExceptionBreakpointsExplainStop(
+             stop_info_sp)) ||
+        (m_objc_language_runtime &&
+         m_objc_language_runtime->ExceptionBreakpointsExplainStop(
+             stop_info_sp))) {
+      Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_STEP));
+      if (log)
+        log->Printf("ThreadPlanCallFunction::BreakpointsExplainStop - Hit an "
+                    "exception breakpoint, setting plan complete.");
+
+      SetPlanComplete(false);
+
+      // If the user has set the ObjC language breakpoint, it would normally get
+      // priority over our internal
+      // catcher breakpoint, but in this case we can't let that happen, so force
+      // the ShouldStop here.
+      stop_info_sp->OverrideShouldStop(true);
+      return true;
     }
+  }
+
+  return false;
 }
 
-bool
-ThreadPlanCallFunction::BreakpointsExplainStop()
-{
-    StopInfoSP stop_info_sp = GetPrivateStopInfo ();
-    
-    if (m_trap_exceptions)
-    {
-        if ((m_cxx_language_runtime &&
-                m_cxx_language_runtime->ExceptionBreakpointsExplainStop(stop_info_sp))
-           ||(m_objc_language_runtime &&
-                m_objc_language_runtime->ExceptionBreakpointsExplainStop(stop_info_sp)))
-        {
-            Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_STEP));
-            if (log)
-                log->Printf ("ThreadPlanCallFunction::BreakpointsExplainStop - Hit an exception breakpoint, setting plan complete.");
-            
-            SetPlanComplete(false);
-            
-            // If the user has set the ObjC language breakpoint, it would normally get priority over our internal
-            // catcher breakpoint, but in this case we can't let that happen, so force the ShouldStop here.
-            stop_info_sp->OverrideShouldStop (true);
-            return true;
-        }
-    }
-    
-    return false;
+void ThreadPlanCallFunction::SetStopOthers(bool new_value) {
+  m_subplan_sp->SetStopOthers(new_value);
 }
 
-void
-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() : nullptr;
-    if (abi && m_return_type.IsValid())
-    {
-        const bool persistent = false;
-        m_return_valobj_sp = abi->GetReturnValueObject(m_thread, m_return_type, persistent);
-    }
+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() : nullptr;
+  if (abi && m_return_type.IsValid()) {
+    const bool persistent = false;
+    m_return_valobj_sp =
+        abi->GetReturnValueObject(m_thread, m_return_type, persistent);
+  }
 }

Modified: lldb/trunk/source/Target/ThreadPlanCallFunctionUsingABI.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanCallFunctionUsingABI.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Target/ThreadPlanCallFunctionUsingABI.cpp (original)
+++ lldb/trunk/source/Target/ThreadPlanCallFunctionUsingABI.cpp Tue Sep  6 15:57:50 2016
@@ -24,63 +24,52 @@ using namespace lldb;
 using namespace lldb_private;
 
 //--------------------------------------------------------------------------------------------
-// ThreadPlanCallFunctionUsingABI: Plan to call a single function using the ABI instead of JIT
+// ThreadPlanCallFunctionUsingABI: Plan to call a single function using the ABI
+// instead of JIT
 //-------------------------------------------------------------------------------------------
-ThreadPlanCallFunctionUsingABI::ThreadPlanCallFunctionUsingABI (Thread &thread,
-                                                          const Address &function,
-                                                          llvm::Type &prototype,
-                                                          llvm::Type &return_type,
-                                                          llvm::ArrayRef<ABI::CallArgument> args,
-                                                          const EvaluateExpressionOptions &options) :
-     ThreadPlanCallFunction(thread,function,options),
-     m_return_type(return_type)
-{
-    lldb::addr_t start_load_addr = LLDB_INVALID_ADDRESS;
-    lldb::addr_t function_load_addr = LLDB_INVALID_ADDRESS;
-    ABI *abi = nullptr;
-
-    if (!ConstructorSetup(thread, abi, start_load_addr, function_load_addr))
-        return;
-
-    if (!abi->PrepareTrivialCall(thread,
-        m_function_sp,
-        function_load_addr,
-        start_load_addr,
-        prototype,
-        args))
-        return;
+ThreadPlanCallFunctionUsingABI::ThreadPlanCallFunctionUsingABI(
+    Thread &thread, const Address &function, llvm::Type &prototype,
+    llvm::Type &return_type, llvm::ArrayRef<ABI::CallArgument> args,
+    const EvaluateExpressionOptions &options)
+    : ThreadPlanCallFunction(thread, function, options),
+      m_return_type(return_type) {
+  lldb::addr_t start_load_addr = LLDB_INVALID_ADDRESS;
+  lldb::addr_t function_load_addr = LLDB_INVALID_ADDRESS;
+  ABI *abi = nullptr;
+
+  if (!ConstructorSetup(thread, abi, start_load_addr, function_load_addr))
+    return;
+
+  if (!abi->PrepareTrivialCall(thread, m_function_sp, function_load_addr,
+                               start_load_addr, prototype, args))
+    return;
 
-    ReportRegisterState("ABI Function call was set up.  Register state was:");
+  ReportRegisterState("ABI Function call was set up.  Register state was:");
 
-    m_valid = true;
+  m_valid = true;
 }
 
 ThreadPlanCallFunctionUsingABI::~ThreadPlanCallFunctionUsingABI() = default;
 
-void
-ThreadPlanCallFunctionUsingABI::GetDescription(Stream *s, DescriptionLevel level)
-{
-    if (level == eDescriptionLevelBrief)
-    {
-        s->Printf("Function call thread plan using ABI instead of JIT");
-    }
-    else
-    {
-        TargetSP target_sp(m_thread.CalculateTarget());
-        s->Printf("Thread plan to call 0x%" PRIx64" using ABI instead of JIT", m_function_addr.GetLoadAddress(target_sp.get()));
-    }
+void ThreadPlanCallFunctionUsingABI::GetDescription(Stream *s,
+                                                    DescriptionLevel level) {
+  if (level == eDescriptionLevelBrief) {
+    s->Printf("Function call thread plan using ABI instead of JIT");
+  } else {
+    TargetSP target_sp(m_thread.CalculateTarget());
+    s->Printf("Thread plan to call 0x%" PRIx64 " using ABI instead of JIT",
+              m_function_addr.GetLoadAddress(target_sp.get()));
+  }
 }
 
-void
-ThreadPlanCallFunctionUsingABI::SetReturnValue()
-{
-    ProcessSP process_sp(m_thread.GetProcess());
-    const ABI *abi = process_sp ? process_sp->GetABI().get() : nullptr;
-
-    // Ask the abi for the return value
-    if (abi)
-    {
-        const bool persistent = false;
-        m_return_valobj_sp = abi->GetReturnValueObject(m_thread, m_return_type, persistent);
-    }
+void ThreadPlanCallFunctionUsingABI::SetReturnValue() {
+  ProcessSP process_sp(m_thread.GetProcess());
+  const ABI *abi = process_sp ? process_sp->GetABI().get() : nullptr;
+
+  // Ask the abi for the return value
+  if (abi) {
+    const bool persistent = false;
+    m_return_valobj_sp =
+        abi->GetReturnValueObject(m_thread, m_return_type, persistent);
+  }
 }

Modified: lldb/trunk/source/Target/ThreadPlanCallOnFunctionExit.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanCallOnFunctionExit.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Target/ThreadPlanCallOnFunctionExit.cpp (original)
+++ lldb/trunk/source/Target/ThreadPlanCallOnFunctionExit.cpp Tue Sep  6 15:57:50 2016
@@ -12,108 +12,89 @@
 using namespace lldb;
 using namespace lldb_private;
 
-ThreadPlanCallOnFunctionExit::ThreadPlanCallOnFunctionExit(Thread &thread,
-                                                           const Callback
-                                                           &callback) :
-    ThreadPlan(ThreadPlanKind::eKindGeneric, "CallOnFunctionExit",
-               thread,
-               eVoteNoOpinion, eVoteNoOpinion // TODO check with Jim on these
-               ),
-    m_callback(callback)
-{
-    // We are not a user-generated plan.
-    SetIsMasterPlan(false);
-}
-
-void
-ThreadPlanCallOnFunctionExit::DidPush()
-{
-    // We now want to queue the "step out" thread plan so it executes
-    // and completes.
-
-    // Set stop vote to eVoteNo.
-    m_step_out_threadplan_sp = GetThread()
-        .QueueThreadPlanForStepOut(false,   // abort other plans
-                                   nullptr, // addr_context
-                                   true,    // first instruction
-                                   true,    // stop other threads
-                                   eVoteNo, // do not say "we're stopping"
-                                   eVoteNoOpinion, // don't care about
-                                                   // run state broadcasting
-                                   0,       // frame_idx
-                                   eLazyBoolCalculate // avoid code w/o debinfo
-                                   );
+ThreadPlanCallOnFunctionExit::ThreadPlanCallOnFunctionExit(
+    Thread &thread, const Callback &callback)
+    : ThreadPlan(ThreadPlanKind::eKindGeneric, "CallOnFunctionExit", thread,
+                 eVoteNoOpinion, eVoteNoOpinion // TODO check with Jim on these
+                 ),
+      m_callback(callback) {
+  // We are not a user-generated plan.
+  SetIsMasterPlan(false);
+}
+
+void ThreadPlanCallOnFunctionExit::DidPush() {
+  // We now want to queue the "step out" thread plan so it executes
+  // and completes.
+
+  // Set stop vote to eVoteNo.
+  m_step_out_threadplan_sp = GetThread().QueueThreadPlanForStepOut(
+      false,             // abort other plans
+      nullptr,           // addr_context
+      true,              // first instruction
+      true,              // stop other threads
+      eVoteNo,           // do not say "we're stopping"
+      eVoteNoOpinion,    // don't care about
+                         // run state broadcasting
+      0,                 // frame_idx
+      eLazyBoolCalculate // avoid code w/o debinfo
+      );
 }
 
 // -------------------------------------------------------------------------
 // ThreadPlan API
 // -------------------------------------------------------------------------
 
-void
-ThreadPlanCallOnFunctionExit::GetDescription(Stream *s, lldb::DescriptionLevel
-                                             level)
-{
-    if (!s)
-        return;
-    s->Printf("Running until completion of current function, then making "
-              "callback.");
-}
-
-bool
-ThreadPlanCallOnFunctionExit::ValidatePlan(Stream *error)
-{
-    // We'll say we're always good since I don't know what would make this
-    // invalid.
-    return true;
-}
-
-bool
-ThreadPlanCallOnFunctionExit::ShouldStop(Event *event_ptr)
-{
-    // If this is where we find out that an internal stop came in, then:
-    // Check if the step-out plan completed.  If it did, then we want to
-    // run the callback here (our reason for living...)
-    if (m_step_out_threadplan_sp &&
-        m_step_out_threadplan_sp->IsPlanComplete())
-    {
-        m_callback();
-
-        // We no longer need the pointer to the step-out thread plan.
-        m_step_out_threadplan_sp.reset();
-
-        // Indicate that this plan is done and can be discarded.
-        SetPlanComplete();
-
-        // We're done now, but we want to return false so that we
-        // don't cause the thread to really stop.
-    }
-
-    return false;
-}
-
-bool
-ThreadPlanCallOnFunctionExit::WillStop()
-{
-    // The code looks like the return value is ignored via ThreadList::
-    // ShouldStop().
-    // This is called when we really are going to stop.  We don't care
-    // and don't need to do anything here.
-    return false;
-}
-
-bool
-ThreadPlanCallOnFunctionExit::DoPlanExplainsStop (Event *event_ptr)
-{
-    // We don't ever explain a stop.  The only stop that is relevant
-    // to us directly is the step_out plan we added to do the heavy lifting
-    // of getting us past the current method.
-    return false;
-}
-
-lldb::StateType
-ThreadPlanCallOnFunctionExit::GetPlanRunState()
-{
-    // This value doesn't matter - we'll never be the top thread plan, so
-    // nobody will ask us this question.
-    return eStateRunning;
+void ThreadPlanCallOnFunctionExit::GetDescription(
+    Stream *s, lldb::DescriptionLevel level) {
+  if (!s)
+    return;
+  s->Printf("Running until completion of current function, then making "
+            "callback.");
+}
+
+bool ThreadPlanCallOnFunctionExit::ValidatePlan(Stream *error) {
+  // We'll say we're always good since I don't know what would make this
+  // invalid.
+  return true;
+}
+
+bool ThreadPlanCallOnFunctionExit::ShouldStop(Event *event_ptr) {
+  // If this is where we find out that an internal stop came in, then:
+  // Check if the step-out plan completed.  If it did, then we want to
+  // run the callback here (our reason for living...)
+  if (m_step_out_threadplan_sp && m_step_out_threadplan_sp->IsPlanComplete()) {
+    m_callback();
+
+    // We no longer need the pointer to the step-out thread plan.
+    m_step_out_threadplan_sp.reset();
+
+    // Indicate that this plan is done and can be discarded.
+    SetPlanComplete();
+
+    // We're done now, but we want to return false so that we
+    // don't cause the thread to really stop.
+  }
+
+  return false;
+}
+
+bool ThreadPlanCallOnFunctionExit::WillStop() {
+  // The code looks like the return value is ignored via ThreadList::
+  // ShouldStop().
+  // This is called when we really are going to stop.  We don't care
+  // and don't need to do anything here.
+  return false;
+}
+
+bool ThreadPlanCallOnFunctionExit::DoPlanExplainsStop(Event *event_ptr) {
+  // We don't ever explain a stop.  The only stop that is relevant
+  // to us directly is the step_out plan we added to do the heavy lifting
+  // of getting us past the current method.
+  return false;
+}
+
+lldb::StateType ThreadPlanCallOnFunctionExit::GetPlanRunState() {
+  // This value doesn't matter - we'll never be the top thread plan, so
+  // nobody will ask us this question.
+  return eStateRunning;
 }

Modified: lldb/trunk/source/Target/ThreadPlanCallUserExpression.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanCallUserExpression.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Target/ThreadPlanCallUserExpression.cpp (original)
+++ lldb/trunk/source/Target/ThreadPlanCallUserExpression.cpp Tue Sep  6 15:57:50 2016
@@ -1,4 +1,5 @@
-//===-- ThreadPlanCallUserExpression.cpp ------------------------------*- C++ -*-===//
+//===-- ThreadPlanCallUserExpression.cpp ------------------------------*- C++
+//-*-===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -38,91 +39,78 @@ using namespace lldb_private;
 // ThreadPlanCallUserExpression: Plan to call a single function
 //----------------------------------------------------------------------
 
-ThreadPlanCallUserExpression::ThreadPlanCallUserExpression (Thread &thread,
-                                                Address &function,
-                                                llvm::ArrayRef<lldb::addr_t> args,
-                                                const EvaluateExpressionOptions &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.
-    SetIsMasterPlan (true);
-    SetOkayToDiscard(false);
+ThreadPlanCallUserExpression::ThreadPlanCallUserExpression(
+    Thread &thread, Address &function, llvm::ArrayRef<lldb::addr_t> args,
+    const EvaluateExpressionOptions &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.
+  SetIsMasterPlan(true);
+  SetOkayToDiscard(false);
 }
 
-ThreadPlanCallUserExpression::~ThreadPlanCallUserExpression ()
-{
-}
+ThreadPlanCallUserExpression::~ThreadPlanCallUserExpression() {}
 
-void
-ThreadPlanCallUserExpression::GetDescription (Stream *s, lldb::DescriptionLevel level)
-{        
-    if (level == eDescriptionLevelBrief)
-        s->Printf("User Expression thread plan");
-    else
-        ThreadPlanCallFunction::GetDescription (s, level);
+void ThreadPlanCallUserExpression::GetDescription(
+    Stream *s, lldb::DescriptionLevel level) {
+  if (level == eDescriptionLevelBrief)
+    s->Printf("User Expression thread plan");
+  else
+    ThreadPlanCallFunction::GetDescription(s, level);
 }
 
-void
-ThreadPlanCallUserExpression::WillPop ()
-{
-    ThreadPlanCallFunction::WillPop();
-    if (m_user_expression_sp)
-        m_user_expression_sp.reset();
+void ThreadPlanCallUserExpression::WillPop() {
+  ThreadPlanCallFunction::WillPop();
+  if (m_user_expression_sp)
+    m_user_expression_sp.reset();
 }
 
-bool
-ThreadPlanCallUserExpression::MischiefManaged ()
-{
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
-
-    if (IsPlanComplete())
-    {
-        if (log)
-            log->Printf("ThreadPlanCallFunction(%p): Completed call function plan.",
-                        static_cast<void*>(this));
-
-        if (m_manage_materialization && PlanSucceeded() && m_user_expression_sp)
-        {
-            lldb::addr_t function_stack_top;
-            lldb::addr_t function_stack_bottom;
-            lldb::addr_t function_stack_pointer = GetFunctionStackPointer();
-
-            function_stack_bottom = function_stack_pointer - HostInfo::GetPageSize();
-            function_stack_top = function_stack_pointer;
-
-            DiagnosticManager diagnostics;
-
-            ExecutionContext exe_ctx(GetThread());
-
-            m_user_expression_sp->FinalizeJITExecution(diagnostics, exe_ctx, m_result_var_sp, function_stack_bottom,
-                                                       function_stack_top);
-        }
+bool ThreadPlanCallUserExpression::MischiefManaged() {
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
 
-        ThreadPlan::MischiefManaged();
-        return true;
-    }
-    else
-    {
-        return false;
-    }
-}
+  if (IsPlanComplete()) {
+    if (log)
+      log->Printf("ThreadPlanCallFunction(%p): Completed call function plan.",
+                  static_cast<void *>(this));
+
+    if (m_manage_materialization && PlanSucceeded() && m_user_expression_sp) {
+      lldb::addr_t function_stack_top;
+      lldb::addr_t function_stack_bottom;
+      lldb::addr_t function_stack_pointer = GetFunctionStackPointer();
 
-StopInfoSP
-ThreadPlanCallUserExpression::GetRealStopInfo()
-{
-    StopInfoSP stop_info_sp = ThreadPlanCallFunction::GetRealStopInfo();
-    
-    if (stop_info_sp)
-    {
-        lldb::addr_t addr = GetStopAddress();
-        DynamicCheckerFunctions *checkers = m_thread.GetProcess()->GetDynamicCheckers();
-        StreamString s;
-        
-        if (checkers && checkers->DoCheckersExplainStop(addr, s))
-            stop_info_sp->SetDescription(s.GetData());
+      function_stack_bottom = function_stack_pointer - HostInfo::GetPageSize();
+      function_stack_top = function_stack_pointer;
+
+      DiagnosticManager diagnostics;
+
+      ExecutionContext exe_ctx(GetThread());
+
+      m_user_expression_sp->FinalizeJITExecution(
+          diagnostics, exe_ctx, m_result_var_sp, function_stack_bottom,
+          function_stack_top);
     }
 
-    return stop_info_sp;
+    ThreadPlan::MischiefManaged();
+    return true;
+  } else {
+    return false;
+  }
+}
+
+StopInfoSP ThreadPlanCallUserExpression::GetRealStopInfo() {
+  StopInfoSP stop_info_sp = ThreadPlanCallFunction::GetRealStopInfo();
+
+  if (stop_info_sp) {
+    lldb::addr_t addr = GetStopAddress();
+    DynamicCheckerFunctions *checkers =
+        m_thread.GetProcess()->GetDynamicCheckers();
+    StreamString s;
+
+    if (checkers && checkers->DoCheckersExplainStop(addr, s))
+      stop_info_sp->SetDescription(s.GetData());
+  }
+
+  return stop_info_sp;
 }

Modified: lldb/trunk/source/Target/ThreadPlanPython.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanPython.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Target/ThreadPlanPython.cpp (original)
+++ lldb/trunk/source/Target/ThreadPlanPython.cpp Tue Sep  6 15:57:50 2016
@@ -18,12 +18,12 @@
 #include "lldb/Core/State.h"
 #include "lldb/Interpreter/CommandInterpreter.h"
 #include "lldb/Interpreter/ScriptInterpreter.h"
+#include "lldb/Target/Process.h"
 #include "lldb/Target/RegisterContext.h"
+#include "lldb/Target/Target.h"
 #include "lldb/Target/Thread.h"
 #include "lldb/Target/ThreadPlan.h"
 #include "lldb/Target/ThreadPlanPython.h"
-#include "lldb/Target/Process.h"
-#include "lldb/Target/Target.h"
 
 using namespace lldb;
 using namespace lldb_private;
@@ -32,181 +32,175 @@ using namespace lldb_private;
 // ThreadPlanPython
 //----------------------------------------------------------------------
 
-ThreadPlanPython::ThreadPlanPython (Thread &thread, const char *class_name) :
-    ThreadPlan (ThreadPlan::eKindPython,
-                "Python based Thread Plan",
-                thread,
-                eVoteNoOpinion,
-                eVoteNoOpinion),
-    m_class_name (class_name)
-{
-    SetIsMasterPlan (true);
-    SetOkayToDiscard (true);
-    SetPrivate (false);
-}
-
-ThreadPlanPython::~ThreadPlanPython ()
-{
-    // FIXME, do I need to decrement the ref count on this implementation object to make it go away?
-}
-
-bool
-ThreadPlanPython::ValidatePlan (Stream *error)
-{
-    // I have to postpone setting up the implementation till after the constructor because I need to call
-    // shared_from_this, which you can't do in the constructor.  So I'll do it here.
-    if (m_implementation_sp)
-        return true;
-    else
-        return false;
-}
-
-void
-ThreadPlanPython::DidPush()
-{
-    // We set up the script side in DidPush, so that it can push other plans in the constructor,
-    // and doesn't have to care about the details of DidPush.
-
-    if (!m_class_name.empty())
-    {
-        ScriptInterpreter *script_interp = m_thread.GetProcess()->GetTarget().GetDebugger().GetCommandInterpreter().GetScriptInterpreter();
-        if (script_interp)
-        {
-            m_implementation_sp = script_interp->CreateScriptedThreadPlan (m_class_name.c_str(), this->shared_from_this());
-        }
-    }
-}
-
-bool
-ThreadPlanPython::ShouldStop (Event *event_ptr)
-{
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_THREAD));
-    if (log)
-        log->Printf ("%s called on Python Thread Plan: %s )",
-                    LLVM_PRETTY_FUNCTION, m_class_name.c_str());
-
-    bool should_stop = true;
-    if (m_implementation_sp)
-    {
-        ScriptInterpreter *script_interp = m_thread.GetProcess()->GetTarget().GetDebugger().GetCommandInterpreter().GetScriptInterpreter();
-        if (script_interp)
-        {
-            bool script_error;
-            should_stop = script_interp->ScriptedThreadPlanShouldStop (m_implementation_sp, event_ptr, script_error);
-            if (script_error)
-                SetPlanComplete(false);
-        }
-    }
-    return should_stop;
-}
-
-bool
-ThreadPlanPython::IsPlanStale()
-{
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_THREAD));
-    if (log)
-        log->Printf ("%s called on Python Thread Plan: %s )",
-                    LLVM_PRETTY_FUNCTION, m_class_name.c_str());
-
-    bool is_stale = true;
-    if (m_implementation_sp)
-    {
-        ScriptInterpreter *script_interp = m_thread.GetProcess()->GetTarget().GetDebugger().GetCommandInterpreter().GetScriptInterpreter();
-        if (script_interp)
-        {
-            bool script_error;
-            is_stale = script_interp->ScriptedThreadPlanIsStale (m_implementation_sp, script_error);
-            if (script_error)
-                SetPlanComplete(false);
-        }
-    }
-    return is_stale;
-}
-
-bool
-ThreadPlanPython::DoPlanExplainsStop (Event *event_ptr)
-{
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_THREAD));
-    if (log)
-        log->Printf ("%s called on Python Thread Plan: %s )",
-                    LLVM_PRETTY_FUNCTION, m_class_name.c_str());
-
-    bool explains_stop = true;
-    if (m_implementation_sp)
-    {
-        ScriptInterpreter *script_interp = m_thread.GetProcess()->GetTarget().GetDebugger().GetCommandInterpreter().GetScriptInterpreter();
-        if (script_interp)
-        {
-            bool script_error;
-            explains_stop = script_interp->ScriptedThreadPlanExplainsStop (m_implementation_sp, event_ptr, script_error);
-            if (script_error)
-                SetPlanComplete(false);
-        }
-    }
-    return explains_stop;
-}
-
-bool
-ThreadPlanPython::MischiefManaged ()
-{
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_THREAD));
-    if (log)
-        log->Printf ("%s called on Python Thread Plan: %s )",
-                    LLVM_PRETTY_FUNCTION, m_class_name.c_str());
-    bool mischief_managed = true;
-    if (m_implementation_sp)
-    {
-        // I don't really need mischief_managed, since it's simpler to just call SetPlanComplete in should_stop.
-        mischief_managed = IsPlanComplete();
-        if (mischief_managed)
-            m_implementation_sp.reset();
-    }
-    return mischief_managed;
+ThreadPlanPython::ThreadPlanPython(Thread &thread, const char *class_name)
+    : ThreadPlan(ThreadPlan::eKindPython, "Python based Thread Plan", thread,
+                 eVoteNoOpinion, eVoteNoOpinion),
+      m_class_name(class_name) {
+  SetIsMasterPlan(true);
+  SetOkayToDiscard(true);
+  SetPrivate(false);
+}
+
+ThreadPlanPython::~ThreadPlanPython() {
+  // FIXME, do I need to decrement the ref count on this implementation object
+  // to make it go away?
+}
+
+bool ThreadPlanPython::ValidatePlan(Stream *error) {
+  // I have to postpone setting up the implementation till after the constructor
+  // because I need to call
+  // shared_from_this, which you can't do in the constructor.  So I'll do it
+  // here.
+  if (m_implementation_sp)
+    return true;
+  else
+    return false;
 }
 
-lldb::StateType
-ThreadPlanPython::GetPlanRunState ()
-{
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_THREAD));
-    if (log)
-        log->Printf ("%s called on Python Thread Plan: %s )",
-                     LLVM_PRETTY_FUNCTION,
-                     m_class_name.c_str());
-    lldb::StateType run_state = eStateRunning;
-    if (m_implementation_sp)
-    {
-        ScriptInterpreter *script_interp = m_thread.GetProcess()->GetTarget().GetDebugger().GetCommandInterpreter().GetScriptInterpreter();
-        if (script_interp)
-        {
-            bool script_error;
-            run_state = script_interp->ScriptedThreadPlanGetRunState (m_implementation_sp, script_error);
-        }
+void ThreadPlanPython::DidPush() {
+  // We set up the script side in DidPush, so that it can push other plans in
+  // the constructor,
+  // and doesn't have to care about the details of DidPush.
+
+  if (!m_class_name.empty()) {
+    ScriptInterpreter *script_interp = m_thread.GetProcess()
+                                           ->GetTarget()
+                                           .GetDebugger()
+                                           .GetCommandInterpreter()
+                                           .GetScriptInterpreter();
+    if (script_interp) {
+      m_implementation_sp = script_interp->CreateScriptedThreadPlan(
+          m_class_name.c_str(), this->shared_from_this());
+    }
+  }
+}
+
+bool ThreadPlanPython::ShouldStop(Event *event_ptr) {
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_THREAD));
+  if (log)
+    log->Printf("%s called on Python Thread Plan: %s )", LLVM_PRETTY_FUNCTION,
+                m_class_name.c_str());
+
+  bool should_stop = true;
+  if (m_implementation_sp) {
+    ScriptInterpreter *script_interp = m_thread.GetProcess()
+                                           ->GetTarget()
+                                           .GetDebugger()
+                                           .GetCommandInterpreter()
+                                           .GetScriptInterpreter();
+    if (script_interp) {
+      bool script_error;
+      should_stop = script_interp->ScriptedThreadPlanShouldStop(
+          m_implementation_sp, event_ptr, script_error);
+      if (script_error)
+        SetPlanComplete(false);
+    }
+  }
+  return should_stop;
+}
+
+bool ThreadPlanPython::IsPlanStale() {
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_THREAD));
+  if (log)
+    log->Printf("%s called on Python Thread Plan: %s )", LLVM_PRETTY_FUNCTION,
+                m_class_name.c_str());
+
+  bool is_stale = true;
+  if (m_implementation_sp) {
+    ScriptInterpreter *script_interp = m_thread.GetProcess()
+                                           ->GetTarget()
+                                           .GetDebugger()
+                                           .GetCommandInterpreter()
+                                           .GetScriptInterpreter();
+    if (script_interp) {
+      bool script_error;
+      is_stale = script_interp->ScriptedThreadPlanIsStale(m_implementation_sp,
+                                                          script_error);
+      if (script_error)
+        SetPlanComplete(false);
+    }
+  }
+  return is_stale;
+}
+
+bool ThreadPlanPython::DoPlanExplainsStop(Event *event_ptr) {
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_THREAD));
+  if (log)
+    log->Printf("%s called on Python Thread Plan: %s )", LLVM_PRETTY_FUNCTION,
+                m_class_name.c_str());
+
+  bool explains_stop = true;
+  if (m_implementation_sp) {
+    ScriptInterpreter *script_interp = m_thread.GetProcess()
+                                           ->GetTarget()
+                                           .GetDebugger()
+                                           .GetCommandInterpreter()
+                                           .GetScriptInterpreter();
+    if (script_interp) {
+      bool script_error;
+      explains_stop = script_interp->ScriptedThreadPlanExplainsStop(
+          m_implementation_sp, event_ptr, script_error);
+      if (script_error)
+        SetPlanComplete(false);
+    }
+  }
+  return explains_stop;
+}
+
+bool ThreadPlanPython::MischiefManaged() {
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_THREAD));
+  if (log)
+    log->Printf("%s called on Python Thread Plan: %s )", LLVM_PRETTY_FUNCTION,
+                m_class_name.c_str());
+  bool mischief_managed = true;
+  if (m_implementation_sp) {
+    // I don't really need mischief_managed, since it's simpler to just call
+    // SetPlanComplete in should_stop.
+    mischief_managed = IsPlanComplete();
+    if (mischief_managed)
+      m_implementation_sp.reset();
+  }
+  return mischief_managed;
+}
+
+lldb::StateType ThreadPlanPython::GetPlanRunState() {
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_THREAD));
+  if (log)
+    log->Printf("%s called on Python Thread Plan: %s )", LLVM_PRETTY_FUNCTION,
+                m_class_name.c_str());
+  lldb::StateType run_state = eStateRunning;
+  if (m_implementation_sp) {
+    ScriptInterpreter *script_interp = m_thread.GetProcess()
+                                           ->GetTarget()
+                                           .GetDebugger()
+                                           .GetCommandInterpreter()
+                                           .GetScriptInterpreter();
+    if (script_interp) {
+      bool script_error;
+      run_state = script_interp->ScriptedThreadPlanGetRunState(
+          m_implementation_sp, script_error);
     }
-    return run_state;
+  }
+  return run_state;
 }
 
 // The ones below are not currently exported to Python.
 
-bool
-ThreadPlanPython::StopOthers ()
-{
-    // For now Python plans run all threads, but we should add some controls for this.
-    return false;
-}
-
-void
-ThreadPlanPython::GetDescription (Stream *s,
-                                lldb::DescriptionLevel level)
-{
-    s->Printf ("Python thread plan implemented by class %s.", m_class_name.c_str());
-}
-
-bool
-ThreadPlanPython::WillStop ()
-{
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_THREAD));
-    if (log)
-        log->Printf ("%s called on Python Thread Plan: %s )",
-                    LLVM_PRETTY_FUNCTION, m_class_name.c_str());
-    return true;
+bool ThreadPlanPython::StopOthers() {
+  // For now Python plans run all threads, but we should add some controls for
+  // this.
+  return false;
+}
+
+void ThreadPlanPython::GetDescription(Stream *s, lldb::DescriptionLevel level) {
+  s->Printf("Python thread plan implemented by class %s.",
+            m_class_name.c_str());
+}
+
+bool ThreadPlanPython::WillStop() {
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_THREAD));
+  if (log)
+    log->Printf("%s called on Python Thread Plan: %s )", LLVM_PRETTY_FUNCTION,
+                m_class_name.c_str());
+  return true;
 }

Modified: lldb/trunk/source/Target/ThreadPlanRunToAddress.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanRunToAddress.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Target/ThreadPlanRunToAddress.cpp (original)
+++ lldb/trunk/source/Target/ThreadPlanRunToAddress.cpp Tue Sep  6 15:57:50 2016
@@ -14,10 +14,10 @@
 #include "lldb/Target/ThreadPlanRunToAddress.h"
 #include "lldb/Core/Log.h"
 #include "lldb/Core/Stream.h"
-#include "lldb/Target/Target.h"
 #include "lldb/Target/Process.h"
-#include "lldb/Target/Thread.h"
 #include "lldb/Target/RegisterContext.h"
+#include "lldb/Target/Target.h"
+#include "lldb/Target/Thread.h"
 
 using namespace lldb;
 using namespace lldb_private;
@@ -26,241 +26,179 @@ using namespace lldb_private;
 // ThreadPlanRunToAddress: Continue plan
 //----------------------------------------------------------------------
 
-ThreadPlanRunToAddress::ThreadPlanRunToAddress
-(
-    Thread &thread,
-    Address &address,
-    bool stop_others
-) :
-    ThreadPlan (ThreadPlan::eKindRunToAddress, "Run to address plan", thread, eVoteNoOpinion, eVoteNoOpinion),
-    m_stop_others (stop_others),
-    m_addresses (),
-    m_break_ids ()
-{
-    m_addresses.push_back (address.GetOpcodeLoadAddress (m_thread.CalculateTarget().get()));
-    SetInitialBreakpoints();
-}
-
-ThreadPlanRunToAddress::ThreadPlanRunToAddress
-(
-    Thread &thread,
-    lldb::addr_t address,
-    bool stop_others
-) :
-    ThreadPlan (ThreadPlan::eKindRunToAddress, "Run to address plan", thread, eVoteNoOpinion, eVoteNoOpinion),
-    m_stop_others (stop_others),
-    m_addresses (),
-    m_break_ids ()
-{
-    m_addresses.push_back(m_thread.CalculateTarget()->GetOpcodeLoadAddress(address));
-    SetInitialBreakpoints();
-}
-
-ThreadPlanRunToAddress::ThreadPlanRunToAddress
-(
-    Thread &thread,
-    const std::vector<lldb::addr_t> &addresses,
-    bool stop_others
-) :
-    ThreadPlan (ThreadPlan::eKindRunToAddress, "Run to address plan", thread, eVoteNoOpinion, eVoteNoOpinion),
-    m_stop_others (stop_others),
-    m_addresses (addresses),
-    m_break_ids ()
-{
-    // Convert all addresses into opcode addresses to make sure we set 
-    // breakpoints at the correct address.
-    Target &target = thread.GetProcess()->GetTarget();
-    std::vector<lldb::addr_t>::iterator pos, end = m_addresses.end();
-    for (pos = m_addresses.begin(); pos != end; ++pos)
-        *pos = target.GetOpcodeLoadAddress (*pos);
-
-    SetInitialBreakpoints();
-}
-
-void
-ThreadPlanRunToAddress::SetInitialBreakpoints ()
-{
-    size_t num_addresses = m_addresses.size();
-    m_break_ids.resize(num_addresses);
-    
-    for (size_t i = 0; i < num_addresses; i++)
-    {
-        Breakpoint *breakpoint;
-        breakpoint = m_thread.CalculateTarget()->CreateBreakpoint (m_addresses[i], true, false).get();
-        if (breakpoint != nullptr)
-        {
-            m_break_ids[i] = breakpoint->GetID();
-            breakpoint->SetThreadID(m_thread.GetID());
-            breakpoint->SetBreakpointKind("run-to-address");
-        }
-    }
-}
+ThreadPlanRunToAddress::ThreadPlanRunToAddress(Thread &thread, Address &address,
+                                               bool stop_others)
+    : ThreadPlan(ThreadPlan::eKindRunToAddress, "Run to address plan", thread,
+                 eVoteNoOpinion, eVoteNoOpinion),
+      m_stop_others(stop_others), m_addresses(), m_break_ids() {
+  m_addresses.push_back(
+      address.GetOpcodeLoadAddress(m_thread.CalculateTarget().get()));
+  SetInitialBreakpoints();
+}
+
+ThreadPlanRunToAddress::ThreadPlanRunToAddress(Thread &thread,
+                                               lldb::addr_t address,
+                                               bool stop_others)
+    : ThreadPlan(ThreadPlan::eKindRunToAddress, "Run to address plan", thread,
+                 eVoteNoOpinion, eVoteNoOpinion),
+      m_stop_others(stop_others), m_addresses(), m_break_ids() {
+  m_addresses.push_back(
+      m_thread.CalculateTarget()->GetOpcodeLoadAddress(address));
+  SetInitialBreakpoints();
+}
+
+ThreadPlanRunToAddress::ThreadPlanRunToAddress(
+    Thread &thread, const std::vector<lldb::addr_t> &addresses,
+    bool stop_others)
+    : ThreadPlan(ThreadPlan::eKindRunToAddress, "Run to address plan", thread,
+                 eVoteNoOpinion, eVoteNoOpinion),
+      m_stop_others(stop_others), m_addresses(addresses), m_break_ids() {
+  // Convert all addresses into opcode addresses to make sure we set
+  // breakpoints at the correct address.
+  Target &target = thread.GetProcess()->GetTarget();
+  std::vector<lldb::addr_t>::iterator pos, end = m_addresses.end();
+  for (pos = m_addresses.begin(); pos != end; ++pos)
+    *pos = target.GetOpcodeLoadAddress(*pos);
+
+  SetInitialBreakpoints();
+}
+
+void ThreadPlanRunToAddress::SetInitialBreakpoints() {
+  size_t num_addresses = m_addresses.size();
+  m_break_ids.resize(num_addresses);
+
+  for (size_t i = 0; i < num_addresses; i++) {
+    Breakpoint *breakpoint;
+    breakpoint = m_thread.CalculateTarget()
+                     ->CreateBreakpoint(m_addresses[i], true, false)
+                     .get();
+    if (breakpoint != nullptr) {
+      m_break_ids[i] = breakpoint->GetID();
+      breakpoint->SetThreadID(m_thread.GetID());
+      breakpoint->SetBreakpointKind("run-to-address");
+    }
+  }
+}
+
+ThreadPlanRunToAddress::~ThreadPlanRunToAddress() {
+  size_t num_break_ids = m_break_ids.size();
+  for (size_t i = 0; i < num_break_ids; i++) {
+    m_thread.CalculateTarget()->RemoveBreakpointByID(m_break_ids[i]);
+  }
+}
+
+void ThreadPlanRunToAddress::GetDescription(Stream *s,
+                                            lldb::DescriptionLevel level) {
+  size_t num_addresses = m_addresses.size();
+
+  if (level == lldb::eDescriptionLevelBrief) {
+    if (num_addresses == 0) {
+      s->Printf("run to address with no addresses given.");
+      return;
+    } else if (num_addresses == 1)
+      s->Printf("run to address: ");
+    else
+      s->Printf("run to addresses: ");
 
-ThreadPlanRunToAddress::~ThreadPlanRunToAddress ()
-{
-    size_t num_break_ids = m_break_ids.size();
-    for (size_t i = 0; i <  num_break_ids; i++)
-    {
-        m_thread.CalculateTarget()->RemoveBreakpointByID (m_break_ids[i]);
+    for (size_t i = 0; i < num_addresses; i++) {
+      s->Address(m_addresses[i], sizeof(addr_t));
+      s->Printf(" ");
     }
-}
-
-void
-ThreadPlanRunToAddress::GetDescription (Stream *s, lldb::DescriptionLevel level)
-{
-    size_t num_addresses = m_addresses.size();
-    
-    if (level == lldb::eDescriptionLevelBrief)
-    {
-        if (num_addresses == 0)
-        {
-            s->Printf ("run to address with no addresses given.");
-            return;
-        }
-        else if (num_addresses == 1)
-            s->Printf ("run to address: ");
-        else
-            s->Printf ("run to addresses: ");
-            
-        for (size_t i = 0; i < num_addresses; i++)
-        {
-            s->Address (m_addresses[i], sizeof (addr_t));
-            s->Printf(" ");
-        }
+  } else {
+    if (num_addresses == 0) {
+      s->Printf("run to address with no addresses given.");
+      return;
+    } else if (num_addresses == 1)
+      s->Printf("Run to address: ");
+    else {
+      s->Printf("Run to addresses: ");
     }
-    else
-    {
-        if (num_addresses == 0)
-        {
-            s->Printf ("run to address with no addresses given.");
-            return;
-        }
-        else if (num_addresses == 1)
-            s->Printf ("Run to address: ");
-        else
-        {
-            s->Printf ("Run to addresses: ");
-        }
-            
-        for (size_t i = 0; i < num_addresses; i++)
-        {
-            if (num_addresses > 1)
-            {
-                s->Printf("\n");
-                s->Indent();
-            }
-            
-            s->Address(m_addresses[i], sizeof (addr_t));
-            s->Printf (" using breakpoint: %d - ", m_break_ids[i]);
-            Breakpoint *breakpoint = m_thread.CalculateTarget()->GetBreakpointByID (m_break_ids[i]).get();
-            if (breakpoint)
-                breakpoint->Dump (s);
-            else
-                s->Printf ("but the breakpoint has been deleted.");
-        }
+
+    for (size_t i = 0; i < num_addresses; i++) {
+      if (num_addresses > 1) {
+        s->Printf("\n");
+        s->Indent();
+      }
+
+      s->Address(m_addresses[i], sizeof(addr_t));
+      s->Printf(" using breakpoint: %d - ", m_break_ids[i]);
+      Breakpoint *breakpoint =
+          m_thread.CalculateTarget()->GetBreakpointByID(m_break_ids[i]).get();
+      if (breakpoint)
+        breakpoint->Dump(s);
+      else
+        s->Printf("but the breakpoint has been deleted.");
     }
+  }
 }
 
-bool
-ThreadPlanRunToAddress::ValidatePlan (Stream *error)
-{
-    // If we couldn't set the breakpoint for some reason, then this won't
-    // work.
-    bool all_bps_good = true;
-    size_t num_break_ids = m_break_ids.size();
-        
-    for (size_t i = 0; i < num_break_ids; i++)
-    {
-        if (m_break_ids[i] == LLDB_INVALID_BREAK_ID)
-        {
-            all_bps_good = false;
-            if (error)
-            {
-                error->Printf ("Could not set breakpoint for address: ");
-                error->Address (m_addresses[i], sizeof (addr_t));
-                error->Printf ("\n");
-            }
-        }
+bool ThreadPlanRunToAddress::ValidatePlan(Stream *error) {
+  // If we couldn't set the breakpoint for some reason, then this won't
+  // work.
+  bool all_bps_good = true;
+  size_t num_break_ids = m_break_ids.size();
+
+  for (size_t i = 0; i < num_break_ids; i++) {
+    if (m_break_ids[i] == LLDB_INVALID_BREAK_ID) {
+      all_bps_good = false;
+      if (error) {
+        error->Printf("Could not set breakpoint for address: ");
+        error->Address(m_addresses[i], sizeof(addr_t));
+        error->Printf("\n");
+      }
     }
-    return all_bps_good;
+  }
+  return all_bps_good;
 }
 
-bool
-ThreadPlanRunToAddress::DoPlanExplainsStop (Event *event_ptr)
-{
-    return AtOurAddress();
+bool ThreadPlanRunToAddress::DoPlanExplainsStop(Event *event_ptr) {
+  return AtOurAddress();
 }
 
-bool
-ThreadPlanRunToAddress::ShouldStop (Event *event_ptr)
-{
-    return AtOurAddress();
+bool ThreadPlanRunToAddress::ShouldStop(Event *event_ptr) {
+  return AtOurAddress();
 }
 
-bool
-ThreadPlanRunToAddress::StopOthers ()
-{
-    return m_stop_others;
-}
+bool ThreadPlanRunToAddress::StopOthers() { return m_stop_others; }
 
-void
-ThreadPlanRunToAddress::SetStopOthers (bool new_value)
-{
-    m_stop_others = new_value;
+void ThreadPlanRunToAddress::SetStopOthers(bool new_value) {
+  m_stop_others = new_value;
 }
 
-StateType
-ThreadPlanRunToAddress::GetPlanRunState ()
-{
-    return eStateRunning;
-}
+StateType ThreadPlanRunToAddress::GetPlanRunState() { return eStateRunning; }
 
-bool
-ThreadPlanRunToAddress::WillStop ()
-{
-    return true;
-}
+bool ThreadPlanRunToAddress::WillStop() { return true; }
 
-bool
-ThreadPlanRunToAddress::MischiefManaged ()
-{
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
-
-    if (AtOurAddress())
-    {
-        // Remove the breakpoint
-        size_t num_break_ids = m_break_ids.size();
-        
-        for (size_t i = 0; i < num_break_ids; i++)
-        {
-            if (m_break_ids[i] != LLDB_INVALID_BREAK_ID)
-            {
-                m_thread.CalculateTarget()->RemoveBreakpointByID (m_break_ids[i]);
-                m_break_ids[i] = LLDB_INVALID_BREAK_ID;
-            }
-        }
-        if (log)
-            log->Printf("Completed run to address plan.");
-        ThreadPlan::MischiefManaged ();
-        return true;
-    }
-    else
-        return false;
+bool ThreadPlanRunToAddress::MischiefManaged() {
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
+
+  if (AtOurAddress()) {
+    // Remove the breakpoint
+    size_t num_break_ids = m_break_ids.size();
+
+    for (size_t i = 0; i < num_break_ids; i++) {
+      if (m_break_ids[i] != LLDB_INVALID_BREAK_ID) {
+        m_thread.CalculateTarget()->RemoveBreakpointByID(m_break_ids[i]);
+        m_break_ids[i] = LLDB_INVALID_BREAK_ID;
+      }
+    }
+    if (log)
+      log->Printf("Completed run to address plan.");
+    ThreadPlan::MischiefManaged();
+    return true;
+  } else
+    return false;
 }
 
-bool
-ThreadPlanRunToAddress::AtOurAddress ()
-{
-    lldb::addr_t current_address = m_thread.GetRegisterContext()->GetPC();
-    bool found_it = false;
-    size_t num_addresses = m_addresses.size();
-    for (size_t i = 0; i < num_addresses; i++)
-    {
-        if (m_addresses[i] == current_address)
-        {
-            found_it = true;
-            break;
-        }
+bool ThreadPlanRunToAddress::AtOurAddress() {
+  lldb::addr_t current_address = m_thread.GetRegisterContext()->GetPC();
+  bool found_it = false;
+  size_t num_addresses = m_addresses.size();
+  for (size_t i = 0; i < num_addresses; i++) {
+    if (m_addresses[i] == current_address) {
+      found_it = true;
+      break;
     }
-    return found_it;
+  }
+  return found_it;
 }

Modified: lldb/trunk/source/Target/ThreadPlanShouldStopHere.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanShouldStopHere.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Target/ThreadPlanShouldStopHere.cpp (original)
+++ lldb/trunk/source/Target/ThreadPlanShouldStopHere.cpp Tue Sep  6 15:57:50 2016
@@ -11,10 +11,10 @@
 // C++ Includes
 // Other libraries and framework includes
 // Project includes
+#include "lldb/Target/Thread.h"
 #include "lldb/Core/Log.h"
 #include "lldb/Symbol/Symbol.h"
 #include "lldb/Target/RegisterContext.h"
-#include "lldb/Target/Thread.h"
 #include "lldb/Target/ThreadPlanShouldStopHere.h"
 
 using namespace lldb;
@@ -23,166 +23,149 @@ using namespace lldb_private;
 //----------------------------------------------------------------------
 // ThreadPlanShouldStopHere constructor
 //----------------------------------------------------------------------
-ThreadPlanShouldStopHere::ThreadPlanShouldStopHere(ThreadPlan *owner) :
-    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;
-}
-
-ThreadPlanShouldStopHere::ThreadPlanShouldStopHere(ThreadPlan *owner, const ThreadPlanShouldStopHereCallbacks *callbacks, void *baton) :
-    m_callbacks (),
-    m_baton (),
-    m_owner (owner),
-    m_flags (ThreadPlanShouldStopHere::eNone)
-{
-    SetShouldStopHereCallbacks(callbacks, baton);
+ThreadPlanShouldStopHere::ThreadPlanShouldStopHere(ThreadPlan *owner)
+    : 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;
+}
+
+ThreadPlanShouldStopHere::ThreadPlanShouldStopHere(
+    ThreadPlan *owner, const ThreadPlanShouldStopHereCallbacks *callbacks,
+    void *baton)
+    : m_callbacks(), m_baton(), m_owner(owner),
+      m_flags(ThreadPlanShouldStopHere::eNone) {
+  SetShouldStopHereCallbacks(callbacks, baton);
 }
 
 ThreadPlanShouldStopHere::~ThreadPlanShouldStopHere() = default;
 
-bool
-ThreadPlanShouldStopHere::InvokeShouldStopHereCallback (FrameComparison operation)
-{
-    bool should_stop_here = true;
-    if (m_callbacks.should_stop_here_callback)
-    {
-        should_stop_here = m_callbacks.should_stop_here_callback (m_owner, m_flags, operation, m_baton);
-        Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
-        if (log)
-        {
-            lldb::addr_t current_addr = m_owner->GetThread().GetRegisterContext()->GetPC(0);
+bool ThreadPlanShouldStopHere::InvokeShouldStopHereCallback(
+    FrameComparison operation) {
+  bool should_stop_here = true;
+  if (m_callbacks.should_stop_here_callback) {
+    should_stop_here = m_callbacks.should_stop_here_callback(
+        m_owner, m_flags, operation, m_baton);
+    Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
+    if (log) {
+      lldb::addr_t current_addr =
+          m_owner->GetThread().GetRegisterContext()->GetPC(0);
 
-            log->Printf ("ShouldStopHere callback returned %u from 0x%" PRIx64 ".", should_stop_here, current_addr);
-        }
+      log->Printf("ShouldStopHere callback returned %u from 0x%" PRIx64 ".",
+                  should_stop_here, current_addr);
     }
-    
-    return should_stop_here;
+  }
+
+  return should_stop_here;
 }
 
-bool
-ThreadPlanShouldStopHere::DefaultShouldStopHereCallback (ThreadPlan *current_plan,
-                                                         Flags &flags,
-                                                         FrameComparison operation,
-                                                         void *baton)
-{
-    bool should_stop_here = true;
-    StackFrame *frame = current_plan->GetThread().GetStackFrameAtIndex(0).get();
-    if (!frame)
-        return true;
-    
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
-
-    if ((operation == eFrameCompareOlder && flags.Test(eStepOutAvoidNoDebug))
-        || (operation == eFrameCompareYounger && flags.Test(eStepInAvoidNoDebug))
-        || (operation == eFrameCompareSameParent && flags.Test(eStepInAvoidNoDebug)))
-    {
-        if (!frame->HasDebugInformation())
-        {
-            if (log)
-                log->Printf ("Stepping out of frame with no debug info");
+bool ThreadPlanShouldStopHere::DefaultShouldStopHereCallback(
+    ThreadPlan *current_plan, Flags &flags, FrameComparison operation,
+    void *baton) {
+  bool should_stop_here = true;
+  StackFrame *frame = current_plan->GetThread().GetStackFrameAtIndex(0).get();
+  if (!frame)
+    return true;
+
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
+
+  if ((operation == eFrameCompareOlder && flags.Test(eStepOutAvoidNoDebug)) ||
+      (operation == eFrameCompareYounger && flags.Test(eStepInAvoidNoDebug)) ||
+      (operation == eFrameCompareSameParent &&
+       flags.Test(eStepInAvoidNoDebug))) {
+    if (!frame->HasDebugInformation()) {
+      if (log)
+        log->Printf("Stepping out of frame with no debug info");
 
-            should_stop_here = false;
-        }
-    }
-    
-    // Always avoid code with line number 0.
-    // FIXME: At present the ShouldStop and the StepFromHere calculate this independently.  If this ever
-    // becomes expensive (this one isn't) we can try to have this set a state that the StepFromHere can use.
-    if (frame)
-    {
-        SymbolContext sc;
-        sc = frame->GetSymbolContext (eSymbolContextLineEntry);
-        if (sc.line_entry.line == 0)
-            should_stop_here = false;
+      should_stop_here = false;
     }
-    
-    return should_stop_here;
-}
+  }
 
-ThreadPlanSP
-ThreadPlanShouldStopHere::DefaultStepFromHereCallback (ThreadPlan *current_plan,
-                                                         Flags &flags,
-                                                         FrameComparison operation,
-                                                         void *baton)
-{
-    const bool stop_others = false;
-    const size_t frame_index = 0;
-    ThreadPlanSP return_plan_sp;
-    // If we are stepping through code at line number 0, then we need to step over this range.  Otherwise
-    // we will step out.
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
-
-    StackFrame *frame = current_plan->GetThread().GetStackFrameAtIndex(0).get();
-    if (!frame)
-        return return_plan_sp;
+  // Always avoid code with line number 0.
+  // FIXME: At present the ShouldStop and the StepFromHere calculate this
+  // independently.  If this ever
+  // becomes expensive (this one isn't) we can try to have this set a state that
+  // the StepFromHere can use.
+  if (frame) {
     SymbolContext sc;
-    sc = frame->GetSymbolContext (eSymbolContextLineEntry|eSymbolContextSymbol);
-
+    sc = frame->GetSymbolContext(eSymbolContextLineEntry);
     if (sc.line_entry.line == 0)
-    {
-        AddressRange range = sc.line_entry.range;
+      should_stop_here = false;
+  }
 
-	// If the whole function is marked line 0 just step out, that's easier & faster than continuing
-        // to step through it.
-	bool just_step_out = false;
-	if (sc.symbol && sc.symbol->ValueIsAddress())
-        {
-	    Address symbol_end = sc.symbol->GetAddress();
-	    symbol_end.Slide(sc.symbol->GetByteSize() - 1);
-            if (range.ContainsFileAddress(sc.symbol->GetAddress()) && range.ContainsFileAddress(symbol_end))
-	    {
-	        if (log)
-	            log->Printf("Stopped in a function with only line 0 lines, just stepping out.");
-                just_step_out = true;
-	    }
-	}
-        if (!just_step_out)
-        {
-            if (log)
-                log->Printf ("ThreadPlanShouldStopHere::DefaultStepFromHereCallback Queueing StepInRange plan to step through line 0 code.");
-            
-            return_plan_sp = current_plan->GetThread().QueueThreadPlanForStepInRange(false,
-                                                                                     range,
-                                                                                     sc,
-                                                                                     NULL,
-                                                                                     eOnlyDuringStepping,
-                                                                                     eLazyBoolCalculate,
-                                                                                     eLazyBoolNo);
-        }
-    }
-    
-    if (!return_plan_sp)
-        return_plan_sp = current_plan->GetThread().QueueThreadPlanForStepOutNoShouldStop(false,
-                                                                                         nullptr,
-                                                                                         true,
-                                                                                         stop_others,
-                                                                                         eVoteNo,
-                                                                                         eVoteNoOpinion,
-                                                                                         frame_index,
-                                                                                         true);
-    return return_plan_sp;
+  return should_stop_here;
 }
 
-ThreadPlanSP
-ThreadPlanShouldStopHere::QueueStepOutFromHerePlan(lldb_private::Flags &flags, lldb::FrameComparison operation)
-{
-    ThreadPlanSP return_plan_sp;
-    if (m_callbacks.step_from_here_callback)
-    {
-         return_plan_sp = m_callbacks.step_from_here_callback (m_owner, flags, operation, m_baton);
-    }
+ThreadPlanSP ThreadPlanShouldStopHere::DefaultStepFromHereCallback(
+    ThreadPlan *current_plan, Flags &flags, FrameComparison operation,
+    void *baton) {
+  const bool stop_others = false;
+  const size_t frame_index = 0;
+  ThreadPlanSP return_plan_sp;
+  // If we are stepping through code at line number 0, then we need to step over
+  // this range.  Otherwise
+  // we will step out.
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
+
+  StackFrame *frame = current_plan->GetThread().GetStackFrameAtIndex(0).get();
+  if (!frame)
     return return_plan_sp;
-}
+  SymbolContext sc;
+  sc = frame->GetSymbolContext(eSymbolContextLineEntry | eSymbolContextSymbol);
+
+  if (sc.line_entry.line == 0) {
+    AddressRange range = sc.line_entry.range;
+
+    // If the whole function is marked line 0 just step out, that's easier &
+    // faster than continuing
+    // to step through it.
+    bool just_step_out = false;
+    if (sc.symbol && sc.symbol->ValueIsAddress()) {
+      Address symbol_end = sc.symbol->GetAddress();
+      symbol_end.Slide(sc.symbol->GetByteSize() - 1);
+      if (range.ContainsFileAddress(sc.symbol->GetAddress()) &&
+          range.ContainsFileAddress(symbol_end)) {
+        if (log)
+          log->Printf("Stopped in a function with only line 0 lines, just "
+                      "stepping out.");
+        just_step_out = true;
+      }
+    }
+    if (!just_step_out) {
+      if (log)
+        log->Printf("ThreadPlanShouldStopHere::DefaultStepFromHereCallback "
+                    "Queueing StepInRange plan to step through line 0 code.");
+
+      return_plan_sp = current_plan->GetThread().QueueThreadPlanForStepInRange(
+          false, range, sc, NULL, eOnlyDuringStepping, eLazyBoolCalculate,
+          eLazyBoolNo);
+    }
+  }
 
-lldb::ThreadPlanSP
-ThreadPlanShouldStopHere::CheckShouldStopHereAndQueueStepOut (lldb::FrameComparison operation)
-{
-    if (!InvokeShouldStopHereCallback(operation))
-        return QueueStepOutFromHerePlan(m_flags, operation);
-    else
-        return ThreadPlanSP();
+  if (!return_plan_sp)
+    return_plan_sp =
+        current_plan->GetThread().QueueThreadPlanForStepOutNoShouldStop(
+            false, nullptr, true, stop_others, eVoteNo, eVoteNoOpinion,
+            frame_index, true);
+  return return_plan_sp;
+}
+
+ThreadPlanSP ThreadPlanShouldStopHere::QueueStepOutFromHerePlan(
+    lldb_private::Flags &flags, lldb::FrameComparison operation) {
+  ThreadPlanSP return_plan_sp;
+  if (m_callbacks.step_from_here_callback) {
+    return_plan_sp =
+        m_callbacks.step_from_here_callback(m_owner, flags, operation, m_baton);
+  }
+  return return_plan_sp;
+}
+
+lldb::ThreadPlanSP ThreadPlanShouldStopHere::CheckShouldStopHereAndQueueStepOut(
+    lldb::FrameComparison operation) {
+  if (!InvokeShouldStopHereCallback(operation))
+    return QueueStepOutFromHerePlan(m_flags, operation);
+  else
+    return ThreadPlanSP();
 }

Modified: lldb/trunk/source/Target/ThreadPlanStepInRange.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanStepInRange.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Target/ThreadPlanStepInRange.cpp (original)
+++ lldb/trunk/source/Target/ThreadPlanStepInRange.cpp Tue Sep  6 15:57:50 2016
@@ -14,526 +14,493 @@
 #include "lldb/Target/ThreadPlanStepInRange.h"
 #include "lldb/Core/Log.h"
 #include "lldb/Core/Module.h"
+#include "lldb/Core/RegularExpression.h"
 #include "lldb/Core/Stream.h"
-#include "lldb/Symbol/Symbol.h"
 #include "lldb/Symbol/Function.h"
+#include "lldb/Symbol/Symbol.h"
 #include "lldb/Target/Process.h"
 #include "lldb/Target/RegisterContext.h"
 #include "lldb/Target/Target.h"
 #include "lldb/Target/Thread.h"
 #include "lldb/Target/ThreadPlanStepOut.h"
 #include "lldb/Target/ThreadPlanStepThrough.h"
-#include "lldb/Core/RegularExpression.h"
 
 using namespace lldb;
 using namespace lldb_private;
 
-uint32_t ThreadPlanStepInRange::s_default_flag_values = ThreadPlanShouldStopHere::eStepInAvoidNoDebug;
+uint32_t ThreadPlanStepInRange::s_default_flag_values =
+    ThreadPlanShouldStopHere::eStepInAvoidNoDebug;
 
 //----------------------------------------------------------------------
-// ThreadPlanStepInRange: Step through a stack range, either stepping over or into
+// ThreadPlanStepInRange: Step through a stack range, either stepping over or
+// into
 // based on the value of \a type.
 //----------------------------------------------------------------------
 
-ThreadPlanStepInRange::ThreadPlanStepInRange
-(
-    Thread &thread,
-    const AddressRange &range,
-    const SymbolContext &addr_context,
-    lldb::RunMode stop_others,
+ThreadPlanStepInRange::ThreadPlanStepInRange(
+    Thread &thread, const AddressRange &range,
+    const SymbolContext &addr_context, lldb::RunMode stop_others,
     LazyBool step_in_avoids_code_without_debug_info,
-    LazyBool step_out_avoids_code_without_debug_info
-) :
-    ThreadPlanStepRange (ThreadPlan::eKindStepInRange, "Step Range stepping in", thread, range, addr_context, stop_others),
-    ThreadPlanShouldStopHere (this),
-    m_step_past_prologue (true),
-    m_virtual_step (false)
-{
-    SetCallbacks();
-    SetFlagsToDefault ();
-    SetupAvoidNoDebug(step_in_avoids_code_without_debug_info, step_out_avoids_code_without_debug_info);
-}
-
-ThreadPlanStepInRange::ThreadPlanStepInRange
-(
-    Thread &thread,
-    const AddressRange &range,
-    const SymbolContext &addr_context,
-    const char *step_into_target,
-    lldb::RunMode stop_others,
-    LazyBool step_in_avoids_code_without_debug_info,
-    LazyBool step_out_avoids_code_without_debug_info
-) :
-    ThreadPlanStepRange (ThreadPlan::eKindStepInRange, "Step Range stepping in", thread, range, addr_context, stop_others),
-    ThreadPlanShouldStopHere (this),
-    m_step_past_prologue (true),
-    m_virtual_step (false),
-    m_step_into_target (step_into_target)
-{
-    SetCallbacks();
-    SetFlagsToDefault ();
-    SetupAvoidNoDebug(step_in_avoids_code_without_debug_info, step_out_avoids_code_without_debug_info);
+    LazyBool step_out_avoids_code_without_debug_info)
+    : ThreadPlanStepRange(ThreadPlan::eKindStepInRange,
+                          "Step Range stepping in", thread, range, addr_context,
+                          stop_others),
+      ThreadPlanShouldStopHere(this), m_step_past_prologue(true),
+      m_virtual_step(false) {
+  SetCallbacks();
+  SetFlagsToDefault();
+  SetupAvoidNoDebug(step_in_avoids_code_without_debug_info,
+                    step_out_avoids_code_without_debug_info);
+}
+
+ThreadPlanStepInRange::ThreadPlanStepInRange(
+    Thread &thread, const AddressRange &range,
+    const SymbolContext &addr_context, const char *step_into_target,
+    lldb::RunMode stop_others, LazyBool step_in_avoids_code_without_debug_info,
+    LazyBool step_out_avoids_code_without_debug_info)
+    : ThreadPlanStepRange(ThreadPlan::eKindStepInRange,
+                          "Step Range stepping in", thread, range, addr_context,
+                          stop_others),
+      ThreadPlanShouldStopHere(this), m_step_past_prologue(true),
+      m_virtual_step(false), m_step_into_target(step_into_target) {
+  SetCallbacks();
+  SetFlagsToDefault();
+  SetupAvoidNoDebug(step_in_avoids_code_without_debug_info,
+                    step_out_avoids_code_without_debug_info);
 }
 
 ThreadPlanStepInRange::~ThreadPlanStepInRange() = default;
 
-void
-ThreadPlanStepInRange::SetupAvoidNoDebug(LazyBool step_in_avoids_code_without_debug_info,
-                                         LazyBool step_out_avoids_code_without_debug_info)
-{
-    bool avoid_nodebug = true;
-    
-    switch (step_in_avoids_code_without_debug_info)
-    {
-        case eLazyBoolYes:
-            avoid_nodebug = true;
-            break;
-        case eLazyBoolNo:
-            avoid_nodebug = false;
-            break;
-        case eLazyBoolCalculate:
-            avoid_nodebug = m_thread.GetStepInAvoidsNoDebug();
-            break;
-    }
-    if (avoid_nodebug)
-        GetFlags().Set (ThreadPlanShouldStopHere::eStepInAvoidNoDebug);
-    else
-        GetFlags().Clear (ThreadPlanShouldStopHere::eStepInAvoidNoDebug);
-    
-    switch (step_out_avoids_code_without_debug_info)
-    {
-        case eLazyBoolYes:
-            avoid_nodebug = true;
-            break;
-        case eLazyBoolNo:
-            avoid_nodebug = false;
-            break;
-        case eLazyBoolCalculate:
-            avoid_nodebug = m_thread.GetStepOutAvoidsNoDebug();
-            break;
-    }
-    if (avoid_nodebug)
-        GetFlags().Set (ThreadPlanShouldStopHere::eStepOutAvoidNoDebug);
-    else
-        GetFlags().Clear (ThreadPlanShouldStopHere::eStepOutAvoidNoDebug);
-}
-
-void
-ThreadPlanStepInRange::GetDescription (Stream *s, lldb::DescriptionLevel level)
-{
-    if (level == lldb::eDescriptionLevelBrief)
-    {
-        s->Printf("step in");
-        return;
-    }
-
-    s->Printf ("Stepping in");
-    bool printed_line_info = false;
-    if (m_addr_context.line_entry.IsValid())
-    {
-        s->Printf (" through line ");
-        m_addr_context.line_entry.DumpStopContext (s, false);
-        printed_line_info = true;
-    }
+void ThreadPlanStepInRange::SetupAvoidNoDebug(
+    LazyBool step_in_avoids_code_without_debug_info,
+    LazyBool step_out_avoids_code_without_debug_info) {
+  bool avoid_nodebug = true;
 
-    const char *step_into_target = m_step_into_target.AsCString();
-    if (step_into_target && step_into_target[0] != '\0')
-        s->Printf (" targeting %s", m_step_into_target.AsCString());
-
-    if (!printed_line_info || level == eDescriptionLevelVerbose)
-    {
-        s->Printf (" using ranges:");
-        DumpRanges(s);
-    }
+  switch (step_in_avoids_code_without_debug_info) {
+  case eLazyBoolYes:
+    avoid_nodebug = true;
+    break;
+  case eLazyBoolNo:
+    avoid_nodebug = false;
+    break;
+  case eLazyBoolCalculate:
+    avoid_nodebug = m_thread.GetStepInAvoidsNoDebug();
+    break;
+  }
+  if (avoid_nodebug)
+    GetFlags().Set(ThreadPlanShouldStopHere::eStepInAvoidNoDebug);
+  else
+    GetFlags().Clear(ThreadPlanShouldStopHere::eStepInAvoidNoDebug);
+
+  switch (step_out_avoids_code_without_debug_info) {
+  case eLazyBoolYes:
+    avoid_nodebug = true;
+    break;
+  case eLazyBoolNo:
+    avoid_nodebug = false;
+    break;
+  case eLazyBoolCalculate:
+    avoid_nodebug = m_thread.GetStepOutAvoidsNoDebug();
+    break;
+  }
+  if (avoid_nodebug)
+    GetFlags().Set(ThreadPlanShouldStopHere::eStepOutAvoidNoDebug);
+  else
+    GetFlags().Clear(ThreadPlanShouldStopHere::eStepOutAvoidNoDebug);
+}
+
+void ThreadPlanStepInRange::GetDescription(Stream *s,
+                                           lldb::DescriptionLevel level) {
+  if (level == lldb::eDescriptionLevelBrief) {
+    s->Printf("step in");
+    return;
+  }
+
+  s->Printf("Stepping in");
+  bool printed_line_info = false;
+  if (m_addr_context.line_entry.IsValid()) {
+    s->Printf(" through line ");
+    m_addr_context.line_entry.DumpStopContext(s, false);
+    printed_line_info = true;
+  }
+
+  const char *step_into_target = m_step_into_target.AsCString();
+  if (step_into_target && step_into_target[0] != '\0')
+    s->Printf(" targeting %s", m_step_into_target.AsCString());
+
+  if (!printed_line_info || level == eDescriptionLevelVerbose) {
+    s->Printf(" using ranges:");
+    DumpRanges(s);
+  }
+
+  s->PutChar('.');
+}
+
+bool ThreadPlanStepInRange::ShouldStop(Event *event_ptr) {
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
+
+  if (log) {
+    StreamString s;
+    s.Address(
+        m_thread.GetRegisterContext()->GetPC(),
+        m_thread.CalculateTarget()->GetArchitecture().GetAddressByteSize());
+    log->Printf("ThreadPlanStepInRange reached %s.", s.GetData());
+  }
 
-    s->PutChar('.');
-}
-
-bool
-ThreadPlanStepInRange::ShouldStop (Event *event_ptr)
-{
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
-    
-    if (log)
-    {
-        StreamString s;
-        s.Address (m_thread.GetRegisterContext()->GetPC(), 
-                   m_thread.CalculateTarget()->GetArchitecture().GetAddressByteSize());
-        log->Printf("ThreadPlanStepInRange reached %s.", s.GetData());
-    }
+  if (IsPlanComplete())
+    return true;
 
-    if (IsPlanComplete())
-        return true;
-        
-    m_no_more_plans = false;
-    if (m_sub_plan_sp && m_sub_plan_sp->IsPlanComplete())
-    {
-        if (!m_sub_plan_sp->PlanSucceeded())
-        {
-            SetPlanComplete();
-            m_no_more_plans = true;
-            return true;
-        }
-        else
-            m_sub_plan_sp.reset();
-    }
-    
-    if (m_virtual_step)
-    {
-        // If we've just completed a virtual step, all we need to do is check for a ShouldStopHere plan, and otherwise
-        // we're done.
-        // FIXME - This can be both a step in and a step out.  Probably should record which in the m_virtual_step.
-        m_sub_plan_sp = CheckShouldStopHereAndQueueStepOut(eFrameCompareYounger);
-    }
-    else
-    {
-        // 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 = (m_stop_others == lldb::eOnlyThisThread);
-            
-        FrameComparison frame_order = CompareCurrentFrameToStartFrame();
-        
-        if (frame_order == eFrameCompareOlder || frame_order == eFrameCompareSameParent)
-        {
-            // If we're in an older frame then we should stop.
-            //
-            // A caveat to this is if we think the frame is older but we're actually in a trampoline.
-            // I'm going to make the assumption that you wouldn't RETURN to a trampoline.  So if we are
-            // in a trampoline we think the frame is older because the trampoline confused the backtracer.
-            m_sub_plan_sp = m_thread.QueueThreadPlanForStepThrough (m_stack_id, false, stop_others);
-            if (!m_sub_plan_sp)
-            {
-                // Otherwise check the ShouldStopHere for step out:
-                m_sub_plan_sp = CheckShouldStopHereAndQueueStepOut(frame_order);
-                if (log)
-                    log->Printf ("ShouldStopHere says we should step out of this frame.");
-            }
-            else if (log)
-            {
-                log->Printf("Thought I stepped out, but in fact arrived at a trampoline.");
-            }
-        }
-        else if (frame_order == eFrameCompareEqual && InSymbol())
-        {
-            // If we are not in a place we should step through, we're done.
-            // One tricky bit here is that some stubs don't push a frame, so we have to check
-            // both the case of a frame that is younger, or the same as this frame.  
-            // However, if the frame is the same, and we are still in the symbol we started
-            // in, the we don't need to do this.  This first check isn't strictly necessary,
-            // but it is more efficient.
-            
-            // If we're still in the range, keep going, either by running to the next branch breakpoint, or by
-            // stepping.
-            if (InRange())
-            {
-                SetNextBranchBreakpoint();
-                return false;
-            }
-        
-            SetPlanComplete();
-            m_no_more_plans = true;
-            return true;
-        }
-        
-        // If we get to this point, we're not going to use a previously set "next branch" breakpoint, so delete it:
-        ClearNextBranchBreakpoint();
-        
-        // We may have set the plan up above in the FrameIsOlder section:
-        
-        if (!m_sub_plan_sp)
-            m_sub_plan_sp = m_thread.QueueThreadPlanForStepThrough (m_stack_id, false, stop_others);
-        
+  m_no_more_plans = false;
+  if (m_sub_plan_sp && m_sub_plan_sp->IsPlanComplete()) {
+    if (!m_sub_plan_sp->PlanSucceeded()) {
+      SetPlanComplete();
+      m_no_more_plans = true;
+      return true;
+    } else
+      m_sub_plan_sp.reset();
+  }
+
+  if (m_virtual_step) {
+    // If we've just completed a virtual step, all we need to do is check for a
+    // ShouldStopHere plan, and otherwise
+    // we're done.
+    // FIXME - This can be both a step in and a step out.  Probably should
+    // record which in the m_virtual_step.
+    m_sub_plan_sp = CheckShouldStopHereAndQueueStepOut(eFrameCompareYounger);
+  } else {
+    // 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 = (m_stop_others == lldb::eOnlyThisThread);
+
+    FrameComparison frame_order = CompareCurrentFrameToStartFrame();
+
+    if (frame_order == eFrameCompareOlder ||
+        frame_order == eFrameCompareSameParent) {
+      // If we're in an older frame then we should stop.
+      //
+      // A caveat to this is if we think the frame is older but we're actually
+      // in a trampoline.
+      // I'm going to make the assumption that you wouldn't RETURN to a
+      // trampoline.  So if we are
+      // in a trampoline we think the frame is older because the trampoline
+      // confused the backtracer.
+      m_sub_plan_sp = m_thread.QueueThreadPlanForStepThrough(m_stack_id, false,
+                                                             stop_others);
+      if (!m_sub_plan_sp) {
+        // Otherwise check the ShouldStopHere for step out:
+        m_sub_plan_sp = CheckShouldStopHereAndQueueStepOut(frame_order);
         if (log)
-        {
-            if (m_sub_plan_sp)
-                log->Printf ("Found a step through plan: %s", m_sub_plan_sp->GetName());
-            else
-                log->Printf ("No step through plan found.");
-        }
-        
-        // If not, give the "should_stop" callback a chance to push a plan to get us out of here.
-        // But only do that if we actually have stepped in.
-        if (!m_sub_plan_sp && frame_order == eFrameCompareYounger)
-            m_sub_plan_sp = CheckShouldStopHereAndQueueStepOut(frame_order);
-
-        // If we've stepped in and we are going to stop here, check to see if we were asked to
-        // run past the prologue, and if so do that.
-        
-        if (!m_sub_plan_sp && frame_order == eFrameCompareYounger && m_step_past_prologue)
-        {
-            lldb::StackFrameSP curr_frame = m_thread.GetStackFrameAtIndex(0);
-            if (curr_frame)
-            {
-                size_t bytes_to_skip = 0;
-                lldb::addr_t curr_addr = m_thread.GetRegisterContext()->GetPC();
-                Address func_start_address;
-                
-                SymbolContext sc = curr_frame->GetSymbolContext (eSymbolContextFunction | eSymbolContextSymbol);
-                
-                if (sc.function)
-                {
-                    func_start_address = sc.function->GetAddressRange().GetBaseAddress();
-                    if (curr_addr == func_start_address.GetLoadAddress(m_thread.CalculateTarget().get()))
-                        bytes_to_skip = sc.function->GetPrologueByteSize();
-                }
-                else if (sc.symbol)
-                {
-                    func_start_address = sc.symbol->GetAddress();
-                    if (curr_addr == func_start_address.GetLoadAddress(m_thread.CalculateTarget().get()))
-                        bytes_to_skip = sc.symbol->GetPrologueByteSize();
-                }
-                
-                if (bytes_to_skip != 0)
-                {
-                    func_start_address.Slide (bytes_to_skip);
-                    log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP);
-                    if (log)
-                        log->Printf ("Pushing past prologue ");
-                        
-                    m_sub_plan_sp = m_thread.QueueThreadPlanForRunToAddress(false, func_start_address,true);
-                }
-            }
-        }
-     }
-    
-     if (!m_sub_plan_sp)
-     {
-        m_no_more_plans = true;
-        SetPlanComplete();
-        return true;
-    }
-    else
-    {
-        m_no_more_plans = false;
-        m_sub_plan_sp->SetPrivate(true);
+          log->Printf("ShouldStopHere says we should step out of this frame.");
+      } else if (log) {
+        log->Printf(
+            "Thought I stepped out, but in fact arrived at a trampoline.");
+      }
+    } else if (frame_order == eFrameCompareEqual && InSymbol()) {
+      // If we are not in a place we should step through, we're done.
+      // One tricky bit here is that some stubs don't push a frame, so we have
+      // to check
+      // both the case of a frame that is younger, or the same as this frame.
+      // However, if the frame is the same, and we are still in the symbol we
+      // started
+      // in, the we don't need to do this.  This first check isn't strictly
+      // necessary,
+      // but it is more efficient.
+
+      // If we're still in the range, keep going, either by running to the next
+      // branch breakpoint, or by
+      // stepping.
+      if (InRange()) {
+        SetNextBranchBreakpoint();
         return false;
-    }
-}
+      }
 
-void 
-ThreadPlanStepInRange::SetAvoidRegexp(const char *name)
-{
-    if (!m_avoid_regexp_ap)
-        m_avoid_regexp_ap.reset (new RegularExpression(name));
-
-    m_avoid_regexp_ap->Compile (name);
-}
-
-void
-ThreadPlanStepInRange::SetDefaultFlagValue (uint32_t new_value)
-{
-    // TODO: Should we test this for sanity?
-    ThreadPlanStepInRange::s_default_flag_values = new_value;
-}
-
-bool
-ThreadPlanStepInRange::FrameMatchesAvoidCriteria ()
-{
-    StackFrame *frame = GetThread().GetStackFrameAtIndex(0).get();
-    
-    // Check the library list first, as that's cheapest:
-    bool libraries_say_avoid = false;
-
-    FileSpecList libraries_to_avoid (GetThread().GetLibrariesToAvoid());
-    size_t num_libraries = libraries_to_avoid.GetSize();
-    if (num_libraries > 0)
-    {
-        SymbolContext sc(frame->GetSymbolContext(eSymbolContextModule));
-        FileSpec frame_library(sc.module_sp->GetFileSpec());
-        
-        if (frame_library)
-        {
-            for (size_t i = 0; i < num_libraries; i++)
-            {
-                const FileSpec &file_spec(libraries_to_avoid.GetFileSpecAtIndex(i));
-                if (FileSpec::Equal (file_spec, frame_library, false))
-                {
-                    libraries_say_avoid = true;
-                    break;
-                }
-            }
-        }
-    }
-    if (libraries_say_avoid)
-        return true;
-    
-    const RegularExpression *avoid_regexp_to_use = m_avoid_regexp_ap.get();
-    if (avoid_regexp_to_use == nullptr)
-        avoid_regexp_to_use = GetThread().GetSymbolsToAvoidRegexp();
-        
-    if (avoid_regexp_to_use != nullptr)
-    {
-        SymbolContext sc = frame->GetSymbolContext(eSymbolContextFunction|eSymbolContextBlock|eSymbolContextSymbol);
-        if (sc.symbol != nullptr)
-        {
-            const char *frame_function_name = sc.GetFunctionName(Mangled::ePreferDemangledWithoutArguments).GetCString();
-            if (frame_function_name)
-            {
-                size_t num_matches = 0;
-                Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
-                if (log)
-                    num_matches = 1;
-                
-                RegularExpression::Match regex_match(num_matches);
-
-                bool return_value = avoid_regexp_to_use->Execute(frame_function_name, &regex_match);
-                if (return_value)
-                {
-                    if (log)
-                    {
-                        std::string match;
-                        regex_match.GetMatchAtIndex(frame_function_name,0, match);
-                        log->Printf ("Stepping out of function \"%s\" because it matches the avoid regexp \"%s\" - match substring: \"%s\".",
-                                     frame_function_name,
-                                     avoid_regexp_to_use->GetText(),
-                                     match.c_str());
-                    }
-
-                }
-                return return_value;
-            }
-        }
-    }
+      SetPlanComplete();
+      m_no_more_plans = true;
+      return true;
+    }
+
+    // If we get to this point, we're not going to use a previously set "next
+    // branch" breakpoint, so delete it:
+    ClearNextBranchBreakpoint();
+
+    // We may have set the plan up above in the FrameIsOlder section:
+
+    if (!m_sub_plan_sp)
+      m_sub_plan_sp = m_thread.QueueThreadPlanForStepThrough(m_stack_id, false,
+                                                             stop_others);
+
+    if (log) {
+      if (m_sub_plan_sp)
+        log->Printf("Found a step through plan: %s", m_sub_plan_sp->GetName());
+      else
+        log->Printf("No step through plan found.");
+    }
+
+    // If not, give the "should_stop" callback a chance to push a plan to get us
+    // out of here.
+    // But only do that if we actually have stepped in.
+    if (!m_sub_plan_sp && frame_order == eFrameCompareYounger)
+      m_sub_plan_sp = CheckShouldStopHereAndQueueStepOut(frame_order);
+
+    // If we've stepped in and we are going to stop here, check to see if we
+    // were asked to
+    // run past the prologue, and if so do that.
+
+    if (!m_sub_plan_sp && frame_order == eFrameCompareYounger &&
+        m_step_past_prologue) {
+      lldb::StackFrameSP curr_frame = m_thread.GetStackFrameAtIndex(0);
+      if (curr_frame) {
+        size_t bytes_to_skip = 0;
+        lldb::addr_t curr_addr = m_thread.GetRegisterContext()->GetPC();
+        Address func_start_address;
+
+        SymbolContext sc = curr_frame->GetSymbolContext(eSymbolContextFunction |
+                                                        eSymbolContextSymbol);
+
+        if (sc.function) {
+          func_start_address = sc.function->GetAddressRange().GetBaseAddress();
+          if (curr_addr ==
+              func_start_address.GetLoadAddress(
+                  m_thread.CalculateTarget().get()))
+            bytes_to_skip = sc.function->GetPrologueByteSize();
+        } else if (sc.symbol) {
+          func_start_address = sc.symbol->GetAddress();
+          if (curr_addr ==
+              func_start_address.GetLoadAddress(
+                  m_thread.CalculateTarget().get()))
+            bytes_to_skip = sc.symbol->GetPrologueByteSize();
+        }
+
+        if (bytes_to_skip != 0) {
+          func_start_address.Slide(bytes_to_skip);
+          log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP);
+          if (log)
+            log->Printf("Pushing past prologue ");
+
+          m_sub_plan_sp = m_thread.QueueThreadPlanForRunToAddress(
+              false, func_start_address, true);
+        }
+      }
+    }
+  }
+
+  if (!m_sub_plan_sp) {
+    m_no_more_plans = true;
+    SetPlanComplete();
+    return true;
+  } else {
+    m_no_more_plans = false;
+    m_sub_plan_sp->SetPrivate(true);
     return false;
+  }
 }
 
-bool
-ThreadPlanStepInRange::DefaultShouldStopHereCallback (ThreadPlan *current_plan, Flags &flags, FrameComparison operation, void *baton)
-{
-    bool should_stop_here = true;
-    StackFrame *frame = current_plan->GetThread().GetStackFrameAtIndex(0).get();
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
-
-    // First see if the ThreadPlanShouldStopHere default implementation thinks we should get out of here:
-    should_stop_here = ThreadPlanShouldStopHere::DefaultShouldStopHereCallback (current_plan, flags, operation, baton);
-    if (!should_stop_here)
-        return should_stop_here;
-    
-    if (should_stop_here && current_plan->GetKind() == eKindStepInRange && operation == eFrameCompareYounger)
-    {
-        ThreadPlanStepInRange *step_in_range_plan = static_cast<ThreadPlanStepInRange *> (current_plan);
-        if (step_in_range_plan->m_step_into_target)
-        {
-            SymbolContext sc = frame->GetSymbolContext(eSymbolContextFunction|eSymbolContextBlock|eSymbolContextSymbol);
-            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())
-                {
-                    should_stop_here = true;
-                }
-                else
-                {
-                    const char *target_name = step_in_range_plan->m_step_into_target.AsCString();
-                    const char *function_name = sc.GetFunctionName().AsCString();
-                    
-                    if (function_name == nullptr)
-                        should_stop_here = false;
-                    else if (strstr(function_name, target_name) == nullptr)
-                        should_stop_here = false;
-                }
-                if (log && !should_stop_here)
-                    log->Printf("Stepping out of frame %s which did not match step into target %s.",
-                                sc.GetFunctionName().AsCString(),
-                                step_in_range_plan->m_step_into_target.AsCString());
-            }
-        }
-        
-        if (should_stop_here)
-        {
-            ThreadPlanStepInRange *step_in_range_plan = static_cast<ThreadPlanStepInRange *> (current_plan);
-            // Don't log the should_step_out here, it's easier to do it in FrameMatchesAvoidCriteria.
-            should_stop_here = !step_in_range_plan->FrameMatchesAvoidCriteria ();
-        }
-    }
-    
-    return should_stop_here;
+void ThreadPlanStepInRange::SetAvoidRegexp(const char *name) {
+  if (!m_avoid_regexp_ap)
+    m_avoid_regexp_ap.reset(new RegularExpression(name));
+
+  m_avoid_regexp_ap->Compile(name);
 }
 
-bool
-ThreadPlanStepInRange::DoPlanExplainsStop (Event *event_ptr)
-{
-    // We always explain a stop.  Either we've just done a single step, in which
-    // case we'll do our ordinary processing, or we stopped for some
-    // reason that isn't handled by our sub-plans, in which case we want to just stop right
-    // away.
-    // In general, we don't want to mark the plan as complete for unexplained stops.
-    // For instance, if you step in to some code with no debug info, so you step out
-    // and in the course of that hit a breakpoint, then you want to stop & show the user
-    // the breakpoint, but not unship the step in plan, since you still may want to complete that
-    // plan when you continue.  This is particularly true when doing "step in to target function."
-    // stepping.
-    //
-    // 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 = false;
-    
-    if (m_virtual_step)
-    {
-        return_value = true;
-    }
-    else
-    {
-        StopInfoSP stop_info_sp = GetPrivateStopInfo ();
-        if (stop_info_sp)
-        {
-            StopReason reason = stop_info_sp->GetStopReason();
-            
-            if (reason ==  eStopReasonBreakpoint)
-            {
-                if (NextRangeBreakpointExplainsStop(stop_info_sp))
-                {
-                    return_value = true;
-                }
-            }
-            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;
-            }
-            else
-            {
-                return_value = true;
-            }
-        }
-        else
-            return_value = true;
-    }
-    
-    return return_value;
+void ThreadPlanStepInRange::SetDefaultFlagValue(uint32_t new_value) {
+  // TODO: Should we test this for sanity?
+  ThreadPlanStepInRange::s_default_flag_values = new_value;
 }
 
-bool
-ThreadPlanStepInRange::DoWillResume (lldb::StateType resume_state, bool current_plan)
-{
-    m_virtual_step = false;
-    if (resume_state == eStateStepping && current_plan)
-    {
-        // See if we are about to step over a virtual inlined call.
-        bool step_without_resume = m_thread.DecrementCurrentInlinedDepth();
-        if (step_without_resume)
-        {
-            Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
-            if (log)
-                log->Printf ("ThreadPlanStepInRange::DoWillResume: returning false, inline_depth: %d",
-                             m_thread.GetCurrentInlinedDepth());
-            SetStopInfo(StopInfo::CreateStopReasonToTrace(m_thread));
-            
-            // FIXME: Maybe it would be better to create a InlineStep stop reason, but then
-            // the whole rest of the world would have to handle that stop reason.
-            m_virtual_step = true;
+bool ThreadPlanStepInRange::FrameMatchesAvoidCriteria() {
+  StackFrame *frame = GetThread().GetStackFrameAtIndex(0).get();
+
+  // Check the library list first, as that's cheapest:
+  bool libraries_say_avoid = false;
+
+  FileSpecList libraries_to_avoid(GetThread().GetLibrariesToAvoid());
+  size_t num_libraries = libraries_to_avoid.GetSize();
+  if (num_libraries > 0) {
+    SymbolContext sc(frame->GetSymbolContext(eSymbolContextModule));
+    FileSpec frame_library(sc.module_sp->GetFileSpec());
+
+    if (frame_library) {
+      for (size_t i = 0; i < num_libraries; i++) {
+        const FileSpec &file_spec(libraries_to_avoid.GetFileSpecAtIndex(i));
+        if (FileSpec::Equal(file_spec, frame_library, false)) {
+          libraries_say_avoid = true;
+          break;
         }
-        return !step_without_resume;
+      }
     }
+  }
+  if (libraries_say_avoid)
     return true;
-}
 
-bool
-ThreadPlanStepInRange::IsVirtualStep()
-{
-    return m_virtual_step;
+  const RegularExpression *avoid_regexp_to_use = m_avoid_regexp_ap.get();
+  if (avoid_regexp_to_use == nullptr)
+    avoid_regexp_to_use = GetThread().GetSymbolsToAvoidRegexp();
+
+  if (avoid_regexp_to_use != nullptr) {
+    SymbolContext sc = frame->GetSymbolContext(
+        eSymbolContextFunction | eSymbolContextBlock | eSymbolContextSymbol);
+    if (sc.symbol != nullptr) {
+      const char *frame_function_name =
+          sc.GetFunctionName(Mangled::ePreferDemangledWithoutArguments)
+              .GetCString();
+      if (frame_function_name) {
+        size_t num_matches = 0;
+        Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
+        if (log)
+          num_matches = 1;
+
+        RegularExpression::Match regex_match(num_matches);
+
+        bool return_value =
+            avoid_regexp_to_use->Execute(frame_function_name, &regex_match);
+        if (return_value) {
+          if (log) {
+            std::string match;
+            regex_match.GetMatchAtIndex(frame_function_name, 0, match);
+            log->Printf("Stepping out of function \"%s\" because it matches "
+                        "the avoid regexp \"%s\" - match substring: \"%s\".",
+                        frame_function_name, avoid_regexp_to_use->GetText(),
+                        match.c_str());
+          }
+        }
+        return return_value;
+      }
+    }
+  }
+  return false;
+}
+
+bool ThreadPlanStepInRange::DefaultShouldStopHereCallback(
+    ThreadPlan *current_plan, Flags &flags, FrameComparison operation,
+    void *baton) {
+  bool should_stop_here = true;
+  StackFrame *frame = current_plan->GetThread().GetStackFrameAtIndex(0).get();
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
+
+  // First see if the ThreadPlanShouldStopHere default implementation thinks we
+  // should get out of here:
+  should_stop_here = ThreadPlanShouldStopHere::DefaultShouldStopHereCallback(
+      current_plan, flags, operation, baton);
+  if (!should_stop_here)
+    return should_stop_here;
+
+  if (should_stop_here && current_plan->GetKind() == eKindStepInRange &&
+      operation == eFrameCompareYounger) {
+    ThreadPlanStepInRange *step_in_range_plan =
+        static_cast<ThreadPlanStepInRange *>(current_plan);
+    if (step_in_range_plan->m_step_into_target) {
+      SymbolContext sc = frame->GetSymbolContext(
+          eSymbolContextFunction | eSymbolContextBlock | eSymbolContextSymbol);
+      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()) {
+          should_stop_here = true;
+        } else {
+          const char *target_name =
+              step_in_range_plan->m_step_into_target.AsCString();
+          const char *function_name = sc.GetFunctionName().AsCString();
+
+          if (function_name == nullptr)
+            should_stop_here = false;
+          else if (strstr(function_name, target_name) == nullptr)
+            should_stop_here = false;
+        }
+        if (log && !should_stop_here)
+          log->Printf("Stepping out of frame %s which did not match step into "
+                      "target %s.",
+                      sc.GetFunctionName().AsCString(),
+                      step_in_range_plan->m_step_into_target.AsCString());
+      }
+    }
+
+    if (should_stop_here) {
+      ThreadPlanStepInRange *step_in_range_plan =
+          static_cast<ThreadPlanStepInRange *>(current_plan);
+      // Don't log the should_step_out here, it's easier to do it in
+      // FrameMatchesAvoidCriteria.
+      should_stop_here = !step_in_range_plan->FrameMatchesAvoidCriteria();
+    }
+  }
+
+  return should_stop_here;
+}
+
+bool ThreadPlanStepInRange::DoPlanExplainsStop(Event *event_ptr) {
+  // We always explain a stop.  Either we've just done a single step, in which
+  // case we'll do our ordinary processing, or we stopped for some
+  // reason that isn't handled by our sub-plans, in which case we want to just
+  // stop right
+  // away.
+  // In general, we don't want to mark the plan as complete for unexplained
+  // stops.
+  // For instance, if you step in to some code with no debug info, so you step
+  // out
+  // and in the course of that hit a breakpoint, then you want to stop & show
+  // the user
+  // the breakpoint, but not unship the step in plan, since you still may want
+  // to complete that
+  // plan when you continue.  This is particularly true when doing "step in to
+  // target function."
+  // stepping.
+  //
+  // 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 = false;
+
+  if (m_virtual_step) {
+    return_value = true;
+  } else {
+    StopInfoSP stop_info_sp = GetPrivateStopInfo();
+    if (stop_info_sp) {
+      StopReason reason = stop_info_sp->GetStopReason();
+
+      if (reason == eStopReasonBreakpoint) {
+        if (NextRangeBreakpointExplainsStop(stop_info_sp)) {
+          return_value = true;
+        }
+      } 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;
+      } else {
+        return_value = true;
+      }
+    } else
+      return_value = true;
+  }
+
+  return return_value;
+}
+
+bool ThreadPlanStepInRange::DoWillResume(lldb::StateType resume_state,
+                                         bool current_plan) {
+  m_virtual_step = false;
+  if (resume_state == eStateStepping && current_plan) {
+    // See if we are about to step over a virtual inlined call.
+    bool step_without_resume = m_thread.DecrementCurrentInlinedDepth();
+    if (step_without_resume) {
+      Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
+      if (log)
+        log->Printf("ThreadPlanStepInRange::DoWillResume: returning false, "
+                    "inline_depth: %d",
+                    m_thread.GetCurrentInlinedDepth());
+      SetStopInfo(StopInfo::CreateStopReasonToTrace(m_thread));
+
+      // FIXME: Maybe it would be better to create a InlineStep stop reason, but
+      // then
+      // the whole rest of the world would have to handle that stop reason.
+      m_virtual_step = true;
+    }
+    return !step_without_resume;
+  }
+  return true;
 }
+
+bool ThreadPlanStepInRange::IsVirtualStep() { return m_virtual_step; }

Modified: lldb/trunk/source/Target/ThreadPlanStepInstruction.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanStepInstruction.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Target/ThreadPlanStepInstruction.cpp (original)
+++ lldb/trunk/source/Target/ThreadPlanStepInstruction.cpp Tue Sep  6 15:57:50 2016
@@ -27,270 +27,218 @@ using namespace lldb_private;
 // ThreadPlanStepInstruction: Step over the current instruction
 //----------------------------------------------------------------------
 
-ThreadPlanStepInstruction::ThreadPlanStepInstruction
-(
-    Thread &thread,
-    bool step_over,
-    bool stop_other_threads,
-    Vote stop_vote,
-    Vote run_vote
-) :
-    ThreadPlan (ThreadPlan::eKindStepInstruction, "Step over single instruction", thread, stop_vote, run_vote),
-    m_instruction_addr (0),
-    m_stop_other_threads (stop_other_threads),
-    m_step_over (step_over)
-{
-    m_takes_iteration_count = true;
-    SetUpState();
+ThreadPlanStepInstruction::ThreadPlanStepInstruction(Thread &thread,
+                                                     bool step_over,
+                                                     bool stop_other_threads,
+                                                     Vote stop_vote,
+                                                     Vote run_vote)
+    : ThreadPlan(ThreadPlan::eKindStepInstruction,
+                 "Step over single instruction", thread, stop_vote, run_vote),
+      m_instruction_addr(0), m_stop_other_threads(stop_other_threads),
+      m_step_over(step_over) {
+  m_takes_iteration_count = true;
+  SetUpState();
 }
 
 ThreadPlanStepInstruction::~ThreadPlanStepInstruction() = default;
 
-void
-ThreadPlanStepInstruction::SetUpState()
-{
-    m_instruction_addr = m_thread.GetRegisterContext()->GetPC(0);
-    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 != nullptr;
-    
-    StackFrameSP parent_frame_sp = m_thread.GetStackFrameAtIndex(1);
-    if (parent_frame_sp)
-        m_parent_frame_id = parent_frame_sp->GetStackID();
-}
+void ThreadPlanStepInstruction::SetUpState() {
+  m_instruction_addr = m_thread.GetRegisterContext()->GetPC(0);
+  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 != nullptr;
+
+  StackFrameSP parent_frame_sp = m_thread.GetStackFrameAtIndex(1);
+  if (parent_frame_sp)
+    m_parent_frame_id = parent_frame_sp->GetStackID();
+}
+
+void ThreadPlanStepInstruction::GetDescription(Stream *s,
+                                               lldb::DescriptionLevel level) {
+  if (level == lldb::eDescriptionLevelBrief) {
+    if (m_step_over)
+      s->Printf("instruction step over");
+    else
+      s->Printf("instruction step into");
+  } else {
+    s->Printf("Stepping one instruction past ");
+    s->Address(m_instruction_addr, sizeof(addr_t));
+    if (!m_start_has_symbol)
+      s->Printf(" which has no symbol");
 
-void
-ThreadPlanStepInstruction::GetDescription (Stream *s, lldb::DescriptionLevel level)
-{
-    if (level == lldb::eDescriptionLevelBrief)
-    {
-        if (m_step_over)
-            s->Printf ("instruction step over");
-        else
-            s->Printf ("instruction step into");
-    }
+    if (m_step_over)
+      s->Printf(" stepping over calls");
     else
-    {
-        s->Printf ("Stepping one instruction past ");
-        s->Address(m_instruction_addr, sizeof (addr_t));
-        if (!m_start_has_symbol)
-            s->Printf(" which has no symbol");
-        
-        if (m_step_over)
-            s->Printf(" stepping over calls");
-        else
-            s->Printf(" stepping into calls");
-    }
+      s->Printf(" stepping into calls");
+  }
 }
 
-bool
-ThreadPlanStepInstruction::ValidatePlan (Stream *error)
-{
-    // Since we read the instruction we're stepping over from the thread,
-    // this plan will always work.
+bool ThreadPlanStepInstruction::ValidatePlan(Stream *error) {
+  // Since we read the instruction we're stepping over from the thread,
+  // this plan will always work.
+  return true;
+}
+
+bool ThreadPlanStepInstruction::DoPlanExplainsStop(Event *event_ptr) {
+  StopInfoSP stop_info_sp = GetPrivateStopInfo();
+  if (stop_info_sp) {
+    StopReason reason = stop_info_sp->GetStopReason();
+    return (reason == eStopReasonTrace || reason == eStopReasonNone);
+  }
+  return false;
+}
+
+bool ThreadPlanStepInstruction::IsPlanStale() {
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
+  StackID cur_frame_id = m_thread.GetStackFrameAtIndex(0)->GetStackID();
+  if (cur_frame_id == m_stack_id) {
+    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.
+    return !m_step_over;
+  } else {
+    if (log) {
+      log->Printf("ThreadPlanStepInstruction::IsPlanStale - Current frame is "
+                  "older than start frame, plan is stale.");
+    }
     return true;
+  }
 }
 
-bool
-ThreadPlanStepInstruction::DoPlanExplainsStop (Event *event_ptr)
-{
-    StopInfoSP stop_info_sp = GetPrivateStopInfo ();
-    if (stop_info_sp)
-    {
-        StopReason reason = stop_info_sp->GetStopReason();
-        return (reason == eStopReasonTrace || reason == eStopReasonNone);
-    }
-    return false;
-}
+bool ThreadPlanStepInstruction::ShouldStop(Event *event_ptr) {
+  if (m_step_over) {
+    Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
+
+    StackFrameSP cur_frame_sp = m_thread.GetStackFrameAtIndex(0);
+    if (!cur_frame_sp) {
+      if (log)
+        log->Printf(
+            "ThreadPlanStepInstruction couldn't get the 0th frame, stopping.");
+      SetPlanComplete();
+      return true;
+    }
+
+    StackID cur_frame_zero_id = cur_frame_sp->GetStackID();
+
+    if (cur_frame_zero_id == m_stack_id || m_stack_id < cur_frame_zero_id) {
+      if (m_thread.GetRegisterContext()->GetPC(0) != m_instruction_addr) {
+        if (--m_iteration_count <= 0) {
+          SetPlanComplete();
+          return true;
+        } else {
+          // We are still stepping, reset the start pc, and in case we've
+          // stepped out,
+          // reset the current stack id.
+          SetUpState();
+          return false;
+        }
+      } else
+        return false;
+    } else {
+      // We've stepped in, step back out again:
+      StackFrame *return_frame = m_thread.GetStackFrameAtIndex(1).get();
+      if (return_frame) {
+        if (return_frame->GetStackID() != m_parent_frame_id ||
+            m_start_has_symbol) {
+          // next-instruction shouldn't step out of inlined functions.  But we
+          // may have stepped into a
+          // real function that starts with an inlined function, and we do want
+          // to step out of that...
+
+          if (cur_frame_sp->IsInlined()) {
+            StackFrameSP parent_frame_sp =
+                m_thread.GetFrameWithStackID(m_stack_id);
+
+            if (parent_frame_sp &&
+                parent_frame_sp->GetConcreteFrameIndex() ==
+                    cur_frame_sp->GetConcreteFrameIndex()) {
+              SetPlanComplete();
+              if (log) {
+                log->Printf("Frame we stepped into is inlined into the frame "
+                            "we were stepping from, stopping.");
+              }
+              return true;
+            }
+          }
 
-bool
-ThreadPlanStepInstruction::IsPlanStale ()
-{
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
-    StackID cur_frame_id = m_thread.GetStackFrameAtIndex(0)->GetStackID();
-    if (cur_frame_id == m_stack_id)
-    {
-        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.
-        return !m_step_over;
-    }
-    else
-    {
-        if (log)
-        {
-            log->Printf ("ThreadPlanStepInstruction::IsPlanStale - Current frame is older than start frame, plan is stale.");
+          if (log) {
+            StreamString s;
+            s.PutCString("Stepped in to: ");
+            addr_t stop_addr =
+                m_thread.GetStackFrameAtIndex(0)->GetRegisterContext()->GetPC();
+            s.Address(stop_addr, m_thread.CalculateTarget()
+                                     ->GetArchitecture()
+                                     .GetAddressByteSize());
+            s.PutCString(" stepping out to: ");
+            addr_t return_addr = return_frame->GetRegisterContext()->GetPC();
+            s.Address(return_addr, m_thread.CalculateTarget()
+                                       ->GetArchitecture()
+                                       .GetAddressByteSize());
+            log->Printf("%s.", s.GetData());
+          }
+
+          // StepInstruction should probably have the tri-state RunMode, but for
+          // now it is safer to
+          // run others.
+          const bool stop_others = false;
+          m_thread.QueueThreadPlanForStepOutNoShouldStop(
+              false, nullptr, true, stop_others, eVoteNo, eVoteNoOpinion, 0);
+          return false;
+        } else {
+          if (log) {
+            log->PutCString(
+                "The stack id we are stepping in changed, but our parent frame "
+                "did not when stepping from code with no symbols.  "
+                "We are probably just confused about where we are, stopping.");
+          }
+          SetPlanComplete();
+          return true;
         }
+      } else {
+        if (log)
+          log->Printf("Could not find previous frame, stopping.");
+        SetPlanComplete();
         return true;
+      }
     }
+  } else {
+    lldb::addr_t pc_addr = m_thread.GetRegisterContext()->GetPC(0);
+    if (pc_addr != m_instruction_addr) {
+      if (--m_iteration_count <= 0) {
+        SetPlanComplete();
+        return true;
+      } else {
+        // We are still stepping, reset the start pc, and in case we've stepped
+        // in or out,
+        // reset the current stack id.
+        SetUpState();
+        return false;
+      }
+    } else
+      return false;
+  }
 }
 
-bool
-ThreadPlanStepInstruction::ShouldStop (Event *event_ptr)
-{
-    if (m_step_over)
-    {
-        Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
-        
-        StackFrameSP cur_frame_sp = m_thread.GetStackFrameAtIndex(0);
-        if (!cur_frame_sp)
-        {
-            if (log)
-                log->Printf ("ThreadPlanStepInstruction couldn't get the 0th frame, stopping.");
-            SetPlanComplete();
-            return true;
-        }
+bool ThreadPlanStepInstruction::StopOthers() { return m_stop_other_threads; }
 
-        StackID cur_frame_zero_id = cur_frame_sp->GetStackID();
-        
-        if (cur_frame_zero_id == m_stack_id || m_stack_id < cur_frame_zero_id)
-        {
-            if (m_thread.GetRegisterContext()->GetPC(0) != m_instruction_addr)
-            {
-                if (--m_iteration_count <= 0)
-                {
-                    SetPlanComplete();
-                    return true;
-                }
-                else
-                {
-                    // We are still stepping, reset the start pc, and in case we've stepped out,
-                    // reset the current stack id.
-                    SetUpState();
-                    return false;
-                }
-            }
-            else
-                return false;
-        }
-        else
-        {
-            // We've stepped in, step back out again:
-            StackFrame *return_frame = m_thread.GetStackFrameAtIndex(1).get();
-            if (return_frame)
-            {
-                if (return_frame->GetStackID() != m_parent_frame_id || m_start_has_symbol)
-                {
-                    // next-instruction shouldn't step out of inlined functions.  But we may have stepped into a
-                    // real function that starts with an inlined function, and we do want to step out of that...
-
-                    if (cur_frame_sp->IsInlined())
-                    {
-                        StackFrameSP parent_frame_sp = m_thread.GetFrameWithStackID(m_stack_id);
-
-                        if(parent_frame_sp && parent_frame_sp->GetConcreteFrameIndex() == cur_frame_sp->GetConcreteFrameIndex())
-                        {
-                            SetPlanComplete();
-                            if (log)
-                            {
-                                log->Printf("Frame we stepped into is inlined into the frame we were stepping from, stopping.");
-                            }
-                            return true;
-                        }
-                    }
-
-                    if (log)
-                    {
-                        StreamString s;
-                        s.PutCString ("Stepped in to: ");
-                        addr_t stop_addr = m_thread.GetStackFrameAtIndex(0)->GetRegisterContext()->GetPC();
-                        s.Address (stop_addr, m_thread.CalculateTarget()->GetArchitecture().GetAddressByteSize());
-                        s.PutCString (" stepping out to: ");
-                        addr_t return_addr = return_frame->GetRegisterContext()->GetPC();
-                        s.Address (return_addr, m_thread.CalculateTarget()->GetArchitecture().GetAddressByteSize());
-                        log->Printf("%s.", s.GetData());
-                    }
-                    
-                    // StepInstruction should probably have the tri-state RunMode, but for now it is safer to
-                    // run others.
-                    const bool stop_others = false;
-                    m_thread.QueueThreadPlanForStepOutNoShouldStop(false,
-                                                                   nullptr,
-                                                                   true,
-                                                                   stop_others,
-                                                                   eVoteNo,
-                                                                   eVoteNoOpinion,
-                                                                   0);
-                    return false;
-                }
-                else
-                {
-                    if (log)
-                    {
-                        log->PutCString("The stack id we are stepping in changed, but our parent frame did not when stepping from code with no symbols.  "
-                        "We are probably just confused about where we are, stopping.");
-                    }
-                    SetPlanComplete();
-                    return true;
-                }
-            }
-            else
-            {
-                if (log)
-                    log->Printf("Could not find previous frame, stopping.");
-                SetPlanComplete();
-                return true;
-            }
-        }
-    }
-    else
-    {
-        lldb::addr_t pc_addr = m_thread.GetRegisterContext()->GetPC(0);
-        if (pc_addr != m_instruction_addr)
-        {
-            if (--m_iteration_count <= 0)
-            {
-                SetPlanComplete();
-                return true;
-            }
-            else
-            {
-                // We are still stepping, reset the start pc, and in case we've stepped in or out,
-                // reset the current stack id.
-                SetUpState();
-                return false;
-            }
-        }
-        else
-            return false;
-    }
-}
-
-bool
-ThreadPlanStepInstruction::StopOthers ()
-{
-    return m_stop_other_threads;
+StateType ThreadPlanStepInstruction::GetPlanRunState() {
+  return eStateStepping;
 }
 
-StateType
-ThreadPlanStepInstruction::GetPlanRunState ()
-{
-    return eStateStepping;
-}
+bool ThreadPlanStepInstruction::WillStop() { return true; }
 
-bool
-ThreadPlanStepInstruction::WillStop ()
-{
+bool ThreadPlanStepInstruction::MischiefManaged() {
+  if (IsPlanComplete()) {
+    Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
+    if (log)
+      log->Printf("Completed single instruction step plan.");
+    ThreadPlan::MischiefManaged();
     return true;
-}
-
-bool
-ThreadPlanStepInstruction::MischiefManaged ()
-{
-    if (IsPlanComplete())
-    {
-        Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
-        if (log)
-            log->Printf("Completed single instruction step plan.");
-        ThreadPlan::MischiefManaged ();
-        return true;
-    }
-    else
-    {
-        return false;
-    }
+  } else {
+    return false;
+  }
 }

Modified: lldb/trunk/source/Target/ThreadPlanStepOut.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanStepOut.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Target/ThreadPlanStepOut.cpp (original)
+++ lldb/trunk/source/Target/ThreadPlanStepOut.cpp Tue Sep  6 15:57:50 2016
@@ -36,529 +36,450 @@ uint32_t ThreadPlanStepOut::s_default_fl
 //----------------------------------------------------------------------
 // ThreadPlanStepOut: Step out of the current frame
 //----------------------------------------------------------------------
-ThreadPlanStepOut::ThreadPlanStepOut
-(
-    Thread &thread,
-    SymbolContext *context,
-    bool first_insn,
-    bool stop_others,
-    Vote stop_vote,
-    Vote run_vote,
-    uint32_t frame_idx,
+ThreadPlanStepOut::ThreadPlanStepOut(
+    Thread &thread, SymbolContext *context, bool first_insn, bool stop_others,
+    Vote stop_vote, Vote run_vote, uint32_t frame_idx,
     LazyBool step_out_avoids_code_without_debug_info,
-    bool continue_to_next_branch,
-    bool gather_return_value
-) :
-    ThreadPlan (ThreadPlan::eKindStepOut, "Step out", thread, stop_vote, run_vote),
-    ThreadPlanShouldStopHere (this),
-    m_step_from_insn (LLDB_INVALID_ADDRESS),
-    m_return_bp_id (LLDB_INVALID_BREAK_ID),
-    m_return_addr (LLDB_INVALID_ADDRESS),
-    m_stop_others (stop_others),
-    m_immediate_step_from_function(nullptr),
-    m_calculate_return_value(gather_return_value)
-{
-    SetFlagsToDefault();
-    SetupAvoidNoDebug(step_out_avoids_code_without_debug_info);
-    
-    m_step_from_insn = m_thread.GetRegisterContext()->GetPC(0);
-
-    StackFrameSP return_frame_sp (m_thread.GetStackFrameAtIndex(frame_idx + 1));
-    StackFrameSP immediate_return_from_sp (m_thread.GetStackFrameAtIndex (frame_idx));
-    
-    if (!return_frame_sp || !immediate_return_from_sp)
-        return; // we can't do anything here.  ValidatePlan() will return false.
-    
-    m_step_out_to_id = return_frame_sp->GetStackID();
-    m_immediate_step_from_id = immediate_return_from_sp->GetStackID();
-
-    // If the frame directly below the one we are returning to is inlined, we have to be
-    // a little more careful.  It is non-trivial to determine the real "return code address" for
-    // an inlined frame, so we have to work our way to that frame and then step out.
-    if (immediate_return_from_sp && immediate_return_from_sp->IsInlined())
-    {
-        if (frame_idx > 0)
-        {
-            // First queue a plan that gets us to this inlined frame, and when we get there we'll queue a second
-            // plan that walks us out of this frame.
-            m_step_out_to_inline_plan_sp.reset(new ThreadPlanStepOut(m_thread,
-                                                                     nullptr,
-                                                                     false,
-                                                                     stop_others,
-                                                                     eVoteNoOpinion,
-                                                                     eVoteNoOpinion,
-                                                                     frame_idx - 1,
-                                                                     eLazyBoolNo,
-                                                                     continue_to_next_branch));
-            static_cast<ThreadPlanStepOut *>(m_step_out_to_inline_plan_sp.get())->SetShouldStopHereCallbacks(nullptr, nullptr);
-            m_step_out_to_inline_plan_sp->SetPrivate(true);
-        }
-        else
-        {
-            // If we're already at the inlined frame we're stepping through, then just do that now.
-            QueueInlinedStepPlan(false);
-        }
-    }
-    else if (return_frame_sp)
-    {
-        // Find the return address and set a breakpoint there:
-        // FIXME - can we do this more securely if we know first_insn?
-
-        Address return_address (return_frame_sp->GetFrameCodeAddress());
-        if (continue_to_next_branch)
-        {
-            SymbolContext return_address_sc;
-            AddressRange range;
-            Address return_address_decr_pc = return_address;
-            if (return_address_decr_pc.GetOffset() > 0)
-                return_address_decr_pc.Slide (-1);
-
-            return_address_decr_pc.CalculateSymbolContext (&return_address_sc, lldb::eSymbolContextLineEntry);
-            if (return_address_sc.line_entry.IsValid())
-            {
-                range = return_address_sc.line_entry.GetSameLineContiguousAddressRange();
-                if (range.GetByteSize() > 0)
-                {
-                    return_address = m_thread.GetProcess()->AdvanceAddressToNextBranchInstruction (return_address, 
-                                                                                                   range);
-                }
-            }
-        }
-        m_return_addr = return_address.GetLoadAddress(&m_thread.GetProcess()->GetTarget());
-        
-        if (m_return_addr == LLDB_INVALID_ADDRESS)
-            return;
-        
-        Breakpoint *return_bp = m_thread.CalculateTarget()->CreateBreakpoint (m_return_addr, true, false).get();
-        if (return_bp != nullptr)
-        {
-            return_bp->SetThreadID(m_thread.GetID());
-            m_return_bp_id = return_bp->GetID();
-            return_bp->SetBreakpointKind ("step-out");
-        }
-        
-        if (immediate_return_from_sp)
-        {
-            const SymbolContext &sc = immediate_return_from_sp->GetSymbolContext(eSymbolContextFunction);
-            if (sc.function)
-            {
-                m_immediate_step_from_function = sc.function; 
-            }
-        }
-    }
-}
-
-void
-ThreadPlanStepOut::SetupAvoidNoDebug(LazyBool step_out_avoids_code_without_debug_info)
-{
-    bool avoid_nodebug = true;
-    switch (step_out_avoids_code_without_debug_info)
-    {
-        case eLazyBoolYes:
-            avoid_nodebug = true;
-            break;
-        case eLazyBoolNo:
-            avoid_nodebug = false;
-            break;
-        case eLazyBoolCalculate:
-            avoid_nodebug = m_thread.GetStepOutAvoidsNoDebug();
-            break;
-    }
-    if (avoid_nodebug)
-        GetFlags().Set (ThreadPlanShouldStopHere::eStepOutAvoidNoDebug);
-    else
-        GetFlags().Clear (ThreadPlanShouldStopHere::eStepOutAvoidNoDebug);
-}
-
-void
-ThreadPlanStepOut::DidPush()
-{
+    bool continue_to_next_branch, bool gather_return_value)
+    : ThreadPlan(ThreadPlan::eKindStepOut, "Step out", thread, stop_vote,
+                 run_vote),
+      ThreadPlanShouldStopHere(this), m_step_from_insn(LLDB_INVALID_ADDRESS),
+      m_return_bp_id(LLDB_INVALID_BREAK_ID),
+      m_return_addr(LLDB_INVALID_ADDRESS), m_stop_others(stop_others),
+      m_immediate_step_from_function(nullptr),
+      m_calculate_return_value(gather_return_value) {
+  SetFlagsToDefault();
+  SetupAvoidNoDebug(step_out_avoids_code_without_debug_info);
+
+  m_step_from_insn = m_thread.GetRegisterContext()->GetPC(0);
+
+  StackFrameSP return_frame_sp(m_thread.GetStackFrameAtIndex(frame_idx + 1));
+  StackFrameSP immediate_return_from_sp(
+      m_thread.GetStackFrameAtIndex(frame_idx));
+
+  if (!return_frame_sp || !immediate_return_from_sp)
+    return; // we can't do anything here.  ValidatePlan() will return false.
+
+  m_step_out_to_id = return_frame_sp->GetStackID();
+  m_immediate_step_from_id = immediate_return_from_sp->GetStackID();
+
+  // If the frame directly below the one we are returning to is inlined, we have
+  // to be
+  // a little more careful.  It is non-trivial to determine the real "return
+  // code address" for
+  // an inlined frame, so we have to work our way to that frame and then step
+  // out.
+  if (immediate_return_from_sp && immediate_return_from_sp->IsInlined()) {
+    if (frame_idx > 0) {
+      // First queue a plan that gets us to this inlined frame, and when we get
+      // there we'll queue a second
+      // plan that walks us out of this frame.
+      m_step_out_to_inline_plan_sp.reset(new ThreadPlanStepOut(
+          m_thread, nullptr, false, stop_others, eVoteNoOpinion, eVoteNoOpinion,
+          frame_idx - 1, eLazyBoolNo, continue_to_next_branch));
+      static_cast<ThreadPlanStepOut *>(m_step_out_to_inline_plan_sp.get())
+          ->SetShouldStopHereCallbacks(nullptr, nullptr);
+      m_step_out_to_inline_plan_sp->SetPrivate(true);
+    } else {
+      // If we're already at the inlined frame we're stepping through, then just
+      // do that now.
+      QueueInlinedStepPlan(false);
+    }
+  } else if (return_frame_sp) {
+    // Find the return address and set a breakpoint there:
+    // FIXME - can we do this more securely if we know first_insn?
+
+    Address return_address(return_frame_sp->GetFrameCodeAddress());
+    if (continue_to_next_branch) {
+      SymbolContext return_address_sc;
+      AddressRange range;
+      Address return_address_decr_pc = return_address;
+      if (return_address_decr_pc.GetOffset() > 0)
+        return_address_decr_pc.Slide(-1);
+
+      return_address_decr_pc.CalculateSymbolContext(
+          &return_address_sc, lldb::eSymbolContextLineEntry);
+      if (return_address_sc.line_entry.IsValid()) {
+        range =
+            return_address_sc.line_entry.GetSameLineContiguousAddressRange();
+        if (range.GetByteSize() > 0) {
+          return_address =
+              m_thread.GetProcess()->AdvanceAddressToNextBranchInstruction(
+                  return_address, range);
+        }
+      }
+    }
+    m_return_addr =
+        return_address.GetLoadAddress(&m_thread.GetProcess()->GetTarget());
+
+    if (m_return_addr == LLDB_INVALID_ADDRESS)
+      return;
+
+    Breakpoint *return_bp = m_thread.CalculateTarget()
+                                ->CreateBreakpoint(m_return_addr, true, false)
+                                .get();
+    if (return_bp != nullptr) {
+      return_bp->SetThreadID(m_thread.GetID());
+      m_return_bp_id = return_bp->GetID();
+      return_bp->SetBreakpointKind("step-out");
+    }
+
+    if (immediate_return_from_sp) {
+      const SymbolContext &sc =
+          immediate_return_from_sp->GetSymbolContext(eSymbolContextFunction);
+      if (sc.function) {
+        m_immediate_step_from_function = sc.function;
+      }
+    }
+  }
+}
+
+void ThreadPlanStepOut::SetupAvoidNoDebug(
+    LazyBool step_out_avoids_code_without_debug_info) {
+  bool avoid_nodebug = true;
+  switch (step_out_avoids_code_without_debug_info) {
+  case eLazyBoolYes:
+    avoid_nodebug = true;
+    break;
+  case eLazyBoolNo:
+    avoid_nodebug = false;
+    break;
+  case eLazyBoolCalculate:
+    avoid_nodebug = m_thread.GetStepOutAvoidsNoDebug();
+    break;
+  }
+  if (avoid_nodebug)
+    GetFlags().Set(ThreadPlanShouldStopHere::eStepOutAvoidNoDebug);
+  else
+    GetFlags().Clear(ThreadPlanShouldStopHere::eStepOutAvoidNoDebug);
+}
+
+void ThreadPlanStepOut::DidPush() {
+  if (m_step_out_to_inline_plan_sp)
+    m_thread.QueueThreadPlan(m_step_out_to_inline_plan_sp, false);
+  else if (m_step_through_inline_plan_sp)
+    m_thread.QueueThreadPlan(m_step_through_inline_plan_sp, false);
+}
+
+ThreadPlanStepOut::~ThreadPlanStepOut() {
+  if (m_return_bp_id != LLDB_INVALID_BREAK_ID)
+    m_thread.CalculateTarget()->RemoveBreakpointByID(m_return_bp_id);
+}
+
+void ThreadPlanStepOut::GetDescription(Stream *s,
+                                       lldb::DescriptionLevel level) {
+  if (level == lldb::eDescriptionLevelBrief)
+    s->Printf("step out");
+  else {
     if (m_step_out_to_inline_plan_sp)
-        m_thread.QueueThreadPlan(m_step_out_to_inline_plan_sp, false);
+      s->Printf("Stepping out to inlined frame so we can walk through it.");
     else if (m_step_through_inline_plan_sp)
-        m_thread.QueueThreadPlan(m_step_through_inline_plan_sp, false);
+      s->Printf("Stepping out by stepping through inlined function.");
+    else {
+      s->Printf("Stepping out from ");
+      Address tmp_address;
+      if (tmp_address.SetLoadAddress(m_step_from_insn, &GetTarget())) {
+        tmp_address.Dump(s, &GetThread(), Address::DumpStyleResolvedDescription,
+                         Address::DumpStyleLoadAddress);
+      } else {
+        s->Printf("address 0x%" PRIx64 "", (uint64_t)m_step_from_insn);
+      }
+
+      // 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 ");
+      if (tmp_address.SetLoadAddress(m_return_addr, &GetTarget())) {
+        tmp_address.Dump(s, &GetThread(), Address::DumpStyleResolvedDescription,
+                         Address::DumpStyleLoadAddress);
+      } else {
+        s->Printf("address 0x%" PRIx64 "", (uint64_t)m_return_addr);
+      }
+
+      if (level == eDescriptionLevelVerbose)
+        s->Printf(" using breakpoint site %d", m_return_bp_id);
+    }
+  }
+}
+
+bool ThreadPlanStepOut::ValidatePlan(Stream *error) {
+  if (m_step_out_to_inline_plan_sp)
+    return m_step_out_to_inline_plan_sp->ValidatePlan(error);
+  else if (m_step_through_inline_plan_sp)
+    return m_step_through_inline_plan_sp->ValidatePlan(error);
+  else if (m_return_bp_id == LLDB_INVALID_BREAK_ID) {
+    if (error)
+      error->PutCString("Could not create return address breakpoint.");
+    return false;
+  } else
+    return true;
 }
 
-ThreadPlanStepOut::~ThreadPlanStepOut ()
-{
-    if (m_return_bp_id != LLDB_INVALID_BREAK_ID)
-        m_thread.CalculateTarget()->RemoveBreakpointByID(m_return_bp_id);
-}
+bool 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) {
+    return m_step_out_to_inline_plan_sp->MischiefManaged();
+  } else if (m_step_through_inline_plan_sp) {
+    if (m_step_through_inline_plan_sp->MischiefManaged()) {
+      CalculateReturnValue();
+      SetPlanComplete();
+      return true;
+    } else
+      return false;
+  } else if (m_step_out_further_plan_sp) {
+    return m_step_out_further_plan_sp->MischiefManaged();
+  }
+
+  // We don't explain signals or breakpoints (breakpoints that handle stepping
+  // in or
+  // out will be handled by a child plan.
+
+  StopInfoSP stop_info_sp = GetPrivateStopInfo();
+  if (stop_info_sp) {
+    StopReason reason = stop_info_sp->GetStopReason();
+    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()));
+      if (site_sp && site_sp->IsBreakpointAtThisSite(m_return_bp_id)) {
+        bool done;
 
-void
-ThreadPlanStepOut::GetDescription (Stream *s, lldb::DescriptionLevel level)
-{
-    if (level == lldb::eDescriptionLevelBrief)
-        s->Printf ("step out");
-    else
-    {
-        if (m_step_out_to_inline_plan_sp)
-            s->Printf ("Stepping out to inlined frame so we can walk through it.");
-        else if (m_step_through_inline_plan_sp)
-            s->Printf ("Stepping out by stepping through inlined function.");
-        else
-        {
-            s->Printf ("Stepping out from ");
-            Address tmp_address;
-            if (tmp_address.SetLoadAddress (m_step_from_insn, &GetTarget()))
-            {
-                tmp_address.Dump(s, &GetThread(), Address::DumpStyleResolvedDescription, Address::DumpStyleLoadAddress);
-            }
-            else
-            {
-                s->Printf ("address 0x%" PRIx64 "", (uint64_t)m_step_from_insn);
-            }
-
-            // 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 ");
-            if (tmp_address.SetLoadAddress (m_return_addr, &GetTarget()))
-            {
-                tmp_address.Dump(s, &GetThread(), Address::DumpStyleResolvedDescription, Address::DumpStyleLoadAddress);
-            }
-            else
-            {
-                s->Printf ("address 0x%" PRIx64 "", (uint64_t)m_return_addr);
-            }
+        StackID frame_zero_id = m_thread.GetStackFrameAtIndex(0)->GetStackID();
 
-            if (level == eDescriptionLevelVerbose)
-                s->Printf(" using breakpoint site %d", m_return_bp_id);
+        if (m_step_out_to_id == frame_zero_id)
+          done = true;
+        else if (m_step_out_to_id < frame_zero_id) {
+          // Either we stepped past the breakpoint, or the stack ID calculation
+          // was incorrect and we should probably stop.
+          done = true;
+        } else {
+          done = (m_immediate_step_from_id < frame_zero_id);
         }
-    }
-}
 
-bool
-ThreadPlanStepOut::ValidatePlan (Stream *error)
-{
-    if (m_step_out_to_inline_plan_sp)
-        return m_step_out_to_inline_plan_sp->ValidatePlan (error);
-    else if (m_step_through_inline_plan_sp)
-        return m_step_through_inline_plan_sp->ValidatePlan (error);
-    else if (m_return_bp_id == LLDB_INVALID_BREAK_ID)
-    {
-        if (error)
-            error->PutCString("Could not create return address breakpoint.");
-        return false;
-    }
-    else
-        return true;
-}
-
-bool
-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)
-    {
-        return m_step_out_to_inline_plan_sp->MischiefManaged();
-    }
-    else if (m_step_through_inline_plan_sp)
-    {
-        if (m_step_through_inline_plan_sp->MischiefManaged())
-        {
+        if (done) {
+          if (InvokeShouldStopHereCallback(eFrameCompareOlder)) {
             CalculateReturnValue();
             SetPlanComplete();
-            return true;
-        }
-        else
-            return false;
-    }
-    else if (m_step_out_further_plan_sp)
-    {
-        return m_step_out_further_plan_sp->MischiefManaged();
-    }
-        
-    // We don't explain signals or breakpoints (breakpoints that handle stepping in or
-    // out will be handled by a child plan.
-    
-    StopInfoSP stop_info_sp = GetPrivateStopInfo ();
-    if (stop_info_sp)
-    {
-        StopReason reason = stop_info_sp->GetStopReason();
-        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()));
-            if (site_sp && site_sp->IsBreakpointAtThisSite (m_return_bp_id))
-            {
-                bool done;
-                
-                StackID frame_zero_id = m_thread.GetStackFrameAtIndex(0)->GetStackID();
-                
-                if (m_step_out_to_id == frame_zero_id)
-                    done = true;
-                else if (m_step_out_to_id < frame_zero_id)
-                {
-                    // Either we stepped past the breakpoint, or the stack ID calculation
-                    // was incorrect and we should probably stop.
-                    done = true;
-                }
-                else
-                {
-                    done = (m_immediate_step_from_id < frame_zero_id);
-                }
-                    
-                if (done)
-                {
-                    if (InvokeShouldStopHereCallback (eFrameCompareOlder))
-                    {
-                        CalculateReturnValue();
-                        SetPlanComplete();
-                    }
-                }
-
-                // If there was only one owner, then we're done.  But if we also hit some
-                // user breakpoint on our way out, we should mark ourselves as done, but
-                // also not claim to explain the stop, since it is more important to report
-                // the user breakpoint than the step out completion.
-
-                if (site_sp->GetNumberOfOwners() == 1)
-                    return true;
-            }
-            return false;
+          }
         }
-        else if (IsUsuallyUnexplainedStopReason(reason))
-            return false;
-        else
-            return true;
-    }
-    return true;
+
+        // If there was only one owner, then we're done.  But if we also hit
+        // some
+        // user breakpoint on our way out, we should mark ourselves as done, but
+        // also not claim to explain the stop, since it is more important to
+        // report
+        // the user breakpoint than the step out completion.
+
+        if (site_sp->GetNumberOfOwners() == 1)
+          return true;
+      }
+      return false;
+    } else if (IsUsuallyUnexplainedStopReason(reason))
+      return false;
+    else
+      return true;
+  }
+  return true;
 }
 
-bool
-ThreadPlanStepOut::ShouldStop (Event *event_ptr)
-{
-    if (IsPlanComplete())
+bool ThreadPlanStepOut::ShouldStop(Event *event_ptr) {
+  if (IsPlanComplete())
+    return true;
+
+  bool done = false;
+  if (m_step_out_to_inline_plan_sp) {
+    if (m_step_out_to_inline_plan_sp->MischiefManaged()) {
+      // Now step through the inlined stack we are in:
+      if (QueueInlinedStepPlan(true)) {
+        // If we can't queue a plan to do this, then just call ourselves done.
+        m_step_out_to_inline_plan_sp.reset();
+        SetPlanComplete(false);
         return true;
-    
-    bool done = false;
-    if (m_step_out_to_inline_plan_sp)
-    {
-        if (m_step_out_to_inline_plan_sp->MischiefManaged())
-        {
-            // Now step through the inlined stack we are in:
-            if (QueueInlinedStepPlan(true))
-            {
-                // If we can't queue a plan to do this, then just call ourselves done.
-                m_step_out_to_inline_plan_sp.reset();
-                SetPlanComplete (false);
-                return true;
-            }
-            else
-                done = true;
-        }
-        else
-            return m_step_out_to_inline_plan_sp->ShouldStop(event_ptr);
-    }
-    else if (m_step_through_inline_plan_sp)
-    {
-        if (m_step_through_inline_plan_sp->MischiefManaged())
-            done = true;
-        else
-            return m_step_through_inline_plan_sp->ShouldStop(event_ptr);
-    }
-    else if (m_step_out_further_plan_sp)
-    {
-        if (m_step_out_further_plan_sp->MischiefManaged())
-            m_step_out_further_plan_sp.reset();
-        else
-            return m_step_out_further_plan_sp->ShouldStop(event_ptr);
-    }
+      } else
+        done = true;
+    } else
+      return m_step_out_to_inline_plan_sp->ShouldStop(event_ptr);
+  } else if (m_step_through_inline_plan_sp) {
+    if (m_step_through_inline_plan_sp->MischiefManaged())
+      done = true;
+    else
+      return m_step_through_inline_plan_sp->ShouldStop(event_ptr);
+  } else if (m_step_out_further_plan_sp) {
+    if (m_step_out_further_plan_sp->MischiefManaged())
+      m_step_out_further_plan_sp.reset();
+    else
+      return m_step_out_further_plan_sp->ShouldStop(event_ptr);
+  }
 
-    if (!done)
-    {
-        StackID frame_zero_id = m_thread.GetStackFrameAtIndex(0)->GetStackID();
-        done = !(frame_zero_id < m_step_out_to_id);
-    }
+  if (!done) {
+    StackID frame_zero_id = m_thread.GetStackFrameAtIndex(0)->GetStackID();
+    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,
-    // and we are done.
-    
-    if (done)
-    {
-        if (InvokeShouldStopHereCallback(eFrameCompareOlder))
-        {
-            CalculateReturnValue();
-            SetPlanComplete();
-        }
-        else
-        {
-            m_step_out_further_plan_sp = QueueStepOutFromHerePlan(m_flags, eFrameCompareOlder);
-            done = false;
-        }
+  // The normal step out computations think we are done, so all we need to do is
+  // consult the ShouldStopHere,
+  // and we are done.
+
+  if (done) {
+    if (InvokeShouldStopHereCallback(eFrameCompareOlder)) {
+      CalculateReturnValue();
+      SetPlanComplete();
+    } else {
+      m_step_out_further_plan_sp =
+          QueueStepOutFromHerePlan(m_flags, eFrameCompareOlder);
+      done = false;
     }
+  }
 
-    return done;
+  return done;
 }
 
-bool
-ThreadPlanStepOut::StopOthers ()
-{
-    return m_stop_others;
-}
+bool ThreadPlanStepOut::StopOthers() { return m_stop_others; }
 
-StateType
-ThreadPlanStepOut::GetPlanRunState ()
-{
-    return eStateRunning;
-}
+StateType ThreadPlanStepOut::GetPlanRunState() { return eStateRunning; }
 
-bool
-ThreadPlanStepOut::DoWillResume (StateType resume_state, bool current_plan)
-{
-    if (m_step_out_to_inline_plan_sp || m_step_through_inline_plan_sp)
-        return true;
-        
-    if (m_return_bp_id == LLDB_INVALID_BREAK_ID)
-        return false;
-
-    if (current_plan)
-    {
-        Breakpoint *return_bp = m_thread.CalculateTarget()->GetBreakpointByID(m_return_bp_id).get();
-        if (return_bp != nullptr)
-            return_bp->SetEnabled (true);
-    }
+bool ThreadPlanStepOut::DoWillResume(StateType resume_state,
+                                     bool current_plan) {
+  if (m_step_out_to_inline_plan_sp || m_step_through_inline_plan_sp)
     return true;
-}
 
-bool
-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 != nullptr)
-            return_bp->SetEnabled (false);
+  if (m_return_bp_id == LLDB_INVALID_BREAK_ID)
+    return false;
+
+  if (current_plan) {
+    Breakpoint *return_bp =
+        m_thread.CalculateTarget()->GetBreakpointByID(m_return_bp_id).get();
+    if (return_bp != nullptr)
+      return_bp->SetEnabled(true);
+  }
+  return true;
+}
+
+bool 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 != nullptr)
+      return_bp->SetEnabled(false);
+  }
+
+  return true;
+}
+
+bool ThreadPlanStepOut::MischiefManaged() {
+  if (IsPlanComplete()) {
+    // Did I reach my breakpoint?  If so I'm done.
+    //
+    // I also check the stack depth, since if we've blown past the breakpoint
+    // for some
+    // reason and we're now stopping for some other reason altogether, then
+    // we're done
+    // with this step out operation.
+
+    Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
+    if (log)
+      log->Printf("Completed step out plan.");
+    if (m_return_bp_id != LLDB_INVALID_BREAK_ID) {
+      m_thread.CalculateTarget()->RemoveBreakpointByID(m_return_bp_id);
+      m_return_bp_id = LLDB_INVALID_BREAK_ID;
     }
-    
+
+    ThreadPlan::MischiefManaged();
     return true;
+  } else {
+    return false;
+  }
 }
 
-bool
-ThreadPlanStepOut::MischiefManaged ()
-{
-    if (IsPlanComplete())
-    {
-        // Did I reach my breakpoint?  If so I'm done.
-        //
-        // I also check the stack depth, since if we've blown past the breakpoint for some
-        // reason and we're now stopping for some other reason altogether, then we're done
-        // with this step out operation.
-
-        Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
-        if (log)
-            log->Printf("Completed step out plan.");
-        if (m_return_bp_id != LLDB_INVALID_BREAK_ID)
-        {
-            m_thread.CalculateTarget()->RemoveBreakpointByID (m_return_bp_id);
-            m_return_bp_id = LLDB_INVALID_BREAK_ID;
+bool ThreadPlanStepOut::QueueInlinedStepPlan(bool queue_now) {
+  // Now figure out the range of this inlined block, and set up a "step through
+  // range"
+  // plan for that.  If we've been provided with a context, then use the block
+  // in that
+  // context.
+  StackFrameSP immediate_return_from_sp(m_thread.GetStackFrameAtIndex(0));
+  if (!immediate_return_from_sp)
+    return false;
+
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
+  if (log) {
+    StreamString s;
+    immediate_return_from_sp->Dump(&s, true, false);
+    log->Printf("Queuing inlined frame to step past: %s.", s.GetData());
+  }
+
+  Block *from_block = immediate_return_from_sp->GetFrameBlock();
+  if (from_block) {
+    Block *inlined_block = from_block->GetContainingInlinedBlock();
+    if (inlined_block) {
+      size_t num_ranges = inlined_block->GetNumRanges();
+      AddressRange inline_range;
+      if (inlined_block->GetRangeAtIndex(0, inline_range)) {
+        SymbolContext inlined_sc;
+        inlined_block->CalculateSymbolContext(&inlined_sc);
+        inlined_sc.target_sp = GetTarget().shared_from_this();
+        RunMode run_mode =
+            m_stop_others ? lldb::eOnlyThisThread : lldb::eAllThreads;
+        const LazyBool avoid_no_debug = eLazyBoolNo;
+
+        m_step_through_inline_plan_sp.reset(new ThreadPlanStepOverRange(
+            m_thread, inline_range, inlined_sc, run_mode, avoid_no_debug));
+        ThreadPlanStepOverRange *step_through_inline_plan_ptr =
+            static_cast<ThreadPlanStepOverRange *>(
+                m_step_through_inline_plan_sp.get());
+        m_step_through_inline_plan_sp->SetPrivate(true);
+
+        step_through_inline_plan_ptr->SetOkayToDiscard(true);
+        StreamString errors;
+        if (!step_through_inline_plan_ptr->ValidatePlan(&errors)) {
+          // FIXME: Log this failure.
+          delete step_through_inline_plan_ptr;
+          return false;
+        }
+
+        for (size_t i = 1; i < num_ranges; i++) {
+          if (inlined_block->GetRangeAtIndex(i, inline_range))
+            step_through_inline_plan_ptr->AddRange(inline_range);
         }
-        
-        ThreadPlan::MischiefManaged ();
+
+        if (queue_now)
+          m_thread.QueueThreadPlan(m_step_through_inline_plan_sp, false);
         return true;
+      }
     }
-    else
-    {
-        return false;
-    }
-}
+  }
 
-bool
-ThreadPlanStepOut::QueueInlinedStepPlan (bool queue_now)
-{
-    // Now figure out the range of this inlined block, and set up a "step through range"
-    // plan for that.  If we've been provided with a context, then use the block in that
-    // context.  
-    StackFrameSP immediate_return_from_sp (m_thread.GetStackFrameAtIndex (0));
-    if (!immediate_return_from_sp)
-        return false;
-        
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
-    if (log)
-    {   
-        StreamString s;
-        immediate_return_from_sp->Dump(&s, true, false);
-        log->Printf("Queuing inlined frame to step past: %s.", s.GetData());
-    }
-        
-    Block *from_block = immediate_return_from_sp->GetFrameBlock();
-    if (from_block)
-    {
-        Block *inlined_block = from_block->GetContainingInlinedBlock();
-        if (inlined_block)
-        {
-            size_t num_ranges = inlined_block->GetNumRanges();
-            AddressRange inline_range;
-            if (inlined_block->GetRangeAtIndex(0, inline_range))
-            {
-                SymbolContext inlined_sc;
-                inlined_block->CalculateSymbolContext(&inlined_sc);
-                inlined_sc.target_sp = GetTarget().shared_from_this();
-                RunMode run_mode = m_stop_others ? lldb::eOnlyThisThread : lldb::eAllThreads;
-                const LazyBool avoid_no_debug = eLazyBoolNo;
-
-                m_step_through_inline_plan_sp.reset (new ThreadPlanStepOverRange(m_thread, 
-                                                                                 inline_range, 
-                                                                                 inlined_sc, 
-                                                                                 run_mode,
-                                                                                 avoid_no_debug));
-                ThreadPlanStepOverRange *step_through_inline_plan_ptr
-                        = static_cast<ThreadPlanStepOverRange *>(m_step_through_inline_plan_sp.get());
-                m_step_through_inline_plan_sp->SetPrivate(true);
-                        
-                step_through_inline_plan_ptr->SetOkayToDiscard(true);                                                                                    
-                StreamString errors;
-                if (!step_through_inline_plan_ptr->ValidatePlan(&errors))
-                {
-                    //FIXME: Log this failure.
-                    delete step_through_inline_plan_ptr;
-                    return false;
-                }
-                
-                for (size_t i = 1; i < num_ranges; i++)
-                {
-                    if (inlined_block->GetRangeAtIndex (i, inline_range))
-                        step_through_inline_plan_ptr->AddRange (inline_range);
-                }
-
-                if (queue_now)
-                    m_thread.QueueThreadPlan (m_step_through_inline_plan_sp, false);
-                return true;
-            }
-        }
-    }
-        
-    return false;
+  return false;
 }
 
-void
-ThreadPlanStepOut::CalculateReturnValue ()
-{
-    if (m_return_valobj_sp)
-        return;
-        
-    if (!m_calculate_return_value)
-        return;
-        
-    if (m_immediate_step_from_function != nullptr)
-    {
-        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_compiler_type);
-        }
+void ThreadPlanStepOut::CalculateReturnValue() {
+  if (m_return_valobj_sp)
+    return;
+
+  if (!m_calculate_return_value)
+    return;
+
+  if (m_immediate_step_from_function != nullptr) {
+    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_compiler_type);
     }
+  }
 }
 
-bool
-ThreadPlanStepOut::IsPlanStale()
-{
-    // If we are still lower on the stack than the frame we are returning to, then
-    // there's something for us to do.  Otherwise, we're stale.
-    
-    StackID frame_zero_id = m_thread.GetStackFrameAtIndex(0)->GetStackID();
-    return !(frame_zero_id < m_step_out_to_id);
+bool ThreadPlanStepOut::IsPlanStale() {
+  // If we are still lower on the stack than the frame we are returning to, then
+  // there's something for us to do.  Otherwise, we're stale.
+
+  StackID frame_zero_id = m_thread.GetStackFrameAtIndex(0)->GetStackID();
+  return !(frame_zero_id < m_step_out_to_id);
 }

Modified: lldb/trunk/source/Target/ThreadPlanStepOverBreakpoint.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanStepOverBreakpoint.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Target/ThreadPlanStepOverBreakpoint.cpp (original)
+++ lldb/trunk/source/Target/ThreadPlanStepOverBreakpoint.cpp Tue Sep  6 15:57:50 2016
@@ -22,172 +22,152 @@ using namespace lldb;
 using namespace lldb_private;
 
 //----------------------------------------------------------------------
-// ThreadPlanStepOverBreakpoint: Single steps over a breakpoint bp_site_sp at the pc.
+// ThreadPlanStepOverBreakpoint: Single steps over a breakpoint bp_site_sp at
+// the pc.
 //----------------------------------------------------------------------
 
-ThreadPlanStepOverBreakpoint::ThreadPlanStepOverBreakpoint (Thread &thread) :
-    ThreadPlan (ThreadPlan::eKindStepOverBreakpoint, "Step over breakpoint trap",
-                thread,
-                eVoteNo,
-                eVoteNoOpinion),  // We need to report the run since this happens
-                            // first in the thread plan stack when stepping
-                            // over a breakpoint
-    m_breakpoint_addr (LLDB_INVALID_ADDRESS),
-    m_auto_continue(false),
-    m_reenabled_breakpoint_site (false)
-
-{
-    m_breakpoint_addr = m_thread.GetRegisterContext()->GetPC();
-    m_breakpoint_site_id =  m_thread.GetProcess()->GetBreakpointSiteList().FindIDByAddress (m_breakpoint_addr);
-}
-
-ThreadPlanStepOverBreakpoint::~ThreadPlanStepOverBreakpoint ()
-{
-}
-
-void
-ThreadPlanStepOverBreakpoint::GetDescription (Stream *s, lldb::DescriptionLevel level)
-{
-    s->Printf("Single stepping past breakpoint site %" PRIu64 " at 0x%" PRIx64, m_breakpoint_site_id, (uint64_t)m_breakpoint_addr);
-}
-
-bool
-ThreadPlanStepOverBreakpoint::ValidatePlan (Stream *error)
-{
-    return true;
-}
-
-bool
-ThreadPlanStepOverBreakpoint::DoPlanExplainsStop (Event *event_ptr)
-{
-    StopInfoSP stop_info_sp = GetPrivateStopInfo ();
-    if (stop_info_sp)
-    {
-        // It's a little surprising that we stop here for a breakpoint hit.  However, when you single step ONTO a breakpoint
-        // we still want to call that a breakpoint hit, and trigger the actions, etc.  Otherwise you would see the
-        // PC at the breakpoint without having triggered the actions, then you'd continue, the PC wouldn't change,
-        // and you'd see the breakpoint hit, which would be odd.
-        // So the lower levels fake "step onto breakpoint address" and return that as a breakpoint.  So our trace
-        // step COULD appear as a breakpoint hit if the next instruction also contained a breakpoint.
-        StopReason reason = stop_info_sp->GetStopReason();
-
-        switch (reason)
-        {
-        case eStopReasonTrace:
-        case eStopReasonNone:
-            return true;
-        case eStopReasonBreakpoint:
-            // It's a little surprising that we stop here for a breakpoint hit.  However, when you single step ONTO a
-            // breakpoint we still want to call that a breakpoint hit, and trigger the actions, etc.  Otherwise you
-            // would see the PC at the breakpoint without having triggered the actions, then you'd continue, the PC
-            // wouldn't change, and you'd see the breakpoint hit, which would be odd.
-            // So the lower levels fake "step onto breakpoint address" and return that as a breakpoint hit.  So our trace
-            // step COULD appear as a breakpoint hit if the next instruction also contained a breakpoint.  We don't want
-            // to handle that, since we really don't know what to do with breakpoint hits.  But make sure we don't set
-            // ourselves to auto-continue or we'll wrench control away from the plans that can deal with this.
-            SetAutoContinue(false);
-            return false;
-        default:
-            return false;
-        }
+ThreadPlanStepOverBreakpoint::ThreadPlanStepOverBreakpoint(Thread &thread)
+    : ThreadPlan(
+          ThreadPlan::eKindStepOverBreakpoint, "Step over breakpoint trap",
+          thread, eVoteNo,
+          eVoteNoOpinion), // We need to report the run since this happens
+                           // first in the thread plan stack when stepping
+                           // over a breakpoint
+      m_breakpoint_addr(LLDB_INVALID_ADDRESS),
+      m_auto_continue(false), m_reenabled_breakpoint_site(false)
+
+{
+  m_breakpoint_addr = m_thread.GetRegisterContext()->GetPC();
+  m_breakpoint_site_id =
+      m_thread.GetProcess()->GetBreakpointSiteList().FindIDByAddress(
+          m_breakpoint_addr);
+}
+
+ThreadPlanStepOverBreakpoint::~ThreadPlanStepOverBreakpoint() {}
+
+void ThreadPlanStepOverBreakpoint::GetDescription(
+    Stream *s, lldb::DescriptionLevel level) {
+  s->Printf("Single stepping past breakpoint site %" PRIu64 " at 0x%" PRIx64,
+            m_breakpoint_site_id, (uint64_t)m_breakpoint_addr);
+}
+
+bool ThreadPlanStepOverBreakpoint::ValidatePlan(Stream *error) { return true; }
+
+bool ThreadPlanStepOverBreakpoint::DoPlanExplainsStop(Event *event_ptr) {
+  StopInfoSP stop_info_sp = GetPrivateStopInfo();
+  if (stop_info_sp) {
+    // It's a little surprising that we stop here for a breakpoint hit.
+    // However, when you single step ONTO a breakpoint
+    // we still want to call that a breakpoint hit, and trigger the actions,
+    // etc.  Otherwise you would see the
+    // PC at the breakpoint without having triggered the actions, then you'd
+    // continue, the PC wouldn't change,
+    // and you'd see the breakpoint hit, which would be odd.
+    // So the lower levels fake "step onto breakpoint address" and return that
+    // as a breakpoint.  So our trace
+    // step COULD appear as a breakpoint hit if the next instruction also
+    // contained a breakpoint.
+    StopReason reason = stop_info_sp->GetStopReason();
+
+    switch (reason) {
+    case eStopReasonTrace:
+    case eStopReasonNone:
+      return true;
+    case eStopReasonBreakpoint:
+      // It's a little surprising that we stop here for a breakpoint hit.
+      // However, when you single step ONTO a
+      // breakpoint we still want to call that a breakpoint hit, and trigger the
+      // actions, etc.  Otherwise you
+      // would see the PC at the breakpoint without having triggered the
+      // actions, then you'd continue, the PC
+      // wouldn't change, and you'd see the breakpoint hit, which would be odd.
+      // So the lower levels fake "step onto breakpoint address" and return that
+      // as a breakpoint hit.  So our trace
+      // step COULD appear as a breakpoint hit if the next instruction also
+      // contained a breakpoint.  We don't want
+      // to handle that, since we really don't know what to do with breakpoint
+      // hits.  But make sure we don't set
+      // ourselves to auto-continue or we'll wrench control away from the plans
+      // that can deal with this.
+      SetAutoContinue(false);
+      return false;
+    default:
+      return false;
     }
-    return false;
+  }
+  return false;
 }
 
-bool
-ThreadPlanStepOverBreakpoint::ShouldStop (Event *event_ptr)
-{
-    return !ShouldAutoContinue(event_ptr);
+bool ThreadPlanStepOverBreakpoint::ShouldStop(Event *event_ptr) {
+  return !ShouldAutoContinue(event_ptr);
 }
 
-bool
-ThreadPlanStepOverBreakpoint::StopOthers ()
-{
-    return true;
-}
+bool ThreadPlanStepOverBreakpoint::StopOthers() { return true; }
 
-StateType
-ThreadPlanStepOverBreakpoint::GetPlanRunState ()
-{
-    return eStateStepping;
+StateType ThreadPlanStepOverBreakpoint::GetPlanRunState() {
+  return eStateStepping;
 }
 
-bool
-ThreadPlanStepOverBreakpoint::DoWillResume (StateType resume_state, bool current_plan)
-{
-    if (current_plan)
-    {
-        BreakpointSiteSP bp_site_sp (m_thread.GetProcess()->GetBreakpointSiteList().FindByAddress (m_breakpoint_addr));
-        if (bp_site_sp  && bp_site_sp->IsEnabled())
-            m_thread.GetProcess()->DisableBreakpointSite (bp_site_sp.get());
-    }
-    return true;
+bool ThreadPlanStepOverBreakpoint::DoWillResume(StateType resume_state,
+                                                bool current_plan) {
+  if (current_plan) {
+    BreakpointSiteSP bp_site_sp(
+        m_thread.GetProcess()->GetBreakpointSiteList().FindByAddress(
+            m_breakpoint_addr));
+    if (bp_site_sp && bp_site_sp->IsEnabled())
+      m_thread.GetProcess()->DisableBreakpointSite(bp_site_sp.get());
+  }
+  return true;
 }
 
-bool
-ThreadPlanStepOverBreakpoint::WillStop ()
-{
-    ReenableBreakpointSite ();
-    return true;
+bool ThreadPlanStepOverBreakpoint::WillStop() {
+  ReenableBreakpointSite();
+  return true;
 }
 
-bool
-ThreadPlanStepOverBreakpoint::MischiefManaged ()
-{
-    lldb::addr_t pc_addr = m_thread.GetRegisterContext()->GetPC();
+bool ThreadPlanStepOverBreakpoint::MischiefManaged() {
+  lldb::addr_t pc_addr = m_thread.GetRegisterContext()->GetPC();
 
-    if (pc_addr == m_breakpoint_addr)
-    {
-        // If we are still at the PC of our breakpoint, then for some reason we didn't
-        // get a chance to run.
-        return false;
-    }
-    else
-    {
-        Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
-        if (log)
-            log->Printf("Completed step over breakpoint plan.");
-        // Otherwise, re-enable the breakpoint we were stepping over, and we're done.
-        ReenableBreakpointSite ();
-        ThreadPlan::MischiefManaged ();
-        return true;
-    }
+  if (pc_addr == m_breakpoint_addr) {
+    // If we are still at the PC of our breakpoint, then for some reason we
+    // didn't
+    // get a chance to run.
+    return false;
+  } else {
+    Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
+    if (log)
+      log->Printf("Completed step over breakpoint plan.");
+    // Otherwise, re-enable the breakpoint we were stepping over, and we're
+    // done.
+    ReenableBreakpointSite();
+    ThreadPlan::MischiefManaged();
+    return true;
+  }
 }
 
-void
-ThreadPlanStepOverBreakpoint::ReenableBreakpointSite ()
-{
-    if (!m_reenabled_breakpoint_site)
-    {
-        m_reenabled_breakpoint_site = true;
-        BreakpointSiteSP bp_site_sp (m_thread.GetProcess()->GetBreakpointSiteList().FindByAddress (m_breakpoint_addr));
-        if (bp_site_sp)
-        {
-            m_thread.GetProcess()->EnableBreakpointSite (bp_site_sp.get());
-        }
+void ThreadPlanStepOverBreakpoint::ReenableBreakpointSite() {
+  if (!m_reenabled_breakpoint_site) {
+    m_reenabled_breakpoint_site = true;
+    BreakpointSiteSP bp_site_sp(
+        m_thread.GetProcess()->GetBreakpointSiteList().FindByAddress(
+            m_breakpoint_addr));
+    if (bp_site_sp) {
+      m_thread.GetProcess()->EnableBreakpointSite(bp_site_sp.get());
     }
+  }
 }
-void
-ThreadPlanStepOverBreakpoint::ThreadDestroyed ()
-{
-    ReenableBreakpointSite ();
+void ThreadPlanStepOverBreakpoint::ThreadDestroyed() {
+  ReenableBreakpointSite();
 }
 
-void
-ThreadPlanStepOverBreakpoint::SetAutoContinue (bool do_it)
-{
-    m_auto_continue = do_it;
+void ThreadPlanStepOverBreakpoint::SetAutoContinue(bool do_it) {
+  m_auto_continue = do_it;
 }
 
-bool
-ThreadPlanStepOverBreakpoint::ShouldAutoContinue (Event *event_ptr)
-{
-    return m_auto_continue;
+bool ThreadPlanStepOverBreakpoint::ShouldAutoContinue(Event *event_ptr) {
+  return m_auto_continue;
 }
 
-bool
-ThreadPlanStepOverBreakpoint::IsPlanStale()
-{
-    return m_thread.GetRegisterContext()->GetPC() != m_breakpoint_addr;
+bool ThreadPlanStepOverBreakpoint::IsPlanStale() {
+  return m_thread.GetRegisterContext()->GetPC() != m_breakpoint_addr;
 }
-

Modified: lldb/trunk/source/Target/ThreadPlanStepOverRange.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanStepOverRange.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Target/ThreadPlanStepOverRange.cpp (original)
+++ lldb/trunk/source/Target/ThreadPlanStepOverRange.cpp Tue Sep  6 15:57:50 2016
@@ -31,410 +31,404 @@ using namespace lldb;
 uint32_t ThreadPlanStepOverRange::s_default_flag_values = 0;
 
 //----------------------------------------------------------------------
-// ThreadPlanStepOverRange: Step through a stack range, either stepping over or into
+// ThreadPlanStepOverRange: Step through a stack range, either stepping over or
+// into
 // based on the value of \a type.
 //----------------------------------------------------------------------
 
-ThreadPlanStepOverRange::ThreadPlanStepOverRange
-(
-    Thread &thread,
-    const AddressRange &range,
-    const SymbolContext &addr_context,
-    lldb::RunMode stop_others,
-    LazyBool step_out_avoids_code_without_debug_info
-) :
-    ThreadPlanStepRange (ThreadPlan::eKindStepOverRange, "Step range stepping over", thread, range, addr_context, stop_others),
-    ThreadPlanShouldStopHere (this),
-    m_first_resume(true)
-{
-    SetFlagsToDefault();
-    SetupAvoidNoDebug(step_out_avoids_code_without_debug_info);
+ThreadPlanStepOverRange::ThreadPlanStepOverRange(
+    Thread &thread, const AddressRange &range,
+    const SymbolContext &addr_context, lldb::RunMode stop_others,
+    LazyBool step_out_avoids_code_without_debug_info)
+    : ThreadPlanStepRange(ThreadPlan::eKindStepOverRange,
+                          "Step range stepping over", thread, range,
+                          addr_context, stop_others),
+      ThreadPlanShouldStopHere(this), m_first_resume(true) {
+  SetFlagsToDefault();
+  SetupAvoidNoDebug(step_out_avoids_code_without_debug_info);
 }
 
 ThreadPlanStepOverRange::~ThreadPlanStepOverRange() = default;
 
-void
-ThreadPlanStepOverRange::GetDescription (Stream *s, lldb::DescriptionLevel level)
-{
-    if (level == lldb::eDescriptionLevelBrief)
-    {
-        s->Printf("step over");
-        return;
-    }
-    s->Printf ("Stepping over");
-    bool printed_line_info = false;
-    if (m_addr_context.line_entry.IsValid())
-    {
-        s->Printf (" line ");
-        m_addr_context.line_entry.DumpStopContext (s, false);
-        printed_line_info = true;
-    }
+void ThreadPlanStepOverRange::GetDescription(Stream *s,
+                                             lldb::DescriptionLevel level) {
+  if (level == lldb::eDescriptionLevelBrief) {
+    s->Printf("step over");
+    return;
+  }
+  s->Printf("Stepping over");
+  bool printed_line_info = false;
+  if (m_addr_context.line_entry.IsValid()) {
+    s->Printf(" line ");
+    m_addr_context.line_entry.DumpStopContext(s, false);
+    printed_line_info = true;
+  }
+
+  if (!printed_line_info || level == eDescriptionLevelVerbose) {
+    s->Printf(" using ranges: ");
+    DumpRanges(s);
+  }
 
-    if (!printed_line_info || level == eDescriptionLevelVerbose)
-    {
-        s->Printf (" using ranges: ");
-        DumpRanges(s);
-    }
-
-    s->PutChar('.');
+  s->PutChar('.');
 }
 
-void
-ThreadPlanStepOverRange::SetupAvoidNoDebug(LazyBool step_out_avoids_code_without_debug_info)
-{
-    bool avoid_nodebug = true;
-    switch (step_out_avoids_code_without_debug_info)
-    {
-        case eLazyBoolYes:
-            avoid_nodebug = true;
-            break;
-        case eLazyBoolNo:
-            avoid_nodebug = false;
-            break;
-        case eLazyBoolCalculate:
-            avoid_nodebug = m_thread.GetStepOutAvoidsNoDebug();
-            break;
-    }
-    if (avoid_nodebug)
-        GetFlags().Set (ThreadPlanShouldStopHere::eStepOutAvoidNoDebug);
-    else
-        GetFlags().Clear (ThreadPlanShouldStopHere::eStepOutAvoidNoDebug);
-    // Step Over plans should always avoid no-debug on step in.  Seems like you shouldn't
-    // have to say this, but a tail call looks more like a step in that a step out, so
-    // we want to catch this case.
-    GetFlags().Set (ThreadPlanShouldStopHere::eStepInAvoidNoDebug);
+void ThreadPlanStepOverRange::SetupAvoidNoDebug(
+    LazyBool step_out_avoids_code_without_debug_info) {
+  bool avoid_nodebug = true;
+  switch (step_out_avoids_code_without_debug_info) {
+  case eLazyBoolYes:
+    avoid_nodebug = true;
+    break;
+  case eLazyBoolNo:
+    avoid_nodebug = false;
+    break;
+  case eLazyBoolCalculate:
+    avoid_nodebug = m_thread.GetStepOutAvoidsNoDebug();
+    break;
+  }
+  if (avoid_nodebug)
+    GetFlags().Set(ThreadPlanShouldStopHere::eStepOutAvoidNoDebug);
+  else
+    GetFlags().Clear(ThreadPlanShouldStopHere::eStepOutAvoidNoDebug);
+  // Step Over plans should always avoid no-debug on step in.  Seems like you
+  // shouldn't
+  // have to say this, but a tail call looks more like a step in that a step
+  // out, so
+  // we want to catch this case.
+  GetFlags().Set(ThreadPlanShouldStopHere::eStepInAvoidNoDebug);
 }
 
-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
-    // inlined range, so I left that out too...
-    if (m_addr_context.comp_unit)
-    {
-        if (m_addr_context.comp_unit == context.comp_unit)
-        {
-            if (m_addr_context.function && m_addr_context.function == context.function)
-            {
-                // It is okay to return to a different block of a straight function, we only have to 
-                // be more careful if returning from one inlined block to another.
-                if (m_addr_context.block->GetInlinedFunctionInfo() == nullptr
-                    && context.block->GetInlinedFunctionInfo() == nullptr)
-                    return true;
-                
-                if (m_addr_context.block && m_addr_context.block == context.block)
-                    return true;
-            }
-        }
-    }
-    else if (m_addr_context.symbol && m_addr_context.symbol == context.symbol)
-    {
-        return true;
+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
+  // inlined range, so I left that out too...
+  if (m_addr_context.comp_unit) {
+    if (m_addr_context.comp_unit == context.comp_unit) {
+      if (m_addr_context.function &&
+          m_addr_context.function == context.function) {
+        // It is okay to return to a different block of a straight function, we
+        // only have to
+        // be more careful if returning from one inlined block to another.
+        if (m_addr_context.block->GetInlinedFunctionInfo() == nullptr &&
+            context.block->GetInlinedFunctionInfo() == nullptr)
+          return true;
+
+        if (m_addr_context.block && m_addr_context.block == context.block)
+          return true;
+      }
     }
-    return false;
+  } else if (m_addr_context.symbol && m_addr_context.symbol == context.symbol) {
+    return true;
+  }
+  return false;
 }
 
-bool
-ThreadPlanStepOverRange::ShouldStop (Event *event_ptr)
-{
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
-
-    if (log)
-    {
-        StreamString s;
-        s.Address (m_thread.GetRegisterContext()->GetPC(), 
-                   m_thread.CalculateTarget()->GetArchitecture().GetAddressByteSize());
-        log->Printf("ThreadPlanStepOverRange reached %s.", s.GetData());
-    }
-    
-    // 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 = (m_stop_others == lldb::eOnlyThisThread);
-    ThreadPlanSP new_plan_sp;
-    FrameComparison frame_order = CompareCurrentFrameToStartFrame();
-    
-    if (frame_order == eFrameCompareOlder)
-    {
-        // If we're in an older frame then we should stop.
-        //
-        // A caveat to this is if we think the frame is older but we're actually in a trampoline.
-        // I'm going to make the assumption that you wouldn't RETURN to a trampoline.  So if we are
-        // in a trampoline we think the frame is older because the trampoline confused the backtracer.
-        // As below, we step through first, and then try to figure out how to get back out again.
-        
-        new_plan_sp = m_thread.QueueThreadPlanForStepThrough (m_stack_id, false, stop_others);
+bool ThreadPlanStepOverRange::ShouldStop(Event *event_ptr) {
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
 
-        if (new_plan_sp && log)
-            log->Printf("Thought I stepped out, but in fact arrived at a trampoline.");
-    }
-    else if (frame_order == eFrameCompareYounger)
-    {
-        // Make sure we really are in a new frame.  Do that by unwinding and seeing if the
-        // start function really is our start function...
-        for(uint32_t i = 1;; ++i)
-        {
-            StackFrameSP older_frame_sp = m_thread.GetStackFrameAtIndex(i);
-            if (!older_frame_sp) {
-                // We can't unwind the next frame we should just get out of here & stop...
-                break;
-            }
-
-            const SymbolContext &older_context = older_frame_sp->GetSymbolContext(eSymbolContextEverything);
-            if (IsEquivalentContext(older_context))
-            {
-                new_plan_sp = m_thread.QueueThreadPlanForStepOutNoShouldStop(false,
-                                                                             nullptr,
-                                                                             true,
-                                                                             stop_others,
-                                                                             eVoteNo,
-                                                                             eVoteNoOpinion,
-                                                                             0,
-                                                                             true);
-                break;
-            }
-            else
-            {
-                new_plan_sp = m_thread.QueueThreadPlanForStepThrough (m_stack_id, false, stop_others);
-                // If we found a way through, then we should stop recursing.
-                if (new_plan_sp)
-                    break;
-            }
-        }
-    }
-    else
-    {
-        // If we're still in the range, keep going.
-        if (InRange())
-        {
-            SetNextBranchBreakpoint();
-            return false;
-        }
+  if (log) {
+    StreamString s;
+    s.Address(
+        m_thread.GetRegisterContext()->GetPC(),
+        m_thread.CalculateTarget()->GetArchitecture().GetAddressByteSize());
+    log->Printf("ThreadPlanStepOverRange reached %s.", s.GetData());
+  }
+
+  // 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 = (m_stop_others == lldb::eOnlyThisThread);
+  ThreadPlanSP new_plan_sp;
+  FrameComparison frame_order = CompareCurrentFrameToStartFrame();
+
+  if (frame_order == eFrameCompareOlder) {
+    // If we're in an older frame then we should stop.
+    //
+    // A caveat to this is if we think the frame is older but we're actually in
+    // a trampoline.
+    // I'm going to make the assumption that you wouldn't RETURN to a
+    // trampoline.  So if we are
+    // in a trampoline we think the frame is older because the trampoline
+    // confused the backtracer.
+    // As below, we step through first, and then try to figure out how to get
+    // back out again.
+
+    new_plan_sp =
+        m_thread.QueueThreadPlanForStepThrough(m_stack_id, false, stop_others);
+
+    if (new_plan_sp && log)
+      log->Printf(
+          "Thought I stepped out, but in fact arrived at a trampoline.");
+  } else if (frame_order == eFrameCompareYounger) {
+    // Make sure we really are in a new frame.  Do that by unwinding and seeing
+    // if the
+    // start function really is our start function...
+    for (uint32_t i = 1;; ++i) {
+      StackFrameSP older_frame_sp = m_thread.GetStackFrameAtIndex(i);
+      if (!older_frame_sp) {
+        // We can't unwind the next frame we should just get out of here &
+        // stop...
+        break;
+      }
+
+      const SymbolContext &older_context =
+          older_frame_sp->GetSymbolContext(eSymbolContextEverything);
+      if (IsEquivalentContext(older_context)) {
+        new_plan_sp = m_thread.QueueThreadPlanForStepOutNoShouldStop(
+            false, nullptr, true, stop_others, eVoteNo, eVoteNoOpinion, 0,
+            true);
+        break;
+      } else {
+        new_plan_sp = m_thread.QueueThreadPlanForStepThrough(m_stack_id, false,
+                                                             stop_others);
+        // If we found a way through, then we should stop recursing.
+        if (new_plan_sp)
+          break;
+      }
+    }
+  } else {
+    // If we're still in the range, keep going.
+    if (InRange()) {
+      SetNextBranchBreakpoint();
+      return false;
+    }
+
+    if (!InSymbol()) {
+      // This one is a little tricky.  Sometimes we may be in a stub or
+      // something similar,
+      // in which case we need to get out of there.  But if we are in a stub
+      // then it's
+      // likely going to be hard to get out from here.  It is probably easiest
+      // to step into the
+      // stub, and then it will be straight-forward to step out.
+      new_plan_sp = m_thread.QueueThreadPlanForStepThrough(m_stack_id, false,
+                                                           stop_others);
+    } else {
+      // The current clang (at least through 424) doesn't always get the address
+      // range for the
+      // DW_TAG_inlined_subroutines right, so that when you leave the inlined
+      // range the line table says
+      // you are still in the source file of the inlining function.  This is
+      // bad, because now you are missing
+      // the stack frame for the function containing the inlining, and if you
+      // sensibly do "finish" to get
+      // out of this function you will instead exit the containing function.
+      // To work around this, we check whether we are still in the source file
+      // we started in, and if not assume
+      // it is an error, and push a plan to get us out of this line and back to
+      // the containing file.
+
+      if (m_addr_context.line_entry.IsValid()) {
+        SymbolContext sc;
+        StackFrameSP frame_sp = m_thread.GetStackFrameAtIndex(0);
+        sc = frame_sp->GetSymbolContext(eSymbolContextEverything);
+        if (sc.line_entry.IsValid()) {
+          if (sc.line_entry.original_file !=
+                  m_addr_context.line_entry.original_file &&
+              sc.comp_unit == m_addr_context.comp_unit &&
+              sc.function == m_addr_context.function) {
+            // Okay, find the next occurrence of this file in the line table:
+            LineTable *line_table = m_addr_context.comp_unit->GetLineTable();
+            if (line_table) {
+              Address cur_address = frame_sp->GetFrameCodeAddress();
+              uint32_t entry_idx;
+              LineEntry line_entry;
+              if (line_table->FindLineEntryByAddress(cur_address, line_entry,
+                                                     &entry_idx)) {
+                LineEntry next_line_entry;
+                bool step_past_remaining_inline = false;
+                if (entry_idx > 0) {
+                  // We require the previous line entry and the current line
+                  // entry come
+                  // from the same file.
+                  // The other requirement is that the previous line table entry
+                  // be part of an
+                  // inlined block, we don't want to step past cases where
+                  // people have inlined
+                  // some code fragment by using #include <source-fragment.c>
+                  // directly.
+                  LineEntry prev_line_entry;
+                  if (line_table->GetLineEntryAtIndex(entry_idx - 1,
+                                                      prev_line_entry) &&
+                      prev_line_entry.original_file ==
+                          line_entry.original_file) {
+                    SymbolContext prev_sc;
+                    Address prev_address =
+                        prev_line_entry.range.GetBaseAddress();
+                    prev_address.CalculateSymbolContext(&prev_sc);
+                    if (prev_sc.block) {
+                      Block *inlined_block =
+                          prev_sc.block->GetContainingInlinedBlock();
+                      if (inlined_block) {
+                        AddressRange inline_range;
+                        inlined_block->GetRangeContainingAddress(prev_address,
+                                                                 inline_range);
+                        if (!inline_range.ContainsFileAddress(cur_address)) {
 
-        if (!InSymbol())
-        {
-            // This one is a little tricky.  Sometimes we may be in a stub or something similar,
-            // in which case we need to get out of there.  But if we are in a stub then it's 
-            // likely going to be hard to get out from here.  It is probably easiest to step into the
-            // stub, and then it will be straight-forward to step out.        
-            new_plan_sp = m_thread.QueueThreadPlanForStepThrough (m_stack_id, false, stop_others);
-        }
-        else
-        {
-            // The current clang (at least through 424) doesn't always get the address range for the 
-            // DW_TAG_inlined_subroutines right, so that when you leave the inlined range the line table says 
-            // you are still in the source file of the inlining function.  This is bad, because now you are missing 
-            // the stack frame for the function containing the inlining, and if you sensibly do "finish" to get
-            // out of this function you will instead exit the containing function.
-            // To work around this, we check whether we are still in the source file we started in, and if not assume
-            // it is an error, and push a plan to get us out of this line and back to the containing file.
-
-            if (m_addr_context.line_entry.IsValid())
-            {
-                SymbolContext sc;
-                StackFrameSP frame_sp = m_thread.GetStackFrameAtIndex(0);
-                sc = frame_sp->GetSymbolContext (eSymbolContextEverything);
-                if (sc.line_entry.IsValid())
-                {
-                    if (sc.line_entry.original_file != m_addr_context.line_entry.original_file
-                         && sc.comp_unit == m_addr_context.comp_unit
-                         && sc.function == m_addr_context.function)
-                    {
-                        // Okay, find the next occurrence of this file in the line table:
-                        LineTable *line_table = m_addr_context.comp_unit->GetLineTable();
-                        if (line_table)
-                        {
-                            Address cur_address = frame_sp->GetFrameCodeAddress();
-                            uint32_t entry_idx;
-                            LineEntry line_entry;
-                            if (line_table->FindLineEntryByAddress (cur_address, line_entry, &entry_idx))
-                            {
-                                LineEntry next_line_entry;
-                                bool step_past_remaining_inline = false;
-                                if (entry_idx > 0)
-                                {
-                                    // We require the previous line entry and the current line entry come
-                                    // from the same file.
-                                    // The other requirement is that the previous line table entry be part of an
-                                    // inlined block, we don't want to step past cases where people have inlined
-                                    // some code fragment by using #include <source-fragment.c> directly.
-                                    LineEntry prev_line_entry;
-                                    if (line_table->GetLineEntryAtIndex(entry_idx - 1, prev_line_entry)
-                                        && prev_line_entry.original_file == line_entry.original_file)
-                                    {
-                                        SymbolContext prev_sc;
-                                        Address prev_address = prev_line_entry.range.GetBaseAddress();
-                                        prev_address.CalculateSymbolContext(&prev_sc);
-                                        if (prev_sc.block)
-                                        {
-                                            Block *inlined_block = prev_sc.block->GetContainingInlinedBlock();
-                                            if (inlined_block)
-                                            {
-                                                AddressRange inline_range;
-                                                inlined_block->GetRangeContainingAddress(prev_address, inline_range);
-                                                if (!inline_range.ContainsFileAddress(cur_address))
-                                                {
-                                                    
-                                                    step_past_remaining_inline = true;
-                                                }
-                                            }
-                                        }
-                                    }
-                                }
-                                
-                                if (step_past_remaining_inline)
-                                {
-                                    uint32_t look_ahead_step = 1;
-                                    while (line_table->GetLineEntryAtIndex(entry_idx + look_ahead_step, next_line_entry))
-                                    {
-                                        // Make sure we haven't wandered out of the function we started from...
-                                        Address next_line_address = next_line_entry.range.GetBaseAddress();
-                                        Function *next_line_function = next_line_address.CalculateSymbolContextFunction();
-                                        if (next_line_function != m_addr_context.function)
-                                            break;
-                                        
-                                        if (next_line_entry.original_file == m_addr_context.line_entry.original_file)
-                                        {
-                                            const bool abort_other_plans = false;
-                                            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++;
-                                    }
-                                }
-                            }
+                          step_past_remaining_inline = true;
                         }
+                      }
                     }
+                  }
                 }
+
+                if (step_past_remaining_inline) {
+                  uint32_t look_ahead_step = 1;
+                  while (line_table->GetLineEntryAtIndex(
+                      entry_idx + look_ahead_step, next_line_entry)) {
+                    // Make sure we haven't wandered out of the function we
+                    // started from...
+                    Address next_line_address =
+                        next_line_entry.range.GetBaseAddress();
+                    Function *next_line_function =
+                        next_line_address.CalculateSymbolContextFunction();
+                    if (next_line_function != m_addr_context.function)
+                      break;
+
+                    if (next_line_entry.original_file ==
+                        m_addr_context.line_entry.original_file) {
+                      const bool abort_other_plans = false;
+                      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++;
+                  }
+                }
+              }
             }
+          }
         }
+      }
     }
+  }
 
-    // If we get to this point, we're not going to use a previously set "next branch" breakpoint, so delete it:
-    ClearNextBranchBreakpoint();
-    
-    
-    // If we haven't figured out something to do yet, then ask the ShouldStopHere callback:
-    if (!new_plan_sp)
-    {
-        new_plan_sp = CheckShouldStopHereAndQueueStepOut (frame_order);
-    }
-
-    if (!new_plan_sp)
-        m_no_more_plans = true;
-    else
-    {
-        // Any new plan will be an implementation plan, so mark it private:
-        new_plan_sp->SetPrivate(true);
-        m_no_more_plans = false;
-    }
-
-    if (!new_plan_sp)
-    {
-        // For efficiencies sake, we know we're done here so we don't have to do this
-        // calculation again in MischiefManaged.
-        SetPlanComplete();
-        return true;
-    }
-    else
-        return false;
+  // If we get to this point, we're not going to use a previously set "next
+  // branch" breakpoint, so delete it:
+  ClearNextBranchBreakpoint();
+
+  // If we haven't figured out something to do yet, then ask the ShouldStopHere
+  // callback:
+  if (!new_plan_sp) {
+    new_plan_sp = CheckShouldStopHereAndQueueStepOut(frame_order);
+  }
+
+  if (!new_plan_sp)
+    m_no_more_plans = true;
+  else {
+    // Any new plan will be an implementation plan, so mark it private:
+    new_plan_sp->SetPrivate(true);
+    m_no_more_plans = false;
+  }
+
+  if (!new_plan_sp) {
+    // For efficiencies sake, we know we're done here so we don't have to do
+    // this
+    // calculation again in MischiefManaged.
+    SetPlanComplete();
+    return true;
+  } else
+    return false;
 }
 
-bool
-ThreadPlanStepOverRange::DoPlanExplainsStop (Event *event_ptr)
-{
-    // For crashes, breakpoint hits, signals, etc, let the base plan (or some plan above us)
-    // handle the stop.  That way the user can see the stop, step around, and then when they
-    // are done, continue and have their step complete.  The exception is if we've hit our
-    // "run to next branch" breakpoint.
-    // Note, unlike the step in range plan, we don't mark ourselves complete if we hit an
-    // unexplained breakpoint/crash.
-    
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
-    StopInfoSP stop_info_sp = GetPrivateStopInfo ();
-    bool return_value;
-    
-    if (stop_info_sp)
-    {
-        StopReason reason = stop_info_sp->GetStopReason();
-
-        if (reason == eStopReasonTrace)
-        {
-            return_value = true;
-        }
-        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;
-        }
+bool ThreadPlanStepOverRange::DoPlanExplainsStop(Event *event_ptr) {
+  // For crashes, breakpoint hits, signals, etc, let the base plan (or some plan
+  // above us)
+  // handle the stop.  That way the user can see the stop, step around, and then
+  // when they
+  // are done, continue and have their step complete.  The exception is if we've
+  // hit our
+  // "run to next branch" breakpoint.
+  // Note, unlike the step in range plan, we don't mark ourselves complete if we
+  // hit an
+  // unexplained breakpoint/crash.
+
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
+  StopInfoSP stop_info_sp = GetPrivateStopInfo();
+  bool return_value;
+
+  if (stop_info_sp) {
+    StopReason reason = stop_info_sp->GetStopReason();
+
+    if (reason == eStopReasonTrace) {
+      return_value = true;
+    } 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;
     }
-    else
-        return_value = true;
+  } else
+    return_value = true;
 
-    return return_value;
+  return return_value;
 }
 
-bool
-ThreadPlanStepOverRange::DoWillResume (lldb::StateType resume_state, bool current_plan)
-{
-    if (resume_state != eStateSuspended && m_first_resume)
-    {
-        m_first_resume = false;
-        if (resume_state == eStateStepping && current_plan)
-        {
-            // See if we are about to step over an inlined call in the middle of the inlined stack, if so figure
-            // out its extents and reset our range to step over that.
-            bool in_inlined_stack = m_thread.DecrementCurrentInlinedDepth();
-            if (in_inlined_stack)
-            {
-                Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
-                if (log)
-                    log->Printf ("ThreadPlanStepInRange::DoWillResume: adjusting range to the frame at inlined depth %d.",
-                                 m_thread.GetCurrentInlinedDepth());
-                StackFrameSP stack_sp = m_thread.GetStackFrameAtIndex(0);
-                if (stack_sp)
-                {
-                    Block *frame_block = stack_sp->GetFrameBlock();
-                    lldb::addr_t curr_pc = m_thread.GetRegisterContext()->GetPC();
-                    AddressRange my_range;
-                    if (frame_block->GetRangeContainingLoadAddress(curr_pc, m_thread.GetProcess()->GetTarget(), my_range))
-                    {
-                        m_address_ranges.clear();
-                        m_address_ranges.push_back(my_range);
-                        if (log)
-                        {
-                            StreamString s;
-                            const InlineFunctionInfo *inline_info = frame_block->GetInlinedFunctionInfo();
-                            const char *name;
-                            if (inline_info)
-                                name = inline_info->GetName(frame_block->CalculateSymbolContextFunction()->GetLanguage()).AsCString();
-                            else
-                                name = "<unknown-notinlined>";
-                            
-                            s.Printf ("Stepping over inlined function \"%s\" in inlined stack: ", name);
-                            DumpRanges(&s);
-                            log->PutCString(s.GetData());
-                        }
-                    }
-                    
-                }
+bool ThreadPlanStepOverRange::DoWillResume(lldb::StateType resume_state,
+                                           bool current_plan) {
+  if (resume_state != eStateSuspended && m_first_resume) {
+    m_first_resume = false;
+    if (resume_state == eStateStepping && current_plan) {
+      // See if we are about to step over an inlined call in the middle of the
+      // inlined stack, if so figure
+      // out its extents and reset our range to step over that.
+      bool in_inlined_stack = m_thread.DecrementCurrentInlinedDepth();
+      if (in_inlined_stack) {
+        Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
+        if (log)
+          log->Printf("ThreadPlanStepInRange::DoWillResume: adjusting range to "
+                      "the frame at inlined depth %d.",
+                      m_thread.GetCurrentInlinedDepth());
+        StackFrameSP stack_sp = m_thread.GetStackFrameAtIndex(0);
+        if (stack_sp) {
+          Block *frame_block = stack_sp->GetFrameBlock();
+          lldb::addr_t curr_pc = m_thread.GetRegisterContext()->GetPC();
+          AddressRange my_range;
+          if (frame_block->GetRangeContainingLoadAddress(
+                  curr_pc, m_thread.GetProcess()->GetTarget(), my_range)) {
+            m_address_ranges.clear();
+            m_address_ranges.push_back(my_range);
+            if (log) {
+              StreamString s;
+              const InlineFunctionInfo *inline_info =
+                  frame_block->GetInlinedFunctionInfo();
+              const char *name;
+              if (inline_info)
+                name =
+                    inline_info
+                        ->GetName(frame_block->CalculateSymbolContextFunction()
+                                      ->GetLanguage())
+                        .AsCString();
+              else
+                name = "<unknown-notinlined>";
+
+              s.Printf(
+                  "Stepping over inlined function \"%s\" in inlined stack: ",
+                  name);
+              DumpRanges(&s);
+              log->PutCString(s.GetData());
             }
+          }
         }
+      }
     }
-    
-    return true;
+  }
+
+  return true;
 }

Modified: lldb/trunk/source/Target/ThreadPlanStepRange.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanStepRange.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Target/ThreadPlanStepRange.cpp (original)
+++ lldb/trunk/source/Target/ThreadPlanStepRange.cpp Tue Sep  6 15:57:50 2016
@@ -35,504 +35,434 @@ using namespace lldb_private;
 // based on the value of \a type.
 //----------------------------------------------------------------------
 
-ThreadPlanStepRange::ThreadPlanStepRange (ThreadPlanKind kind, 
-                                          const char *name, 
-                                          Thread &thread, 
-                                          const AddressRange &range, 
-                                          const SymbolContext &addr_context, 
-                                          lldb::RunMode stop_others,
-                                          bool given_ranges_only) :
-    ThreadPlan (kind, name, thread, eVoteNoOpinion, eVoteNoOpinion),
-    m_addr_context (addr_context),
-    m_address_ranges (),
-    m_stop_others (stop_others),
-    m_stack_id (),
-    m_parent_stack_id(),
-    m_no_more_plans (false),
-    m_first_run_event (true),
-    m_use_fast_step(false),
-    m_given_ranges_only (given_ranges_only)
-{
-    m_use_fast_step = GetTarget().GetUseFastStepping();
-    AddRange(range);
-    m_stack_id = m_thread.GetStackFrameAtIndex(0)->GetStackID();
-    StackFrameSP parent_stack = m_thread.GetStackFrameAtIndex(1);
-    if (parent_stack)
-      m_parent_stack_id = parent_stack->GetStackID();
+ThreadPlanStepRange::ThreadPlanStepRange(ThreadPlanKind kind, const char *name,
+                                         Thread &thread,
+                                         const AddressRange &range,
+                                         const SymbolContext &addr_context,
+                                         lldb::RunMode stop_others,
+                                         bool given_ranges_only)
+    : ThreadPlan(kind, name, thread, eVoteNoOpinion, eVoteNoOpinion),
+      m_addr_context(addr_context), m_address_ranges(),
+      m_stop_others(stop_others), m_stack_id(), m_parent_stack_id(),
+      m_no_more_plans(false), m_first_run_event(true), m_use_fast_step(false),
+      m_given_ranges_only(given_ranges_only) {
+  m_use_fast_step = GetTarget().GetUseFastStepping();
+  AddRange(range);
+  m_stack_id = m_thread.GetStackFrameAtIndex(0)->GetStackID();
+  StackFrameSP parent_stack = m_thread.GetStackFrameAtIndex(1);
+  if (parent_stack)
+    m_parent_stack_id = parent_stack->GetStackID();
+}
+
+ThreadPlanStepRange::~ThreadPlanStepRange() { ClearNextBranchBreakpoint(); }
+
+void ThreadPlanStepRange::DidPush() {
+  // See if we can find a "next range" breakpoint:
+  SetNextBranchBreakpoint();
+}
+
+bool ThreadPlanStepRange::ValidatePlan(Stream *error) { return true; }
+
+Vote ThreadPlanStepRange::ShouldReportStop(Event *event_ptr) {
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
+
+  const Vote vote = IsPlanComplete() ? eVoteYes : eVoteNo;
+  if (log)
+    log->Printf("ThreadPlanStepRange::ShouldReportStop() returning vote %i\n",
+                vote);
+  return vote;
+}
+
+void ThreadPlanStepRange::AddRange(const AddressRange &new_range) {
+  // For now I'm just adding the ranges.  At some point we may want to
+  // condense the ranges if they overlap, though I don't think it is likely
+  // to be very important.
+  m_address_ranges.push_back(new_range);
+
+  // Fill the slot for this address range with an empty DisassemblerSP in the
+  // instruction ranges. I want the
+  // indices to match, but I don't want to do the work to disassemble this range
+  // if I don't step into it.
+  m_instruction_ranges.push_back(DisassemblerSP());
+}
+
+void ThreadPlanStepRange::DumpRanges(Stream *s) {
+  size_t num_ranges = m_address_ranges.size();
+  if (num_ranges == 1) {
+    m_address_ranges[0].Dump(s, m_thread.CalculateTarget().get(),
+                             Address::DumpStyleLoadAddress);
+  } else {
+    for (size_t i = 0; i < num_ranges; i++) {
+      s->Printf(" %" PRIu64 ": ", uint64_t(i));
+      m_address_ranges[i].Dump(s, m_thread.CalculateTarget().get(),
+                               Address::DumpStyleLoadAddress);
+    }
+  }
+}
+
+bool ThreadPlanStepRange::InRange() {
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
+  bool ret_value = false;
+
+  lldb::addr_t pc_load_addr = m_thread.GetRegisterContext()->GetPC();
+
+  size_t num_ranges = m_address_ranges.size();
+  for (size_t i = 0; i < num_ranges; i++) {
+    ret_value = m_address_ranges[i].ContainsLoadAddress(
+        pc_load_addr, m_thread.CalculateTarget().get());
+    if (ret_value)
+      break;
+  }
+
+  if (!ret_value && !m_given_ranges_only) {
+    // See if we've just stepped to another part of the same line number...
+    StackFrame *frame = m_thread.GetStackFrameAtIndex(0).get();
+
+    SymbolContext new_context(
+        frame->GetSymbolContext(eSymbolContextEverything));
+    if (m_addr_context.line_entry.IsValid() &&
+        new_context.line_entry.IsValid()) {
+      if (m_addr_context.line_entry.original_file ==
+          new_context.line_entry.original_file) {
+        if (m_addr_context.line_entry.line == new_context.line_entry.line) {
+          m_addr_context = new_context;
+          AddRange(
+              m_addr_context.line_entry.GetSameLineContiguousAddressRange());
+          ret_value = true;
+          if (log) {
+            StreamString s;
+            m_addr_context.line_entry.Dump(&s, m_thread.CalculateTarget().get(),
+                                           true, Address::DumpStyleLoadAddress,
+                                           Address::DumpStyleLoadAddress, true);
+
+            log->Printf(
+                "Step range plan stepped to another range of same line: %s",
+                s.GetData());
+          }
+        } else if (new_context.line_entry.line == 0) {
+          new_context.line_entry.line = m_addr_context.line_entry.line;
+          m_addr_context = new_context;
+          AddRange(
+              m_addr_context.line_entry.GetSameLineContiguousAddressRange());
+          ret_value = true;
+          if (log) {
+            StreamString s;
+            m_addr_context.line_entry.Dump(&s, m_thread.CalculateTarget().get(),
+                                           true, Address::DumpStyleLoadAddress,
+                                           Address::DumpStyleLoadAddress, true);
+
+            log->Printf("Step range plan stepped to a range at linenumber 0 "
+                        "stepping through that range: %s",
+                        s.GetData());
+          }
+        } else if (new_context.line_entry.range.GetBaseAddress().GetLoadAddress(
+                       m_thread.CalculateTarget().get()) != pc_load_addr) {
+          // Another thing that sometimes happens here is that we step out of
+          // one line into the MIDDLE of another
+          // line.  So far I mostly see this due to bugs in the debug
+          // information.
+          // But we probably don't want to be in the middle of a line range, so
+          // in that case reset the stepping
+          // range to the line we've stepped into the middle of and continue.
+          m_addr_context = new_context;
+          m_address_ranges.clear();
+          AddRange(m_addr_context.line_entry.range);
+          ret_value = true;
+          if (log) {
+            StreamString s;
+            m_addr_context.line_entry.Dump(&s, m_thread.CalculateTarget().get(),
+                                           true, Address::DumpStyleLoadAddress,
+                                           Address::DumpStyleLoadAddress, true);
+
+            log->Printf("Step range plan stepped to the middle of new "
+                        "line(%d): %s, continuing to clear this line.",
+                        new_context.line_entry.line, s.GetData());
+          }
+        }
+      }
+    }
+  }
+
+  if (!ret_value && log)
+    log->Printf("Step range plan out of range to 0x%" PRIx64, pc_load_addr);
+
+  return ret_value;
+}
+
+bool ThreadPlanStepRange::InSymbol() {
+  lldb::addr_t cur_pc = m_thread.GetRegisterContext()->GetPC();
+  if (m_addr_context.function != nullptr) {
+    return m_addr_context.function->GetAddressRange().ContainsLoadAddress(
+        cur_pc, m_thread.CalculateTarget().get());
+  } else if (m_addr_context.symbol && m_addr_context.symbol->ValueIsAddress()) {
+    AddressRange range(m_addr_context.symbol->GetAddressRef(),
+                       m_addr_context.symbol->GetByteSize());
+    return range.ContainsLoadAddress(cur_pc, m_thread.CalculateTarget().get());
+  }
+  return false;
 }
 
-ThreadPlanStepRange::~ThreadPlanStepRange ()
-{
-    ClearNextBranchBreakpoint();
-}
-
-void
-ThreadPlanStepRange::DidPush ()
-{
-    // See if we can find a "next range" breakpoint:
-    SetNextBranchBreakpoint();
-}
+// FIXME: This should also handle inlining if we aren't going to do inlining in
+// the
+// main stack.
+//
+// Ideally we should remember the whole stack frame list, and then compare that
+// to the current list.
 
-bool
-ThreadPlanStepRange::ValidatePlan (Stream *error)
-{
-    return true;
-}
+lldb::FrameComparison ThreadPlanStepRange::CompareCurrentFrameToStartFrame() {
+  FrameComparison frame_order;
 
-Vote
-ThreadPlanStepRange::ShouldReportStop (Event *event_ptr)
-{
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
+  StackID cur_frame_id = m_thread.GetStackFrameAtIndex(0)->GetStackID();
 
-    const Vote vote = IsPlanComplete() ? eVoteYes : eVoteNo;
+  if (cur_frame_id == m_stack_id) {
+    frame_order = eFrameCompareEqual;
+  } else if (cur_frame_id < m_stack_id) {
+    frame_order = eFrameCompareYounger;
+  } else {
+    StackFrameSP cur_parent_frame = m_thread.GetStackFrameAtIndex(1);
+    StackID cur_parent_id;
+    if (cur_parent_frame)
+      cur_parent_id = cur_parent_frame->GetStackID();
+    if (m_parent_stack_id.IsValid() && cur_parent_id.IsValid() &&
+        m_parent_stack_id == cur_parent_id)
+      frame_order = eFrameCompareSameParent;
+    else
+      frame_order = eFrameCompareOlder;
+  }
+  return frame_order;
+}
+
+bool ThreadPlanStepRange::StopOthers() {
+  return (m_stop_others == lldb::eOnlyThisThread ||
+          m_stop_others == lldb::eOnlyDuringStepping);
+}
+
+InstructionList *ThreadPlanStepRange::GetInstructionsForAddress(
+    lldb::addr_t addr, size_t &range_index, size_t &insn_offset) {
+  size_t num_ranges = m_address_ranges.size();
+  for (size_t i = 0; i < num_ranges; i++) {
+    if (m_address_ranges[i].ContainsLoadAddress(addr, &GetTarget())) {
+      // Some joker added a zero size range to the stepping range...
+      if (m_address_ranges[i].GetByteSize() == 0)
+        return nullptr;
+
+      if (!m_instruction_ranges[i]) {
+        // Disassemble the address range given:
+        ExecutionContext exe_ctx(m_thread.GetProcess());
+        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, flavor, exe_ctx,
+            m_address_ranges[i], prefer_file_cache);
+      }
+      if (!m_instruction_ranges[i])
+        return nullptr;
+      else {
+        // Find where we are in the instruction list as well.  If we aren't at
+        // an instruction,
+        // 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 nullptr;
+        else {
+          range_index = i;
+          return &m_instruction_ranges[i]->GetInstructionList();
+        }
+      }
+    }
+  }
+  return nullptr;
+}
+
+void ThreadPlanStepRange::ClearNextBranchBreakpoint() {
+  if (m_next_branch_bp_sp) {
+    Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
     if (log)
-        log->Printf ("ThreadPlanStepRange::ShouldReportStop() returning vote %i\n", vote);
-    return vote;
+      log->Printf("Removing next branch breakpoint: %d.",
+                  m_next_branch_bp_sp->GetID());
+    GetTarget().RemoveBreakpointByID(m_next_branch_bp_sp->GetID());
+    m_next_branch_bp_sp.reset();
+  }
 }
 
-void
-ThreadPlanStepRange::AddRange(const AddressRange &new_range)
-{
-    // For now I'm just adding the ranges.  At some point we may want to 
-    // condense the ranges if they overlap, though I don't think it is likely
-    // to be very important.
-    m_address_ranges.push_back (new_range);
-    
-    // Fill the slot for this address range with an empty DisassemblerSP in the instruction ranges. I want the
-    // indices to match, but I don't want to do the work to disassemble this range if I don't step into it.
-    m_instruction_ranges.push_back (DisassemblerSP());
-}
-
-void
-ThreadPlanStepRange::DumpRanges(Stream *s)
-{
-    size_t num_ranges = m_address_ranges.size();
-    if (num_ranges == 1)
-    {
-        m_address_ranges[0].Dump (s, m_thread.CalculateTarget().get(), Address::DumpStyleLoadAddress);
-    }
-    else
-    {
-        for (size_t i = 0; i < num_ranges; i++)
-        {
-            s->Printf(" %" PRIu64 ": ", uint64_t(i));
-            m_address_ranges[i].Dump (s, m_thread.CalculateTarget().get(), Address::DumpStyleLoadAddress);
-        }
-    }
-}
+bool ThreadPlanStepRange::SetNextBranchBreakpoint() {
+  if (m_next_branch_bp_sp)
+    return true;
 
-bool
-ThreadPlanStepRange::InRange ()
-{
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
-    bool ret_value = false;
-
-    lldb::addr_t pc_load_addr = m_thread.GetRegisterContext()->GetPC();
-
-    size_t num_ranges = m_address_ranges.size();
-    for (size_t i = 0; i < num_ranges; i++)
-    {
-        ret_value = m_address_ranges[i].ContainsLoadAddress(pc_load_addr, m_thread.CalculateTarget().get());
-        if (ret_value)
-            break;
-    }
-    
-    if (!ret_value && !m_given_ranges_only)
-    {
-        // See if we've just stepped to another part of the same line number...
-        StackFrame *frame = m_thread.GetStackFrameAtIndex(0).get();
-        
-        SymbolContext new_context(frame->GetSymbolContext(eSymbolContextEverything));
-        if (m_addr_context.line_entry.IsValid() && new_context.line_entry.IsValid())
-        {
-            if (m_addr_context.line_entry.original_file == new_context.line_entry.original_file)
-            {
-                if (m_addr_context.line_entry.line == new_context.line_entry.line)
-                {
-                    m_addr_context = new_context;
-                    AddRange(m_addr_context.line_entry.GetSameLineContiguousAddressRange());
-                    ret_value = true;
-                    if (log)
-                    {
-                        StreamString s;
-                        m_addr_context.line_entry.Dump (&s,
-                                                        m_thread.CalculateTarget().get(),
-                                                        true,
-                                                        Address::DumpStyleLoadAddress,
-                                                        Address::DumpStyleLoadAddress,
-                                                        true);
-
-                        log->Printf ("Step range plan stepped to another range of same line: %s", s.GetData());
-                    }
-                }
-                else if (new_context.line_entry.line == 0)
-                {
-                    new_context.line_entry.line = m_addr_context.line_entry.line;
-                    m_addr_context = new_context;
-                    AddRange(m_addr_context.line_entry.GetSameLineContiguousAddressRange());
-                    ret_value = true;
-                    if (log)
-                    {
-                        StreamString s;
-                        m_addr_context.line_entry.Dump (&s,
-                                                        m_thread.CalculateTarget().get(),
-                                                        true,
-                                                        Address::DumpStyleLoadAddress,
-                                                        Address::DumpStyleLoadAddress,
-                                                        true);
-
-                        log->Printf ("Step range plan stepped to a range at linenumber 0 stepping through that range: %s", s.GetData());
-                    }
-                }
-                else if (new_context.line_entry.range.GetBaseAddress().GetLoadAddress(m_thread.CalculateTarget().get())
-                         != pc_load_addr)
-                {
-                    // Another thing that sometimes happens here is that we step out of one line into the MIDDLE of another
-                    // line.  So far I mostly see this due to bugs in the debug information.
-                    // But we probably don't want to be in the middle of a line range, so in that case reset the stepping
-                    // range to the line we've stepped into the middle of and continue.
-                    m_addr_context = new_context;
-                    m_address_ranges.clear();
-                    AddRange(m_addr_context.line_entry.range);
-                    ret_value = true;
-                    if (log)
-                    {
-                        StreamString s;
-                        m_addr_context.line_entry.Dump (&s, 
-                                                        m_thread.CalculateTarget().get(),
-                                                        true,
-                                                        Address::DumpStyleLoadAddress,
-                                                        Address::DumpStyleLoadAddress,
-                                                        true);
-
-                        log->Printf ("Step range plan stepped to the middle of new line(%d): %s, continuing to clear this line.", 
-                                     new_context.line_entry.line, 
-                                     s.GetData());
-                    }
-                }
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
+  // Stepping through ranges using breakpoints doesn't work yet, but with this
+  // off we fall back to instruction
+  // single stepping.
+  if (!m_use_fast_step)
+    return false;
+
+  lldb::addr_t cur_addr = GetThread().GetRegisterContext()->GetPC();
+  // Find the current address in our address ranges, and fetch the disassembly
+  // if we haven't already:
+  size_t pc_index;
+  size_t range_index;
+  InstructionList *instructions =
+      GetInstructionsForAddress(cur_addr, range_index, pc_index);
+  if (instructions == nullptr)
+    return false;
+  else {
+    Target &target = GetThread().GetProcess()->GetTarget();
+    uint32_t branch_index;
+    branch_index =
+        instructions->GetIndexOfNextBranchInstruction(pc_index, target);
+
+    Address run_to_address;
+
+    // If we didn't find a branch, run to the end of the range.
+    if (branch_index == UINT32_MAX) {
+      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 (run_to_address.IsValid()) {
+      const bool is_internal = true;
+      m_next_branch_bp_sp =
+          GetTarget().CreateBreakpoint(run_to_address, is_internal, false);
+      if (m_next_branch_bp_sp) {
+        if (log) {
+          lldb::break_id_t bp_site_id = LLDB_INVALID_BREAK_ID;
+          BreakpointLocationSP bp_loc =
+              m_next_branch_bp_sp->GetLocationAtIndex(0);
+          if (bp_loc) {
+            BreakpointSiteSP bp_site = bp_loc->GetBreakpointSite();
+            if (bp_site) {
+              bp_site_id = bp_site->GetID();
             }
+          }
+          log->Printf("ThreadPlanStepRange::SetNextBranchBreakpoint - Setting "
+                      "breakpoint %d (site %d) to run to address 0x%" PRIx64,
+                      m_next_branch_bp_sp->GetID(), bp_site_id,
+                      run_to_address.GetLoadAddress(
+                          &m_thread.GetProcess()->GetTarget()));
         }
+        m_next_branch_bp_sp->SetThreadID(m_thread.GetID());
+        m_next_branch_bp_sp->SetBreakpointKind("next-branch-location");
+        return true;
+      } else
+        return false;
     }
-
-    if (!ret_value && log)
-        log->Printf ("Step range plan out of range to 0x%" PRIx64, pc_load_addr);
-
-    return ret_value;
+  }
+  return false;
 }
 
-bool
-ThreadPlanStepRange::InSymbol()
-{
-    lldb::addr_t cur_pc = m_thread.GetRegisterContext()->GetPC();
-    if (m_addr_context.function != nullptr)
-    {
-        return m_addr_context.function->GetAddressRange().ContainsLoadAddress (cur_pc, m_thread.CalculateTarget().get());
-    }
-    else if (m_addr_context.symbol && m_addr_context.symbol->ValueIsAddress())
-    {
-        AddressRange range(m_addr_context.symbol->GetAddressRef(), m_addr_context.symbol->GetByteSize());
-        return range.ContainsLoadAddress (cur_pc, m_thread.CalculateTarget().get());
-    }
+bool ThreadPlanStepRange::NextRangeBreakpointExplainsStop(
+    lldb::StopInfoSP stop_info_sp) {
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
+  if (!m_next_branch_bp_sp)
     return false;
-}
-
-// FIXME: This should also handle inlining if we aren't going to do inlining in the
-// main stack.
-//
-// Ideally we should remember the whole stack frame list, and then compare that
-// to the current list.
 
-lldb::FrameComparison
-ThreadPlanStepRange::CompareCurrentFrameToStartFrame()
-{
-    FrameComparison frame_order;
-    
-    StackID cur_frame_id = m_thread.GetStackFrameAtIndex(0)->GetStackID();
-    
-    if (cur_frame_id == m_stack_id)
-    {
-        frame_order = eFrameCompareEqual;
-    }
-    else if (cur_frame_id < m_stack_id)
-    {
-        frame_order = eFrameCompareYounger;
-    }
-    else
-    {
-        StackFrameSP cur_parent_frame = m_thread.GetStackFrameAtIndex(1);
-        StackID cur_parent_id;
-        if (cur_parent_frame)
-          cur_parent_id = cur_parent_frame->GetStackID();
-        if (m_parent_stack_id.IsValid()
-            && cur_parent_id.IsValid()
-            && m_parent_stack_id == cur_parent_id)
-           frame_order = eFrameCompareSameParent;
-        else
-            frame_order = eFrameCompareOlder;
+  break_id_t bp_site_id = stop_info_sp->GetValue();
+  BreakpointSiteSP bp_site_sp =
+      m_thread.GetProcess()->GetBreakpointSiteList().FindByID(bp_site_id);
+  if (!bp_site_sp)
+    return false;
+  else if (!bp_site_sp->IsBreakpointAtThisSite(m_next_branch_bp_sp->GetID()))
+    return false;
+  else {
+    // If we've hit the next branch breakpoint, then clear it.
+    size_t num_owners = bp_site_sp->GetNumberOfOwners();
+    bool explains_stop = true;
+    // If all the owners are internal, then we are probably just stepping over
+    // this range from multiple threads,
+    // or multiple frames, so we want to continue.  If one is not internal, then
+    // we should not explain the stop,
+    // and let the user breakpoint handle the stop.
+    for (size_t i = 0; i < num_owners; i++) {
+      if (!bp_site_sp->GetOwnerAtIndex(i)->GetBreakpoint().IsInternal()) {
+        explains_stop = false;
+        break;
+      }
     }
-    return frame_order;
+    if (log)
+      log->Printf("ThreadPlanStepRange::NextRangeBreakpointExplainsStop - Hit "
+                  "next range breakpoint which has %" PRIu64
+                  " owners - explains stop: %u.",
+                  (uint64_t)num_owners, explains_stop);
+    ClearNextBranchBreakpoint();
+    return explains_stop;
+  }
 }
 
-bool
-ThreadPlanStepRange::StopOthers ()
-{
-    return (m_stop_others == lldb::eOnlyThisThread || m_stop_others == lldb::eOnlyDuringStepping);
-}
-
-InstructionList *
-ThreadPlanStepRange::GetInstructionsForAddress(lldb::addr_t addr, size_t &range_index, size_t &insn_offset)
-{
-    size_t num_ranges = m_address_ranges.size();
-    for (size_t i = 0; i < num_ranges; i++)
-    {
-        if (m_address_ranges[i].ContainsLoadAddress(addr, &GetTarget()))
-        {
-            // Some joker added a zero size range to the stepping range...
-            if (m_address_ranges[i].GetByteSize() == 0)
-                return nullptr;
-
-            if (!m_instruction_ranges[i])
-            {
-                //Disassemble the address range given:
-                ExecutionContext exe_ctx (m_thread.GetProcess());
-                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,
-                                                                         flavor,
-                                                                         exe_ctx,
-                                                                         m_address_ranges[i],
-                                                                         prefer_file_cache);
-            }
-            if (!m_instruction_ranges[i])
-                return nullptr;
-            else
-            {
-                // Find where we are in the instruction list as well.  If we aren't at an instruction,
-                // 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 nullptr;
-                else
-                {
-                    range_index = i;
-                    return &m_instruction_ranges[i]->GetInstructionList();
-                }
-            }
-        }
-    }
-    return nullptr;
-}
+bool ThreadPlanStepRange::WillStop() { return true; }
 
-void
-ThreadPlanStepRange::ClearNextBranchBreakpoint()
-{
-    if (m_next_branch_bp_sp)
-    {
-        Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
-        if (log)
-            log->Printf ("Removing next branch breakpoint: %d.", m_next_branch_bp_sp->GetID());
-        GetTarget().RemoveBreakpointByID (m_next_branch_bp_sp->GetID());
-        m_next_branch_bp_sp.reset();
-    }
+StateType ThreadPlanStepRange::GetPlanRunState() {
+  if (m_next_branch_bp_sp)
+    return eStateRunning;
+  else
+    return eStateStepping;
 }
 
-bool
-ThreadPlanStepRange::SetNextBranchBreakpoint ()
-{
-    if (m_next_branch_bp_sp)
-        return true;
+bool ThreadPlanStepRange::MischiefManaged() {
+  // If we have pushed some plans between ShouldStop & MischiefManaged, then
+  // we're not done...
+  // I do this check first because we might have stepped somewhere that will
+  // fool InRange into
+  // thinking it needs to step past the end of that line.  This happens, for
+  // instance, when stepping
+  // over inlined code that is in the middle of the current line.
 
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
-    // Stepping through ranges using breakpoints doesn't work yet, but with this off we fall back to instruction
-    // single stepping.
-    if (!m_use_fast_step)
-         return false;
-
-    lldb::addr_t cur_addr = GetThread().GetRegisterContext()->GetPC();
-    // Find the current address in our address ranges, and fetch the disassembly if we haven't already:
-    size_t pc_index;
-    size_t range_index;
-    InstructionList *instructions = GetInstructionsForAddress (cur_addr, range_index, pc_index);
-    if (instructions == nullptr)
-        return false;
-    else
-    {
-        Target &target = GetThread().GetProcess()->GetTarget();
-        uint32_t branch_index;
-        branch_index = instructions->GetIndexOfNextBranchInstruction (pc_index, target);
-        
-        Address run_to_address;
-        
-        // If we didn't find a branch, run to the end of the range.
-        if (branch_index == UINT32_MAX)
-        {
-            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 (run_to_address.IsValid())
-        {
-            const bool is_internal = true;
-            m_next_branch_bp_sp = GetTarget().CreateBreakpoint(run_to_address, is_internal, false);
-            if (m_next_branch_bp_sp)
-            {
-                if (log)
-                {
-                    lldb::break_id_t bp_site_id = LLDB_INVALID_BREAK_ID;
-                    BreakpointLocationSP bp_loc = m_next_branch_bp_sp->GetLocationAtIndex(0);
-                    if (bp_loc)
-                    {
-                        BreakpointSiteSP bp_site = bp_loc->GetBreakpointSite();
-                        if (bp_site)
-                        {
-                            bp_site_id = bp_site->GetID();
-                        }
-                    }
-                    log->Printf ("ThreadPlanStepRange::SetNextBranchBreakpoint - Setting breakpoint %d (site %d) to run to address 0x%" PRIx64,
-                                 m_next_branch_bp_sp->GetID(),
-                                 bp_site_id,
-                                 run_to_address.GetLoadAddress(&m_thread.GetProcess()->GetTarget()));
-                }
-                m_next_branch_bp_sp->SetThreadID(m_thread.GetID());
-                m_next_branch_bp_sp->SetBreakpointKind ("next-branch-location");
-                return true;
-            }
-            else
-                return false;
-        }
-    }
+  if (!m_no_more_plans)
     return false;
-}
 
-bool
-ThreadPlanStepRange::NextRangeBreakpointExplainsStop (lldb::StopInfoSP stop_info_sp)
-{
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
-    if (!m_next_branch_bp_sp)
-        return false;
-    
-    break_id_t bp_site_id = stop_info_sp->GetValue();
-    BreakpointSiteSP bp_site_sp = m_thread.GetProcess()->GetBreakpointSiteList().FindByID(bp_site_id);
-    if (!bp_site_sp)
-        return false;
-    else if (!bp_site_sp->IsBreakpointAtThisSite (m_next_branch_bp_sp->GetID()))
-        return false;
-    else
-    {
-        // If we've hit the next branch breakpoint, then clear it.
-        size_t num_owners = bp_site_sp->GetNumberOfOwners();
-        bool explains_stop = true;
-        // If all the owners are internal, then we are probably just stepping over this range from multiple threads,
-        // or multiple frames, so we want to continue.  If one is not internal, then we should not explain the stop,
-        // and let the user breakpoint handle the stop.
-        for (size_t i = 0; i < num_owners; i++)
-        {
-            if (!bp_site_sp->GetOwnerAtIndex(i)->GetBreakpoint().IsInternal())
-            {
-                explains_stop = false;
-                break;
-            }
-        }
-        if (log)
-            log->Printf ("ThreadPlanStepRange::NextRangeBreakpointExplainsStop - Hit next range breakpoint which has %" PRIu64 " owners - explains stop: %u.",
-                        (uint64_t)num_owners,
-                        explains_stop);
-        ClearNextBranchBreakpoint();
-        return  explains_stop;
+  bool done = true;
+  if (!IsPlanComplete()) {
+    if (InRange()) {
+      done = false;
+    } else {
+      FrameComparison frame_order = CompareCurrentFrameToStartFrame();
+      done = (frame_order != eFrameCompareOlder) ? m_no_more_plans : true;
     }
-}
+  }
 
-bool
-ThreadPlanStepRange::WillStop ()
-{
+  if (done) {
+    Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
+    if (log)
+      log->Printf("Completed step through range plan.");
+    ClearNextBranchBreakpoint();
+    ThreadPlan::MischiefManaged();
     return true;
+  } else {
+    return false;
+  }
 }
 
-StateType
-ThreadPlanStepRange::GetPlanRunState ()
-{
-    if (m_next_branch_bp_sp)
-        return eStateRunning;
-    else
-        return eStateStepping;
-}
+bool ThreadPlanStepRange::IsPlanStale() {
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
+  FrameComparison frame_order = CompareCurrentFrameToStartFrame();
 
-bool
-ThreadPlanStepRange::MischiefManaged ()
-{
-    // If we have pushed some plans between ShouldStop & MischiefManaged, then we're not done...
-    // I do this check first because we might have stepped somewhere that will fool InRange into
-    // thinking it needs to step past the end of that line.  This happens, for instance, when stepping
-    // over inlined code that is in the middle of the current line.
-    
-    if (!m_no_more_plans)
-        return false;
-    
-    bool done = true;
-    if (!IsPlanComplete())
-    {
-        if (InRange())
-        {
-            done = false;
-        }
-        else 
-        {
-            FrameComparison frame_order = CompareCurrentFrameToStartFrame();
-            done = (frame_order != eFrameCompareOlder) ? m_no_more_plans : true;
-        }
+  if (frame_order == eFrameCompareOlder) {
+    if (log) {
+      log->Printf("ThreadPlanStepRange::IsPlanStale returning true, we've "
+                  "stepped out.");
     }
-
-    if (done)
-    {
-        Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
-        if (log)
-            log->Printf("Completed step through range plan.");
-        ClearNextBranchBreakpoint();
-        ThreadPlan::MischiefManaged ();
-        return true;
-    }
-    else
-    {
-        return false;
-    }
-}
-
-bool
-ThreadPlanStepRange::IsPlanStale ()
-{
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
-    FrameComparison frame_order = CompareCurrentFrameToStartFrame();
-    
-    if (frame_order == eFrameCompareOlder)
-    {
-        if (log)
-        {
-            log->Printf("ThreadPlanStepRange::IsPlanStale returning true, we've stepped out.");
-        }
-        return true;
-    }
-    else if (frame_order == eFrameCompareEqual && InSymbol())
-    {
-        // If we are not in a place we should step through, we've gotten stale.
-        // One tricky bit here is that some stubs don't push a frame, so we should.  
-        // check that we are in the same symbol.          
-        if (!InRange())
-        {
-            return true;
-        }
+    return true;
+  } else if (frame_order == eFrameCompareEqual && InSymbol()) {
+    // If we are not in a place we should step through, we've gotten stale.
+    // One tricky bit here is that some stubs don't push a frame, so we should.
+    // check that we are in the same symbol.
+    if (!InRange()) {
+      return true;
     }
-    return false;
+  }
+  return false;
 }

Modified: lldb/trunk/source/Target/ThreadPlanStepThrough.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanStepThrough.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Target/ThreadPlanStepThrough.cpp (original)
+++ lldb/trunk/source/Target/ThreadPlanStepThrough.cpp Tue Sep  6 15:57:50 2016
@@ -12,6 +12,7 @@
 // Other libraries and framework includes
 // Project includes
 #include "lldb/Target/ThreadPlanStepThrough.h"
+#include "lldb/Breakpoint/Breakpoint.h"
 #include "lldb/Core/Log.h"
 #include "lldb/Core/Stream.h"
 #include "lldb/Target/DynamicLoader.h"
@@ -19,268 +20,235 @@
 #include "lldb/Target/Process.h"
 #include "lldb/Target/RegisterContext.h"
 #include "lldb/Target/Target.h"
-#include "lldb/Breakpoint/Breakpoint.h"
 
 using namespace lldb;
 using namespace lldb_private;
 
 //----------------------------------------------------------------------
-// ThreadPlanStepThrough: If the current instruction is a trampoline, step through it
-// If it is the beginning of the prologue of a function, step through that as well.
+// ThreadPlanStepThrough: If the current instruction is a trampoline, step
+// through it
+// If it is the beginning of the prologue of a function, step through that as
+// well.
 // FIXME: At present only handles DYLD trampolines.
 //----------------------------------------------------------------------
 
-ThreadPlanStepThrough::ThreadPlanStepThrough (Thread &thread, StackID &m_stack_id, bool stop_others) :
-    ThreadPlan (ThreadPlan::eKindStepThrough, "Step through trampolines and prologues", thread, eVoteNoOpinion, eVoteNoOpinion),
-    m_start_address (0),
-    m_backstop_bkpt_id (LLDB_INVALID_BREAK_ID),
-    m_backstop_addr(LLDB_INVALID_ADDRESS),
-    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.
-    if (m_sub_plan_sp)
-    {
-        m_start_address = GetThread().GetRegisterContext()->GetPC(0);
-                
-        // We are going to return back to the concrete frame 1, we might pass by some inlined code that we're in 
-        // the middle of by doing this, but it's easier than trying to figure out where the inlined code might return to.
-            
-        StackFrameSP return_frame_sp = m_thread.GetFrameWithStackID (m_stack_id);
-        
-        if (return_frame_sp)
-        {
-            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 != nullptr)
-            {
-                return_bp->SetThreadID(m_thread.GetID());
-                m_backstop_bkpt_id = return_bp->GetID();
-                return_bp->SetBreakpointKind("step-through-backstop");
-            }
-            Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
-            if (log)
-            {
-                log->Printf ("Setting backstop breakpoint %d at address: 0x%" PRIx64, m_backstop_bkpt_id, m_backstop_addr);
-            }
-        }
-    }
-}
+ThreadPlanStepThrough::ThreadPlanStepThrough(Thread &thread,
+                                             StackID &m_stack_id,
+                                             bool stop_others)
+    : ThreadPlan(ThreadPlan::eKindStepThrough,
+                 "Step through trampolines and prologues", thread,
+                 eVoteNoOpinion, eVoteNoOpinion),
+      m_start_address(0), m_backstop_bkpt_id(LLDB_INVALID_BREAK_ID),
+      m_backstop_addr(LLDB_INVALID_ADDRESS), 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.
+  if (m_sub_plan_sp) {
+    m_start_address = GetThread().GetRegisterContext()->GetPC(0);
+
+    // We are going to return back to the concrete frame 1, we might pass by
+    // some inlined code that we're in
+    // the middle of by doing this, but it's easier than trying to figure out
+    // where the inlined code might return to.
+
+    StackFrameSP return_frame_sp = m_thread.GetFrameWithStackID(m_stack_id);
+
+    if (return_frame_sp) {
+      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 != nullptr) {
+        return_bp->SetThreadID(m_thread.GetID());
+        m_backstop_bkpt_id = return_bp->GetID();
+        return_bp->SetBreakpointKind("step-through-backstop");
+      }
+      Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
+      if (log) {
+        log->Printf("Setting backstop breakpoint %d at address: 0x%" PRIx64,
+                    m_backstop_bkpt_id, m_backstop_addr);
+      }
+    }
+  }
+}
+
+ThreadPlanStepThrough::~ThreadPlanStepThrough() { ClearBackstopBreakpoint(); }
+
+void ThreadPlanStepThrough::DidPush() {
+  if (m_sub_plan_sp)
+    PushPlan(m_sub_plan_sp);
+}
+
+void ThreadPlanStepThrough::LookForPlanToStepThroughFromCurrentPC() {
+  DynamicLoader *loader = m_thread.GetProcess()->GetDynamicLoader();
+  if (loader)
+    m_sub_plan_sp =
+        loader->GetStepThroughTrampolinePlan(m_thread, m_stop_others);
+
+  // If that didn't come up with anything, try the ObjC runtime plugin:
+  if (!m_sub_plan_sp.get()) {
+    ObjCLanguageRuntime *objc_runtime =
+        m_thread.GetProcess()->GetObjCLanguageRuntime();
+    if (objc_runtime)
+      m_sub_plan_sp =
+          objc_runtime->GetStepThroughTrampolinePlan(m_thread, m_stop_others);
+  }
+
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
+  if (log) {
+    lldb::addr_t current_address = GetThread().GetRegisterContext()->GetPC(0);
+    if (m_sub_plan_sp) {
+      StreamString s;
+      m_sub_plan_sp->GetDescription(&s, lldb::eDescriptionLevelFull);
+      log->Printf("Found step through plan from 0x%" PRIx64 ": %s",
+                  current_address, s.GetData());
+    } else {
+      log->Printf("Couldn't find step through plan from address 0x%" PRIx64 ".",
+                  current_address);
+    }
+  }
+}
+
+void ThreadPlanStepThrough::GetDescription(Stream *s,
+                                           lldb::DescriptionLevel level) {
+  if (level == lldb::eDescriptionLevelBrief)
+    s->Printf("Step through");
+  else {
+    s->PutCString("Stepping through trampoline code from: ");
+    s->Address(m_start_address, sizeof(addr_t));
+    if (m_backstop_bkpt_id != LLDB_INVALID_BREAK_ID) {
+      s->Printf(" with backstop breakpoint ID: %d at address: ",
+                m_backstop_bkpt_id);
+      s->Address(m_backstop_addr, sizeof(addr_t));
+    } else
+      s->PutCString(" unable to set a backstop breakpoint.");
+  }
+}
+
+bool ThreadPlanStepThrough::ValidatePlan(Stream *error) {
+  return m_sub_plan_sp.get() != nullptr;
+}
+
+bool ThreadPlanStepThrough::DoPlanExplainsStop(Event *event_ptr) {
+  // If we have a sub-plan, it will have been asked first if we explain the
+  // stop, and
+  // we won't get asked.  The only time we would be the one directly asked this
+  // question
+  // is if we hit our backstop breakpoint.
+
+  return HitOurBackstopBreakpoint();
+}
+
+bool ThreadPlanStepThrough::ShouldStop(Event *event_ptr) {
+  // If we've already marked ourselves done, then we're done...
+  if (IsPlanComplete())
+    return true;
 
-ThreadPlanStepThrough::~ThreadPlanStepThrough ()
-{
-    ClearBackstopBreakpoint ();
-}
-
-void
-ThreadPlanStepThrough::DidPush ()
-{
-    if (m_sub_plan_sp)
-        PushPlan(m_sub_plan_sp);
-}
-
-void
-ThreadPlanStepThrough::LookForPlanToStepThroughFromCurrentPC()
-{
-    DynamicLoader *loader = m_thread.GetProcess()->GetDynamicLoader();
-    if (loader)
-        m_sub_plan_sp = loader->GetStepThroughTrampolinePlan (m_thread, m_stop_others);
-        
-    // If that didn't come up with anything, try the ObjC runtime plugin:
-    if (!m_sub_plan_sp.get())
-    {
-        ObjCLanguageRuntime *objc_runtime = m_thread.GetProcess()->GetObjCLanguageRuntime();
-        if (objc_runtime)
-            m_sub_plan_sp = objc_runtime->GetStepThroughTrampolinePlan (m_thread, m_stop_others);
-    }
-    
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
-    if (log)
-    {
-        lldb::addr_t current_address = GetThread().GetRegisterContext()->GetPC(0);
-        if (m_sub_plan_sp)
-        {
-            StreamString s;
-            m_sub_plan_sp->GetDescription(&s, lldb::eDescriptionLevelFull);
-            log->Printf ("Found step through plan from 0x%" PRIx64 ": %s", current_address, s.GetData());
-        }
-        else
-        {
-            log->Printf ("Couldn't find step through plan from address 0x%" PRIx64 ".", current_address);
-        }
-    }
-}
+  // First, did we hit the backstop breakpoint?
+  if (HitOurBackstopBreakpoint()) {
+    SetPlanComplete(true);
+    return true;
+  }
 
-void
-ThreadPlanStepThrough::GetDescription (Stream *s, lldb::DescriptionLevel level)
-{
-    if (level == lldb::eDescriptionLevelBrief)
-        s->Printf ("Step through");
-    else
-    {
-        s->PutCString ("Stepping through trampoline code from: ");
-        s->Address(m_start_address, sizeof (addr_t));
-        if (m_backstop_bkpt_id != LLDB_INVALID_BREAK_ID)
-        {
-            s->Printf(" with backstop breakpoint ID: %d at address: ", m_backstop_bkpt_id);
-            s->Address (m_backstop_addr, sizeof (addr_t));
-        }
-        else
-            s->PutCString (" unable to set a backstop breakpoint.");
-    }
-}
+  // If we don't have a sub-plan, then we're also done (can't see how we would
+  // ever get here
+  // without a plan, but just in case.
 
-bool
-ThreadPlanStepThrough::ValidatePlan (Stream *error)
-{
-    return m_sub_plan_sp.get() != nullptr;
-}
-
-bool
-ThreadPlanStepThrough::DoPlanExplainsStop (Event *event_ptr)
-{
-    // If we have a sub-plan, it will have been asked first if we explain the stop, and
-    // we won't get asked.  The only time we would be the one directly asked this question
-    // is if we hit our backstop breakpoint.
-    
-    return HitOurBackstopBreakpoint();
-}
-
-bool
-ThreadPlanStepThrough::ShouldStop (Event *event_ptr)
-{
-    // If we've already marked ourselves done, then we're done...
-    if (IsPlanComplete())
-        return true;
-        
-    // First, did we hit the backstop breakpoint?
-    if (HitOurBackstopBreakpoint())
-    {
-        SetPlanComplete(true);
-        return true;
-    }
+  if (!m_sub_plan_sp) {
+    SetPlanComplete();
+    return true;
+  }
 
-    // If we don't have a sub-plan, then we're also done (can't see how we would ever get here
-    // without a plan, but just in case.
-    
-    if (!m_sub_plan_sp)
-    {
-        SetPlanComplete();
-        return true;
-    }
-    
-    // If the current sub plan is not done, we don't want to stop.  Actually, we probably won't
-    // ever get here in this state, since we generally won't get asked any questions if out
-    // current sub-plan is not done...
-    if (!m_sub_plan_sp->IsPlanComplete())
-        return false;
-    
-    // If our current sub plan failed, then let's just run to our backstop.  If we can't do that then just stop.
-    if (!m_sub_plan_sp->PlanSucceeded())
-    {
-        if (m_backstop_bkpt_id != LLDB_INVALID_BREAK_ID)
-        {
-            m_sub_plan_sp.reset();
-            return false;
-        }
-        else
-        {
-            SetPlanComplete(false);
-            return true;
-        }
-    }
-        
-    // Next see if there is a specific step through plan at our current pc (these might 
-    // chain, for instance stepping through a dylib trampoline to the objc dispatch function...)
-    LookForPlanToStepThroughFromCurrentPC();
-    if (m_sub_plan_sp)
-    {
-        PushPlan (m_sub_plan_sp);
-        return false;
-    }
-    else
-    {
-        SetPlanComplete();
-        return true;
-    }
-}
+  // If the current sub plan is not done, we don't want to stop.  Actually, we
+  // probably won't
+  // ever get here in this state, since we generally won't get asked any
+  // questions if out
+  // current sub-plan is not done...
+  if (!m_sub_plan_sp->IsPlanComplete())
+    return false;
 
-bool
-ThreadPlanStepThrough::StopOthers ()
-{
-    return m_stop_others;
+  // If our current sub plan failed, then let's just run to our backstop.  If we
+  // can't do that then just stop.
+  if (!m_sub_plan_sp->PlanSucceeded()) {
+    if (m_backstop_bkpt_id != LLDB_INVALID_BREAK_ID) {
+      m_sub_plan_sp.reset();
+      return false;
+    } else {
+      SetPlanComplete(false);
+      return true;
+    }
+  }
+
+  // Next see if there is a specific step through plan at our current pc (these
+  // might
+  // chain, for instance stepping through a dylib trampoline to the objc
+  // dispatch function...)
+  LookForPlanToStepThroughFromCurrentPC();
+  if (m_sub_plan_sp) {
+    PushPlan(m_sub_plan_sp);
+    return false;
+  } else {
+    SetPlanComplete();
+    return true;
+  }
 }
 
-StateType
-ThreadPlanStepThrough::GetPlanRunState ()
-{
-    return eStateRunning;
+bool ThreadPlanStepThrough::StopOthers() { return m_stop_others; }
+
+StateType ThreadPlanStepThrough::GetPlanRunState() { return eStateRunning; }
+
+bool ThreadPlanStepThrough::DoWillResume(StateType resume_state,
+                                         bool current_plan) {
+  return true;
 }
 
-bool
-ThreadPlanStepThrough::DoWillResume (StateType resume_state, bool current_plan)
-{
-    return true;
+bool ThreadPlanStepThrough::WillStop() { return true; }
+
+void ThreadPlanStepThrough::ClearBackstopBreakpoint() {
+  if (m_backstop_bkpt_id != LLDB_INVALID_BREAK_ID) {
+    m_thread.GetProcess()->GetTarget().RemoveBreakpointByID(m_backstop_bkpt_id);
+    m_backstop_bkpt_id = LLDB_INVALID_BREAK_ID;
+  }
 }
 
-bool
-ThreadPlanStepThrough::WillStop ()
-{
+bool ThreadPlanStepThrough::MischiefManaged() {
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
+
+  if (!IsPlanComplete()) {
+    return false;
+  } else {
+    if (log)
+      log->Printf("Completed step through step plan.");
+
+    ClearBackstopBreakpoint();
+    ThreadPlan::MischiefManaged();
     return true;
+  }
 }
 
-void
-ThreadPlanStepThrough::ClearBackstopBreakpoint ()
-{
-    if (m_backstop_bkpt_id != LLDB_INVALID_BREAK_ID)
-    {
-        m_thread.GetProcess()->GetTarget().RemoveBreakpointByID (m_backstop_bkpt_id);
-        m_backstop_bkpt_id = LLDB_INVALID_BREAK_ID;
-    }
-}
+bool ThreadPlanStepThrough::HitOurBackstopBreakpoint() {
+  StopInfoSP stop_info_sp(m_thread.GetStopInfo());
+  if (stop_info_sp && stop_info_sp->GetStopReason() == eStopReasonBreakpoint) {
+    break_id_t stop_value = (break_id_t)stop_info_sp->GetValue();
+    BreakpointSiteSP cur_site_sp =
+        m_thread.GetProcess()->GetBreakpointSiteList().FindByID(stop_value);
+    if (cur_site_sp &&
+        cur_site_sp->IsBreakpointAtThisSite(m_backstop_bkpt_id)) {
+      StackID cur_frame_zero_id =
+          m_thread.GetStackFrameAtIndex(0)->GetStackID();
 
-bool
-ThreadPlanStepThrough::MischiefManaged ()
-{
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
-
-    if (!IsPlanComplete())
-    {
-        return false;
-    }
-    else
-    {
+      if (cur_frame_zero_id == m_return_stack_id) {
+        Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
         if (log)
-            log->Printf("Completed step through step plan.");
-            
-        ClearBackstopBreakpoint ();
-        ThreadPlan::MischiefManaged ();
+          log->PutCString("ThreadPlanStepThrough hit backstop breakpoint.");
         return true;
+      }
     }
-}
-
-bool
-ThreadPlanStepThrough::HitOurBackstopBreakpoint()
-{
-    StopInfoSP stop_info_sp(m_thread.GetStopInfo());
-    if (stop_info_sp && stop_info_sp->GetStopReason() == eStopReasonBreakpoint)
-    {
-        break_id_t stop_value = (break_id_t) stop_info_sp->GetValue();
-        BreakpointSiteSP cur_site_sp = m_thread.GetProcess()->GetBreakpointSiteList().FindByID(stop_value);
-        if (cur_site_sp && cur_site_sp->IsBreakpointAtThisSite(m_backstop_bkpt_id))
-        {
-            StackID cur_frame_zero_id = m_thread.GetStackFrameAtIndex(0)->GetStackID();
-            
-            if (cur_frame_zero_id == m_return_stack_id)
-            {
-                Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
-                if (log)
-                    log->PutCString ("ThreadPlanStepThrough hit backstop breakpoint.");
-                return true;
-            }
-        }
-    }
-    return false;
+  }
+  return false;
 }

Modified: lldb/trunk/source/Target/ThreadPlanStepUntil.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanStepUntil.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Target/ThreadPlanStepUntil.cpp (original)
+++ lldb/trunk/source/Target/ThreadPlanStepUntil.cpp Tue Sep  6 15:57:50 2016
@@ -23,371 +23,317 @@ using namespace lldb;
 using namespace lldb_private;
 
 //----------------------------------------------------------------------
-// ThreadPlanStepUntil: Run until we reach a given line number or step out of the current frame
+// ThreadPlanStepUntil: Run until we reach a given line number or step out of
+// the current frame
 //----------------------------------------------------------------------
 
-ThreadPlanStepUntil::ThreadPlanStepUntil
-(
-    Thread &thread,
-    lldb::addr_t *address_list,
-    size_t num_addresses,
-    bool stop_others,
-    uint32_t frame_idx
-) :
-    ThreadPlan (ThreadPlan::eKindStepUntil, "Step until", thread, eVoteNoOpinion, eVoteNoOpinion),
-    m_step_from_insn (LLDB_INVALID_ADDRESS),
-    m_return_bp_id (LLDB_INVALID_BREAK_ID),
-    m_return_addr (LLDB_INVALID_ADDRESS),
-    m_stepped_out (false),
-    m_should_stop (false),
-    m_ran_analyze (false),
-    m_explains_stop (false),
-    m_until_points (),
-    m_stop_others (stop_others)
-{
-    // Stash away our "until" addresses:
-    TargetSP target_sp (m_thread.CalculateTarget());
-
-    StackFrameSP frame_sp (m_thread.GetStackFrameAtIndex (frame_idx));
-    if (frame_sp)
-    {
-        m_step_from_insn = frame_sp->GetStackID().GetPC();
-        lldb::user_id_t thread_id = m_thread.GetID();
-
-        // Find the return address and set a breakpoint there:
-        // FIXME - can we do this more securely if we know first_insn?
-
-        StackFrameSP return_frame_sp (m_thread.GetStackFrameAtIndex(frame_idx + 1));
-        if (return_frame_sp)
-        {
-            // 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 != nullptr)
-            {
-                return_bp->SetThreadID(thread_id);
-                m_return_bp_id = return_bp->GetID();
-                return_bp->SetBreakpointKind ("until-return-backstop");
-            }
-        }
+ThreadPlanStepUntil::ThreadPlanStepUntil(Thread &thread,
+                                         lldb::addr_t *address_list,
+                                         size_t num_addresses, bool stop_others,
+                                         uint32_t frame_idx)
+    : ThreadPlan(ThreadPlan::eKindStepUntil, "Step until", thread,
+                 eVoteNoOpinion, eVoteNoOpinion),
+      m_step_from_insn(LLDB_INVALID_ADDRESS),
+      m_return_bp_id(LLDB_INVALID_BREAK_ID),
+      m_return_addr(LLDB_INVALID_ADDRESS), m_stepped_out(false),
+      m_should_stop(false), m_ran_analyze(false), m_explains_stop(false),
+      m_until_points(), m_stop_others(stop_others) {
+  // Stash away our "until" addresses:
+  TargetSP target_sp(m_thread.CalculateTarget());
+
+  StackFrameSP frame_sp(m_thread.GetStackFrameAtIndex(frame_idx));
+  if (frame_sp) {
+    m_step_from_insn = frame_sp->GetStackID().GetPC();
+    lldb::user_id_t thread_id = m_thread.GetID();
+
+    // Find the return address and set a breakpoint there:
+    // FIXME - can we do this more securely if we know first_insn?
+
+    StackFrameSP return_frame_sp(m_thread.GetStackFrameAtIndex(frame_idx + 1));
+    if (return_frame_sp) {
+      // 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 != nullptr) {
+        return_bp->SetThreadID(thread_id);
+        m_return_bp_id = return_bp->GetID();
+        return_bp->SetBreakpointKind("until-return-backstop");
+      }
+    }
 
-        m_stack_id = frame_sp->GetStackID();
+    m_stack_id = frame_sp->GetStackID();
 
-        // Now set breakpoints on all our return addresses:
-        for (size_t i = 0; i < num_addresses; i++)
-        {
-            Breakpoint *until_bp = target_sp->CreateBreakpoint (address_list[i], true, false).get();
-            if (until_bp != nullptr)
-            {
-                until_bp->SetThreadID(thread_id);
-                m_until_points[address_list[i]] = until_bp->GetID();
-                until_bp->SetBreakpointKind("until-target");
-            }
-            else
-            {
-                m_until_points[address_list[i]] = LLDB_INVALID_BREAK_ID;
-            }
-        }
+    // Now set breakpoints on all our return addresses:
+    for (size_t i = 0; i < num_addresses; i++) {
+      Breakpoint *until_bp =
+          target_sp->CreateBreakpoint(address_list[i], true, false).get();
+      if (until_bp != nullptr) {
+        until_bp->SetThreadID(thread_id);
+        m_until_points[address_list[i]] = until_bp->GetID();
+        until_bp->SetBreakpointKind("until-target");
+      } else {
+        m_until_points[address_list[i]] = LLDB_INVALID_BREAK_ID;
+      }
     }
+  }
 }
 
-ThreadPlanStepUntil::~ThreadPlanStepUntil ()
-{
-    Clear();
-}
+ThreadPlanStepUntil::~ThreadPlanStepUntil() { Clear(); }
 
-void
-ThreadPlanStepUntil::Clear()
-{
-    TargetSP target_sp (m_thread.CalculateTarget());
-    if (target_sp)
-    {
-        if (m_return_bp_id != LLDB_INVALID_BREAK_ID)
-        {
-            target_sp->RemoveBreakpointByID(m_return_bp_id);
-            m_return_bp_id = LLDB_INVALID_BREAK_ID;
-        }
+void ThreadPlanStepUntil::Clear() {
+  TargetSP target_sp(m_thread.CalculateTarget());
+  if (target_sp) {
+    if (m_return_bp_id != LLDB_INVALID_BREAK_ID) {
+      target_sp->RemoveBreakpointByID(m_return_bp_id);
+      m_return_bp_id = LLDB_INVALID_BREAK_ID;
+    }
 
-        until_collection::iterator pos, end = m_until_points.end();
-        for (pos = m_until_points.begin(); pos != end; pos++)
-        {
-            target_sp->RemoveBreakpointByID((*pos).second);
-        }
+    until_collection::iterator pos, end = m_until_points.end();
+    for (pos = m_until_points.begin(); pos != end; pos++) {
+      target_sp->RemoveBreakpointByID((*pos).second);
     }
-    m_until_points.clear();
+  }
+  m_until_points.clear();
 }
 
-void
-ThreadPlanStepUntil::GetDescription (Stream *s, lldb::DescriptionLevel level)
-{
-    if (level == lldb::eDescriptionLevelBrief)
-    {
-        s->Printf ("step until");
-        if (m_stepped_out)
-            s->Printf (" - stepped out");
-    }
-    else
-    {
-        if (m_until_points.size() == 1)
-            s->Printf ("Stepping from address 0x%" PRIx64 " until we reach 0x%" PRIx64 " using breakpoint %d",
-                       (uint64_t)m_step_from_insn,
-                       (uint64_t) (*m_until_points.begin()).first,
-                       (*m_until_points.begin()).second);
-        else
-        {
-            until_collection::iterator pos, end = m_until_points.end();
-            s->Printf ("Stepping from address 0x%" PRIx64 " until we reach one of:",
-                       (uint64_t)m_step_from_insn);
-            for (pos = m_until_points.begin(); pos != end; pos++)
-            {
-                s->Printf ("\n\t0x%" PRIx64 " (bp: %d)", (uint64_t) (*pos).first, (*pos).second);
-            }
-        }
-        s->Printf(" stepped out address is 0x%" PRIx64 ".", (uint64_t) m_return_addr);
+void ThreadPlanStepUntil::GetDescription(Stream *s,
+                                         lldb::DescriptionLevel level) {
+  if (level == lldb::eDescriptionLevelBrief) {
+    s->Printf("step until");
+    if (m_stepped_out)
+      s->Printf(" - stepped out");
+  } else {
+    if (m_until_points.size() == 1)
+      s->Printf("Stepping from address 0x%" PRIx64 " until we reach 0x%" PRIx64
+                " using breakpoint %d",
+                (uint64_t)m_step_from_insn,
+                (uint64_t)(*m_until_points.begin()).first,
+                (*m_until_points.begin()).second);
+    else {
+      until_collection::iterator pos, end = m_until_points.end();
+      s->Printf("Stepping from address 0x%" PRIx64 " until we reach one of:",
+                (uint64_t)m_step_from_insn);
+      for (pos = m_until_points.begin(); pos != end; pos++) {
+        s->Printf("\n\t0x%" PRIx64 " (bp: %d)", (uint64_t)(*pos).first,
+                  (*pos).second);
+      }
     }
+    s->Printf(" stepped out address is 0x%" PRIx64 ".",
+              (uint64_t)m_return_addr);
+  }
 }
 
-bool
-ThreadPlanStepUntil::ValidatePlan (Stream *error)
-{
-    if (m_return_bp_id == LLDB_INVALID_BREAK_ID)
+bool ThreadPlanStepUntil::ValidatePlan(Stream *error) {
+  if (m_return_bp_id == LLDB_INVALID_BREAK_ID)
+    return false;
+  else {
+    until_collection::iterator pos, end = m_until_points.end();
+    for (pos = m_until_points.begin(); pos != end; pos++) {
+      if (!LLDB_BREAK_ID_IS_VALID((*pos).second))
         return false;
-    else
-    {
-        until_collection::iterator pos, end = m_until_points.end();
-        for (pos = m_until_points.begin(); pos != end; pos++)
-        {
-            if (!LLDB_BREAK_ID_IS_VALID ((*pos).second))
-                return false;
-        }
-        return true;
     }
+    return true;
+  }
 }
 
-void
-ThreadPlanStepUntil::AnalyzeStop()
-{
-    if (m_ran_analyze)
+void ThreadPlanStepUntil::AnalyzeStop() {
+  if (m_ran_analyze)
+    return;
+
+  StopInfoSP stop_info_sp = GetPrivateStopInfo();
+  m_should_stop = true;
+  m_explains_stop = false;
+
+  if (stop_info_sp) {
+    StopReason reason = stop_info_sp->GetStopReason();
+
+    if (reason == 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) {
+        m_explains_stop = false;
         return;
-        
-    StopInfoSP stop_info_sp = GetPrivateStopInfo ();
-    m_should_stop = true;
-    m_explains_stop = false;
-    
-    if (stop_info_sp)
-    {
-        StopReason reason = stop_info_sp->GetStopReason();
-
-        if (reason == 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)
-            {
-                m_explains_stop = false;
-                return;
-            }
+      }
+
+      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) {
+          m_stepped_out = true;
+          SetPlanComplete();
+        } else
+          m_should_stop = false;
 
-            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)
-                {
-                    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;
+        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++) {
+          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 {
+              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);
+
+                done = (older_context == stack_context);
+              } else
+                done = false;
             }
+
+            if (done)
+              SetPlanComplete();
             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++)
-                {
-                    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
-                        {
-                            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);
-                                
-                                done = (older_context == stack_context);
-                            }
-                            else
-                                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;
-                    }
-                }
+              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;
             }
-            // 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;
-        }
+      }
+      // 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;
     }
+  }
 }
 
-bool
-ThreadPlanStepUntil::DoPlanExplainsStop (Event *event_ptr)
-{
-    // We don't explain signals or breakpoints (breakpoints that handle stepping in or
-    // out will be handled by a child plan.
-    AnalyzeStop();
-    return m_explains_stop;
-}
-
-bool
-ThreadPlanStepUntil::ShouldStop (Event *event_ptr)
-{
-    // If we've told our self in ExplainsStop that we plan to continue, then
-    // do so here.  Otherwise, as long as this thread has stopped for a reason,
-    // we will stop.
-
-    StopInfoSP stop_info_sp = GetPrivateStopInfo ();
-    if (!stop_info_sp || stop_info_sp->GetStopReason() == eStopReasonNone)
-        return false;
-
-    AnalyzeStop();
-    return m_should_stop;
-}
-
-bool
-ThreadPlanStepUntil::StopOthers ()
-{
-    return m_stop_others;
-}
-
-StateType
-ThreadPlanStepUntil::GetPlanRunState ()
-{
-    return eStateRunning;
-}
-
-bool
-ThreadPlanStepUntil::DoWillResume (StateType resume_state, bool current_plan)
-{
-    if (current_plan)
-    {
-        TargetSP target_sp (m_thread.CalculateTarget());
-        if (target_sp)
-        {
-            Breakpoint *return_bp = target_sp->GetBreakpointByID(m_return_bp_id).get();
-            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 != nullptr)
-                    until_bp->SetEnabled (true);
-            }
-        }
+bool ThreadPlanStepUntil::DoPlanExplainsStop(Event *event_ptr) {
+  // We don't explain signals or breakpoints (breakpoints that handle stepping
+  // in or
+  // out will be handled by a child plan.
+  AnalyzeStop();
+  return m_explains_stop;
+}
+
+bool ThreadPlanStepUntil::ShouldStop(Event *event_ptr) {
+  // If we've told our self in ExplainsStop that we plan to continue, then
+  // do so here.  Otherwise, as long as this thread has stopped for a reason,
+  // we will stop.
+
+  StopInfoSP stop_info_sp = GetPrivateStopInfo();
+  if (!stop_info_sp || stop_info_sp->GetStopReason() == eStopReasonNone)
+    return false;
+
+  AnalyzeStop();
+  return m_should_stop;
+}
+
+bool ThreadPlanStepUntil::StopOthers() { return m_stop_others; }
+
+StateType ThreadPlanStepUntil::GetPlanRunState() { return eStateRunning; }
+
+bool ThreadPlanStepUntil::DoWillResume(StateType resume_state,
+                                       bool current_plan) {
+  if (current_plan) {
+    TargetSP target_sp(m_thread.CalculateTarget());
+    if (target_sp) {
+      Breakpoint *return_bp =
+          target_sp->GetBreakpointByID(m_return_bp_id).get();
+      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 != nullptr)
+          until_bp->SetEnabled(true);
+      }
     }
-    
-    m_should_stop = true;
-    m_ran_analyze = false;
-    m_explains_stop = false;
-    return true;
-}
+  }
 
-bool
-ThreadPlanStepUntil::WillStop ()
-{
-    TargetSP target_sp (m_thread.CalculateTarget());
-    if (target_sp)
-    {
-        Breakpoint *return_bp = target_sp->GetBreakpointByID(m_return_bp_id).get();
-        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 != nullptr)
-                until_bp->SetEnabled (false);
-        }
+  m_should_stop = true;
+  m_ran_analyze = false;
+  m_explains_stop = false;
+  return true;
+}
+
+bool ThreadPlanStepUntil::WillStop() {
+  TargetSP target_sp(m_thread.CalculateTarget());
+  if (target_sp) {
+    Breakpoint *return_bp = target_sp->GetBreakpointByID(m_return_bp_id).get();
+    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 != nullptr)
+        until_bp->SetEnabled(false);
     }
-    return true;
+  }
+  return true;
 }
 
-bool
-ThreadPlanStepUntil::MischiefManaged ()
-{
-    // I'm letting "PlanExplainsStop" do all the work, and just reporting that here.
-    bool done = false;
-    if (IsPlanComplete())
-    {
-        Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
-        if (log)
-            log->Printf("Completed step until plan.");
+bool ThreadPlanStepUntil::MischiefManaged() {
+  // I'm letting "PlanExplainsStop" do all the work, and just reporting that
+  // here.
+  bool done = false;
+  if (IsPlanComplete()) {
+    Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
+    if (log)
+      log->Printf("Completed step until plan.");
 
-        Clear();
-        done = true;
-    }
-    if (done)
-        ThreadPlan::MischiefManaged ();
+    Clear();
+    done = true;
+  }
+  if (done)
+    ThreadPlan::MischiefManaged();
 
-    return done;
+  return done;
 }

Modified: lldb/trunk/source/Target/ThreadPlanTracer.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanTracer.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Target/ThreadPlanTracer.cpp (original)
+++ lldb/trunk/source/Target/ThreadPlanTracer.cpp Tue Sep  6 15:57:50 2016
@@ -13,7 +13,6 @@
 
 // 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"
@@ -27,244 +26,206 @@
 #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"
 #include "lldb/Target/Process.h"
+#include "lldb/Target/RegisterContext.h"
 #include "lldb/Target/SectionLoadList.h"
 #include "lldb/Target/Target.h"
+#include "lldb/Target/Thread.h"
+#include "lldb/Target/ThreadPlan.h"
 
 using namespace lldb;
 using namespace lldb_private;
 
 #pragma mark ThreadPlanTracer
 
-ThreadPlanTracer::ThreadPlanTracer (Thread &thread, lldb::StreamSP &stream_sp) :
-    m_thread (thread),
-    m_single_step(true),
-    m_enabled (false),
-    m_stream_sp (stream_sp)
-{
-}
-
-ThreadPlanTracer::ThreadPlanTracer (Thread &thread) :
-    m_thread (thread),
-    m_single_step(true),
-    m_enabled (false),
-    m_stream_sp ()
-{
+ThreadPlanTracer::ThreadPlanTracer(Thread &thread, lldb::StreamSP &stream_sp)
+    : m_thread(thread), m_single_step(true), m_enabled(false),
+      m_stream_sp(stream_sp) {}
+
+ThreadPlanTracer::ThreadPlanTracer(Thread &thread)
+    : m_thread(thread), m_single_step(true), m_enabled(false), m_stream_sp() {}
+
+Stream *ThreadPlanTracer::GetLogStream() {
+  if (m_stream_sp)
+    return m_stream_sp.get();
+  else {
+    TargetSP target_sp(m_thread.CalculateTarget());
+    if (target_sp)
+      return target_sp->GetDebugger().GetOutputFile().get();
+  }
+  return nullptr;
+}
+
+void ThreadPlanTracer::Log() {
+  SymbolContext sc;
+  bool show_frame_index = false;
+  bool show_fullpaths = false;
+
+  Stream *stream = GetLogStream();
+  if (stream) {
+    m_thread.GetStackFrameAtIndex(0)->Dump(stream, show_frame_index,
+                                           show_fullpaths);
+    stream->Printf("\n");
+    stream->Flush();
+  }
 }
 
-Stream *
-ThreadPlanTracer::GetLogStream ()
-{
-    if (m_stream_sp)
-        return m_stream_sp.get();
-    else
-    {
-        TargetSP target_sp (m_thread.CalculateTarget());
-        if (target_sp)
-            return target_sp->GetDebugger().GetOutputFile().get();
-    }
-    return nullptr;
-}
-
-void 
-ThreadPlanTracer::Log()
-{
-    SymbolContext sc;
-    bool show_frame_index = false;
-    bool show_fullpaths = false;
-    
-    Stream *stream = GetLogStream();
-    if (stream)
-    {
-        m_thread.GetStackFrameAtIndex(0)->Dump (stream, show_frame_index, show_fullpaths);
-        stream->Printf("\n");
-        stream->Flush();
-    }
-}
-
-bool
-ThreadPlanTracer::TracerExplainsStop ()
-{
-    if (m_enabled && m_single_step)
-    {
-        lldb::StopInfoSP stop_info = m_thread.GetStopInfo();
-        return (stop_info->GetStopReason() == eStopReasonTrace);
-    }
-    else
-        return false;
+bool ThreadPlanTracer::TracerExplainsStop() {
+  if (m_enabled && m_single_step) {
+    lldb::StopInfoSP stop_info = m_thread.GetStopInfo();
+    return (stop_info->GetStopReason() == eStopReasonTrace);
+  } else
+    return false;
 }
 
 #pragma mark ThreadPlanAssemblyTracer
 
-ThreadPlanAssemblyTracer::ThreadPlanAssemblyTracer (Thread &thread, lldb::StreamSP &stream_sp) :
-    ThreadPlanTracer (thread, stream_sp),
-    m_disassembler_sp (),
-    m_intptr_type (),
-    m_register_values ()
-{
-}
-
-ThreadPlanAssemblyTracer::ThreadPlanAssemblyTracer (Thread &thread) :
-    ThreadPlanTracer (thread),
-    m_disassembler_sp (),
-    m_intptr_type (),
-    m_register_values ()
-{
-}
-
-Disassembler *
-ThreadPlanAssemblyTracer::GetDisassembler ()
-{
-    if (!m_disassembler_sp)
-        m_disassembler_sp = Disassembler::FindPlugin(m_thread.GetProcess()->GetTarget().GetArchitecture(), nullptr, nullptr);
-    return m_disassembler_sp.get();
-}
-
-TypeFromUser
-ThreadPlanAssemblyTracer::GetIntPointerType()
-{
-    if (!m_intptr_type.IsValid ())
-    {
-        TargetSP target_sp (m_thread.CalculateTarget());
-        if (target_sp)
-        {
-            TypeSystem *type_system = target_sp->GetScratchTypeSystemForLanguage(nullptr, eLanguageTypeC);
-            if (type_system)
-                m_intptr_type = TypeFromUser(type_system->GetBuiltinTypeForEncodingAndBitSize(eEncodingUint, target_sp->GetArchitecture().GetAddressByteSize() * 8));
-        }        
+ThreadPlanAssemblyTracer::ThreadPlanAssemblyTracer(Thread &thread,
+                                                   lldb::StreamSP &stream_sp)
+    : ThreadPlanTracer(thread, stream_sp), m_disassembler_sp(), m_intptr_type(),
+      m_register_values() {}
+
+ThreadPlanAssemblyTracer::ThreadPlanAssemblyTracer(Thread &thread)
+    : ThreadPlanTracer(thread), m_disassembler_sp(), m_intptr_type(),
+      m_register_values() {}
+
+Disassembler *ThreadPlanAssemblyTracer::GetDisassembler() {
+  if (!m_disassembler_sp)
+    m_disassembler_sp = Disassembler::FindPlugin(
+        m_thread.GetProcess()->GetTarget().GetArchitecture(), nullptr, nullptr);
+  return m_disassembler_sp.get();
+}
+
+TypeFromUser ThreadPlanAssemblyTracer::GetIntPointerType() {
+  if (!m_intptr_type.IsValid()) {
+    TargetSP target_sp(m_thread.CalculateTarget());
+    if (target_sp) {
+      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;
+  }
+  return m_intptr_type;
 }
 
 ThreadPlanAssemblyTracer::~ThreadPlanAssemblyTracer() = default;
 
-void 
-ThreadPlanAssemblyTracer::TracingStarted ()
-{
-    RegisterContext *reg_ctx = m_thread.GetRegisterContext().get();
-    
-    if (m_register_values.empty())
-        m_register_values.resize (reg_ctx->GetRegisterCount());
-}
+void ThreadPlanAssemblyTracer::TracingStarted() {
+  RegisterContext *reg_ctx = m_thread.GetRegisterContext().get();
 
-void
-ThreadPlanAssemblyTracer::TracingEnded ()
-{
-    m_register_values.clear();
+  if (m_register_values.empty())
+    m_register_values.resize(reg_ctx->GetRegisterCount());
 }
 
-void 
-ThreadPlanAssemblyTracer::Log ()
-{
-    Stream *stream = GetLogStream ();
-    
-    if (!stream)
-        return;
-            
-    RegisterContext *reg_ctx = m_thread.GetRegisterContext().get();
-    
-    lldb::addr_t pc = reg_ctx->GetPC();
-    ProcessSP process_sp (m_thread.GetProcess());
-    Address pc_addr;
-    bool addr_valid = false;
-    uint8_t buffer[16] = {0}; // Must be big enough for any single instruction
-    addr_valid = process_sp->GetTarget().GetSectionLoadList().ResolveLoadAddress (pc, pc_addr);
-    
-    pc_addr.Dump(stream, &m_thread, Address::DumpStyleResolvedDescription, Address::DumpStyleModuleWithFileAddress);
-    stream->PutCString (" ");
-    
-    Disassembler *disassembler = GetDisassembler();
-    if (disassembler)
-    {        
-        Error err;
-        process_sp->ReadMemory(pc, buffer, sizeof(buffer), err);
-        
-        if (err.Success())
-        {
-            DataExtractor extractor(buffer, sizeof(buffer), 
-                                    process_sp->GetByteOrder(), 
-                                    process_sp->GetAddressByteSize());
-            
-			bool data_from_file = false;
-            if (addr_valid)
-                disassembler->DecodeInstructions (pc_addr, extractor, 0, 1, false, data_from_file);
-            else
-                disassembler->DecodeInstructions (Address (pc), extractor, 0, 1, false, data_from_file);
-            
-            InstructionList &instruction_list = disassembler->GetInstructionList();
-            const uint32_t max_opcode_byte_size = instruction_list.GetMaxOpcocdeByteSize();
-
-            if (instruction_list.GetSize())
-            {
-                const bool show_bytes = true;
-                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,
-                                  nullptr,
-                                  nullptr,
-                                  nullptr,
-                                  disassemble_format,
-                                  0);
-            }
-        }
-    }
-    
-    const ABI *abi = process_sp->GetABI().get();
-    TypeFromUser intptr_type = GetIntPointerType();
-    
-    if (abi && intptr_type.IsValid())
-    {
-        ValueList value_list;
-        const int num_args = 1;
-        
-        for (int arg_index = 0; arg_index < num_args; ++arg_index)
-        {
-            Value value;
-            value.SetValueType (Value::eValueTypeScalar);
-//            value.SetContext (Value::eContextTypeClangType, intptr_type.GetOpaqueQualType());
-            value.SetCompilerType (intptr_type);
-            value_list.PushValue (value);
-        }
-        
-        if (abi->GetArgumentValues (m_thread, value_list))
-        {                
-            for (int arg_index = 0; arg_index < num_args; ++arg_index)
-            {
-                stream->Printf("\n\targ[%d]=%llx", arg_index, value_list.GetValueAtIndex(arg_index)->GetScalar().ULongLong());
-                
-                if (arg_index + 1 < num_args)
-                    stream->PutCString (", ");
-            }
-        }
-    }
+void ThreadPlanAssemblyTracer::TracingEnded() { m_register_values.clear(); }
 
-    RegisterValue reg_value;
-    for (uint32_t reg_num = 0, num_registers = reg_ctx->GetRegisterCount();
-         reg_num < num_registers;
-         ++reg_num)
-    {
-        const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoAtIndex(reg_num);
-        if (reg_ctx->ReadRegister (reg_info, reg_value))
-        {
-            assert (reg_num < m_register_values.size());
-            if (m_register_values[reg_num].GetType() == RegisterValue::eTypeInvalid || 
-                reg_value != m_register_values[reg_num])
-            {
-                if (reg_value.GetType() != RegisterValue::eTypeInvalid)
-                {
-                    stream->PutCString ("\n\t");
-                    reg_value.Dump(stream, reg_info, true, false, eFormatDefault);
-                }
-            }
-            m_register_values[reg_num] = reg_value;
+void ThreadPlanAssemblyTracer::Log() {
+  Stream *stream = GetLogStream();
+
+  if (!stream)
+    return;
+
+  RegisterContext *reg_ctx = m_thread.GetRegisterContext().get();
+
+  lldb::addr_t pc = reg_ctx->GetPC();
+  ProcessSP process_sp(m_thread.GetProcess());
+  Address pc_addr;
+  bool addr_valid = false;
+  uint8_t buffer[16] = {0}; // Must be big enough for any single instruction
+  addr_valid = process_sp->GetTarget().GetSectionLoadList().ResolveLoadAddress(
+      pc, pc_addr);
+
+  pc_addr.Dump(stream, &m_thread, Address::DumpStyleResolvedDescription,
+               Address::DumpStyleModuleWithFileAddress);
+  stream->PutCString(" ");
+
+  Disassembler *disassembler = GetDisassembler();
+  if (disassembler) {
+    Error err;
+    process_sp->ReadMemory(pc, buffer, sizeof(buffer), err);
+
+    if (err.Success()) {
+      DataExtractor extractor(buffer, sizeof(buffer),
+                              process_sp->GetByteOrder(),
+                              process_sp->GetAddressByteSize());
+
+      bool data_from_file = false;
+      if (addr_valid)
+        disassembler->DecodeInstructions(pc_addr, extractor, 0, 1, false,
+                                         data_from_file);
+      else
+        disassembler->DecodeInstructions(Address(pc), extractor, 0, 1, false,
+                                         data_from_file);
+
+      InstructionList &instruction_list = disassembler->GetInstructionList();
+      const uint32_t max_opcode_byte_size =
+          instruction_list.GetMaxOpcocdeByteSize();
+
+      if (instruction_list.GetSize()) {
+        const bool show_bytes = true;
+        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, nullptr, nullptr, nullptr,
+                          disassemble_format, 0);
+      }
+    }
+  }
+
+  const ABI *abi = process_sp->GetABI().get();
+  TypeFromUser intptr_type = GetIntPointerType();
+
+  if (abi && intptr_type.IsValid()) {
+    ValueList value_list;
+    const int num_args = 1;
+
+    for (int arg_index = 0; arg_index < num_args; ++arg_index) {
+      Value value;
+      value.SetValueType(Value::eValueTypeScalar);
+      //            value.SetContext (Value::eContextTypeClangType,
+      //            intptr_type.GetOpaqueQualType());
+      value.SetCompilerType(intptr_type);
+      value_list.PushValue(value);
+    }
+
+    if (abi->GetArgumentValues(m_thread, value_list)) {
+      for (int arg_index = 0; arg_index < num_args; ++arg_index) {
+        stream->Printf(
+            "\n\targ[%d]=%llx", arg_index,
+            value_list.GetValueAtIndex(arg_index)->GetScalar().ULongLong());
+
+        if (arg_index + 1 < num_args)
+          stream->PutCString(", ");
+      }
+    }
+  }
+
+  RegisterValue reg_value;
+  for (uint32_t reg_num = 0, num_registers = reg_ctx->GetRegisterCount();
+       reg_num < num_registers; ++reg_num) {
+    const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoAtIndex(reg_num);
+    if (reg_ctx->ReadRegister(reg_info, reg_value)) {
+      assert(reg_num < m_register_values.size());
+      if (m_register_values[reg_num].GetType() == RegisterValue::eTypeInvalid ||
+          reg_value != m_register_values[reg_num]) {
+        if (reg_value.GetType() != RegisterValue::eTypeInvalid) {
+          stream->PutCString("\n\t");
+          reg_value.Dump(stream, reg_info, true, false, eFormatDefault);
         }
+      }
+      m_register_values[reg_num] = reg_value;
     }
-    stream->EOL();
-    stream->Flush();
+  }
+  stream->EOL();
+  stream->Flush();
 }

Modified: lldb/trunk/source/Target/ThreadSpec.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadSpec.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Target/ThreadSpec.cpp (original)
+++ lldb/trunk/source/Target/ThreadSpec.cpp Tue Sep  6 15:57:50 2016
@@ -17,142 +17,107 @@
 using namespace lldb;
 using namespace lldb_private;
 
-ThreadSpec::ThreadSpec() :
-    m_index (UINT32_MAX),
-    m_tid (LLDB_INVALID_THREAD_ID),
-    m_name(),
-    m_queue_name ()
-{
-}
-
-ThreadSpec::ThreadSpec(const ThreadSpec &rhs) :
-    m_index(rhs.m_index),
-    m_tid(rhs.m_tid),
-    m_name(rhs.m_name),
-    m_queue_name(rhs.m_queue_name)
-{
-}
-
-const ThreadSpec &
-ThreadSpec::operator=(const ThreadSpec &rhs)
-{
-    m_index = rhs.m_index;
-    m_tid = rhs.m_tid;
-    m_name = rhs.m_name;
-    m_queue_name = rhs.m_queue_name;
-    return *this;
-}
-
-const char *
-ThreadSpec::GetName () const
-{
-    return m_name.empty() ? nullptr : m_name.c_str();
-}
-
-const char *
-ThreadSpec::GetQueueName () const
-{
-    return m_queue_name.empty() ? nullptr : m_queue_name.c_str();
-}
-
-bool
-ThreadSpec::TIDMatches (Thread &thread) const
-{
-    if (m_tid == LLDB_INVALID_THREAD_ID)
-        return true;
-        
-    lldb::tid_t thread_id = thread.GetID();
-    return TIDMatches (thread_id);
-}
-
-bool 
-ThreadSpec::IndexMatches (Thread &thread) const
-{
-    if (m_index == UINT32_MAX)
-        return true;
-    uint32_t index = thread.GetIndexID();
-    return IndexMatches (index);
-}
-
-bool 
-ThreadSpec::NameMatches (Thread &thread) const
-{
-    if (m_name.empty())
-        return true;
-        
-    const char *name = thread.GetName();
-    return NameMatches (name);
-}
-
-bool 
-ThreadSpec::QueueNameMatches (Thread &thread) const
-{
-    if (m_queue_name.empty())
-        return true;
-        
-    const char *queue_name = thread.GetQueueName();
-    return QueueNameMatches (queue_name);
-}
-
-bool
-ThreadSpec::ThreadPassesBasicTests (Thread &thread) const
-{
-    if (!HasSpecification())
-        return true;
-        
-    if (!TIDMatches(thread))
-        return false;
-        
-    if (!IndexMatches(thread))
-        return false;
-        
-    if (!NameMatches (thread))
-        return false;
-        
-    if (!QueueNameMatches (thread))
-        return false;
-        
+ThreadSpec::ThreadSpec()
+    : m_index(UINT32_MAX), m_tid(LLDB_INVALID_THREAD_ID), m_name(),
+      m_queue_name() {}
+
+ThreadSpec::ThreadSpec(const ThreadSpec &rhs)
+    : m_index(rhs.m_index), m_tid(rhs.m_tid), m_name(rhs.m_name),
+      m_queue_name(rhs.m_queue_name) {}
+
+const ThreadSpec &ThreadSpec::operator=(const ThreadSpec &rhs) {
+  m_index = rhs.m_index;
+  m_tid = rhs.m_tid;
+  m_name = rhs.m_name;
+  m_queue_name = rhs.m_queue_name;
+  return *this;
+}
+
+const char *ThreadSpec::GetName() const {
+  return m_name.empty() ? nullptr : m_name.c_str();
+}
+
+const char *ThreadSpec::GetQueueName() const {
+  return m_queue_name.empty() ? nullptr : m_queue_name.c_str();
+}
+
+bool ThreadSpec::TIDMatches(Thread &thread) const {
+  if (m_tid == LLDB_INVALID_THREAD_ID)
     return true;
+
+  lldb::tid_t thread_id = thread.GetID();
+  return TIDMatches(thread_id);
 }
 
-bool
-ThreadSpec::HasSpecification() const
-{
-    return (m_index != UINT32_MAX || m_tid != LLDB_INVALID_THREAD_ID || !m_name.empty() || !m_queue_name.empty());
+bool ThreadSpec::IndexMatches(Thread &thread) const {
+  if (m_index == UINT32_MAX)
+    return true;
+  uint32_t index = thread.GetIndexID();
+  return IndexMatches(index);
 }
 
-void
-ThreadSpec::GetDescription (Stream *s, lldb::DescriptionLevel level) const
-{
-    if (!HasSpecification())
-    {
-        if (level == eDescriptionLevelBrief)
-        {
-            s->PutCString("thread spec: no ");
-        }
-    }
-    else
-    {
-        if (level == eDescriptionLevelBrief)
-        {
-            s->PutCString("thread spec: yes ");
-        }
-        else
-        {
-            if (GetTID() != LLDB_INVALID_THREAD_ID)
-                s->Printf("tid: 0x%" PRIx64 " ", GetTID());
-                
-            if (GetIndex() != UINT32_MAX)
-                s->Printf("index: %d ", GetIndex());
-                
-            const char *name = GetName();
-            if (name)
-                s->Printf ("thread name: \"%s\" ", name);
-                
-            const char *queue_name = GetQueueName();
-            if (queue_name)
-                s->Printf ("queue name: \"%s\" ", queue_name);
-        }
+bool ThreadSpec::NameMatches(Thread &thread) const {
+  if (m_name.empty())
+    return true;
 
+  const char *name = thread.GetName();
+  return NameMatches(name);
+}
+
+bool ThreadSpec::QueueNameMatches(Thread &thread) const {
+  if (m_queue_name.empty())
+    return true;
+
+  const char *queue_name = thread.GetQueueName();
+  return QueueNameMatches(queue_name);
+}
+
+bool ThreadSpec::ThreadPassesBasicTests(Thread &thread) const {
+  if (!HasSpecification())
+    return true;
+
+  if (!TIDMatches(thread))
+    return false;
+
+  if (!IndexMatches(thread))
+    return false;
+
+  if (!NameMatches(thread))
+    return false;
+
+  if (!QueueNameMatches(thread))
+    return false;
+
+  return true;
+}
+
+bool 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 {
+  if (!HasSpecification()) {
+    if (level == eDescriptionLevelBrief) {
+      s->PutCString("thread spec: no ");
+    }
+  } else {
+    if (level == eDescriptionLevelBrief) {
+      s->PutCString("thread spec: yes ");
+    } else {
+      if (GetTID() != LLDB_INVALID_THREAD_ID)
+        s->Printf("tid: 0x%" PRIx64 " ", GetTID());
+
+      if (GetIndex() != UINT32_MAX)
+        s->Printf("index: %d ", GetIndex());
+
+      const char *name = GetName();
+      if (name)
+        s->Printf("thread name: \"%s\" ", name);
+
+      const char *queue_name = GetQueueName();
+      if (queue_name)
+        s->Printf("queue name: \"%s\" ", queue_name);
     }
+  }
 }

Modified: lldb/trunk/source/Target/UnixSignals.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/UnixSignals.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Target/UnixSignals.cpp (original)
+++ lldb/trunk/source/Target/UnixSignals.cpp Tue Sep  6 15:57:50 2016
@@ -7,340 +7,280 @@
 //
 //===----------------------------------------------------------------------===//
 
-
 // C Includes
 // C++ Includes
 // Other libraries and framework includes
 // Project includes
 #include "lldb/Target/UnixSignals.h"
-#include "lldb/Core/ArchSpec.h"
-#include "lldb/Host/StringConvert.h"
 #include "Plugins/Process/Utility/FreeBSDSignals.h"
 #include "Plugins/Process/Utility/LinuxSignals.h"
 #include "Plugins/Process/Utility/MipsLinuxSignals.h"
 #include "Plugins/Process/Utility/NetBSDSignals.h"
+#include "lldb/Core/ArchSpec.h"
+#include "lldb/Host/StringConvert.h"
 
 using namespace lldb_private;
 
-UnixSignals::Signal::Signal(const char *name,
-                            bool default_suppress,
-                            bool default_stop,
-                            bool default_notify,
-                            const char *description,
-                            const char *alias) :
-    m_name (name),
-    m_alias (alias),
-    m_description (),
-    m_suppress (default_suppress),
-    m_stop (default_stop),
-    m_notify (default_notify)
-{
-    if (description)
-        m_description.assign (description);
-}
-
-lldb::UnixSignalsSP
-UnixSignals::Create(const ArchSpec &arch)
-{
-    const auto &triple = arch.GetTriple();
-    switch (triple.getOS())
-    {
-        case llvm::Triple::Linux:
-        {
-            switch (triple.getArch())
-            {
-                case llvm::Triple::mips:
-                case llvm::Triple::mipsel:
-                case llvm::Triple::mips64:
-                case llvm::Triple::mips64el:
-                    return std::make_shared<MipsLinuxSignals>();
-                default:
-                    return std::make_shared<LinuxSignals>();
-            }
-        }
-        case llvm::Triple::FreeBSD:
-        case llvm::Triple::OpenBSD:
-            return std::make_shared<FreeBSDSignals>();
-        case llvm::Triple::NetBSD:
-            return std::make_shared<NetBSDSignals>();
-        default:
-            return std::make_shared<UnixSignals>();
+UnixSignals::Signal::Signal(const char *name, bool default_suppress,
+                            bool default_stop, bool default_notify,
+                            const char *description, const char *alias)
+    : m_name(name), m_alias(alias), m_description(),
+      m_suppress(default_suppress), m_stop(default_stop),
+      m_notify(default_notify) {
+  if (description)
+    m_description.assign(description);
+}
+
+lldb::UnixSignalsSP UnixSignals::Create(const ArchSpec &arch) {
+  const auto &triple = arch.GetTriple();
+  switch (triple.getOS()) {
+  case llvm::Triple::Linux: {
+    switch (triple.getArch()) {
+    case llvm::Triple::mips:
+    case llvm::Triple::mipsel:
+    case llvm::Triple::mips64:
+    case llvm::Triple::mips64el:
+      return std::make_shared<MipsLinuxSignals>();
+    default:
+      return std::make_shared<LinuxSignals>();
     }
+  }
+  case llvm::Triple::FreeBSD:
+  case llvm::Triple::OpenBSD:
+    return std::make_shared<FreeBSDSignals>();
+  case llvm::Triple::NetBSD:
+    return std::make_shared<NetBSDSignals>();
+  default:
+    return std::make_shared<UnixSignals>();
+  }
 }
 
 //----------------------------------------------------------------------
 // UnixSignals constructor
 //----------------------------------------------------------------------
-UnixSignals::UnixSignals ()
-{
-    Reset ();
-}
+UnixSignals::UnixSignals() { Reset(); }
 
-UnixSignals::UnixSignals(const UnixSignals &rhs)
-    : m_signals(rhs.m_signals)
-{
-}
+UnixSignals::UnixSignals(const UnixSignals &rhs) : m_signals(rhs.m_signals) {}
 
 UnixSignals::~UnixSignals() = default;
 
-void
-UnixSignals::Reset ()
-{
-    // This builds one standard set of Unix Signals.  If yours aren't quite in this
-    // 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;
-    //
-    // Note: the signals below are the Darwin signals.  Do not change these!
-    m_signals.clear();
-    //        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
-UnixSignals::AddSignal(int signo,
-                       const char *name,
-                       bool default_suppress,
-                       bool default_stop,
-                       bool default_notify,
-                       const char *description,
-                       const char *alias)
-{
-    Signal new_signal (name, default_suppress, default_stop, default_notify, description, alias);
-    m_signals.insert (std::make_pair(signo, new_signal));
-}
-
-void
-UnixSignals::RemoveSignal (int signo)
-{
-    collection::iterator pos = m_signals.find (signo);
-    if (pos != m_signals.end())
-        m_signals.erase (pos);
-}
-
-const char *
-UnixSignals::GetSignalAsCString (int signo) const
-{
-    collection::const_iterator pos = m_signals.find (signo);
-    if (pos == m_signals.end())
-        return nullptr;
-    else
-        return pos->second.m_name.GetCString ();
-}
-
-bool
-UnixSignals::SignalIsValid (int32_t signo) const
-{
-    return m_signals.find (signo) != m_signals.end();
-}
-
-ConstString
-UnixSignals::GetShortName(ConstString name) const
-{
-    if (name)
-    {
-      const char* signame = name.AsCString();
-      return ConstString(signame + 3); // Remove "SIG" from name
-    }
-    return name;
+void UnixSignals::Reset() {
+  // This builds one standard set of Unix Signals.  If yours aren't quite in
+  // this
+  // 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;
+  //
+  // Note: the signals below are the Darwin signals.  Do not change these!
+  m_signals.clear();
+  //        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 UnixSignals::AddSignal(int signo, const char *name, bool default_suppress,
+                            bool default_stop, bool default_notify,
+                            const char *description, const char *alias) {
+  Signal new_signal(name, default_suppress, default_stop, default_notify,
+                    description, alias);
+  m_signals.insert(std::make_pair(signo, new_signal));
+}
+
+void UnixSignals::RemoveSignal(int signo) {
+  collection::iterator pos = m_signals.find(signo);
+  if (pos != m_signals.end())
+    m_signals.erase(pos);
+}
+
+const char *UnixSignals::GetSignalAsCString(int signo) const {
+  collection::const_iterator pos = m_signals.find(signo);
+  if (pos == m_signals.end())
+    return nullptr;
+  else
+    return pos->second.m_name.GetCString();
+}
+
+bool UnixSignals::SignalIsValid(int32_t signo) const {
+  return m_signals.find(signo) != m_signals.end();
+}
+
+ConstString UnixSignals::GetShortName(ConstString name) const {
+  if (name) {
+    const char *signame = name.AsCString();
+    return ConstString(signame + 3); // Remove "SIG" from name
+  }
+  return name;
+}
+
+int32_t UnixSignals::GetSignalNumberFromName(const char *name) const {
+  ConstString const_name(name);
+
+  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_alias) ||
+        (const_name == GetShortName(pos->second.m_name)) ||
+        (const_name == GetShortName(pos->second.m_alias)))
+      return pos->first;
+  }
+
+  const int32_t signo =
+      StringConvert::ToSInt32(name, LLDB_INVALID_SIGNAL_NUMBER, 0);
+  if (signo != LLDB_INVALID_SIGNAL_NUMBER)
+    return signo;
+  return LLDB_INVALID_SIGNAL_NUMBER;
 }
 
-int32_t
-UnixSignals::GetSignalNumberFromName (const char *name) const
-{
-    ConstString const_name (name);
-
-    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_alias) ||
-            (const_name == GetShortName(pos->second.m_name)) || (const_name == GetShortName(pos->second.m_alias)))
-            return pos->first;
-    }
-    
-    const int32_t signo = StringConvert::ToSInt32(name, LLDB_INVALID_SIGNAL_NUMBER, 0);
-    if (signo != LLDB_INVALID_SIGNAL_NUMBER)
-        return signo;
+int32_t UnixSignals::GetFirstSignalNumber() const {
+  if (m_signals.empty())
     return LLDB_INVALID_SIGNAL_NUMBER;
-}
 
-int32_t
-UnixSignals::GetFirstSignalNumber () const
-{
-    if (m_signals.empty())
-        return LLDB_INVALID_SIGNAL_NUMBER;
-
-    return (*m_signals.begin ()).first;
+  return (*m_signals.begin()).first;
 }
 
-int32_t
-UnixSignals::GetNextSignalNumber (int32_t current_signal) const
-{
-    collection::const_iterator pos = m_signals.find (current_signal);
-    collection::const_iterator end = m_signals.end();
+int32_t UnixSignals::GetNextSignalNumber(int32_t current_signal) const {
+  collection::const_iterator pos = m_signals.find(current_signal);
+  collection::const_iterator end = m_signals.end();
+  if (pos == end)
+    return LLDB_INVALID_SIGNAL_NUMBER;
+  else {
+    pos++;
     if (pos == end)
-        return LLDB_INVALID_SIGNAL_NUMBER;
+      return LLDB_INVALID_SIGNAL_NUMBER;
     else
-    {
-        pos++;
-        if (pos == end)
-            return LLDB_INVALID_SIGNAL_NUMBER;
-        else
-            return pos->first;
-    }
+      return pos->first;
+  }
 }
 
-const char *
-UnixSignals::GetSignalInfo(int32_t signo,
-                           bool &should_suppress,
-                           bool &should_stop,
-                           bool &should_notify) const
-{
-    collection::const_iterator pos = m_signals.find (signo);
-    if (pos == m_signals.end())
-        return nullptr;
-    else
-    {
-        const Signal &signal = pos->second;
-        should_suppress = signal.m_suppress;
-        should_stop     = signal.m_stop;
-        should_notify   = signal.m_notify;
-        return signal.m_name.AsCString("");
-    }
+const char *UnixSignals::GetSignalInfo(int32_t signo, bool &should_suppress,
+                                       bool &should_stop,
+                                       bool &should_notify) const {
+  collection::const_iterator pos = m_signals.find(signo);
+  if (pos == m_signals.end())
+    return nullptr;
+  else {
+    const Signal &signal = pos->second;
+    should_suppress = signal.m_suppress;
+    should_stop = signal.m_stop;
+    should_notify = signal.m_notify;
+    return signal.m_name.AsCString("");
+  }
+}
+
+bool UnixSignals::GetShouldSuppress(int signo) const {
+  collection::const_iterator pos = m_signals.find(signo);
+  if (pos != m_signals.end())
+    return pos->second.m_suppress;
+  return false;
+}
+
+bool UnixSignals::SetShouldSuppress(int signo, bool value) {
+  collection::iterator pos = m_signals.find(signo);
+  if (pos != m_signals.end()) {
+    pos->second.m_suppress = value;
+    return true;
+  }
+  return false;
+}
+
+bool UnixSignals::SetShouldSuppress(const char *signal_name, bool value) {
+  const int32_t signo = GetSignalNumberFromName(signal_name);
+  if (signo != LLDB_INVALID_SIGNAL_NUMBER)
+    return SetShouldSuppress(signo, value);
+  return false;
+}
+
+bool UnixSignals::GetShouldStop(int signo) const {
+  collection::const_iterator pos = m_signals.find(signo);
+  if (pos != m_signals.end())
+    return pos->second.m_stop;
+  return false;
+}
+
+bool UnixSignals::SetShouldStop(int signo, bool value) {
+  collection::iterator pos = m_signals.find(signo);
+  if (pos != m_signals.end()) {
+    pos->second.m_stop = value;
+    return true;
+  }
+  return false;
+}
+
+bool UnixSignals::SetShouldStop(const char *signal_name, bool value) {
+  const int32_t signo = GetSignalNumberFromName(signal_name);
+  if (signo != LLDB_INVALID_SIGNAL_NUMBER)
+    return SetShouldStop(signo, value);
+  return false;
+}
+
+bool UnixSignals::GetShouldNotify(int signo) const {
+  collection::const_iterator pos = m_signals.find(signo);
+  if (pos != m_signals.end())
+    return pos->second.m_notify;
+  return false;
+}
+
+bool UnixSignals::SetShouldNotify(int signo, bool value) {
+  collection::iterator pos = m_signals.find(signo);
+  if (pos != m_signals.end()) {
+    pos->second.m_notify = value;
+    return true;
+  }
+  return false;
+}
+
+bool UnixSignals::SetShouldNotify(const char *signal_name, bool value) {
+  const int32_t signo = GetSignalNumberFromName(signal_name);
+  if (signo != LLDB_INVALID_SIGNAL_NUMBER)
+    return SetShouldNotify(signo, value);
+  return false;
 }
 
-bool
-UnixSignals::GetShouldSuppress (int signo) const
-{
-    collection::const_iterator pos = m_signals.find (signo);
-    if (pos != m_signals.end())
-        return pos->second.m_suppress;
-    return false;
-}
-
-bool
-UnixSignals::SetShouldSuppress (int signo, bool value)
-{
-    collection::iterator pos = m_signals.find (signo);
-    if (pos != m_signals.end())
-    {
-        pos->second.m_suppress = value;
-        return true;
-    }
-    return false;
-}
+int32_t UnixSignals::GetNumSignals() const { return m_signals.size(); }
 
-bool
-UnixSignals::SetShouldSuppress (const char *signal_name, bool value)
-{
-    const int32_t signo = GetSignalNumberFromName (signal_name);
-    if (signo != LLDB_INVALID_SIGNAL_NUMBER)
-        return SetShouldSuppress (signo, value);
-    return false;
-}
-
-bool
-UnixSignals::GetShouldStop (int signo) const
-{
-    collection::const_iterator pos = m_signals.find (signo);
-    if (pos != m_signals.end())
-        return pos->second.m_stop;
-    return false;
-}
-
-bool
-UnixSignals::SetShouldStop (int signo, bool value)
-{
-    collection::iterator pos = m_signals.find (signo);
-    if (pos != m_signals.end())
-    {
-        pos->second.m_stop = value;
-        return true;
-    }
-    return false;
-}
-
-bool
-UnixSignals::SetShouldStop (const char *signal_name, bool value)
-{
-    const int32_t signo = GetSignalNumberFromName (signal_name);
-    if (signo != LLDB_INVALID_SIGNAL_NUMBER)
-        return SetShouldStop (signo, value);
-    return false;
-}
-
-bool
-UnixSignals::GetShouldNotify (int signo) const
-{
-    collection::const_iterator pos = m_signals.find (signo);
-    if (pos != m_signals.end())
-        return pos->second.m_notify;
-    return false;
-}
-
-bool
-UnixSignals::SetShouldNotify (int signo, bool value)
-{
-    collection::iterator pos = m_signals.find (signo);
-    if (pos != m_signals.end())
-    {
-        pos->second.m_notify = value;
-        return true;
-    }
-    return false;
-}
-
-bool
-UnixSignals::SetShouldNotify (const char *signal_name, bool value)
-{
-    const int32_t signo = GetSignalNumberFromName (signal_name);
-    if (signo != LLDB_INVALID_SIGNAL_NUMBER)
-        return SetShouldNotify (signo, value);
-    return false;
-}
-
-int32_t
-UnixSignals::GetNumSignals() const
-{
-    return m_signals.size();
-}
-
-int32_t
-UnixSignals::GetSignalAtIndex(int32_t index) const
-{
-    if (index < 0 || m_signals.size() <= static_cast<size_t>(index))
-        return LLDB_INVALID_SIGNAL_NUMBER;
-    auto it = m_signals.begin();
-    std::advance(it, index);
-    return it->first;
+int32_t UnixSignals::GetSignalAtIndex(int32_t index) const {
+  if (index < 0 || m_signals.size() <= static_cast<size_t>(index))
+    return LLDB_INVALID_SIGNAL_NUMBER;
+  auto it = m_signals.begin();
+  std::advance(it, index);
+  return it->first;
 }

Modified: lldb/trunk/source/Target/UnwindAssembly.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/UnwindAssembly.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Target/UnwindAssembly.cpp (original)
+++ lldb/trunk/source/Target/UnwindAssembly.cpp Tue Sep  6 15:57:50 2016
@@ -11,33 +11,28 @@
 // C++ Includes
 // Other libraries and framework includes
 // Project includes
-#include "lldb/lldb-private.h"
-#include "lldb/Core/PluginManager.h"
-#include "lldb/Core/PluginInterface.h"
 #include "lldb/Target/UnwindAssembly.h"
+#include "lldb/Core/PluginInterface.h"
+#include "lldb/Core/PluginManager.h"
+#include "lldb/lldb-private.h"
 
 using namespace lldb;
 using namespace lldb_private;
 
-UnwindAssemblySP
-UnwindAssembly::FindPlugin (const ArchSpec &arch)
-{
-    UnwindAssemblyCreateInstance create_callback;
+UnwindAssemblySP UnwindAssembly::FindPlugin(const ArchSpec &arch) {
+  UnwindAssemblyCreateInstance create_callback;
 
-    for (uint32_t idx = 0;
-         (create_callback = PluginManager::GetUnwindAssemblyCreateCallbackAtIndex(idx)) != nullptr;
-         ++idx)
-    {
-        UnwindAssemblySP assembly_profiler_ap (create_callback (arch));
-        if (assembly_profiler_ap)
-            return assembly_profiler_ap;
-    }
-    return nullptr;
+  for (uint32_t idx = 0;
+       (create_callback = PluginManager::GetUnwindAssemblyCreateCallbackAtIndex(
+            idx)) != nullptr;
+       ++idx) {
+    UnwindAssemblySP assembly_profiler_ap(create_callback(arch));
+    if (assembly_profiler_ap)
+      return assembly_profiler_ap;
+  }
+  return nullptr;
 }
 
-UnwindAssembly::UnwindAssembly (const ArchSpec &arch) :
-    m_arch (arch)
-{
-}
+UnwindAssembly::UnwindAssembly(const ArchSpec &arch) : m_arch(arch) {}
 
 UnwindAssembly::~UnwindAssembly() = default;

Modified: lldb/trunk/source/Utility/ARM64_DWARF_Registers.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/ARM64_DWARF_Registers.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Utility/ARM64_DWARF_Registers.cpp (original)
+++ lldb/trunk/source/Utility/ARM64_DWARF_Registers.cpp Tue Sep  6 15:57:50 2016
@@ -15,134 +15,198 @@ using namespace lldb;
 using namespace lldb_private;
 using namespace arm64_dwarf;
 
-const char *
-arm64_dwarf::GetRegisterName (unsigned reg_num, bool altnernate_name)
-{
-    if (altnernate_name)
-    {
-        switch (reg_num)
-        {
-            case fp: return "x29"; 
-            case lr: return "x30"; 
-            case sp: return "x31"; 
-            default:
-                break;
-        }
-        return nullptr;
-    }
-    
-    switch (reg_num)
-    {
-        case x0:       return "x0";
-        case x1:       return "x1";
-        case x2:       return "x2";
-        case x3:       return "x3";
-        case x4:       return "x4";
-        case x5:       return "x5";
-        case x6:       return "x6";
-        case x7:       return "x7";
-        case x8:       return "x8";
-        case x9:       return "x9";
-        case x10:      return "x10";
-        case x11:      return "x11";
-        case x12:      return "x12";
-        case x13:      return "x13";
-        case x14:      return "x14";
-        case x15:      return "x15";
-        case x16:      return "x16";
-        case x17:      return "x17";
-        case x18:      return "x18";
-        case x19:      return "x19";
-        case x20:      return "x20";
-        case x21:      return "x21";
-        case x22:      return "x22";
-        case x23:      return "x23";
-        case x24:      return "x24";
-        case x25:      return "x25";
-        case x26:      return "x26";
-        case x27:      return "x27";
-        case x28:      return "x28";
-        case fp:       return "fp";
-        case lr:       return "lr";
-        case sp:       return "sp";
-        case pc:       return "pc";
-        case cpsr:     return "cpsr";
-        case v0:       return "v0";
-        case v1:       return "v1";
-        case v2:       return "v2";
-        case v3:       return "v3";
-        case v4:       return "v4";
-        case v5:       return "v5";
-        case v6:       return "v6";
-        case v7:       return "v7";
-        case v8:       return "v8";
-        case v9:       return "v9";
-        case v10:      return "v10";
-        case v11:      return "v11";
-        case v12:      return "v12";
-        case v13:      return "v13";
-        case v14:      return "v14";
-        case v15:      return "v15";
-        case v16:      return "v16";
-        case v17:      return "v17";
-        case v18:      return "v18";
-        case v19:      return "v19";
-        case v20:      return "v20";
-        case v21:      return "v21";
-        case v22:      return "v22";
-        case v23:      return "v23";
-        case v24:      return "v24";
-        case v25:      return "v25";
-        case v26:      return "v26";
-        case v27:      return "v27";
-        case v28:      return "v28";
-        case v29:      return "v29";
-        case v30:      return "v30";
-        case v31:      return "v31";
+const char *arm64_dwarf::GetRegisterName(unsigned reg_num,
+                                         bool altnernate_name) {
+  if (altnernate_name) {
+    switch (reg_num) {
+    case fp:
+      return "x29";
+    case lr:
+      return "x30";
+    case sp:
+      return "x31";
+    default:
+      break;
     }
     return nullptr;
+  }
+
+  switch (reg_num) {
+  case x0:
+    return "x0";
+  case x1:
+    return "x1";
+  case x2:
+    return "x2";
+  case x3:
+    return "x3";
+  case x4:
+    return "x4";
+  case x5:
+    return "x5";
+  case x6:
+    return "x6";
+  case x7:
+    return "x7";
+  case x8:
+    return "x8";
+  case x9:
+    return "x9";
+  case x10:
+    return "x10";
+  case x11:
+    return "x11";
+  case x12:
+    return "x12";
+  case x13:
+    return "x13";
+  case x14:
+    return "x14";
+  case x15:
+    return "x15";
+  case x16:
+    return "x16";
+  case x17:
+    return "x17";
+  case x18:
+    return "x18";
+  case x19:
+    return "x19";
+  case x20:
+    return "x20";
+  case x21:
+    return "x21";
+  case x22:
+    return "x22";
+  case x23:
+    return "x23";
+  case x24:
+    return "x24";
+  case x25:
+    return "x25";
+  case x26:
+    return "x26";
+  case x27:
+    return "x27";
+  case x28:
+    return "x28";
+  case fp:
+    return "fp";
+  case lr:
+    return "lr";
+  case sp:
+    return "sp";
+  case pc:
+    return "pc";
+  case cpsr:
+    return "cpsr";
+  case v0:
+    return "v0";
+  case v1:
+    return "v1";
+  case v2:
+    return "v2";
+  case v3:
+    return "v3";
+  case v4:
+    return "v4";
+  case v5:
+    return "v5";
+  case v6:
+    return "v6";
+  case v7:
+    return "v7";
+  case v8:
+    return "v8";
+  case v9:
+    return "v9";
+  case v10:
+    return "v10";
+  case v11:
+    return "v11";
+  case v12:
+    return "v12";
+  case v13:
+    return "v13";
+  case v14:
+    return "v14";
+  case v15:
+    return "v15";
+  case v16:
+    return "v16";
+  case v17:
+    return "v17";
+  case v18:
+    return "v18";
+  case v19:
+    return "v19";
+  case v20:
+    return "v20";
+  case v21:
+    return "v21";
+  case v22:
+    return "v22";
+  case v23:
+    return "v23";
+  case v24:
+    return "v24";
+  case v25:
+    return "v25";
+  case v26:
+    return "v26";
+  case v27:
+    return "v27";
+  case v28:
+    return "v28";
+  case v29:
+    return "v29";
+  case v30:
+    return "v30";
+  case v31:
+    return "v31";
+  }
+  return nullptr;
 }
 
-bool
-arm64_dwarf::GetRegisterInfo (unsigned reg_num, RegisterInfo &reg_info)
-{
-    ::memset (&reg_info, 0, sizeof(RegisterInfo));
-    ::memset (reg_info.kinds, LLDB_INVALID_REGNUM, sizeof(reg_info.kinds));
-    
-    if (reg_num >= x0 && reg_num <= pc)
-    {
-        reg_info.byte_size = 8;
-        reg_info.format = eFormatHex;
-        reg_info.encoding = eEncodingUint;
-    }
-    else if (reg_num >= v0 && reg_num <= v31)
-    {
-        reg_info.byte_size = 16;
-        reg_info.format = eFormatVectorOfFloat32;
-        reg_info.encoding = eEncodingVector;
-    }
-    else if (reg_num == cpsr)
-    {
-        reg_info.byte_size = 4;
-        reg_info.format = eFormatHex;
-        reg_info.encoding = eEncodingUint;
-    }
-    else
-    {
-        return false;
-    }
-    
-    reg_info.name = arm64_dwarf::GetRegisterName (reg_num, false);
-    reg_info.alt_name = arm64_dwarf::GetRegisterName (reg_num, true);
-    reg_info.kinds[eRegisterKindDWARF] = reg_num;
-
-    switch (reg_num)
-    {            
-    case fp: reg_info.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_FP; break;
-    case lr: reg_info.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_RA; break;
-    case sp: reg_info.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_SP; break;
-    case pc: reg_info.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_PC; break;
-    default: break;
-    }
-    return true;
+bool arm64_dwarf::GetRegisterInfo(unsigned reg_num, RegisterInfo &reg_info) {
+  ::memset(&reg_info, 0, sizeof(RegisterInfo));
+  ::memset(reg_info.kinds, LLDB_INVALID_REGNUM, sizeof(reg_info.kinds));
+
+  if (reg_num >= x0 && reg_num <= pc) {
+    reg_info.byte_size = 8;
+    reg_info.format = eFormatHex;
+    reg_info.encoding = eEncodingUint;
+  } else if (reg_num >= v0 && reg_num <= v31) {
+    reg_info.byte_size = 16;
+    reg_info.format = eFormatVectorOfFloat32;
+    reg_info.encoding = eEncodingVector;
+  } else if (reg_num == cpsr) {
+    reg_info.byte_size = 4;
+    reg_info.format = eFormatHex;
+    reg_info.encoding = eEncodingUint;
+  } else {
+    return false;
+  }
+
+  reg_info.name = arm64_dwarf::GetRegisterName(reg_num, false);
+  reg_info.alt_name = arm64_dwarf::GetRegisterName(reg_num, true);
+  reg_info.kinds[eRegisterKindDWARF] = reg_num;
+
+  switch (reg_num) {
+  case fp:
+    reg_info.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_FP;
+    break;
+  case lr:
+    reg_info.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_RA;
+    break;
+  case sp:
+    reg_info.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_SP;
+    break;
+  case pc:
+    reg_info.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_PC;
+    break;
+  default:
+    break;
+  }
+  return true;
 }

Modified: lldb/trunk/source/Utility/ARM64_DWARF_Registers.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/ARM64_DWARF_Registers.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Utility/ARM64_DWARF_Registers.h (original)
+++ lldb/trunk/source/Utility/ARM64_DWARF_Registers.h Tue Sep  6 15:57:50 2016
@@ -13,90 +13,88 @@
 #include "lldb/lldb-private.h"
 
 namespace arm64_dwarf {
-    
-enum
-{
-    x0 = 0,
-    x1,
-    x2,
-    x3,
-    x4,
-    x5,
-    x6,
-    x7,
-    x8,
-    x9,
-    x10,
-    x11,
-    x12,
-    x13,
-    x14,
-    x15,
-    x16,
-    x17,
-    x18,
-    x19,
-    x20,
-    x21,
-    x22,
-    x23,
-    x24,
-    x25,
-    x26,
-    x27,
-    x28,
-    x29       = 29,   fp = x29,
-    x30       = 30,   lr = x30,
-    x31       = 31,   sp = x31,
-    pc        = 32,
-    cpsr  = 33,
-    // 34-63 reserved
-
-    // V0-V31 (128 bit vector registers)
-    v0        = 64,
-    v1,
-    v2,
-    v3,
-    v4,
-    v5,
-    v6,
-    v7,
-    v8,
-    v9,
-    v10,
-    v11,
-    v12,
-    v13,
-    v14,
-    v15,
-    v16,
-    v17,
-    v18,
-    v19,
-    v20,
-    v21,
-    v22,
-    v23,
-    v24,
-    v25,
-    v26,
-    v27,
-    v28,
-    v29,
-    v30,
-    v31
 
-    // 96-127 reserved
+enum {
+  x0 = 0,
+  x1,
+  x2,
+  x3,
+  x4,
+  x5,
+  x6,
+  x7,
+  x8,
+  x9,
+  x10,
+  x11,
+  x12,
+  x13,
+  x14,
+  x15,
+  x16,
+  x17,
+  x18,
+  x19,
+  x20,
+  x21,
+  x22,
+  x23,
+  x24,
+  x25,
+  x26,
+  x27,
+  x28,
+  x29 = 29,
+  fp = x29,
+  x30 = 30,
+  lr = x30,
+  x31 = 31,
+  sp = x31,
+  pc = 32,
+  cpsr = 33,
+  // 34-63 reserved
+
+  // V0-V31 (128 bit vector registers)
+  v0 = 64,
+  v1,
+  v2,
+  v3,
+  v4,
+  v5,
+  v6,
+  v7,
+  v8,
+  v9,
+  v10,
+  v11,
+  v12,
+  v13,
+  v14,
+  v15,
+  v16,
+  v17,
+  v18,
+  v19,
+  v20,
+  v21,
+  v22,
+  v23,
+  v24,
+  v25,
+  v26,
+  v27,
+  v28,
+  v29,
+  v30,
+  v31
+
+  // 96-127 reserved
 };
 
-const char *
-GetRegisterName (unsigned reg_num, bool altnernate_name);
-    
-bool
-GetRegisterInfo (unsigned reg_num, 
-                 lldb_private::RegisterInfo &reg_info);
+const char *GetRegisterName(unsigned reg_num, bool altnernate_name);
 
-}   // namespace arm64_dwarf
+bool GetRegisterInfo(unsigned reg_num, lldb_private::RegisterInfo &reg_info);
 
-#endif // utility_ARM64_DWARF_Registers_h_
+} // namespace arm64_dwarf
 
+#endif // utility_ARM64_DWARF_Registers_h_

Modified: lldb/trunk/source/Utility/ARM64_ehframe_Registers.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/ARM64_ehframe_Registers.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Utility/ARM64_ehframe_Registers.h (original)
+++ lldb/trunk/source/Utility/ARM64_ehframe_Registers.h Tue Sep  6 15:57:50 2016
@@ -1,4 +1,5 @@
-//===-- ARM64_ehframe_Registers.h -------------------------------------*- C++ -*-===//
+//===-- ARM64_ehframe_Registers.h -------------------------------------*- C++
+//-*-===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -14,82 +15,78 @@
 // Should be the same as DWARF register numbers.
 
 namespace arm64_ehframe {
-    
-enum
-{
-    x0 = 0,
-    x1,
-    x2,
-    x3,
-    x4,
-    x5,
-    x6,
-    x7,
-    x8,
-    x9,
-    x10,
-    x11,
-    x12,
-    x13,
-    x14,
-    x15,
-    x16,
-    x17,
-    x18,
-    x19,
-    x20,
-    x21,
-    x22,
-    x23,
-    x24,
-    x25,
-    x26,
-    x27,
-    x28,
-    fp,       // aka x29
-    lr,       // aka x30
-    sp,       // aka x31 aka wzr
-    pc,       // value is 32
-    cpsr
-};
 
-enum
-{
-    v0 = 64,
-    v1,
-    v2,
-    v3,
-    v4,
-    v5,
-    v6,
-    v7,
-    v8,
-    v9,
-    v10,
-    v11,
-    v12,
-    v13,
-    v14,
-    v15,
-    v16,
-    v17,
-    v18,
-    v19,
-    v20,
-    v21,
-    v22,
-    v23,
-    v24,
-    v25,
-    v26,
-    v27,
-    v28,
-    v29,
-    v30,
-    v31  // 95
+enum {
+  x0 = 0,
+  x1,
+  x2,
+  x3,
+  x4,
+  x5,
+  x6,
+  x7,
+  x8,
+  x9,
+  x10,
+  x11,
+  x12,
+  x13,
+  x14,
+  x15,
+  x16,
+  x17,
+  x18,
+  x19,
+  x20,
+  x21,
+  x22,
+  x23,
+  x24,
+  x25,
+  x26,
+  x27,
+  x28,
+  fp, // aka x29
+  lr, // aka x30
+  sp, // aka x31 aka wzr
+  pc, // value is 32
+  cpsr
 };
 
+enum {
+  v0 = 64,
+  v1,
+  v2,
+  v3,
+  v4,
+  v5,
+  v6,
+  v7,
+  v8,
+  v9,
+  v10,
+  v11,
+  v12,
+  v13,
+  v14,
+  v15,
+  v16,
+  v17,
+  v18,
+  v19,
+  v20,
+  v21,
+  v22,
+  v23,
+  v24,
+  v25,
+  v26,
+  v27,
+  v28,
+  v29,
+  v30,
+  v31 // 95
+};
 }
 
 #endif // utility_ARM64_ehframe_Registers_h_
-




More information about the lldb-commits mailing list