This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: gcc - Run Time Memory Capture


Raman,
	A simpler method is to fill the stack area with a magic number, e.g.
12345678h, at the start of the program and then check at the end how much
has been overwritten. A more useful addition to the gcc suite would be a
program that can work out the maximum possible stack depth without having to
run the program. For each function it would need to know the stack used and
a list of functions called.

Regards,
	Chris Palmer 

> -----Original Message-----
> From: kodandaraman govindan [mailto:raman.govindan@wipro.com]
> Sent: 23 April 2001 14:10
> To: bug-gcc@gnu.org
> Cc: raman.govindan@wipro.com
> Subject: gcc - Run Time Memory Capture
> 
> 
> Hi,
> 
>   I have an idea regarding enhancing gcc to capture Run Time Stack
> Size. Find enclosed a paper on the same.
> 
>   I am not sure if this feature is already implemented in gcc. If so
> please let me know and forgive my ignorance.
> 
> Thanks & Regards
> -raman
> 
> PS: I had posted this mail to gnu@gnu.org and I got response to
> contact you. In addition, I was suggested to write this up as a
> technical report for 
> http://www.gnu.org/mailman/listinfo/info-tech-reports/.
> 
>  I was not able to access the above mentioned site.
> 
> --------------------------------------------------------------
> -----------
> 
>  	
>                          Runtime Stack Size
> 
>  1. Abstract
>     --------
> 
>     To sell a product, footprint plays an important rule, 
> especially if
>  the product is to embedded into a device. This paper describes about
>  how to capture Runtime stack size on a intel platform.
> 
>  2. Concept
>     -------
> 
>    The GNU compiler, gcc with -mstats options gives the stack
>  statistics on MIPS processor only. This paper describes how to modify
>  the gcc to obtain stack statistics on intel platform. The same idea
>  can be extended to other platforms as well.
> 
> 
>                                  STACK
> 
>  					       -----------------
>  baseStackPosition --->   |                 |
>  				          |                 |
>  				     	   -----------------
>   				          |                 |
>  				          |                 |
>  					       -----------------
>  				          |                 |
>  				          |                 |
>  					       -----------------
>  currentStackPosition --> |                 |
>          			      |                 |
>  					       -----------------
>  				          |                 |
>  				          |      .          |
>  					      |      .          |
>  				          |      .          |
>  				          |                 |
>  					       -----------------
>   				          |                 |
>  				          |                 |
>  					       -----------------
> 
> 
> 
>     PIECE OF CODE TO KEEP TRACK OF MAXIMUM STACK SIZE
>     -------------------------------------------------
> 
>         maximumStackSize = 0;
>         baseStackPosition is the initial Stack Position
>         currentStackPosition is the current Stack Position
> 
>         Whenever a function is called, the stack grows and the
>         currentStackPosition (%esp) changes.
> 
>         if ( (%esp - baseStackPosition) greater than 
> maximumStackSize )
>         then
>             maximumStackSize = %esp - baseStackPosition
>             output the stderr the value of maximumStackSize
>         endif
> 
> 
> 
>  gcc can be modified in the code generation phase, so that 
> every time a
>  "push" instruction is emitted, "PIECE OF CODE TO KEEP TRACK 
> OF MAXIMUM
>  STACK SIZE" described above is also emitted.
> 
>  3.  Practical Significance
>      ----------------------
> 
>  This can be used to capture RunTime Stack Size of a product.
> 
> 
> 
> -- 
> _______________________________________________________________
> Raman Govindan, Software Specialist,
> Global R&D Division, Wipro Technologies.
> 
> Visit http://netphone.wipro.com (For now Only Wipro Employees)
> Email: raman.govindan@wipro.com
> Tel: +91-(80)-5364801/07, Ext: 160 (Office)
> _______________________________________________________________
> 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]