<div dir="ltr">(I will say "LTOrErr" is a slightly confusing variable name, given the prevalence of "LTO" as a known acronym... )</div><br><div class="gmail_quote"><div dir="ltr">On Mon, Mar 12, 2018 at 8:27 AM James Henderson via Phabricator via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">jhenderson created this revision.<br>
jhenderson added reviewers: ruiu, espindola.<br>
Herald added subscribers: arichardson, emaste.<br>
<br>
This is a companion change to <a href="https://reviews.llvm.org/D44382" rel="noreferrer" target="_blank">https://reviews.llvm.org/D44382</a>. That change changes the debug line parser interface to report LLVM errors, and to improve the error/warning reporting mechanism to not use fprintf(stderr, ...).<br>
<br>
As noted in the description on <a href="https://reviews.llvm.org/D44382" rel="noreferrer" target="_blank">https://reviews.llvm.org/D44382</a>, these warnings were not using the errs() stream, and so were not always being flushed properly by LLD on shutdown. To test this, I have extended the bad-debug undefined symbol message case to show that a corresponding warning is printed, if the debug line cannot be parsed.<br>
<br>
<br>
Repository:<br>
rLLD LLVM Linker<br>
<br>
<a href="https://reviews.llvm.org/D44388" rel="noreferrer" target="_blank">https://reviews.llvm.org/D44388</a><br>
<br>
Files:<br>
ELF/InputFiles.cpp<br>
test/ELF/Inputs/undef-bad-debug.s<br>
test/ELF/undef.s<br>
<br>
<br>
Index: test/ELF/undef.s<br>
===================================================================<br>
--- test/ELF/undef.s<br>
+++ test/ELF/undef.s<br>
@@ -34,6 +34,7 @@<br>
# CHECK: >>> referenced by undef-debug.s:11 (dir{{/|\\}}undef-debug.s:11)<br>
# CHECK: >>> {{.*}}.o:(.text.2+0x0)<br>
<br>
+# CHECK: warning: parsing line table prologue at 0x00000000 should have ended at 0x00000038 but it ended at 0x00000037<br>
# CHECK: error: undefined symbol: zed6<br>
# CHECK: >>> referenced by {{.*}}tmp4.o:(.text+0x0)<br>
<br>
Index: test/ELF/Inputs/undef-bad-debug.s<br>
===================================================================<br>
--- test/ELF/Inputs/undef-bad-debug.s<br>
+++ test/ELF/Inputs/undef-bad-debug.s<br>
@@ -1,7 +1,37 @@<br>
.section .text,"ax"<br>
sym:<br>
.quad zed6<br>
-<br>
+<br>
+.section .debug_line,"",@progbits<br>
+ .long .Lunit_end - .Lunit_start # unit length<br>
+.Lunit_start:<br>
+ .short 4 # version<br>
+ .long .Lprologue_end - .Lprologue_start # prologue length<br>
+.Lprologue_start:<br>
+ .byte 1 # minimum instruction length<br>
+ .byte 1 # maximum operatiosn per instruction<br>
+ .byte 1 # default is_stmt<br>
+ .byte -5 # line base<br>
+ .byte 14 # line range<br>
+ .byte 13 # opcode base<br>
+ .byte 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1 # standard opcode lengths<br>
+ .asciz "dir" # include directories<br>
+ .byte 0<br>
+ .asciz "undef-bad-debug.s" # file names<br>
+ .byte 1, 0, 0<br>
+ .byte 0<br>
+ .byte 0 # extraneous byte<br>
+.Lprologue_end:<br>
+ .byte 0, 9, 2 # DW_LNE_set_address<br>
+ .quad sym<br>
+ .byte 3 # DW_LNS_advance_line<br>
+ .byte 10<br>
+ .byte 1 # DW_LNS_copy<br>
+ .byte 2 # DW_LNS_advance_pc<br>
+ .byte 8<br>
+ .byte 0, 1, 1 # DW_LNE_end_sequence<br>
+.Lunit_end:<br>
+<br>
.section .debug_info,"",@progbits<br>
.long .Lcu_end - .Lcu_start # Length of Unit<br>
.Lcu_start:<br>
Index: ELF/InputFiles.cpp<br>
===================================================================<br>
--- ELF/InputFiles.cpp<br>
+++ ELF/InputFiles.cpp<br>
@@ -124,8 +124,11 @@<br>
// The second parameter is offset in .debug_line section<br>
// for compilation unit (CU) of interest. We have only one<br>
// CU (object file), so offset is always 0.<br>
- const DWARFDebugLine::LineTable *LT =<br>
- DwarfLine->getOrParseLineTable(LineData, 0, Dwarf, nullptr);<br>
+ auto LTOrErr = DwarfLine->getOrParseLineTable(LineData, 0, Dwarf, nullptr);<br>
+ const DWARFDebugLine::LineTable *LT = LTOrErr.Table;<br>
+ handleAllErrors(std::move(LTOrErr.Err),<br>
+ [&](DebugLineError &Err) { warn(Err.message()); },<br>
+ [&](ErrorInfoBase &Err) { error(Err.message()); });<br>
if (!LT)<br>
return;<br>
<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div>