summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmaury Pouly <amaury.pouly@gmail.com>2017-10-01 17:28:42 +0200
committerAmaury Pouly <amaury.pouly@gmail.com>2017-10-01 17:28:42 +0200
commit679ae2d21c17115c998b1ada6412463c3c7a1db9 (patch)
tree2123fef50489d7fe6db189d2684dd18c0659d343
parenta82ebac53a23867452a62e3bd6c2516679ac95d8 (diff)
downloadrockbox-679ae2d.tar.gz
rockbox-679ae2d.zip
sonynwzlinux: print debug info to log on crash
Print the crash info and dump the memory map from /proc/self/maps Change-Id: I99de32e5e6cca3bf1aca4fa253834ca4ad599fbe
-rw-r--r--firmware/target/hosted/sonynwz/system-nwz.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/firmware/target/hosted/sonynwz/system-nwz.c b/firmware/target/hosted/sonynwz/system-nwz.c
index 5ef660be8c..b20ee71774 100644
--- a/firmware/target/hosted/sonynwz/system-nwz.c
+++ b/firmware/target/hosted/sonynwz/system-nwz.c
@@ -90,6 +90,28 @@ static void print_kern_mod_list(void)
uintptr_t *stackbegin;
uintptr_t *stackend;
+static void dump_proc_map(void)
+{
+ const char *file = "/proc/self/maps";
+ printf("Dumping %s...\n", file);
+ FILE *f = fopen(file, "r");
+ if(f == NULL)
+ {
+ perror("Cannot open file");
+ return;
+ }
+ while(true)
+ {
+ char *line = NULL;
+ size_t n;
+ if(getline(&line, &n, f) < 0)
+ break;
+ printf("> %s", line);
+ free(line);
+ }
+ fclose(f);
+}
+
static void nwz_sig_handler(int sig, siginfo_t *siginfo, void *context)
{
/* safe guard variable - we call backtrace() only on first
@@ -98,6 +120,10 @@ static void nwz_sig_handler(int sig, siginfo_t *siginfo, void *context)
*/
static bool triggered = false;
+ /* dump process maps to log file to ease debugging
+ * will also print crash info to the log */
+ dump_proc_map();
+
lcd_set_backdrop(NULL);
lcd_set_drawmode(DRMODE_SOLID);
lcd_set_foreground(LCD_BLACK);
@@ -113,10 +139,14 @@ static void nwz_sig_handler(int sig, siginfo_t *siginfo, void *context)
unsigned long pc = uc->uc_mcontext.arm_pc;
unsigned long sp = uc->uc_mcontext.arm_sp;
+ printf("%s at %08x\n", strsignal(sig), (unsigned int)pc);
lcd_putsf(0, line++, "%s at %08x", strsignal(sig), pc);
if(sig == SIGILL || sig == SIGFPE || sig == SIGSEGV || sig == SIGBUS || sig == SIGTRAP)
+ {
+ printf("address 0x%08x\n", (unsigned int)siginfo->si_addr);
lcd_putsf(0, line++, "address 0x%08x", siginfo->si_addr);
+ }
if(!triggered)
{