2013-01-08 21:05:02 +08:00
|
|
|
/*
|
2018-10-15 01:35:07 +08:00
|
|
|
* Copyright (c) 2006-2018, RT-Thread Development Team
|
2013-01-08 21:05:02 +08:00
|
|
|
*
|
2018-10-15 01:35:07 +08:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2013-01-08 21:05:02 +08:00
|
|
|
*
|
|
|
|
* Change Logs:
|
|
|
|
* Date Author Notes
|
|
|
|
* 2008-07-29 Bernard first version from QiuYi implementation
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <rtthread.h>
|
|
|
|
|
|
|
|
#ifdef __GNUC__
|
|
|
|
/*
|
|
|
|
-->High Address,Stack Top
|
2019-01-07 06:09:45 +08:00
|
|
|
PC<------|
|
|
|
|
LR |
|
|
|
|
IP |
|
|
|
|
FP |
|
|
|
|
...... |
|
|
|
|
PC <-| |
|
|
|
|
LR | |
|
|
|
|
IP | |
|
2013-01-08 21:05:02 +08:00
|
|
|
FP---|-- |
|
2019-01-07 06:09:45 +08:00
|
|
|
...... |
|
|
|
|
PC |
|
|
|
|
LR |
|
|
|
|
IP |
|
2013-01-08 21:05:02 +08:00
|
|
|
FP---
|
|
|
|
-->Low Address,Stack Bottom
|
|
|
|
*/
|
|
|
|
void rt_hw_backtrace(rt_uint32_t *fp, rt_uint32_t thread_entry)
|
|
|
|
{
|
2019-01-07 06:09:45 +08:00
|
|
|
rt_uint32_t i, pc, func_entry;
|
2013-01-08 21:05:02 +08:00
|
|
|
|
2019-01-07 06:09:45 +08:00
|
|
|
pc = *fp;
|
|
|
|
rt_kprintf("[0x%x]\n", pc-0xC);
|
2013-01-08 21:05:02 +08:00
|
|
|
|
2019-01-07 06:09:45 +08:00
|
|
|
for(i=0; i<10; i++)
|
|
|
|
{
|
|
|
|
fp = (rt_uint32_t *)*(fp - 3);
|
|
|
|
pc = *fp ;
|
2013-01-08 21:05:02 +08:00
|
|
|
|
2019-01-07 06:09:45 +08:00
|
|
|
func_entry = pc - 0xC;
|
2013-01-08 21:05:02 +08:00
|
|
|
|
2019-01-07 06:09:45 +08:00
|
|
|
if(func_entry <= 0x30000000) break;
|
2013-01-08 21:05:02 +08:00
|
|
|
|
2019-01-07 06:09:45 +08:00
|
|
|
if(func_entry == thread_entry)
|
|
|
|
{
|
|
|
|
rt_kprintf("EntryPoint:0x%x\n", func_entry);
|
2013-01-08 21:05:02 +08:00
|
|
|
|
2019-01-07 06:09:45 +08:00
|
|
|
break;
|
|
|
|
}
|
2013-01-08 21:05:02 +08:00
|
|
|
|
2019-01-07 06:09:45 +08:00
|
|
|
rt_kprintf("[0x%x]\n", func_entry);
|
|
|
|
}
|
2013-01-08 21:05:02 +08:00
|
|
|
}
|
|
|
|
#else
|
|
|
|
void rt_hw_backtrace(rt_uint32_t *fp, rt_uint32_t thread_entry)
|
|
|
|
{
|
2019-01-07 06:09:45 +08:00
|
|
|
/* old compiler implementation */
|
2013-01-08 21:05:02 +08:00
|
|
|
}
|
|
|
|
#endif
|