From 9c2d77e216fc9da29978fddcb4b4bc43d241acca Mon Sep 17 00:00:00 2001 From: xross Date: Fri, 9 Sep 2022 11:21:03 +0100 Subject: [PATCH] Added example asserts to decouple --- lib_xua/module_build_info | 11 ++++++++++- lib_xua/src/core/buffer/decouple/decouple.xc | 7 +++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/lib_xua/module_build_info b/lib_xua/module_build_info index ae82693c..7d9f5ddd 100644 --- a/lib_xua/module_build_info +++ b/lib_xua/module_build_info @@ -1,5 +1,13 @@ VERSION = 3.2.0 +DEBUG ?= 0 + +ifeq ($(DEBUG),1) +DEBUG_FLAGS = -g -DXASSERT_ENABLE_ASSERTIONS_DECOUPLE=1 +else +DEBUG_FLAGS = -DXASSERT_DISABLE_ASSERTIONS_DECOUPLE=1 +endif + DEPENDENT_MODULES = lib_locks(>=2.1.0) \ lib_logging(>=3.1.1) \ lib_mic_array(>=4.5.0) \ @@ -11,7 +19,8 @@ MODULE_XCC_FLAGS = $(XCC_FLAGS) \ -O3 \ -DREF_CLK_FREQ=100 \ -fasm-linenum \ - -fcomment-asm + -fcomment-asm \ + $(DEBUG_FLAGS) # Core XCC_FLAGS_xua_endpoint0.c = $(MODULE_XCC_FLAGS) -Os -mno-dual-issue diff --git a/lib_xua/src/core/buffer/decouple/decouple.xc b/lib_xua/src/core/buffer/decouple/decouple.xc index 4248ea4d..4a4bcba5 100644 --- a/lib_xua/src/core/buffer/decouple/decouple.xc +++ b/lib_xua/src/core/buffer/decouple/decouple.xc @@ -2,6 +2,9 @@ // This Software is subject to the terms of the XMOS Public Licence: Version 1. #include "xua.h" +#define XASSERT_UNIT DECOUPLE +#include "xassert.h" + #if XUA_USB_EN #include #include "xc_ptr.h" @@ -503,6 +506,8 @@ __builtin_unreachable(); space_left = aud_to_host_fifo_end - g_aud_to_host_wrptr; } + assert(space_left > 0 && msg("space_left expected to be positive")); + if((space_left < (totalSampsToWrite * g_numUsbChan_In * (unsigned) g_curSubSlot_In + 4))) { /* In pipe has filled its buffer - we need to overflow @@ -538,6 +543,8 @@ __builtin_unreachable(); space_left += datalength; SET_SHARED_GLOBAL(g_aud_to_host_rdptr, rdPtr); + assert(rdPtr < aud_to_host_fifo_end && msg("rdPtr must be within buffer")); + } while(space_left < (BUFF_SIZE_IN - 2 * max_pkt_size)); }