[英]Is there any design tools that I can get the exact number of instructions of different functions in C code
I need to analyze some c code with functions and I want to get the exact number of instructions of different function in c code. 我需要分析一些带有函数的C代码,并且想要获得C代码中不同函数的确切指令数。 I have no idea.
我不知道。 Thanks.
谢谢。
If you're talking about assembly instructions, this is pretty easy: 如果您在谈论汇编说明,这很简单:
Make a small C program with main. 用main编写一个小的C程序。 Immediately in main, call your desired function.
立即在main中调用所需的函数。 Compile with the gcc -c option (outputs an object file).
使用gcc -c选项进行编译(输出目标文件)。 Open up your object f ile (.o) in a text editor.
在文本编辑器中打开对象文件(.o)。 Look for t he call function (This is the call into the function).
查找调用函数(这是对该函数的调用)。 Start counting the lines until you hit a return (ret) instruction.
开始计数行数,直到您按了返回(ret)指令。
There you go! 你去! Of course, your compiler will probably optimize this object code so it might be a little more complex, but this is probably a really easy way to do it.
当然,您的编译器可能会优化此目标代码,因此可能会稍微复杂一些,但这可能是一种非常简单的方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.