summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
authorAidan MacDonald <amachronic@protonmail.com>2022-05-16 14:33:26 +0100
committerAidan MacDonald <amachronic@protonmail.com>2022-05-22 07:16:11 -0400
commit981e9728390b401404c36241e2ce6bd4cfcb723d (patch)
treeb68a7eaf7bf53dcd0dea8b29324c1e303bbb48f7 /firmware
parentcade488b089667f1252220d6b613c6795f960852 (diff)
downloadrockbox-981e9728390b401404c36241e2ce6bd4cfcb723d.tar.gz
rockbox-981e9728390b401404c36241e2ce6bd4cfcb723d.zip
mips: add native backtrace implementation
Should make debugging crashes on native MIPS targets far easier. This is by no means a 100% complete or robust implementation but it seems to handle the vast majority of functions. Change-Id: Id5f430270e02b5092b79026b6876675c784aa649
Diffstat (limited to 'firmware')
-rw-r--r--firmware/export/backtrace.h3
-rw-r--r--firmware/export/system.h3
-rw-r--r--firmware/panic.c10
3 files changed, 13 insertions, 3 deletions
diff --git a/firmware/export/backtrace.h b/firmware/export/backtrace.h
index 283e293b2a..fb007ab004 100644
--- a/firmware/export/backtrace.h
+++ b/firmware/export/backtrace.h
@@ -25,6 +25,9 @@
25#ifdef BACKTRACE_UNWARMINDER 25#ifdef BACKTRACE_UNWARMINDER
26#include "backtrace-unwarminder.h" 26#include "backtrace-unwarminder.h"
27#endif 27#endif
28#ifdef BACKTRACE_MIPSUNWINDER
29#include "backtrace-mipsunwinder.h"
30#endif
28 31
29/* Print a backtrace using lcd_* functions, starting at the given line and updating 32/* Print a backtrace using lcd_* functions, starting at the given line and updating
30 * the line number. On targets that support it (typically native targets), the 33 * the line number. On targets that support it (typically native targets), the
diff --git a/firmware/export/system.h b/firmware/export/system.h
index 9558be559a..def3122205 100644
--- a/firmware/export/system.h
+++ b/firmware/export/system.h
@@ -258,7 +258,8 @@ static inline void cpu_boost_unlock(void)
258#endif 258#endif
259 259
260/* Define this if target has support for generating backtraces */ 260/* Define this if target has support for generating backtraces */
261#ifdef CPU_ARM 261#if defined(CPU_ARM) || \
262 (defined(CPU_MIPS) && (CONFIG_PLATFORM & PLATFORM_NATIVE))
262 #define HAVE_RB_BACKTRACE 263 #define HAVE_RB_BACKTRACE
263#endif 264#endif
264 265
diff --git a/firmware/panic.c b/firmware/panic.c
index fcfa8b2bb8..586ecb6e0a 100644
--- a/firmware/panic.c
+++ b/firmware/panic.c
@@ -32,9 +32,9 @@
32#include "system.h" 32#include "system.h"
33#include "logf.h" 33#include "logf.h"
34 34
35#if defined(CPU_ARM) 35#ifdef HAVE_RB_BACKTRACE
36#include "gcc_extensions.h" 36#include "gcc_extensions.h"
37#include <backtrace.h> 37#include "backtrace.h"
38#endif 38#endif
39 39
40static char panic_buf[128]; 40static char panic_buf[128];
@@ -65,6 +65,12 @@ void panicf_f( const char *fmt, ...)
65 ); 65 );
66 66
67 int pc = (int)__builtin_return_address(0); 67 int pc = (int)__builtin_return_address(0);
68#elif defined(BACKTRACE_MIPSUNWINDER)
69void panicf( const char *fmt, ... )
70{
71 /* NOTE: these are obtained by the backtrace lib */
72 const int pc = 0;
73 const int sp = 0;
68#else 74#else
69void panicf( const char *fmt, ...) 75void panicf( const char *fmt, ...)
70{ 76{