@@ -275,26 +275,42 @@ struct umm_last_fail_alloc {
275
275
// file names stored in PROGMEM. The PROGMEM address to the string is printed in
276
276
// its place.
277
277
#define DEBUG_HEAP_PRINTF ets_uart_printf
278
- static void IRAM_ATTR print_loc (size_t size, const char * file, int line, const void * caller)
279
- {
280
- if (system_get_os_print ()) {
281
- DEBUG_HEAP_PRINTF (" :oom(%d)@" , (int )size);
282
278
279
+ static ALWAYS_INLINE bool withinISR (uint32_t ps) {
280
+ return (0 != (ps & 0x0fu ));
281
+ }
282
+
283
+ #if 0
284
+ /*
285
+ ICACHE should be accessable from an ISR "IF" it has not been disabled for a
286
+ SPI bus transfer. TODO investagate further - `if (inISR && ! isCacheReady())`
287
+ */
288
+ #define SPIRDY ESP8266_DREG(0x0C) // CACHE_FLASH_CTRL_REG
289
+ #define CACHE_READ_EN_BIT BIT8 // eagle_soc.h in RTOS_SDK
290
+ static ALWAYS_INLINE bool isCacheReady(void) {
291
+ return 0 != (SPIRDY & CACHE_READ_EN_BIT);
292
+ }
293
+ #endif
294
+
295
+ static void IRAM_ATTR print_loc (bool inISR, size_t size, const char * file, int line, const void * caller) {
296
+ if (system_get_os_print ()) {
297
+ DEBUG_HEAP_PRINTF (" :oom %p(%d), File: " , caller, (int )size);
283
298
if (file) {
284
- bool inISR = ETS_INTR_WITHINISR ();
285
- if (inISR && (uint32_t )file >= 0x40200000 ) {
286
- DEBUG_HEAP_PRINTF (" %p, File: %p" , caller, file);
287
- } else if (!inISR && (uint32_t )file >= 0x40200000 ) {
288
- char buf[strlen_P (file) + 1 ];
289
- strcpy_P (buf, file);
290
- DEBUG_HEAP_PRINTF (" %p, File: %s" , caller, buf);
299
+ if ((uint32_t )file >= 0x40200000 ) {
300
+ if (inISR) {
301
+ DEBUG_HEAP_PRINTF (" %p" , file);
302
+ } else {
303
+ char buf[strlen_P (file) + 1 ];
304
+ strcpy_P (buf, file);
305
+ DEBUG_HEAP_PRINTF (buf);
306
+ }
291
307
} else {
292
308
DEBUG_HEAP_PRINTF (file);
293
309
}
294
- DEBUG_HEAP_PRINTF (" :%d\n " , line);
295
310
} else {
296
- DEBUG_HEAP_PRINTF (" %p \n " , caller );
311
+ DEBUG_HEAP_PRINTF (" ?? " );
297
312
}
313
+ DEBUG_HEAP_PRINTF (" :%d\n " , line);
298
314
}
299
315
}
300
316
@@ -308,7 +324,7 @@ static bool IRAM_ATTR oom_check__log_last_fail_atomic_psflc(void *ptr, size_t si
308
324
_umm_last_fail_alloc.size = size;
309
325
_umm_last_fail_alloc.file = file;
310
326
_umm_last_fail_alloc.line = line;
311
- print_loc (size, file, line, caller);
327
+ print_loc (withinISR (saved_ps), size, file, line, caller);
312
328
xt_wsr_ps (saved_ps);
313
329
_HEAP_DEBUG_PROBE_PSFLC_CB (heap_oom_cb_id, ptr, size, file, line, caller);
314
330
return false ;
0 commit comments