跟踪/分析说明 [英] Tracing/profiling instructions

查看:170
本文介绍了跟踪/分析说明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在指令级进行统计分析我的C $ C $℃。
我需要知道有多少加法,乘法,部门,等我表演。

I'd like to statistically profile my C code at the instruction level. I need to know how many additions, multiplications, divisions, etc I'm performing.

这是不是你平时的磨code分析的要求运行。我是一个算法开发人员,我想估计我的code转换成硬件实现的成本。对于这一点,我被要求在运行时的指令调用击穿(解析编译的程序集是不够的,因为它没有考虑在code循环)。

This is not your usual run of the mill code profiling requirement. I'm an algorithm developer and I want to estimate the cost of converting my code to hardware implementations. For this, I'm being asked the instruction call breakdown during run-time (parsing the compiled assembly isn't sufficient as it doesn't consider loops in the code).

环顾四周之后,似乎VMware的可能提供了一个可能的解决方案,但我仍然无法找到特定的功能,让我跟踪我处理的指令调用流。

After looking around, it seems VMware may offer a possible solution, but I still couldn't find the specific feature that will allow me to trace the instruction call stream of my process.

您知道任何分析工具,使这个?

Are you aware of any profiling tools which enable this?

推荐答案

我最终用一个简单而有效的解决方案。

I eventually used a trivial yet effective solution.


  1. 配置GDB通过调用来显示下一条指令(每次停止时间)的拆卸:


    显示/ I $ PC


  1. 配置,打破了在我需要分析功能,并继续用指令的指令一步一个简单的GDB脚本:

  1. Configured a simple gdb script that breaks in the function I need to analyze and proceeds to step instruction by instruction:

set $i=0
break main
run
while ($i<100000)
si
set $i = $i + 1
end
quit

执行的GDB与我的脚本倾倒输出到日志文件:

Executed gdb with my script dumping output into a log file:

GDB -x脚本的a.out&GT; log.txt的

分析日志来算的具体指导的电话。

Analyzed the log to count specific instruction calls.

粗糙,但它的工作原理...

Crude, but it works...

这篇关于跟踪/分析说明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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