<div dir="ltr">Hi all,<div><br></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"><div>Consider this ARM assembly code of a C function:</div><div><br></div><div><div>00008124 <foo>:</div><div> 8124: push {r4, r6, r7, lr}</div><div> 8126: add r7, sp, #8</div><div> 8128: mov r4, r0</div><div> 812a: ldrsb.w r0, [r2]</div><div> 812e: cmp r0, #1</div><div> 8130: itt lt</div><div> 8132: movlt r0, #85 ; 0x55</div><div> 8134: poplt {r4, r6, r7, pc} // a function return</div><div><br></div><div> 8136: ldrb.w ip, [r1, #3]</div><div> 813a: ldrb.w lr, [r4, #3]</div><div> 813e: movs r0, #85 ; 0x55</div><div> 8140: cmp lr, ip</div><div> 8142: bne.n 8168 <foo+0x44></div><div><br></div><div> 8144: ldrb.w ip, [r1, #2]</div><div> 8148: ldrb r3, [r4, #2]</div><div> 814a: cmp r3, ip</div><div> 814c: it ne</div><div> 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"><span> </span> // a function return</span></div><div><br></div><div> 8150: ldrb.w ip, [r1, #1]</div><div> 8154: ldrb r3, [r4, #1]</div><div> 8156: cmp r3, ip</div><div> 8158: bne.n 8168 <foo+0x44></div><div><br></div><div> 815a: ldrb r1, [r1, #0]</div><div> 815c: ldrb r3, [r4, #0]</div><div> 815e: cmp r3, r1</div><div> 8160: ittt eq</div><div> 8162: moveq r0, #3</div><div> 8164: strbeq r0, [r2, #0]</div><div> 8166: moveq r0, #170 ; 0xaa</div><div> 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"> </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"><span> </span> // a function return</span></div></div></div><div><div><br></div><div>I have a variable <b>bar</b> and here's its corresponding DWARF DIE:</div><div><div><br></div><div><div> <2><3b>: Abbrev Number: 3 (DW_TAG_formal_parameter)</div><div> <3c> DW_AT_location : 0x0 (location list)</div><div> <40> DW_AT_name : (indirect string, offset: 0x9e): <b>bar</b></div><div> <44> DW_AT_decl_file : 1</div><div> <45> DW_AT_decl_line : 34</div><div> <46> DW_AT_type : <0x153></div></div><div><br></div><div> // <b>Its location list</b></div><div><div> 00000000 00008124 0000812a (DW_OP_reg0 (r0))</div><div> 0000000b 0000812a 00008136 (DW_OP_reg4 (r4))</div><div> 00000016 <End of list></div></div><div><br></div><div>As you can see, it says that we can find <b>bar </b>in <b>r4</b> from <b>0x812a</b><b> </b>to <b>0x8134 (poplt)</b>. However, this is only true when the <b>cmp </b>instruction at <b>0x812e</b> yields <b>less than (lt)</b>. So if the value in <b>r0 </b>is greater than 1 (which is the case of my input), we should still be able to read the value of <b>bar</b> from <b>r4</b> in the remaining of the function.</div><div><br></div><div>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>bar</b>. However, in this case, since the conditional instruction that clobbers <b>r4</b> is a function return, I'd expect to read the value of <b>bar</b> from <b>r4</b> in the remaining of the function. </div><div><br></div><div>If the conditional instruction <b>poplt </b>was <b>addlt r4, r0, 3</b> for example, what should be the correct location list of <b>bar</b>?</div><div><br></div></div><div>For now, my only idea is to check if the clobbering MI is a <b>conditional return</b> in <b>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><br></div><div>Looking forward to hearing your thoughts on this,</div><div><br></div><div>Thank you for reading this,</div><div><br></div><div><div class="gmail_signature"><div dir="ltr">Son Tuan Vu</div></div></div>
</div></div>