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/SBCommunication.cpp b/source/API/SBCommunication.cpp
index fca4882..ac3042f 100644
--- a/source/API/SBCommunication.cpp
+++ b/source/API/SBCommunication.cpp
@@ -28,7 +28,7 @@
m_opaque (new Communication (broadcaster_name)),
m_opaque_owned (true)
{
- Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API);
+ LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
log->Printf ("SBCommunication::SBCommunication (broadcaster_name=\"%s\") => "
@@ -82,7 +82,7 @@
ConnectionStatus
SBCommunication::AdoptFileDesriptor (int fd, bool owns_fd)
{
- Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API);
+ LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
ConnectionStatus status = eConnectionStatusNoConnection;
if (m_opaque)
@@ -110,7 +110,7 @@
ConnectionStatus
SBCommunication::Disconnect ()
{
- Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API);
+ LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
ConnectionStatus status= eConnectionStatusNoConnection;
if (m_opaque)
@@ -126,7 +126,7 @@
bool
SBCommunication::IsConnected () const
{
- Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API);
+ LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
bool result = false;
if (m_opaque)
result = m_opaque->IsConnected ();
@@ -140,7 +140,7 @@
size_t
SBCommunication::Read (void *dst, size_t dst_len, uint32_t timeout_usec, ConnectionStatus &status)
{
- Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API);
+ LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
log->Printf ("SBCommunication(%p)::Read (dst=%p, dst_len=%zu, timeout_usec=%u, &status)...",
m_opaque, dst, dst_len, timeout_usec);
@@ -167,7 +167,7 @@
else
status = eConnectionStatusNoConnection;
- Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API);
+ LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
log->Printf ("SBCommunication(%p)::Write (src=%p, src_len=%zu, &status=%s) => %zu",
m_opaque, src, src_len, Communication::ConnectionStatusAsCString (status), bytes_written);
@@ -178,7 +178,7 @@
bool
SBCommunication::ReadThreadStart ()
{
- Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API);
+ LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
bool success = false;
if (m_opaque)
@@ -195,7 +195,7 @@
bool
SBCommunication::ReadThreadStop ()
{
- Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API);
+ LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
log->Printf ("SBCommunication(%p)::ReadThreadStop ()...", m_opaque);
@@ -215,7 +215,7 @@
bool result = false;
if (m_opaque)
result = m_opaque->ReadThreadIsRunning ();
- Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API);
+ LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
log->Printf ("SBCommunication(%p)::ReadThreadIsRunning () => %i", m_opaque, result);
return result;
@@ -228,7 +228,7 @@
void *callback_baton
)
{
- Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API);
+ LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
bool result = false;
if (m_opaque)
@@ -249,7 +249,7 @@
{
SBBroadcaster broadcaster (m_opaque, false);
- Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API);
+ LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
log->Printf ("SBCommunication(%p)::GetBroadcaster () => SBBroadcaster (%p)",