You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by cc...@apache.org on 2016/06/06 11:04:47 UTC

[4/9] incubator-mynewt-core git commit: Preserve stack on assert failue when debugging.

Preserve stack on assert failue when debugging.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/3d92d5ed
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/3d92d5ed
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/3d92d5ed

Branch: refs/heads/upf54
Commit: 3d92d5ed1fb09b0783b454a3adb0c68516725f8a
Parents: f77f979
Author: Christopher Collins <cc...@apache.org>
Authored: Mon Jun 6 18:25:59 2016 +0800
Committer: Christopher Collins <cc...@apache.org>
Committed: Mon Jun 6 18:25:59 2016 +0800

----------------------------------------------------------------------
 libs/os/src/arch/cortex_m4/os_fault.c | 6 ++++++
 1 file changed, 6 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/3d92d5ed/libs/os/src/arch/cortex_m4/os_fault.c
----------------------------------------------------------------------
diff --git a/libs/os/src/arch/cortex_m4/os_fault.c b/libs/os/src/arch/cortex_m4/os_fault.c
index 9bc1db4..3a33f7a 100644
--- a/libs/os/src/arch/cortex_m4/os_fault.c
+++ b/libs/os/src/arch/cortex_m4/os_fault.c
@@ -118,6 +118,12 @@ __assert_func(const char *file, int line, const char *func, const char *e)
     (void)sr;
     console_blocking_mode();
     console_printf("Assert %s; failed in %s:%d\n", e ? e : "", file, line);
+    if (CoreDebug->DHCSR & CoreDebug_DHCSR_C_DEBUGEN_Msk) {
+        /*
+         * If debugger is attached, breakpoint here.
+         */
+        asm("bkpt");
+    }
     SCB->ICSR = SCB_ICSR_NMIPENDSET_Msk;
     asm("isb");
     system_reset();