Arm Community
Site
Search
User
Site
Search
User
Support forums
Architectures and Processors forum
How to get Call Stack from stack data.
Jump...
Cancel
State
Not Answered
Locked
Locked
Replies
4 replies
Subscribers
348 subscribers
Views
9009 views
Users
0 members are here
register
Cortex-M
Debugger
Options
Share
More actions
Cancel
Related
How was your experience today?
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion
How to get Call Stack from stack data.
Mountain Mountain
over 12 years ago
Note: This was originally posted on 23rd January 2009 at
http://forums.arm.com
Hi everyone.
Here is a question that puzzled me a long time. if I get stack data(HEX data), anyone konw that how to get call stack from it.
How to know that which is R14.
Parents
0
Jacob Bramley
over 12 years ago
Note: This was originally posted on 28th January 2009 at
http://forums.arm.com
Interesting question.
Basically, the stack works because you read values off it in the opposite order to that which they were stored. r14's entry in the stack will not be obviously labelled as such, for example.
Of course, this only works because C functions will be ABI compliant and thus don't mess up the stack pointer. If you write a function in assembly which doesn't correctly handle the stack pointer, everything will fall apart because what should be stored in r14 will end up somewhere else.
Also, note that there may be many copies of r14 in the stack as it will be pushed every time a function needs to modify it. As r14 is the link register, that will occur for pretty much every function call.
The only way to determine where r14 is located in the stack is to study your code and work out the address at which it will eventually be stored. Of course, you can use a debugger to do that for you by setting breakpoints and that kind of thing.
Does that answer your question?
Cancel
Vote up
0
Vote down
Cancel
Reply
0
Jacob Bramley
over 12 years ago
Note: This was originally posted on 28th January 2009 at
http://forums.arm.com
Interesting question.
Basically, the stack works because you read values off it in the opposite order to that which they were stored. r14's entry in the stack will not be obviously labelled as such, for example.
Of course, this only works because C functions will be ABI compliant and thus don't mess up the stack pointer. If you write a function in assembly which doesn't correctly handle the stack pointer, everything will fall apart because what should be stored in r14 will end up somewhere else.
Also, note that there may be many copies of r14 in the stack as it will be pushed every time a function needs to modify it. As r14 is the link register, that will occur for pretty much every function call.
The only way to determine where r14 is located in the stack is to study your code and work out the address at which it will eventually be stored. Of course, you can use a debugger to do that for you by setting breakpoints and that kind of thing.
Does that answer your question?
Cancel
Vote up
0
Vote down
Cancel
Children
No data