Re: [lldb-dev] Identifying instructions that definitely access memory

2019-11-12 Thread Vangelis Tsiatsianas via lldb-dev
Hi Tatyana,

Thank you for your reply! πŸ™‚

If I understand correctly, TargetOpcode::G_{LOAD, STORE} do not cover x86’s mov 
instructions (and other relevant instructions of both x86 the rest of supported 
architectures) and such, which also access memory, however I will look into it 
more.

Additionally, thank you for the suggestion regarding llvm-dev ―I will forward 
my email to that list, too.


― Vangelis


> On 7 Nov 2019, at 13:49, Tatyana Krasnukha  
> wrote:
> 
> Hi Vangelis,
>  
> Not sure this will help you, but you can try to compare 
> llvm::MachineInstr::getOpcode() with TargetOpcode::G_LOAD and 
> TargetOpcode::G_STORE if you can obtain a MachineInstr instance.
> It also may have sense to ask llvm-dev for a proper solution.
>  
> From: lldb-dev  On Behalf Of Vangelis 
> Tsiatsianas via lldb-dev
> Sent: Tuesday, November 5, 2019 3:43 PM
> To: via lldb-dev 
> Cc: Vangelis Tsiatsianas 
> Subject: Re: [lldb-dev] Identifying instructions that definitely access memory
>  
> Hello,
>  
> 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).
>  
> 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.
>  
> My thinking so far:
> Recognize the instructions that definitely access memory before they execute, 
> based on their opcode.
> Tell whether each operand is a register or a memory location.
> If it’s a memory location, check whether it is a load or store destination.
> In case it is a store destination, fetch and save current value from memory.
> Execute instruction.
> Fetch and save new value from memory.
>  
> However, I was not able to find a cross-architecture API that covers all of 
> the conditions above and more specifically Instruction::DoesStore() and 
> Operand::IsStoreDestination().
>  
> 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.
>  
> Thanks, again, in advance! πŸ™‚
>  
>  
> ― Vangelis
>  
> 
> 
> On 21 Oct 2019, at 08:54, Vangelis Tsiatsianas  <mailto:vangeli...@icloud.com>> wrote:
>  
> Hello,
>  
> I am looking for a way to identify loads, stores and any other kind of 
> instruction that definitely 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 "MCInstrDesc::mayLoad()" and 
> "MCInstrDesc::mayStore()", 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.
>  
> Is there a way to identify such instructions either by examining them through 
> the disassembler (e.g. "DoesLoad()" | "DoesStore()") before they execute or 
> right after they perform any kind of memory access?
>  
> Thank you very much, in advance! πŸ™‚
>  
>  
> ― Vangelis

___
lldb-dev mailing list
lldb-dev@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev


Re: [lldb-dev] Identifying instructions that definitely access memory

2019-11-07 Thread Tatyana Krasnukha via lldb-dev
Hi Vangelis,

Not sure this will help you, but you can try to compare 
llvm::MachineInstr::getOpcode() with TargetOpcode::G_LOAD and 
TargetOpcode::G_STORE if you can obtain a MachineInstr instance.
It also may have sense to ask llvm-dev for a proper solution.

From: lldb-dev  On Behalf Of Vangelis 
Tsiatsianas via lldb-dev
Sent: Tuesday, November 5, 2019 3:43 PM
To: via lldb-dev 
Cc: Vangelis Tsiatsianas 
Subject: Re: [lldb-dev] Identifying instructions that definitely access memory

Hello,

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).

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.

My thinking so far:

  1.  Recognize the instructions that definitely access memory before they 
execute, based on their opcode.
  2.  Tell whether each operand is a register or a memory location.
  3.  If it’s a memory location, check whether it is a load or store 
destination.
  4.  In case it is a store destination, fetch and save current value from 
memory.
  5.  Execute instruction.
  6.  Fetch and save new value from memory.

However, I was not able to find a cross-architecture API that covers all of the 
conditions above and more specifically Instruction::DoesStore() and 
Operand::IsStoreDestination().

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.

Thanks, again, in advance! πŸ™‚


― Vangelis



On 21 Oct 2019, at 08:54, Vangelis Tsiatsianas 
mailto:vangeli...@icloud.com>> wrote:

Hello,

I am looking for a way to identify loads, stores and any other kind of 
instruction that definitely 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 "MCInstrDesc::mayLoad()" and 
"MCInstrDesc::mayStore()", 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.

Is there a way to identify such instructions either by examining them through 
the disassembler (e.g. "DoesLoad()" | "DoesStore()") before they execute or 
right after they perform any kind of memory access?

Thank you very much, in advance! πŸ™‚


― Vangelis



___
lldb-dev mailing list
lldb-dev@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev


Re: [lldb-dev] Identifying instructions that definitely access memory

2019-11-05 Thread Vangelis Tsiatsianas via lldb-dev
Hello,

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).

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.

My thinking so far:
Recognize the instructions that definitely access memory before they execute, 
based on their opcode.
Tell whether each operand is a register or a memory location.
If it’s a memory location, check whether it is a load or store destination.
In case it is a store destination, fetch and save current value from memory.
Execute instruction.
Fetch and save new value from memory.

However, I was not able to find a cross-architecture API that covers all of the 
conditions above and more specifically Instruction::DoesStore() and 
Operand::IsStoreDestination().

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.

Thanks, again, in advance! πŸ™‚


― Vangelis


> On 21 Oct 2019, at 08:54, Vangelis Tsiatsianas  wrote:
> 
> Hello,
> 
> I am looking for a way to identify loads, stores and any other kind of 
> instruction that definitely 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 "MCInstrDesc::mayLoad()" and 
> "MCInstrDesc::mayStore()", 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.
> 
> Is there a way to identify such instructions either by examining them through 
> the disassembler (e.g. "DoesLoad()" | "DoesStore()") before they execute or 
> right after they perform any kind of memory access?
> 
> Thank you very much, in advance! πŸ™‚
> 
> 
> ― Vangelis
> 
> 

___
lldb-dev mailing list
lldb-dev@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev


[lldb-dev] Identifying instructions that definitely access memory

2019-10-20 Thread Vangelis Tsiatsianas via lldb-dev
Hello,

I am looking for a way to identify loads, stores and any other kind of 
instruction that definitely 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 "MCInstrDesc::mayLoad()" and 
"MCInstrDesc::mayStore()", 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.

Is there a way to identify such instructions either by examining them through 
the disassembler (e.g. "DoesLoad()" | "DoesStore()") before they execute or 
right after they perform any kind of memory access?

Thank you very much, in advance! πŸ™‚


― Vangelis


___
lldb-dev mailing list
lldb-dev@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev