Introduce getDynamicString to provide better
error handling whenever indexing dynamic string table is needed.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
Do you find another use case of printDynamicString? If yes, can you name it?
llvm/tools/llvm-readobj/ELFDumper.cpp | ||
---|---|---|
300 ↗ | (On Diff #209624) | Delete = true. The default argument is not used I think. |
llvm/test/tools/llvm-readobj/elf-dynamic-malformed.test | ||
---|---|---|
172 ↗ | (On Diff #209752) | Isn't it inconsistent? For line above you print <error>, but here you print [<error>]. |
llvm/tools/llvm-readobj/ELFDumper.cpp | ||
1973 ↗ | (On Diff #209752) | You do not need else after return: if (DynamicStringTable.empty()) return "<String table is empty or was not found>"; if (Value < DynamicStringTable.size()) return DynamicStringTable.data() + Value; |
llvm/test/tools/llvm-readobj/elf-dynamic-malformed.test | ||
---|---|---|
172 ↗ | (On Diff #209752) | Title updated to reflect that it is not NFC. |
llvm/test/tools/llvm-readobj/elf-dynamic-malformed.test | ||
---|---|---|
172 ↗ | (On Diff #209752) | So, previously we printed [valid string] and <error text>. @jhenderson, what do you think? |
llvm/test/tools/llvm-readobj/elf-dynamic-malformed.test | ||
---|---|---|
172 ↗ | (On Diff #209752) | I'm fine with either choice (though I have a slight preference for non-capitalized messages) |
llvm/test/tools/llvm-readobj/elf-dynamic-malformed.test | ||
---|---|---|
172 ↗ | (On Diff #209752) | I am talking about the types of brackets used, not about capitalization. I.e. before this patch we had 2 forms: [..], <..> and it introduced a third one: [<..>] |
llvm/test/tools/llvm-readobj/elf-dynamic-malformed.test | ||
---|---|---|
172 ↗ | (On Diff #209752) | My thought is that [<...>] looks a bit weird, especially when it's inconsistent. That being said, the two are significantly different parts of the output - one is in the header blurb at the start of the output, the other is in the dynamic table output, so actually I'm not sure consistency here is such an issue. In dynamic table printing, everything is surrounded by square brackets for good output. Not having the square brackets could be confusing for consumers when they hit bad output, I guess. I think I could make an argument for it either way around, and I don't think either stands out more than the other. Therefore, I think we should just go with what is easiest in the code. In this case, I think that's the current proposed patch, since it avoids having something come back from getDynamicString saying whether to add the square brackets or not. I don't really mind though, if a good alternative implementation can be found for the other approach. |
I am OK with this patch.
llvm/test/tools/llvm-readobj/elf-dynamic-malformed.test | ||
---|---|---|
172 ↗ | (On Diff #209752) | I do not really like the new output, but it is not so critical probably. |