[llvm-symbolizer] - Fix the crash in GNU output style with --no-inlines and missing...
authorGeorgii Rymar <grimar@accesssoftek.com>
Thu, 28 Jan 2021 13:35:18 +0000 (16:35 +0300)
committerGeorgii Rymar <grimar@accesssoftek.com>
Sat, 30 Jan 2021 15:36:38 +0000 (18:36 +0300)
commitd22140687500f90830fe416d9c1e317f7c4535d5
tree428ae977637de4a44ae63653644c9a7553c7f40d
parentbb57a3422a09dcdd572ccb42767a0dabb5f966dd
[llvm-symbolizer] - Fix the crash in GNU output style with --no-inlines and missing input file.

Fixes https://bugs.llvm.org/show_bug.cgi?id=48882.

If the input file does not exist (or has a reading error), the
following code will crash if there are two or more input addresses.

```
auto ResOrErr = Symbolizer.symbolizeInlinedCode(
  ModuleName, {Offset, object::SectionedAddress::UndefSection});
Printer << (error(ResOrErr) ? DILineInfo() : ResOrErr.get().getFrame(0));
```

For the first address, `symbolizeInlinedCode` returns an error.
For the second address, `symbolizeInlinedCode` returns an empty result
(not an error) and `.getFrame(0)` will crash.

Differential revision: https://reviews.llvm.org/D95609
llvm/test/tools/llvm-symbolizer/output-style-inlined.test
llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp