Reputation: 4085
I'm having problems with stack overflows and would like to see exactly what the contents on the stack are.
How can I examine the stack frame with GDB? is kind of the same question, however info locals
looks fine here (few variables, most of them std::vectors and std::maps), so I wouldn't expect the stack to overflow from this. Moreover, I have set the stack limit to 32MB, so this should be plenty and no recursive functions are used.
Is there a tool that can show the complete contents of the stack, maybe ordered by size?
Upvotes: 3
Views: 692
Reputation:
Stack overflows are better caught by special profilers rather than manually looking at variables in gdb
. It is more likely that you have buffer overrun rather than stack overflow. In either case, here is a list of some profilers that can help you to point out the problem:
Good luck!
Upvotes: 6
Reputation: 4780
You can also get the current stack pointer in gdb (e.g., by running 'info registers') and then dump the memory around that location using the examine (or 'x') command. Just be aware that the stack pointer points below the stack, so you need to start dumping from stack pointer - N to see the first N bytes on the stack.
Upvotes: 0
Reputation: 40372
Even if you have no functions that call themselves, it's possible you've created a situation in which two or more functions are mutually recursive.
A good starting point would be to examine not the current stack frame, but a list of stack frames, using the "backtrace" (or "bt" for short) command. If you see a repeated pattern of two or more functions calling each other, then you have mutual recursion.
Upvotes: 1
Reputation: 4554
You can examine the current stack frame using the backtrace command.
Upvotes: 0