<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><font color="#000000" style="background-color: rgba(255, 255, 255, 0);" class=""><font face="SFProText-Medium" class="">[ This question has already been asked in </font><font face="FiraCode-Medium" class=""><span class="">lldb-dev</span></font><font face="SFProText-Medium" class=""> (see attached emails), however it was suggested that I should forward the question to </font><font face="FiraCode-Medium" class=""><span class="">llvm-dev</span></font><font face="SFProText-Medium" class="">, since it is more relevant to MC Disassembler than LLDB. ]</font></font><div class=""><font color="#000000" class=""><span style="caret-color: rgb(0, 0, 0);" class=""><br class=""></span></font></div><div class=""><font color="#000000" class=""><span style="caret-color: rgb(0, 0, 0);" class=""><br class=""></span></font><div><font color="#000000" style="background-color: rgba(255, 255, 255, 0);" class="">Hello,</font></div><div><font color="#000000" style="background-color: rgba(255, 255, 255, 0);" class=""><br class="">I am looking for a way to track memory stores and save both the old and the new value of the memory location being modified using LLDB, as described below:</font></div><div><font color="#000000" style="background-color: rgba(255, 255, 255, 0);" class=""><br class=""><b class="">1.</b> Recognize the instructions that <b class="">definitely</b> access memory before they execute, based on their opcode.<br class=""><b class="">2.</b> Tell whether each operand is a register or a memory location.<br class=""><b class="">3.</b> If it’s a memory location, check whether it is a load or store destination.<br class=""><b class="">4.</b> In case it is a store destination, fetch and save current value from memory.<br class=""><b class="">5.</b> Execute instruction.<br class=""><b class="">6.</b> Fetch and save new value from memory.</font></div><div><font color="#000000" style="background-color: rgba(255, 255, 255, 0);" class=""><br class="">However, I was not able to find a cross-architecture API that covers all of the conditions above and more specifically <font face="FiraCode-Medium" class=""><span class="">Instruction::DoesStore()</span></font> and <font face="FiraCode-Medium" class=""><span class="">Operand::IsStoreDestination()</span></font>.</font></div><div><font color="#000000" style="background-color: rgba(255, 255, 255, 0);" class=""><br class="">Last but not least, I should notice that the target is executed in single-step mode, so I do have control right before and after the execution of every instruction.</font></div><div><font color="#000000" style="background-color: rgba(255, 255, 255, 0);" class=""><br class="">Thank you very much, in advance! πŸ™‚</font></div><div><font color="#000000" style="background-color: rgba(255, 255, 255, 0);" class=""><br class=""></font></div><div><font color="#000000" style="background-color: rgba(255, 255, 255, 0);" class=""><br class="">― Vangelis</font></div><div><br class=""></div><div><br class=""></div><div><blockquote type="cite" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div class=""><div class="">Begin forwarded message:<br class=""><blockquote type="cite" class=""></blockquote><font color="#00c8fa" class=""><span style="caret-color: rgb(0, 200, 250);" class=""><br class=""></span></font><span class="" style="font-family: -webkit-system-font, "Helvetica Neue", Helvetica, sans-serif;"><b class="">From: </b></span><span class="" style="font-family: -webkit-system-font, "Helvetica Neue", Helvetica, sans-serif;">Vangelis Tsiatsianas</span><br class=""><span class="" style="font-family: -webkit-system-font, "Helvetica Neue", Helvetica, sans-serif;"><b class="">Subject: </b></span><span class="" style="font-family: -webkit-system-font, "Helvetica Neue", Helvetica, sans-serif;"><b class="">Re: Identifying instructions that definitely access memory</b></span><br class=""><span class="" style="font-family: -webkit-system-font, "Helvetica Neue", Helvetica, sans-serif;"><b class="">Date: </b></span><span class="" style="font-family: -webkit-system-font, "Helvetica Neue", Helvetica, sans-serif;">5 November 2019 - 14:43:29 EET</span><br class=""><span class="" style="font-family: -webkit-system-font, "Helvetica Neue", Helvetica, sans-serif;"><b class="">To: </b></span><span class="" style="font-family: -webkit-system-font, "Helvetica Neue", Helvetica, sans-serif;">via lldb-dev <<a href="mailto:lldb-dev@lists.llvm.org" class="">lldb-dev@lists.llvm.org</a>></span><br class=""><font color="#00c8fa" class=""><span style="caret-color: rgb(0, 200, 250);" class=""><br class=""></span></font>Hello,<br class=""><font color="#00c8fa" class=""><span style="caret-color: rgb(0, 200, 250);" class=""><br class=""></span></font>I decided to try once more with a follow-up email, since my previous one got no responses (I hope it’s not considered rude to send more than one message in a row for a particular question).<br class=""><font color="#00c8fa" class=""><span style="caret-color: rgb(0, 200, 250);" class=""><br class=""></span></font>To sum up and clarify my previous question, what I need is a way to track memory stores and save both the old and the new value of the memory location being modified.<br class=""><font color="#00c8fa" class=""><span style="caret-color: rgb(0, 200, 250);" class=""><br class=""></span></font>My thinking so far:<br class=""><b class="">1.</b> Recognize the instructions that definitely access memory before they execute, based on their opcode.<br class=""><b class="">2.</b> Tell whether each operand is a register or a memory location.<br class=""><b class="">3.</b> If it’s a memory location, check whether it is a load or store destination.<br class=""><b class="">4.</b> In case it is a store destination, fetch and save current value from memory.<br class=""><b class="">5.</b> Execute instruction.<br class=""><div class=""><meta http-equiv="Content-Type" content="text/html; charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div class=""><b class="">6.</b> Fetch and save new value from memory.<br class=""></div></div></div><font color="#00c8fa" class=""><span style="caret-color: rgb(0, 200, 250);" class=""><br class=""></span></font>However, I was not able to find a cross-architecture API that covers all of the conditions above and more specifically <font face="FiraCode-Regular" class=""><span class="">Instruction::DoesStore()</span></font> and <font face="FiraCode-Regular" class=""><span class="">Operand::IsStoreDestination()</span></font>.<br class=""><font color="#00c8fa" class=""><span style="caret-color: rgb(0, 200, 250);" class=""><br class=""></span></font>Last but not least, I should notice that the target is executed in single-step mode, so I do have control right before and after the execution of every instruction.<br class=""><font color="#00c8fa" class=""><span style="caret-color: rgb(0, 200, 250);" class=""><br class=""></span></font>Thanks, again, in advance! πŸ™‚<br class=""><font color="#00c8fa" class=""><br class=""><span style="caret-color: rgb(0, 200, 250);" class=""><br class=""></span></font>― Vangelis<br class=""><font color="#00c8fa" class=""><br class=""><span style="caret-color: rgb(0, 200, 250);" class=""><br class=""></span></font><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div class=""><div class=""><div class="">On 21 Oct 2019, at 08:54, Vangelis Tsiatsianas wrote:<br class=""><blockquote type="cite" class=""></blockquote><font color="#57d977" class=""><span style="caret-color: rgb(87, 217, 119);" class=""><br class=""></span></font>Hello,<br class=""><font color="#57d977" class=""><span style="caret-color: rgb(87, 217, 119);" class=""><br class=""></span></font>I am looking for a way to identify loads, stores and any other kind of instruction that <b class="">definitely</b> perform memory access and extract the address operand(s), however I was not able to find a cross-architecture API. The closest I stumbled upon are "<font face="FiraCode-Regular" class=""><span class="">MCInstrDesc::mayLoad()</span></font>" and "<font face="FiraCode-Regular" class=""><span class="">MCInstrDesc::mayStore()</span></font>", but I understand that their results are just a hint, so I would then need to examine the instruction name or opcode in order to find out whether it’s actually a load or store and which operand(s) is (are) memory address(es) and also do so for each architecture separately, which I would really like to avoid.<br class=""><font color="#57d977" class=""><span style="caret-color: rgb(87, 217, 119);" class=""><br class=""></span></font>Is there a way to identify such instructions either by examining them through the disassembler (e.g. "<font face="FiraCode-Regular" class=""><span class="">DoesLoad()</span></font>" | "<font face="FiraCode-Regular" class=""><span class="">DoesStore()</span></font>") before they execute or right after they perform any kind of memory access?<br class=""><font color="#57d977" class=""><span style="caret-color: rgb(87, 217, 119);" class=""><br class=""></span></font>Thank you very much, in advance! πŸ™‚<br class=""><font color="#57d977" class=""><br class=""><span style="caret-color: rgb(87, 217, 119);" class=""><br class=""></span></font>― Vangelis<br class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div class=""><br class=""></div></div></div></div></div></div></div></div></blockquote></div><br class=""></div></div></blockquote></div><br class=""></div></body></html>