Dr. Debasish Jana
Dr. Debasish Jana

Reputation: 7118

Querying runtime stack size on Solaris using C++

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.

Upvotes: 1

Views: 102

Answers (2)

Paul Floyd
Paul Floyd

Reputation: 6916

DTractToolkit has a stacksize.d. That might be worth a look.

Upvotes: 1

tom
tom

Reputation: 11

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 .

Upvotes: 1

Related Questions