<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=""><div class=""><font face="SFProText-Medium" class="">[ This question has already been asked in </font><font face="FiraCode-Medium" class=""><span style="font-style: normal;" 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 style="font-style: normal;" class="">llvm-dev</span></font><font face="SFProText-Medium" class="">, since it is more relevant to MC Disassembler than LLDB. ]</font></div><div class=""><br class=""></div><div class=""><br class=""></div>Hello,<div class=""><br class=""></div><div class=""><div 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:</div><div class=""><br class=""></div><div class=""><b class="">1.</b> Recognize the instructions that <b class="">definitely</b> access memory before they execute, based on their opcode.</div><div class=""><b class="">2.</b> Tell whether each operand is a register or a memory location.</div><div class=""><b class="">3.</b> If it’s a memory location, check whether it is a load or store destination.</div><div class=""><b class="">4.</b> In case it is a store destination, fetch and save current value from memory.</div><div class=""><b class="">5.</b> Execute instruction.</div><div class=""><b class="">6.</b> Fetch and save new value from memory.</div><div class=""><br class=""></div><div 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 style="font-style: normal;" class="">Instruction::DoesStore()</span></font> and <font face="FiraCode-Medium" class=""><span style="font-style: normal;" class="">Operand::IsStoreDestination()</span></font>.</div><div class=""><br class=""></div><div 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.</div><div class=""><br class=""></div><div class="">Thank you very much, in advance! πŸ™‚</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">― Vangelis</div><div class=""><br class=""></div><div><br class=""><blockquote type="cite" class=""><div class="">Begin forwarded message:</div><br class="Apple-interchange-newline"><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px;" class=""><span style="font-family: -webkit-system-font, Helvetica Neue, Helvetica, sans-serif; color:rgba(0, 0, 0, 1.0);" class=""><b class="">From: </b></span><span style="font-family: -webkit-system-font, Helvetica Neue, Helvetica, sans-serif;" class="">Vangelis Tsiatsianas<br class=""></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px;" class=""><span style="font-family: -webkit-system-font, Helvetica Neue, Helvetica, sans-serif; color:rgba(0, 0, 0, 1.0);" class=""><b class="">Subject: </b></span><span style="font-family: -webkit-system-font, Helvetica Neue, Helvetica, sans-serif;" class=""><b class="">Re: Identifying instructions that definitely access memory</b><br class=""></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px;" class=""><span style="font-family: -webkit-system-font, Helvetica Neue, Helvetica, sans-serif; color:rgba(0, 0, 0, 1.0);" class=""><b class="">Date: </b></span><span style="font-family: -webkit-system-font, Helvetica Neue, Helvetica, sans-serif;" class="">5 November 2019 - 14:43:29 EET<br class=""></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px;" class=""><span style="font-family: -webkit-system-font, Helvetica Neue, Helvetica, sans-serif; color:rgba(0, 0, 0, 1.0);" class=""><b class="">To: </b></span><span style="font-family: -webkit-system-font, Helvetica Neue, Helvetica, sans-serif;" class="">via lldb-dev <<a href="mailto:lldb-dev@lists.llvm.org" class="">lldb-dev@lists.llvm.org</a>><br class=""></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px;" class=""><br class=""></div><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="">Hello,<div class=""><br class=""></div><div class="">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).</div><div class=""><br class=""></div><div class="">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.</div><div class=""><br class=""></div><div class="">My thinking so far:</div><div class=""><ol class="MailOutline"><li class="">Recognize the instructions that definitely access memory before they execute, based on their opcode.</li><li class="">Tell whether each operand is a register or a memory location.</li><li class="">If it’s a memory location, check whether it is a load or store destination.</li><li class="">In case it is a store destination, fetch and save current value from memory.</li><li class="">Execute instruction.</li><li class="">Fetch and save new value from memory.</li></ol><div class=""><br class=""></div></div><div 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-Regular" class=""><span style="font-style: normal;" class="">Instruction::DoesStore()</span></font> and <font face="FiraCode-Regular" class=""><span style="font-style: normal;" class="">Operand::IsStoreDestination()</span></font>.</div><div class=""><br class=""></div><div 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.</div><div class=""><br class=""></div><div class="">Thanks, again, in advance! πŸ™‚</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">― Vangelis</div><div class=""><br class=""></div><div class=""><div class=""><div class=""><br class=""><blockquote type="cite" class=""><div class="">On 21 Oct 2019, at 08:54, Vangelis Tsiatsianas wrote:</div><br class="Apple-interchange-newline"><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="">Hello,<div class=""><br class=""></div><div class="">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 style="font-style: normal;" class="">MCInstrDesc::mayLoad()</span></font>" and "<font face="FiraCode-Regular" class=""><span style="font-style: normal;" 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.</div><div class=""><br class=""></div><div class="">Is there a way to identify such instructions either by examining them through the disassembler (e.g. "<font face="FiraCode-Regular" class=""><span style="font-style: normal;" class="">DoesLoad()</span></font>" | "<font face="FiraCode-Regular" class=""><span style="font-style: normal;" class="">DoesStore()</span></font>") before they execute or right after they perform any kind of memory access?</div><div class=""><br class=""></div><div class="">Thank you very much, in advance! πŸ™‚</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">― Vangelis</div><div class=""><br class=""></div><div class=""><br class=""></div></div></div></blockquote></div><br class=""></div></div></div></div></blockquote></div><br class=""></div></body></html>