Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get maximum frame size of each function compiled by gcc?

Tags:

c++

c

stack

gcc

Is it possible to get maximum frame size of each function compiled by GCC?

I have a bunch of C and C++ source files in my project and I want to have a statistics of stack usage of each function, just couldn't find any related options in GCC manual.

like image 857
6bb79df9 Avatar asked Sep 07 '11 14:09

6bb79df9


1 Answers

You can try -fstack-usage.

  • https://gcc.gnu.org/onlinedocs/gnat_ugn/Static-Stack-Usage-Analysis.html

There is also -Wstack-usage=<stack_limit> (eg. -Wstack-usage=4096) which will give you a warning as you compile your code.

like image 162
makes Avatar answered Oct 22 '22 06:10

makes