summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam Wilgus <wilgus.william@gmail.com>2021-09-28 23:42:33 -0400
committerWilliam Wilgus <me.theuser@yahoo.com>2021-09-30 21:13:22 -0400
commit95b10ac74e7a996b9b1ce7ce88c205e39b67502b (patch)
tree111391688167f6dd7abd46610bc05e4e5bc8a6de
parent5883cb4a5254048d59a2d600b5f63b8d1c06d306 (diff)
downloadrockbox-95b10ac74e7a996b9b1ce7ce88c205e39b67502b.tar.gz
rockbox-95b10ac74e7a996b9b1ce7ce88c205e39b67502b.zip
Add ability to dump cpu boost log to disk, include thread names
0.) B 0 /rockbox/apps/main.c:405 1.) B 1 /rockbox/firmware/kernel/thread.c thread[dircache]:1508 2.) B 2 /rockbox/apps/tagcache.c:4772 3.) U 3 /rockbox/apps/tagcache.c:4793 add logic to show count after log rolls over clean-up Change-Id: Ibda0a56e5d8d89aa8b7649f4f9fa64eb1ff0e08f
-rw-r--r--apps/debug_menu.c48
-rw-r--r--firmware/kernel/thread.c7
-rw-r--r--firmware/system.c6
3 files changed, 58 insertions, 3 deletions
diff --git a/apps/debug_menu.c b/apps/debug_menu.c
index 800e485ce3..33970da581 100644
--- a/apps/debug_menu.c
+++ b/apps/debug_menu.c
@@ -2242,6 +2242,51 @@ static bool cpu_boost_log(void)
2242 lcd_setfont(FONT_UI); 2242 lcd_setfont(FONT_UI);
2243 return false; 2243 return false;
2244} 2244}
2245
2246static bool cpu_boost_log_dump(void)
2247{
2248 int fd;
2249#if CONFIG_RTC
2250 struct tm *nowtm;
2251 char fname[MAX_PATH];
2252#endif
2253
2254 int count = cpu_boost_log_getcount();
2255 char *str = cpu_boost_log_getlog_first();
2256
2257 splashf(HZ, "Boost Log File Dumped");
2258
2259 /* nothing to print ? */
2260 if(count == 0)
2261 return false;
2262
2263#if CONFIG_RTC
2264 nowtm = get_time();
2265 snprintf(fname, MAX_PATH, "%s/boostlog_%04d%02d%02d%02d%02d%02d.txt", ROCKBOX_DIR,
2266 nowtm->tm_year + 1900, nowtm->tm_mon + 1, nowtm->tm_mday,
2267 nowtm->tm_hour, nowtm->tm_min, nowtm->tm_sec);
2268 fd = open(fname, O_CREAT|O_WRONLY|O_TRUNC);
2269#else
2270 fd = open(ROCKBOX_DIR "/boostlog.txt", O_CREAT|O_WRONLY|O_TRUNC, 0666);
2271#endif
2272 if(-1 != fd) {
2273 for (int i = 0; i < count; i++)
2274 {
2275 if (!str)
2276 str = cpu_boost_log_getlog_next();
2277 if (str)
2278 {
2279 fdprintf(fd, "%s\n", str);
2280 str = NULL;
2281 }
2282 }
2283
2284 close(fd);
2285 return true;
2286 }
2287
2288 return false;
2289}
2245#endif 2290#endif
2246 2291
2247#if (defined(HAVE_WHEEL_ACCELERATION) && (CONFIG_KEYPAD==IPOD_4G_PAD) \ 2292#if (defined(HAVE_WHEEL_ACCELERATION) && (CONFIG_KEYPAD==IPOD_4G_PAD) \
@@ -2604,7 +2649,8 @@ static const struct {
2604#endif 2649#endif
2605#endif /* HAVE_USBSTACK */ 2650#endif /* HAVE_USBSTACK */
2606#ifdef CPU_BOOST_LOGGING 2651#ifdef CPU_BOOST_LOGGING
2607 {"cpu_boost log",cpu_boost_log}, 2652 {"Show cpu_boost log",cpu_boost_log},
2653 {"Dump cpu_boost log",cpu_boost_log_dump},
2608#endif 2654#endif
2609#if (defined(HAVE_WHEEL_ACCELERATION) && (CONFIG_KEYPAD==IPOD_4G_PAD) \ 2655#if (defined(HAVE_WHEEL_ACCELERATION) && (CONFIG_KEYPAD==IPOD_4G_PAD) \
2610 && !defined(IPOD_MINI) && !defined(SIMULATOR)) 2656 && !defined(IPOD_MINI) && !defined(SIMULATOR))
diff --git a/firmware/kernel/thread.c b/firmware/kernel/thread.c
index 307be7116a..a422624df7 100644
--- a/firmware/kernel/thread.c
+++ b/firmware/kernel/thread.c
@@ -1501,7 +1501,14 @@ static inline void boost_thread(struct thread_entry *thread, bool boost)
1501 if ((thread->cpu_boost != 0) != boost) 1501 if ((thread->cpu_boost != 0) != boost)
1502 { 1502 {
1503 thread->cpu_boost = boost; 1503 thread->cpu_boost = boost;
1504#ifdef CPU_BOOST_LOGGING
1505 const char fmt[] = __FILE__" thread[%s]";
1506 char pathbuf[sizeof(fmt) + 32]; /* thread name 32 */
1507 snprintf(pathbuf, sizeof(pathbuf), fmt, thread->name);
1508 cpu_boost_(boost, pathbuf, __LINE__);
1509#else
1504 cpu_boost(boost); 1510 cpu_boost(boost);
1511#endif
1505 } 1512 }
1506} 1513}
1507 1514
diff --git a/firmware/system.c b/firmware/system.c
index 537e901b05..e2fdff0e59 100644
--- a/firmware/system.c
+++ b/firmware/system.c
@@ -89,6 +89,7 @@ char * cpu_boost_log_getlog_next(void)
89 89
90void cpu_boost_(bool on_off, char* location, int line) 90void cpu_boost_(bool on_off, char* location, int line)
91{ 91{
92 int item = cpu_boost_calls_count;
92 if (!cpu_boost_lock()) 93 if (!cpu_boost_lock())
93 return; 94 return;
94 95
@@ -98,12 +99,13 @@ void cpu_boost_(bool on_off, char* location, int line)
98 cpu_boost_calls_count--; 99 cpu_boost_calls_count--;
99 if (cpu_boost_calls_count < 0) 100 if (cpu_boost_calls_count < 0)
100 cpu_boost_calls_count = 0; 101 cpu_boost_calls_count = 0;
102 item += cpu_boost_first;
101 } 103 }
102 if (cpu_boost_calls_count < MAX_BOOST_LOG) 104 if (cpu_boost_calls_count < MAX_BOOST_LOG)
103 { 105 {
104 int message = (cpu_boost_first+cpu_boost_calls_count)%MAX_BOOST_LOG; 106 int message = (cpu_boost_first+cpu_boost_calls_count)%MAX_BOOST_LOG;
105 snprintf(cpu_boost_calls[message], MAX_PATH, 107 snprintf(cpu_boost_calls[message], MAX_PATH,"%d.) %c %d %s:%d",
106 "%c %s:%d",on_off?'B':'U',location,line); 108 item,on_off?'B':'U',boost_counter,location,line);
107 cpu_boost_calls_count++; 109 cpu_boost_calls_count++;
108 } 110 }
109#else 111#else