From 2de3781ebfeda856b4e3706296dd490be88963b6 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Tue, 24 Sep 2013 13:47:03 -0600 Subject: [PATCH] Slightly improved debug output --- arch/arm/src/armv7-a/arm_assert.c | 14 ++++++++++++-- arch/arm/src/sama5/sam_udphs.c | 8 +++++--- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/arch/arm/src/armv7-a/arm_assert.c b/arch/arm/src/armv7-a/arm_assert.c index b5f959016e..eab0e3252d 100644 --- a/arch/arm/src/armv7-a/arm_assert.c +++ b/arch/arm/src/armv7-a/arm_assert.c @@ -200,6 +200,13 @@ static void up_dumpstate(void) * stack? */ + if (sp > istackbase || sp <= istackbase - istacksize) + { + if (up_interrupt_context()) + { + lldbg("ERROR: Stack pointer is not within interrupt stack\n"); + } + } if (sp <= istackbase && sp > istackbase - istacksize) { /* Yes.. dump the interrupt stack */ @@ -231,9 +238,12 @@ static void up_dumpstate(void) if (sp > ustackbase || sp <= ustackbase - ustacksize) { -#if !defined(CONFIG_ARCH_INTERRUPTSTACK) || CONFIG_ARCH_INTERRUPTSTACK < 4 - lldbg("ERROR: Stack pointer is not within allocated stack\n"); +#if defined(CONFIG_ARCH_INTERRUPTSTACK) && CONFIG_ARCH_INTERRUPTSTACK > 3 + if (!up_interrupt_context()) #endif + { + lldbg("ERROR: Stack pointer is not within allocated stack\n"); + } } else { diff --git a/arch/arm/src/sama5/sam_udphs.c b/arch/arm/src/sama5/sam_udphs.c index 16a214168d..501f3cbc93 100644 --- a/arch/arm/src/sama5/sam_udphs.c +++ b/arch/arm/src/sama5/sam_udphs.c @@ -956,7 +956,8 @@ static void sam_dma_wrsetup(struct sam_usbdev_s *priv, struct sam_ep_s *privep, /* How many bytes remain to be transferred in the request? */ - remaining = privreq->req.len - privreq->req.xfrd; + remaining = (int)privreq->req.len - (int)privreq->req.xfrd; + DEBUGASSERT(remaining >= 0 && remaining <= (int)privreq->req.len); /* If there are no bytes to send, then send a zero length packet */ @@ -1020,8 +1021,9 @@ static void sam_dma_rdsetup(struct sam_usbdev_s *priv, /* How many more bytes can we append to the request buffer? */ - remaining = privreq->req.len - privreq->req.xfrd; - DEBUGASSERT(remaining > 0 && privep->epstate == UDPHS_EPSTATE_RECEIVING); + remaining = (int)privreq->req.len - (int)privreq->req.xfrd; + DEBUGASSERT(remaining > 0 && remaining <= (int)privreq->req.len && + privep->epstate == UDPHS_EPSTATE_RECEIVING); /* Clip the DMA transfer size to the size available in the user buffer */