[lldb/DWARF] Change how we construct a llvm::DWARFContext
Summary: The goal of this patch is two-fold. First, it fixes a use-after-free in the construction of the llvm DWARFContext. This happened because the construction code was throwing away the lldb DataExtractors it got while reading the sections (unlike their llvm counterparts, these are also responsible for memory ownership). In most cases this did not matter, because the sections are just slices of the mmapped file data. But this isn't the case for compressed elf sections, in which case the section is decompressed into a heap buffer. A similar thing also happen with object files which are loaded from process memory. The second goal is to make it explicit which sections go into the llvm DWARFContext -- any access to the sections through both DWARF parsers carries a risk of parsing things twice, so it's better if this is a conscious decision. Also, this avoids loading completely irrelevant sections (e.g. .text). At present, the only section that needs to be present in the llvm DWARFContext is the debug_line_str. Using it through both APIs is not a problem, as there is no parsing involved. The first goal is achieved by loading the sections through the existing lldb DWARFContext APIs, which already do the caching. The second by explicitly enumerating the sections we wish to load. Reviewers: JDevlieghere, aprantl Subscribers: lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D72917
Loading
Please sign in to comment