diff options
| author | Greg Clayton <gclayton@apple.com> | 2013-03-27 23:08:40 +0000 |
|---|---|---|
| committer | Greg Clayton <gclayton@apple.com> | 2013-03-27 23:08:40 +0000 |
| commit | 5160ce5c72e5f55c2e83ca9914cd0f02e0c5ceb3 (patch) | |
| tree | b24bb5959b40d8f0e99ed6d8b13271270dbf08e3 /lldb/source/Plugins/Process | |
| parent | ccc266559f5c028442b6393362da14d866d9b32b (diff) | |
| download | bcm5719-llvm-5160ce5c72e5f55c2e83ca9914cd0f02e0c5ceb3.tar.gz bcm5719-llvm-5160ce5c72e5f55c2e83ca9914cd0f02e0c5ceb3.zip | |
<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
Diffstat (limited to 'lldb/source/Plugins/Process')
15 files changed, 116 insertions, 106 deletions
diff --git a/lldb/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp b/lldb/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp index c98b2465fdb..bbde8ed0709 100644 --- a/lldb/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp +++ b/lldb/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp @@ -102,7 +102,7 @@ CommunicationKDP::SendRequestAndGetReply (const CommandType command, { if (IsRunning()) { - LogSP log (ProcessKDPLog::GetLogIfAllCategoriesSet (KDP_LOG_PACKETS)); + Log *log (ProcessKDPLog::GetLogIfAllCategoriesSet (KDP_LOG_PACKETS)); if (log) { PacketStreamType log_strm; @@ -153,7 +153,7 @@ CommunicationKDP::SendRequestPacketNoLock (const PacketStreamType &request_packe const char *packet_data = request_packet.GetData(); const size_t packet_size = request_packet.GetSize(); - LogSP log (ProcessKDPLog::GetLogIfAllCategoriesSet (KDP_LOG_PACKETS)); + Log *log (ProcessKDPLog::GetLogIfAllCategoriesSet (KDP_LOG_PACKETS)); if (log) { PacketStreamType log_strm; @@ -202,7 +202,7 @@ CommunicationKDP::WaitForPacketWithTimeoutMicroSecondsNoLock (DataExtractor &pac uint8_t buffer[8192]; Error error; - LogSP log (ProcessKDPLog::GetLogIfAllCategoriesSet (KDP_LOG_PACKETS | KDP_LOG_VERBOSE)); + Log *log (ProcessKDPLog::GetLogIfAllCategoriesSet (KDP_LOG_PACKETS | KDP_LOG_VERBOSE)); // Check for a packet from our cache first without trying any reading... if (CheckForPacket (NULL, 0, packet)) @@ -257,7 +257,7 @@ CommunicationKDP::CheckForPacket (const uint8_t *src, size_t src_len, DataExtrac // Put the packet data into the buffer in a thread safe fashion Mutex::Locker locker(m_bytes_mutex); - LogSP log (ProcessKDPLog::GetLogIfAllCategoriesSet (KDP_LOG_PACKETS)); + Log *log (ProcessKDPLog::GetLogIfAllCategoriesSet (KDP_LOG_PACKETS)); if (src && src_len > 0) { diff --git a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp index f27c5f8fa3f..339c83a3098 100644 --- a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp +++ b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp @@ -333,7 +333,7 @@ ProcessKDP::DoAttachToProcessWithName (const char *process_name, bool wait_for_l void ProcessKDP::DidAttach () { - LogSP log (ProcessKDPLog::GetLogIfAllCategoriesSet (KDP_LOG_PROCESS)); + Log *log (ProcessKDPLog::GetLogIfAllCategoriesSet (KDP_LOG_PROCESS)); if (log) log->Printf ("ProcessKDP::DidAttach()"); if (GetID() != LLDB_INVALID_PROCESS_ID) @@ -366,7 +366,7 @@ Error ProcessKDP::DoResume () { Error error; - LogSP log (ProcessKDPLog::GetLogIfAllCategoriesSet (KDP_LOG_PROCESS)); + Log *log (ProcessKDPLog::GetLogIfAllCategoriesSet (KDP_LOG_PROCESS)); // Only start the async thread if we try to do any process control if (!IS_VALID_LLDB_HOST_THREAD(m_async_thread)) StartAsyncThread (); @@ -445,7 +445,7 @@ bool ProcessKDP::UpdateThreadList (ThreadList &old_thread_list, ThreadList &new_thread_list) { // locker will keep a mutex locked until it goes out of scope - LogSP log (ProcessKDPLog::GetLogIfAllCategoriesSet (KDP_LOG_THREAD)); + Log *log (ProcessKDPLog::GetLogIfAllCategoriesSet (KDP_LOG_THREAD)); if (log && log->GetMask().Test(KDP_LOG_VERBOSE)) log->Printf ("ProcessKDP::%s (pid = %" PRIu64 ")", __FUNCTION__, GetID()); @@ -490,7 +490,7 @@ Error ProcessKDP::DoDetach() { Error error; - LogSP log (ProcessKDPLog::GetLogIfAllCategoriesSet(KDP_LOG_PROCESS)); + Log *log (ProcessKDPLog::GetLogIfAllCategoriesSet(KDP_LOG_PROCESS)); if (log) log->Printf ("ProcessKDP::DoDetach()"); @@ -695,7 +695,7 @@ ProcessKDP::Initialize() bool ProcessKDP::StartAsyncThread () { - LogSP log (ProcessKDPLog::GetLogIfAllCategoriesSet(KDP_LOG_PROCESS)); + Log *log (ProcessKDPLog::GetLogIfAllCategoriesSet(KDP_LOG_PROCESS)); if (log) log->Printf ("ProcessKDP::StartAsyncThread ()"); @@ -710,7 +710,7 @@ ProcessKDP::StartAsyncThread () void ProcessKDP::StopAsyncThread () { - LogSP log (ProcessKDPLog::GetLogIfAllCategoriesSet(KDP_LOG_PROCESS)); + Log *log (ProcessKDPLog::GetLogIfAllCategoriesSet(KDP_LOG_PROCESS)); if (log) log->Printf ("ProcessKDP::StopAsyncThread ()"); @@ -733,7 +733,7 @@ ProcessKDP::AsyncThread (void *arg) const lldb::pid_t pid = process->GetID(); - LogSP log (ProcessKDPLog::GetLogIfAllCategoriesSet (KDP_LOG_PROCESS)); + Log *log (ProcessKDPLog::GetLogIfAllCategoriesSet (KDP_LOG_PROCESS)); if (log) log->Printf ("ProcessKDP::AsyncThread (arg = %p, pid = %" PRIu64 ") thread starting...", arg, pid); diff --git a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDPLog.cpp b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDPLog.cpp index ff3c46ece3f..53b08d53c24 100644 --- a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDPLog.cpp +++ b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDPLog.cpp @@ -22,22 +22,25 @@ using namespace lldb_private; // control access to our static g_log_sp by hiding it in a singleton function // that will construct the static g_lob_sp the first time this function is // called. -static LogSP & +static bool g_log_enabled = false; +static Log * g_log = NULL; +static Log * GetLog () { - static LogSP g_log_sp; - return g_log_sp; + if (!g_log_enabled) + return NULL; + return g_log; } -LogSP +Log * ProcessKDPLog::GetLogIfAllCategoriesSet (uint32_t mask) { - LogSP log(GetLog ()); + Log *log(GetLog ()); if (log && mask) { uint32_t log_mask = log->GetMask().Get(); if ((log_mask & mask) != mask) - return LogSP(); + return NULL; } return log; } @@ -45,7 +48,7 @@ ProcessKDPLog::GetLogIfAllCategoriesSet (uint32_t mask) void ProcessKDPLog::DisableLog (const char **categories, Stream *feedback_strm) { - LogSP log (GetLog ()); + Log *log (GetLog ()); if (log) { uint32_t flag_bits = 0; @@ -81,33 +84,33 @@ ProcessKDPLog::DisableLog (const char **categories, Stream *feedback_strm) } } + log->GetMask().Reset (flag_bits); if (flag_bits == 0) - GetLog ().reset(); - else - log->GetMask().Reset (flag_bits); + g_log_enabled = false; } return; } -LogSP +Log * ProcessKDPLog::EnableLog (StreamSP &log_stream_sp, uint32_t log_options, const char **categories, Stream *feedback_strm) { // Try see if there already is a log - that way we can reuse its settings. // We could reuse the log in toto, but we don't know that the stream is the same. uint32_t flag_bits = 0; - LogSP log(GetLog ()); - if (log) - flag_bits = log->GetMask().Get(); + if (g_log) + flag_bits = g_log->GetMask().Get(); // Now make a new log with this stream if one was provided if (log_stream_sp) { - log.reset (new Log(log_stream_sp)); - GetLog () = log; + if (g_log) + g_log->SetStream(log_stream_sp); + else + g_log = new Log(log_stream_sp); } - if (log) + if (g_log) { bool got_unknown_category = false; for (size_t i=0; categories[i] != NULL; ++i) @@ -140,10 +143,11 @@ ProcessKDPLog::EnableLog (StreamSP &log_stream_sp, uint32_t log_options, const c } if (flag_bits == 0) flag_bits = KDP_LOG_DEFAULT; - log->GetMask().Reset(flag_bits); - log->GetOptions().Reset(log_options); + g_log->GetMask().Reset(flag_bits); + g_log->GetOptions().Reset(log_options); } - return log; + g_log_enabled = true; + return g_log; } void @@ -170,7 +174,7 @@ ProcessKDPLog::ListLogCategories (Stream *strm) void ProcessKDPLog::LogIf (uint32_t mask, const char *format, ...) { - LogSP log (ProcessKDPLog::GetLogIfAllCategoriesSet (mask)); + Log *log (ProcessKDPLog::GetLogIfAllCategoriesSet (mask)); if (log) { va_list args; diff --git a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDPLog.h b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDPLog.h index ffdc471ff3a..0cb32d9b2dc 100644 --- a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDPLog.h +++ b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDPLog.h @@ -35,13 +35,13 @@ class ProcessKDPLog { public: - static lldb::LogSP + static lldb_private::Log * GetLogIfAllCategoriesSet(uint32_t mask = 0); static void DisableLog (const char **categories, lldb_private::Stream *feedback_strm); - static lldb::LogSP + static lldb_private::Log * EnableLog (lldb::StreamSP &log_stream_sp, uint32_t log_options, const char **categories, lldb_private::Stream *feedback_strm); static void diff --git a/lldb/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.cpp b/lldb/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.cpp index 33c5e47d0b2..8ce90e57fde 100644 --- a/lldb/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.cpp +++ b/lldb/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.cpp @@ -76,7 +76,7 @@ ThreadKDP::WillResume (StateType resume_state) ClearStackFrames(); - lldb::LogSP log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_STEP)); + Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_STEP)); if (log) log->Printf ("Resuming thread: %4.4" PRIx64 " with state: %s.", GetID(), StateAsCString(resume_state)); diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp b/lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp index 6b52a62ecb2..8eb4c612bdf 100644 --- a/lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp +++ b/lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp @@ -87,7 +87,7 @@ RegisterContextLLDB::RegisterContextLLDB void RegisterContextLLDB::InitializeZerothFrame() { - LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_UNWIND)); + Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_UNWIND)); ExecutionContext exe_ctx(m_thread.shared_from_this()); RegisterContextSP reg_ctx_sp = m_thread.GetRegisterContext(); @@ -227,7 +227,7 @@ RegisterContextLLDB::InitializeZerothFrame() void RegisterContextLLDB::InitializeNonZerothFrame() { - LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_UNWIND)); + Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_UNWIND)); if (IsFrameZero ()) { m_frame_type = eNotAValidFrame; @@ -591,7 +591,7 @@ RegisterContextLLDB::GetFastUnwindPlanForFrame () { if (unwind_plan_sp->PlanValidAtAddress (m_current_pc)) { - LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_UNWIND)); + Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_UNWIND)); if (log && log->GetVerbose()) { if (m_fast_unwind_plan_sp) @@ -1456,7 +1456,7 @@ RegisterContextLLDB::ReadPC (addr_t& pc) void RegisterContextLLDB::UnwindLogMsg (const char *fmt, ...) { - LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_UNWIND)); + Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_UNWIND)); if (log) { va_list args; @@ -1482,7 +1482,7 @@ RegisterContextLLDB::UnwindLogMsg (const char *fmt, ...) void RegisterContextLLDB::UnwindLogMsgVerbose (const char *fmt, ...) { - LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_UNWIND)); + Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_UNWIND)); if (log && log->GetVerbose()) { va_list args; diff --git a/lldb/source/Plugins/Process/Utility/UnwindLLDB.cpp b/lldb/source/Plugins/Process/Utility/UnwindLLDB.cpp index 4f4d2182f25..db0306bd015 100644 --- a/lldb/source/Plugins/Process/Utility/UnwindLLDB.cpp +++ b/lldb/source/Plugins/Process/Utility/UnwindLLDB.cpp @@ -108,7 +108,7 @@ UnwindLLDB::AddOneMoreFrame (ABI *abi) if (m_unwind_complete) return false; - LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_UNWIND)); + Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_UNWIND)); CursorSP cursor_sp(new Cursor ()); // Frame zero is a little different diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp index fd9cecaa397..edce0543579 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp @@ -171,7 +171,7 @@ GDBRemoteCommunication::CalculcateChecksum (const char *payload, size_t payload_ size_t GDBRemoteCommunication::SendAck () { - LogSP log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_PACKETS)); + Log *log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_PACKETS)); ConnectionStatus status = eConnectionStatusSuccess; char ch = '+'; const size_t bytes_written = Write (&ch, 1, status, NULL); @@ -184,7 +184,7 @@ GDBRemoteCommunication::SendAck () size_t GDBRemoteCommunication::SendNack () { - LogSP log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_PACKETS)); + Log *log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_PACKETS)); ConnectionStatus status = eConnectionStatusSuccess; char ch = '-'; const size_t bytes_written = Write (&ch, 1, status, NULL); @@ -213,7 +213,7 @@ GDBRemoteCommunication::SendPacketNoLock (const char *payload, size_t payload_le packet.PutChar('#'); packet.PutHex8(CalculcateChecksum (payload, payload_length)); - LogSP log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_PACKETS)); + Log *log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_PACKETS)); ConnectionStatus status = eConnectionStatusSuccess; size_t bytes_written = Write (packet.GetData(), packet.GetSize(), status, NULL); if (log) @@ -223,7 +223,7 @@ GDBRemoteCommunication::SendPacketNoLock (const char *payload, size_t payload_le // logs all of the packet will set a boolean so that we don't dump this more // than once if (!m_history.DidDumpToLog ()) - m_history.Dump (log.get()); + m_history.Dump (log); log->Printf ("<%4zu> send packet: %.*s", bytes_written, (int)packet.GetSize(), packet.GetData()); } @@ -285,7 +285,7 @@ GDBRemoteCommunication::WaitForPacketWithTimeoutMicroSecondsNoLock (StringExtrac uint8_t buffer[8192]; Error error; - LogSP log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_PACKETS | GDBR_LOG_VERBOSE)); + Log *log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_PACKETS | GDBR_LOG_VERBOSE)); // Check for a packet from our cache first without trying any reading... if (CheckForPacket (NULL, 0, packet)) @@ -340,7 +340,7 @@ GDBRemoteCommunication::CheckForPacket (const uint8_t *src, size_t src_len, Stri // Put the packet data into the buffer in a thread safe fashion Mutex::Locker locker(m_bytes_mutex); - LogSP log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_PACKETS)); + Log *log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_PACKETS)); if (src && src_len > 0) { @@ -457,7 +457,7 @@ GDBRemoteCommunication::CheckForPacket (const uint8_t *src, size_t src_len, Stri // logs all of the packet will set a boolean so that we don't dump this more // than once if (!m_history.DidDumpToLog ()) - m_history.Dump (log.get()); + m_history.Dump (log); log->Printf ("<%4zu> read packet: %.*s", total_length, (int)(total_length), m_bytes.c_str()); } diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp index df89058d6a6..9351b93761b 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp @@ -311,7 +311,7 @@ GDBRemoteCommunicationClient::SendPacketAndWaitForResponse ) { Mutex::Locker locker; - LogSP log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_PROCESS)); + Log *log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_PROCESS)); size_t response_len = 0; if (GetSequenceMutex (locker)) { @@ -527,7 +527,7 @@ GDBRemoteCommunicationClient::SendContinuePacketAndWaitForResponse ) { m_curr_tid = LLDB_INVALID_THREAD_ID; - LogSP log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_PROCESS)); + Log *log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_PROCESS)); if (log) log->Printf ("GDBRemoteCommunicationClient::%s ()", __FUNCTION__); @@ -677,7 +677,7 @@ GDBRemoteCommunicationClient::SendContinuePacketAndWaitForResponse } else if (m_async_packet_predicate.GetValue()) { - LogSP packet_log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_PACKETS)); + Log * packet_log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_PACKETS)); // We are supposed to send an asynchronous packet while // we are running. @@ -837,7 +837,7 @@ GDBRemoteCommunicationClient::SendInterrupt ) { timed_out = false; - LogSP log (ProcessGDBRemoteLog::GetLogIfAnyCategoryIsSet (GDBR_LOG_PROCESS | GDBR_LOG_PACKETS)); + Log *log (ProcessGDBRemoteLog::GetLogIfAnyCategoryIsSet (GDBR_LOG_PROCESS | GDBR_LOG_PACKETS)); if (IsRunning()) { @@ -2283,7 +2283,7 @@ GDBRemoteCommunicationClient::GetCurrentThreadIDs (std::vector<lldb::tid_t> &thr #if defined (LLDB_CONFIGURATION_DEBUG) // assert(!"ProcessGDBRemote::UpdateThreadList() failed due to not getting the sequence mutex"); #else - LogSP log (ProcessGDBRemoteLog::GetLogIfAnyCategoryIsSet (GDBR_LOG_PROCESS | GDBR_LOG_PACKETS)); + Log *log (ProcessGDBRemoteLog::GetLogIfAnyCategoryIsSet (GDBR_LOG_PROCESS | GDBR_LOG_PACKETS)); if (log) log->Printf("error: failed to get packet sequence mutex, not sending packet 'qfThreadInfo'"); #endif diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp index e83ea40c91e..7f7361522a4 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp @@ -60,7 +60,7 @@ GDBRemoteCommunicationServer::~GDBRemoteCommunicationServer() //{ // GDBRemoteCommunicationServer *server = (GDBRemoteCommunicationServer*) arg; // -// LogSP log;// (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_PROCESS)); +// Log *log;// (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_PROCESS)); // if (log) // log->Printf ("ProcessGDBRemote::%s (arg = %p, pid = %i) thread starting...", __FUNCTION__, arg, process->GetID()); // diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp index 08c9de74b15..bf3dc4d8636 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp @@ -248,13 +248,13 @@ GDBRemoteRegisterContext::ReadRegisterBytes (const RegisterInfo *reg_info, DataE } else { - LogSP log (ProcessGDBRemoteLog::GetLogIfAnyCategoryIsSet (GDBR_LOG_THREAD | GDBR_LOG_PACKETS)); #if LLDB_CONFIGURATION_DEBUG StreamString strm; gdb_comm.DumpHistory(strm); Host::SetCrashDescription (strm.GetData()); assert (!"Didn't get sequence mutex for read register."); #else + Log *log (ProcessGDBRemoteLog::GetLogIfAnyCategoryIsSet (GDBR_LOG_THREAD | GDBR_LOG_PACKETS)); if (log) { if (log->GetVerbose()) @@ -468,7 +468,7 @@ GDBRemoteRegisterContext::WriteRegisterBytes (const lldb_private::RegisterInfo * } else { - LogSP log (ProcessGDBRemoteLog::GetLogIfAnyCategoryIsSet (GDBR_LOG_THREAD | GDBR_LOG_PACKETS)); + Log *log (ProcessGDBRemoteLog::GetLogIfAnyCategoryIsSet (GDBR_LOG_THREAD | GDBR_LOG_PACKETS)); if (log) { if (log->GetVerbose()) @@ -540,7 +540,7 @@ GDBRemoteRegisterContext::ReadAllRegisterValues (lldb::DataBufferSP &data_sp) } else { - LogSP log (ProcessGDBRemoteLog::GetLogIfAnyCategoryIsSet (GDBR_LOG_THREAD | GDBR_LOG_PACKETS)); + Log *log (ProcessGDBRemoteLog::GetLogIfAnyCategoryIsSet (GDBR_LOG_THREAD | GDBR_LOG_PACKETS)); if (log) { if (log->GetVerbose()) @@ -673,7 +673,7 @@ GDBRemoteRegisterContext::WriteAllRegisterValues (const lldb::DataBufferSP &data } else { - LogSP log (ProcessGDBRemoteLog::GetLogIfAnyCategoryIsSet (GDBR_LOG_THREAD | GDBR_LOG_PACKETS)); + Log *log (ProcessGDBRemoteLog::GetLogIfAnyCategoryIsSet (GDBR_LOG_THREAD | GDBR_LOG_PACKETS)); if (log) { if (log->GetVerbose()) diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp index 07f4d7b70c1..05c39f97fb5 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -578,7 +578,7 @@ ProcessGDBRemote::DoLaunch (Module *exe_module, const ProcessLaunchInfo &launch_ // ::LogSetBitMask (GDBR_LOG_DEFAULT); // ::LogSetOptions (LLDB_LOG_OPTION_THREADSAFE | LLDB_LOG_OPTION_PREPEND_TIMESTAMP | LLDB_LOG_OPTION_PREPEND_PROC_AND_THREAD); // ::LogSetLogFile ("/dev/stdout"); - LogSP log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_PROCESS)); + Log *log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_PROCESS)); ObjectFile * object_file = exe_module->GetObjectFile(); if (object_file) @@ -798,7 +798,7 @@ ProcessGDBRemote::ConnectToDebugserver (const char *connect_url) void ProcessGDBRemote::DidLaunchOrAttach () { - LogSP log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_PROCESS)); + Log *log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_PROCESS)); if (log) log->Printf ("ProcessGDBRemote::DidLaunch()"); if (GetID() != LLDB_INVALID_PROCESS_ID) @@ -1036,7 +1036,7 @@ Error ProcessGDBRemote::DoResume () { Error error; - LogSP log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_PROCESS)); + Log *log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_PROCESS)); if (log) log->Printf ("ProcessGDBRemote::Resume()"); @@ -1293,7 +1293,7 @@ bool ProcessGDBRemote::UpdateThreadList (ThreadList &old_thread_list, ThreadList &new_thread_list) { // locker will keep a mutex locked until it goes out of scope - LogSP log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_THREAD)); + Log *log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_THREAD)); if (log && log->GetMask().Test(GDBR_LOG_VERBOSE)) log->Printf ("ProcessGDBRemote::%s (pid = %" PRIu64 ")", __FUNCTION__, GetID()); @@ -1680,7 +1680,7 @@ ProcessGDBRemote::InterruptIfRunning { Error error; - LogSP log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS)); + Log *log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS)); bool paused_private_state_thread = false; const bool is_running = m_gdb_comm.IsRunning(); @@ -1749,7 +1749,7 @@ ProcessGDBRemote::InterruptIfRunning Error ProcessGDBRemote::WillDetach () { - LogSP log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS)); + Log *log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS)); if (log) log->Printf ("ProcessGDBRemote::WillDetach()"); @@ -1767,7 +1767,7 @@ Error ProcessGDBRemote::DoDetach() { Error error; - LogSP log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS)); + Log *log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS)); if (log) log->Printf ("ProcessGDBRemote::DoDetach()"); @@ -1798,7 +1798,7 @@ Error ProcessGDBRemote::DoDestroy () { Error error; - LogSP log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS)); + Log *log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS)); if (log) log->Printf ("ProcessGDBRemote::DoDestroy()"); @@ -2177,7 +2177,7 @@ ProcessGDBRemote::EnableBreakpointSite (BreakpointSite *bp_site) Error error; assert (bp_site != NULL); - LogSP log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_BREAKPOINTS)); + Log *log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_BREAKPOINTS)); user_id_t site_id = bp_site->GetID(); const addr_t addr = bp_site->GetLoadAddress(); if (log) @@ -2241,7 +2241,7 @@ ProcessGDBRemote::DisableBreakpointSite (BreakpointSite *bp_site) assert (bp_site != NULL); addr_t addr = bp_site->GetLoadAddress(); user_id_t site_id = bp_site->GetID(); - LogSP log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_BREAKPOINTS)); + Log *log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_BREAKPOINTS)); if (log) log->Printf ("ProcessGDBRemote::DisableBreakpointSite (site_id = %" PRIu64 ") addr = 0x%8.8" PRIx64, site_id, (uint64_t)addr); @@ -2307,7 +2307,7 @@ ProcessGDBRemote::EnableWatchpoint (Watchpoint *wp, bool notify) { user_id_t watchID = wp->GetID(); addr_t addr = wp->GetLoadAddress(); - LogSP log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_WATCHPOINTS)); + Log *log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_WATCHPOINTS)); if (log) log->Printf ("ProcessGDBRemote::EnableWatchpoint(watchID = %" PRIu64 ")", watchID); if (wp->IsEnabled()) @@ -2349,7 +2349,7 @@ ProcessGDBRemote::DisableWatchpoint (Watchpoint *wp, bool notify) { user_id_t watchID = wp->GetID(); - LogSP log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_WATCHPOINTS)); + Log *log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_WATCHPOINTS)); addr_t addr = wp->GetLoadAddress(); @@ -2401,7 +2401,7 @@ Error ProcessGDBRemote::DoSignal (int signo) { Error error; - LogSP log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS)); + Log *log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS)); if (log) log->Printf ("ProcessGDBRemote::DoSignal (signal = %d)", signo); @@ -2464,7 +2464,7 @@ ProcessGDBRemote::StartDebugserverProcess (const char *debugserver_url, const Pr m_stdio_communication.Clear(); - LogSP log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_PROCESS)); + Log *log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_PROCESS)); Args &debugserver_args = debugserver_launch_info.GetArguments(); char arg_cstr[PATH_MAX]; @@ -2553,7 +2553,7 @@ ProcessGDBRemote::StartDebugserverProcess (const char *debugserver_url, const Pr m_debugserver_pid = LLDB_INVALID_PROCESS_ID; if (error.Fail() || log) - error.PutToLog(log.get(), "Host::LaunchProcess (launch_info) => pid=%" PRIu64 ", path='%s'", m_debugserver_pid, debugserver_path); + error.PutToLog(log, "Host::LaunchProcess (launch_info) => pid=%" PRIu64 ", path='%s'", m_debugserver_pid, debugserver_path); } else { @@ -2588,7 +2588,7 @@ ProcessGDBRemote::MonitorDebugserverProcess // "debugserver_pid" argument passed in is the process ID for // debugserver that we are tracking... - LogSP log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS)); + Log *log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS)); ProcessGDBRemote *process = (ProcessGDBRemote *)callback_baton; @@ -2689,7 +2689,7 @@ ProcessGDBRemote::Initialize() bool ProcessGDBRemote::StartAsyncThread () { - LogSP log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS)); + Log *log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS)); if (log) log->Printf ("ProcessGDBRemote::%s ()", __FUNCTION__); @@ -2724,7 +2724,7 @@ ProcessGDBRemote::StartAsyncThread () void ProcessGDBRemote::StopAsyncThread () { - LogSP log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS)); + Log *log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS)); if (log) log->Printf ("ProcessGDBRemote::%s ()", __FUNCTION__); @@ -2757,7 +2757,7 @@ ProcessGDBRemote::AsyncThread (void *arg) { ProcessGDBRemote *process = (ProcessGDBRemote*) arg; - LogSP log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_PROCESS)); + Log *log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_PROCESS)); if (log) log->Printf ("ProcessGDBRemote::%s (arg = %p, pid = %" PRIu64 ") thread starting...", __FUNCTION__, arg, process->GetID()); @@ -2990,7 +2990,7 @@ ProcessGDBRemote::NewThreadNotifyBreakpointHit (void *baton, { // I don't think I have to do anything here, just make sure I notice the new thread when it starts to // run so I can stop it if that's what I want to do. - LogSP log (lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP)); + Log *log (lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP)); if (log) log->Printf("Hit New Thread Notification breakpoint."); return false; @@ -3000,7 +3000,7 @@ ProcessGDBRemote::NewThreadNotifyBreakpointHit (void *baton, bool ProcessGDBRemote::StartNoticingNewThreads() { - LogSP log (lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP)); + Log *log (lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP)); if (m_thread_create_bp_sp) { if (log && log->GetVerbose()) @@ -3032,7 +3032,7 @@ ProcessGDBRemote::StartNoticingNewThreads() bool ProcessGDBRemote::StopNoticingNewThreads() { - LogSP log (lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP)); + Log *log (lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP)); if (log && log->GetVerbose()) log->Printf ("Disabling new thread notification breakpoint."); diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.cpp index cb764238683..2bb6826e223 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.cpp @@ -22,39 +22,43 @@ using namespace lldb_private; // control access to our static g_log_sp by hiding it in a singleton function // that will construct the static g_lob_sp the first time this function is // called. -static LogSP & +static bool g_log_enabled = false; +static Log * g_log = NULL; +static Log * GetLog () { - static LogSP g_log_sp; - return g_log_sp; + if (!g_log_enabled) + return NULL; + return g_log; } -LogSP + +Log * ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (uint32_t mask) { - LogSP log(GetLog ()); + Log *log(GetLog ()); if (log && mask) { uint32_t log_mask = log->GetMask().Get(); if ((log_mask & mask) != mask) - return LogSP(); + return NULL; } return log; } -LogSP +Log * ProcessGDBRemoteLog::GetLogIfAnyCategoryIsSet (uint32_t mask) { - LogSP log(GetLog ()); + Log *log(GetLog ()); if (log && log->GetMask().Get() & mask) return log; - return LogSP(); + return NULL; } void ProcessGDBRemoteLog::DisableLog (const char **categories, Stream *feedback_strm) { - LogSP log (GetLog ()); + Log *log (GetLog ()); if (log) { uint32_t flag_bits = 0; @@ -91,7 +95,7 @@ ProcessGDBRemoteLog::DisableLog (const char **categories, Stream *feedback_strm) } if (flag_bits == 0) - GetLog ().reset(); + g_log_enabled = false; else log->GetMask().Reset (flag_bits); } @@ -99,24 +103,25 @@ ProcessGDBRemoteLog::DisableLog (const char **categories, Stream *feedback_strm) return; } -LogSP +Log * ProcessGDBRemoteLog::EnableLog (StreamSP &log_stream_sp, uint32_t log_options, const char **categories, Stream *feedback_strm) { // Try see if there already is a log - that way we can reuse its settings. // We could reuse the log in toto, but we don't know that the stream is the same. uint32_t flag_bits = 0; - LogSP log(GetLog ()); - if (log) - flag_bits = log->GetMask().Get(); + if (g_log) + flag_bits = g_log->GetMask().Get(); // Now make a new log with this stream if one was provided if (log_stream_sp) { - log.reset (new Log(log_stream_sp)); - GetLog () = log; + if (g_log) + g_log->SetStream(log_stream_sp); + else + g_log = new Log(log_stream_sp); } - if (log) + if (g_log) { bool got_unknown_category = false; for (size_t i=0; categories[i] != NULL; ++i) @@ -149,10 +154,11 @@ ProcessGDBRemoteLog::EnableLog (StreamSP &log_stream_sp, uint32_t log_options, c } if (flag_bits == 0) flag_bits = GDBR_LOG_DEFAULT; - log->GetMask().Reset(flag_bits); - log->GetOptions().Reset(log_options); + g_log->GetMask().Reset(flag_bits); + g_log->GetOptions().Reset(log_options); } - return log; + g_log_enabled = true; + return g_log; } void @@ -179,7 +185,7 @@ ProcessGDBRemoteLog::ListLogCategories (Stream *strm) void ProcessGDBRemoteLog::LogIf (uint32_t mask, const char *format, ...) { - LogSP log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (mask)); + Log *log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (mask)); if (log) { va_list args; diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.h b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.h index cf5e176a213..93734067f13 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.h +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.h @@ -35,16 +35,16 @@ class ProcessGDBRemoteLog { public: - static lldb::LogSP + static lldb_private::Log * GetLogIfAllCategoriesSet(uint32_t mask = 0); - static lldb::LogSP + static lldb_private::Log * GetLogIfAnyCategoryIsSet (uint32_t mask); static void DisableLog (const char **categories, lldb_private::Stream *feedback_strm); - static lldb::LogSP + static lldb_private::Log * EnableLog (lldb::StreamSP &log_stream_sp, uint32_t log_options, const char **categories, lldb_private::Stream *feedback_strm); static void diff --git a/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp index 001cc60aea1..4ac3f687aba 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp @@ -95,7 +95,7 @@ ThreadGDBRemote::WillResume (StateType resume_state) ClearStackFrames(); int signo = GetResumeSignal(); - lldb::LogSP log(lldb_private::GetLogIfAnyCategoriesSet (GDBR_LOG_THREAD)); + Log *log(lldb_private::GetLogIfAnyCategoriesSet (GDBR_LOG_THREAD)); if (log) log->Printf ("Resuming thread: %4.4" PRIx64 " with state: %s.", GetID(), StateAsCString(resume_state)); |

