开发者

How to debug a stackoverflow problem on targets

开发者 https://www.devze.com 2023-01-02 22:41 出处:网络
I want to know how do we proceed to debug a STACKOVERFLOW issue on targets . I mean what are the ste开发者_StackOverflow中文版ps we should follow to reach a conclusion.Put a memory write watchpoint fo

I want to know how do we proceed to debug a STACKOVERFLOW issue on targets . I mean what are the ste开发者_StackOverflow中文版ps we should follow to reach a conclusion.


Put a memory write watchpoint for one word past the end of your stack space. Then the debugger will break in when that spot gets written to, and you can see what's at fault.


All stacks can be filled at start up with certain hex value (for example 0xAAAAAAAA). And then using special routine you can monitor all stack's maximum usage periodically by calculating the quantity of known values (0xAA..) from end of stack until finds the first difference.


Run it through a debugger such as gdb. The backtrace at the time of the stack overflow will tell you exactly which function or functions are repeating indefinitely. From there, figure out which input(s) to those functions are not changing, and not moving the function (if it's recursive) towards a base-case that will end the recursion.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号