[lldb-dev] Question (bug?) about thread tids when lldb loads a core dump.

Zachary Turner zturner at google.com
Thu Jul 30 09:14:39 PDT 2015


Would be great if we had a test that verified this.  I think we could do
this by making a small program that gets its own main thread id at runtime
and stores it in a local variable.  Generate a core dump while stopped at a
breakpoint right after the variable is initialized.  Then have the test
verify that whatever command reports the current thread is has the same
value as the variable.

On Thu, Jul 30, 2015 at 9:02 AM Ed Maste <emaste at freebsd.org> wrote:

> On 30 July 2015 at 10:44, Adrian McCarthy <amccarth at google.com> wrote:
> > I noticed that while studying the code in order to determine how to do
> the
> > same thing for Windows mini dumps.  Note that the loop index is treated
> as
> > the thread ID in ProcessElfCore::UpdateThreadList:
> >
> >     for (lldb::tid_t tid = 0; tid < num_threads; ++tid)
> >     {
> >         const ThreadData &td = m_thread_data[tid];
> >         lldb::ThreadSP thread_sp(new ThreadElfCore (*this, tid, td));
> >         new_thread_list.AddThread (thread_sp);
> >     }
> >
> > I wondered if this was intentional, to avoid confusion between the dead
> > threads and any live threads that might happen to be using a recycled
> thread
> > ID.
>
> I suspect it's not intentional, and that it just wasn't apparent to
> the original author how to obtain the tid. For FreeBSD the tid is
> (somewhat unintuitively) found in the pr_pid field of the NT_PRSTATUS
> note. I've put a change in review (http://reviews.llvm.org/D11652)
> that fixes this for FreeBSD:
>
> (lldb) thread list
> Process 0 stopped
> * thread #1: tid = 102802, 0x00000008008fa4fa
> libc.so.7`__sys_nanosleep + 10 at _nanosleep.S:3, name = 'sleep', stop
> reason = signal SIGABRT
>
> If someone can tell me where to obtain the Linux tid I'll update the patch.
> _______________________________________________
> lldb-dev mailing list
> lldb-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20150730/b9976ef1/attachment.html>


More information about the lldb-dev mailing list