8000 Updated printing in heap.cpp to behave the way os_printf did. · esp8266/Arduino@5ded134 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5ded134

Browse files
committed
Updated printing in heap.cpp to behave the way os_printf did.
Updated printing in heap.cpp to behave the way os_printf would have with regards to system_set_os_print. ie. setDebugOutput enable/disables printing Expanded #ifdef fenceing of .c files to prevent Arduino IDE from building them outside of the .cpp file they are included in. Corrected more conditional building issues. Remaining concern - umm_info(0, true) printing - does it need an ISR safe method, all printing is done from within a critical sectionn with rsil(15)? Or should be have the print option disabled for non-debug builds. ie. Debug port: "Disabled"
1 parent 79fe67f commit 5ded134

File tree

8 files changed

+32
-20
lines changed

8 files changed

+32
-20
lines changed

cores/esp8266/heap.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,14 @@ static const char oom_fmt_2[] PROGMEM STORE_ATTR = ":%d\n";
128128

129129
void ICACHE_RAM_ATTR print_loc(size_t size, const char* file, int line)
130130
{
131+
if (system_get_os_print()) {
131132
DBGLOG_FUNCTION_P(oom_fmt_1, (int)size);
132133
DBGLOG_FUNCTION_P(file);
133134
DBGLOG_FUNCTION_P(oom_fmt_2, line);
135+
}
134136
}
135137

136-
#define OOM_CHECK__PRINT_OOM(p, f, s) if (!p) DBGLOG_FUNCTION_P(f, s)
138+
#define OOM_CHECK__PRINT_OOM(p, f, s) if (!p && system_get_os_print()) DBGLOG_FUNCTION_P(f, s)
137139
#define OOM_CHECK__PRINT_LOC(p, s, f, l) if (!p) print_loc(s, f, l)
138140

139141
#else // ! DEBUG_ESP_OOM

cores/esp8266/umm_malloc/isr_safe_printf.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,7 @@
6464

6565
extern "C" {
6666

67-
//C This #if 1 changes once the best print option from ISR is determined.
68-
#if 1
67+
#if defined(DEBUG_ESP_PORT) || defined(DEBUG_ESP_OOM) || defined(UMM_POISON_CHECK) || defined(UMM_POISON_CHECK_LITE)
6968

7069
int _isr_safe_printf_P(const char *fmt, ...) __attribute__((format(printf, 1, 2)));
7170
// Note, _isr_safe_printf_P will not handle additional string arguments in

cores/esp8266/umm_malloc/umm_info.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#if defined(BUILD_UMM_MALLOC_C)
12
#ifdef UMM_INFO
23

34
/* ----------------------------------------------------------------------------
@@ -203,3 +204,4 @@ size_t umm_free_heap_size_lw( void ) {
203204
return (size_t)ummStats.free_blocks * sizeof(umm_block);
204205
}
205206
#endif
207+
#endif

cores/esp8266/umm_malloc/umm_integrity.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* integrity check (UMM_INTEGRITY_CHECK) {{{ */
2-
#if defined(UMM_INTEGRITY_CHECK)
2+
#if defined(UMM_INTEGRITY_CHECK) && defined(BUILD_UMM_MALLOC_C)
33
/*
44
* Perform integrity check of the whole heap data. Returns 1 in case of
55
* success, 0 otherwise.

cores/esp8266/umm_malloc/umm_local.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
* Local Additions/Enhancements
33
*
44
*/
5+
#if defined(BUILD_UMM_MALLOC_C)
6+
57
#if defined(UMM_CRITICAL_METRICS)
68
/*
79
* umm_malloc performance measurments for critical sections
@@ -154,3 +156,5 @@ size_t xPortGetFreeHeapSize(void) __attribute__ ((alias("umm_free_heap_size_lw")
154156
size_t umm_free_heap_size( void ) __attribute__ ((alias("umm_free_heap_size_info")));
155157
size_t xPortGetFreeHeapSize(void) __attribute__ ((alias("umm_free_heap_size_info")));
156158
#endif
159+
160+
#endif

cores/esp8266/umm_malloc/umm_malloc.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,9 @@
129129
/*
130130
* Added for using with Arduino ESP8266 and handling renameing to umm_malloc.cpp
131131
*/
132+
133+
#define BUILD_UMM_MALLOC_C
134+
132135
extern "C" {
133136

134137
#include <stdio.h>

cores/esp8266/umm_malloc/umm_malloc_cfg.h

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -55,22 +55,6 @@ extern "C" {
5555
* ----------------------------------------------------------------------------
5656
*/
5757

58-
/////////////////////////////////////////////////
59-
#undef DBGLOG_FUNCTION
60-
#undef DBGLOG_FUNCTION_P
61-
62-
//C This #if 1 changes once the best print option from ISR is determined
63-
#if 1
64-
int _isr_safe_printf_P(const char *fmt, ...) __attribute__((format(printf, 1, 2)));
65-
// Note, _isr_safe_printf_P will not handle additional string arguments in
66-
// PROGMEM. Only the 1st parameter, fmt, is supported in PROGMEM.
67-
#define DBGLOG_FUNCTION(fmt, ...) _isr_safe_printf_P(PSTR(fmt), ##__VA_ARGS__)
68-
#define DBGLOG_FUNCTION_P(fmt, ...) _isr_safe_printf_P(fmt, ##__VA_ARGS__)
69-
#else
70-
#define DBGLOG_FUNCTION(fmt, ...) printf(PSTR(fmt), ##__VA_ARGS__)
71-
#define DBGLOG_FUNCTION_P(fmt, ...) printf_P(fmt, ##__VA_ARGS__)
72-
#endif
73-
/////////////////////////////////////////////////
7458

7559
/* Start addresses and the size of the heap */
7660
extern char _heap_start[];
@@ -534,6 +518,22 @@ static inline void _critical_exit(UMM_TIME_STAT *p, uint32_t *saved_ps) {
534518
# define POISON_CHECK_NEIGHBORS(c) do{}while(false)
535519
#endif
536520

521+
/////////////////////////////////////////////////
522+
#undef DBGLOG_FUNCTION
523+
#undef DBGLOG_FUNCTION_P
524+
525+
#if defined(DEBUG_ESP_PORT) || defined(DEBUG_ESP_OOM) || defined(UMM_POISON_CHECK) || defined(UMM_POISON_CHECK_LITE)
526+
int _isr_safe_printf_P(const char *fmt, ...) __attribute__((format(printf, 1, 2)));
527+
// Note, _isr_safe_printf_P will not handle additional string arguments in
528+
// PROGMEM. Only the 1st parameter, fmt, is supported in PROGMEM.
529+
#define DBGLOG_FUNCTION(fmt, ...) _isr_safe_printf_P(PSTR(fmt), ##__VA_ARGS__)
530+
#define DBGLOG_FUNCTION_P(fmt, ...) _isr_safe_printf_P(fmt, ##__VA_ARGS__)
531+
#else
532+
#define DBGLOG_FUNCTION(fmt, ...) printf(PSTR(fmt), ##__VA_ARGS__)
533+
#define DBGLOG_FUNCTION_P(fmt, ...) printf_P(fmt, ##__VA_ARGS__)
534+
#endif
535+
536+
//C What about printing from umm_info - does it need to be ISR safe
537537

538538
/////////////////////////////////////////////////
539539

cores/esp8266/umm_malloc/umm_poison.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/* poisoning (UMM_POISON_CHECK) {{{ */
2+
#if defined(BUILD_UMM_MALLOC_C)
23
#if defined(UMM_POISON_CHECK) || defined(UMM_POISON_CHECK_LITE)
34
#define POISON_BYTE (0xa5)
45

@@ -235,3 +236,4 @@ int umm_poison_check(void) {
235236
/* ------------------------------------------------------------------------ */
236237

237238
#endif
239+
#endif

0 commit comments

Comments
 (0)
0