SBError SBDebugger::RunREPL (lldb::LanguageType language, const char *repl_options) { SBError error; if (m_opaque_sp) error.ref() = m_opaque_sp->RunREPL(language, repl_options); else error.SetErrorString ("invalid debugger"); return error; }
size_t SBProcess::ReadMemory (addr_t addr, void *dst, size_t dst_len, SBError &sb_error) { LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); size_t bytes_read = 0; ProcessSP process_sp(GetSP()); if (log) { log->Printf ("SBProcess(%p)::ReadMemory (addr=0x%llx, dst=%p, dst_len=%zu, SBError (%p))...", process_sp.get(), addr, dst, dst_len, sb_error.get()); } if (process_sp) { Process::StopLocker stop_locker; if (stop_locker.TryLock(&process_sp->GetRunLock())) { Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); bytes_read = process_sp->ReadMemory (addr, dst, dst_len, sb_error.ref()); } else { if (log) log->Printf ("SBProcess(%p)::ReadMemory() => error: process is running", process_sp.get()); sb_error.SetErrorString("process is running"); } } else { sb_error.SetErrorString ("SBProcess is invalid"); } if (log) { SBStream sstr; sb_error.GetDescription (sstr); log->Printf ("SBProcess(%p)::ReadMemory (addr=0x%llx, dst=%p, dst_len=%zu, SBError (%p): %s) => %zu", process_sp.get(), addr, dst, dst_len, sb_error.get(), sstr.GetData(), bytes_read); } return bytes_read; }
size_t SBProcess::WriteMemory (addr_t addr, const void *src, size_t src_len, SBError &sb_error) { size_t bytes_written = 0; LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); ProcessSP process_sp(GetSP()); if (log) { log->Printf ("SBProcess(%p)::WriteMemory (addr=0x%llx, src=%p, src_len=%llu, SBError (%p))...", process_sp.get(), addr, src, (uint64_t)src_len, sb_error.get()); } if (process_sp) { Process::StopLocker stop_locker; if (stop_locker.TryLock(&process_sp->GetRunLock())) { Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); bytes_written = process_sp->WriteMemory (addr, src, src_len, sb_error.ref()); } else { if (log) log->Printf ("SBProcess(%p)::WriteMemory() => error: process is running", process_sp.get()); sb_error.SetErrorString("process is running"); } } if (log) { SBStream sstr; sb_error.GetDescription (sstr); log->Printf ("SBProcess(%p)::WriteMemory (addr=0x%llx, src=%p, src_len=%llu, SBError (%p): %s) => %llu", process_sp.get(), addr, src, (uint64_t)src_len, sb_error.get(), sstr.GetData(), (uint64_t)bytes_written); } return bytes_written; }
void SBThread::StepInto(const char *target_name, uint32_t end_line, SBError &error, lldb::RunMode stop_other_threads) { Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); std::unique_lock<std::recursive_mutex> lock; ExecutionContext exe_ctx(m_opaque_sp.get(), lock); if (log) log->Printf( "SBThread(%p)::StepInto (target_name='%s', stop_other_threads='%s')", static_cast<void *>(exe_ctx.GetThreadPtr()), target_name ? target_name : "<NULL>", Thread::RunModeAsCString(stop_other_threads)); if (exe_ctx.HasThreadScope()) { bool abort_other_plans = false; Thread *thread = exe_ctx.GetThreadPtr(); StackFrameSP frame_sp(thread->GetStackFrameAtIndex(0)); ThreadPlanSP new_plan_sp; if (frame_sp && frame_sp->HasDebugInformation()) { SymbolContext sc(frame_sp->GetSymbolContext(eSymbolContextEverything)); AddressRange range; if (end_line == LLDB_INVALID_LINE_NUMBER) range = sc.line_entry.range; else { if (!sc.GetAddressRangeFromHereToEndLine(end_line, range, error.ref())) return; } const LazyBool step_out_avoids_code_without_debug_info = eLazyBoolCalculate; const LazyBool step_in_avoids_code_without_debug_info = eLazyBoolCalculate; new_plan_sp = thread->QueueThreadPlanForStepInRange( abort_other_plans, range, sc, target_name, stop_other_threads, step_in_avoids_code_without_debug_info, step_out_avoids_code_without_debug_info); } else { new_plan_sp = thread->QueueThreadPlanForStepSingleInstruction( false, abort_other_plans, stop_other_threads); } error = ResumeNewPlan(exe_ctx, new_plan_sp.get()); } }