I am using g++ on Solaris. Is there any way internally or externally to know how much stack size aI have used till now while within a function call? This is required to diagnose a suspected stack overflow.
Asked
Active
Viewed 93 times
1
-
1related/dupe: https://stackoverflow.com/questions/2275550/change-stack-size-for-a-c-application-in-linux-during-compilation-with-gnu-com – NathanOliver Jun 19 '17 at 12:45
-
@NathanOliver I would like to know how much I have consumed in terms of stack size so far not the max limit – Dr. Debasish Jana Jun 19 '17 at 12:53
2 Answers
1
static analysis: request the compiler / linker for static analysis if the stack size of your application (check compiler option -fstack-usage ).
dynamic analysis / approach: use the debugger and set a conditional (write access) breakpoint to the end of your stack. If application writes to the end of the stack, the debugger will stop and present you the call stack and the function which leads to the memory violation .

tom
- 11
- 1
-
How to set conditional breakpoint to the end of the stack (within gdb)? – Dr. Debasish Jana Jun 20 '17 at 13:00