# 1 "../../../Package/cm_backtrace/cm_backtrace.c" # 1 "" 1 # 1 "" 3 # 387 "" 3 # 1 "" 1 # 1 "" 2 # 1 "../../../Package/cm_backtrace/cm_backtrace.c" 2 # 29 "../../../Package/cm_backtrace/cm_backtrace.c" # 1 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\stdbool.h" 1 3 # 30 "../../../Package/cm_backtrace/cm_backtrace.c" 2 # 1 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\string.h" 1 3 # 51 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\string.h" 3 typedef unsigned int size_t; extern __attribute__((__nothrow__)) void *memcpy(void * __restrict , const void * __restrict , size_t ) __attribute__((__nonnull__(1,2))); extern __attribute__((__nothrow__)) void *memmove(void * , const void * , size_t ) __attribute__((__nonnull__(1,2))); # 77 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\string.h" 3 extern __attribute__((__nothrow__)) char *strcpy(char * __restrict , const char * __restrict ) __attribute__((__nonnull__(1,2))); extern __attribute__((__nothrow__)) char *strncpy(char * __restrict , const char * __restrict , size_t ) __attribute__((__nonnull__(1,2))); # 93 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\string.h" 3 extern __attribute__((__nothrow__)) char *strcat(char * __restrict , const char * __restrict ) __attribute__((__nonnull__(1,2))); extern __attribute__((__nothrow__)) char *strncat(char * __restrict , const char * __restrict , size_t ) __attribute__((__nonnull__(1,2))); # 117 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\string.h" 3 extern __attribute__((__nothrow__)) int memcmp(const void * , const void * , size_t ) __attribute__((__nonnull__(1,2))); extern __attribute__((__nothrow__)) int strcmp(const char * , const char * ) __attribute__((__nonnull__(1,2))); extern __attribute__((__nothrow__)) int strncmp(const char * , const char * , size_t ) __attribute__((__nonnull__(1,2))); # 141 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\string.h" 3 extern __attribute__((__nothrow__)) int strcasecmp(const char * , const char * ) __attribute__((__nonnull__(1,2))); extern __attribute__((__nothrow__)) int strncasecmp(const char * , const char * , size_t ) __attribute__((__nonnull__(1,2))); # 158 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\string.h" 3 extern __attribute__((__nothrow__)) int strcoll(const char * , const char * ) __attribute__((__nonnull__(1,2))); # 169 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\string.h" 3 extern __attribute__((__nothrow__)) size_t strxfrm(char * __restrict , const char * __restrict , size_t ) __attribute__((__nonnull__(2))); # 193 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\string.h" 3 extern __attribute__((__nothrow__)) void *memchr(const void * , int , size_t ) __attribute__((__nonnull__(1))); # 209 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\string.h" 3 extern __attribute__((__nothrow__)) char *strchr(const char * , int ) __attribute__((__nonnull__(1))); # 218 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\string.h" 3 extern __attribute__((__nothrow__)) size_t strcspn(const char * , const char * ) __attribute__((__nonnull__(1,2))); # 232 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\string.h" 3 extern __attribute__((__nothrow__)) char *strpbrk(const char * , const char * ) __attribute__((__nonnull__(1,2))); # 247 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\string.h" 3 extern __attribute__((__nothrow__)) char *strrchr(const char * , int ) __attribute__((__nonnull__(1))); # 257 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\string.h" 3 extern __attribute__((__nothrow__)) size_t strspn(const char * , const char * ) __attribute__((__nonnull__(1,2))); # 270 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\string.h" 3 extern __attribute__((__nothrow__)) char *strstr(const char * , const char * ) __attribute__((__nonnull__(1,2))); # 280 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\string.h" 3 extern __attribute__((__nothrow__)) char *strtok(char * __restrict , const char * __restrict ) __attribute__((__nonnull__(2))); extern __attribute__((__nothrow__)) char *_strtok_r(char * , const char * , char ** ) __attribute__((__nonnull__(2,3))); # 321 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\string.h" 3 extern __attribute__((__nothrow__)) void *memset(void * , int , size_t ) __attribute__((__nonnull__(1))); extern __attribute__((__nothrow__)) char *strerror(int ); extern __attribute__((__nothrow__)) size_t strlen(const char * ) __attribute__((__nonnull__(1))); extern __attribute__((__nothrow__)) size_t strlcpy(char * , const char * , size_t ) __attribute__((__nonnull__(1,2))); # 362 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\string.h" 3 extern __attribute__((__nothrow__)) size_t strlcat(char * , const char * , size_t ) __attribute__((__nonnull__(1,2))); # 388 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\string.h" 3 extern __attribute__((__nothrow__)) void _membitcpybl(void * , const void * , int , int , size_t ) __attribute__((__nonnull__(1,2))); extern __attribute__((__nothrow__)) void _membitcpybb(void * , const void * , int , int , size_t ) __attribute__((__nonnull__(1,2))); extern __attribute__((__nothrow__)) void _membitcpyhl(void * , const void * , int , int , size_t ) __attribute__((__nonnull__(1,2))); extern __attribute__((__nothrow__)) void _membitcpyhb(void * , const void * , int , int , size_t ) __attribute__((__nonnull__(1,2))); extern __attribute__((__nothrow__)) void _membitcpywl(void * , const void * , int , int , size_t ) __attribute__((__nonnull__(1,2))); extern __attribute__((__nothrow__)) void _membitcpywb(void * , const void * , int , int , size_t ) __attribute__((__nonnull__(1,2))); extern __attribute__((__nothrow__)) void _membitmovebl(void * , const void * , int , int , size_t ) __attribute__((__nonnull__(1,2))); extern __attribute__((__nothrow__)) void _membitmovebb(void * , const void * , int , int , size_t ) __attribute__((__nonnull__(1,2))); extern __attribute__((__nothrow__)) void _membitmovehl(void * , const void * , int , int , size_t ) __attribute__((__nonnull__(1,2))); extern __attribute__((__nothrow__)) void _membitmovehb(void * , const void * , int , int , size_t ) __attribute__((__nonnull__(1,2))); extern __attribute__((__nothrow__)) void _membitmovewl(void * , const void * , int , int , size_t ) __attribute__((__nonnull__(1,2))); extern __attribute__((__nothrow__)) void _membitmovewb(void * , const void * , int , int , size_t ) __attribute__((__nonnull__(1,2))); # 31 "../../../Package/cm_backtrace/cm_backtrace.c" 2 # 1 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\stdio.h" 1 3 # 68 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\stdio.h" 3 typedef __builtin_va_list __va_list; # 87 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\stdio.h" 3 typedef struct __fpos_t_struct { unsigned long long int __pos; struct { unsigned int __state1, __state2; } __mbstate; } fpos_t; # 108 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\stdio.h" 3 typedef struct __FILE FILE; # 119 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\stdio.h" 3 struct __FILE { union { long __FILE_alignment; char __FILE_size[84]; } __FILE_opaque; }; # 138 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\stdio.h" 3 extern FILE __stdin, __stdout, __stderr; extern FILE *__aeabi_stdin, *__aeabi_stdout, *__aeabi_stderr; # 224 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\stdio.h" 3 extern __attribute__((__nothrow__)) int remove(const char * ) __attribute__((__nonnull__(1))); extern __attribute__((__nothrow__)) int rename(const char * , const char * ) __attribute__((__nonnull__(1,2))); # 243 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\stdio.h" 3 extern __attribute__((__nothrow__)) FILE *tmpfile(void); extern __attribute__((__nothrow__)) char *tmpnam(char * ); # 265 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\stdio.h" 3 extern __attribute__((__nothrow__)) int fclose(FILE * ) __attribute__((__nonnull__(1))); # 275 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\stdio.h" 3 extern __attribute__((__nothrow__)) int fflush(FILE * ); # 285 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\stdio.h" 3 extern __attribute__((__nothrow__)) FILE *fopen(const char * __restrict , const char * __restrict ) __attribute__((__nonnull__(1,2))); # 329 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\stdio.h" 3 extern __attribute__((__nothrow__)) FILE *freopen(const char * __restrict , const char * __restrict , FILE * __restrict ) __attribute__((__nonnull__(2,3))); # 342 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\stdio.h" 3 extern __attribute__((__nothrow__)) void setbuf(FILE * __restrict , char * __restrict ) __attribute__((__nonnull__(1))); extern __attribute__((__nothrow__)) int setvbuf(FILE * __restrict , char * __restrict , int , size_t ) __attribute__((__nonnull__(1))); # 370 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\stdio.h" 3 #pragma __printf_args extern __attribute__((__nothrow__)) int fprintf(FILE * __restrict , const char * __restrict , ...) __attribute__((__nonnull__(1,2))); # 393 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\stdio.h" 3 #pragma __printf_args extern __attribute__((__nothrow__)) int _fprintf(FILE * __restrict , const char * __restrict , ...) __attribute__((__nonnull__(1,2))); #pragma __printf_args extern __attribute__((__nothrow__)) int printf(const char * __restrict , ...) __attribute__((__nonnull__(1))); #pragma __printf_args extern __attribute__((__nothrow__)) int _printf(const char * __restrict , ...) __attribute__((__nonnull__(1))); #pragma __printf_args extern __attribute__((__nothrow__)) int sprintf(char * __restrict , const char * __restrict , ...) __attribute__((__nonnull__(1,2))); #pragma __printf_args extern __attribute__((__nothrow__)) int _sprintf(char * __restrict , const char * __restrict , ...) __attribute__((__nonnull__(1,2))); #pragma __printf_args extern __attribute__((__nothrow__)) int __ARM_snprintf(char * __restrict , size_t , const char * __restrict , ...) __attribute__((__nonnull__(3))); #pragma __printf_args extern __attribute__((__nothrow__)) int snprintf(char * __restrict , size_t , const char * __restrict , ...) __attribute__((__nonnull__(3))); # 460 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\stdio.h" 3 #pragma __printf_args extern __attribute__((__nothrow__)) int _snprintf(char * __restrict , size_t , const char * __restrict , ...) __attribute__((__nonnull__(3))); #pragma __scanf_args extern __attribute__((__nothrow__)) int fscanf(FILE * __restrict , const char * __restrict , ...) __attribute__((__nonnull__(1,2))); # 503 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\stdio.h" 3 #pragma __scanf_args extern __attribute__((__nothrow__)) int _fscanf(FILE * __restrict , const char * __restrict , ...) __attribute__((__nonnull__(1,2))); #pragma __scanf_args extern __attribute__((__nothrow__)) int scanf(const char * __restrict , ...) __attribute__((__nonnull__(1))); #pragma __scanf_args extern __attribute__((__nothrow__)) int _scanf(const char * __restrict , ...) __attribute__((__nonnull__(1))); #pragma __scanf_args extern __attribute__((__nothrow__)) int sscanf(const char * __restrict , const char * __restrict , ...) __attribute__((__nonnull__(1,2))); # 541 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\stdio.h" 3 #pragma __scanf_args extern __attribute__((__nothrow__)) int _sscanf(const char * __restrict , const char * __restrict , ...) __attribute__((__nonnull__(1,2))); extern __attribute__((__nothrow__)) int vfscanf(FILE * __restrict , const char * __restrict , __va_list) __attribute__((__nonnull__(1,2))); extern __attribute__((__nothrow__)) int vscanf(const char * __restrict , __va_list) __attribute__((__nonnull__(1))); extern __attribute__((__nothrow__)) int vsscanf(const char * __restrict , const char * __restrict , __va_list) __attribute__((__nonnull__(1,2))); extern __attribute__((__nothrow__)) int _vfscanf(FILE * __restrict , const char * __restrict , __va_list) __attribute__((__nonnull__(1,2))); extern __attribute__((__nothrow__)) int _vscanf(const char * __restrict , __va_list) __attribute__((__nonnull__(1))); extern __attribute__((__nothrow__)) int _vsscanf(const char * __restrict , const char * __restrict , __va_list) __attribute__((__nonnull__(1,2))); extern __attribute__((__nothrow__)) int __ARM_vsscanf(const char * __restrict , const char * __restrict , __va_list) __attribute__((__nonnull__(1,2))); extern __attribute__((__nothrow__)) int vprintf(const char * __restrict , __va_list ) __attribute__((__nonnull__(1))); extern __attribute__((__nothrow__)) int _vprintf(const char * __restrict , __va_list ) __attribute__((__nonnull__(1))); extern __attribute__((__nothrow__)) int vfprintf(FILE * __restrict , const char * __restrict , __va_list ) __attribute__((__nonnull__(1,2))); # 584 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\stdio.h" 3 extern __attribute__((__nothrow__)) int vsprintf(char * __restrict , const char * __restrict , __va_list ) __attribute__((__nonnull__(1,2))); # 594 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\stdio.h" 3 extern __attribute__((__nothrow__)) int __ARM_vsnprintf(char * __restrict , size_t , const char * __restrict , __va_list ) __attribute__((__nonnull__(3))); extern __attribute__((__nothrow__)) int vsnprintf(char * __restrict , size_t , const char * __restrict , __va_list ) __attribute__((__nonnull__(3))); # 609 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\stdio.h" 3 extern __attribute__((__nothrow__)) int _vsprintf(char * __restrict , const char * __restrict , __va_list ) __attribute__((__nonnull__(1,2))); extern __attribute__((__nothrow__)) int _vfprintf(FILE * __restrict , const char * __restrict , __va_list ) __attribute__((__nonnull__(1,2))); extern __attribute__((__nothrow__)) int _vsnprintf(char * __restrict , size_t , const char * __restrict , __va_list ) __attribute__((__nonnull__(3))); # 635 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\stdio.h" 3 #pragma __printf_args extern __attribute__((__nothrow__)) int __ARM_asprintf(char ** , const char * __restrict , ...) __attribute__((__nonnull__(2))); extern __attribute__((__nothrow__)) int __ARM_vasprintf(char ** , const char * __restrict , __va_list ) __attribute__((__nonnull__(2))); # 649 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\stdio.h" 3 extern __attribute__((__nothrow__)) int fgetc(FILE * ) __attribute__((__nonnull__(1))); # 659 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\stdio.h" 3 extern __attribute__((__nothrow__)) char *fgets(char * __restrict , int , FILE * __restrict ) __attribute__((__nonnull__(1,3))); # 673 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\stdio.h" 3 extern __attribute__((__nothrow__)) int fputc(int , FILE * ) __attribute__((__nonnull__(2))); # 683 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\stdio.h" 3 extern __attribute__((__nothrow__)) int fputs(const char * __restrict , FILE * __restrict ) __attribute__((__nonnull__(1,2))); extern __attribute__((__nothrow__)) int getc(FILE * ) __attribute__((__nonnull__(1))); # 704 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\stdio.h" 3 extern __attribute__((__nothrow__)) int (getchar)(void); # 713 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\stdio.h" 3 extern __attribute__((__nothrow__)) char *gets(char * ) __attribute__((__nonnull__(1))); # 725 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\stdio.h" 3 extern __attribute__((__nothrow__)) int putc(int , FILE * ) __attribute__((__nonnull__(2))); # 737 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\stdio.h" 3 extern __attribute__((__nothrow__)) int (putchar)(int ); extern __attribute__((__nothrow__)) int puts(const char * ) __attribute__((__nonnull__(1))); extern __attribute__((__nothrow__)) int ungetc(int , FILE * ) __attribute__((__nonnull__(2))); # 778 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\stdio.h" 3 extern __attribute__((__nothrow__)) size_t fread(void * __restrict , size_t , size_t , FILE * __restrict ) __attribute__((__nonnull__(1,4))); # 794 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\stdio.h" 3 extern __attribute__((__nothrow__)) size_t __fread_bytes_avail(void * __restrict , size_t , FILE * __restrict ) __attribute__((__nonnull__(1,3))); # 810 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\stdio.h" 3 extern __attribute__((__nothrow__)) size_t fwrite(const void * __restrict , size_t , size_t , FILE * __restrict ) __attribute__((__nonnull__(1,4))); # 822 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\stdio.h" 3 extern __attribute__((__nothrow__)) int fgetpos(FILE * __restrict , fpos_t * __restrict ) __attribute__((__nonnull__(1,2))); # 833 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\stdio.h" 3 extern __attribute__((__nothrow__)) int fseek(FILE * , long int , int ) __attribute__((__nonnull__(1))); # 850 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\stdio.h" 3 extern __attribute__((__nothrow__)) int fsetpos(FILE * __restrict , const fpos_t * __restrict ) __attribute__((__nonnull__(1,2))); # 863 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\stdio.h" 3 extern __attribute__((__nothrow__)) long int ftell(FILE * ) __attribute__((__nonnull__(1))); # 877 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\stdio.h" 3 extern __attribute__((__nothrow__)) void rewind(FILE * ) __attribute__((__nonnull__(1))); # 886 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\stdio.h" 3 extern __attribute__((__nothrow__)) void clearerr(FILE * ) __attribute__((__nonnull__(1))); extern __attribute__((__nothrow__)) int feof(FILE * ) __attribute__((__nonnull__(1))); extern __attribute__((__nothrow__)) int ferror(FILE * ) __attribute__((__nonnull__(1))); extern __attribute__((__nothrow__)) void perror(const char * ); # 917 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\stdio.h" 3 extern __attribute__((__nothrow__)) int _fisatty(FILE * ) __attribute__((__nonnull__(1))); extern __attribute__((__nothrow__)) void __use_no_semihosting_swi(void); extern __attribute__((__nothrow__)) void __use_no_semihosting(void); # 32 "../../../Package/cm_backtrace/cm_backtrace.c" 2 # 1 "../../../Package/cm_backtrace/cm_backtrace.h" 1 # 32 "../../../Package/cm_backtrace/cm_backtrace.h" # 1 "../../../Package/cm_backtrace/cmb_def.h" 1 # 32 "../../../Package/cm_backtrace/cmb_def.h" # 1 "../../../Package/cm_backtrace\\cmb_cfg.h" 1 # 34 "../../../Package/cm_backtrace\\cmb_cfg.h" # 1 "../../../Package/cm_backtrace/MyPrintf.h" 1 void MyPrintf(const char *fmt,...); # 35 "../../../Package/cm_backtrace\\cmb_cfg.h" 2 # 33 "../../../Package/cm_backtrace/cmb_def.h" 2 # 1 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\stdint.h" 1 3 # 56 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\stdint.h" 3 typedef signed char int8_t; typedef signed short int int16_t; typedef signed int int32_t; typedef signed long long int int64_t; typedef unsigned char uint8_t; typedef unsigned short int uint16_t; typedef unsigned int uint32_t; typedef unsigned long long int uint64_t; typedef signed char int_least8_t; typedef signed short int int_least16_t; typedef signed int int_least32_t; typedef signed long long int int_least64_t; typedef unsigned char uint_least8_t; typedef unsigned short int uint_least16_t; typedef unsigned int uint_least32_t; typedef unsigned long long int uint_least64_t; typedef signed int int_fast8_t; typedef signed int int_fast16_t; typedef signed int int_fast32_t; typedef signed long long int int_fast64_t; typedef unsigned int uint_fast8_t; typedef unsigned int uint_fast16_t; typedef unsigned int uint_fast32_t; typedef unsigned long long int uint_fast64_t; typedef signed int intptr_t; typedef unsigned int uintptr_t; typedef signed long long intmax_t; typedef unsigned long long uintmax_t; # 34 "../../../Package/cm_backtrace/cmb_def.h" 2 # 1 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\stdlib.h" 1 3 # 91 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\stdlib.h" 3 typedef unsigned short wchar_t; typedef struct div_t { int quot, rem; } div_t; typedef struct ldiv_t { long int quot, rem; } ldiv_t; typedef struct lldiv_t { long long quot, rem; } lldiv_t; # 139 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\stdlib.h" 3 extern __attribute__((__nothrow__)) int __aeabi_MB_CUR_MAX(void); # 158 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\stdlib.h" 3 extern __attribute__((__nothrow__)) double atof(const char * ) __attribute__((__nonnull__(1))); extern __attribute__((__nothrow__)) int atoi(const char * ) __attribute__((__nonnull__(1))); extern __attribute__((__nothrow__)) long int atol(const char * ) __attribute__((__nonnull__(1))); extern __attribute__((__nothrow__)) long long atoll(const char * ) __attribute__((__nonnull__(1))); extern __attribute__((__nothrow__)) double strtod(const char * __restrict , char ** __restrict ) __attribute__((__nonnull__(1))); # 206 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\stdlib.h" 3 extern __attribute__((__nothrow__)) float strtof(const char * __restrict , char ** __restrict ) __attribute__((__nonnull__(1))); extern __attribute__((__nothrow__)) long double strtold(const char * __restrict , char ** __restrict ) __attribute__((__nonnull__(1))); extern __attribute__((__nothrow__)) long int strtol(const char * __restrict , char ** __restrict , int ) __attribute__((__nonnull__(1))); # 243 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\stdlib.h" 3 extern __attribute__((__nothrow__)) unsigned long int strtoul(const char * __restrict , char ** __restrict , int ) __attribute__((__nonnull__(1))); # 275 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\stdlib.h" 3 extern __attribute__((__nothrow__)) long long strtoll(const char * __restrict , char ** __restrict , int ) __attribute__((__nonnull__(1))); extern __attribute__((__nothrow__)) unsigned long long strtoull(const char * __restrict , char ** __restrict , int ) __attribute__((__nonnull__(1))); extern __attribute__((__nothrow__)) int rand(void); # 303 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\stdlib.h" 3 extern __attribute__((__nothrow__)) void srand(unsigned int ); # 313 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\stdlib.h" 3 struct _rand_state { int __x[57]; }; extern __attribute__((__nothrow__)) int _rand_r(struct _rand_state *); extern __attribute__((__nothrow__)) void _srand_r(struct _rand_state *, unsigned int); struct _ANSI_rand_state { int __x[1]; }; extern __attribute__((__nothrow__)) int _ANSI_rand_r(struct _ANSI_rand_state *); extern __attribute__((__nothrow__)) void _ANSI_srand_r(struct _ANSI_rand_state *, unsigned int); extern __attribute__((__nothrow__)) void *calloc(size_t , size_t ); extern __attribute__((__nothrow__)) void free(void * ); extern __attribute__((__nothrow__)) void *malloc(size_t ); extern __attribute__((__nothrow__)) void *realloc(void * , size_t ); # 374 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\stdlib.h" 3 typedef int (*__heapprt)(void *, char const *, ...); extern __attribute__((__nothrow__)) void __heapstats(int (* )(void * , char const * , ...), void * ) __attribute__((__nonnull__(1))); # 390 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\stdlib.h" 3 extern __attribute__((__nothrow__)) int __heapvalid(int (* )(void * , char const * , ...), void * , int ) __attribute__((__nonnull__(1))); # 411 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\stdlib.h" 3 extern __attribute__((__nothrow__)) __attribute__((__noreturn__)) void abort(void); # 422 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\stdlib.h" 3 extern __attribute__((__nothrow__)) int atexit(void (* )(void)) __attribute__((__nonnull__(1))); # 444 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\stdlib.h" 3 extern __attribute__((__nothrow__)) __attribute__((__noreturn__)) void exit(int ); # 460 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\stdlib.h" 3 extern __attribute__((__nothrow__)) __attribute__((__noreturn__)) void _Exit(int ); # 471 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\stdlib.h" 3 extern __attribute__((__nothrow__)) char *getenv(const char * ) __attribute__((__nonnull__(1))); # 484 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\stdlib.h" 3 extern __attribute__((__nothrow__)) int system(const char * ); # 497 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\stdlib.h" 3 extern void *bsearch(const void * , const void * , size_t , size_t , int (* )(const void *, const void *)) __attribute__((__nonnull__(1,2,5))); # 532 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\stdlib.h" 3 extern void qsort(void * , size_t , size_t , int (* )(const void *, const void *)) __attribute__((__nonnull__(1,4))); # 560 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\stdlib.h" 3 extern __attribute__((__nothrow__)) __attribute__((__const__)) int abs(int ); extern __attribute__((__nothrow__)) __attribute__((__const__)) div_t div(int , int ); # 579 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\stdlib.h" 3 extern __attribute__((__nothrow__)) __attribute__((__const__)) long int labs(long int ); # 589 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\stdlib.h" 3 extern __attribute__((__nothrow__)) __attribute__((__const__)) ldiv_t ldiv(long int , long int ); # 610 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\stdlib.h" 3 extern __attribute__((__nothrow__)) __attribute__((__const__)) long long llabs(long long ); # 620 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\stdlib.h" 3 extern __attribute__((__nothrow__)) __attribute__((__const__)) lldiv_t lldiv(long long , long long ); # 644 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\stdlib.h" 3 typedef struct __sdiv32by16 { long quot, rem; } __sdiv32by16; typedef struct __udiv32by16 { unsigned long quot, rem; } __udiv32by16; typedef struct __sdiv64by32 { long rem, quot; } __sdiv64by32; __attribute__((__value_in_regs__)) extern __attribute__((__nothrow__)) __attribute__((__const__)) __sdiv32by16 __rt_sdiv32by16( int , short int ); __attribute__((__value_in_regs__)) extern __attribute__((__nothrow__)) __attribute__((__const__)) __udiv32by16 __rt_udiv32by16( unsigned int , unsigned short ); __attribute__((__value_in_regs__)) extern __attribute__((__nothrow__)) __attribute__((__const__)) __sdiv64by32 __rt_sdiv64by32( int , unsigned int , int ); extern __attribute__((__nothrow__)) unsigned int __fp_status(unsigned int , unsigned int ); # 705 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\stdlib.h" 3 extern __attribute__((__nothrow__)) int mblen(const char * , size_t ); # 720 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\stdlib.h" 3 extern __attribute__((__nothrow__)) int mbtowc(wchar_t * __restrict , const char * __restrict , size_t ); # 739 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\stdlib.h" 3 extern __attribute__((__nothrow__)) int wctomb(char * , wchar_t ); # 761 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\stdlib.h" 3 extern __attribute__((__nothrow__)) size_t mbstowcs(wchar_t * __restrict , const char * __restrict , size_t ) __attribute__((__nonnull__(2))); # 779 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\stdlib.h" 3 extern __attribute__((__nothrow__)) size_t wcstombs(char * __restrict , const wchar_t * __restrict , size_t ) __attribute__((__nonnull__(2))); # 798 "d:\\Keil\\ARM\\ARMCLANG\\Bin\\..\\include\\stdlib.h" 3 extern __attribute__((__nothrow__)) void __use_realtime_heap(void); extern __attribute__((__nothrow__)) void __use_realtime_division(void); extern __attribute__((__nothrow__)) void __use_two_region_memory(void); extern __attribute__((__nothrow__)) void __use_no_heap(void); extern __attribute__((__nothrow__)) void __use_no_heap_region(void); extern __attribute__((__nothrow__)) char const *__C_library_version_string(void); extern __attribute__((__nothrow__)) int __C_library_version_number(void); # 35 "../../../Package/cm_backtrace/cmb_def.h" 2 # 167 "../../../Package/cm_backtrace/cmb_def.h" struct cmb_hard_fault_regs{ struct { unsigned int r0; unsigned int r1; unsigned int r2; unsigned int r3; unsigned int r12; unsigned int lr; unsigned int pc; union { unsigned int value; struct { unsigned int IPSR : 8; unsigned int EPSR : 19; unsigned int APSR : 5; } bits; } psr; } saved; union { unsigned int value; struct { unsigned int MEMFAULTACT : 1; unsigned int BUSFAULTACT : 1; unsigned int UnusedBits1 : 1; unsigned int USGFAULTACT : 1; unsigned int UnusedBits2 : 3; unsigned int SVCALLACT : 1; unsigned int MONITORACT : 1; unsigned int UnusedBits3 : 1; unsigned int PENDSVACT : 1; unsigned int SYSTICKACT : 1; unsigned int USGFAULTPENDED : 1; unsigned int MEMFAULTPENDED : 1; unsigned int BUSFAULTPENDED : 1; unsigned int SVCALLPENDED : 1; unsigned int MEMFAULTENA : 1; unsigned int BUSFAULTENA : 1; unsigned int USGFAULTENA : 1; } bits; } syshndctrl; union { unsigned char value; struct { unsigned char IACCVIOL : 1; unsigned char DACCVIOL : 1; unsigned char UnusedBits : 1; unsigned char MUNSTKERR : 1; unsigned char MSTKERR : 1; unsigned char MLSPERR : 1; unsigned char UnusedBits2 : 1; unsigned char MMARVALID : 1; } bits; } mfsr; unsigned int mmar; union { unsigned char value; struct { unsigned char IBUSERR : 1; unsigned char PRECISERR : 1; unsigned char IMPREISERR : 1; unsigned char UNSTKERR : 1; unsigned char STKERR : 1; unsigned char LSPERR : 1; unsigned char UnusedBits : 1; unsigned char BFARVALID : 1; } bits; } bfsr; unsigned int bfar; union { unsigned short value; struct { unsigned short UNDEFINSTR : 1; unsigned short INVSTATE : 1; unsigned short INVPC : 1; unsigned short NOCP : 1; unsigned short UnusedBits : 4; unsigned short UNALIGNED : 1; unsigned short DIVBYZERO0 : 1; } bits; } ufsr; union { unsigned int value; struct { unsigned int UnusedBits : 1; unsigned int VECTBL : 1; unsigned int UnusedBits2 : 28; unsigned int FORCED : 1; unsigned int DEBUGEVT : 1; } bits; } hfsr; union { unsigned int value; struct { unsigned int HALTED : 1; unsigned int BKPT : 1; unsigned int DWTTRAP : 1; unsigned int VCATCH : 1; unsigned int EXTERNAL : 1; } bits; } dfsr; unsigned int afsr; }; # 407 "../../../Package/cm_backtrace/cmb_def.h" __attribute__( ( always_inline ) ) static inline uint32_t cmb_get_msp(void) { register uint32_t result; __asm volatile ("MRS %0, msp\n" : "=r" (result) ); return(result); } __attribute__( ( always_inline ) ) static inline uint32_t cmb_get_psp(void) { register uint32_t result; __asm volatile ("MRS %0, psp\n" : "=r" (result) ); return(result); } __attribute__( ( always_inline ) ) static inline uint32_t cmb_get_sp(void) { register uint32_t result; __asm volatile ("MOV %0, sp\n" : "=r" (result) ); return(result); } # 33 "../../../Package/cm_backtrace/cm_backtrace.h" 2 void cm_backtrace_init(const char *firmware_name, const char *hardware_ver, const char *software_ver); void cm_backtrace_firmware_info(void); size_t cm_backtrace_call_stack(uint32_t *buffer, size_t size, uint32_t sp); void cm_backtrace_assert(uint32_t sp); void cm_backtrace_fault(uint32_t fault_handler_lr, uint32_t fault_handler_sp); # 33 "../../../Package/cm_backtrace/cm_backtrace.c" 2 # 48 "../../../Package/cm_backtrace/cm_backtrace.c" extern const int STACK$$Base; extern const int STACK$$Limit; extern const int Image$$ER_IROM1$$Base; extern const int Image$$ER_IROM1$$Limit; # 64 "../../../Package/cm_backtrace/cm_backtrace.c" enum { PRINT_MAIN_STACK_CFG_ERROR, PRINT_FIRMWARE_INFO, PRINT_ASSERT_ON_THREAD, PRINT_ASSERT_ON_HANDLER, PRINT_THREAD_STACK_INFO, PRINT_MAIN_STACK_INFO, PRINT_THREAD_STACK_OVERFLOW, PRINT_MAIN_STACK_OVERFLOW, PRINT_CALL_STACK_INFO, PRINT_CALL_STACK_ERR, PRINT_FAULT_ON_THREAD, PRINT_FAULT_ON_HANDLER, PRINT_REGS_TITLE, PRINT_HFSR_VECTBL, PRINT_MFSR_IACCVIOL, PRINT_MFSR_DACCVIOL, PRINT_MFSR_MUNSTKERR, PRINT_MFSR_MSTKERR, PRINT_MFSR_MLSPERR, PRINT_BFSR_IBUSERR, PRINT_BFSR_PRECISERR, PRINT_BFSR_IMPREISERR, PRINT_BFSR_UNSTKERR, PRINT_BFSR_STKERR, PRINT_BFSR_LSPERR, PRINT_UFSR_UNDEFINSTR, PRINT_UFSR_INVSTATE, PRINT_UFSR_INVPC, PRINT_UFSR_NOCP, PRINT_UFSR_UNALIGNED, PRINT_UFSR_DIVBYZERO0, PRINT_DFSR_HALTED, PRINT_DFSR_BKPT, PRINT_DFSR_DWTTRAP, PRINT_DFSR_VCATCH, PRINT_DFSR_EXTERNAL, PRINT_MMAR, PRINT_BFAR, }; static const char * const print_info[] = { # 1 "../../../Package/cm_backtrace/Languages/en-US/cmb_en_US.h" 1 # 31 "../../../Package/cm_backtrace/Languages/en-US/cmb_en_US.h" [PRINT_MAIN_STACK_CFG_ERROR] = "ERROR: Unable to get the main stack information, please check the configuration of the main stack", [PRINT_FIRMWARE_INFO] = "Firmware name: %s, hardware version: %s, software version: %s", [PRINT_ASSERT_ON_THREAD] = "Assert on thread %s", [PRINT_ASSERT_ON_HANDLER] = "Assert on interrupt or bare metal(no OS) environment", [PRINT_THREAD_STACK_INFO] = "===== Thread stack information =====", [PRINT_MAIN_STACK_INFO] = "====== Main stack information ======", [PRINT_THREAD_STACK_OVERFLOW] = "Error: Thread stack(%08x) was overflow", [PRINT_MAIN_STACK_OVERFLOW] = "Error: Main stack(%08x) was overflow", [PRINT_CALL_STACK_INFO] = "Show more call stack info by run: addr2line -e %s%s -afpiC %.*s", [PRINT_CALL_STACK_ERR] = "Dump call stack has an error", [PRINT_FAULT_ON_THREAD] = "Fault on thread %s", [PRINT_FAULT_ON_HANDLER] = "Fault on interrupt or bare metal(no OS) environment", [PRINT_REGS_TITLE] = "=================== Registers information ====================", [PRINT_HFSR_VECTBL] = "Hard fault is caused by failed vector fetch", [PRINT_MFSR_IACCVIOL] = "Memory management fault is caused by instruction access violation", [PRINT_MFSR_DACCVIOL] = "Memory management fault is caused by data access violation", [PRINT_MFSR_MUNSTKERR] = "Memory management fault is caused by unstacking error", [PRINT_MFSR_MSTKERR] = "Memory management fault is caused by stacking error", [PRINT_MFSR_MLSPERR] = "Memory management fault is caused by floating-point lazy state preservation", [PRINT_BFSR_IBUSERR] = "Bus fault is caused by instruction access violation", [PRINT_BFSR_PRECISERR] = "Bus fault is caused by precise data access violation", [PRINT_BFSR_IMPREISERR] = "Bus fault is caused by imprecise data access violation", [PRINT_BFSR_UNSTKERR] = "Bus fault is caused by unstacking error", [PRINT_BFSR_STKERR] = "Bus fault is caused by stacking error", [PRINT_BFSR_LSPERR] = "Bus fault is caused by floating-point lazy state preservation", [PRINT_UFSR_UNDEFINSTR] = "Usage fault is caused by attempts to execute an undefined instruction", [PRINT_UFSR_INVSTATE] = "Usage fault is caused by attempts to switch to an invalid state (e.g., ARM)", [PRINT_UFSR_INVPC] = "Usage fault is caused by attempts to do an exception with a bad value in the EXC_RETURN number", [PRINT_UFSR_NOCP] = "Usage fault is caused by attempts to execute a coprocessor instruction", [PRINT_UFSR_UNALIGNED] = "Usage fault is caused by indicates that an unaligned access fault has taken place", [PRINT_UFSR_DIVBYZERO0] = "Usage fault is caused by Indicates a divide by zero has taken place (can be set only if DIV_0_TRP is set)", [PRINT_DFSR_HALTED] = "Debug fault is caused by halt requested in NVIC", [PRINT_DFSR_BKPT] = "Debug fault is caused by BKPT instruction executed", [PRINT_DFSR_DWTTRAP] = "Debug fault is caused by DWT match occurred", [PRINT_DFSR_VCATCH] = "Debug fault is caused by Vector fetch occurred", [PRINT_DFSR_EXTERNAL] = "Debug fault is caused by EDBGRQ signal asserted", [PRINT_MMAR] = "The memory management fault occurred address is %08x", [PRINT_BFAR] = "The bus fault occurred address is %08x", # 111 "../../../Package/cm_backtrace/cm_backtrace.c" 2 # 120 "../../../Package/cm_backtrace/cm_backtrace.c" }; static char fw_name[32 + 1] = {0}; static char hw_ver[32 + 1] = {0}; static char sw_ver[32 + 1] = {0}; static uint32_t main_stack_start_addr1 = 0; static uint32_t main_stack_start_addr = 0; static size_t main_stack_size = 0; static uint32_t code_start_addr = 0; static size_t code_size = 0; static _Bool init_ok = 0; static char call_stack_info[32 * (8 + 1)] = { 0 }; static _Bool on_fault = 0; static _Bool stack_is_overflow = 0; static struct cmb_hard_fault_regs regs; static _Bool statck_has_fpu_regs = 0; static _Bool on_thread_before_fault = 0; extern uint32_t Image$$ARM_LIB_STACK$$Base; extern uint32_t Image$$ARM_LIB_STACK$$ZI$$Base; extern uint32_t Image$$ARM_LIB_STACK$$ZI$$Limit; void cm_backtrace_init(const char *firmware_name, const char *hardware_ver, const char *software_ver) { strncpy(fw_name, firmware_name, 32); strncpy(hw_ver, hardware_ver, 32); strncpy(sw_ver, software_ver, 32); main_stack_start_addr1 = (uint32_t)&Image$$ARM_LIB_STACK$$ZI$$Base; main_stack_start_addr = (uint32_t)&Image$$ARM_LIB_STACK$$Base; main_stack_size = (uint32_t)&Image$$ARM_LIB_STACK$$ZI$$Limit-main_stack_start_addr; code_start_addr = (uint32_t)&Image$$ER_IROM1$$Base; code_size = (uint32_t)&Image$$ER_IROM1$$Limit - code_start_addr; # 178 "../../../Package/cm_backtrace/cm_backtrace.c" if (main_stack_size == 0) { MyPrintf(print_info[PRINT_MAIN_STACK_CFG_ERROR]); return; } init_ok = 1; } void cm_backtrace_firmware_info(void) { MyPrintf(print_info[PRINT_FIRMWARE_INFO], fw_name, hw_ver, sw_ver); } # 266 "../../../Package/cm_backtrace/cm_backtrace.c" static void dump_stack(uint32_t stack_start_addr, size_t stack_size, uint32_t *stack_pointer) { uint32_t deep = (16); if (stack_is_overflow) { if (on_thread_before_fault) { MyPrintf(print_info[PRINT_THREAD_STACK_OVERFLOW], stack_pointer); } else { MyPrintf(print_info[PRINT_MAIN_STACK_OVERFLOW], stack_pointer); } if ((uint32_t) stack_pointer < stack_start_addr) { stack_pointer = (uint32_t *) stack_start_addr; } else if ((uint32_t) stack_pointer > stack_start_addr + stack_size) { stack_pointer = (uint32_t *) (stack_start_addr + stack_size); } } MyPrintf(print_info[PRINT_THREAD_STACK_INFO]); for (; (uint32_t) stack_pointer < stack_start_addr + stack_size && deep; stack_pointer++, deep--) { MyPrintf(" addr: %08x data: %08x", stack_pointer, *stack_pointer); } MyPrintf("===================================="); } static _Bool disassembly_ins_is_bl_blx(uint32_t addr) { uint16_t ins1 = *((uint16_t *)addr); uint16_t ins2 = *((uint16_t *)(addr + 2)); if ((ins2 & 0xF800) == 0xF800 && (ins1 & 0xF800) == 0xF000) { return 1; } else if ((ins2 & 0xFF00) == 0x4700) { return 1; } else { return 0; } } size_t cm_backtrace_call_stack_any(uint32_t *buffer, size_t size, uint32_t sp, uint32_t stack_start_addr, uint32_t stack_size) { uint32_t pc; size_t depth = 0; for (; sp < stack_start_addr + stack_size; sp += sizeof(size_t)) { pc = *((uint32_t *) sp) - sizeof(size_t); if (pc % 2 == 0) { continue; } pc = *((uint32_t *) sp) - 1; if ((pc >= code_start_addr + sizeof(size_t)) && (pc <= code_start_addr + code_size) && (depth < 32) && disassembly_ins_is_bl_blx(pc - sizeof(size_t)) && (depth < size)) { buffer[depth++] = pc; } } return depth; } # 343 "../../../Package/cm_backtrace/cm_backtrace.c" size_t cm_backtrace_call_stack(uint32_t *buffer, size_t size, uint32_t sp) { uint32_t stack_start_addr = main_stack_start_addr, pc; size_t depth = 0, stack_size = main_stack_size; _Bool regs_saved_lr_is_valid = 0; if (on_fault) { if (!stack_is_overflow) { buffer[depth++] = regs.saved.pc; pc = regs.saved.lr - 1; if ((pc >= code_start_addr) && (pc <= code_start_addr + code_size) && (depth < 32) && (depth < size)) { buffer[depth++] = pc; regs_saved_lr_is_valid = 1; } } # 377 "../../../Package/cm_backtrace/cm_backtrace.c" } if (stack_is_overflow) { sp = stack_start_addr; } for (; sp < stack_start_addr + stack_size; sp += sizeof(size_t)) { pc = *((uint32_t *) sp) - sizeof(size_t); if (pc % 2 == 0) { continue; } pc = *((uint32_t *) sp) - 1; if ((pc >= code_start_addr + sizeof(size_t)) && (pc <= code_start_addr + code_size) && (depth < 32) && disassembly_ins_is_bl_blx(pc - sizeof(size_t)) && (depth < size)) { if ((depth == 2) && regs_saved_lr_is_valid && (pc == buffer[1])) { continue; } buffer[depth++] = pc; } } return depth; } static void print_call_stack(uint32_t sp) { size_t i, cur_depth = 0; uint32_t call_stack_buf[32] = {0}; cur_depth = cm_backtrace_call_stack(call_stack_buf, 32, sp); for (i = 0; i < cur_depth; i++) { sprintf(call_stack_info + i * (8 + 1), "%08lx", (unsigned long)call_stack_buf[i]); call_stack_info[i * (8 + 1) + 8] = ' '; } if (cur_depth) { MyPrintf(print_info[PRINT_CALL_STACK_INFO], fw_name, ".axf", cur_depth * (8 + 1), call_stack_info); } else { MyPrintf(print_info[PRINT_CALL_STACK_ERR]); } } void cm_backtrace_assert(uint32_t sp) { if (!(init_ok)) { MyPrintf("(%s) has assert failed at %s.", "init_ok", __FUNCTION__); while (1); }; MyPrintf(""); cm_backtrace_firmware_info(); # 472 "../../../Package/cm_backtrace/cm_backtrace.c" dump_stack(main_stack_start_addr, main_stack_size, (uint32_t *) sp); print_call_stack(sp); } static void fault_diagnosis(void) { if (regs.hfsr.bits.VECTBL) { MyPrintf(print_info[PRINT_HFSR_VECTBL]); } if (regs.hfsr.bits.FORCED) { if (regs.mfsr.value) { if (regs.mfsr.bits.IACCVIOL) { MyPrintf(print_info[PRINT_MFSR_IACCVIOL]); } if (regs.mfsr.bits.DACCVIOL) { MyPrintf(print_info[PRINT_MFSR_DACCVIOL]); } if (regs.mfsr.bits.MUNSTKERR) { MyPrintf(print_info[PRINT_MFSR_MUNSTKERR]); } if (regs.mfsr.bits.MSTKERR) { MyPrintf(print_info[PRINT_MFSR_MSTKERR]); } if (regs.mfsr.bits.MLSPERR) { MyPrintf(print_info[PRINT_MFSR_MLSPERR]); } if (regs.mfsr.bits.MMARVALID) { if (regs.mfsr.bits.IACCVIOL || regs.mfsr.bits.DACCVIOL) { MyPrintf(print_info[PRINT_MMAR], regs.mmar); } } } if (regs.bfsr.value) { if (regs.bfsr.bits.IBUSERR) { MyPrintf(print_info[PRINT_BFSR_IBUSERR]); } if (regs.bfsr.bits.PRECISERR) { MyPrintf(print_info[PRINT_BFSR_PRECISERR]); } if (regs.bfsr.bits.IMPREISERR) { MyPrintf(print_info[PRINT_BFSR_IMPREISERR]); } if (regs.bfsr.bits.UNSTKERR) { MyPrintf(print_info[PRINT_BFSR_UNSTKERR]); } if (regs.bfsr.bits.STKERR) { MyPrintf(print_info[PRINT_BFSR_STKERR]); } if (regs.bfsr.bits.LSPERR) { MyPrintf(print_info[PRINT_BFSR_LSPERR]); } if (regs.bfsr.bits.BFARVALID) { if (regs.bfsr.bits.PRECISERR) { MyPrintf(print_info[PRINT_BFAR], regs.bfar); } } } if (regs.ufsr.value) { if (regs.ufsr.bits.UNDEFINSTR) { MyPrintf(print_info[PRINT_UFSR_UNDEFINSTR]); } if (regs.ufsr.bits.INVSTATE) { MyPrintf(print_info[PRINT_UFSR_INVSTATE]); } if (regs.ufsr.bits.INVPC) { MyPrintf(print_info[PRINT_UFSR_INVPC]); } if (regs.ufsr.bits.NOCP) { MyPrintf(print_info[PRINT_UFSR_NOCP]); } if (regs.ufsr.bits.UNALIGNED) { MyPrintf(print_info[PRINT_UFSR_UNALIGNED]); } if (regs.ufsr.bits.DIVBYZERO0) { MyPrintf(print_info[PRINT_UFSR_DIVBYZERO0]); } } } if (regs.hfsr.bits.DEBUGEVT) { if (regs.dfsr.value) { if (regs.dfsr.bits.HALTED) { MyPrintf(print_info[PRINT_DFSR_HALTED]); } if (regs.dfsr.bits.BKPT) { MyPrintf(print_info[PRINT_DFSR_BKPT]); } if (regs.dfsr.bits.DWTTRAP) { MyPrintf(print_info[PRINT_DFSR_DWTTRAP]); } if (regs.dfsr.bits.VCATCH) { MyPrintf(print_info[PRINT_DFSR_VCATCH]); } if (regs.dfsr.bits.EXTERNAL) { MyPrintf(print_info[PRINT_DFSR_EXTERNAL]); } } } } static uint32_t statck_del_fpu_regs(uint32_t fault_handler_lr, uint32_t sp) { statck_has_fpu_regs = (fault_handler_lr & (1UL << 4)) == 0 ? 1 : 0; return statck_has_fpu_regs == 1 ? sp + sizeof(size_t) * 18 : sp; } # 616 "../../../Package/cm_backtrace/cm_backtrace.c" void cm_backtrace_fault(uint32_t fault_handler_lr, uint32_t fault_handler_sp) { uint32_t stack_pointer = fault_handler_sp, saved_regs_addr = stack_pointer, tcb_stack_pointer = 0; const char *regs_name[] = { "R0 ", "R1 ", "R2 ", "R3 ", "R12", "LR ", "PC ", "PSR" }; uint32_t stack_start_addr = main_stack_start_addr; size_t stack_size = main_stack_size; if (!(init_ok)) { MyPrintf("(%s) has assert failed at %s.", "init_ok", __FUNCTION__); while (1); }; if (!(!on_fault)) { MyPrintf("(%s) has assert failed at %s.", "!on_fault", __FUNCTION__); while (1); }; on_fault = 1; MyPrintf(""); cm_backtrace_firmware_info(); # 650 "../../../Package/cm_backtrace/cm_backtrace.c" MyPrintf(print_info[PRINT_FAULT_ON_HANDLER]); stack_pointer += sizeof(size_t) * 8; stack_pointer = statck_del_fpu_regs(fault_handler_lr, stack_pointer); if (stack_pointer < stack_start_addr || stack_pointer > stack_start_addr + stack_size) { MyPrintf("stack_pointer: 0x%08x, stack_start_addr: 0x%08x, stack_end_addr: 0x%08x", stack_pointer, stack_start_addr, stack_start_addr + stack_size); stack_is_overflow = 1; if (on_thread_before_fault) { stack_pointer = tcb_stack_pointer; } } dump_stack(stack_start_addr, stack_size, (uint32_t *) stack_pointer); { MyPrintf(print_info[PRINT_REGS_TITLE]); regs.saved.r0 = ((uint32_t *)saved_regs_addr)[0]; regs.saved.r1 = ((uint32_t *)saved_regs_addr)[1]; regs.saved.r2 = ((uint32_t *)saved_regs_addr)[2]; regs.saved.r3 = ((uint32_t *)saved_regs_addr)[3]; regs.saved.r12 = ((uint32_t *)saved_regs_addr)[4]; regs.saved.lr = ((uint32_t *)saved_regs_addr)[5]; regs.saved.pc = ((uint32_t *)saved_regs_addr)[6]; regs.saved.psr.value = ((uint32_t *)saved_regs_addr)[7]; MyPrintf(" %s: %08x %s: %08x %s: %08x %s: %08x", regs_name[0], regs.saved.r0, regs_name[1], regs.saved.r1, regs_name[2], regs.saved.r2, regs_name[3], regs.saved.r3); MyPrintf(" %s: %08x %s: %08x %s: %08x %s: %08x", regs_name[4], regs.saved.r12, regs_name[5], regs.saved.lr, regs_name[6], regs.saved.pc, regs_name[7], regs.saved.psr.value); MyPrintf("=============================================================="); } regs.syshndctrl.value = (*(volatile unsigned int*) (0xE000ED24u)); regs.mfsr.value = (*(volatile unsigned char*) (0xE000ED28u)); regs.mmar = (*(volatile unsigned int*) (0xE000ED34u)); regs.bfsr.value = (*(volatile unsigned char*) (0xE000ED29u)); regs.bfar = (*(volatile unsigned int*) (0xE000ED38u)); regs.ufsr.value = (*(volatile unsigned short*)(0xE000ED2Au)); regs.hfsr.value = (*(volatile unsigned int*) (0xE000ED2Cu)); regs.dfsr.value = (*(volatile unsigned short*)(0xE000ED30u)); regs.afsr = (*(volatile unsigned short*)(0xE000ED3Cu)); fault_diagnosis(); print_call_stack(stack_pointer); }