[lldb-dev] Logging different channels to different files

Greg Clayton gclayton at apple.com
Thu May 7 13:58:27 PDT 2015


It must be due to a deadlock during a signal handler. That is the only way this can deadlock. We can also localize the mutex locker solely around one "stream_sp->Write()" call and have everything go into the local "StreamString header" stream first and then have a:


static Mutex g_LogThreadedMutex(Mutex::eMutexTypeRecursive);

// Scope for locker
{ 
    Mutex::Locker locker (g_LogThreadedMutex);
    stream_sp->Write(header.GetString().data(), header.GetString().size());
}

We just need to avoid writing anything directly into "stream_sp" except for the above stream_sp->Write() call and we can reduce the 

> On May 7, 2015, at 1:25 PM, Zachary Turner <zturner at google.com> wrote:
> 
> void
> Log::VAPrintf(const char *format, va_list args)
> {
>     // Make a copy of our stream shared pointer in case someone disables our
>     // log while we are logging and releases the stream
>     StreamSP stream_sp(m_stream_sp);
>     if (stream_sp)
>     {
>         static uint32_t g_sequence_id = 0;
>         StreamString header;
> 		// Enabling the thread safe logging actually deadlocks right now.
> 		// Need to fix this at some point.
> //        static Mutex g_LogThreadedMutex(Mutex::eMutexTypeRecursive);
> //        Mutex::Locker locker (g_LogThreadedMutex);
> 
> 
> On Thu, May 7, 2015 at 9:09 AM Ed Maste <emaste at freebsd.org> wrote:
> On 7 May 2015 at 01:03, Vince Harron <vince at nethacker.com> wrote:
> > Okay, I don't know what I was thinking.
> >
> > Debugger.cpp:1317
> > It's re-using an existing stream if the filename is identical.
> >
> > The stomping that Ed is seeing might be solvable by using the -t flag as Jim
> > suggests.
> 
> Possibly - I only looked into this when I was first getting started
> with LLDB and enabled a large set of log channels to try to understand
> how everything worked. I distinctly recall that log entries were
> completely missing though, not just "interweaved" as the help for -t
> suggests.
> 
> Ah, this seems a bit bizarre:
> 
>     if (log_options == 0)
>         log_options = LLDB_LOG_OPTION_PREPEND_THREAD_NAME |
> LLDB_LOG_OPTION_THREADSAFE;
> 
> so by default we get the thread name and threadsafe logging, but if
> any options are set then they are not automatically set.
> 
> Oh, but I don't see anywhere LLDB_LOG_OPTION_THREADSAFE is checked.
> _______________________________________________
> lldb-dev mailing list
> lldb-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev
> _______________________________________________
> lldb-dev mailing list
> lldb-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev





More information about the lldb-dev mailing list