diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/chthreads.c | 13 | ||||
| -rw-r--r-- | src/include/debug.h | 17 | 
2 files changed, 23 insertions, 7 deletions
| diff --git a/src/chthreads.c b/src/chthreads.c index d32f9d44a..902867a41 100644 --- a/src/chthreads.c +++ b/src/chthreads.c @@ -59,10 +59,10 @@ Thread *init_thread(Thread *tp, tprio_t prio) {  }  #if CH_DBG_FILL_THREADS -static void memfill(uint8_t *p, uint32_t n, uint8_t v) { +static void memfill(uint8_t *startp, uint8_t *endp, uint8_t v) { -  while (n) -    *p++ = v, n--; +  while (startp < endp) +    *startp++ = v;  }  #endif @@ -95,7 +95,12 @@ Thread *chThdInit(void *workspace, size_t wsize,               (prio <= HIGHPRIO) && (pf != NULL),               "chThdInit");  #if CH_DBG_FILL_THREADS -  memfill(workspace, wsize, MEM_FILL_PATTERN); +  memfill(workspace, +		  (uint8_t)workspace + sizeof(Thread), +		  THREAD_FILL_VALUE); +  memfill((uint8_t)workspace + sizeof(Thread), +		  (uint8_t)workspace + wsize +		  STACK_FILL_VALUE);  #endif    SETUP_CONTEXT(workspace, wsize, pf, arg);    return init_thread(tp, prio); diff --git a/src/include/debug.h b/src/include/debug.h index 2efc6a8c7..82e784040 100644 --- a/src/include/debug.h +++ b/src/include/debug.h @@ -35,10 +35,21 @@  #endif
  /**
 - * @brief Fill value for threads working area in debug mode.
 + * @brief Fill value for thread stack area in debug mode.
   */
 -#ifndef MEM_FILL_PATTERN
 -#define MEM_FILL_PATTERN 0x55
 +#ifndef STACK_FILL_VALUE
 +#define STACK_FILL_VALUE 0x55
 +#endif
 +
 +/**
 + * @brief Fill value for thread area in debug mode.
 + * @note The chosen default value is 0xFF in order to make evident which
 + *       thread fields were not initialized when inspecting the memory with
 + *       a debugger. A uninitialized field is not an error in itself but it
 + *       better to know it.
 + */
 +#ifndef THREAD_FILL_VALUE
 +#define THREAD_FILL_VALUE 0xFF
  #endif
  /**
 | 
