[Lldb-commits] [lldb] r122262 - in /lldb/trunk: include/lldb/API/ include/lldb/Breakpoint/ include/lldb/Core/ include/lldb/Target/ source/API/ source/Core/ source/Target/
Greg Clayton
gclayton at apple.com
Mon Dec 20 12:49:23 PST 2010
Author: gclayton
Date: Mon Dec 20 14:49:23 2010
New Revision: 122262
URL: http://llvm.org/viewvc/llvm-project?rev=122262&view=rev
Log:
The LLDB API (lldb::SB*) is now thread safe!
Modified:
lldb/trunk/include/lldb/API/SBDebugger.h
lldb/trunk/include/lldb/API/SBProcess.h
lldb/trunk/include/lldb/API/SBTarget.h
lldb/trunk/include/lldb/API/SBValue.h
lldb/trunk/include/lldb/Breakpoint/BreakpointList.h
lldb/trunk/include/lldb/Core/ValueObject.h
lldb/trunk/include/lldb/Target/Target.h
lldb/trunk/source/API/SBAddress.cpp
lldb/trunk/source/API/SBBreakpoint.cpp
lldb/trunk/source/API/SBBreakpointLocation.cpp
lldb/trunk/source/API/SBCommandInterpreter.cpp
lldb/trunk/source/API/SBDebugger.cpp
lldb/trunk/source/API/SBFrame.cpp
lldb/trunk/source/API/SBFunction.cpp
lldb/trunk/source/API/SBProcess.cpp
lldb/trunk/source/API/SBSymbol.cpp
lldb/trunk/source/API/SBTarget.cpp
lldb/trunk/source/API/SBThread.cpp
lldb/trunk/source/API/SBValue.cpp
lldb/trunk/source/API/SBValueList.cpp
lldb/trunk/source/Core/ValueObject.cpp
lldb/trunk/source/Target/StackFrame.cpp
lldb/trunk/source/Target/Target.cpp
Modified: lldb/trunk/include/lldb/API/SBDebugger.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBDebugger.h?rev=122262&r1=122261&r2=122262&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBDebugger.h (original)
+++ lldb/trunk/include/lldb/API/SBDebugger.h Mon Dec 20 14:49:23 2010
@@ -111,9 +111,6 @@
lldb::SBTarget
GetSelectedTarget ();
- void
- UpdateSelectedThread (lldb::SBProcess &process);
-
lldb::SBSourceManager &
GetSourceManager ();
@@ -125,10 +122,10 @@
bool
GetUseExternalEditor ();
- bool
+ static bool
GetDefaultArchitecture (char *arch_name, size_t arch_name_len);
- bool
+ static bool
SetDefaultArchitecture (const char *arch_name);
lldb::ScriptLanguage
Modified: lldb/trunk/include/lldb/API/SBProcess.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBProcess.h?rev=122262&r1=122261&r2=122262&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBProcess.h (original)
+++ lldb/trunk/include/lldb/API/SBProcess.h Mon Dec 20 14:49:23 2010
@@ -111,17 +111,6 @@
lldb::SBError
Destroy ();
- lldb::pid_t
- AttachByPID (lldb::pid_t pid); // DEPRECATED
-
- // DEPRECATED: relocated to "SBProcess SBTarget::AttachToProcess (lldb::pid_t pid, lldb::SBError& error)"
- lldb::SBError
- Attach (lldb::pid_t pid);
-
- // DEPRECATED: relocated to "SBProcess SBTarget::AttachToProcess (const char *name, bool wait_for_launch, lldb::SBError& error)"
- lldb::SBError
- AttachByName (const char *name, bool wait_for_launch);
-
lldb::SBError
Continue ();
Modified: lldb/trunk/include/lldb/API/SBTarget.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBTarget.h?rev=122262&r1=122261&r2=122262&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBTarget.h (original)
+++ lldb/trunk/include/lldb/API/SBTarget.h Mon Dec 20 14:49:23 2010
@@ -52,13 +52,8 @@
IsValid() const;
lldb::SBProcess
- CreateProcess (); // DEPRECATED
-
- lldb::SBProcess
GetProcess ();
- // DEPRECATED in favor of the function below that contains an SBError as the
- // last parameter.
lldb::SBProcess
LaunchProcess (char const **argv,
char const **envp,
@@ -147,17 +142,6 @@
lldb::SBBroadcaster
GetBroadcaster () const;
- //void
- //Disassemble ();
-
- void
- Disassemble (lldb::addr_t start_address,
- lldb::addr_t end_address = LLDB_INVALID_ADDRESS,
- const char *module_name = NULL);
-
- void
- Disassemble (const char *function_name, const char *module_name = NULL);
-
#ifndef SWIG
bool
operator == (const lldb::SBTarget &rhs) const;
Modified: lldb/trunk/include/lldb/API/SBValue.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBValue.h?rev=122262&r1=122261&r2=122262&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBValue.h (original)
+++ lldb/trunk/include/lldb/API/SBValue.h Mon Dec 20 14:49:23 2010
@@ -85,9 +85,6 @@
uint32_t
GetNumChildren ();
- bool
- ValueIsStale ();
-
void *
GetOpaqueType();
Modified: lldb/trunk/include/lldb/Breakpoint/BreakpointList.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/BreakpointList.h?rev=122262&r1=122261&r2=122262&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Breakpoint/BreakpointList.h (original)
+++ lldb/trunk/include/lldb/Breakpoint/BreakpointList.h Mon Dec 20 14:49:23 2010
@@ -114,7 +114,11 @@
/// The number of elements.
//------------------------------------------------------------------
size_t
- GetSize() const { return m_breakpoints.size(); }
+ GetSize() const
+ {
+ Mutex::Locker locker(m_mutex);
+ return m_breakpoints.size();
+ }
//------------------------------------------------------------------
/// Removes the breakpoint given by \b breakID from this list.
Modified: lldb/trunk/include/lldb/Core/ValueObject.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObject.h?rev=122262&r1=122261&r2=122262&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ValueObject.h (original)
+++ lldb/trunk/include/lldb/Core/ValueObject.h Mon Dec 20 14:49:23 2010
@@ -207,7 +207,7 @@
CreateConstantValue (ExecutionContextScope *exe_scope, const ConstString &name);
virtual lldb::ValueObjectSP
- Dereference (ExecutionContextScope *exe_scope, Error &error);
+ Dereference (Error &error);
virtual lldb::ValueObjectSP
AddressOf (Error &error);
Modified: lldb/trunk/include/lldb/Target/Target.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Target.h?rev=122262&r1=122261&r2=122262&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Target.h (original)
+++ lldb/trunk/include/lldb/Target/Target.h Mon Dec 20 14:49:23 2010
@@ -173,6 +173,12 @@
public:
~Target();
+ Mutex &
+ GetAPIMutex ()
+ {
+ return m_mutex;
+ }
+
void
DeleteCurrentProcess ();
@@ -472,6 +478,7 @@
// Member variables.
//------------------------------------------------------------------
Debugger & m_debugger;
+ Mutex m_mutex; ///< An API mutex that is used by the lldb::SB* classes make the SB interface thread safe
ArchSpec m_arch_spec;
ModuleList m_images; ///< The list of images for this process (shared libraries and anything dynamically loaded).
SectionLoadList m_section_load_list;
Modified: lldb/trunk/source/API/SBAddress.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBAddress.cpp?rev=122262&r1=122261&r2=122262&view=diff
==============================================================================
--- lldb/trunk/source/API/SBAddress.cpp (original)
+++ lldb/trunk/source/API/SBAddress.cpp Mon Dec 20 14:49:23 2010
@@ -12,6 +12,8 @@
#include "lldb/API/SBStream.h"
#include "lldb/Core/Address.h"
#include "lldb/Core/Log.h"
+#include "lldb/Host/Mutex.h"
+#include "lldb/Target/Target.h"
using namespace lldb;
using namespace lldb_private;
@@ -89,19 +91,22 @@
{
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ lldb::addr_t addr = LLDB_INVALID_ADDRESS;
if (m_opaque_ap.get())
{
- lldb::addr_t addr = m_opaque_ap->GetLoadAddress (target.get());
- if (log)
- log->Printf ("SBAddress::GetLoadAddress (SBTarget(%p)) => 0x%llx", target.get(), addr);
- return addr;
+ Mutex::Locker api_locker (target->GetAPIMutex());
+ addr = m_opaque_ap->GetLoadAddress (target.get());
}
- else
+
+ if (log)
{
- if (log)
+ if (addr == LLDB_INVALID_ADDRESS)
log->Printf ("SBAddress::GetLoadAddress (SBTarget(%p)) => LLDB_INVALID_ADDRESS", target.get());
- return LLDB_INVALID_ADDRESS;
+ else
+ log->Printf ("SBAddress::GetLoadAddress (SBTarget(%p)) => 0x%llx", target.get(), addr);
}
+
+ return addr;
}
bool
Modified: lldb/trunk/source/API/SBBreakpoint.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBBreakpoint.cpp?rev=122262&r1=122261&r2=122262&view=diff
==============================================================================
--- lldb/trunk/source/API/SBBreakpoint.cpp (original)
+++ lldb/trunk/source/API/SBBreakpoint.cpp Mon Dec 20 14:49:23 2010
@@ -105,18 +105,19 @@
{
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ break_id_t break_id = LLDB_INVALID_BREAK_ID;
if (m_opaque_sp)
+ break_id = m_opaque_sp->GetID();
+
+ if (log)
{
- break_id_t break_id = m_opaque_sp->GetID();
- if (log)
+ if (break_id == LLDB_INVALID_BREAK_ID)
+ log->Printf ("SBBreakpoint(%p)::GetID () => LLDB_INVALID_BREAK_ID", m_opaque_sp.get());
+ else
log->Printf ("SBBreakpoint(%p)::GetID () => %u", m_opaque_sp.get(), break_id);
- return break_id;
}
- if (log)
- log->Printf ("SBBreakpoint(%p)::GetID () => LLDB_INVALID_BREAK_ID", m_opaque_sp.get());
-
- return LLDB_INVALID_BREAK_ID;
+ return break_id;
}
@@ -130,7 +131,10 @@
SBBreakpoint::ClearAllBreakpointSites ()
{
if (m_opaque_sp)
+ {
+ Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
m_opaque_sp->ClearAllBreakpointSites ();
+ }
}
SBBreakpointLocation
@@ -142,6 +146,7 @@
{
if (vm_addr != LLDB_INVALID_ADDRESS)
{
+ Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
Address address;
Target &target = m_opaque_sp->GetTarget();
if (target.GetSectionLoadList().ResolveLoadAddress (vm_addr, address) == false)
@@ -158,24 +163,22 @@
break_id_t
SBBreakpoint::FindLocationIDByAddress (addr_t vm_addr)
{
- break_id_t lldb_id = (break_id_t) 0;
+ break_id_t break_id = LLDB_INVALID_BREAK_ID;
- if (m_opaque_sp)
+ if (m_opaque_sp && vm_addr != LLDB_INVALID_ADDRESS)
{
- if (vm_addr != LLDB_INVALID_ADDRESS)
+ Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
+ Address address;
+ Target &target = m_opaque_sp->GetTarget();
+ if (target.GetSectionLoadList().ResolveLoadAddress (vm_addr, address) == false)
{
- Address address;
- Target &target = m_opaque_sp->GetTarget();
- if (target.GetSectionLoadList().ResolveLoadAddress (vm_addr, address) == false)
- {
- address.SetSection (NULL);
- address.SetOffset (vm_addr);
- }
- lldb_id = m_opaque_sp->FindLocationIDByAddress (address);
+ address.SetSection (NULL);
+ address.SetOffset (vm_addr);
}
+ break_id = m_opaque_sp->FindLocationIDByAddress (address);
}
- return lldb_id;
+ return break_id;
}
SBBreakpointLocation
@@ -184,7 +187,10 @@
SBBreakpointLocation sb_bp_location;
if (m_opaque_sp)
+ {
+ Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
sb_bp_location.SetLocation (m_opaque_sp->FindLocationByID (bp_loc_id));
+ }
return sb_bp_location;
}
@@ -195,7 +201,10 @@
SBBreakpointLocation sb_bp_location;
if (m_opaque_sp)
+ {
+ Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
sb_bp_location.SetLocation (m_opaque_sp->GetLocationAtIndex (index));
+ }
return sb_bp_location;
}
@@ -209,14 +218,20 @@
log->Printf ("SBBreakpoint(%p)::SetEnabled (enabled=%i)", m_opaque_sp.get(), enable);
if (m_opaque_sp)
+ {
+ Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
m_opaque_sp->SetEnabled (enable);
+ }
}
bool
SBBreakpoint::IsEnabled ()
{
if (m_opaque_sp)
+ {
+ Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
return m_opaque_sp->IsEnabled();
+ }
else
return false;
}
@@ -230,19 +245,31 @@
log->Printf ("SBBreakpoint(%p)::SetIgnoreCount (count=%u)", m_opaque_sp.get(), count);
if (m_opaque_sp)
+ {
+ Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
m_opaque_sp->SetIgnoreCount (count);
+ }
}
void
SBBreakpoint::SetCondition (const char *condition)
{
- m_opaque_sp->SetCondition (condition);
+ if (m_opaque_sp)
+ {
+ Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
+ m_opaque_sp->SetCondition (condition);
+ }
}
const char *
SBBreakpoint::GetCondition ()
{
- return m_opaque_sp->GetConditionText ();
+ if (m_opaque_sp)
+ {
+ Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
+ return m_opaque_sp->GetConditionText ();
+ }
+ return NULL;
}
uint32_t
@@ -250,7 +277,10 @@
{
uint32_t count = 0;
if (m_opaque_sp)
+ {
+ Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
count = m_opaque_sp->GetHitCount();
+ }
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
@@ -264,7 +294,10 @@
{
uint32_t count = 0;
if (m_opaque_sp)
+ {
+ Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
count = m_opaque_sp->GetIgnoreCount();
+ }
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
@@ -277,7 +310,10 @@
SBBreakpoint::SetThreadID (tid_t tid)
{
if (m_opaque_sp)
+ {
+ Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
m_opaque_sp->SetThreadID (tid);
+ }
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
log->Printf ("SBBreakpoint(%p)::SetThreadID (tid=0x%4.4x)", m_opaque_sp.get(), tid);
@@ -289,7 +325,10 @@
{
tid_t tid = LLDB_INVALID_THREAD_ID;
if (m_opaque_sp)
+ {
+ Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
tid = m_opaque_sp->GetThreadID();
+ }
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
@@ -304,7 +343,10 @@
if (log)
log->Printf ("SBBreakpoint(%p)::SetThreadIndex (%u)", m_opaque_sp.get(), index);
if (m_opaque_sp)
+ {
+ Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
m_opaque_sp->GetOptions()->GetThreadSpec()->SetIndex (index);
+ }
}
uint32_t
@@ -313,7 +355,8 @@
uint32_t thread_idx = UINT32_MAX;
if (m_opaque_sp)
{
- const ThreadSpec *thread_spec = m_opaque_sp->GetOptions()->GetThreadSpec();
+ Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
+ const ThreadSpec *thread_spec = m_opaque_sp->GetOptions()->GetThreadSpecNoCreate();
if (thread_spec != NULL)
thread_idx = thread_spec->GetIndex();
}
@@ -333,7 +376,10 @@
log->Printf ("SBBreakpoint(%p)::SetThreadName (%s)", m_opaque_sp.get(), thread_name);
if (m_opaque_sp)
+ {
+ Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
m_opaque_sp->GetOptions()->GetThreadSpec()->SetName (thread_name);
+ }
}
const char *
@@ -342,7 +388,8 @@
const char *name = NULL;
if (m_opaque_sp)
{
- const ThreadSpec *thread_spec = m_opaque_sp->GetOptions()->GetThreadSpec();
+ Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
+ const ThreadSpec *thread_spec = m_opaque_sp->GetOptions()->GetThreadSpecNoCreate();
if (thread_spec != NULL)
name = thread_spec->GetName();
}
@@ -360,7 +407,10 @@
if (log)
log->Printf ("SBBreakpoint(%p)::SetQueueName (%s)", m_opaque_sp.get(), queue_name);
if (m_opaque_sp)
+ {
+ Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
m_opaque_sp->GetOptions()->GetThreadSpec()->SetQueueName (queue_name);
+ }
}
const char *
@@ -369,7 +419,9 @@
const char *name = NULL;
if (m_opaque_sp)
{
- const ThreadSpec *thread_spec = m_opaque_sp->GetOptions()->GetThreadSpec();
+ Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
+ const ThreadSpec *thread_spec = m_opaque_sp->GetOptions()->GetThreadSpecNoCreate();
+ if (thread_spec)
name = thread_spec->GetQueueName();
}
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
@@ -384,7 +436,10 @@
{
size_t num_resolved = 0;
if (m_opaque_sp)
+ {
+ Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
num_resolved = m_opaque_sp->GetNumResolvedLocations();
+ }
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
log->Printf ("SBBreakpoint(%p)::GetNumResolvedLocations () => %zu", m_opaque_sp.get(), num_resolved);
@@ -396,7 +451,10 @@
{
size_t num_locs = 0;
if (m_opaque_sp)
+ {
+ Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
num_locs = m_opaque_sp->GetNumLocations();
+ }
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
log->Printf ("SBBreakpoint(%p)::GetNumLocations () => %zu", m_opaque_sp.get(), num_locs);
@@ -408,6 +466,7 @@
{
if (m_opaque_sp)
{
+ Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
s.Printf("SBBreakpoint: id = %i, ", m_opaque_sp->GetID());
m_opaque_sp->GetResolverDescription (s.get());
m_opaque_sp->GetFilterDescription (s.get());
@@ -465,6 +524,7 @@
if (m_opaque_sp.get())
{
+ Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
BatonSP baton_sp(new SBBreakpointCallbackBaton (callback, baton));
m_opaque_sp->SetCallback (SBBreakpoint::PrivateBreakpointHitCallback, baton_sp, false);
}
Modified: lldb/trunk/source/API/SBBreakpointLocation.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBBreakpointLocation.cpp?rev=122262&r1=122261&r2=122262&view=diff
==============================================================================
--- lldb/trunk/source/API/SBBreakpointLocation.cpp (original)
+++ lldb/trunk/source/API/SBBreakpointLocation.cpp Mon Dec 20 14:49:23 2010
@@ -20,6 +20,7 @@
#include "lldb/Core/Log.h"
#include "lldb/Core/Stream.h"
#include "lldb/Core/StreamFile.h"
+#include "lldb/Target/Target.h"
#include "lldb/Target/ThreadSpec.h"
using namespace lldb;
@@ -76,6 +77,7 @@
if (m_opaque_sp)
{
+ Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex());
ret_addr = m_opaque_sp->GetLoadAddress();
}
@@ -87,6 +89,7 @@
{
if (m_opaque_sp)
{
+ Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex());
m_opaque_sp->SetEnabled (enabled);
}
}
@@ -95,7 +98,10 @@
SBBreakpointLocation::IsEnabled ()
{
if (m_opaque_sp)
+ {
+ Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex());
return m_opaque_sp->IsEnabled();
+ }
else
return false;
}
@@ -104,7 +110,10 @@
SBBreakpointLocation::GetIgnoreCount ()
{
if (m_opaque_sp)
+ {
+ Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex());
return m_opaque_sp->GetIgnoreCount();
+ }
else
return 0;
}
@@ -113,56 +122,79 @@
SBBreakpointLocation::SetIgnoreCount (uint32_t n)
{
if (m_opaque_sp)
+ {
+ Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex());
m_opaque_sp->SetIgnoreCount (n);
+ }
}
void
SBBreakpointLocation::SetCondition (const char *condition)
{
- m_opaque_sp->SetCondition (condition);
+ if (m_opaque_sp)
+ {
+ Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex());
+ m_opaque_sp->SetCondition (condition);
+ }
}
const char *
SBBreakpointLocation::GetCondition ()
{
- return m_opaque_sp->GetConditionText ();
+ if (m_opaque_sp)
+ {
+ Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex());
+ return m_opaque_sp->GetConditionText ();
+ }
+ return NULL;
}
void
SBBreakpointLocation::SetThreadID (tid_t thread_id)
{
if (m_opaque_sp)
+ {
+ Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex());
m_opaque_sp->SetThreadID (thread_id);
+ }
}
tid_t
SBBreakpointLocation::GetThreadID ()
{
- tid_t sb_thread_id = (lldb::tid_t) LLDB_INVALID_THREAD_ID;
+ tid_t tid = LLDB_INVALID_THREAD_ID;
if (m_opaque_sp)
- sb_thread_id = m_opaque_sp->GetLocationOptions()->GetThreadSpecNoCreate()->GetTID();
- return sb_thread_id;
+ {
+ Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex());
+ const ThreadSpec *thread_spec = m_opaque_sp->GetLocationOptions()->GetThreadSpecNoCreate();
+ if (thread_spec)
+ tid = thread_spec->GetTID();
+ }
+ return tid;
}
void
SBBreakpointLocation::SetThreadIndex (uint32_t index)
{
if (m_opaque_sp)
+ {
+ Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex());
m_opaque_sp->GetLocationOptions()->GetThreadSpec()->SetIndex (index);
+ }
}
uint32_t
SBBreakpointLocation::GetThreadIndex() const
{
+ uint32_t thread_idx = UINT32_MAX;
if (m_opaque_sp)
{
+ Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex());
const ThreadSpec *thread_spec = m_opaque_sp->GetOptionsNoCreate()->GetThreadSpecNoCreate();
- if (thread_spec == NULL)
- return 0;
- else
- return thread_spec->GetIndex();
+ if (thread_spec)
+ thread_idx = thread_spec->GetIndex();
}
- return 0;
+ return thread_idx;
}
@@ -170,7 +202,10 @@
SBBreakpointLocation::SetThreadName (const char *thread_name)
{
if (m_opaque_sp)
+ {
+ Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex());
m_opaque_sp->GetLocationOptions()->GetThreadSpec()->SetName (thread_name);
+ }
}
const char *
@@ -178,10 +213,9 @@
{
if (m_opaque_sp)
{
+ Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex());
const ThreadSpec *thread_spec = m_opaque_sp->GetOptionsNoCreate()->GetThreadSpecNoCreate();
- if (thread_spec == NULL)
- return NULL;
- else
+ if (thread_spec)
return thread_spec->GetName();
}
return NULL;
@@ -191,7 +225,10 @@
SBBreakpointLocation::SetQueueName (const char *queue_name)
{
if (m_opaque_sp)
+ {
+ Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex());
m_opaque_sp->GetLocationOptions()->GetThreadSpec()->SetQueueName (queue_name);
+ }
}
const char *
@@ -199,10 +236,9 @@
{
if (m_opaque_sp)
{
+ Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex());
const ThreadSpec *thread_spec = m_opaque_sp->GetOptionsNoCreate()->GetThreadSpecNoCreate();
- if (thread_spec == NULL)
- return NULL;
- else
+ if (thread_spec)
return thread_spec->GetQueueName();
}
return NULL;
@@ -212,18 +248,17 @@
SBBreakpointLocation::IsResolved ()
{
if (m_opaque_sp)
+ {
+ Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex());
return m_opaque_sp->IsResolved();
- else
- return false;
+ }
+ return false;
}
void
SBBreakpointLocation::SetLocation (const lldb::BreakpointLocationSP &break_loc_sp)
{
- if (m_opaque_sp)
- {
- // Uninstall the callbacks?
- }
+ // Uninstall the callbacks?
m_opaque_sp = break_loc_sp;
}
@@ -232,6 +267,7 @@
{
if (m_opaque_sp)
{
+ Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex());
description.ref();
m_opaque_sp->GetDescription (description.get(), level);
description.get()->EOL();
@@ -252,7 +288,10 @@
SBBreakpoint sb_bp;
if (m_opaque_sp)
- *sb_bp = m_opaque_sp->GetBreakpoint ().GetSP();
+ {
+ Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex());
+ *sb_bp = m_opaque_sp->GetBreakpoint ().GetSP();
+ }
if (log)
{
Modified: lldb/trunk/source/API/SBCommandInterpreter.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBCommandInterpreter.cpp?rev=122262&r1=122261&r2=122262&view=diff
==============================================================================
--- lldb/trunk/source/API/SBCommandInterpreter.cpp (original)
+++ lldb/trunk/source/API/SBCommandInterpreter.cpp Mon Dec 20 14:49:23 2010
@@ -91,6 +91,10 @@
result.Clear();
if (m_opaque_ptr)
{
+ TargetSP target_sp(m_opaque_ptr->GetDebugger().GetSelectedTarget());
+ Mutex::Locker api_locker;
+ if (target_sp)
+ api_locker.Reset(target_sp->GetAPIMutex().GetMutex());
m_opaque_ptr->HandleCommand (command_line, add_to_history, result.ref());
}
else
@@ -163,10 +167,12 @@
SBProcess process;
if (m_opaque_ptr)
{
- Debugger &debugger = m_opaque_ptr->GetDebugger();
- Target *target = debugger.GetSelectedTarget().get();
- if (target)
- process.SetProcess(target->GetProcessSP());
+ TargetSP target_sp(m_opaque_ptr->GetDebugger().GetSelectedTarget());
+ if (target_sp)
+ {
+ Mutex::Locker api_locker(target_sp->GetAPIMutex());
+ process.SetProcess(target_sp->GetProcessSP());
+ }
}
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
@@ -229,6 +235,10 @@
result.Clear();
if (m_opaque_ptr)
{
+ TargetSP target_sp(m_opaque_ptr->GetDebugger().GetSelectedTarget());
+ Mutex::Locker api_locker;
+ if (target_sp)
+ api_locker.Reset(target_sp->GetAPIMutex().GetMutex());
m_opaque_ptr->SourceInitFile (false, result.ref());
}
else
@@ -250,6 +260,10 @@
result.Clear();
if (m_opaque_ptr)
{
+ TargetSP target_sp(m_opaque_ptr->GetDebugger().GetSelectedTarget());
+ Mutex::Locker api_locker;
+ if (target_sp)
+ api_locker.Reset(target_sp->GetAPIMutex().GetMutex());
m_opaque_ptr->SourceInitFile (true, result.ref());
}
else
Modified: lldb/trunk/source/API/SBDebugger.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBDebugger.cpp?rev=122262&r1=122261&r2=122262&view=diff
==============================================================================
--- lldb/trunk/source/API/SBDebugger.cpp (original)
+++ lldb/trunk/source/API/SBDebugger.cpp Mon Dec 20 14:49:23 2010
@@ -216,6 +216,11 @@
{
if (m_opaque_sp)
{
+ TargetSP target_sp (m_opaque_sp->GetSelectedTarget());
+ Mutex::Locker api_locker;
+ if (target_sp)
+ api_locker.Reset(target_sp->GetAPIMutex().GetMutex());
+
SBCommandInterpreter sb_interpreter(GetCommandInterpreter ());
SBCommandReturnObject result;
@@ -262,110 +267,41 @@
void
SBDebugger::HandleProcessEvent (const SBProcess &process, const SBEvent &event, FILE *out, FILE *err)
{
- const uint32_t event_type = event.GetType();
- char stdio_buffer[1024];
- size_t len;
-
- if (event_type & Process::eBroadcastBitSTDOUT)
- {
- while ((len = process.GetSTDOUT (stdio_buffer, sizeof (stdio_buffer))) > 0)
- if (out != NULL)
- ::fwrite (stdio_buffer, 1, len, out);
- }
- else if (event_type & Process::eBroadcastBitSTDERR)
- {
- while ((len = process.GetSTDERR (stdio_buffer, sizeof (stdio_buffer))) > 0)
- if (out != NULL)
- ::fwrite (stdio_buffer, 1, len, out);
- }
- else if (event_type & Process::eBroadcastBitStateChanged)
- {
- // Drain any stdout messages.
- while ((len = process.GetSTDOUT (stdio_buffer, sizeof (stdio_buffer))) > 0)
- if (out != NULL)
- ::fwrite (stdio_buffer, 1, len, out);
-
- // Drain any stderr messages.
- while ((len = process.GetSTDERR (stdio_buffer, sizeof (stdio_buffer))) > 0)
- if (out != NULL)
- ::fwrite (stdio_buffer, 1, len, out);
-
- StateType event_state = SBProcess::GetStateFromEvent (event);
-
- if (event_state == eStateInvalid)
- return;
-
- bool is_stopped = StateIsStoppedState (event_state);
- if (!is_stopped)
- process.ReportEventState (event, out);
- }
-}
+ if (!process.IsValid())
+ return;
-void
-SBDebugger::UpdateSelectedThread (SBProcess &process)
-{
- if (process.IsValid())
- {
- SBThread curr_thread = process.GetSelectedThread ();
- SBThread thread;
- StopReason curr_thread_stop_reason = eStopReasonInvalid;
- if (curr_thread.IsValid())
- {
- if (curr_thread.GetStopReason() != eStopReasonInvalid)
- curr_thread_stop_reason = curr_thread.GetStopReason ();
- }
+ const uint32_t event_type = event.GetType();
+ char stdio_buffer[1024];
+ size_t len;
- if (! curr_thread.IsValid()
- || curr_thread_stop_reason == eStopReasonInvalid
- || curr_thread_stop_reason == eStopReasonNone)
- {
- // Prefer a thread that has just completed its plan over another thread as current thread.
- SBThread plan_thread;
- SBThread other_thread;
- const size_t num_threads = process.GetNumThreads ();
- size_t i;
- for (i = 0; i < num_threads; ++i)
- {
- thread = process.GetThreadAtIndex(i);
- if (thread.GetStopReason () != eStopReasonInvalid)
- {
- switch (thread.GetStopReason ())
- {
- default:
- case eStopReasonInvalid:
- case eStopReasonNone:
- break;
-
- case eStopReasonTrace:
- case eStopReasonBreakpoint:
- case eStopReasonWatchpoint:
- case eStopReasonSignal:
- case eStopReasonException:
- if (! other_thread.IsValid())
- other_thread = thread;
- break;
- case eStopReasonPlanComplete:
- if (! plan_thread.IsValid())
- plan_thread = thread;
- break;
- }
- }
- }
- if (plan_thread.IsValid())
- process.SetSelectedThreadByID (plan_thread.GetThreadID());
- else if (other_thread.IsValid())
- process.SetSelectedThreadByID (other_thread.GetThreadID());
- else
- {
- if (curr_thread.IsValid())
- thread = curr_thread;
- else
- thread = process.GetThreadAtIndex(0);
-
- if (thread.IsValid())
- process.SetSelectedThreadByID (thread.GetThreadID());
- }
- }
+ Mutex::Locker api_locker (process.GetTarget()->GetAPIMutex());
+
+ if (event_type & (Process::eBroadcastBitSTDOUT | Process::eBroadcastBitStateChanged))
+ {
+ // Drain stdout when we stop just in case we have any bytes
+ while ((len = process.GetSTDOUT (stdio_buffer, sizeof (stdio_buffer))) > 0)
+ if (out != NULL)
+ ::fwrite (stdio_buffer, 1, len, out);
+ }
+
+ if (event_type & (Process::eBroadcastBitSTDERR | Process::eBroadcastBitStateChanged))
+ {
+ // Drain stderr when we stop just in case we have any bytes
+ while ((len = process.GetSTDERR (stdio_buffer, sizeof (stdio_buffer))) > 0)
+ if (err != NULL)
+ ::fwrite (stdio_buffer, 1, len, err);
+ }
+
+ if (event_type & Process::eBroadcastBitStateChanged)
+ {
+ StateType event_state = SBProcess::GetStateFromEvent (event);
+
+ if (event_state == eStateInvalid)
+ return;
+
+ bool is_stopped = StateIsStoppedState (event_state);
+ if (!is_stopped)
+ process.ReportEventState (event, out);
}
}
@@ -415,6 +351,7 @@
ScriptLanguage
SBDebugger::GetScriptingLanguage (const char *script_language_name)
{
+
return Args::StringToScriptLanguage (script_language_name,
eScriptLanguageDefault,
NULL);
@@ -582,7 +519,10 @@
{
SBTarget sb_target;
if (m_opaque_sp)
+ {
+ // No need to lock, the target list is thread safe
sb_target.reset(m_opaque_sp->GetTargetList().GetTargetAtIndex (idx));
+ }
return sb_target;
}
@@ -591,7 +531,10 @@
{
SBTarget sb_target;
if (m_opaque_sp)
+ {
+ // No need to lock, the target list is thread safe
sb_target.reset(m_opaque_sp->GetTargetList().FindTargetWithProcessID (pid));
+ }
return sb_target;
}
@@ -601,6 +544,7 @@
SBTarget sb_target;
if (m_opaque_sp && filename && filename[0])
{
+ // No need to lock, the target list is thread safe
ArchSpec arch;
if (arch_name)
arch.SetArch(arch_name);
@@ -615,7 +559,10 @@
{
SBTarget sb_target;
if (m_opaque_sp)
+ {
+ // No need to lock, the target list is thread safe
sb_target.reset(m_opaque_sp->GetTargetList().FindTargetWithProcess (process_sp.get()));
+ }
return sb_target;
}
@@ -624,7 +571,10 @@
SBDebugger::GetNumTargets ()
{
if (m_opaque_sp)
+ {
+ // No need to lock, the target list is thread safe
return m_opaque_sp->GetTargetList().GetNumTargets ();
+ }
return 0;
}
@@ -635,7 +585,10 @@
SBTarget sb_target;
if (m_opaque_sp)
+ {
+ // No need to lock, the target list is thread safe
sb_target.reset(m_opaque_sp->GetTargetList().GetSelectedTarget ());
+ }
if (log)
{
@@ -685,6 +638,10 @@
if (m_opaque_sp && reader.IsValid())
{
+ TargetSP target_sp (m_opaque_sp->GetSelectedTarget());
+ Mutex::Locker api_locker;
+ if (target_sp)
+ api_locker.Reset(target_sp->GetAPIMutex().GetMutex());
InputReaderSP reader_sp(*reader);
m_opaque_sp->PushInputReader (reader_sp);
}
@@ -713,6 +670,7 @@
SBDebugger
SBDebugger::FindDebuggerWithID (int id)
{
+ // No need to lock, the debugger list is thread safe
SBDebugger sb_debugger;
lldb::DebuggerSP debugger_sp = Debugger::FindDebuggerWithID (id);
if (debugger_sp)
@@ -816,19 +774,17 @@
SBDebugger::SetScriptLanguage (lldb::ScriptLanguage script_lang)
{
if (m_opaque_sp)
+ {
m_opaque_sp->SetScriptLanguage (script_lang);
+ }
}
-
-
-
bool
SBDebugger::SetUseExternalEditor (bool value)
{
if (m_opaque_sp)
return m_opaque_sp->SetUseExternalEditor (value);
- else
- return false;
+ return false;
}
bool
@@ -836,8 +792,7 @@
{
if (m_opaque_sp)
return m_opaque_sp->GetUseExternalEditor ();
- else
- return false;
+ return false;
}
bool
Modified: lldb/trunk/source/API/SBFrame.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBFrame.cpp?rev=122262&r1=122261&r2=122262&view=diff
==============================================================================
--- lldb/trunk/source/API/SBFrame.cpp (original)
+++ lldb/trunk/source/API/SBFrame.cpp Mon Dec 20 14:49:23 2010
@@ -109,7 +109,10 @@
SBSymbolContext sb_sym_ctx;
if (m_opaque_sp)
+ {
+ Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex());
sb_sym_ctx.SetSymbolContext(&m_opaque_sp->GetSymbolContext (resolve_scope));
+ }
LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
@@ -124,7 +127,10 @@
{
SBModule sb_module;
if (m_opaque_sp)
+ {
+ Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex());
*sb_module = m_opaque_sp->GetSymbolContext (eSymbolContextModule).module_sp;
+ }
LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
@@ -139,7 +145,10 @@
{
SBCompileUnit sb_comp_unit;
if (m_opaque_sp)
+ {
+ Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex());
sb_comp_unit.reset (m_opaque_sp->GetSymbolContext (eSymbolContextCompUnit).comp_unit);
+ }
LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
log->Printf ("SBFrame(%p)::GetModule () => SBCompileUnit(%p)",
@@ -153,7 +162,10 @@
{
SBFunction sb_function;
if (m_opaque_sp)
+ {
+ Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex());
sb_function.reset(m_opaque_sp->GetSymbolContext (eSymbolContextFunction).function);
+ }
LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
log->Printf ("SBFrame(%p)::GetFunction () => SBFunction(%p)",
@@ -167,7 +179,10 @@
{
SBSymbol sb_symbol;
if (m_opaque_sp)
+ {
+ Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex());
sb_symbol.reset(m_opaque_sp->GetSymbolContext (eSymbolContextSymbol).symbol);
+ }
LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
log->Printf ("SBFrame(%p)::GetSymbol () => SBSymbol(%p)",
@@ -180,7 +195,10 @@
{
SBBlock sb_block;
if (m_opaque_sp)
+ {
+ Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex());
sb_block.reset (m_opaque_sp->GetSymbolContext (eSymbolContextBlock).block);
+ }
LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
log->Printf ("SBFrame(%p)::GetBlock () => SBBlock(%p)",
@@ -193,7 +211,10 @@
{
SBBlock sb_block;
if (m_opaque_sp)
+ {
+ Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex());
sb_block.reset(m_opaque_sp->GetFrameBlock ());
+ }
LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
log->Printf ("SBFrame(%p)::GetFrameBlock () => SBBlock(%p)",
@@ -206,7 +227,10 @@
{
SBLineEntry sb_line_entry;
if (m_opaque_sp)
+ {
+ Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex());
sb_line_entry.SetLineEntry (m_opaque_sp->GetSymbolContext (eSymbolContextLineEntry).line_entry);
+ }
LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
log->Printf ("SBFrame(%p)::GetLineEntry () => SBLineEntry(%p)",
@@ -231,7 +255,10 @@
{
addr_t addr = LLDB_INVALID_ADDRESS;
if (m_opaque_sp)
+ {
+ Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex());
addr = m_opaque_sp->GetFrameCodeAddress().GetLoadAddress (&m_opaque_sp->GetThread().GetProcess().GetTarget());
+ }
LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
@@ -245,7 +272,10 @@
{
bool ret_val = false;
if (m_opaque_sp)
+ {
+ Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex());
ret_val = m_opaque_sp->GetRegisterContext()->SetPC (new_pc);
+ }
LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
@@ -260,7 +290,10 @@
{
addr_t addr = LLDB_INVALID_ADDRESS;
if (m_opaque_sp)
+ {
+ Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex());
addr = m_opaque_sp->GetRegisterContext()->GetSP();
+ }
LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
log->Printf ("SBFrame(%p)::GetSP () => 0x%llx", m_opaque_sp.get(), addr);
@@ -274,7 +307,10 @@
{
addr_t addr = LLDB_INVALID_ADDRESS;
if (m_opaque_sp)
+ {
+ Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex());
addr = m_opaque_sp->GetRegisterContext()->GetFP();
+ }
LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
@@ -288,7 +324,10 @@
{
SBAddress sb_addr;
if (m_opaque_sp)
+ {
+ Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex());
sb_addr.SetAddress (&m_opaque_sp->GetFrameCodeAddress());
+ }
LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
log->Printf ("SBFrame(%p)::GetPCAddress () => SBAddress(%p)", m_opaque_sp.get(), sb_addr.get());
@@ -308,7 +347,7 @@
if (m_opaque_sp && name && name[0])
{
VariableList variable_list;
-
+ Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex());
SymbolContext sc (m_opaque_sp->GetSymbolContext (eSymbolContextBlock));
if (sc.block)
@@ -346,6 +385,7 @@
SBValue sb_value;
if (m_opaque_sp && name && name[0])
{
+ Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex());
switch (value_type)
{
@@ -479,7 +519,10 @@
SBThread sb_thread;
if (m_opaque_sp)
+ {
+ Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex());
sb_thread.SetThread (m_opaque_sp->GetThread().GetSP());
+ }
if (log)
{
@@ -497,7 +540,10 @@
{
const char *disassembly = NULL;
if (m_opaque_sp)
+ {
+ Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex());
disassembly = m_opaque_sp->Disassemble();
+ }
LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
@@ -526,8 +572,14 @@
SBValueList value_list;
if (m_opaque_sp)
{
+
size_t i;
- VariableList *variable_list = m_opaque_sp->GetVariableList(true);
+ VariableList *variable_list = NULL;
+ // Scope for locker
+ {
+ Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex());
+ variable_list = m_opaque_sp->GetVariableList(true);
+ }
if (variable_list)
{
const size_t num_variables = variable_list->GetSize();
@@ -587,6 +639,7 @@
SBValueList value_list;
if (m_opaque_sp)
{
+ Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex());
RegisterContext *reg_ctx = m_opaque_sp->GetRegisterContext();
if (reg_ctx)
{
@@ -609,6 +662,7 @@
{
if (m_opaque_sp)
{
+ Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex());
Stream &s = description.ref();
m_opaque_sp->DumpUsingSettingsFormat (&s);
}
@@ -621,6 +675,8 @@
SBValue
SBFrame::EvaluateExpression (const char *expr)
{
+ Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex());
+
LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
LogSP expr_log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
Modified: lldb/trunk/source/API/SBFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBFunction.cpp?rev=122262&r1=122261&r2=122262&view=diff
==============================================================================
--- lldb/trunk/source/API/SBFunction.cpp (original)
+++ lldb/trunk/source/API/SBFunction.cpp Mon Dec 20 14:49:23 2010
@@ -125,9 +125,11 @@
SBInstructionList sb_instructions;
if (m_opaque_ptr)
{
+ Mutex::Locker api_locker;
ExecutionContext exe_ctx;
if (target.IsValid())
{
+ api_locker.Reset (target->GetAPIMutex().GetMutex());
target->CalculateExecutionContext (exe_ctx);
exe_ctx.process = target->GetProcessSP().get();
}
Modified: lldb/trunk/source/API/SBProcess.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBProcess.cpp?rev=122262&r1=122261&r2=122262&view=diff
==============================================================================
--- lldb/trunk/source/API/SBProcess.cpp (original)
+++ lldb/trunk/source/API/SBProcess.cpp Mon Dec 20 14:49:23 2010
@@ -104,6 +104,7 @@
uint32_t num_threads = 0;
if (m_opaque_sp)
{
+ Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
const bool can_update = true;
num_threads = m_opaque_sp->GetThreadList().GetSize(can_update);
}
@@ -121,7 +122,10 @@
SBThread sb_thread;
if (m_opaque_sp)
+ {
+ Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
sb_thread.SetThread (m_opaque_sp->GetThreadList().GetSelectedThread());
+ }
if (log)
{
@@ -153,7 +157,7 @@
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
size_t ret_val = 0;
- if (m_opaque_sp != NULL)
+ if (m_opaque_sp)
{
Error error;
ret_val = m_opaque_sp->PutSTDIN (src, src_len, error);
@@ -173,7 +177,7 @@
SBProcess::GetSTDOUT (char *dst, size_t dst_len) const
{
size_t bytes_read = 0;
- if (m_opaque_sp != NULL)
+ if (m_opaque_sp)
{
Error error;
bytes_read = m_opaque_sp->GetSTDOUT (dst, dst_len, error);
@@ -191,7 +195,7 @@
SBProcess::GetSTDERR (char *dst, size_t dst_len) const
{
size_t bytes_read = 0;
- if (m_opaque_sp != NULL)
+ if (m_opaque_sp)
{
Error error;
bytes_read = m_opaque_sp->GetSTDERR (dst, dst_len, error);
@@ -211,7 +215,7 @@
if (out == NULL)
return;
- if (m_opaque_sp != NULL)
+ if (m_opaque_sp)
{
const StateType event_state = SBProcess::GetStateFromEvent (event);
char message[1024];
@@ -229,7 +233,7 @@
void
SBProcess::AppendEventStateReport (const SBEvent &event, SBCommandReturnObject &result)
{
- if (m_opaque_sp != NULL)
+ if (m_opaque_sp)
{
const StateType event_state = SBProcess::GetStateFromEvent (event);
char message[1024];
@@ -246,8 +250,11 @@
bool
SBProcess::SetSelectedThread (const SBThread &thread)
{
- if (m_opaque_sp != NULL)
+ if (m_opaque_sp)
+ {
+ Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
return m_opaque_sp->GetThreadList().SetSelectedThreadByID (thread.GetThreadID());
+ }
return false;
}
@@ -257,8 +264,11 @@
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
bool ret_val = false;
- if (m_opaque_sp != NULL)
+ if (m_opaque_sp)
+ {
+ Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
ret_val = m_opaque_sp->GetThreadList().SetSelectedThreadByID (tid);
+ }
if (log)
log->Printf ("SBProcess(%p)::SetSelectedThreadByID (tid=0x%4.4x) => %s",
@@ -274,7 +284,10 @@
SBThread thread;
if (m_opaque_sp)
+ {
+ Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
thread.SetThread (m_opaque_sp->GetThreadList().GetThreadAtIndex(index));
+ }
if (log)
{
@@ -290,8 +303,11 @@
{
StateType ret_val = eStateInvalid;
- if (m_opaque_sp != NULL)
+ if (m_opaque_sp)
+ {
+ Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
ret_val = m_opaque_sp->GetState();
+ }
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
@@ -308,7 +324,10 @@
{
int exit_status = 0;
if (m_opaque_sp)
+ {
+ Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
exit_status = m_opaque_sp->GetExitStatus ();
+ }
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
log->Printf ("SBProcess(%p)::GetExitStatus () => %i (0x%8.8x)",
@@ -321,8 +340,11 @@
SBProcess::GetExitDescription ()
{
const char *exit_desc = NULL;
- if (m_opaque_sp != NULL)
+ if (m_opaque_sp)
+ {
+ Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
exit_desc = m_opaque_sp->GetExitDescription ();
+ }
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
log->Printf ("SBProcess(%p)::GetExitDescription () => %s",
@@ -361,6 +383,8 @@
SBError
SBProcess::Continue ()
{
+ Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
+
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
log->Printf ("SBProcess(%p)::Continue ()...", m_opaque_sp.get());
@@ -397,6 +421,8 @@
SBError
SBProcess::Destroy ()
{
+ Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
+
SBError sb_error;
if (m_opaque_sp)
sb_error.SetError(m_opaque_sp->Destroy());
@@ -418,10 +444,12 @@
SBError
SBProcess::Stop ()
{
-
SBError sb_error;
if (IsValid())
+ {
+ Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
sb_error.SetError (m_opaque_sp->Halt());
+ }
else
sb_error.SetErrorString ("SBProcess is invalid");
@@ -442,10 +470,12 @@
SBError
SBProcess::Kill ()
{
-
SBError sb_error;
if (m_opaque_sp)
+ {
+ Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
sb_error.SetError (m_opaque_sp->Destroy());
+ }
else
sb_error.SetErrorString ("SBProcess is invalid");
@@ -463,43 +493,15 @@
return sb_error;
}
-
-SBError
-SBProcess::AttachByName (const char *name, bool wait_for_launch) // DEPRECATED
-{
- SBError sb_error;
- if (m_opaque_sp)
- sb_error.SetError (m_opaque_sp->Attach (name, wait_for_launch));
- else
- sb_error.SetErrorString ("SBProcess is invalid");
- return sb_error;
-}
-
-lldb::pid_t
-SBProcess::AttachByPID (lldb::pid_t attach_pid) // DEPRECATED
-{
- Attach (attach_pid);
- return GetProcessID();
-}
-
-
-SBError
-SBProcess::Attach (lldb::pid_t attach_pid) // DEPRECATED
-{
- SBError sb_error;
- if (m_opaque_sp)
- sb_error.SetError (m_opaque_sp->Attach (attach_pid));
- else
- sb_error.SetErrorString ("SBProcess is invalid");
- return sb_error;
-}
-
SBError
SBProcess::Detach ()
{
SBError sb_error;
if (m_opaque_sp)
+ {
+ Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
sb_error.SetError (m_opaque_sp->Detach());
+ }
else
sb_error.SetErrorString ("SBProcess is invalid");
@@ -511,7 +513,10 @@
{
SBError sb_error;
if (m_opaque_sp)
+ {
+ Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
sb_error.SetError (m_opaque_sp->Signal (signo));
+ }
else
sb_error.SetErrorString ("SBProcess is invalid");
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
@@ -533,7 +538,10 @@
{
SBThread sb_thread;
if (m_opaque_sp)
+ {
+ Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
sb_thread.SetThread (m_opaque_sp->GetThreadList().FindThreadByID ((tid_t) tid));
+ }
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
@@ -612,9 +620,10 @@
sb_error.get());
}
- if (IsValid())
+ if (m_opaque_sp)
{
Error error;
+ Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
bytes_read = m_opaque_sp->ReadMemory (addr, dst, dst_len, error);
sb_error.SetError (error);
}
@@ -656,9 +665,10 @@
sb_error.get());
}
- if (IsValid())
+ if (m_opaque_sp)
{
Error error;
+ Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
bytes_written = m_opaque_sp->WriteMemory (addr, src, src_len, error);
sb_error.SetError (error);
}
@@ -716,7 +726,10 @@
SBProcess::LoadImage (lldb::SBFileSpec &sb_image_spec, lldb::SBError &sb_error)
{
if (m_opaque_sp)
+ {
+ Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
return m_opaque_sp->LoadImage (*sb_image_spec, sb_error.ref());
+ }
return LLDB_INVALID_IMAGE_TOKEN;
}
@@ -725,7 +738,10 @@
{
lldb::SBError sb_error;
if (m_opaque_sp)
+ {
+ Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
sb_error.SetError (m_opaque_sp->UnloadImage (image_token));
+ }
else
sb_error.SetErrorString("invalid process");
return sb_error;
Modified: lldb/trunk/source/API/SBSymbol.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBSymbol.cpp?rev=122262&r1=122261&r2=122262&view=diff
==============================================================================
--- lldb/trunk/source/API/SBSymbol.cpp (original)
+++ lldb/trunk/source/API/SBSymbol.cpp Mon Dec 20 14:49:23 2010
@@ -120,9 +120,13 @@
SBInstructionList sb_instructions;
if (m_opaque_ptr)
{
+ Mutex::Locker api_locker;
ExecutionContext exe_ctx;
if (target.IsValid())
+ {
+ api_locker.Reset (target->GetAPIMutex().GetMutex());
target->CalculateExecutionContext (exe_ctx);
+ }
const AddressRange *symbol_range = m_opaque_ptr->GetAddressRangePtr();
if (symbol_range)
{
Modified: lldb/trunk/source/API/SBTarget.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBTarget.cpp?rev=122262&r1=122261&r2=122262&view=diff
==============================================================================
--- lldb/trunk/source/API/SBTarget.cpp (original)
+++ lldb/trunk/source/API/SBTarget.cpp Mon Dec 20 14:49:23 2010
@@ -92,7 +92,10 @@
SBProcess sb_process;
if (m_opaque_sp)
+ {
+ Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex());
sb_process.SetProcess (m_opaque_sp->GetProcessSP());
+ }
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
@@ -113,28 +116,6 @@
return debugger;
}
-
-// DEPRECATED
-SBProcess
-SBTarget::CreateProcess ()
-{
-
- SBProcess sb_process;
-
- if (m_opaque_sp)
- sb_process.SetProcess (m_opaque_sp->CreateProcess (m_opaque_sp->GetDebugger().GetListener()));
-
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- if (log)
- {
- log->Printf ("SBTarget(%p)::CreateProcess () => SBProcess(%p)",
- m_opaque_sp.get(), sb_process.get());
- }
-
- return sb_process;
-}
-
-
SBProcess
SBTarget::LaunchProcess
(
@@ -185,17 +166,8 @@
SBProcess sb_process;
if (m_opaque_sp)
{
- // DEPRECATED, this will change when CreateProcess is removed...
- if (m_opaque_sp->GetProcessSP())
- {
- sb_process.SetProcess(m_opaque_sp->GetProcessSP());
- }
- else
- {
- // When launching, we always want to create a new process When
- // SBTarget::CreateProcess is removed, this will always happen.
- sb_process.SetProcess (m_opaque_sp->CreateProcess (m_opaque_sp->GetDebugger().GetListener()));
- }
+ Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex());
+ sb_process.SetProcess (m_opaque_sp->CreateProcess (m_opaque_sp->GetDebugger().GetListener()));
if (sb_process.IsValid())
{
@@ -253,17 +225,8 @@
SBProcess sb_process;
if (m_opaque_sp)
{
- // DEPRECATED, this will change when CreateProcess is removed...
- if (m_opaque_sp->GetProcessSP())
- {
- sb_process.SetProcess(m_opaque_sp->GetProcessSP());
- }
- else
- {
- // When launching, we always want to create a new process When
- // SBTarget::CreateProcess is removed, this will always happen.
- sb_process.SetProcess (m_opaque_sp->CreateProcess (m_opaque_sp->GetDebugger().GetListener()));
- }
+ Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex());
+ sb_process.SetProcess (m_opaque_sp->CreateProcess (m_opaque_sp->GetDebugger().GetListener()));
if (sb_process.IsValid())
{
@@ -293,17 +256,9 @@
SBProcess sb_process;
if (m_opaque_sp)
{
- // DEPRECATED, this will change when CreateProcess is removed...
- if (m_opaque_sp->GetProcessSP())
- {
- sb_process.SetProcess(m_opaque_sp->GetProcessSP());
- }
- else
- {
- // When launching, we always want to create a new process When
- // SBTarget::CreateProcess is removed, this will always happen.
- sb_process.SetProcess (m_opaque_sp->CreateProcess (m_opaque_sp->GetDebugger().GetListener()));
- }
+ Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex());
+
+ sb_process.SetProcess (m_opaque_sp->CreateProcess (m_opaque_sp->GetDebugger().GetListener()));
if (sb_process.IsValid())
{
@@ -389,7 +344,10 @@
lldb::SBAddress& addr)
{
if (m_opaque_sp)
+ {
+ Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex());
return m_opaque_sp->GetSectionLoadList().ResolveLoadAddress (vm_addr, *addr);
+ }
addr->Clear();
return false;
@@ -408,7 +366,10 @@
SBBreakpoint sb_bp;
if (m_opaque_sp.get() && line != 0)
+ {
+ Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex());
*sb_bp = m_opaque_sp->CreateBreakpoint (NULL, *sb_file_spec, line, true, false);
+ }
if (log)
{
@@ -435,6 +396,7 @@
SBBreakpoint sb_bp;
if (m_opaque_sp.get() && symbol_name && symbol_name[0])
{
+ Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex());
if (module_name && module_name[0])
{
FileSpec module_file_spec(module_name, false);
@@ -463,6 +425,7 @@
SBBreakpoint sb_bp;
if (m_opaque_sp.get() && symbol_name_regex && symbol_name_regex[0])
{
+ Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex());
RegularExpression regexp(symbol_name_regex);
if (module_name && module_name[0])
@@ -495,7 +458,10 @@
SBBreakpoint sb_bp;
if (m_opaque_sp.get())
+ {
+ Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex());
*sb_bp = m_opaque_sp->CreateBreakpoint (address, false);
+ }
if (log)
{
@@ -512,7 +478,10 @@
SBBreakpoint sb_breakpoint;
if (m_opaque_sp && bp_id != LLDB_INVALID_BREAK_ID)
+ {
+ Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex());
*sb_breakpoint = m_opaque_sp->GetBreakpointByID (bp_id);
+ }
if (log)
{
@@ -527,7 +496,10 @@
SBTarget::GetNumBreakpoints () const
{
if (m_opaque_sp)
+ {
+ // The breakpoint list is thread safe, no need to lock
return m_opaque_sp->GetBreakpointList().GetSize();
+ }
return 0;
}
@@ -536,7 +508,10 @@
{
SBBreakpoint sb_breakpoint;
if (m_opaque_sp)
+ {
+ // The breakpoint list is thread safe, no need to lock
*sb_breakpoint = m_opaque_sp->GetBreakpointList().GetBreakpointAtIndex(idx);
+ }
return sb_breakpoint;
}
@@ -547,7 +522,10 @@
bool result = false;
if (m_opaque_sp)
+ {
+ Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex());
result = m_opaque_sp->RemoveBreakpointByID (bp_id);
+ }
if (log)
{
@@ -562,6 +540,7 @@
{
if (m_opaque_sp)
{
+ Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex());
m_opaque_sp->EnableAllBreakpoints ();
return true;
}
@@ -573,6 +552,7 @@
{
if (m_opaque_sp)
{
+ Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex());
m_opaque_sp->DisableAllBreakpoints ();
return true;
}
@@ -584,6 +564,7 @@
{
if (m_opaque_sp)
{
+ Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex());
m_opaque_sp->RemoveAllBreakpoints ();
return true;
}
@@ -598,7 +579,10 @@
uint32_t num = 0;
if (m_opaque_sp)
- num = m_opaque_sp->GetImages().GetSize();
+ {
+ // The module list is thread safe, no need to lock
+ num = m_opaque_sp->GetImages().GetSize();
+ }
if (log)
log->Printf ("SBTarget(%p)::GetNumModules () => %d", m_opaque_sp.get(), num);
@@ -623,7 +607,10 @@
{
SBModule sb_module;
if (m_opaque_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));
+ }
return sb_module;
}
@@ -634,7 +621,10 @@
SBModule sb_module;
if (m_opaque_sp)
+ {
+ // The module list is thread safe, no need to lock
sb_module.SetModule(m_opaque_sp->GetImages().GetModuleAtIndex(idx));
+ }
if (log)
{
@@ -660,130 +650,6 @@
return broadcaster;
}
-void
-SBTarget::Disassemble (lldb::addr_t start_addr, lldb::addr_t end_addr, const char *module_name)
-{
- if (start_addr == LLDB_INVALID_ADDRESS)
- return;
-
- FILE *out = m_opaque_sp->GetDebugger().GetOutputFileHandle();
- if (out == NULL)
- return;
-
- if (m_opaque_sp)
- {
- ModuleSP module_sp;
- if (module_name != NULL)
- {
- FileSpec module_file_spec (module_name, false);
- module_sp = m_opaque_sp->GetImages().FindFirstModuleForFileSpec (module_file_spec, NULL);
- }
-
- AddressRange range;
-
- // Make sure the process object is alive if we have one (it might be
- // created but we might not be launched yet).
-
- Process *sb_process = m_opaque_sp->GetProcessSP().get();
- if (sb_process && !sb_process->IsAlive())
- sb_process = NULL;
-
- // If we are given a module, then "start_addr" is a file address in
- // that module.
- if (module_sp)
- {
- if (!module_sp->ResolveFileAddress (start_addr, range.GetBaseAddress()))
- range.GetBaseAddress().SetOffset(start_addr);
- }
- else if (m_opaque_sp->GetSectionLoadList().IsEmpty() == false)
- {
- // We don't have a module, se we need to figure out if "start_addr"
- // resolves to anything in a running process.
- if (!m_opaque_sp->GetSectionLoadList().ResolveLoadAddress (start_addr, range.GetBaseAddress()))
- range.GetBaseAddress().SetOffset(start_addr);
- }
- else
- {
- if (m_opaque_sp->GetImages().ResolveFileAddress (start_addr, range.GetBaseAddress()))
- range.GetBaseAddress().SetOffset(start_addr);
- }
-
- // For now, we need a process; the disassembly functions insist. If we don't have one already,
- // make one.
-
- ExecutionContext exe_ctx;
-
- if (sb_process)
- sb_process->CalculateExecutionContext(exe_ctx);
- else
- m_opaque_sp->CalculateExecutionContext(exe_ctx);
-
- if (end_addr == LLDB_INVALID_ADDRESS || end_addr < start_addr)
- range.SetByteSize( DEFAULT_DISASM_BYTE_SIZE);
- else
- range.SetByteSize(end_addr - start_addr);
-
- StreamFile out_stream (out);
-
- Disassembler::Disassemble (m_opaque_sp->GetDebugger(),
- m_opaque_sp->GetArchitecture(),
- exe_ctx,
- range,
- 3,
- false,
- out_stream);
- }
-}
-
-void
-SBTarget::Disassemble (const char *function_name, const char *module_name)
-{
- if (function_name == NULL)
- return;
-
- FILE *out = m_opaque_sp->GetDebugger().GetOutputFileHandle();
- if (out == NULL)
- return;
-
- if (m_opaque_sp)
- {
- Disassembler *disassembler = Disassembler::FindPlugin (m_opaque_sp->GetArchitecture());
- if (disassembler == NULL)
- return;
-
- ModuleSP module_sp;
- if (module_name != NULL)
- {
- FileSpec module_file_spec (module_name, false);
- module_sp = m_opaque_sp->GetImages().FindFirstModuleForFileSpec (module_file_spec, NULL);
- }
-
- ExecutionContext exe_ctx;
-
- // Make sure the process object is alive if we have one (it might be
- // created but we might not be launched yet).
- Process *sb_process = m_opaque_sp->GetProcessSP().get();
- if (sb_process && !sb_process->IsAlive())
- sb_process = NULL;
-
- if (sb_process)
- sb_process->CalculateExecutionContext(exe_ctx);
- else
- m_opaque_sp->CalculateExecutionContext(exe_ctx);
-
-
- StreamFile out_stream (out);
-
- Disassembler::Disassemble (m_opaque_sp->GetDebugger(),
- m_opaque_sp->GetArchitecture(),
- exe_ctx,
- ConstString (function_name),
- module_sp.get(),
- 3,
- false,
- out_stream);
- }
-}
bool
SBTarget::GetDescription (SBStream &description, lldb::DescriptionLevel description_level)
Modified: lldb/trunk/source/API/SBThread.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBThread.cpp?rev=122262&r1=122261&r2=122262&view=diff
==============================================================================
--- lldb/trunk/source/API/SBThread.cpp (original)
+++ lldb/trunk/source/API/SBThread.cpp Mon Dec 20 14:49:23 2010
@@ -97,6 +97,7 @@
StopReason reason = eStopReasonInvalid;
if (m_opaque_sp)
{
+ Mutex::Locker api_locker (m_opaque_sp->GetProcess().GetTarget().GetAPIMutex());
StopInfoSP stop_info_sp = m_opaque_sp->GetStopInfo ();
if (stop_info_sp)
reason = stop_info_sp->GetStopReason();
@@ -114,6 +115,7 @@
{
if (m_opaque_sp)
{
+ Mutex::Locker api_locker (m_opaque_sp->GetProcess().GetTarget().GetAPIMutex());
StopInfoSP stop_info_sp = m_opaque_sp->GetStopInfo ();
if (stop_info_sp)
{
@@ -158,6 +160,7 @@
{
if (m_opaque_sp)
{
+ Mutex::Locker api_locker (m_opaque_sp->GetProcess().GetTarget().GetAPIMutex());
StopInfoSP stop_info_sp = m_opaque_sp->GetStopInfo ();
if (stop_info_sp)
{
@@ -219,6 +222,7 @@
if (m_opaque_sp)
{
+ Mutex::Locker api_locker (m_opaque_sp->GetProcess().GetTarget().GetAPIMutex());
StopInfoSP stop_info_sp = m_opaque_sp->GetStopInfo ();
if (stop_info_sp)
{
@@ -324,14 +328,14 @@
{
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- lldb::tid_t id = LLDB_INVALID_THREAD_ID;
+ lldb::tid_t tid = LLDB_INVALID_THREAD_ID;
if (m_opaque_sp)
- id = m_opaque_sp->GetID();
+ tid = m_opaque_sp->GetID();
if (log)
- log->Printf ("SBThread(%p)::GetThreadID () => 0x%4.4x", m_opaque_sp.get(), id);
+ log->Printf ("SBThread(%p)::GetThreadID () => 0x%4.4x", m_opaque_sp.get(), tid);
- return id;
+ return tid;
}
uint32_t
@@ -346,7 +350,10 @@
{
const char *name = NULL;
if (m_opaque_sp)
+ {
+ Mutex::Locker api_locker (m_opaque_sp->GetProcess().GetTarget().GetAPIMutex());
name = m_opaque_sp->GetName();
+ }
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
@@ -360,7 +367,10 @@
{
const char *name = NULL;
if (m_opaque_sp)
+ {
+ Mutex::Locker api_locker (m_opaque_sp->GetProcess().GetTarget().GetAPIMutex());
name = m_opaque_sp->GetQueueName();
+ }
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
@@ -381,6 +391,7 @@
if (m_opaque_sp)
{
+ Mutex::Locker api_locker (m_opaque_sp->GetProcess().GetTarget().GetAPIMutex());
bool abort_other_plans = true;
StackFrameSP frame_sp(m_opaque_sp->GetStackFrameAtIndex (0));
@@ -430,6 +441,7 @@
if (m_opaque_sp)
{
+ Mutex::Locker api_locker (m_opaque_sp->GetProcess().GetTarget().GetAPIMutex());
bool abort_other_plans = true;
StackFrameSP frame_sp(m_opaque_sp->GetStackFrameAtIndex (0));
@@ -476,6 +488,7 @@
if (m_opaque_sp)
{
+ Mutex::Locker api_locker (m_opaque_sp->GetProcess().GetTarget().GetAPIMutex());
bool abort_other_plans = true;
bool stop_other_threads = true;
@@ -504,6 +517,7 @@
if (m_opaque_sp)
{
+ Mutex::Locker api_locker (m_opaque_sp->GetProcess().GetTarget().GetAPIMutex());
m_opaque_sp->QueueThreadPlanForStepSingleInstruction (step_over, true, true);
Process &process = m_opaque_sp->GetProcess();
process.GetThreadList().SetSelectedThreadByID (m_opaque_sp->GetID());
@@ -578,7 +592,10 @@
uint32_t num_frames = 0;
if (m_opaque_sp)
+ {
+ Mutex::Locker api_locker (m_opaque_sp->GetProcess().GetTarget().GetAPIMutex());
num_frames = m_opaque_sp->GetStackFrameCount();
+ }
if (log)
log->Printf ("SBThread(%p)::GetNumFrames () => %u", m_opaque_sp.get(), num_frames);
@@ -593,7 +610,10 @@
SBFrame sb_frame;
if (m_opaque_sp)
+ {
+ Mutex::Locker api_locker (m_opaque_sp->GetProcess().GetTarget().GetAPIMutex());
sb_frame.SetFrame (m_opaque_sp->GetStackFrameAtIndex (idx));
+ }
if (log)
{
@@ -613,7 +633,10 @@
SBFrame sb_frame;
if (m_opaque_sp)
+ {
+ Mutex::Locker api_locker (m_opaque_sp->GetProcess().GetTarget().GetAPIMutex());
sb_frame.SetFrame (m_opaque_sp->GetSelectedFrame ());
+ }
if (log)
{
@@ -634,6 +657,7 @@
SBFrame sb_frame;
if (m_opaque_sp)
{
+ Mutex::Locker api_locker (m_opaque_sp->GetProcess().GetTarget().GetAPIMutex());
lldb::StackFrameSP frame_sp (m_opaque_sp->GetStackFrameAtIndex (idx));
if (frame_sp)
{
Modified: lldb/trunk/source/API/SBValue.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBValue.cpp?rev=122262&r1=122261&r2=122262&view=diff
==============================================================================
--- lldb/trunk/source/API/SBValue.cpp (original)
+++ lldb/trunk/source/API/SBValue.cpp Mon Dec 20 14:49:23 2010
@@ -23,6 +23,7 @@
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/StackFrame.h"
+#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
#include "lldb/API/SBProcess.h"
@@ -135,12 +136,19 @@
}
bool
-SBValue::IsInScope (const SBFrame &frame)
+SBValue::IsInScope (const SBFrame &sb_frame)
{
bool result = false;
if (m_opaque_sp)
- result = m_opaque_sp->IsInScope (frame.get());
+ {
+ StackFrame *frame = sb_frame.get();
+ if (frame)
+ {
+ Mutex::Locker api_locker (frame->GetThread().GetProcess().GetTarget().GetAPIMutex());
+ result = m_opaque_sp->IsInScope (frame);
+ }
+ }
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
@@ -150,18 +158,25 @@
}
const char *
-SBValue::GetValue (const SBFrame &frame)
+SBValue::GetValue (const SBFrame &sb_frame)
{
const char *cstr = NULL;
- if ( m_opaque_sp)
- cstr = m_opaque_sp->GetValueAsCString (frame.get());
+ if (m_opaque_sp)
+ {
+ StackFrame *frame = sb_frame.get();
+ if (frame)
+ {
+ Mutex::Locker api_locker (frame->GetThread().GetProcess().GetTarget().GetAPIMutex());
+ cstr = m_opaque_sp->GetValueAsCString (frame);
+ }
+ }
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
{
if (cstr)
- log->Printf ("SBValue(%p)::GetValue (SBFrame(%p)) => \"%s\"", m_opaque_sp.get(), frame.get(), cstr);
+ log->Printf ("SBValue(%p)::GetValue (SBFrame(%p)) => \"%s\"", m_opaque_sp.get(), sb_frame.get(), cstr);
else
- log->Printf ("SBValue(%p)::GetValue (SBFrame(%p)) => NULL", m_opaque_sp.get(), frame.get());
+ log->Printf ("SBValue(%p)::GetValue (SBFrame(%p)) => NULL", m_opaque_sp.get(), sb_frame.get());
}
return cstr;
@@ -193,75 +208,110 @@
}
const char *
-SBValue::GetObjectDescription (const SBFrame &frame)
+SBValue::GetObjectDescription (const SBFrame &sb_frame)
{
const char *cstr = NULL;
if ( m_opaque_sp)
- cstr = m_opaque_sp->GetObjectDescription (frame.get());
+ {
+ StackFrame *frame = sb_frame.get();
+ if (frame)
+ {
+ Mutex::Locker api_locker (frame->GetThread().GetProcess().GetTarget().GetAPIMutex());
+ cstr = m_opaque_sp->GetObjectDescription (frame);
+ }
+ }
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
{
if (cstr)
- log->Printf ("SBValue(%p)::GetObjectDescription (SBFrame(%p)) => \"%s\"", m_opaque_sp.get(), frame.get(), cstr);
+ log->Printf ("SBValue(%p)::GetObjectDescription (SBFrame(%p)) => \"%s\"", m_opaque_sp.get(), sb_frame.get(), cstr);
else
- log->Printf ("SBValue(%p)::GetObjectDescription (SBFrame(%p)) => NULL", m_opaque_sp.get(), frame.get());
+ log->Printf ("SBValue(%p)::GetObjectDescription (SBFrame(%p)) => NULL", m_opaque_sp.get(), sb_frame.get());
}
return cstr;
}
bool
-SBValue::GetValueDidChange (const SBFrame &frame)
+SBValue::GetValueDidChange (const SBFrame &sb_frame)
{
bool result = false;
if (m_opaque_sp)
- result = m_opaque_sp->GetValueDidChange (frame.get());
+ {
+ StackFrame *frame = sb_frame.get();
+ if (frame)
+ {
+ Mutex::Locker api_locker (frame->GetThread().GetProcess().GetTarget().GetAPIMutex());
+ result = m_opaque_sp->GetValueDidChange (frame);
+ }
+ }
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
- log->Printf ("SBValue(%p)::GetValueDidChange (SBFrame(%p)) => %i", m_opaque_sp.get(), frame.get(), result);
+ log->Printf ("SBValue(%p)::GetValueDidChange (SBFrame(%p)) => %i", m_opaque_sp.get(), sb_frame.get(), result);
return result;
}
const char *
-SBValue::GetSummary (const SBFrame &frame)
+SBValue::GetSummary (const SBFrame &sb_frame)
{
const char *cstr = NULL;
if (m_opaque_sp)
- cstr = m_opaque_sp->GetSummaryAsCString(frame.get());
+ {
+ StackFrame *frame = sb_frame.get();
+ if (frame)
+ {
+ Mutex::Locker api_locker (frame->GetThread().GetProcess().GetTarget().GetAPIMutex());
+ cstr = m_opaque_sp->GetSummaryAsCString(frame);
+ }
+ }
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
{
if (cstr)
- log->Printf ("SBValue(%p)::GetSummary (SBFrame(%p)) => \"%s\"", m_opaque_sp.get(), frame.get(), cstr);
+ log->Printf ("SBValue(%p)::GetSummary (SBFrame(%p)) => \"%s\"", m_opaque_sp.get(), sb_frame.get(), cstr);
else
- log->Printf ("SBValue(%p)::GetSummary (SBFrame(%p)) => NULL", m_opaque_sp.get(), frame.get());
+ log->Printf ("SBValue(%p)::GetSummary (SBFrame(%p)) => NULL", m_opaque_sp.get(), sb_frame.get());
}
return cstr;
}
const char *
-SBValue::GetLocation (const SBFrame &frame)
+SBValue::GetLocation (const SBFrame &sb_frame)
{
const char *cstr = NULL;
if (m_opaque_sp)
- cstr = m_opaque_sp->GetLocationAsCString(frame.get());
+ {
+ StackFrame *frame = sb_frame.get();
+ if (frame)
+ {
+ Mutex::Locker api_locker (frame->GetThread().GetProcess().GetTarget().GetAPIMutex());
+ cstr = m_opaque_sp->GetLocationAsCString(frame);
+ }
+ }
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
{
if (cstr)
- log->Printf ("SBValue(%p)::GetSummary (SBFrame(%p)) => \"%s\"", m_opaque_sp.get(), frame.get(), cstr);
+ log->Printf ("SBValue(%p)::GetSummary (SBFrame(%p)) => \"%s\"", m_opaque_sp.get(), sb_frame.get(), cstr);
else
- log->Printf ("SBValue(%p)::GetSummary (SBFrame(%p)) => NULL", m_opaque_sp.get(), frame.get());
+ log->Printf ("SBValue(%p)::GetSummary (SBFrame(%p)) => NULL", m_opaque_sp.get(), sb_frame.get());
}
return cstr;
}
bool
-SBValue::SetValueFromCString (const SBFrame &frame, const char *value_str)
+SBValue::SetValueFromCString (const SBFrame &sb_frame, const char *value_str)
{
bool success = false;
if (m_opaque_sp)
- success = m_opaque_sp->SetValueFromCString (frame.get(), value_str);
+ {
+ StackFrame *frame = sb_frame.get();
+ if (frame)
+ {
+ Mutex::Locker api_locker (frame->GetThread().GetProcess().GetTarget().GetAPIMutex());
+ success = m_opaque_sp->SetValueFromCString (frame, value_str);
+ }
+ }
return success;
}
@@ -336,17 +386,6 @@
return num_children;
}
-bool
-SBValue::ValueIsStale ()
-{
- bool result = true;
-
- if (m_opaque_sp)
- result = m_opaque_sp->GetValueIsValid();
-
- return result;
-}
-
SBValue
SBValue::Dereference ()
@@ -354,8 +393,8 @@
SBValue sb_value;
if (m_opaque_sp)
{
- if (m_opaque_sp->IsPointerType())
- sb_value = GetChildAtIndex(0);
+ Error error;
+ sb_value = m_opaque_sp->Dereference (error);
}
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
Modified: lldb/trunk/source/API/SBValueList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBValueList.cpp?rev=122262&r1=122261&r2=122262&view=diff
==============================================================================
--- lldb/trunk/source/API/SBValueList.cpp (original)
+++ lldb/trunk/source/API/SBValueList.cpp Mon Dec 20 14:49:23 2010
@@ -11,8 +11,6 @@
#include "lldb/API/SBValueList.h"
#include "lldb/API/SBValue.h"
#include "lldb/API/SBStream.h"
-
-
#include "lldb/Core/Log.h"
#include "lldb/Core/ValueObjectList.h"
@@ -35,16 +33,8 @@
if (log)
{
log->Printf ("SBValueList::SBValueList (rhs.ap=%p) => this.ap = %p",
- (rhs.IsValid() ? rhs.m_opaque_ap.get() : NULL), m_opaque_ap.get());
-
- uint32_t num_vars = GetSize();
- for (uint32_t i = 0; i < num_vars; ++i)
- {
- SBValue value = GetValueAtIndex (i);
- SBStream sstr;
- value.GetDescription (sstr);
- log->Printf (" %s", sstr.GetData());
- }
+ (rhs.IsValid() ? rhs.m_opaque_ap.get() : NULL),
+ m_opaque_ap.get());
}
}
@@ -58,18 +48,9 @@
if (log)
{
- log->Printf ("SBValueList::SBValueList (lldb_object_ptr=%p) => this.ap = %p", lldb_object_ptr,
+ log->Printf ("SBValueList::SBValueList (lldb_object_ptr=%p) => this.ap = %p",
+ lldb_object_ptr,
m_opaque_ap.get());
-
-
- uint32_t num_vars = GetSize();
- for (uint32_t i = 0; i < num_vars; ++i)
- {
- SBValue value = GetValueAtIndex (i);
- SBStream sstr;
- value.GetDescription (sstr);
- log->Printf (" %s", sstr.GetData());
- }
}
}
@@ -194,7 +175,7 @@
SBValueList::FindValueObjectByUID (lldb::user_id_t uid)
{
SBValue sb_value;
- if ( m_opaque_ap.get())
+ if (m_opaque_ap.get())
*sb_value = m_opaque_ap->FindValueObjectByUID (uid);
return sb_value;
}
Modified: lldb/trunk/source/Core/ValueObject.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=122262&r1=122261&r2=122262&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObject.cpp (original)
+++ lldb/trunk/source/Core/ValueObject.cpp Mon Dec 20 14:49:23 2010
@@ -1203,7 +1203,7 @@
}
lldb::ValueObjectSP
-ValueObject::Dereference (ExecutionContextScope *exe_scope, Error &error)
+ValueObject::Dereference (Error &error)
{
lldb::ValueObjectSP valobj_sp;
const bool is_pointer_type = IsPointerType();
Modified: lldb/trunk/source/Target/StackFrame.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/StackFrame.cpp?rev=122262&r1=122261&r2=122262&view=diff
==============================================================================
--- lldb/trunk/source/Target/StackFrame.cpp (original)
+++ lldb/trunk/source/Target/StackFrame.cpp Mon Dec 20 14:49:23 2010
@@ -688,7 +688,7 @@
{
if (deref)
{
- ValueObjectSP deref_valobj_sp (valobj_sp->Dereference(this, error));
+ ValueObjectSP deref_valobj_sp (valobj_sp->Dereference(error));
valobj_sp = deref_valobj_sp;
}
else if (address_of)
Modified: lldb/trunk/source/Target/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=122262&r1=122261&r2=122262&view=diff
==============================================================================
--- lldb/trunk/source/Target/Target.cpp (original)
+++ lldb/trunk/source/Target/Target.cpp Mon Dec 20 14:49:23 2010
@@ -40,6 +40,7 @@
Broadcaster("lldb.target"),
TargetInstanceSettings (*GetSettingsController()),
m_debugger (debugger),
+ m_mutex (Mutex::eMutexTypeRecursive),
m_images(),
m_section_load_list (),
m_breakpoint_list (false),
More information about the lldb-commits
mailing list