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

Ed Maste emaste at freebsd.org
Thu Jul 30 09:00:01 PDT 2015


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.



More information about the lldb-dev mailing list