Arm Community
Site
Search
User
Site
Search
User
Groups
Arm Research
DesignStart
Education Hub
Graphics and Gaming
High Performance Computing
Innovation
Multimedia
Open Source Software and Platforms
Physical
Processors
Security
System
Software Tools
TrustZone for Armv8-M
中文社区
Blog
Announcements
Artificial Intelligence
Automotive
Healthcare
HPC
Infrastructure
Innovation
Internet of Things
Machine Learning
Mobile
Smart Homes
Wearables
Forums
All developer forums
IP Product forums
Tool & Software forums
Support
Open a support case
Documentation
Downloads
Training
Arm Approved program
Arm Design Reviews
Community Help
More
Cancel
Developer Community
IP Products
Processors
Jump...
Cancel
Processors
Cortex-M / M-Profile forum
How to get Call Stack from stack data.
Blogs
Forums
Videos & Files
Help
Jump...
Cancel
New
State
Not Answered
Replies
4 replies
Subscribers
6 subscribers
Views
5078 views
Users
0 members are here
register
Cortex-M
Debugger
Related
How to get Call Stack from stack data.
Offline
Mountain Mountain
over 7 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
Offline
Jacob Bramley
over 7 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
Up
0
Down
Reply
Accept answer
Cancel
Reply
0
Offline
Jacob Bramley
over 7 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
Up
0
Down
Reply
Accept answer
Cancel
Children
No data
More questions in this forum
By title
By date
By reply count
By view count
By most asked
By votes
By quality
Descending
Ascending
All recent questions
Unread questions
Questions you've participated in
Questions you've asked
Unanswered questions
Answered questions
Questions with suggested answers
Questions with no replies
Not Answered
Using STM32H7 ETM without external tool
0
CoreSight ETM7
STM32
331
views
0
replies
Started
3 months ago
by
GuillaumeP
Not Answered
How to realise Real-time detection of access of memory beyond the bounds of an allocation block, instead of period detection in Cortex-M4. Please give me any idea.
0
Cortex-M4
1052
views
3
replies
Latest
3 months ago
by
42Bastian Schick
Not Answered
Getting Dummy character while receiving UART data,How to fix it ?
0
732
views
2
replies
Latest
3 months ago
by
Jerome Decamps - 杜尚杰
Not Answered
Timer not working in stm32f401re
0
Keil MDK Cortex-M Edition
STM32
Cortex-M
STM32 F4
618
views
1
reply
Latest
3 months ago
by
42Bastian Schick
Not Answered
Is there an FPGA image for the MPS2+AN521 with an FPU?
0
Cortex-M33
Cortex-M Prototyping System (V2M-MPS2)
343
views
0
replies
Started
3 months ago
by
erickroane
<
>
View all questions in Cortex-M / M-Profile forum