summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2020-06-02 16:24:53 +1000
committerDamien George <damien.p.george@gmail.com>2020-06-05 20:52:10 +1000
commit596fb73927df4f9202729ff9d92a1db479a95ed7 (patch)
treef7f7df7e9cbe138003399597b81d34410c82aa89
parent834b482e67ebb1b9ad250d62ddfa1275824a7e19 (diff)
qemu-arm: Support building in debug mode with DEBUG=1.
Fixes issue #6095.
-rw-r--r--ports/qemu-arm/Makefile4
-rw-r--r--ports/qemu-arm/startup.c9
2 files changed, 11 insertions, 2 deletions
diff --git a/ports/qemu-arm/Makefile b/ports/qemu-arm/Makefile
index 430740ccf..e7b6523f8 100644
--- a/ports/qemu-arm/Makefile
+++ b/ports/qemu-arm/Makefile
@@ -43,9 +43,9 @@ INC += -I$(BUILD)
CFLAGS += $(INC) -Wall -Wpointer-arith -Wdouble-promotion -Wfloat-conversion -Werror -std=gnu99 $(COPT) \
-ffunction-sections -fdata-sections
-#Debugging/Optimization
+# Debugging/Optimization
ifeq ($(DEBUG), 1)
-CFLAGS += -g -DPENDSV_DEBUG
+CFLAGS += -g
COPT = -O0
else
COPT += -Os -DNDEBUG
diff --git a/ports/qemu-arm/startup.c b/ports/qemu-arm/startup.c
index 002d5ef62..58bdf7af9 100644
--- a/ports/qemu-arm/startup.c
+++ b/ports/qemu-arm/startup.c
@@ -1,4 +1,5 @@
#include <stdint.h>
+#include <stdio.h>
#include <stdlib.h>
#include "uart.h"
@@ -73,6 +74,14 @@ __attribute__((naked)) void exit(int status) {
}
}
+#ifndef NDEBUG
+void __assert_func(const char *file, int line, const char *func, const char *expr) {
+ (void)func;
+ printf("Assertion '%s' failed, at file %s:%d\n", expr, file, line);
+ exit(1);
+}
+#endif
+
// The following are needed for tinytest
#include <stdio.h>