I've tested the patch and It works fine. Using gimp as a target
process, I've compared my patch and rewinddir. I found there is no big
difference in execution time between two patches.
I guess getdents used in readdir can read enough entries at once.
Thanks.
Tested-by: Masatake YAMATO <yamato(a)redhat.com>
Masatake YAMATO
> On Mon, 16 Dec 2013 16:24:26 +0100, Mark Wielaard wrote:
> > --- a/libdwfl/linux-pid-attach.c
> > +++ b/libdwfl/linux-pid-attach.c
> > @@ -164,6 +164,9 @@ pid_next_thread (Dwfl *dwfl __attribute__
> > ((unused)), void *
> > {
> > struct pid_arg *pid_arg = dwfl_arg;
> > struct dirent *dirent;
> > + /* Start fresh on first traversal. */
> > + if (*thread_argp == NULL)
> > + rewinddir (pid_arg->dir);
> > do
> > {
> > errno = 0;
>
> I also find this patch somehow more suitable / good enough.
I pushed this variant of the fix as attached.
Thanks for reporting Masatake and sorry we went with the simpler fix.
Cheers,
Mark