[Lldb-commits] [lldb] r186033 - Add support for listing inferior thread names on Linux.
matt.kopec at intel.com
Mon Jul 15 14:07:40 PDT 2013
Linux does something similar as in your example. I wasn't aware that you don't receive new thread notifications. That's really unfortunate.
So in your case, do you generate the new thread or exit thread messages in ProcessMonitor and send them? Or do you just update the thread list in the monitor?
For the renamed case I think we can make it a little smarter. We can put a hidden breakpoint on pthread_setname_np and/or prctl (haven't confirmed this but pthread_setname_np probably uses prctl to change the thread name). So when this gets hit we will know the inferior thread name will be changed.
On 2013-07-15, at 4:00 PM, Ed Maste <emaste at freebsd.org>
> On 15 July 2013 15:22, Kopec, Matt <matt.kopec at intel.com> wrote:
>> 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?
> On FreeBSD I don't have a ptrace event for a thread creation, so I'll
> need to check the process's thread list after each stop event and
> update any new / terminated / renamed threads; presumably this will be
> equivalent to what Linux needs to do for just the renamed case. So
> the SetThreadName implementation on FreeBSD is probably a no-op.
> For a concrete example, this is what I'm currently doing upon attach
> to create the threads:
> if (PTRACE(PT_GETLWPLIST, pid, (void *)tids, tdcnt) < 0)
> return false;
> for (int i = 0; i < tdcnt; i++)
> lldb::tid_t tid = tids[i];
> if (log)
> log->Printf("ProcessMonitor::%s() adding tid = %" PRIu64,
> __FUNCTION__, tid);
> lldb::ProcessSP processSP = process.shared_from_this();
> POSIXThread *thread;
> lldb::ThreadSP inferior;
> struct ptrace_lwpinfo plwp;
> inferior.reset(new POSIXThread(*processSP, tid));
> if (PTRACE(PT_LWPINFO, tid, &plwp, sizeof(plwp)) == 0)
> thread = static_cast<POSIXThread*>(inferior.get());
> // Let our process instance know the thread has stopped.
More information about the lldb-commits