我如何指定一个代码区域以使用pintool进行检测? [英] How can i specify an area of code to instrument it by pintool?

查看:156
本文介绍了我如何指定一个代码区域以使用pintool进行检测?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Pin中有四个粒度级别:例程,指令和图像,跟踪. 我可以指定一个限制/区域来开始和停止插入检测代码. 可以通过类似的指令来代替(#开始检测,#结束检测) 或类似的东西

There are four levels of granularity in Pin: routine, instruction and image, trace. Can i specify an limits/area to start and stop inserting instrumentation code. may by like directive like ( # start instrumentation , # end instrumentation ) or some thing like that,

一个例子:
for( int i=0; i< x; i++) { #startInstrumentation for( ....;.....;.....) { // some code // function call, conditions , loops, .... } #endInstrumentation }
有什么方法可以做到这一点?

An example:
for( int i=0; i< x; i++) { #startInstrumentation for( ....;.....;.....) { // some code // function call, conditions , loops, .... } #endInstrumentation }
Is there are any way to do this ?

推荐答案

您可以使用基于跟踪的工具来执行所需的操作.在每个跟踪的开始处,检查其起始地址,如果不在感兴趣范围内,请避免添加分析功能并立即从例程中返回.

You can use trace-based instrumentation to do what you want. At the beginning of each trace, check its start address and if it is not in range of interest, avoid adding analysis functions and return immediately from the routine.

跟踪可能会在感兴趣区域之外开始,而在其内部结束,或者反之亦然.如果发生这种情况,您将需要对要检测的内容进行更精细的选择.在投入精力之前,我会检查这是否是一个真正的问题.

It's possible that a trace will begin outside a region of interest but end inside it, or the other way around. If this can happen, you will need to perform more fine grained choice about what to instrument. I would check if this is a real concern before investing an effort.

如果您对检测特定的例程或图像感兴趣,请考虑使用套件中InstLib的filter.cpp.可以在InstLibExamples中找到使用的示例.

If you're interested in instrumenting specific routines or images, consider using filter.cpp from InstLib in the kit. An example for use can be found in InstLibExamples.

现在,关于如何定位这些感兴趣的区域,您有几种选择.如果您无法控制目标二进制文件,则可以在命令行参数中指定区域,作为目标图像中的一对偏移量.

Now, as for how to target these regions of interest, you have several options. If you have no control over the target binary, you can specify the region in a command line parameter, as a pair of offsets into the image of interest.

如果您对二进制文件有控制权,则可以插入两个符号,以指定感兴趣的片段的开始和结束,然后使用SYM界面遍历图像符号.

If you have control of the binary, you can insert two symbols, that specify the start and end of the rgion of interest, and then iterate over image symbols using the SYM interface.

这篇关于我如何指定一个代码区域以使用pintool进行检测?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆