【问题标题】:Pin:Insert two different instructions at the same addressPin:在同一个地址插入两条不同的指令
【发布时间】:2019-05-16 09:14:19
【问题描述】:

我想更改在相同地址指令之前的时间插入的函数。

我该怎么办?

例如。

int count=10;
void insert_check_code(INS ins){
    if(INS_Address(ins) == tmpaddr)
        if(count > 5){
        INS_InsertCall(ins,IPOINT_BEFORE,count--func)
    }else  {
        INS_InsertCall(ins,IPOINT_BEFORE,count_printfunc)
    }


}

在上面的例子中,计数值恢复到原来的我想改变在同地址指令之前的时序插入的函数。

我该怎么办?

例如。

int count=10;
void insert_check_code(INS ins){
    if(INS_Address(ins) == tmpaddr)
        if(count > 5){
        INS_InsertCall(ins,IPOINT_BEFORE,count--func)
    }else  {
        INS_InsertCall(ins,IPOINT_BEFORE,count_printfunc)
    }


}

在上面的例子中,计数值恢复到原来的值。

目标程序是一个简单的服务器程序,所以我们使用了fork()函数。 使用fork()函数的程序是否需要在Pintool中写特殊描述?值。

【问题讨论】:

    标签: intel-pin


    【解决方案1】:

    if-else 代码移动到它自己的函数中并插入该函数:

    void conditional_func() {
       if(count > 5){
          count_decrement_func()
       } else  {
          count_printfunc()
       }
    }
    
    void insert_check_code(INS ins) {
        INS_InsertCall(ins,IPOINT_BEFORE,conditional_func)
    }
    

    关于fork(),看fork()ing时你想要什么行为。

    请记住,如果应用程序是多线程的,count 访问必须同步。

    【讨论】:

      猜你喜欢
      • 2020-09-14
      • 2019-09-07
      • 1970-01-01
      • 2019-05-10
      • 2022-01-23
      • 2021-12-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多