DWARFContext: Make loading of sections thread-safe
authorPavel Labath <pavel@labath.sk>
Fri, 24 May 2019 08:04:03 +0000 (08:04 +0000)
committerPavel Labath <pavel@labath.sk>
Fri, 24 May 2019 08:04:03 +0000 (08:04 +0000)
commit8ac0bc9832a251837681b3a1cd53085ed8d594dc
tree9d06b0fcf6d3ca6066f24f574e1aa6c080b7933f
parentb087129b5d3bde08ddaefa021bbefb2f152ed409
DWARFContext: Make loading of sections thread-safe

Summary:
SymbolFileDWARF used to load debug sections in a thread-safe manner.
When we moved to DWARFContext, we dropped the thread-safe part, because
we thought it was not necessary.

It turns out this was only mostly correct.

The "mostly" part is there because this is a problem only if we use the
manual index, as that is the only source of intra-module paralelism.
Also, this only seems to occur for extremely simple files (like the ones
I've been creating for tests lately), where we've managed to start
indexing before loading the debug_str section. Then, two threads start
to load the section simultaneously and produce wrong results.

On more complex files, something seems to be loading the debug_str section
before we start indexing, as I haven't been able to reproduce this
there, but I have not investigated what it is.

I've tried to come up with a test for this, but I haven't been able to
reproduce the problem reliably. Still, while doing so, I created a way
to generate many compile units on demand. Given that most of our tests
work with only one or two compile units, it seems like this could be
useful anyway.

Reviewers: aprantl, JDevlieghere, clayborg

Subscribers: arphaman, lldb-commits

Differential Revision: https://reviews.llvm.org/D62316

llvm-svn: 361602
lldb/lit/SymbolFile/DWARF/parallel-indexing-stress.s [new file with mode: 0644]
lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.h