From 8ff4f1aec9f19613e4f67d2e22ae96bec7657292 Mon Sep 17 00:00:00 2001 From: Frank Gevaerts Date: Sun, 26 Sep 2010 12:05:42 +0000 Subject: Add optional (define BUFFER_ALLOC_DEBUG to enable it) code to check for code overflowing buffer_alloc()-allocated buffers. Also add a panicf() if buffer_alloc() doesn't have enough space left to allocate a requested buffer git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28173 a1c6a512-1295-4272-9138-f99709370657 --- firmware/thread.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'firmware/thread.c') diff --git a/firmware/thread.c b/firmware/thread.c index b3d8ec3970..655af1a940 100644 --- a/firmware/thread.c +++ b/firmware/thread.c @@ -27,6 +27,7 @@ #include "kernel.h" #include "cpu.h" #include "string.h" +#include "buffer.h" #ifdef RB_PROFILE #include #endif @@ -1160,6 +1161,16 @@ void switch_thread(void) if (UNLIKELY(thread->stack[0] != DEADBEEF) && thread->stack_size > 0) thread_stkov(thread); +#ifdef BUFFER_ALLOC_DEBUG + /* Check if the current thread just did bad things with buffer_alloc()ed + * memory */ + { + static char name[32]; + thread_get_name(name, 32, thread); + buffer_alloc_check(name); + } +#endif + #if NUM_CORES > 1 /* Run any blocking operations requested before switching/sleeping */ run_blocking_ops(core, thread); -- cgit v1.2.3