[PATCH] D72369: DWARFDebugLine.cpp: Format NULL as "(null)" to avoid UB

Hubert Tong via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 9 07:34:07 PST 2020


hubert.reinterpretcast marked 2 inline comments as done.
hubert.reinterpretcast added a comment.

In D72369#1809613 <https://reviews.llvm.org/D72369#1809613>, @jhenderson wrote:

> I think a better solution is to print something more meaningful. For example, "DW_LNS_unknown_<value>" or something similar. You can see examples of that with the DW_AT_unknown_* printing in debug-abbrev.s. I don't think that will be significantly more complex and will provide more user-friendly output.


Thanks for the pointer. I have set up "DW_LNS_unknown_<value>" printing based on the DW_AT_unknown_* printing.



================
Comment at: llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp:690
       if (OS)
         *OS << LNStandardString(Opcode);
       switch (Opcode) {
----------------
jhenderson wrote:
> If you put the fix in LNStandardString instead, this line will also print more user-friendly output in verbose mode (a test should be added for it, if you do).
I looked into this, and `LNStandardString` is part of a family of functions where returning an empty `StringRef` is the documented interface for unknown values.

`operator<<` is okay with empty `StringRef`s, and the opcode value is already printed. Changing the output here does not really fit with this patch.



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72369/new/

https://reviews.llvm.org/D72369





More information about the llvm-commits mailing list