lldb::SBTarget and lldb::SBProcess are now thread hardened. They both still
contain shared pointers to the lldb_private::Target and lldb_private::Process
objects respectively as we won't want the target or process just going away.
Also cleaned up the lldb::SBModule to remove dangerous pointer accessors.
For any code the public API files, we should always be grabbing shared
pointers to any objects for the current class, and any other classes prior
to running code with them.
git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@149238 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/API/SBTarget.cpp b/source/API/SBTarget.cpp
index dc06e7c..376ed78 100644
--- a/source/API/SBTarget.cpp
+++ b/source/API/SBTarget.cpp
@@ -98,9 +98,10 @@
{
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 @@
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 @@
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 @@
{
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 @@
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 @@
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 @@
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 @@
{
// 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 @@
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 @@
{
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 @@
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 @@
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 @@
{
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 @@
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 @@
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 @@
{
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 @@
{
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 @@
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 @@
{
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
{
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 @@
{
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 @@
{
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 @@
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 @@
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 @@
{
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; i<match_count; ++i)
{
@@ -1305,14 +1362,15 @@
{
SBInstructionList sb_instructions;
- if (m_opaque_sp)
+ TargetSP target_sp(GetSP());
+ if (target_sp)
{
Address addr;
if (base_addr.get())
addr = *base_addr.get();
- sb_instructions.SetDisassembler (Disassembler::DisassembleBytes (m_opaque_sp->GetArchitecture(),
+ sb_instructions.SetDisassembler (Disassembler::DisassembleBytes (target_sp->GetArchitecture(),
NULL,
addr,
buf,
@@ -1333,8 +1391,8 @@
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 @@
}
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 @@
{
SBError sb_error;
- if (IsValid())
+ TargetSP target_sp(GetSP());
+ if (target_sp)
{
if (!section.IsValid())
{
@@ -1365,7 +1424,7 @@
}
else
{
- m_opaque_sp->GetSectionLoadList().SetSectionUnloaded (section.GetSection());
+ target_sp->GetSectionLoadList().SetSectionUnloaded (section.GetSection());
}
}
else
@@ -1381,15 +1440,13 @@
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 @@
{
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 @@
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 @@
{
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
{