<html><head><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Oct 24, 2019, at 3:02 PM, David Blaikie via Phabricator <<a href="mailto:reviews@reviews.llvm.org" class="">reviews@reviews.llvm.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">dblaikie added a comment.<br class=""><br class="">In D67723#1720509 <<a href="https://reviews.llvm.org/D67723#1720509" class="">https://reviews.llvm.org/D67723#1720509</a>>, @aprantl wrote:<br class=""><br class=""><blockquote type="cite" class="">In D67723#1720353 <<a href="https://reviews.llvm.org/D67723#1720353" class="">https://reviews.llvm.org/D67723#1720353</a>>, @rnk wrote:<br class=""><br class=""><blockquote type="cite" class="">In D67723#1717468 <<a href="https://reviews.llvm.org/D67723#1717468" class="">https://reviews.llvm.org/D67723#1717468</a>>, @aprantl wrote:<br class=""><br class=""><blockquote type="cite" class="">I agree that it would make sense to have a `-ginline-info-threshold=<#insns>` or `-gno-small-inline-functions` with a hardcoded threshold to implement the feature Paul described, and this patch seems to be a step in that direction, with the threshold being hardcoded to 0.<br class=""></blockquote><br class=""><br class="">OK. :)<br class=""><br class=""><blockquote type="cite" class=""><blockquote type="cite" class="">We are motivated by one tool in particular at the moment, but if we're going to take the time to add a knob, we might as well make it work for DWARF.<br class=""></blockquote><br class="">Here you got me confused: When I read "we might as well make it work for DWARF", I read that as "we should emit the inlined instructions with line 0 under a DWARF debugger tuning". But that reading seems to to contradict your next sentence:<br class=""><br class=""><blockquote type="cite" class="">If the user cares enough to find this flag, it seems more user friendly to make it behave the same rather than making it format-dependent.<br class=""></blockquote><br class="">Can you clarify?<br class=""></blockquote><br class="">If we use line zero for DWARF, gdb will not behave in the way documented by the function attribute in LangRef. I was the one who suggested the wording there, so maybe we could come up with new wording that describes what the user should expect in the debugger when using line zero. However, given the behavior I show below, I have a hard time imagining the use case for it.<br class=""></blockquote><br class=""><br class="">I didn't realize that GDB also had problems; I thought that this was a problem that only affected Windows debuggers.<br class=""></blockquote><br class=""><br class="">I don't think the behavior Reid described would be a "problem" - it seems to me like the only behavior the debugger could provide if those instructions are attributed to line zero.<br class=""><br class=""><blockquote type="cite" class=""><br class=""><br class=""><blockquote type="cite" class="">I applied the version of this patch that uses getMergedLocation, compiled this program, and ran it under gdb:<br class=""><br class=""> volatile int x;<br class=""> static inline void foo() {<br class=""> ++x;<br class=""> *(volatile int*)0 = 42; // crash<br class=""> ++x;<br class=""> }<br class=""> int main() {<br class=""> ++x; // line 8<br class=""> foo(); // line 9<br class=""> ++x;<br class=""> return x;<br class=""> }<br class=""><br class=""><br class="">If we apply line zero, the debugger stops on line 8:<br class=""><br class=""> Program received signal SIGSEGV, Segmentation fault.<br class=""> 0x000000000040111e in main () at t.cpp:8<br class=""> 8 ++x;<br class=""> (gdb) bt<br class=""> #0 0x000000000040111e in main () at t.cpp:8<br class=""><br class=""><br class="">The inline frame is gone, as expected for this flag, but the current location does not reflect the site of the call to `foo`. So, if we want it to behave as documented, we have to put the call site location on some instructions.<br class=""><br class="">Alternatively, if I arrange things like this, the crash is attributed to line `return x`, which is completely unrelated to the inline call site:<br class=""><br class=""> static inline void foo() {<br class=""> ++x;<br class=""> if (x) {<br class=""> *(volatile int*)0 = 42; // crash<br class=""> __builtin_unreachable();<br class=""> }<br class=""> ++x;<br class=""> }<br class=""><br class=""><br class="">This means that if line zero is used, the source location shown in the debugger becomes sensitive to code layout, which is arbitrary.<br class=""><br class="">These experiments are convincing me that, in general, line zero isn't that helpful for DWARF consumers. If the goal is to get smooth stepping, we may want to refocus on getting reliable is_stmt bits in the line table.<br class=""></blockquote><br class="">The Swift compiler is far more aggressive in using line 0 than Clang, and consequently LLDB is much better at handling line 0 than even GDB, and that can skew my perception :-)<br class=""></blockquote><br class="">What behavior does LLDB have in the example Reid gave?<br class=""></div></div></blockquote><div><br class=""></div><div>I short-circuited a little by marking the function always_inline and putting a .loc 1 0 0 before the inlined instructions, so I hope that didn't butcher the example, but I didn't want to wait for clang to compile. LLDB says</div><div style="font-size: 10px;"><br class=""></div><div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo; color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">* thread #1, queue = </span><span style="font-variant-ligatures: no-common-ligatures; color: #39c026" class="">'com.apple.main-thread'</span><span style="font-variant-ligatures: no-common-ligatures" class="">, stop reason = </span><span style="font-variant-ligatures: no-common-ligatures; color: #ca3323" class="">EXC_BAD_ACCESS (code=1, address=0x0)</span></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo; color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> frame #0: </span><span style="font-variant-ligatures: no-common-ligatures; color: #aaab25" class="">0x0000000100000f9f</span><span style="font-variant-ligatures: no-common-ligatures" class=""> a.out`main at </span><span style="font-variant-ligatures: no-common-ligatures; color: #38b9c7" class="">reid.c</span><span style="font-variant-ligatures: no-common-ligatures" class="">:</span><span style="font-variant-ligatures: no-common-ligatures; color: #aaab25" class="">0</span><span style="font-variant-ligatures: no-common-ligatures" class=""> [opt]</span></div></div><div><br class=""></div><div>If the intended behavior is to show the crash at the call site like LangRef in the patch suggest then line 0 will certainly not achieve that. I implicitly assumed the wording in LangRef would follow the implementation if we switched to line 0. </div><div><br class=""></div><div>-- adrian</div><div><br class=""></div><blockquote type="cite" class=""><div class=""><div class=""><br class=""><blockquote type="cite" class="">Give how popular GDB is, I don't want to intentionally break compatibility with it, so I think this patch is okay. If we wanted we can put an if-debugger-tuning-is-LLDB-getMergedLocation condition in. Otherwise documenting that this is necessary for compatibility with popular debuggers, seems fine to me, too.<br class=""></blockquote><br class=""><br class=""><br class=""><br class="">Repository:<br class=""> rG LLVM Github Monorepo<br class=""><br class="">CHANGES SINCE LAST ACTION<br class=""> <a href="https://reviews.llvm.org/D67723/new/" class="">https://reviews.llvm.org/D67723/new/</a><br class=""><br class=""><a href="https://reviews.llvm.org/D67723" class="">https://reviews.llvm.org/D67723</a><br class=""><br class=""><br class=""><br class=""></div></div></blockquote></div><br class=""></body></html>