[Lldb-commits] [lldb] r186033 - Add support for listing inferior thread names on Linux.

Kopec, Matt matt.kopec at intel.com
Mon Jul 15 12:22:22 PDT 2013


I'm not sure messages are the right place. We should also handle the case where a thread name changes through the pthread_setname_np call in the inferior.

Since there are Linux and FreeBSD subclasses of ProcessPOSIX, we could add something like a SetThreadName virtual function to ProcessPOSIX and replace the SetName call below with this function. How about that?

There is a separate gdb remote plugin which should get thread names through the packets it receives. So eventually, debugserver on Linux/FreeBSD will have to support retrieving of the thread names from the OS in some way but I don't think the Host class will be reused.

On 2013-07-15, at 1:51 PM, Ed Maste <emaste at freebsd.org>
 wrote:

> On 10 July 2013 16:53, Matt Kopec <Matt.Kopec at intel.com> wrote:
> 
>> Modified: lldb/trunk/source/Plugins/Process/POSIX/ProcessPOSIX.cpp
>> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/POSIX/ProcessPOSIX.cpp?rev=186033&r1=186032&r2=186033&view=diff
>> ==============================================================================
>> --- lldb/trunk/source/Plugins/Process/POSIX/ProcessPOSIX.cpp (original)
>> +++ lldb/trunk/source/Plugins/Process/POSIX/ProcessPOSIX.cpp Wed Jul 10 15:53:11 2013
>> @@ -491,8 +491,13 @@ ProcessPOSIX::RefreshStateAfterStop()
>>         {
>>             if (log)
>>                 log->Printf ("ProcessPOSIX::%s() adding thread, tid = %" PRIi64, __FUNCTION__, message.GetChildTID());
>> +            lldb::tid_t child_tid = message.GetChildTID();
>>             ThreadSP thread_sp;
>> -            thread_sp.reset(new POSIXThread(*this, message.GetChildTID()));
>> +            thread_sp.reset(new POSIXThread(*this, child_tid));
>> +
>> +            POSIXThread *thread = static_cast<POSIXThread*>(thread_sp.get());
>> +            thread->SetName(Host::GetThreadName(GetID(), child_tid).c_str());
>> +
>>             m_thread_list.AddThread(thread_sp);
>>         }
> 
> What do you think of passing the new thread's name in the message
> instead?  On FreeBSD we'll get the thread name via ptrace in
> ProcessMonitor.cpp rather than calling into the Host class, and will
> need to avoid this SetName call.  Also, the Linux implementation will
> have to avoid using the Host method when debugserver / gdb remote work
> happens anyway, yes?
> 
> I've #ifdef'd it out in my test tree, and threads & thread names work,
> at least for the attach case.
> 
> (lldb) thread list
> Process 15337 stopped
> * thread #1: tid = 0x19004, 0x0000000800b21c7c libc.so.7`_nanosleep +
> 12, name = 'td3, stop reason = trace
>  thread #2: tid = 0x18be9, 0x0000000800b21c7c libc.so.7`_nanosleep +
> 12, name = 'td2, stop reason = trace
>  thread #3: tid = 0x188b1, 0x0000000800b21c7c libc.so.7`_nanosleep +
> 12, name = 'td1, stop reason = trace
>  thread #4: tid = 0x19248, 0x0000000800b21c7c libc.so.7`_nanosleep +
> 12, name = 'threads, stop reason = trace
> 
> There's a single quote at the beginning of the name, but this doesn't
> seem to be specific to FreeBSD.
> 
> Also, on FreeBSD we conventionally list thread IDs in decimal, not
> hex, and gdb on Linux seems to do the same; perhaps we should have a
> target-specific tid formatter.





More information about the lldb-commits mailing list