zoukankan      html  css  js  c++  java
  • Valgrind学习

    Valgrind与其他DBI(Pin, DynamoRIO)的区别

    我们需要了解DBI的几个

    D&R

    Disassemble-and-Resynthesise
    反汇编后重新组装

    Valgrind采用这种方式,将Client中的代码全部翻译成IR,然后在IR级别进行instrument,最后将IR翻译成机器代码执行。

    如果Client中的一段代码被翻译成IR,那么原来的native code就不再存在了,以后也不会再使用到。

    Native Code --> IR --> IR --> Machine Code
                ^        ^      ^
                |        |      |
                |        |      |
            translate    |      |
                         |      |
                    instrument  |
                                |
                             translate  

    C&A

    Copy-and-Annotate
    拷贝并添加注解

    将Client中的native code原封不动地拷贝过来,并且对于每条指令都添加相应的注解,以解释这条指令的效果。

    DynamoRIO是通过给每条指令添加一个额外的data structure;

    Intel Pin是通过提供相应的获取指令相关信息的API;

    这些添加的注解可以指导进行相应的instrument,并且底线是不影响原来的native code的执行效果。


    Valgrind的IR

    进行IR扫描时单元,在Valgrind 3.0.0版本之前,是basic block(单入口,单出口);

    而在之后的版本中,换成了super block(单入口,多出口);

    IR的特点是:

    architecture-neutral
    D&R
    single-static-assignment(SSA)

    每个IR block包含一组statements的列表,而每个statement又包含多个expression。

    expression是pure的,即不依赖外部状态的。

    expression可以是tree-IR,也可以是flat-IR,二者的区别在于:

    tree-IR: complicated
    flat-IR: simple, but need to introduce temporaries, and one tree-IR will expand to several flat-IR expressions.

    but they(tree-IR) can also be flattened by introducing statements that write intermediate values to temporaries.

  • 相关阅读:
    MySQL 有关权限的表都有哪几个?
    MyISAM 表格将在哪里存储,并且还提供其存储格式?
    你是怎么看Spring框架的?
    elasticsearch 的倒排索引是什么 ?
    主键和候选键有什么区别?
    MySQL 支持事务吗?
    可以使用多少列创建索引?
    LIKE 声明中的%和_是什么意思?
    什么是通用 SQL 函数?
    MySQL 中有哪些不同的表格?
  • 原文地址:https://www.cnblogs.com/long123king/p/3739159.html
Copyright © 2011-2022 走看看