Re: Multi-threaded dwarf parsing

Tom Tromey
2016-02-24T15:30:37Z

>> According to his description (from https://github.com/tromey/gdb/wiki):
>> "I think it doesn't help any real-world case". I'd like to ask you
>> directly, Tom: now that you debug Firefox (i.e. a quite large program)
>> daily with gdb, are you still of the same opinion? Of course, I'm also
>> interested in what others have to say about that. Is it something that
>> would have value, you think?

It's been a while since I thought about that branch.

I think it helps some scenarios, but maybe not as many as you'd like.
In fact, I think it doesn't help the two of the three most typical ways
I debug Firefox. (I realize this may not apply directly to your idea of
reading each CU independently; this is just the state of that branch.)

1. Run Firefox, then attach.

Here it is pretty normal for the attach to interrupt Firefox
somewhere in libxul.so -- the largest library (so much larger that it
is the only one that causes a noticeable pause at gdb startup).

But, it seems to me that stopping somewhere in libxul.so should
probably cause its debuginfo to be read.

2. Start gdb, set a breakpoint, then run Firefox.

Here debuginfo for every library must be read in order to set the
breakpoint correctly.

The third scenario, which would be helped, is:

3. Start gdb, run Firefox, and try to reproduce a crash. In this
situation gdb could read the debuginfo in the background and
everything would work nicely.

That said, I think my branch might have helped a tiny bit with scenario
#1, because it prioritized the largest files when reading debuginfo.
So, libxul.so would generally be read a bit earlier than it is now.

Reading each CU independently seems like a good idea to me. I think it
will stumble into various problems inside gdb, but I'd guess they are
all surmountable with enough work.

I think this could help with scenario #1. The ideal situation here
would be to read just the CU (or CUs?) covering the stop address; then
lazily read more as needed for types and such.

I suppose it could also help #2 if enough parallelism is there to be
had, though I'm a bit skeptical.

>> So, in a word, are there any gotchas or good reasons not do take this
>> path?

Pedro> The obvious gotchas are of course all the globals, and coming up with
Pedro> fine enough locking granularity that threads actually do run in parallel.

I think the gotcha situation got worse since I wrote my patch.

Now the DWARF reader can call into the type-printing system, which it
didn't before. It wasn't clear to me that this was safe. ISTR there
was some other change along these lines -- the DWARF reader calling out
to some gdb module that it previously did not -- but I can't remember
what it was any more.

The DWARF reader also has many more modes (debug_types, dwz, dwo/dwp)
than it did back then. So, this will require some careful auditing.

FWIW my threading patches were written during my time at Red Hat and so
you can use any part of that series without needing any paperwork from
me.

Tom