The code we have currently reports an error if something is not right with the
profile section. Instead we can report a warning and continue dumping when it is possible.
This patch does it.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm/tools/llvm-readobj/ELFDumper.cpp | ||
---|---|---|
6579–6586 | This seems like a pattern we're likely to have in several different parts of the ELFDumper. Is there any code we could share to avoid duplication? Maybe it just makes sense to change getStaticSymbolName to report the warning/return the <?> itself? |
llvm/tools/llvm-readobj/ELFDumper.cpp | ||
---|---|---|
6579–6586 | From what I see, the getStaticSymbolName is used in one more place: template <class ELFT> void LLVMStyle<ELFT>::printAddrsig(const ELFFile<ELFT> *Obj) { ... for (uint64_t Sym : *V) { Expected<std::string> NameOrErr = this->dumper()->getStaticSymbolName(Sym); if (NameOrErr) { W.printNumber("Sym", *NameOrErr, Sym); continue; } reportWarning(NameOrErr.takeError(), this->FileName); W.printNumber("Sym", "<?>", Sym); } } And it looks like it should be reasonable and possible to do what you suggest. Follow-up? |
LGTM, but see my inline comment (happy for you to commit the two patches separately or as one).
llvm/tools/llvm-readobj/ELFDumper.cpp | ||
---|---|---|
6579–6586 | Normally, I'd say yes, follow-up, but in this case, D83208 looks small enough that it could be done as part of this, especially as most of that change is just undoing what some of this change does (in particular, the GetSymName lamdba replaces getStaticSymbolName in this change and then is just replaced back the other way again). I don't feel strongly about this though. |
llvm/tools/llvm-readobj/ELFDumper.cpp | ||
---|---|---|
6579–6586 | The problem is that D83208 is not a NFC. It changes the message reported for --addrsig (adds a prefix with the context): "warning: '[[FILE]]': unable to get symbol from section [index 2]: invalid symbol index (255)" -> "warning: '[[FILE]]': unable to read the name of symbol with index 255: unable to get symbol from section [index 2]: invalid symbol index (255)" That is why I slightly prefer to keep them separate. |
This seems like a pattern we're likely to have in several different parts of the ELFDumper. Is there any code we could share to avoid duplication? Maybe it just makes sense to change getStaticSymbolName to report the warning/return the <?> itself?