This is an automated email from the ASF dual-hosted git repository.

jerzy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git

commit d6718428c979b63a6e89b2663ccfe9436e69907d
Author: Jerzy Kasenberg <[email protected]>
AuthorDate: Fri May 10 14:57:04 2019 +0200

    os_fault: Break into debugger before fault handler is executed
    
    Change allows to stop execution at asserting line instead of
    inside __assert_func().
    This small change makes it easier to debug code.
    When debugger is not connected normal call to __assert_func() is done.
    User provided hook can be executed before debugger stop execution.
---
 kernel/os/include/os/os_fault.h       | 7 +++++--
 sys/sysinit/include/sysinit/sysinit.h | 1 +
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/kernel/os/include/os/os_fault.h b/kernel/os/include/os/os_fault.h
index 1a3c6f5..e830e7a 100644
--- a/kernel/os/include/os/os_fault.h
+++ b/kernel/os/include/os/os_fault.h
@@ -21,6 +21,9 @@
 #define _OS_FAULT_H
 
 #include "syscfg/syscfg.h"
+#include "os/os_arch.h"
+#include "hal/hal_system.h"
+#include "hal/hal_debug.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -30,9 +33,9 @@ void __assert_func(const char *file, int line, const char 
*func, const char *e)
     __attribute((noreturn));
 
 #if MYNEWT_VAL(OS_CRASH_FILE_LINE)
-#define OS_CRASH() __assert_func(__FILE__, __LINE__, NULL, NULL)
+#define OS_CRASH() (HAL_DEBUG_BREAK(), __assert_func(__FILE__, __LINE__, NULL, 
NULL))
 #else
-#define OS_CRASH() __assert_func(NULL, 0, NULL, NULL)
+#define OS_CRASH() (HAL_DEBUG_BREAK(), __assert_func(NULL, 0, NULL, NULL))
 #endif
 
 #ifdef __cplusplus
diff --git a/sys/sysinit/include/sysinit/sysinit.h 
b/sys/sysinit/include/sysinit/sysinit.h
index 7694c42..d30cb57 100644
--- a/sys/sysinit/include/sysinit/sysinit.h
+++ b/sys/sysinit/include/sysinit/sysinit.h
@@ -67,6 +67,7 @@ void sysinit_panic_set(sysinit_panic_fn *panic_fn);
 #define SYSINIT_PANIC_ASSERT_MSG(rc, msg) do \
 {                                            \
     if (!(rc)) {                             \
+        HAL_DEBUG_BREAK();                   \
         SYSINIT_PANIC_MSG(msg);              \
     }                                        \
 } while (0)

Reply via email to