DWARFDebugLine.cpp: Format unknown line number standard opcodes
authorHubert Tong <hubert.reinterpretcast@gmail.com>
Wed, 15 Jan 2020 15:42:27 +0000 (10:42 -0500)
committerHubert Tong <hubert.reinterpretcast@gmail.com>
Wed, 15 Jan 2020 15:45:50 +0000 (10:45 -0500)
commit63b428e3861bed666525b3af56cd50e14ab30495
tree27c25bbbd431701260351a7f3505371c809d5453
parente429f24ed8b16149ad668edd3fb000a3a56c8e40
DWARFDebugLine.cpp: Format unknown line number standard opcodes

Summary:
This patch implements `formatv()` formatting for `dwarf::LineNumberOps`
and makes use of it for the `llvm-dwarfdump --debug-line` dump.

Previously, unknown line number standard opcodes would lead to undefined
behaviour. The code would attempt to format the data pointer of an empty
`StringRef` (a null pointer) using `%s`. According to the description
for `format()`, use of that interface carries the "risk of `printf`".
Passing a null pointer in place of an array to a C library function
results in undefined behaviour.

Reviewers: jhenderson, daltenty, stevewan

Reviewed By: jhenderson

Subscribers: aprantl, hiraditya, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D72369
llvm/include/llvm/BinaryFormat/Dwarf.h
llvm/lib/BinaryFormat/Dwarf.cpp
llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
llvm/test/tools/llvm-dwarfdump/X86/debug-line.s