[lldb-dev] How to enumerate stopped threads in C++ API?
Eugene Birukov via lldb-dev
lldb-dev at lists.llvm.org
Thu Mar 3 16:52:32 PST 2016
Thanks a lot! We'll try to profile what is going on, I'll let you know if we find something.Skipping locks if possible is always nice. I'll look into getting collection approach.
Eugene
> Subject: Re: [lldb-dev] How to enumerate stopped threads in C++ API?
> From: gclayton at apple.com
> Date: Thu, 3 Mar 2016 12:41:16 -0800
> CC: lldb-dev at lists.llvm.org; rdorr at microsoft.com
> To: eugenebi at hotmail.com
>
> Each call into the lldb::SB* API will take a target lock and possible a process read/write lock.
>
> We do have a SBThreadCollection class that we can use. Feel free to add an API like this to SBProcess:
>
>
> class SBProcess
> {
> SBThreadCollection GetThreads();
> };
>
> class SBThreadCollection
> {
> SBThreadCollection GetThreadsWithStopReasons();
> };
>
>
> The current API on process SBProcess::GetNumThreads() and SBProcess::GetThreadAtIndex() might have issues if you are doing things like evaluating an expression on another thread where you might request the number of threads and get 10, but then an expression runs on another thread and there are now maybe 8 or 12 threads, and then you call SBProcess::GetThreadAtIndex() and it might return you results that are different that what you wanted. If we return all threads at once, we won't run into this issue. Then you can have SBThreadCollection add a new methods to return a new list for all threads with stop reasons.
>
> That being said, hundreds of threads should not cause a huge bottleneck for single stop, but if you doing it many many many times it could be.
>
> Greg Clayton
>
> > On Mar 3, 2016, at 9:54 AM, Eugene Birukov via lldb-dev <lldb-dev at lists.llvm.org> wrote:
> >
> > Hi,
> >
> > I am working on a custom debugger on Linux and I am using LLDB C++ API for that. So far, from the functionality point of view the life is good, but I am running into severe performance issue.
> >
> > The problem is that the target application has literally hundreds of threads, and when the target process stops, I need to identify all the threads that have non-trivial stop reason. So, I am doing something like that:
> >
> > // Loop over threads
> > int numThreads = m_Process.GetNumThreads();
> > for (int threadIndex = 0; threadIndex < numThreads; ++threadIndex)
> > {
> > // Inspect the thread state
> > sbThread = m_Process.GetThreadAtIndex(threadIndex);
> > stopReason = sbThread.GetStopReason();
> > ...
> >
> >
> > Well, this loop turns out to be a bottleneck.
> >
> > So, is there any way to find all the stopped threads without iterating over the whole world?
> >
> > Thanks,
> > Eugene
> >
> >
> > _______________________________________________
> > lldb-dev mailing list
> > lldb-dev at lists.llvm.org
> > http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20160303/58875947/attachment.html>
More information about the lldb-dev
mailing list