1 /* 2 * Copyright (c) 2006-2018, RT-Thread Development Team 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 * 6 * Change Logs: 7 * Date Author Notes 8 * 2008-07-29 Bernard first version from QiuYi implementation 9 */ 10 11 #include <rtthread.h> 12 13 #ifdef __GNUC__ 14 /* 15 -->High Address,Stack Top 16 PC<------| 17 LR | 18 IP | 19 FP | 20 ...... | 21 PC <-| | 22 LR | | 23 IP | | 24 FP---|-- | 25 ...... | 26 PC | 27 LR | 28 IP | 29 FP--- 30 -->Low Address,Stack Bottom 31 */ 32 void rt_hw_backtrace(rt_uint32_t *fp, rt_uint32_t thread_entry) 33 { 34 rt_uint32_t i, pc, func_entry; 35 36 pc = *fp; 37 rt_kprintf("[0x%x]\n", pc-0xC); 38 39 for(i=0; i<10; i++) 40 { 41 fp = (rt_uint32_t *)*(fp - 3); 42 pc = *fp ; 43 44 func_entry = pc - 0xC; 45 46 if(func_entry <= 0x30000000) break; 47 48 if(func_entry == thread_entry) 49 { 50 rt_kprintf("EntryPoint:0x%x\n", func_entry); 51 52 break; 53 } 54 55 rt_kprintf("[0x%x]\n", func_entry); 56 } 57 } 58 #else 59 void rt_hw_backtrace(rt_uint32_t *fp, rt_uint32_t thread_entry) 60 { 61 /* old compiler implementation */ 62 } 63 #endif 64