Catch dynamic de/allocations in ISRs.
authorAdam Green <adamgr@foo.bar>
Thu, 24 Jan 2013 14:18:04 +0000 (06:18 -0800)
committerAdam Green <adamgr@foo.bar>
Thu, 24 Jan 2013 14:18:04 +0000 (06:18 -0800)
gcc4mbed/src/gcc4mbed.c

index 37c2f2b..81d9484 100644 (file)
@@ -16,7 +16,7 @@
 /* Provide routines which hook the MRI debug monitor into GCC4MBED projects. */\r
 #include <string.h>\r
 #include <mri.h>\r
-\r
+#include <cmsis.h>\r
 \r
 extern unsigned int __bss_start__;\r
 extern unsigned int __bss_end__;\r
@@ -112,3 +112,14 @@ extern "C" int __aeabi_unwind_cpp_pr2(int state, void* controlBlock, void* conte
 {\r
     abort();\r
 }\r
+\r
+/* Trap calls to malloc/free/realloc in ISR. */\r
+extern "C" void __malloc_lock(void)\r
+{\r
+    if (__get_IPSR() != 0)\r
+        __debugbreak();\r
+}\r
+\r
+extern "C" void __malloc_unlock(void)\r
+{\r
+}\r