diff --git a/lldb/include/lldb/API/SBModule.h b/lldb/include/lldb/API/SBModule.h index 9f7bf7ede40d..f4255742b815 100644 --- a/lldb/include/lldb/API/SBModule.h +++ b/lldb/include/lldb/API/SBModule.h @@ -188,31 +188,11 @@ private: explicit SBModule (const lldb::ModuleSP& module_sp); - void - SetModule (const lldb::ModuleSP& module_sp); -#ifndef SWIG - - lldb::ModuleSP & - operator *(); - - - lldb_private::Module * - operator ->(); - - const lldb_private::Module * - operator ->() const; - - lldb_private::Module * - get(); - - const lldb_private::Module * - get() const; - - const lldb::ModuleSP & - get_sp() const; + ModuleSP + GetSP () const; - -#endif + void + SetSP (const ModuleSP &module_sp); lldb::ModuleSP m_opaque_sp; }; diff --git a/lldb/source/API/SBAddress.cpp b/lldb/source/API/SBAddress.cpp index 7cb0d902dfb6..430e11aa1d49 100644 --- a/lldb/source/API/SBAddress.cpp +++ b/lldb/source/API/SBAddress.cpp @@ -300,9 +300,7 @@ SBAddress::GetModule () SBModule sb_module; if (m_opaque_ap.get()) { - Module *module = m_opaque_ap->GetModule(); - if (module) - *sb_module = module->shared_from_this(); + sb_module.SetSP (m_opaque_ap->GetModuleSP()); } return sb_module; } diff --git a/lldb/source/API/SBFrame.cpp b/lldb/source/API/SBFrame.cpp index 564cf7736f25..a1bb7062ce46 100644 --- a/lldb/source/API/SBFrame.cpp +++ b/lldb/source/API/SBFrame.cpp @@ -222,17 +222,19 @@ SBModule SBFrame::GetModule () const { SBModule sb_module; + ModuleSP module_sp; StackFrameSP frame_sp(GetFrameSP()); if (frame_sp) { Mutex::Locker api_locker (frame_sp->GetThread().GetProcess().GetTarget().GetAPIMutex()); - *sb_module = frame_sp->GetSymbolContext (eSymbolContextModule).module_sp; + module_sp = frame_sp->GetSymbolContext (eSymbolContextModule).module_sp; + sb_module.SetSP (module_sp); } LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) log->Printf ("SBFrame(%p)::GetModule () => SBModule(%p)", - frame_sp.get(), sb_module.get()); + frame_sp.get(), module_sp.get()); return sb_module; } diff --git a/lldb/source/API/SBModule.cpp b/lldb/source/API/SBModule.cpp index 28180fce63a8..6200cc6c8393 100644 --- a/lldb/source/API/SBModule.cpp +++ b/lldb/source/API/SBModule.cpp @@ -193,49 +193,18 @@ SBModule::operator != (const SBModule &rhs) const return false; } -lldb::ModuleSP & -SBModule::operator *() -{ - return m_opaque_sp; -} - -lldb_private::Module * -SBModule::operator ->() -{ - return m_opaque_sp.get(); -} - -const lldb_private::Module * -SBModule::operator ->() const -{ - return m_opaque_sp.get(); -} - -lldb_private::Module * -SBModule::get() -{ - return m_opaque_sp.get(); -} - -const lldb_private::Module * -SBModule::get() const -{ - return m_opaque_sp.get(); -} - -const lldb::ModuleSP & -SBModule::get_sp() const +ModuleSP +SBModule::GetSP () const { return m_opaque_sp; } void -SBModule::SetModule (const lldb::ModuleSP& module_sp) +SBModule::SetSP (const ModuleSP &module_sp) { m_opaque_sp = module_sp; } - SBAddress SBModule::ResolveFileAddress (lldb::addr_t vm_addr) { diff --git a/lldb/source/API/SBProcess.cpp b/lldb/source/API/SBProcess.cpp index 3422efbdb94d..4b4e840e63d1 100644 --- a/lldb/source/API/SBProcess.cpp +++ b/lldb/source/API/SBProcess.cpp @@ -125,10 +125,11 @@ SBProcess::RemoteLaunch (char const **argv, error.get()); } - if (m_opaque_sp) + ProcessSP process_sp(GetSP()); + if (process_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); - if (m_opaque_sp->GetState() == eStateConnected) + Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); + if (process_sp->GetState() == eStateConnected) { if (stop_at_entry) launch_flags |= eLaunchFlagStopAtEntry; @@ -137,14 +138,14 @@ SBProcess::RemoteLaunch (char const **argv, stderr_path, working_directory, launch_flags); - Module *exe_module = m_opaque_sp->GetTarget().GetExecutableModulePointer(); + Module *exe_module = process_sp->GetTarget().GetExecutableModulePointer(); if (exe_module) launch_info.SetExecutableFile(exe_module->GetFileSpec(), true); if (argv) launch_info.GetArguments().AppendArguments (argv); if (envp) launch_info.GetEnvironmentEntries ().SetArguments (envp); - error.SetError (m_opaque_sp->Launch (launch_info)); + error.SetError (process_sp->Launch (launch_info)); } else { @@ -159,7 +160,7 @@ SBProcess::RemoteLaunch (char const **argv, if (log) { SBStream sstr; error.GetDescription (sstr); - log->Printf ("SBProcess(%p)::RemoteLaunch (...) => SBError (%p): %s", m_opaque_sp.get(), error.get(), sstr.GetData()); + log->Printf ("SBProcess(%p)::RemoteLaunch (...) => SBError (%p): %s", process_sp.get(), error.get(), sstr.GetData()); } return error.Success(); @@ -168,14 +169,15 @@ SBProcess::RemoteLaunch (char const **argv, bool SBProcess::RemoteAttachToProcessWithID (lldb::pid_t pid, lldb::SBError& error) { - if (m_opaque_sp) + ProcessSP process_sp(GetSP()); + if (process_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); - if (m_opaque_sp->GetState() == eStateConnected) + Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); + if (process_sp->GetState() == eStateConnected) { ProcessAttachInfo attach_info; attach_info.SetProcessID (pid); - error.SetError (m_opaque_sp->Attach (attach_info)); + error.SetError (process_sp->Attach (attach_info)); } else { @@ -191,7 +193,7 @@ SBProcess::RemoteAttachToProcessWithID (lldb::pid_t pid, lldb::SBError& error) if (log) { SBStream sstr; error.GetDescription (sstr); - log->Printf ("SBProcess(%p)::RemoteAttachToProcessWithID (%llu) => SBError (%p): %s", m_opaque_sp.get(), pid, error.get(), sstr.GetData()); + log->Printf ("SBProcess(%p)::RemoteAttachToProcessWithID (%llu) => SBError (%p): %s", process_sp.get(), pid, error.get(), sstr.GetData()); } return error.Success(); @@ -204,15 +206,16 @@ SBProcess::GetNumThreads () LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); uint32_t num_threads = 0; - if (m_opaque_sp) + ProcessSP process_sp(GetSP()); + if (process_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); + Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); const bool can_update = true; - num_threads = m_opaque_sp->GetThreadList().GetSize(can_update); + num_threads = process_sp->GetThreadList().GetSize(can_update); } if (log) - log->Printf ("SBProcess(%p)::GetNumThreads () => %d", m_opaque_sp.get(), num_threads); + log->Printf ("SBProcess(%p)::GetNumThreads () => %d", process_sp.get(), num_threads); return num_threads; } @@ -224,16 +227,17 @@ SBProcess::GetSelectedThread () const SBThread sb_thread; ThreadSP thread_sp; - if (m_opaque_sp) + ProcessSP process_sp(GetSP()); + if (process_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); - thread_sp = m_opaque_sp->GetThreadList().GetSelectedThread(); + Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); + thread_sp = process_sp->GetThreadList().GetSelectedThread(); sb_thread.SetThread (thread_sp); } if (log) { - log->Printf ("SBProcess(%p)::GetSelectedThread () => SBThread(%p)", m_opaque_sp.get(), thread_sp.get()); + log->Printf ("SBProcess(%p)::GetSelectedThread () => SBThread(%p)", process_sp.get(), thread_sp.get()); } return sb_thread; @@ -246,14 +250,15 @@ SBProcess::GetTarget() const SBTarget sb_target; TargetSP target_sp; - if (m_opaque_sp) + ProcessSP process_sp(GetSP()); + if (process_sp) { - target_sp = m_opaque_sp->GetTarget().shared_from_this(); + target_sp = process_sp->GetTarget().shared_from_this(); sb_target.SetSP (target_sp); } if (log) - log->Printf ("SBProcess(%p)::GetTarget () => SBTarget(%p)", m_opaque_sp.get(), target_sp.get()); + log->Printf ("SBProcess(%p)::GetTarget () => SBTarget(%p)", process_sp.get(), target_sp.get()); return sb_target; } @@ -265,15 +270,16 @@ SBProcess::PutSTDIN (const char *src, size_t src_len) LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); size_t ret_val = 0; - if (m_opaque_sp) + ProcessSP process_sp(GetSP()); + if (process_sp) { Error error; - ret_val = m_opaque_sp->PutSTDIN (src, src_len, error); + ret_val = process_sp->PutSTDIN (src, src_len, error); } if (log) log->Printf ("SBProcess(%p)::PutSTDIN (src=\"%s\", src_len=%d) => %lu", - m_opaque_sp.get(), + process_sp.get(), src, (uint32_t) src_len, ret_val); @@ -285,16 +291,17 @@ size_t SBProcess::GetSTDOUT (char *dst, size_t dst_len) const { size_t bytes_read = 0; - if (m_opaque_sp) + ProcessSP process_sp(GetSP()); + if (process_sp) { Error error; - bytes_read = m_opaque_sp->GetSTDOUT (dst, dst_len, error); + bytes_read = process_sp->GetSTDOUT (dst, dst_len, error); } LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) log->Printf ("SBProcess(%p)::GetSTDOUT (dst=\"%.*s\", dst_len=%zu) => %zu", - m_opaque_sp.get(), (int) bytes_read, dst, dst_len, bytes_read); + process_sp.get(), (int) bytes_read, dst, dst_len, bytes_read); return bytes_read; } @@ -303,16 +310,17 @@ size_t SBProcess::GetSTDERR (char *dst, size_t dst_len) const { size_t bytes_read = 0; - if (m_opaque_sp) + ProcessSP process_sp(GetSP()); + if (process_sp) { Error error; - bytes_read = m_opaque_sp->GetSTDERR (dst, dst_len, error); + bytes_read = process_sp->GetSTDERR (dst, dst_len, error); } LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) log->Printf ("SBProcess(%p)::GetSTDERR (dst=\"%.*s\", dst_len=%zu) => %zu", - m_opaque_sp.get(), (int) bytes_read, dst, dst_len, bytes_read); + process_sp.get(), (int) bytes_read, dst, dst_len, bytes_read); return bytes_read; } @@ -323,14 +331,15 @@ SBProcess::ReportEventState (const SBEvent &event, FILE *out) const if (out == NULL) return; - if (m_opaque_sp) + ProcessSP process_sp(GetSP()); + if (process_sp) { const StateType event_state = SBProcess::GetStateFromEvent (event); char message[1024]; int message_len = ::snprintf (message, sizeof (message), "Process %llu %s\n", - m_opaque_sp->GetID(), + process_sp->GetID(), SBDebugger::StateAsCString (event_state)); if (message_len > 0) @@ -341,14 +350,15 @@ SBProcess::ReportEventState (const SBEvent &event, FILE *out) const void SBProcess::AppendEventStateReport (const SBEvent &event, SBCommandReturnObject &result) { - if (m_opaque_sp) + ProcessSP process_sp(GetSP()); + if (process_sp) { const StateType event_state = SBProcess::GetStateFromEvent (event); char message[1024]; ::snprintf (message, sizeof (message), "Process %llu %s\n", - m_opaque_sp->GetID(), + process_sp->GetID(), SBDebugger::StateAsCString (event_state)); result.AppendMessage (message); @@ -358,10 +368,11 @@ SBProcess::AppendEventStateReport (const SBEvent &event, SBCommandReturnObject & bool SBProcess::SetSelectedThread (const SBThread &thread) { - if (m_opaque_sp) + ProcessSP process_sp(GetSP()); + if (process_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); - return m_opaque_sp->GetThreadList().SetSelectedThreadByID (thread.GetThreadID()); + Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); + return process_sp->GetThreadList().SetSelectedThreadByID (thread.GetThreadID()); } return false; } @@ -372,15 +383,16 @@ SBProcess::SetSelectedThreadByID (uint32_t tid) LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); bool ret_val = false; - if (m_opaque_sp) + ProcessSP process_sp(GetSP()); + if (process_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); - ret_val = m_opaque_sp->GetThreadList().SetSelectedThreadByID (tid); + Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); + ret_val = process_sp->GetThreadList().SetSelectedThreadByID (tid); } if (log) log->Printf ("SBProcess(%p)::SetSelectedThreadByID (tid=0x%4.4x) => %s", - m_opaque_sp.get(), tid, (ret_val ? "true" : "false")); + process_sp.get(), tid, (ret_val ? "true" : "false")); return ret_val; } @@ -392,17 +404,18 @@ SBProcess::GetThreadAtIndex (size_t index) SBThread sb_thread; ThreadSP thread_sp; - if (m_opaque_sp) + ProcessSP process_sp(GetSP()); + if (process_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); - thread_sp = m_opaque_sp->GetThreadList().GetThreadAtIndex(index); + Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); + thread_sp = process_sp->GetThreadList().GetThreadAtIndex(index); sb_thread.SetThread (thread_sp); } if (log) { log->Printf ("SBProcess(%p)::GetThreadAtIndex (index=%d) => SBThread(%p)", - m_opaque_sp.get(), (uint32_t) index, thread_sp.get()); + process_sp.get(), (uint32_t) index, thread_sp.get()); } return sb_thread; @@ -413,16 +426,17 @@ SBProcess::GetState () { StateType ret_val = eStateInvalid; - if (m_opaque_sp) + ProcessSP process_sp(GetSP()); + if (process_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); - ret_val = m_opaque_sp->GetState(); + Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); + ret_val = process_sp->GetState(); } LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) log->Printf ("SBProcess(%p)::GetState () => %s", - m_opaque_sp.get(), + process_sp.get(), lldb_private::StateAsCString (ret_val)); return ret_val; @@ -433,15 +447,16 @@ int SBProcess::GetExitStatus () { int exit_status = 0; - if (m_opaque_sp) + ProcessSP process_sp(GetSP()); + if (process_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); - exit_status = m_opaque_sp->GetExitStatus (); + Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); + exit_status = process_sp->GetExitStatus (); } LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) log->Printf ("SBProcess(%p)::GetExitStatus () => %i (0x%8.8x)", - m_opaque_sp.get(), exit_status, exit_status); + process_sp.get(), exit_status, exit_status); return exit_status; } @@ -450,15 +465,16 @@ const char * SBProcess::GetExitDescription () { const char *exit_desc = NULL; - if (m_opaque_sp) + ProcessSP process_sp(GetSP()); + if (process_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); - exit_desc = m_opaque_sp->GetExitDescription (); + Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); + exit_desc = process_sp->GetExitDescription (); } LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) log->Printf ("SBProcess(%p)::GetExitDescription () => %s", - m_opaque_sp.get(), exit_desc); + process_sp.get(), exit_desc); return exit_desc; } @@ -466,12 +482,13 @@ lldb::pid_t SBProcess::GetProcessID () { lldb::pid_t ret_val = LLDB_INVALID_PROCESS_ID; - if (m_opaque_sp) - ret_val = m_opaque_sp->GetID(); + ProcessSP process_sp(GetSP()); + if (process_sp) + ret_val = process_sp->GetID(); LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) - log->Printf ("SBProcess(%p)::GetProcessID () => %llu", m_opaque_sp.get(), ret_val); + log->Printf ("SBProcess(%p)::GetProcessID () => %llu", process_sp.get(), ret_val); return ret_val; } @@ -480,12 +497,13 @@ ByteOrder SBProcess::GetByteOrder () const { ByteOrder byteOrder = eByteOrderInvalid; - if (m_opaque_sp) - byteOrder = m_opaque_sp->GetTarget().GetArchitecture().GetByteOrder(); + ProcessSP process_sp(GetSP()); + if (process_sp) + byteOrder = process_sp->GetTarget().GetArchitecture().GetByteOrder(); LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) - log->Printf ("SBProcess(%p)::GetByteOrder () => %d", m_opaque_sp.get(), byteOrder); + log->Printf ("SBProcess(%p)::GetByteOrder () => %d", process_sp.get(), byteOrder); return byteOrder; } @@ -494,12 +512,13 @@ uint32_t SBProcess::GetAddressByteSize () const { uint32_t size = 0; - if (m_opaque_sp) - size = m_opaque_sp->GetTarget().GetArchitecture().GetAddressByteSize(); + ProcessSP process_sp(GetSP()); + if (process_sp) + size = process_sp->GetTarget().GetArchitecture().GetAddressByteSize(); LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) - log->Printf ("SBProcess(%p)::GetAddressByteSize () => %d", m_opaque_sp.get(), size); + log->Printf ("SBProcess(%p)::GetAddressByteSize () => %d", process_sp.get(), size); return size; } @@ -508,22 +527,25 @@ SBError SBProcess::Continue () { LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); - if (log) - log->Printf ("SBProcess(%p)::Continue ()...", m_opaque_sp.get()); SBError sb_error; - if (m_opaque_sp) + ProcessSP process_sp(GetSP()); + + if (log) + log->Printf ("SBProcess(%p)::Continue ()...", process_sp.get()); + + if (process_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); + Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); - Error error (m_opaque_sp->Resume()); + Error error (process_sp->Resume()); if (error.Success()) { - if (m_opaque_sp->GetTarget().GetDebugger().GetAsyncExecution () == false) + if (process_sp->GetTarget().GetDebugger().GetAsyncExecution () == false) { if (log) - log->Printf ("SBProcess(%p)::Continue () waiting for process to stop...", m_opaque_sp.get()); - m_opaque_sp->WaitForProcessToStop (NULL); + log->Printf ("SBProcess(%p)::Continue () waiting for process to stop...", process_sp.get()); + process_sp->WaitForProcessToStop (NULL); } } sb_error.SetError(error); @@ -535,7 +557,7 @@ SBProcess::Continue () { SBStream sstr; sb_error.GetDescription (sstr); - log->Printf ("SBProcess(%p)::Continue () => SBError (%p): %s", m_opaque_sp.get(), sb_error.get(), sstr.GetData()); + log->Printf ("SBProcess(%p)::Continue () => SBError (%p): %s", process_sp.get(), sb_error.get(), sstr.GetData()); } return sb_error; @@ -546,10 +568,11 @@ SBError SBProcess::Destroy () { SBError sb_error; - if (m_opaque_sp) + ProcessSP process_sp(GetSP()); + if (process_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); - sb_error.SetError(m_opaque_sp->Destroy()); + Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); + sb_error.SetError(process_sp->Destroy()); } else sb_error.SetErrorString ("SBProcess is invalid"); @@ -560,7 +583,7 @@ SBProcess::Destroy () SBStream sstr; sb_error.GetDescription (sstr); log->Printf ("SBProcess(%p)::Destroy () => SBError (%p): %s", - m_opaque_sp.get(), + process_sp.get(), sb_error.get(), sstr.GetData()); } @@ -573,10 +596,11 @@ SBError SBProcess::Stop () { SBError sb_error; - if (m_opaque_sp) + ProcessSP process_sp(GetSP()); + if (process_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); - sb_error.SetError (m_opaque_sp->Halt()); + Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); + sb_error.SetError (process_sp->Halt()); } else sb_error.SetErrorString ("SBProcess is invalid"); @@ -587,7 +611,7 @@ SBProcess::Stop () SBStream sstr; sb_error.GetDescription (sstr); log->Printf ("SBProcess(%p)::Stop () => SBError (%p): %s", - m_opaque_sp.get(), + process_sp.get(), sb_error.get(), sstr.GetData()); } @@ -599,10 +623,11 @@ SBError SBProcess::Kill () { SBError sb_error; - if (m_opaque_sp) + ProcessSP process_sp(GetSP()); + if (process_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); - sb_error.SetError (m_opaque_sp->Destroy()); + Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); + sb_error.SetError (process_sp->Destroy()); } else sb_error.SetErrorString ("SBProcess is invalid"); @@ -613,7 +638,7 @@ SBProcess::Kill () SBStream sstr; sb_error.GetDescription (sstr); log->Printf ("SBProcess(%p)::Kill () => SBError (%p): %s", - m_opaque_sp.get(), + process_sp.get(), sb_error.get(), sstr.GetData()); } @@ -625,10 +650,11 @@ SBError SBProcess::Detach () { SBError sb_error; - if (m_opaque_sp) + ProcessSP process_sp(GetSP()); + if (process_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); - sb_error.SetError (m_opaque_sp->Detach()); + Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); + sb_error.SetError (process_sp->Detach()); } else sb_error.SetErrorString ("SBProcess is invalid"); @@ -640,10 +666,11 @@ SBError SBProcess::Signal (int signo) { SBError sb_error; - if (m_opaque_sp) + ProcessSP process_sp(GetSP()); + if (process_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); - sb_error.SetError (m_opaque_sp->Signal (signo)); + Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); + sb_error.SetError (process_sp->Signal (signo)); } else sb_error.SetErrorString ("SBProcess is invalid"); @@ -653,7 +680,7 @@ SBProcess::Signal (int signo) SBStream sstr; sb_error.GetDescription (sstr); log->Printf ("SBProcess(%p)::Signal (signo=%i) => SBError (%p): %s", - m_opaque_sp.get(), + process_sp.get(), signo, sb_error.get(), sstr.GetData()); @@ -666,10 +693,11 @@ SBProcess::GetThreadByID (tid_t tid) { SBThread sb_thread; ThreadSP thread_sp; - if (m_opaque_sp) + ProcessSP process_sp(GetSP()); + if (process_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); - thread_sp = m_opaque_sp->GetThreadList().FindThreadByID (tid); + Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); + thread_sp = process_sp->GetThreadList().FindThreadByID (tid); sb_thread.SetThread (thread_sp); } @@ -677,7 +705,7 @@ SBProcess::GetThreadByID (tid_t tid) if (log) { log->Printf ("SBProcess(%p)::GetThreadByID (tid=0x%4.4llx) => SBThread (%p)", - m_opaque_sp.get(), + process_sp.get(), tid, thread_sp.get()); } @@ -718,10 +746,12 @@ SBProcess::GetBroadcaster () const { LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); - SBBroadcaster broadcaster(m_opaque_sp.get(), false); + ProcessSP process_sp(GetSP()); + + SBBroadcaster broadcaster(process_sp.get(), false); if (log) - log->Printf ("SBProcess(%p)::GetBroadcaster () => SBBroadcaster (%p)", m_opaque_sp.get(), + log->Printf ("SBProcess(%p)::GetBroadcaster () => SBBroadcaster (%p)", process_sp.get(), broadcaster.get()); return broadcaster; @@ -734,21 +764,23 @@ SBProcess::ReadMemory (addr_t addr, void *dst, size_t dst_len, SBError &sb_error 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))...", - m_opaque_sp.get(), + process_sp.get(), addr, dst, dst_len, sb_error.get()); } - - if (m_opaque_sp) + + if (process_sp) { Error error; - Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); - bytes_read = m_opaque_sp->ReadMemory (addr, dst, dst_len, error); + Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); + bytes_read = process_sp->ReadMemory (addr, dst, dst_len, error); sb_error.SetError (error); } else @@ -761,7 +793,7 @@ SBProcess::ReadMemory (addr_t addr, void *dst, size_t dst_len, SBError &sb_error SBStream sstr; sb_error.GetDescription (sstr); log->Printf ("SBProcess(%p)::ReadMemory (addr=0x%llx, dst=%p, dst_len=%zu, SBError (%p): %s) => %zu", - m_opaque_sp.get(), + process_sp.get(), addr, dst, dst_len, @@ -777,11 +809,12 @@ size_t SBProcess::ReadCStringFromMemory (addr_t addr, void *buf, size_t size, lldb::SBError &sb_error) { size_t bytes_read = 0; - if (m_opaque_sp) + ProcessSP process_sp(GetSP()); + if (process_sp) { Error error; - Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); - bytes_read = m_opaque_sp->ReadCStringFromMemory (addr, (char *)buf, size, error); + Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); + bytes_read = process_sp->ReadCStringFromMemory (addr, (char *)buf, size, error); sb_error.SetError (error); } else @@ -794,11 +827,12 @@ SBProcess::ReadCStringFromMemory (addr_t addr, void *buf, size_t size, lldb::SBE uint64_t SBProcess::ReadUnsignedFromMemory (addr_t addr, uint32_t byte_size, lldb::SBError &sb_error) { - if (m_opaque_sp) + ProcessSP process_sp(GetSP()); + if (process_sp) { Error error; - Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); - uint64_t value = m_opaque_sp->ReadUnsignedIntegerFromMemory (addr, byte_size, 0, error); + Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); + uint64_t value = process_sp->ReadUnsignedIntegerFromMemory (addr, byte_size, 0, error); sb_error.SetError (error); return value; } @@ -813,11 +847,12 @@ lldb::addr_t SBProcess::ReadPointerFromMemory (addr_t addr, lldb::SBError &sb_error) { lldb::addr_t ptr = LLDB_INVALID_ADDRESS; - if (m_opaque_sp) + ProcessSP process_sp(GetSP()); + if (process_sp) { Error error; - Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); - ptr = m_opaque_sp->ReadPointerFromMemory (addr, error); + Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); + ptr = process_sp->ReadPointerFromMemory (addr, error); sb_error.SetError (error); } else @@ -833,21 +868,24 @@ SBProcess::WriteMemory (addr_t addr, const void *src, size_t src_len, SBError &s 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, dst_len=%zu, SBError (%p))...", - m_opaque_sp.get(), + process_sp.get(), addr, src, src_len, sb_error.get()); } - if (m_opaque_sp) + if (process_sp) { Error error; - Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); - bytes_written = m_opaque_sp->WriteMemory (addr, src, src_len, error); + Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); + bytes_written = process_sp->WriteMemory (addr, src, src_len, error); sb_error.SetError (error); } @@ -856,7 +894,7 @@ SBProcess::WriteMemory (addr_t addr, const void *src, size_t src_len, SBError &s SBStream sstr; sb_error.GetDescription (sstr); log->Printf ("SBProcess(%p)::WriteMemory (addr=0x%llx, src=%p, dst_len=%zu, SBError (%p): %s) => %zu", - m_opaque_sp.get(), + process_sp.get(), addr, src, src_len, @@ -873,17 +911,18 @@ SBProcess::GetDescription (SBStream &description) { Stream &strm = description.ref(); - if (m_opaque_sp) + ProcessSP process_sp(GetSP()); + if (process_sp) { char path[PATH_MAX]; GetTarget().GetExecutable().GetPath (path, sizeof(path)); - Module *exe_module = m_opaque_sp->GetTarget().GetExecutableModulePointer(); + Module *exe_module = process_sp->GetTarget().GetExecutableModulePointer(); const char *exe_name = NULL; if (exe_module) exe_name = exe_module->GetFileSpec().GetFilename().AsCString(); strm.Printf ("SBProcess: pid = %llu, state = %s, threads = %d%s%s", - m_opaque_sp->GetID(), + process_sp->GetID(), lldb_private::StateAsCString (GetState()), GetNumThreads(), exe_name ? ", executable = " : "", @@ -898,10 +937,11 @@ SBProcess::GetDescription (SBStream &description) uint32_t SBProcess::LoadImage (lldb::SBFileSpec &sb_image_spec, lldb::SBError &sb_error) { - if (m_opaque_sp) + ProcessSP process_sp(GetSP()); + if (process_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); - return m_opaque_sp->LoadImage (*sb_image_spec, sb_error.ref()); + Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); + return process_sp->LoadImage (*sb_image_spec, sb_error.ref()); } return LLDB_INVALID_IMAGE_TOKEN; } @@ -910,10 +950,11 @@ lldb::SBError SBProcess::UnloadImage (uint32_t image_token) { lldb::SBError sb_error; - if (m_opaque_sp) + ProcessSP process_sp(GetSP()); + if (process_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); - sb_error.SetError (m_opaque_sp->UnloadImage (image_token)); + Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); + sb_error.SetError (process_sp->UnloadImage (image_token)); } else sb_error.SetErrorString("invalid process"); diff --git a/lldb/source/API/SBSymbolContext.cpp b/lldb/source/API/SBSymbolContext.cpp index 1ec79df1ac0b..0f7ce8cf0ac7 100644 --- a/lldb/source/API/SBSymbolContext.cpp +++ b/lldb/source/API/SBSymbolContext.cpp @@ -90,15 +90,19 @@ SBSymbolContext::GetModule () LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); SBModule sb_module; + ModuleSP module_sp; if (m_opaque_ap.get()) - sb_module.SetModule(m_opaque_ap->module_sp); + { + module_sp = m_opaque_ap->module_sp; + sb_module.SetSP (module_sp); + } if (log) { SBStream sstr; sb_module.GetDescription (sstr); log->Printf ("SBSymbolContext(%p)::GetModule () => SBModule(%p): %s", - m_opaque_ap.get(), sb_module.get(), sstr.GetData()); + m_opaque_ap.get(), module_sp.get(), sstr.GetData()); } return sb_module; @@ -177,7 +181,7 @@ SBSymbolContext::GetSymbol () void SBSymbolContext::SetModule (lldb::SBModule module) { - ref().module_sp = module.get_sp(); + ref().module_sp = module.GetSP(); } void diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp index dc06e7c9e5e2..376ed78d9a7b 100644 --- a/lldb/source/API/SBTarget.cpp +++ b/lldb/source/API/SBTarget.cpp @@ -98,9 +98,10 @@ SBTarget::GetProcess () { SBProcess sb_process; ProcessSP process_sp; - if (m_opaque_sp) + TargetSP target_sp(GetSP()); + if (target_sp) { - process_sp = m_opaque_sp->GetProcessSP(); + process_sp = target_sp->GetProcessSP(); sb_process.SetSP (process_sp); } @@ -108,7 +109,7 @@ SBTarget::GetProcess () if (log) { log->Printf ("SBTarget(%p)::GetProcess () => SBProcess(%p)", - m_opaque_sp.get(), process_sp.get()); + target_sp.get(), process_sp.get()); } return sb_process; @@ -118,8 +119,9 @@ SBDebugger SBTarget::GetDebugger () const { SBDebugger debugger; - if (m_opaque_sp) - debugger.reset (m_opaque_sp->GetDebugger().shared_from_this()); + TargetSP target_sp(GetSP()); + if (target_sp) + debugger.reset (target_sp->GetDebugger().shared_from_this()); return debugger; } @@ -167,10 +169,14 @@ SBTarget::Launch { LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); + SBProcess sb_process; + ProcessSP process_sp; + TargetSP target_sp(GetSP()); + if (log) { log->Printf ("SBTarget(%p)::Launch (argv=%p, envp=%p, stdin=%s, stdout=%s, stderr=%s, working-dir=%s, launch_flags=0x%x, stop_at_entry=%i, &error (%p))...", - m_opaque_sp.get(), + target_sp.get(), argv, envp, stdin_path ? stdin_path : "NULL", @@ -181,17 +187,16 @@ SBTarget::Launch stop_at_entry, error.get()); } - SBProcess sb_process; - ProcessSP process_sp; - if (m_opaque_sp) + + if (target_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex()); + Mutex::Locker api_locker (target_sp->GetAPIMutex()); if (getenv("LLDB_LAUNCH_FLAG_DISABLE_ASLR")) launch_flags |= eLaunchFlagDisableASLR; StateType state = eStateInvalid; - process_sp = m_opaque_sp->GetProcessSP(); + process_sp = target_sp->GetProcessSP(); if (process_sp) { state = process_sp->GetState(); @@ -220,9 +225,9 @@ SBTarget::Launch else { if (listener.IsValid()) - process_sp = m_opaque_sp->CreateProcess (listener.ref()); + process_sp = target_sp->CreateProcess (listener.ref()); else - process_sp = m_opaque_sp->CreateProcess (m_opaque_sp->GetDebugger().GetListener()); + process_sp = target_sp->CreateProcess (target_sp->GetDebugger().GetListener()); } if (process_sp) @@ -233,7 +238,7 @@ SBTarget::Launch ProcessLaunchInfo launch_info (stdin_path, stdout_path, stderr_path, working_directory, launch_flags); - Module *exe_module = m_opaque_sp->GetExecutableModulePointer(); + Module *exe_module = target_sp->GetExecutableModulePointer(); if (exe_module) launch_info.SetExecutableFile(exe_module->GetPlatformFileSpec(), true); if (argv) @@ -258,7 +263,7 @@ SBTarget::Launch { // If we are doing synchronous mode, then wait for the // process to stop yet again! - if (m_opaque_sp->GetDebugger().GetAsyncExecution () == false) + if (target_sp->GetDebugger().GetAsyncExecution () == false) process_sp->WaitForProcessToStop (NULL); } } @@ -278,7 +283,7 @@ SBTarget::Launch if (log) { log->Printf ("SBTarget(%p)::Launch (...) => SBProceess(%p)", - m_opaque_sp.get(), process_sp.get()); + target_sp.get(), process_sp.get()); } return sb_process; @@ -306,12 +311,13 @@ SBTarget::AttachToProcessWithID { SBProcess sb_process; ProcessSP process_sp; - if (m_opaque_sp) + TargetSP target_sp(GetSP()); + if (target_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex()); + Mutex::Locker api_locker (target_sp->GetAPIMutex()); StateType state = eStateInvalid; - process_sp = m_opaque_sp->GetProcessSP(); + process_sp = target_sp->GetProcessSP(); if (process_sp) { state = process_sp->GetState(); @@ -340,9 +346,9 @@ SBTarget::AttachToProcessWithID else { if (listener.IsValid()) - process_sp = m_opaque_sp->CreateProcess (listener.ref()); + process_sp = target_sp->CreateProcess (listener.ref()); else - process_sp = m_opaque_sp->CreateProcess (m_opaque_sp->GetDebugger().GetListener()); + process_sp = target_sp->CreateProcess (target_sp->GetDebugger().GetListener()); } if (process_sp) { @@ -353,7 +359,7 @@ SBTarget::AttachToProcessWithID error.SetError (process_sp->Attach (attach_info)); // If we are doing synchronous mode, then wait for the // process to stop! - if (m_opaque_sp->GetDebugger().GetAsyncExecution () == false) + if (target_sp->GetDebugger().GetAsyncExecution () == false) process_sp->WaitForProcessToStop (NULL); } else @@ -380,12 +386,13 @@ SBTarget::AttachToProcessWithName { SBProcess sb_process; ProcessSP process_sp; - if (name && m_opaque_sp) + TargetSP target_sp(GetSP()); + if (name && target_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex()); + Mutex::Locker api_locker (target_sp->GetAPIMutex()); StateType state = eStateInvalid; - process_sp = m_opaque_sp->GetProcessSP(); + process_sp = target_sp->GetProcessSP(); if (process_sp) { state = process_sp->GetState(); @@ -414,9 +421,9 @@ SBTarget::AttachToProcessWithName else { if (listener.IsValid()) - process_sp = m_opaque_sp->CreateProcess (listener.ref()); + process_sp = target_sp->CreateProcess (listener.ref()); else - process_sp = m_opaque_sp->CreateProcess (m_opaque_sp->GetDebugger().GetListener()); + process_sp = target_sp->CreateProcess (target_sp->GetDebugger().GetListener()); } if (process_sp) @@ -428,7 +435,7 @@ SBTarget::AttachToProcessWithName error.SetError (process_sp->Attach (attach_info)); // If we are doing synchronous mode, then wait for the // process to stop! - if (m_opaque_sp->GetDebugger().GetAsyncExecution () == false) + if (target_sp->GetDebugger().GetAsyncExecution () == false) process_sp->WaitForProcessToStop (NULL); } else @@ -455,13 +462,14 @@ SBTarget::ConnectRemote { SBProcess sb_process; ProcessSP process_sp; - if (m_opaque_sp) + TargetSP target_sp(GetSP()); + if (target_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex()); + Mutex::Locker api_locker (target_sp->GetAPIMutex()); if (listener.IsValid()) - process_sp = m_opaque_sp->CreateProcess (listener.ref(), plugin_name); + process_sp = target_sp->CreateProcess (listener.ref(), plugin_name); else - process_sp = m_opaque_sp->CreateProcess (m_opaque_sp->GetDebugger().GetListener(), plugin_name); + process_sp = target_sp->CreateProcess (target_sp->GetDebugger().GetListener(), plugin_name); if (process_sp) @@ -486,9 +494,10 @@ SBTarget::GetExecutable () { SBFileSpec exe_file_spec; - if (m_opaque_sp) + TargetSP target_sp(GetSP()); + if (target_sp) { - Module *exe_module = m_opaque_sp->GetExecutableModulePointer(); + Module *exe_module = target_sp->GetExecutableModulePointer(); if (exe_module) exe_file_spec.SetFileSpec (exe_module->GetFileSpec()); } @@ -497,7 +506,7 @@ SBTarget::GetExecutable () if (log) { log->Printf ("SBTarget(%p)::GetExecutable () => SBFileSpec(%p)", - m_opaque_sp.get(), exe_file_spec.get()); + target_sp.get(), exe_file_spec.get()); } return exe_file_spec; @@ -532,10 +541,11 @@ SBTarget::ResolveLoadAddress (lldb::addr_t vm_addr) { lldb::SBAddress sb_addr; Address &addr = sb_addr.ref(); - if (m_opaque_sp) + TargetSP target_sp(GetSP()); + if (target_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex()); - if (m_opaque_sp->GetSectionLoadList().ResolveLoadAddress (vm_addr, addr)) + Mutex::Locker api_locker (target_sp->GetAPIMutex()); + if (target_sp->GetSectionLoadList().ResolveLoadAddress (vm_addr, addr)) return sb_addr; } @@ -550,8 +560,12 @@ SBSymbolContext SBTarget::ResolveSymbolContextForAddress (const SBAddress& addr, uint32_t resolve_scope) { SBSymbolContext sc; - if (m_opaque_sp && addr.IsValid()) - m_opaque_sp->GetImages().ResolveSymbolContextForAddress (addr.ref(), resolve_scope, sc.ref()); + if (addr.IsValid()) + { + TargetSP target_sp(GetSP()); + if (target_sp) + target_sp->GetImages().ResolveSymbolContextForAddress (addr.ref(), resolve_scope, sc.ref()); + } return sc; } @@ -568,10 +582,11 @@ SBTarget::BreakpointCreateByLocation (const SBFileSpec &sb_file_spec, uint32_t l LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); SBBreakpoint sb_bp; - if (m_opaque_sp.get() && line != 0) + TargetSP target_sp(GetSP()); + if (target_sp && line != 0) { - Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex()); - *sb_bp = m_opaque_sp->CreateBreakpoint (NULL, *sb_file_spec, line, true, false); + Mutex::Locker api_locker (target_sp->GetAPIMutex()); + *sb_bp = target_sp->CreateBreakpoint (NULL, *sb_file_spec, line, true, false); } if (log) @@ -581,7 +596,7 @@ SBTarget::BreakpointCreateByLocation (const SBFileSpec &sb_file_spec, uint32_t l char path[PATH_MAX]; sb_file_spec->GetPath (path, sizeof(path)); log->Printf ("SBTarget(%p)::BreakpointCreateByLocation ( %s:%u ) => SBBreakpoint(%p): %s", - m_opaque_sp.get(), + target_sp.get(), path, line, sb_bp.get(), @@ -597,25 +612,26 @@ SBTarget::BreakpointCreateByName (const char *symbol_name, const char *module_na LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); SBBreakpoint sb_bp; - if (m_opaque_sp.get()) + TargetSP target_sp(GetSP()); + if (target_sp.get()) { - Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex()); + Mutex::Locker api_locker (target_sp->GetAPIMutex()); if (module_name && module_name[0]) { FileSpecList module_spec_list; module_spec_list.Append (FileSpec (module_name, false)); - *sb_bp = m_opaque_sp->CreateBreakpoint (&module_spec_list, NULL, symbol_name, eFunctionNameTypeAuto, false); + *sb_bp = target_sp->CreateBreakpoint (&module_spec_list, NULL, symbol_name, eFunctionNameTypeAuto, false); } else { - *sb_bp = m_opaque_sp->CreateBreakpoint (NULL, NULL, symbol_name, eFunctionNameTypeAuto, false); + *sb_bp = target_sp->CreateBreakpoint (NULL, NULL, symbol_name, eFunctionNameTypeAuto, false); } } if (log) { log->Printf ("SBTarget(%p)::BreakpointCreateByName (symbol=\"%s\", module=\"%s\") => SBBreakpoint(%p)", - m_opaque_sp.get(), symbol_name, module_name, sb_bp.get()); + target_sp.get(), symbol_name, module_name, sb_bp.get()); } return sb_bp; @@ -639,10 +655,11 @@ SBTarget::BreakpointCreateByName (const char *symbol_name, LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); SBBreakpoint sb_bp; - if (m_opaque_sp.get() && symbol_name && symbol_name[0]) + TargetSP target_sp(GetSP()); + if (target_sp && symbol_name && symbol_name[0]) { - Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex()); - *sb_bp = m_opaque_sp->CreateBreakpoint (module_list.get(), + Mutex::Locker api_locker (target_sp->GetAPIMutex()); + *sb_bp = target_sp->CreateBreakpoint (module_list.get(), comp_unit_list.get(), symbol_name, name_type_mask, @@ -652,7 +669,7 @@ SBTarget::BreakpointCreateByName (const char *symbol_name, if (log) { log->Printf ("SBTarget(%p)::BreakpointCreateByName (symbol=\"%s\", name_type: %d) => SBBreakpoint(%p)", - m_opaque_sp.get(), symbol_name, name_type_mask, sb_bp.get()); + target_sp.get(), symbol_name, name_type_mask, sb_bp.get()); } return sb_bp; @@ -665,9 +682,10 @@ SBTarget::BreakpointCreateByRegex (const char *symbol_name_regex, const char *mo LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); SBBreakpoint sb_bp; - if (m_opaque_sp.get() && symbol_name_regex && symbol_name_regex[0]) + TargetSP target_sp(GetSP()); + if (target_sp && symbol_name_regex && symbol_name_regex[0]) { - Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex()); + Mutex::Locker api_locker (target_sp->GetAPIMutex()); RegularExpression regexp(symbol_name_regex); if (module_name && module_name[0]) @@ -675,18 +693,18 @@ SBTarget::BreakpointCreateByRegex (const char *symbol_name_regex, const char *mo FileSpecList module_spec_list; module_spec_list.Append (FileSpec (module_name, false)); - *sb_bp = m_opaque_sp->CreateFuncRegexBreakpoint (&module_spec_list, NULL, regexp, false); + *sb_bp = target_sp->CreateFuncRegexBreakpoint (&module_spec_list, NULL, regexp, false); } else { - *sb_bp = m_opaque_sp->CreateFuncRegexBreakpoint (NULL, NULL, regexp, false); + *sb_bp = target_sp->CreateFuncRegexBreakpoint (NULL, NULL, regexp, false); } } if (log) { log->Printf ("SBTarget(%p)::BreakpointCreateByRegex (symbol_regex=\"%s\", module_name=\"%s\") => SBBreakpoint(%p)", - m_opaque_sp.get(), symbol_name_regex, module_name, sb_bp.get()); + target_sp.get(), symbol_name_regex, module_name, sb_bp.get()); } return sb_bp; @@ -700,18 +718,19 @@ SBTarget::BreakpointCreateByRegex (const char *symbol_name_regex, LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); SBBreakpoint sb_bp; - if (m_opaque_sp.get() && symbol_name_regex && symbol_name_regex[0]) + TargetSP target_sp(GetSP()); + if (target_sp && symbol_name_regex && symbol_name_regex[0]) { - Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex()); + Mutex::Locker api_locker (target_sp->GetAPIMutex()); RegularExpression regexp(symbol_name_regex); - *sb_bp = m_opaque_sp->CreateFuncRegexBreakpoint (module_list.get(), comp_unit_list.get(), regexp, false); + *sb_bp = target_sp->CreateFuncRegexBreakpoint (module_list.get(), comp_unit_list.get(), regexp, false); } if (log) { log->Printf ("SBTarget(%p)::BreakpointCreateByRegex (symbol_regex=\"%s\") => SBBreakpoint(%p)", - m_opaque_sp.get(), symbol_name_regex, sb_bp.get()); + target_sp.get(), symbol_name_regex, sb_bp.get()); } return sb_bp; @@ -723,15 +742,16 @@ SBTarget::BreakpointCreateByAddress (addr_t address) LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); SBBreakpoint sb_bp; - if (m_opaque_sp.get()) + TargetSP target_sp(GetSP()); + if (target_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex()); - *sb_bp = m_opaque_sp->CreateBreakpoint (address, false); + Mutex::Locker api_locker (target_sp->GetAPIMutex()); + *sb_bp = target_sp->CreateBreakpoint (address, false); } if (log) { - log->Printf ("SBTarget(%p)::BreakpointCreateByAddress (address=%llu) => SBBreakpoint(%p)", m_opaque_sp.get(), (uint64_t) address, sb_bp.get()); + log->Printf ("SBTarget(%p)::BreakpointCreateByAddress (address=%llu) => SBBreakpoint(%p)", target_sp.get(), (uint64_t) address, sb_bp.get()); } return sb_bp; @@ -743,9 +763,10 @@ SBTarget::BreakpointCreateBySourceRegex (const char *source_regex, const lldb::S LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); SBBreakpoint sb_bp; - if (m_opaque_sp.get() && source_regex && source_regex[0]) + TargetSP target_sp(GetSP()); + if (target_sp && source_regex && source_regex[0]) { - Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex()); + Mutex::Locker api_locker (target_sp->GetAPIMutex()); RegularExpression regexp(source_regex); FileSpecList source_file_spec_list; source_file_spec_list.Append (source_file.ref()); @@ -755,11 +776,11 @@ SBTarget::BreakpointCreateBySourceRegex (const char *source_regex, const lldb::S FileSpecList module_spec_list; module_spec_list.Append (FileSpec (module_name, false)); - *sb_bp = m_opaque_sp->CreateSourceRegexBreakpoint (&module_spec_list, &source_file_spec_list, regexp, false); + *sb_bp = target_sp->CreateSourceRegexBreakpoint (&module_spec_list, &source_file_spec_list, regexp, false); } else { - *sb_bp = m_opaque_sp->CreateSourceRegexBreakpoint (NULL, &source_file_spec_list, regexp, false); + *sb_bp = target_sp->CreateSourceRegexBreakpoint (NULL, &source_file_spec_list, regexp, false); } } @@ -768,7 +789,7 @@ SBTarget::BreakpointCreateBySourceRegex (const char *source_regex, const lldb::S char path[PATH_MAX]; source_file->GetPath (path, sizeof(path)); log->Printf ("SBTarget(%p)::BreakpointCreateByRegex (source_regex=\"%s\", file=\"%s\", module_name=\"%s\") => SBBreakpoint(%p)", - m_opaque_sp.get(), source_regex, path, module_name, sb_bp.get()); + target_sp.get(), source_regex, path, module_name, sb_bp.get()); } return sb_bp; @@ -782,17 +803,18 @@ SBTarget::BreakpointCreateBySourceRegex (const char *source_regex, LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); SBBreakpoint sb_bp; - if (m_opaque_sp.get() && source_regex && source_regex[0]) + TargetSP target_sp(GetSP()); + if (target_sp && source_regex && source_regex[0]) { - Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex()); + Mutex::Locker api_locker (target_sp->GetAPIMutex()); RegularExpression regexp(source_regex); - *sb_bp = m_opaque_sp->CreateSourceRegexBreakpoint (module_list.get(), source_file_list.get(), regexp, false); + *sb_bp = target_sp->CreateSourceRegexBreakpoint (module_list.get(), source_file_list.get(), regexp, false); } if (log) { log->Printf ("SBTarget(%p)::BreakpointCreateByRegex (source_regex=\"%s\") => SBBreakpoint(%p)", - m_opaque_sp.get(), source_regex, sb_bp.get()); + target_sp.get(), source_regex, sb_bp.get()); } return sb_bp; @@ -801,10 +823,11 @@ SBTarget::BreakpointCreateBySourceRegex (const char *source_regex, uint32_t SBTarget::GetNumBreakpoints () const { - if (m_opaque_sp) + TargetSP target_sp(GetSP()); + if (target_sp) { // The breakpoint list is thread safe, no need to lock - return m_opaque_sp->GetBreakpointList().GetSize(); + return target_sp->GetBreakpointList().GetSize(); } return 0; } @@ -813,10 +836,11 @@ SBBreakpoint SBTarget::GetBreakpointAtIndex (uint32_t idx) const { SBBreakpoint sb_breakpoint; - if (m_opaque_sp) + TargetSP target_sp(GetSP()); + if (target_sp) { // The breakpoint list is thread safe, no need to lock - *sb_breakpoint = m_opaque_sp->GetBreakpointList().GetBreakpointAtIndex(idx); + *sb_breakpoint = target_sp->GetBreakpointList().GetBreakpointAtIndex(idx); } return sb_breakpoint; } @@ -827,15 +851,16 @@ SBTarget::BreakpointDelete (break_id_t bp_id) LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); bool result = false; - if (m_opaque_sp) + TargetSP target_sp(GetSP()); + if (target_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex()); - result = m_opaque_sp->RemoveBreakpointByID (bp_id); + Mutex::Locker api_locker (target_sp->GetAPIMutex()); + result = target_sp->RemoveBreakpointByID (bp_id); } if (log) { - log->Printf ("SBTarget(%p)::BreakpointDelete (bp_id=%d) => %i", m_opaque_sp.get(), (uint32_t) bp_id, result); + log->Printf ("SBTarget(%p)::BreakpointDelete (bp_id=%d) => %i", target_sp.get(), (uint32_t) bp_id, result); } return result; @@ -847,16 +872,17 @@ SBTarget::FindBreakpointByID (break_id_t bp_id) LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); SBBreakpoint sb_breakpoint; - if (m_opaque_sp && bp_id != LLDB_INVALID_BREAK_ID) + TargetSP target_sp(GetSP()); + if (target_sp && bp_id != LLDB_INVALID_BREAK_ID) { - Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex()); - *sb_breakpoint = m_opaque_sp->GetBreakpointByID (bp_id); + Mutex::Locker api_locker (target_sp->GetAPIMutex()); + *sb_breakpoint = target_sp->GetBreakpointByID (bp_id); } if (log) { log->Printf ("SBTarget(%p)::FindBreakpointByID (bp_id=%d) => SBBreakpoint(%p)", - m_opaque_sp.get(), (uint32_t) bp_id, sb_breakpoint.get()); + target_sp.get(), (uint32_t) bp_id, sb_breakpoint.get()); } return sb_breakpoint; @@ -865,10 +891,11 @@ SBTarget::FindBreakpointByID (break_id_t bp_id) bool SBTarget::EnableAllBreakpoints () { - if (m_opaque_sp) + TargetSP target_sp(GetSP()); + if (target_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex()); - m_opaque_sp->EnableAllBreakpoints (); + Mutex::Locker api_locker (target_sp->GetAPIMutex()); + target_sp->EnableAllBreakpoints (); return true; } return false; @@ -877,10 +904,11 @@ SBTarget::EnableAllBreakpoints () bool SBTarget::DisableAllBreakpoints () { - if (m_opaque_sp) + TargetSP target_sp(GetSP()); + if (target_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex()); - m_opaque_sp->DisableAllBreakpoints (); + Mutex::Locker api_locker (target_sp->GetAPIMutex()); + target_sp->DisableAllBreakpoints (); return true; } return false; @@ -889,10 +917,11 @@ SBTarget::DisableAllBreakpoints () bool SBTarget::DeleteAllBreakpoints () { - if (m_opaque_sp) + TargetSP target_sp(GetSP()); + if (target_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex()); - m_opaque_sp->RemoveAllBreakpoints (); + Mutex::Locker api_locker (target_sp->GetAPIMutex()); + target_sp->RemoveAllBreakpoints (); return true; } return false; @@ -901,10 +930,11 @@ SBTarget::DeleteAllBreakpoints () uint32_t SBTarget::GetNumWatchpoints () const { - if (m_opaque_sp) + TargetSP target_sp(GetSP()); + if (target_sp) { // The watchpoint list is thread safe, no need to lock - return m_opaque_sp->GetWatchpointList().GetSize(); + return target_sp->GetWatchpointList().GetSize(); } return 0; } @@ -913,10 +943,11 @@ SBWatchpoint SBTarget::GetWatchpointAtIndex (uint32_t idx) const { SBWatchpoint sb_watchpoint; - if (m_opaque_sp) + TargetSP target_sp(GetSP()); + if (target_sp) { // The watchpoint list is thread safe, no need to lock - *sb_watchpoint = m_opaque_sp->GetWatchpointList().GetByIndex(idx); + *sb_watchpoint = target_sp->GetWatchpointList().GetByIndex(idx); } return sb_watchpoint; } @@ -927,15 +958,16 @@ SBTarget::DeleteWatchpoint (watch_id_t wp_id) LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); bool result = false; - if (m_opaque_sp) + TargetSP target_sp(GetSP()); + if (target_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex()); - result = m_opaque_sp->RemoveWatchpointByID (wp_id); + Mutex::Locker api_locker (target_sp->GetAPIMutex()); + result = target_sp->RemoveWatchpointByID (wp_id); } if (log) { - log->Printf ("SBTarget(%p)::WatchpointDelete (wp_id=%d) => %i", m_opaque_sp.get(), (uint32_t) wp_id, result); + log->Printf ("SBTarget(%p)::WatchpointDelete (wp_id=%d) => %i", target_sp.get(), (uint32_t) wp_id, result); } return result; @@ -947,16 +979,17 @@ SBTarget::FindWatchpointByID (lldb::watch_id_t wp_id) LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); SBWatchpoint sb_watchpoint; - if (m_opaque_sp && wp_id != LLDB_INVALID_WATCH_ID) + TargetSP target_sp(GetSP()); + if (target_sp && wp_id != LLDB_INVALID_WATCH_ID) { - Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex()); - *sb_watchpoint = m_opaque_sp->GetWatchpointList().FindByID(wp_id); + Mutex::Locker api_locker (target_sp->GetAPIMutex()); + *sb_watchpoint = target_sp->GetWatchpointList().FindByID(wp_id); } if (log) { log->Printf ("SBTarget(%p)::FindWatchpointByID (bp_id=%d) => SBWatchpoint(%p)", - m_opaque_sp.get(), (uint32_t) wp_id, sb_watchpoint.get()); + target_sp.get(), (uint32_t) wp_id, sb_watchpoint.get()); } return sb_watchpoint; @@ -968,18 +1001,19 @@ SBTarget::WatchAddress (lldb::addr_t addr, size_t size, bool read, bool write) LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); SBWatchpoint sb_watchpoint; - if (m_opaque_sp) + TargetSP target_sp(GetSP()); + if (target_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex()); + Mutex::Locker api_locker (target_sp->GetAPIMutex()); uint32_t watch_type = (read ? LLDB_WATCH_TYPE_READ : 0) | (write ? LLDB_WATCH_TYPE_WRITE : 0); - sb_watchpoint = m_opaque_sp->CreateWatchpoint(addr, size, watch_type); + sb_watchpoint = target_sp->CreateWatchpoint(addr, size, watch_type); } if (log) { log->Printf ("SBTarget(%p)::WatchAddress (addr=0x%llx, 0x%u) => SBWatchpoint(%p)", - m_opaque_sp.get(), addr, (uint32_t) size, sb_watchpoint.get()); + target_sp.get(), addr, (uint32_t) size, sb_watchpoint.get()); } return sb_watchpoint; @@ -988,10 +1022,11 @@ SBTarget::WatchAddress (lldb::addr_t addr, size_t size, bool read, bool write) bool SBTarget::EnableAllWatchpoints () { - if (m_opaque_sp) + TargetSP target_sp(GetSP()); + if (target_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex()); - m_opaque_sp->EnableAllWatchpoints (); + Mutex::Locker api_locker (target_sp->GetAPIMutex()); + target_sp->EnableAllWatchpoints (); return true; } return false; @@ -1000,10 +1035,11 @@ SBTarget::EnableAllWatchpoints () bool SBTarget::DisableAllWatchpoints () { - if (m_opaque_sp) + TargetSP target_sp(GetSP()); + if (target_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex()); - m_opaque_sp->DisableAllWatchpoints (); + Mutex::Locker api_locker (target_sp->GetAPIMutex()); + target_sp->DisableAllWatchpoints (); return true; } return false; @@ -1012,10 +1048,11 @@ SBTarget::DisableAllWatchpoints () bool SBTarget::DeleteAllWatchpoints () { - if (m_opaque_sp) + TargetSP target_sp(GetSP()); + if (target_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex()); - m_opaque_sp->RemoveAllWatchpoints (); + Mutex::Locker api_locker (target_sp->GetAPIMutex()); + target_sp->RemoveAllWatchpoints (); return true; } return false; @@ -1028,7 +1065,8 @@ SBTarget::AddModule (const char *path, const char *uuid_cstr) { lldb::SBModule sb_module; - if (m_opaque_sp) + TargetSP target_sp(GetSP()); + if (target_sp) { FileSpec module_file_spec; UUID module_uuid; @@ -1041,11 +1079,11 @@ SBTarget::AddModule (const char *path, module_uuid.SetfromCString(uuid_cstr); if (triple) - module_arch.SetTriple (triple, m_opaque_sp->GetPlatform ().get()); + module_arch.SetTriple (triple, target_sp->GetPlatform ().get()); - sb_module.SetModule(m_opaque_sp->GetSharedModule (module_file_spec, - module_arch, - uuid_cstr ? &module_uuid : NULL)); + sb_module.SetSP(target_sp->GetSharedModule (module_file_spec, + module_arch, + uuid_cstr ? &module_uuid : NULL)); } return sb_module; } @@ -1053,9 +1091,10 @@ SBTarget::AddModule (const char *path, bool SBTarget::AddModule (lldb::SBModule &module) { - if (m_opaque_sp) + TargetSP target_sp(GetSP()); + if (target_sp) { - m_opaque_sp->GetImages().AppendIfNeeded (module.get_sp()); + target_sp->GetImages().AppendIfNeeded (module.GetSP()); return true; } return false; @@ -1067,14 +1106,15 @@ SBTarget::GetNumModules () const LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); uint32_t num = 0; - if (m_opaque_sp) + TargetSP target_sp(GetSP()); + if (target_sp) { // The module list is thread safe, no need to lock - num = m_opaque_sp->GetImages().GetSize(); + num = target_sp->GetImages().GetSize(); } if (log) - log->Printf ("SBTarget(%p)::GetNumModules () => %d", m_opaque_sp.get(), num); + log->Printf ("SBTarget(%p)::GetNumModules () => %d", target_sp.get(), num); return num; } @@ -1095,10 +1135,11 @@ SBModule SBTarget::FindModule (const SBFileSpec &sb_file_spec) { SBModule sb_module; - if (m_opaque_sp && sb_file_spec.IsValid()) + TargetSP target_sp(GetSP()); + if (target_sp && sb_file_spec.IsValid()) { // The module list is thread safe, no need to lock - sb_module.SetModule (m_opaque_sp->GetImages().FindFirstModuleForFileSpec (*sb_file_spec, NULL, NULL)); + sb_module.SetSP (target_sp->GetImages().FindFirstModuleForFileSpec (*sb_file_spec, NULL, NULL)); } return sb_module; } @@ -1106,17 +1147,19 @@ SBTarget::FindModule (const SBFileSpec &sb_file_spec) lldb::ByteOrder SBTarget::GetByteOrder () { - if (m_opaque_sp) - return m_opaque_sp->GetArchitecture().GetByteOrder(); + TargetSP target_sp(GetSP()); + if (target_sp) + return target_sp->GetArchitecture().GetByteOrder(); return eByteOrderInvalid; } const char * SBTarget::GetTriple () { - if (m_opaque_sp) + TargetSP target_sp(GetSP()); + if (target_sp) { - std::string triple (m_opaque_sp->GetArchitecture().GetTriple().str()); + std::string triple (target_sp->GetArchitecture().GetTriple().str()); // Unique the string so we don't run into ownership issues since // the const strings put the string into the string pool once and // the strings never comes out @@ -1129,8 +1172,9 @@ SBTarget::GetTriple () uint32_t SBTarget::GetAddressByteSize() { - if (m_opaque_sp) - return m_opaque_sp->GetArchitecture().GetAddressByteSize(); + TargetSP target_sp(GetSP()); + if (target_sp) + return target_sp->GetArchitecture().GetAddressByteSize(); return sizeof(void*); } @@ -1141,16 +1185,19 @@ SBTarget::GetModuleAtIndex (uint32_t idx) LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); SBModule sb_module; - if (m_opaque_sp) + ModuleSP module_sp; + TargetSP target_sp(GetSP()); + if (target_sp) { // The module list is thread safe, no need to lock - sb_module.SetModule(m_opaque_sp->GetImages().GetModuleAtIndex(idx)); + module_sp = target_sp->GetImages().GetModuleAtIndex(idx); + sb_module.SetSP (module_sp); } if (log) { log->Printf ("SBTarget(%p)::GetModuleAtIndex (idx=%d) => SBModule(%p)", - m_opaque_sp.get(), idx, sb_module.get()); + target_sp.get(), idx, module_sp.get()); } return sb_module; @@ -1159,8 +1206,9 @@ SBTarget::GetModuleAtIndex (uint32_t idx) bool SBTarget::RemoveModule (lldb::SBModule module) { - if (m_opaque_sp) - return m_opaque_sp->GetImages().Remove(module.get_sp()); + TargetSP target_sp(GetSP()); + if (target_sp) + return target_sp->GetImages().Remove(module.GetSP()); return false; } @@ -1170,11 +1218,12 @@ SBTarget::GetBroadcaster () const { LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); - SBBroadcaster broadcaster(m_opaque_sp.get(), false); + TargetSP target_sp(GetSP()); + SBBroadcaster broadcaster(target_sp.get(), false); if (log) log->Printf ("SBTarget(%p)::GetBroadcaster () => SBBroadcaster(%p)", - m_opaque_sp.get(), broadcaster.get()); + target_sp.get(), broadcaster.get()); return broadcaster; } @@ -1185,9 +1234,10 @@ SBTarget::GetDescription (SBStream &description, lldb::DescriptionLevel descript { Stream &strm = description.ref(); - if (m_opaque_sp) + TargetSP target_sp(GetSP()); + if (target_sp) { - m_opaque_sp->Dump (&strm, description_level); + target_sp->Dump (&strm, description_level); } else strm.PutCString ("No value"); @@ -1203,14 +1253,18 @@ SBTarget::FindFunctions (const char *name, { if (!append) sc_list.Clear(); - if (name && m_opaque_sp) + if (name && name[0]) { - const bool symbols_ok = true; - return m_opaque_sp->GetImages().FindFunctions (ConstString(name), - name_type_mask, - symbols_ok, - append, - *sc_list); + TargetSP target_sp(GetSP()); + if (target_sp) + { + const bool symbols_ok = true; + return target_sp->GetImages().FindFunctions (ConstString(name), + name_type_mask, + symbols_ok, + append, + *sc_list); + } } return 0; } @@ -1218,9 +1272,10 @@ SBTarget::FindFunctions (const char *name, lldb::SBType SBTarget::FindFirstType (const char* type) { - if (type && m_opaque_sp) + TargetSP target_sp(GetSP()); + if (type && target_sp) { - size_t count = m_opaque_sp->GetImages().GetSize(); + size_t count = target_sp->GetImages().GetSize(); for (size_t idx = 0; idx < count; idx++) { SBType found_at_idx = GetModuleAtIndex(idx).FindFirstType(type); @@ -1238,9 +1293,10 @@ SBTarget::FindTypes (const char* type) SBTypeList retval; - if (type && m_opaque_sp) + TargetSP target_sp(GetSP()); + if (type && target_sp) { - ModuleList& images = m_opaque_sp->GetImages(); + ModuleList& images = target_sp->GetImages(); ConstString name_const(type); SymbolContext sc; TypeList type_list; @@ -1266,20 +1322,21 @@ SBTarget::FindGlobalVariables (const char *name, uint32_t max_matches) { SBValueList sb_value_list; - if (name && m_opaque_sp) + TargetSP target_sp(GetSP()); + if (name && target_sp) { VariableList variable_list; const bool append = true; - const uint32_t match_count = m_opaque_sp->GetImages().FindGlobalVariables (ConstString (name), - append, - max_matches, - variable_list); + const uint32_t match_count = target_sp->GetImages().FindGlobalVariables (ConstString (name), + append, + max_matches, + variable_list); if (match_count > 0) { - ExecutionContextScope *exe_scope = m_opaque_sp->GetProcessSP().get(); + ExecutionContextScope *exe_scope = target_sp->GetProcessSP().get(); if (exe_scope == NULL) - exe_scope = m_opaque_sp.get(); + exe_scope = target_sp.get(); ValueObjectList &value_object_list = sb_value_list.ref(); for (uint32_t i=0; iGetArchitecture(), + sb_instructions.SetDisassembler (Disassembler::DisassembleBytes (target_sp->GetArchitecture(), NULL, addr, buf, @@ -1333,8 +1391,8 @@ SBTarget::SetSectionLoadAddress (lldb::SBSection section, lldb::addr_t section_base_addr) { SBError sb_error; - - if (IsValid()) + TargetSP target_sp(GetSP()); + if (target_sp) { if (!section.IsValid()) { @@ -1342,7 +1400,7 @@ SBTarget::SetSectionLoadAddress (lldb::SBSection section, } else { - m_opaque_sp->GetSectionLoadList().SetSectionLoadAddress (section.GetSection(), section_base_addr); + target_sp->GetSectionLoadList().SetSectionLoadAddress (section.GetSection(), section_base_addr); } } else @@ -1357,7 +1415,8 @@ SBTarget::ClearSectionLoadAddress (lldb::SBSection section) { SBError sb_error; - if (IsValid()) + TargetSP target_sp(GetSP()); + if (target_sp) { if (!section.IsValid()) { @@ -1365,7 +1424,7 @@ SBTarget::ClearSectionLoadAddress (lldb::SBSection section) } else { - m_opaque_sp->GetSectionLoadList().SetSectionUnloaded (section.GetSection()); + target_sp->GetSectionLoadList().SetSectionUnloaded (section.GetSection()); } } else @@ -1381,15 +1440,13 @@ SBTarget::SetModuleLoadAddress (lldb::SBModule module, int64_t slide_offset) SBError sb_error; char path[PATH_MAX]; - if (IsValid()) + TargetSP target_sp(GetSP()); + if (target_sp) { - if (!module.IsValid()) + ModuleSP module_sp (module.GetSP()); + if (module_sp) { - sb_error.SetErrorStringWithFormat ("invalid module"); - } - else - { - ObjectFile *objfile = module->GetObjectFile(); + ObjectFile *objfile = module_sp->GetObjectFile(); if (objfile) { SectionList *section_list = objfile->GetSectionList(); @@ -1400,21 +1457,26 @@ SBTarget::SetModuleLoadAddress (lldb::SBModule module, int64_t slide_offset) { SectionSP section_sp (section_list->GetSectionAtIndex(sect_idx)); if (section_sp) - m_opaque_sp->GetSectionLoadList().SetSectionLoadAddress (section_sp.get(), section_sp->GetFileAddress() + slide_offset); + target_sp->GetSectionLoadList().SetSectionLoadAddress (section_sp.get(), section_sp->GetFileAddress() + slide_offset); } } else { - module->GetFileSpec().GetPath (path, sizeof(path)); + module_sp->GetFileSpec().GetPath (path, sizeof(path)); sb_error.SetErrorStringWithFormat ("no sections in object file '%s'", path); } } else { - module->GetFileSpec().GetPath (path, sizeof(path)); + module_sp->GetFileSpec().GetPath (path, sizeof(path)); sb_error.SetErrorStringWithFormat ("no object file for module '%s'", path); } } + else + { + sb_error.SetErrorStringWithFormat ("invalid module"); + } + } else { @@ -1429,15 +1491,13 @@ SBTarget::ClearModuleLoadAddress (lldb::SBModule module) SBError sb_error; char path[PATH_MAX]; - if (IsValid()) + TargetSP target_sp(GetSP()); + if (target_sp) { - if (!module.IsValid()) + ModuleSP module_sp (module.GetSP()); + if (module_sp) { - sb_error.SetErrorStringWithFormat ("invalid module"); - } - else - { - ObjectFile *objfile = module->GetObjectFile(); + ObjectFile *objfile = module_sp->GetObjectFile(); if (objfile) { SectionList *section_list = objfile->GetSectionList(); @@ -1448,21 +1508,25 @@ SBTarget::ClearModuleLoadAddress (lldb::SBModule module) { SectionSP section_sp (section_list->GetSectionAtIndex(sect_idx)); if (section_sp) - m_opaque_sp->GetSectionLoadList().SetSectionUnloaded (section_sp.get()); + target_sp->GetSectionLoadList().SetSectionUnloaded (section_sp.get()); } } else { - module->GetFileSpec().GetPath (path, sizeof(path)); + module_sp->GetFileSpec().GetPath (path, sizeof(path)); sb_error.SetErrorStringWithFormat ("no sections in object file '%s'", path); } } else { - module->GetFileSpec().GetPath (path, sizeof(path)); + module_sp->GetFileSpec().GetPath (path, sizeof(path)); sb_error.SetErrorStringWithFormat ("no object file for module '%s'", path); } } + else + { + sb_error.SetErrorStringWithFormat ("invalid module"); + } } else {