Modified all logging calls to hand out shared pointers to make sure we
don't crash if we disable logging when some code already has a copy of the
logger. Prior to this fix, logs were handed out as pointers and if they were
held onto while a log got disabled, then it could cause a crash. Now all logs
are handed out as shared pointers so this problem shouldn't happen anymore.
We are also using our new shared pointers that put the shared pointer count
and the object into the same allocation for a tad better performance.
git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@118319 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/API/SBValue.cpp b/source/API/SBValue.cpp
index a4b3db2..538324c 100644
--- a/source/API/SBValue.cpp
+++ b/source/API/SBValue.cpp
@@ -89,7 +89,7 @@
if (m_opaque_sp)
name = m_opaque_sp->GetName().GetCString();
- Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API);
+ LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
{
if (name)
@@ -107,7 +107,7 @@
const char *name = NULL;
if (m_opaque_sp)
name = m_opaque_sp->GetTypeName().GetCString();
- Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API);
+ LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
{
if (name)
@@ -127,7 +127,7 @@
if (m_opaque_sp)
result = m_opaque_sp->GetByteSize();
- Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API);
+ LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
log->Printf ("SBValue(%p)::GetByteSize () => %zu", m_opaque_sp.get(), result);
@@ -142,7 +142,7 @@
if (m_opaque_sp)
result = m_opaque_sp->IsInScope (frame.get());
- Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API);
+ LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
log->Printf ("SBValue(%p)::IsInScope () => %i", m_opaque_sp.get(), result);
@@ -155,7 +155,7 @@
const char *cstr = NULL;
if ( m_opaque_sp)
cstr = m_opaque_sp->GetValueAsCString (frame.get());
- Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API);
+ LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
{
if (cstr)
@@ -173,7 +173,7 @@
ValueType result = eValueTypeInvalid;
if (m_opaque_sp)
result = m_opaque_sp->GetValueType();
- Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API);
+ LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
{
switch (result)
@@ -198,7 +198,7 @@
const char *cstr = NULL;
if ( m_opaque_sp)
cstr = m_opaque_sp->GetObjectDescription (frame.get());
- Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API);
+ LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
{
if (cstr)
@@ -215,7 +215,7 @@
bool result = false;
if (m_opaque_sp)
result = m_opaque_sp->GetValueDidChange (frame.get());
- Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API);
+ 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);
@@ -228,7 +228,7 @@
const char *cstr = NULL;
if (m_opaque_sp)
cstr = m_opaque_sp->GetSummaryAsCString(frame.get());
- Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API);
+ LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
{
if (cstr)
@@ -245,7 +245,7 @@
const char *cstr = NULL;
if (m_opaque_sp)
cstr = m_opaque_sp->GetLocationAsCString(frame.get());
- Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API);
+ LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
{
if (cstr)
@@ -276,7 +276,7 @@
}
SBValue sb_value (child_sp);
- Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API);
+ LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
log->Printf ("SBValue(%p)::GetChildAtIndex (%u) => SBValue(%p)", m_opaque_sp.get(), idx, sb_value.get());
@@ -289,7 +289,7 @@
uint32_t idx = UINT32_MAX;
if (m_opaque_sp)
idx = m_opaque_sp->GetIndexOfChildWithName (ConstString(name));
- Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API);
+ LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
{
if (idx == UINT32_MAX)
@@ -313,7 +313,7 @@
SBValue sb_value (child_sp);
- Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API);
+ LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
log->Printf ("SBValue(%p)::GetChildMemberWithName (name=\"%s\") => SBValue(%p)", m_opaque_sp.get(), name, sb_value.get());
@@ -329,7 +329,7 @@
if (m_opaque_sp)
num_children = m_opaque_sp->GetNumChildren();
- Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API);
+ LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
log->Printf ("SBValue(%p)::GetNumChildren () => %u", m_opaque_sp.get(), num_children);
@@ -357,7 +357,7 @@
if (m_opaque_sp->IsPointerType())
sb_value = GetChildAtIndex(0);
}
- Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API);
+ LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
log->Printf ("SBValue(%p)::Dereference () => SBValue(%p)", m_opaque_sp.get(), sb_value.get());
@@ -372,7 +372,7 @@
if (m_opaque_sp)
is_ptr_type = m_opaque_sp->IsPointerType();
- Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API);
+ LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
log->Printf ("SBValue(%p)::TypeIsPointerType () => %i", m_opaque_sp.get(), is_ptr_type);