summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJim Ingham <jingham@apple.com>2012-08-21 01:46:35 +0000
committerJim Ingham <jingham@apple.com>2012-08-21 01:46:35 +0000
commit48cdc58f0a8127059696e21bc7729e0094e77f26 (patch)
tree7af8577a9a67f1ef7034a751bfbc2e3fefa00e51
parent0980793f87142ea315365150eb6779b2fd0ff2c5 (diff)
downloadbcm5719-llvm-48cdc58f0a8127059696e21bc7729e0094e77f26.tar.gz
bcm5719-llvm-48cdc58f0a8127059696e21bc7729e0094e77f26.zip
SBValue::GetTypeName and SBValue::GetByteSize might have to update the dynamic value - which might involve running code. So they need to take the stop lock & target locks.
<rdar://problem/12001204> llvm-svn: 162250
-rw-r--r--lldb/source/API/SBValue.cpp49
1 files changed, 45 insertions, 4 deletions
diff --git a/lldb/source/API/SBValue.cpp b/lldb/source/API/SBValue.cpp
index 543c7947755..3521e903d15 100644
--- a/lldb/source/API/SBValue.cpp
+++ b/lldb/source/API/SBValue.cpp
@@ -137,11 +137,32 @@ SBValue::GetName()
const char *
SBValue::GetTypeName ()
{
+ LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
const char *name = NULL;
lldb::ValueObjectSP value_sp(GetSP());
if (value_sp)
- name = value_sp->GetQualifiedTypeName().GetCString();
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ {
+ // For a dynamic type we might have to run code to determine the type we are going to report,
+ // and we might not have updated the type before we get asked this. So make sure to get the API lock.
+
+ ProcessSP process_sp(value_sp->GetProcessSP());
+ Process::StopLocker stop_locker;
+ if (process_sp && !stop_locker.TryLock(&process_sp->GetRunLock()))
+ {
+ if (log)
+ log->Printf ("SBValue(%p)::GetTypeName() => error: process is running", value_sp.get());
+ }
+ else
+ {
+ TargetSP target_sp(value_sp->GetTargetSP());
+ if (target_sp)
+ {
+ Mutex::Locker api_locker (target_sp->GetAPIMutex());
+ name = value_sp->GetQualifiedTypeName().GetCString();
+ }
+ }
+ }
+
if (log)
{
if (name)
@@ -156,13 +177,33 @@ SBValue::GetTypeName ()
size_t
SBValue::GetByteSize ()
{
+ LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
size_t result = 0;
lldb::ValueObjectSP value_sp(GetSP());
if (value_sp)
- result = value_sp->GetByteSize();
+ {
+ // For a dynamic type we might have to run code to determine the type we are going to report,
+ // and we might not have updated the type before we get asked this. So make sure to get the API lock.
+
+ ProcessSP process_sp(value_sp->GetProcessSP());
+ Process::StopLocker stop_locker;
+ if (process_sp && !stop_locker.TryLock(&process_sp->GetRunLock()))
+ {
+ if (log)
+ log->Printf ("SBValue(%p)::GetTypeName() => error: process is running", value_sp.get());
+ }
+ else
+ {
+ TargetSP target_sp(value_sp->GetTargetSP());
+ if (target_sp)
+ {
+ Mutex::Locker api_locker (target_sp->GetAPIMutex());
+ result = value_sp->GetByteSize();
+ }
+ }
+ }
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
log->Printf ("SBValue(%p)::GetByteSize () => %zu", value_sp.get(), result);
OpenPOWER on IntegriCloud