180814287SRaphael Isemann //===-- SBThreadPlan.cpp --------------------------------------------------===// 22bdbfd50SJim Ingham // 32946cd70SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 42946cd70SChandler Carruth // See https://llvm.org/LICENSE.txt for license information. 52946cd70SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 62bdbfd50SJim Ingham // 72bdbfd50SJim Ingham //===----------------------------------------------------------------------===// 82bdbfd50SJim Ingham 9baf5664fSJonas Devlieghere #include "SBReproducerPrivate.h" 102bdbfd50SJim Ingham #include "lldb/API/SBThread.h" 112bdbfd50SJim Ingham 122bdbfd50SJim Ingham #include "lldb/API/SBFileSpec.h" 132bdbfd50SJim Ingham #include "lldb/API/SBStream.h" 1427a14f19SJim Ingham #include "lldb/API/SBStructuredData.h" 15b9c1b51eSKate Stone #include "lldb/API/SBSymbolContext.h" 162bdbfd50SJim Ingham #include "lldb/Breakpoint/BreakpointLocation.h" 172bdbfd50SJim Ingham #include "lldb/Core/Debugger.h" 182bdbfd50SJim Ingham #include "lldb/Core/StreamFile.h" 1927a14f19SJim Ingham #include "lldb/Core/StructuredDataImpl.h" 202bdbfd50SJim Ingham #include "lldb/Interpreter/CommandInterpreter.h" 21b9c1b51eSKate Stone #include "lldb/Symbol/CompileUnit.h" 22b9c1b51eSKate Stone #include "lldb/Symbol/SymbolContext.h" 232bdbfd50SJim Ingham #include "lldb/Target/Process.h" 242bdbfd50SJim Ingham #include "lldb/Target/Queue.h" 252bdbfd50SJim Ingham #include "lldb/Target/StopInfo.h" 26b9c1b51eSKate Stone #include "lldb/Target/SystemRuntime.h" 272bdbfd50SJim Ingham #include "lldb/Target/Target.h" 28b9c1b51eSKate Stone #include "lldb/Target/Thread.h" 29b9c1b51eSKate Stone #include "lldb/Target/ThreadPlan.h" 302bdbfd50SJim Ingham #include "lldb/Target/ThreadPlanPython.h" 31b9c1b51eSKate Stone #include "lldb/Target/ThreadPlanStepInRange.h" 322bdbfd50SJim Ingham #include "lldb/Target/ThreadPlanStepInstruction.h" 332bdbfd50SJim Ingham #include "lldb/Target/ThreadPlanStepOut.h" 342bdbfd50SJim Ingham #include "lldb/Target/ThreadPlanStepRange.h" 35d821c997SPavel Labath #include "lldb/Utility/State.h" 36bf9a7730SZachary Turner #include "lldb/Utility/Stream.h" 37f2a8bccfSPavel Labath #include "lldb/Utility/StructuredData.h" 382bdbfd50SJim Ingham 392bdbfd50SJim Ingham #include "lldb/API/SBAddress.h" 402bdbfd50SJim Ingham #include "lldb/API/SBDebugger.h" 412bdbfd50SJim Ingham #include "lldb/API/SBEvent.h" 422bdbfd50SJim Ingham #include "lldb/API/SBFrame.h" 432bdbfd50SJim Ingham #include "lldb/API/SBProcess.h" 442bdbfd50SJim Ingham #include "lldb/API/SBThreadPlan.h" 452bdbfd50SJim Ingham #include "lldb/API/SBValue.h" 462bdbfd50SJim Ingham 47796ac80bSJonas Devlieghere #include <memory> 48796ac80bSJonas Devlieghere 492bdbfd50SJim Ingham using namespace lldb; 502bdbfd50SJim Ingham using namespace lldb_private; 512bdbfd50SJim Ingham 522bdbfd50SJim Ingham // Constructors 53baf5664fSJonas Devlieghere SBThreadPlan::SBThreadPlan() { LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBThreadPlan); } 542bdbfd50SJim Ingham 55b9c1b51eSKate Stone SBThreadPlan::SBThreadPlan(const ThreadPlanSP &lldb_object_sp) 56baf5664fSJonas Devlieghere : m_opaque_sp(lldb_object_sp) { 57baf5664fSJonas Devlieghere LLDB_RECORD_CONSTRUCTOR(SBThreadPlan, (const lldb::ThreadPlanSP &), 58baf5664fSJonas Devlieghere lldb_object_sp); 59baf5664fSJonas Devlieghere } 602bdbfd50SJim Ingham 61b9c1b51eSKate Stone SBThreadPlan::SBThreadPlan(const SBThreadPlan &rhs) 62baf5664fSJonas Devlieghere : m_opaque_sp(rhs.m_opaque_sp) { 63baf5664fSJonas Devlieghere LLDB_RECORD_CONSTRUCTOR(SBThreadPlan, (const lldb::SBThreadPlan &), rhs); 64baf5664fSJonas Devlieghere } 652bdbfd50SJim Ingham 66b9c1b51eSKate Stone SBThreadPlan::SBThreadPlan(lldb::SBThread &sb_thread, const char *class_name) { 67baf5664fSJonas Devlieghere LLDB_RECORD_CONSTRUCTOR(SBThreadPlan, (lldb::SBThread &, const char *), 68baf5664fSJonas Devlieghere sb_thread, class_name); 69baf5664fSJonas Devlieghere 702bdbfd50SJim Ingham Thread *thread = sb_thread.get(); 712bdbfd50SJim Ingham if (thread) 7227a14f19SJim Ingham m_opaque_sp = std::make_shared<ThreadPlanPython>(*thread, class_name, 7327a14f19SJim Ingham nullptr); 7427a14f19SJim Ingham } 7527a14f19SJim Ingham 7627a14f19SJim Ingham SBThreadPlan::SBThreadPlan(lldb::SBThread &sb_thread, const char *class_name, 7727a14f19SJim Ingham lldb::SBStructuredData &args_data) { 7827a14f19SJim Ingham LLDB_RECORD_CONSTRUCTOR(SBThreadPlan, (lldb::SBThread &, const char *, 7927a14f19SJim Ingham SBStructuredData &), 8027a14f19SJim Ingham sb_thread, class_name, args_data); 8127a14f19SJim Ingham 8227a14f19SJim Ingham Thread *thread = sb_thread.get(); 8327a14f19SJim Ingham if (thread) 8427a14f19SJim Ingham m_opaque_sp = std::make_shared<ThreadPlanPython>(*thread, class_name, 8527a14f19SJim Ingham args_data.m_impl_up.get()); 862bdbfd50SJim Ingham } 872bdbfd50SJim Ingham 882bdbfd50SJim Ingham // Assignment operator 892bdbfd50SJim Ingham 90b9c1b51eSKate Stone const lldb::SBThreadPlan &SBThreadPlan::operator=(const SBThreadPlan &rhs) { 91baf5664fSJonas Devlieghere LLDB_RECORD_METHOD(const lldb::SBThreadPlan &, 92baf5664fSJonas Devlieghere SBThreadPlan, operator=,(const lldb::SBThreadPlan &), rhs); 93baf5664fSJonas Devlieghere 942bdbfd50SJim Ingham if (this != &rhs) 952bdbfd50SJim Ingham m_opaque_sp = rhs.m_opaque_sp; 96306809f2SJonas Devlieghere return LLDB_RECORD_RESULT(*this); 972bdbfd50SJim Ingham } 982bdbfd50SJim Ingham // Destructor 99*866b7a65SJonas Devlieghere SBThreadPlan::~SBThreadPlan() = default; 1002bdbfd50SJim Ingham 10126ca5a57SPavel Labath lldb_private::ThreadPlan *SBThreadPlan::get() { return m_opaque_sp.get(); } 1022bdbfd50SJim Ingham 103baf5664fSJonas Devlieghere bool SBThreadPlan::IsValid() const { 104baf5664fSJonas Devlieghere LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBThreadPlan, IsValid); 1057f5237bcSPavel Labath return this->operator bool(); 1067f5237bcSPavel Labath } 1077f5237bcSPavel Labath SBThreadPlan::operator bool() const { 1087f5237bcSPavel Labath LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBThreadPlan, operator bool); 1092bdbfd50SJim Ingham 110248a1305SKonrad Kleine return m_opaque_sp.get() != nullptr; 111baf5664fSJonas Devlieghere } 1122bdbfd50SJim Ingham 113baf5664fSJonas Devlieghere void SBThreadPlan::Clear() { 114baf5664fSJonas Devlieghere LLDB_RECORD_METHOD_NO_ARGS(void, SBThreadPlan, Clear); 1152bdbfd50SJim Ingham 116baf5664fSJonas Devlieghere m_opaque_sp.reset(); 117baf5664fSJonas Devlieghere } 118baf5664fSJonas Devlieghere 119baf5664fSJonas Devlieghere lldb::StopReason SBThreadPlan::GetStopReason() { 120baf5664fSJonas Devlieghere LLDB_RECORD_METHOD_NO_ARGS(lldb::StopReason, SBThreadPlan, GetStopReason); 121baf5664fSJonas Devlieghere 122baf5664fSJonas Devlieghere return eStopReasonNone; 123baf5664fSJonas Devlieghere } 124baf5664fSJonas Devlieghere 125baf5664fSJonas Devlieghere size_t SBThreadPlan::GetStopReasonDataCount() { 126baf5664fSJonas Devlieghere LLDB_RECORD_METHOD_NO_ARGS(size_t, SBThreadPlan, GetStopReasonDataCount); 127baf5664fSJonas Devlieghere 128baf5664fSJonas Devlieghere return 0; 129baf5664fSJonas Devlieghere } 130baf5664fSJonas Devlieghere 131baf5664fSJonas Devlieghere uint64_t SBThreadPlan::GetStopReasonDataAtIndex(uint32_t idx) { 132baf5664fSJonas Devlieghere LLDB_RECORD_METHOD(uint64_t, SBThreadPlan, GetStopReasonDataAtIndex, 133baf5664fSJonas Devlieghere (uint32_t), idx); 134baf5664fSJonas Devlieghere 135baf5664fSJonas Devlieghere return 0; 136baf5664fSJonas Devlieghere } 1372bdbfd50SJim Ingham 138b9c1b51eSKate Stone SBThread SBThreadPlan::GetThread() const { 139baf5664fSJonas Devlieghere LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBThread, SBThreadPlan, GetThread); 140baf5664fSJonas Devlieghere 141b9c1b51eSKate Stone if (m_opaque_sp) { 142baf5664fSJonas Devlieghere return LLDB_RECORD_RESULT( 143baf5664fSJonas Devlieghere SBThread(m_opaque_sp->GetThread().shared_from_this())); 144b9c1b51eSKate Stone } else 145baf5664fSJonas Devlieghere return LLDB_RECORD_RESULT(SBThread()); 1462bdbfd50SJim Ingham } 1472bdbfd50SJim Ingham 148b9c1b51eSKate Stone bool SBThreadPlan::GetDescription(lldb::SBStream &description) const { 149baf5664fSJonas Devlieghere LLDB_RECORD_METHOD_CONST(bool, SBThreadPlan, GetDescription, 150baf5664fSJonas Devlieghere (lldb::SBStream &), description); 151baf5664fSJonas Devlieghere 152b9c1b51eSKate Stone if (m_opaque_sp) { 1532bdbfd50SJim Ingham m_opaque_sp->GetDescription(description.get(), eDescriptionLevelFull); 154b9c1b51eSKate Stone } else { 1552bdbfd50SJim Ingham description.Printf("Empty SBThreadPlan"); 1562bdbfd50SJim Ingham } 1572bdbfd50SJim Ingham return true; 1582bdbfd50SJim Ingham } 1592bdbfd50SJim Ingham 160b9c1b51eSKate Stone void SBThreadPlan::SetThreadPlan(const ThreadPlanSP &lldb_object_sp) { 1612bdbfd50SJim Ingham m_opaque_sp = lldb_object_sp; 1622bdbfd50SJim Ingham } 1632bdbfd50SJim Ingham 164b9c1b51eSKate Stone void SBThreadPlan::SetPlanComplete(bool success) { 165baf5664fSJonas Devlieghere LLDB_RECORD_METHOD(void, SBThreadPlan, SetPlanComplete, (bool), success); 166baf5664fSJonas Devlieghere 1672bdbfd50SJim Ingham if (m_opaque_sp) 1682bdbfd50SJim Ingham m_opaque_sp->SetPlanComplete(success); 1692bdbfd50SJim Ingham } 1702bdbfd50SJim Ingham 171b9c1b51eSKate Stone bool SBThreadPlan::IsPlanComplete() { 172baf5664fSJonas Devlieghere LLDB_RECORD_METHOD_NO_ARGS(bool, SBThreadPlan, IsPlanComplete); 173baf5664fSJonas Devlieghere 1742bdbfd50SJim Ingham if (m_opaque_sp) 1752bdbfd50SJim Ingham return m_opaque_sp->IsPlanComplete(); 1762bdbfd50SJim Ingham else 1772bdbfd50SJim Ingham return true; 1782bdbfd50SJim Ingham } 1792bdbfd50SJim Ingham 180b9c1b51eSKate Stone bool SBThreadPlan::IsPlanStale() { 181baf5664fSJonas Devlieghere LLDB_RECORD_METHOD_NO_ARGS(bool, SBThreadPlan, IsPlanStale); 182baf5664fSJonas Devlieghere 183c915a7d2SJim Ingham if (m_opaque_sp) 184c915a7d2SJim Ingham return m_opaque_sp->IsPlanStale(); 185c915a7d2SJim Ingham else 186c915a7d2SJim Ingham return true; 187c915a7d2SJim Ingham } 188c915a7d2SJim Ingham 189b9c1b51eSKate Stone bool SBThreadPlan::IsValid() { 190baf5664fSJonas Devlieghere LLDB_RECORD_METHOD_NO_ARGS(bool, SBThreadPlan, IsValid); 191baf5664fSJonas Devlieghere 1922bdbfd50SJim Ingham if (m_opaque_sp) 1932bdbfd50SJim Ingham return m_opaque_sp->ValidatePlan(nullptr); 1942bdbfd50SJim Ingham else 1952bdbfd50SJim Ingham return false; 1962bdbfd50SJim Ingham } 1972bdbfd50SJim Ingham 198b9c1b51eSKate Stone // This section allows an SBThreadPlan to push another of the common types of 199b9c1b51eSKate Stone // plans... 2002bdbfd50SJim Ingham // 201b9c1b51eSKate Stone // FIXME, you should only be able to queue thread plans from inside the methods 20205097246SAdrian Prantl // of a Scripted Thread Plan. Need a way to enforce that. 2032bdbfd50SJim Ingham 2042bdbfd50SJim Ingham SBThreadPlan 2052bdbfd50SJim Ingham SBThreadPlan::QueueThreadPlanForStepOverRange(SBAddress &sb_start_address, 206b9c1b51eSKate Stone lldb::addr_t size) { 207baf5664fSJonas Devlieghere LLDB_RECORD_METHOD(lldb::SBThreadPlan, SBThreadPlan, 208baf5664fSJonas Devlieghere QueueThreadPlanForStepOverRange, 209baf5664fSJonas Devlieghere (lldb::SBAddress &, lldb::addr_t), sb_start_address, size); 210baf5664fSJonas Devlieghere 211e103ae92SJonas Devlieghere SBError error; 212baf5664fSJonas Devlieghere return LLDB_RECORD_RESULT( 213baf5664fSJonas Devlieghere QueueThreadPlanForStepOverRange(sb_start_address, size, error)); 214e103ae92SJonas Devlieghere } 215e103ae92SJonas Devlieghere 216e103ae92SJonas Devlieghere SBThreadPlan SBThreadPlan::QueueThreadPlanForStepOverRange( 217e103ae92SJonas Devlieghere SBAddress &sb_start_address, lldb::addr_t size, SBError &error) { 218baf5664fSJonas Devlieghere LLDB_RECORD_METHOD(lldb::SBThreadPlan, SBThreadPlan, 219baf5664fSJonas Devlieghere QueueThreadPlanForStepOverRange, 220baf5664fSJonas Devlieghere (lldb::SBAddress &, lldb::addr_t, lldb::SBError &), 221baf5664fSJonas Devlieghere sb_start_address, size, error); 222baf5664fSJonas Devlieghere 223b9c1b51eSKate Stone if (m_opaque_sp) { 2242bdbfd50SJim Ingham Address *start_address = sb_start_address.get(); 225b9c1b51eSKate Stone if (!start_address) { 226baf5664fSJonas Devlieghere return LLDB_RECORD_RESULT(SBThreadPlan()); 2272bdbfd50SJim Ingham } 2282bdbfd50SJim Ingham 2292bdbfd50SJim Ingham AddressRange range(*start_address, size); 2302bdbfd50SJim Ingham SymbolContext sc; 2312bdbfd50SJim Ingham start_address->CalculateSymbolContext(&sc); 232e103ae92SJonas Devlieghere Status plan_status; 233e103ae92SJonas Devlieghere 234e103ae92SJonas Devlieghere SBThreadPlan plan = 235e103ae92SJonas Devlieghere SBThreadPlan(m_opaque_sp->GetThread().QueueThreadPlanForStepOverRange( 236e103ae92SJonas Devlieghere false, range, sc, eAllThreads, plan_status)); 237e103ae92SJonas Devlieghere 238e103ae92SJonas Devlieghere if (plan_status.Fail()) 239e103ae92SJonas Devlieghere error.SetErrorString(plan_status.AsCString()); 240e103ae92SJonas Devlieghere 241baf5664fSJonas Devlieghere return LLDB_RECORD_RESULT(plan); 242b9c1b51eSKate Stone } else { 243baf5664fSJonas Devlieghere return LLDB_RECORD_RESULT(SBThreadPlan()); 2442bdbfd50SJim Ingham } 2452bdbfd50SJim Ingham } 2462bdbfd50SJim Ingham 2472bdbfd50SJim Ingham SBThreadPlan 2482bdbfd50SJim Ingham SBThreadPlan::QueueThreadPlanForStepInRange(SBAddress &sb_start_address, 249b9c1b51eSKate Stone lldb::addr_t size) { 250baf5664fSJonas Devlieghere LLDB_RECORD_METHOD(lldb::SBThreadPlan, SBThreadPlan, 251baf5664fSJonas Devlieghere QueueThreadPlanForStepInRange, 252baf5664fSJonas Devlieghere (lldb::SBAddress &, lldb::addr_t), sb_start_address, size); 253baf5664fSJonas Devlieghere 254e103ae92SJonas Devlieghere SBError error; 255baf5664fSJonas Devlieghere return LLDB_RECORD_RESULT( 256baf5664fSJonas Devlieghere QueueThreadPlanForStepInRange(sb_start_address, size, error)); 257e103ae92SJonas Devlieghere } 258e103ae92SJonas Devlieghere 259e103ae92SJonas Devlieghere SBThreadPlan 260e103ae92SJonas Devlieghere SBThreadPlan::QueueThreadPlanForStepInRange(SBAddress &sb_start_address, 261e103ae92SJonas Devlieghere lldb::addr_t size, SBError &error) { 262baf5664fSJonas Devlieghere LLDB_RECORD_METHOD(lldb::SBThreadPlan, SBThreadPlan, 263baf5664fSJonas Devlieghere QueueThreadPlanForStepInRange, 264baf5664fSJonas Devlieghere (lldb::SBAddress &, lldb::addr_t, lldb::SBError &), 265baf5664fSJonas Devlieghere sb_start_address, size, error); 266baf5664fSJonas Devlieghere 267b9c1b51eSKate Stone if (m_opaque_sp) { 2682bdbfd50SJim Ingham Address *start_address = sb_start_address.get(); 269b9c1b51eSKate Stone if (!start_address) { 270baf5664fSJonas Devlieghere return LLDB_RECORD_RESULT(SBThreadPlan()); 2712bdbfd50SJim Ingham } 2722bdbfd50SJim Ingham 2732bdbfd50SJim Ingham AddressRange range(*start_address, size); 2742bdbfd50SJim Ingham SymbolContext sc; 2752bdbfd50SJim Ingham start_address->CalculateSymbolContext(&sc); 276e103ae92SJonas Devlieghere 277e103ae92SJonas Devlieghere Status plan_status; 278e103ae92SJonas Devlieghere SBThreadPlan plan = 279e103ae92SJonas Devlieghere SBThreadPlan(m_opaque_sp->GetThread().QueueThreadPlanForStepInRange( 280248a1305SKonrad Kleine false, range, sc, nullptr, eAllThreads, plan_status)); 281e103ae92SJonas Devlieghere 282e103ae92SJonas Devlieghere if (plan_status.Fail()) 283e103ae92SJonas Devlieghere error.SetErrorString(plan_status.AsCString()); 284e103ae92SJonas Devlieghere 285baf5664fSJonas Devlieghere return LLDB_RECORD_RESULT(plan); 286b9c1b51eSKate Stone } else { 287baf5664fSJonas Devlieghere return LLDB_RECORD_RESULT(SBThreadPlan()); 2882bdbfd50SJim Ingham } 2892bdbfd50SJim Ingham } 2902bdbfd50SJim Ingham 2912bdbfd50SJim Ingham SBThreadPlan 292b9c1b51eSKate Stone SBThreadPlan::QueueThreadPlanForStepOut(uint32_t frame_idx_to_step_to, 293b9c1b51eSKate Stone bool first_insn) { 294baf5664fSJonas Devlieghere LLDB_RECORD_METHOD(lldb::SBThreadPlan, SBThreadPlan, 295baf5664fSJonas Devlieghere QueueThreadPlanForStepOut, (uint32_t, bool), 296baf5664fSJonas Devlieghere frame_idx_to_step_to, first_insn); 297baf5664fSJonas Devlieghere 298e103ae92SJonas Devlieghere SBError error; 299baf5664fSJonas Devlieghere return LLDB_RECORD_RESULT( 300baf5664fSJonas Devlieghere QueueThreadPlanForStepOut(frame_idx_to_step_to, first_insn, error)); 301e103ae92SJonas Devlieghere } 302e103ae92SJonas Devlieghere 303e103ae92SJonas Devlieghere SBThreadPlan 304e103ae92SJonas Devlieghere SBThreadPlan::QueueThreadPlanForStepOut(uint32_t frame_idx_to_step_to, 305e103ae92SJonas Devlieghere bool first_insn, SBError &error) { 306baf5664fSJonas Devlieghere LLDB_RECORD_METHOD(lldb::SBThreadPlan, SBThreadPlan, 307baf5664fSJonas Devlieghere QueueThreadPlanForStepOut, 308baf5664fSJonas Devlieghere (uint32_t, bool, lldb::SBError &), frame_idx_to_step_to, 309baf5664fSJonas Devlieghere first_insn, error); 310baf5664fSJonas Devlieghere 311b9c1b51eSKate Stone if (m_opaque_sp) { 3122bdbfd50SJim Ingham SymbolContext sc; 313b9c1b51eSKate Stone sc = m_opaque_sp->GetThread().GetStackFrameAtIndex(0)->GetSymbolContext( 314b9c1b51eSKate Stone lldb::eSymbolContextEverything); 315e103ae92SJonas Devlieghere 316e103ae92SJonas Devlieghere Status plan_status; 317e103ae92SJonas Devlieghere SBThreadPlan plan = 318e103ae92SJonas Devlieghere SBThreadPlan(m_opaque_sp->GetThread().QueueThreadPlanForStepOut( 319b9c1b51eSKate Stone false, &sc, first_insn, false, eVoteYes, eVoteNoOpinion, 320e103ae92SJonas Devlieghere frame_idx_to_step_to, plan_status)); 321e103ae92SJonas Devlieghere 322e103ae92SJonas Devlieghere if (plan_status.Fail()) 323e103ae92SJonas Devlieghere error.SetErrorString(plan_status.AsCString()); 324e103ae92SJonas Devlieghere 325baf5664fSJonas Devlieghere return LLDB_RECORD_RESULT(plan); 326b9c1b51eSKate Stone } else { 327baf5664fSJonas Devlieghere return LLDB_RECORD_RESULT(SBThreadPlan()); 3282bdbfd50SJim Ingham } 3292bdbfd50SJim Ingham } 3302bdbfd50SJim Ingham 3312bdbfd50SJim Ingham SBThreadPlan 332b9c1b51eSKate Stone SBThreadPlan::QueueThreadPlanForRunToAddress(SBAddress sb_address) { 333baf5664fSJonas Devlieghere LLDB_RECORD_METHOD(lldb::SBThreadPlan, SBThreadPlan, 334baf5664fSJonas Devlieghere QueueThreadPlanForRunToAddress, (lldb::SBAddress), 335baf5664fSJonas Devlieghere sb_address); 336baf5664fSJonas Devlieghere 337e103ae92SJonas Devlieghere SBError error; 338baf5664fSJonas Devlieghere return LLDB_RECORD_RESULT(QueueThreadPlanForRunToAddress(sb_address, error)); 339e103ae92SJonas Devlieghere } 340e103ae92SJonas Devlieghere 341e103ae92SJonas Devlieghere SBThreadPlan SBThreadPlan::QueueThreadPlanForRunToAddress(SBAddress sb_address, 342e103ae92SJonas Devlieghere SBError &error) { 343baf5664fSJonas Devlieghere LLDB_RECORD_METHOD(lldb::SBThreadPlan, SBThreadPlan, 344baf5664fSJonas Devlieghere QueueThreadPlanForRunToAddress, 345baf5664fSJonas Devlieghere (lldb::SBAddress, lldb::SBError &), sb_address, error); 346baf5664fSJonas Devlieghere 347b9c1b51eSKate Stone if (m_opaque_sp) { 3482bdbfd50SJim Ingham Address *address = sb_address.get(); 3492bdbfd50SJim Ingham if (!address) 350baf5664fSJonas Devlieghere return LLDB_RECORD_RESULT(SBThreadPlan()); 3512bdbfd50SJim Ingham 352e103ae92SJonas Devlieghere Status plan_status; 353e103ae92SJonas Devlieghere SBThreadPlan plan = 354e103ae92SJonas Devlieghere SBThreadPlan(m_opaque_sp->GetThread().QueueThreadPlanForRunToAddress( 355e103ae92SJonas Devlieghere false, *address, false, plan_status)); 356e103ae92SJonas Devlieghere 357e103ae92SJonas Devlieghere if (plan_status.Fail()) 358e103ae92SJonas Devlieghere error.SetErrorString(plan_status.AsCString()); 359e103ae92SJonas Devlieghere 360baf5664fSJonas Devlieghere return LLDB_RECORD_RESULT(plan); 361b9c1b51eSKate Stone } else { 362baf5664fSJonas Devlieghere return LLDB_RECORD_RESULT(SBThreadPlan()); 3632bdbfd50SJim Ingham } 3642bdbfd50SJim Ingham } 365c1c0fac7SAleksandr Urakov 366c1c0fac7SAleksandr Urakov SBThreadPlan 367c1c0fac7SAleksandr Urakov SBThreadPlan::QueueThreadPlanForStepScripted(const char *script_class_name) { 368baf5664fSJonas Devlieghere LLDB_RECORD_METHOD(lldb::SBThreadPlan, SBThreadPlan, 369baf5664fSJonas Devlieghere QueueThreadPlanForStepScripted, (const char *), 370baf5664fSJonas Devlieghere script_class_name); 371baf5664fSJonas Devlieghere 372e103ae92SJonas Devlieghere SBError error; 373baf5664fSJonas Devlieghere return LLDB_RECORD_RESULT( 374baf5664fSJonas Devlieghere QueueThreadPlanForStepScripted(script_class_name, error)); 375e103ae92SJonas Devlieghere } 376e103ae92SJonas Devlieghere 377e103ae92SJonas Devlieghere SBThreadPlan 378e103ae92SJonas Devlieghere SBThreadPlan::QueueThreadPlanForStepScripted(const char *script_class_name, 379e103ae92SJonas Devlieghere SBError &error) { 380baf5664fSJonas Devlieghere LLDB_RECORD_METHOD(lldb::SBThreadPlan, SBThreadPlan, 381baf5664fSJonas Devlieghere QueueThreadPlanForStepScripted, 382baf5664fSJonas Devlieghere (const char *, lldb::SBError &), script_class_name, error); 383baf5664fSJonas Devlieghere 384c1c0fac7SAleksandr Urakov if (m_opaque_sp) { 385e103ae92SJonas Devlieghere Status plan_status; 38627a14f19SJim Ingham StructuredData::ObjectSP empty_args; 387e103ae92SJonas Devlieghere SBThreadPlan plan = 388e103ae92SJonas Devlieghere SBThreadPlan(m_opaque_sp->GetThread().QueueThreadPlanForStepScripted( 38927a14f19SJim Ingham false, script_class_name, empty_args, false, plan_status)); 39027a14f19SJim Ingham 39127a14f19SJim Ingham if (plan_status.Fail()) 39227a14f19SJim Ingham error.SetErrorString(plan_status.AsCString()); 39327a14f19SJim Ingham 39427a14f19SJim Ingham return LLDB_RECORD_RESULT(plan); 39527a14f19SJim Ingham } else { 39627a14f19SJim Ingham return LLDB_RECORD_RESULT(SBThreadPlan()); 39727a14f19SJim Ingham } 39827a14f19SJim Ingham } 39927a14f19SJim Ingham 40027a14f19SJim Ingham SBThreadPlan 40127a14f19SJim Ingham SBThreadPlan::QueueThreadPlanForStepScripted(const char *script_class_name, 40227a14f19SJim Ingham lldb::SBStructuredData &args_data, 40327a14f19SJim Ingham SBError &error) { 40427a14f19SJim Ingham LLDB_RECORD_METHOD(lldb::SBThreadPlan, SBThreadPlan, 40527a14f19SJim Ingham QueueThreadPlanForStepScripted, 40627a14f19SJim Ingham (const char *, lldb::SBStructuredData &, lldb::SBError &), 40727a14f19SJim Ingham script_class_name, args_data, error); 40827a14f19SJim Ingham 40927a14f19SJim Ingham if (m_opaque_sp) { 41027a14f19SJim Ingham Status plan_status; 41127a14f19SJim Ingham StructuredData::ObjectSP args_obj = args_data.m_impl_up->GetObjectSP(); 41227a14f19SJim Ingham SBThreadPlan plan = 41327a14f19SJim Ingham SBThreadPlan(m_opaque_sp->GetThread().QueueThreadPlanForStepScripted( 41427a14f19SJim Ingham false, script_class_name, args_obj, false, plan_status)); 415e103ae92SJonas Devlieghere 416e103ae92SJonas Devlieghere if (plan_status.Fail()) 417e103ae92SJonas Devlieghere error.SetErrorString(plan_status.AsCString()); 418e103ae92SJonas Devlieghere 419baf5664fSJonas Devlieghere return LLDB_RECORD_RESULT(plan); 420c1c0fac7SAleksandr Urakov } else { 421baf5664fSJonas Devlieghere return LLDB_RECORD_RESULT(SBThreadPlan()); 422c1c0fac7SAleksandr Urakov } 423c1c0fac7SAleksandr Urakov } 424ae211eceSMichal Gorny 425ae211eceSMichal Gorny namespace lldb_private { 426ae211eceSMichal Gorny namespace repro { 427ae211eceSMichal Gorny 428ae211eceSMichal Gorny template <> 429ae211eceSMichal Gorny void RegisterMethods<SBThreadPlan>(Registry &R) { 430ae211eceSMichal Gorny LLDB_REGISTER_CONSTRUCTOR(SBThreadPlan, ()); 431ae211eceSMichal Gorny LLDB_REGISTER_CONSTRUCTOR(SBThreadPlan, (const lldb::ThreadPlanSP &)); 432ae211eceSMichal Gorny LLDB_REGISTER_CONSTRUCTOR(SBThreadPlan, (const lldb::SBThreadPlan &)); 433ae211eceSMichal Gorny LLDB_REGISTER_CONSTRUCTOR(SBThreadPlan, (lldb::SBThread &, const char *)); 43427a14f19SJim Ingham LLDB_REGISTER_CONSTRUCTOR(SBThreadPlan, (lldb::SBThread &, const char *, 43527a14f19SJim Ingham lldb::SBStructuredData &)); 436ae211eceSMichal Gorny LLDB_REGISTER_METHOD(const lldb::SBThreadPlan &, 437ae211eceSMichal Gorny SBThreadPlan, operator=,(const lldb::SBThreadPlan &)); 438ae211eceSMichal Gorny LLDB_REGISTER_METHOD_CONST(bool, SBThreadPlan, IsValid, ()); 439ae211eceSMichal Gorny LLDB_REGISTER_METHOD_CONST(bool, SBThreadPlan, operator bool, ()); 440ae211eceSMichal Gorny LLDB_REGISTER_METHOD(void, SBThreadPlan, Clear, ()); 441ae211eceSMichal Gorny LLDB_REGISTER_METHOD(lldb::StopReason, SBThreadPlan, GetStopReason, ()); 442ae211eceSMichal Gorny LLDB_REGISTER_METHOD(size_t, SBThreadPlan, GetStopReasonDataCount, ()); 443ae211eceSMichal Gorny LLDB_REGISTER_METHOD(uint64_t, SBThreadPlan, GetStopReasonDataAtIndex, 444ae211eceSMichal Gorny (uint32_t)); 445ae211eceSMichal Gorny LLDB_REGISTER_METHOD_CONST(lldb::SBThread, SBThreadPlan, GetThread, ()); 446ae211eceSMichal Gorny LLDB_REGISTER_METHOD_CONST(bool, SBThreadPlan, GetDescription, 447ae211eceSMichal Gorny (lldb::SBStream &)); 448ae211eceSMichal Gorny LLDB_REGISTER_METHOD(void, SBThreadPlan, SetPlanComplete, (bool)); 449ae211eceSMichal Gorny LLDB_REGISTER_METHOD(bool, SBThreadPlan, IsPlanComplete, ()); 450ae211eceSMichal Gorny LLDB_REGISTER_METHOD(bool, SBThreadPlan, IsPlanStale, ()); 451ae211eceSMichal Gorny LLDB_REGISTER_METHOD(bool, SBThreadPlan, IsValid, ()); 452ae211eceSMichal Gorny LLDB_REGISTER_METHOD(lldb::SBThreadPlan, SBThreadPlan, 453ae211eceSMichal Gorny QueueThreadPlanForStepOverRange, 454ae211eceSMichal Gorny (lldb::SBAddress &, lldb::addr_t)); 455ae211eceSMichal Gorny LLDB_REGISTER_METHOD(lldb::SBThreadPlan, SBThreadPlan, 456ae211eceSMichal Gorny QueueThreadPlanForStepOverRange, 457ae211eceSMichal Gorny (lldb::SBAddress &, lldb::addr_t, lldb::SBError &)); 458ae211eceSMichal Gorny LLDB_REGISTER_METHOD(lldb::SBThreadPlan, SBThreadPlan, 459ae211eceSMichal Gorny QueueThreadPlanForStepInRange, 460ae211eceSMichal Gorny (lldb::SBAddress &, lldb::addr_t)); 461ae211eceSMichal Gorny LLDB_REGISTER_METHOD(lldb::SBThreadPlan, SBThreadPlan, 462ae211eceSMichal Gorny QueueThreadPlanForStepInRange, 463ae211eceSMichal Gorny (lldb::SBAddress &, lldb::addr_t, lldb::SBError &)); 464ae211eceSMichal Gorny LLDB_REGISTER_METHOD(lldb::SBThreadPlan, SBThreadPlan, 465ae211eceSMichal Gorny QueueThreadPlanForStepOut, (uint32_t, bool)); 466ae211eceSMichal Gorny LLDB_REGISTER_METHOD(lldb::SBThreadPlan, SBThreadPlan, 467ae211eceSMichal Gorny QueueThreadPlanForStepOut, 468ae211eceSMichal Gorny (uint32_t, bool, lldb::SBError &)); 469ae211eceSMichal Gorny LLDB_REGISTER_METHOD(lldb::SBThreadPlan, SBThreadPlan, 470ae211eceSMichal Gorny QueueThreadPlanForRunToAddress, (lldb::SBAddress)); 471ae211eceSMichal Gorny LLDB_REGISTER_METHOD(lldb::SBThreadPlan, SBThreadPlan, 472ae211eceSMichal Gorny QueueThreadPlanForRunToAddress, 473ae211eceSMichal Gorny (lldb::SBAddress, lldb::SBError &)); 474ae211eceSMichal Gorny LLDB_REGISTER_METHOD(lldb::SBThreadPlan, SBThreadPlan, 475ae211eceSMichal Gorny QueueThreadPlanForStepScripted, (const char *)); 476ae211eceSMichal Gorny LLDB_REGISTER_METHOD(lldb::SBThreadPlan, SBThreadPlan, 477ae211eceSMichal Gorny QueueThreadPlanForStepScripted, 478ae211eceSMichal Gorny (const char *, lldb::SBError &)); 47927a14f19SJim Ingham LLDB_REGISTER_METHOD(lldb::SBThreadPlan, SBThreadPlan, 48027a14f19SJim Ingham QueueThreadPlanForStepScripted, 48127a14f19SJim Ingham (const char *, lldb::SBStructuredData &, 48227a14f19SJim Ingham lldb::SBError &)); 483ae211eceSMichal Gorny } 484ae211eceSMichal Gorny 485ae211eceSMichal Gorny } 486ae211eceSMichal Gorny } 487