diff options
author | Amaury Pouly <amaury.pouly@gmail.com> | 2017-10-01 17:28:42 +0200 |
---|---|---|
committer | Amaury Pouly <amaury.pouly@gmail.com> | 2017-10-01 17:28:42 +0200 |
commit | 679ae2d21c17115c998b1ada6412463c3c7a1db9 (patch) | |
tree | 2123fef50489d7fe6db189d2684dd18c0659d343 /firmware/target/hosted/sonynwz/system-nwz.c | |
parent | a82ebac53a23867452a62e3bd6c2516679ac95d8 (diff) | |
download | rockbox-679ae2d21c17115c998b1ada6412463c3c7a1db9.tar.gz rockbox-679ae2d21c17115c998b1ada6412463c3c7a1db9.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
Diffstat (limited to 'firmware/target/hosted/sonynwz/system-nwz.c')
-rw-r--r-- | firmware/target/hosted/sonynwz/system-nwz.c | 30 |
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) | |||
90 | uintptr_t *stackbegin; | 90 | uintptr_t *stackbegin; |
91 | uintptr_t *stackend; | 91 | uintptr_t *stackend; |
92 | 92 | ||
93 | static void dump_proc_map(void) | ||
94 | { | ||
95 | const char *file = "/proc/self/maps"; | ||
96 | printf("Dumping %s...\n", file); | ||
97 | FILE *f = fopen(file, "r"); | ||
98 | if(f == NULL) | ||
99 | { | ||
100 | perror("Cannot open file"); | ||
101 | return; | ||
102 | } | ||
103 | while(true) | ||
104 | { | ||
105 | char *line = NULL; | ||
106 | size_t n; | ||
107 | if(getline(&line, &n, f) < 0) | ||
108 | break; | ||
109 | printf("> %s", line); | ||
110 | free(line); | ||
111 | } | ||
112 | fclose(f); | ||
113 | } | ||
114 | |||
93 | static void nwz_sig_handler(int sig, siginfo_t *siginfo, void *context) | 115 | static void nwz_sig_handler(int sig, siginfo_t *siginfo, void *context) |
94 | { | 116 | { |
95 | /* safe guard variable - we call backtrace() only on first | 117 | /* 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) | |||
98 | */ | 120 | */ |
99 | static bool triggered = false; | 121 | static bool triggered = false; |
100 | 122 | ||
123 | /* dump process maps to log file to ease debugging | ||
124 | * will also print crash info to the log */ | ||
125 | dump_proc_map(); | ||
126 | |||
101 | lcd_set_backdrop(NULL); | 127 | lcd_set_backdrop(NULL); |
102 | lcd_set_drawmode(DRMODE_SOLID); | 128 | lcd_set_drawmode(DRMODE_SOLID); |
103 | lcd_set_foreground(LCD_BLACK); | 129 | lcd_set_foreground(LCD_BLACK); |
@@ -113,10 +139,14 @@ static void nwz_sig_handler(int sig, siginfo_t *siginfo, void *context) | |||
113 | unsigned long pc = uc->uc_mcontext.arm_pc; | 139 | unsigned long pc = uc->uc_mcontext.arm_pc; |
114 | unsigned long sp = uc->uc_mcontext.arm_sp; | 140 | unsigned long sp = uc->uc_mcontext.arm_sp; |
115 | 141 | ||
142 | printf("%s at %08x\n", strsignal(sig), (unsigned int)pc); | ||
116 | lcd_putsf(0, line++, "%s at %08x", strsignal(sig), pc); | 143 | lcd_putsf(0, line++, "%s at %08x", strsignal(sig), pc); |
117 | 144 | ||
118 | if(sig == SIGILL || sig == SIGFPE || sig == SIGSEGV || sig == SIGBUS || sig == SIGTRAP) | 145 | if(sig == SIGILL || sig == SIGFPE || sig == SIGSEGV || sig == SIGBUS || sig == SIGTRAP) |
146 | { | ||
147 | printf("address 0x%08x\n", (unsigned int)siginfo->si_addr); | ||
119 | lcd_putsf(0, line++, "address 0x%08x", siginfo->si_addr); | 148 | lcd_putsf(0, line++, "address 0x%08x", siginfo->si_addr); |
149 | } | ||
120 | 150 | ||
121 | if(!triggered) | 151 | if(!triggered) |
122 | { | 152 | { |