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.

  • 相关阅读:
    综合日语第一册第十课
    综合日语第一册第九课
    荒木毬菜 小情歌日文版
    c# 匿名函数
    字典取KEY,占位符,延迟刷新
    flash GC
    自定义滤镜 ColorMatrixFilter
    sql join
    NSLog Release
    Windows 运行中的命令
  • 原文地址:https://www.cnblogs.com/long123king/p/3739159.html
Copyright © 2011-2022 走看看