简体   繁体   English

有什么设计工具可以让我确切地获得C代码中不同功能的指令数量

[英]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.

相关问题 不完整的 gamma 函数:此代码在 cython、C 或 Fortran 中能否变得更快? - Incomplete gamma functions: can this code get any faster in cython, C, or Fortran? 测量一组指令的确切时间(周期数) - Measure the exact time (number of cycles) of a set of instructions 我可以使用哪些免费工具在Windows上分析C代码? - What free tools can I use to profile C code on Windows? 如何测试使用MPI调用的C \\ C ++代码:是否有任何一组模拟函数可以使用? - How can one test C\C++ code which uses MPI calls: is there any set of mock functions, that I can use? 在C代码中捕捉愚蠢错误的任何工具? - Any Tools to Catch Silly Mistakes in C Code? 在 C 中确保多段代码的汇编指令数量是固定的 - In C ensure that the number of assembly instructions is fixed for multiple sections of code 在编写C代码时,如何优雅地利用REV和RBIT等ARM指令? - How can I elegantly take advantage of ARM instructions like REV and RBIT when writing C code? 有什么方法可以在 C 中的空格之前获得每行的第一个数字? - Is there any way I can get the first number of every line before a space in C? 我在哪里可以获得gcc / clang等C标准函数的源代码? - Where can I get the source code of the C standard functions in gcc/clang etc? 如何将C代码编译为固件补丁并获取所有功能的位置? - How can I compile c code into a firmware patch and get the location of all the functions?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM