<rdar://problem/13521159>
LLDB is crashing when logging is enabled from lldb-perf-clang. This has to do with the global destructor chain as the process and its threads are being torn down. All logging channels now make one and only one instance that is kept in a global pointer which is never freed. This guarantees that logging can correctly continue as the process tears itself down. llvm-svn: 178191
This commit is contained in:
@@ -143,7 +143,7 @@ SBProcess::RemoteLaunch (char const **argv,
|
||||
bool stop_at_entry,
|
||||
lldb::SBError& error)
|
||||
{
|
||||
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
||||
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
||||
if (log) {
|
||||
log->Printf ("SBProcess(%p)::RemoteLaunch (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_wp.lock().get(),
|
||||
@@ -222,7 +222,7 @@ SBProcess::RemoteAttachToProcessWithID (lldb::pid_t pid, lldb::SBError& error)
|
||||
error.SetErrorString ("unable to attach pid");
|
||||
}
|
||||
|
||||
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
||||
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
||||
if (log) {
|
||||
SBStream sstr;
|
||||
error.GetDescription (sstr);
|
||||
@@ -236,7 +236,7 @@ SBProcess::RemoteAttachToProcessWithID (lldb::pid_t pid, lldb::SBError& error)
|
||||
uint32_t
|
||||
SBProcess::GetNumThreads ()
|
||||
{
|
||||
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
||||
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
||||
|
||||
uint32_t num_threads = 0;
|
||||
ProcessSP process_sp(GetSP());
|
||||
@@ -258,7 +258,7 @@ SBProcess::GetNumThreads ()
|
||||
SBThread
|
||||
SBProcess::GetSelectedThread () const
|
||||
{
|
||||
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
||||
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
||||
|
||||
SBThread sb_thread;
|
||||
ThreadSP thread_sp;
|
||||
@@ -281,7 +281,7 @@ SBProcess::GetSelectedThread () const
|
||||
SBThread
|
||||
SBProcess::CreateOSPluginThread (lldb::tid_t tid, lldb::addr_t context)
|
||||
{
|
||||
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
||||
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
||||
|
||||
SBThread sb_thread;
|
||||
ThreadSP thread_sp;
|
||||
@@ -302,7 +302,7 @@ SBProcess::CreateOSPluginThread (lldb::tid_t tid, lldb::addr_t context)
|
||||
SBTarget
|
||||
SBProcess::GetTarget() const
|
||||
{
|
||||
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
||||
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
||||
|
||||
SBTarget sb_target;
|
||||
TargetSP target_sp;
|
||||
@@ -323,7 +323,7 @@ SBProcess::GetTarget() const
|
||||
size_t
|
||||
SBProcess::PutSTDIN (const char *src, size_t src_len)
|
||||
{
|
||||
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
||||
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
||||
|
||||
size_t ret_val = 0;
|
||||
ProcessSP process_sp(GetSP());
|
||||
@@ -354,7 +354,7 @@ SBProcess::GetSTDOUT (char *dst, size_t dst_len) const
|
||||
bytes_read = process_sp->GetSTDOUT (dst, dst_len, error);
|
||||
}
|
||||
|
||||
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
||||
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
||||
if (log)
|
||||
log->Printf ("SBProcess(%p)::GetSTDOUT (dst=\"%.*s\", dst_len=%" PRIu64 ") => %" PRIu64,
|
||||
process_sp.get(),
|
||||
@@ -377,7 +377,7 @@ SBProcess::GetSTDERR (char *dst, size_t dst_len) const
|
||||
bytes_read = process_sp->GetSTDERR (dst, dst_len, error);
|
||||
}
|
||||
|
||||
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
||||
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
||||
if (log)
|
||||
log->Printf ("SBProcess(%p)::GetSTDERR (dst=\"%.*s\", dst_len=%" PRIu64 ") => %" PRIu64,
|
||||
process_sp.get(),
|
||||
@@ -400,7 +400,7 @@ SBProcess::GetAsyncProfileData(char *dst, size_t dst_len) const
|
||||
bytes_read = process_sp->GetAsyncProfileData (dst, dst_len, error);
|
||||
}
|
||||
|
||||
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
||||
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
||||
if (log)
|
||||
log->Printf ("SBProcess(%p)::GetProfileData (dst=\"%.*s\", dst_len=%" PRIu64 ") => %" PRIu64,
|
||||
process_sp.get(),
|
||||
@@ -467,7 +467,7 @@ SBProcess::SetSelectedThread (const SBThread &thread)
|
||||
bool
|
||||
SBProcess::SetSelectedThreadByID (lldb::tid_t tid)
|
||||
{
|
||||
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
||||
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
||||
|
||||
bool ret_val = false;
|
||||
ProcessSP process_sp(GetSP());
|
||||
@@ -487,7 +487,7 @@ SBProcess::SetSelectedThreadByID (lldb::tid_t tid)
|
||||
bool
|
||||
SBProcess::SetSelectedThreadByIndexID (uint32_t index_id)
|
||||
{
|
||||
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
||||
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
||||
|
||||
bool ret_val = false;
|
||||
ProcessSP process_sp(GetSP());
|
||||
@@ -507,7 +507,7 @@ SBProcess::SetSelectedThreadByIndexID (uint32_t index_id)
|
||||
SBThread
|
||||
SBProcess::GetThreadAtIndex (size_t index)
|
||||
{
|
||||
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
||||
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
||||
|
||||
SBThread sb_thread;
|
||||
ThreadSP thread_sp;
|
||||
@@ -557,7 +557,7 @@ SBProcess::GetState ()
|
||||
ret_val = process_sp->GetState();
|
||||
}
|
||||
|
||||
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
||||
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
||||
if (log)
|
||||
log->Printf ("SBProcess(%p)::GetState () => %s",
|
||||
process_sp.get(),
|
||||
@@ -577,7 +577,7 @@ SBProcess::GetExitStatus ()
|
||||
Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex());
|
||||
exit_status = process_sp->GetExitStatus ();
|
||||
}
|
||||
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
||||
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
||||
if (log)
|
||||
log->Printf ("SBProcess(%p)::GetExitStatus () => %i (0x%8.8x)",
|
||||
process_sp.get(), exit_status, exit_status);
|
||||
@@ -595,7 +595,7 @@ SBProcess::GetExitDescription ()
|
||||
Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex());
|
||||
exit_desc = process_sp->GetExitDescription ();
|
||||
}
|
||||
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
||||
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
||||
if (log)
|
||||
log->Printf ("SBProcess(%p)::GetExitDescription () => %s",
|
||||
process_sp.get(), exit_desc);
|
||||
@@ -610,7 +610,7 @@ SBProcess::GetProcessID ()
|
||||
if (process_sp)
|
||||
ret_val = process_sp->GetID();
|
||||
|
||||
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
||||
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
||||
if (log)
|
||||
log->Printf ("SBProcess(%p)::GetProcessID () => %" PRIu64, process_sp.get(), ret_val);
|
||||
|
||||
@@ -624,7 +624,7 @@ SBProcess::GetUniqueID()
|
||||
ProcessSP process_sp(GetSP());
|
||||
if (process_sp)
|
||||
ret_val = process_sp->GetUniqueID();
|
||||
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
||||
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
||||
if (log)
|
||||
log->Printf ("SBProcess(%p)::GetUniqueID () => %" PRIu32, process_sp.get(), ret_val);
|
||||
return ret_val;
|
||||
@@ -638,7 +638,7 @@ SBProcess::GetByteOrder () const
|
||||
if (process_sp)
|
||||
byteOrder = process_sp->GetTarget().GetArchitecture().GetByteOrder();
|
||||
|
||||
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
||||
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
||||
if (log)
|
||||
log->Printf ("SBProcess(%p)::GetByteOrder () => %d", process_sp.get(), byteOrder);
|
||||
|
||||
@@ -653,7 +653,7 @@ SBProcess::GetAddressByteSize () const
|
||||
if (process_sp)
|
||||
size = process_sp->GetTarget().GetArchitecture().GetAddressByteSize();
|
||||
|
||||
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
||||
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
||||
if (log)
|
||||
log->Printf ("SBProcess(%p)::GetAddressByteSize () => %d", process_sp.get(), size);
|
||||
|
||||
@@ -663,7 +663,7 @@ SBProcess::GetAddressByteSize () const
|
||||
SBError
|
||||
SBProcess::Continue ()
|
||||
{
|
||||
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
||||
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
||||
|
||||
SBError sb_error;
|
||||
ProcessSP process_sp(GetSP());
|
||||
@@ -714,7 +714,7 @@ SBProcess::Destroy ()
|
||||
else
|
||||
sb_error.SetErrorString ("SBProcess is invalid");
|
||||
|
||||
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
||||
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
||||
if (log)
|
||||
{
|
||||
SBStream sstr;
|
||||
@@ -742,7 +742,7 @@ SBProcess::Stop ()
|
||||
else
|
||||
sb_error.SetErrorString ("SBProcess is invalid");
|
||||
|
||||
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
||||
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
||||
if (log)
|
||||
{
|
||||
SBStream sstr;
|
||||
@@ -769,7 +769,7 @@ SBProcess::Kill ()
|
||||
else
|
||||
sb_error.SetErrorString ("SBProcess is invalid");
|
||||
|
||||
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
||||
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
||||
if (log)
|
||||
{
|
||||
SBStream sstr;
|
||||
@@ -811,7 +811,7 @@ SBProcess::Signal (int signo)
|
||||
}
|
||||
else
|
||||
sb_error.SetErrorString ("SBProcess is invalid");
|
||||
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
||||
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
||||
if (log)
|
||||
{
|
||||
SBStream sstr;
|
||||
@@ -850,7 +850,7 @@ SBProcess::GetThreadByID (tid_t tid)
|
||||
sb_thread.SetThread (thread_sp);
|
||||
}
|
||||
|
||||
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
||||
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
||||
if (log)
|
||||
{
|
||||
log->Printf ("SBProcess(%p)::GetThreadByID (tid=0x%4.4" PRIx64 ") => SBThread (%p)",
|
||||
@@ -877,7 +877,7 @@ SBProcess::GetThreadByIndexID (uint32_t index_id)
|
||||
sb_thread.SetThread (thread_sp);
|
||||
}
|
||||
|
||||
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
||||
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
||||
if (log)
|
||||
{
|
||||
log->Printf ("SBProcess(%p)::GetThreadByID (tid=0x%x) => SBThread (%p)",
|
||||
@@ -892,7 +892,7 @@ SBProcess::GetThreadByIndexID (uint32_t index_id)
|
||||
StateType
|
||||
SBProcess::GetStateFromEvent (const SBEvent &event)
|
||||
{
|
||||
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
||||
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
||||
|
||||
StateType ret_val = Process::ProcessEventData::GetStateFromEvent (event.get());
|
||||
|
||||
@@ -937,7 +937,7 @@ SBProcess::EventIsProcessEvent (const SBEvent &event)
|
||||
SBBroadcaster
|
||||
SBProcess::GetBroadcaster () const
|
||||
{
|
||||
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
||||
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
||||
|
||||
ProcessSP process_sp(GetSP());
|
||||
|
||||
@@ -959,7 +959,7 @@ SBProcess::GetBroadcasterClass ()
|
||||
size_t
|
||||
SBProcess::ReadMemory (addr_t addr, void *dst, size_t dst_len, SBError &sb_error)
|
||||
{
|
||||
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
||||
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
||||
|
||||
size_t bytes_read = 0;
|
||||
|
||||
@@ -1027,7 +1027,7 @@ SBProcess::ReadCStringFromMemory (addr_t addr, void *buf, size_t size, lldb::SBE
|
||||
}
|
||||
else
|
||||
{
|
||||
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
||||
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
||||
if (log)
|
||||
log->Printf ("SBProcess(%p)::ReadCStringFromMemory() => error: process is running", process_sp.get());
|
||||
sb_error.SetErrorString("process is running");
|
||||
@@ -1055,7 +1055,7 @@ SBProcess::ReadUnsignedFromMemory (addr_t addr, uint32_t byte_size, lldb::SBErro
|
||||
}
|
||||
else
|
||||
{
|
||||
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
||||
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
||||
if (log)
|
||||
log->Printf ("SBProcess(%p)::ReadUnsignedFromMemory() => error: process is running", process_sp.get());
|
||||
sb_error.SetErrorString("process is running");
|
||||
@@ -1083,7 +1083,7 @@ SBProcess::ReadPointerFromMemory (addr_t addr, lldb::SBError &sb_error)
|
||||
}
|
||||
else
|
||||
{
|
||||
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
||||
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
||||
if (log)
|
||||
log->Printf ("SBProcess(%p)::ReadPointerFromMemory() => error: process is running", process_sp.get());
|
||||
sb_error.SetErrorString("process is running");
|
||||
@@ -1101,7 +1101,7 @@ SBProcess::WriteMemory (addr_t addr, const void *src, size_t src_len, SBError &s
|
||||
{
|
||||
size_t bytes_written = 0;
|
||||
|
||||
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
||||
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
||||
|
||||
ProcessSP process_sp(GetSP());
|
||||
|
||||
@@ -1179,7 +1179,7 @@ SBProcess::GetDescription (SBStream &description)
|
||||
uint32_t
|
||||
SBProcess::GetNumSupportedHardwareWatchpoints (lldb::SBError &sb_error) const
|
||||
{
|
||||
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
||||
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
||||
|
||||
uint32_t num = 0;
|
||||
ProcessSP process_sp(GetSP());
|
||||
@@ -1212,7 +1212,7 @@ SBProcess::LoadImage (lldb::SBFileSpec &sb_image_spec, lldb::SBError &sb_error)
|
||||
}
|
||||
else
|
||||
{
|
||||
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
||||
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
||||
if (log)
|
||||
log->Printf ("SBProcess(%p)::LoadImage() => error: process is running", process_sp.get());
|
||||
sb_error.SetErrorString("process is running");
|
||||
@@ -1236,7 +1236,7 @@ SBProcess::UnloadImage (uint32_t image_token)
|
||||
}
|
||||
else
|
||||
{
|
||||
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
||||
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
||||
if (log)
|
||||
log->Printf ("SBProcess(%p)::UnloadImage() => error: process is running", process_sp.get());
|
||||
sb_error.SetErrorString("process is running");
|
||||
|
||||
Reference in New Issue
Block a user