<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 Apr 27, 2018, at 7:48 AM, Son Tuan VU <<a href="mailto:sontuan.vu119@gmail.com" class="">sontuan.vu119@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Hi all,<div class=""><br class=""></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial" class=""><div class="">Consider this ARM assembly code of a C function:</div><div class=""><br class=""></div><div class=""><div class="">00008124 <foo>:</div><div class=""> 8124: push {r4, r6, r7, lr}</div><div class=""> 8126: add r7, sp, #8</div><div class=""> 8128: mov r4, r0</div><div class=""> 812a: ldrsb.w r0, [r2]</div><div class=""> 812e: cmp r0, #1</div><div class=""> 8130: itt lt</div><div class=""> 8132: movlt r0, #85 ; 0x55</div><div class=""> 8134: poplt {r4, r6, r7, pc} // a function return</div><div class=""><br class=""></div><div class=""> 8136: ldrb.w ip, [r1, #3]</div><div class=""> 813a: ldrb.w lr, [r4, #3]</div><div class=""> 813e: movs r0, #85 ; 0x55</div><div class=""> 8140: cmp lr, ip</div><div class=""> 8142: bne.n 8168 <foo+0x44></div><div class=""><br class=""></div><div class=""> 8144: ldrb.w ip, [r1, #2]</div><div class=""> 8148: ldrb r3, [r4, #2]</div><div class=""> 814a: cmp r3, ip</div><div class=""> 814c: it ne</div><div class=""> 814e: popne {r4, r6, r7, pc} <span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline" class=""><span class=""> </span> // a function return</span></div><div class=""><br class=""></div><div class=""> 8150: ldrb.w ip, [r1, #1]</div><div class=""> 8154: ldrb r3, [r4, #1]</div><div class=""> 8156: cmp r3, ip</div><div class=""> 8158: bne.n 8168 <foo+0x44></div><div class=""><br class=""></div><div class=""> 815a: ldrb r1, [r1, #0]</div><div class=""> 815c: ldrb r3, [r4, #0]</div><div class=""> 815e: cmp r3, r1</div><div class=""> 8160: ittt eq</div><div class=""> 8162: moveq r0, #3</div><div class=""> 8164: strbeq r0, [r2, #0]</div><div class=""> 8166: moveq r0, #170 ; 0xaa</div><div class=""> 8168: pop {r4, r6, r7, pc}<span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline" class=""> </span><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration-style:initial;text-decoration-color:initial;background-color:rgb(255,255,255);float:none;display:inline" class=""><span class=""> </span> // a function return</span></div></div></div><div class=""><div class=""><br class=""></div><div class="">I have a variable <b class="">bar</b> and here's its corresponding DWARF DIE:</div><div class=""><div class=""><br class=""></div><div class=""><div class=""> <2><3b>: Abbrev Number: 3 (DW_TAG_formal_parameter)</div><div class=""> <3c> DW_AT_location : 0x0 (location list)</div><div class=""> <40> DW_AT_name : (indirect string, offset: 0x9e): <b class="">bar</b></div><div class=""> <44> DW_AT_decl_file : 1</div><div class=""> <45> DW_AT_decl_line : 34</div><div class=""> <46> DW_AT_type : <0x153></div></div><div class=""><br class=""></div><div class=""> // <b class="">Its location list</b></div><div class=""><div class=""> 00000000 00008124 0000812a (DW_OP_reg0 (r0))</div><div class=""> 0000000b 0000812a 00008136 (DW_OP_reg4 (r4))</div><div class=""> 00000016 <End of list></div></div><div class=""><br class=""></div><div class="">As you can see, it says that we can find <b class="">bar </b>in <b class="">r4</b> from <b class="">0x812a</b><b class=""> </b>to <b class="">0x8134 (poplt)</b>. However, this is only true when the <b class="">cmp </b>instruction at <b class="">0x812e</b> yields <b class="">less than (lt)</b>. So if the value in <b class="">r0 </b>is greater than 1 (which is the case of my input), we should still be able to read the value of <b class="">bar</b> from <b class="">r4</b> in the remaining of the function.</div><div class=""><br class=""></div><div class="">I don't know if we can consider this a bug, because I don't even know what should be the correct location information for <b class="">bar</b>. However, in this case, since the conditional instruction that clobbers <b class="">r4</b> is a function return, I'd expect to read the value of <b class="">bar</b> from <b class="">r4</b> in the remaining of the function. </div></div></div></div></div></blockquote><div><br class=""></div><div>I can't tell for sure whether the debug info is correct without also seeing the source code, but as a general point: Debug information is <i class="">must</i>-information that holds over all paths through the program. Debug information that is only accurate for some paths is a bug. A serious bug, because if the user can't rely on the debug info to be correct in <b class="">some</b> cases, they can't rely on <b class="">any</b> of the debug info to be correct.</div><div><br class=""></div><div>-- adrian</div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class=""><div class=""><div class=""><br class=""></div><div class="">If the conditional instruction <b class="">poplt </b>was <b class="">addlt r4, r0, 3</b> for example, what should be the correct location list of <b class="">bar</b>?</div><div class=""><br class=""></div></div><div class="">For now, my only idea is to check if the clobbering MI is a <b class="">conditional return</b> in <b class="">DbgValueHistoryCalculator</b> which computes the end address of a location llist entry. But I do not feel like this is the correct fix though.</div><div class=""><br class=""></div><div class="">Looking forward to hearing your thoughts on this,</div><div class=""><br class=""></div><div class="">Thank you for reading this,</div><div class=""><br class=""></div><div class=""><div class="gmail_signature"><div dir="ltr" class="">Son Tuan Vu</div></div></div>
</div></div>
</div></blockquote></div><br class=""></body></html>