From 679ae2d21c17115c998b1ada6412463c3c7a1db9 Mon Sep 17 00:00:00 2001 From: Amaury Pouly Date: Sun, 1 Oct 2017 17:28:42 +0200 Subject: sonynwzlinux: print debug info to log on crash Print the crash info and dump the memory map from /proc/self/maps Change-Id: I99de32e5e6cca3bf1aca4fa253834ca4ad599fbe --- firmware/target/hosted/sonynwz/system-nwz.c | 30 +++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'firmware') 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) { -- cgit v1.2.3