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 2017/03/29 01:07:16 UTC
[13/17] incubator-mynewt-core git commit: sysinit - Allow panic
message.
sysinit - Allow panic message.
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/103f39e8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/103f39e8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/103f39e8
Branch: refs/heads/develop
Commit: 103f39e8004d3908b7c39d19b2a8b82ba9b1c714
Parents: e679687
Author: Christopher Collins <cc...@apache.org>
Authored: Tue Mar 7 15:09:58 2017 -0800
Committer: Christopher Collins <cc...@apache.org>
Committed: Tue Mar 28 16:58:41 2017 -0700
----------------------------------------------------------------------
hw/bsp/native/syscfg.yml | 5 +++++
sys/sysinit/include/sysinit/sysinit.h | 34 ++++++++++++++++++++++++------
sys/sysinit/src/sysinit.c | 17 ++++++++++++++-
sys/sysinit/syscfg.yml | 8 +++++++
4 files changed, 56 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/103f39e8/hw/bsp/native/syscfg.yml
----------------------------------------------------------------------
diff --git a/hw/bsp/native/syscfg.yml b/hw/bsp/native/syscfg.yml
index 9ca0608..2d91f9c 100644
--- a/hw/bsp/native/syscfg.yml
+++ b/hw/bsp/native/syscfg.yml
@@ -18,7 +18,12 @@
#
syscfg.vals:
+ # Sim isn't flash constrained, so include filename, line number, and
+ # message in asserts and sysinit panic messages.
BASELIBC_ASSERT_FILE_LINE: 1
+ SYSINIT_PANIC_FILE_LINE: 1
+ SYSINIT_PANIC_MESSAGE: 1
+
NFFS_FLASH_AREA: FLASH_AREA_NFFS
CONFIG_FCB_FLASH_AREA: FLASH_AREA_NFFS
REBOOT_LOG_FLASH_AREA: FLASH_AREA_REBOOT_LOG
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/103f39e8/sys/sysinit/include/sysinit/sysinit.h
----------------------------------------------------------------------
diff --git a/sys/sysinit/include/sysinit/sysinit.h b/sys/sysinit/include/sysinit/sysinit.h
index 32df52b..7694c42 100644
--- a/sys/sysinit/include/sysinit/sysinit.h
+++ b/sys/sysinit/include/sysinit/sysinit.h
@@ -38,21 +38,41 @@ void sysinit_start(void);
void sysinit_end(void);
typedef void sysinit_panic_fn(const char *file, int line, const char *func,
- const char *expr);
+ const char *expr, const char *msg);
extern sysinit_panic_fn *sysinit_panic_cb;
void sysinit_panic_set(sysinit_panic_fn *panic_fn);
-#define SYSINIT_PANIC() sysinit_panic_cb(NULL, 0, NULL, NULL)
+#if MYNEWT_VAL(SYSINIT_PANIC_MESSAGE)
-#define SYSINIT_PANIC_ASSERT(rc) do \
-{ \
- if (!(rc)) { \
- SYSINIT_PANIC(); \
- } \
+#if MYNEWT_VAL(SYSINIT_PANIC_FILE_LINE)
+#define SYSINIT_PANIC_MSG(msg) sysinit_panic_cb(__FILE__, __LINE__, 0, 0, msg)
+#else
+#define SYSINIT_PANIC_MSG(msg) sysinit_panic_cb(0, 0, 0, 0, msg)
+#endif
+
+#else
+
+#if MYNEWT_VAL(SYSINIT_PANIC_FILE_LINE)
+#define SYSINIT_PANIC_MSG(msg) sysinit_panic_cb(__FILE__, __LINE__, 0, 0, 0)
+#else
+#define SYSINIT_PANIC_MSG(msg) sysinit_panic_cb(0, 0, 0, 0, 0)
+#endif
+
+#endif
+
+#define SYSINIT_PANIC() SYSINIT_PANIC_MSG(NULL)
+
+#define SYSINIT_PANIC_ASSERT_MSG(rc, msg) do \
+{ \
+ if (!(rc)) { \
+ SYSINIT_PANIC_MSG(msg); \
+ } \
} while (0)
+#define SYSINIT_PANIC_ASSERT(rc) SYSINIT_PANIC_ASSERT_MSG(rc, NULL)
+
/**
* Asserts that system initialization is in progress. This macro is used to
* ensure packages don't get initialized a second time after system
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/103f39e8/sys/sysinit/src/sysinit.c
----------------------------------------------------------------------
diff --git a/sys/sysinit/src/sysinit.c b/sys/sysinit/src/sysinit.c
index 767032f..393d1c5 100644
--- a/sys/sysinit/src/sysinit.c
+++ b/sys/sysinit/src/sysinit.c
@@ -17,12 +17,27 @@
* under the License.
*/
+#include <stdio.h>
#include <stddef.h>
#include <limits.h>
#include "os/os_fault.h"
+#include "syscfg/syscfg.h"
#include "sysinit/sysinit.h"
-sysinit_panic_fn *sysinit_panic_cb = __assert_func;
+static void
+sysinit_dflt_panic_cb(const char *file, int line, const char *func,
+ const char *expr, const char *msg)
+{
+#if MYNEWT_VAL(SYSINIT_PANIC_MESSAGE)
+ if (msg != NULL) {
+ fprintf(stderr, "sysinit failure: %s\n", msg);
+ }
+#endif
+
+ __assert_func(file, line, func, expr);
+}
+
+sysinit_panic_fn *sysinit_panic_cb = sysinit_dflt_panic_cb;
uint8_t sysinit_active;
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/103f39e8/sys/sysinit/syscfg.yml
----------------------------------------------------------------------
diff --git a/sys/sysinit/syscfg.yml b/sys/sysinit/syscfg.yml
index 74dbc29..d6bac23 100644
--- a/sys/sysinit/syscfg.yml
+++ b/sys/sysinit/syscfg.yml
@@ -22,3 +22,11 @@ syscfg.defs:
SYSINIT_CONSTRAIN_INIT:
description: Only allow packages to be initialized by sysinit.
value: 1
+
+ SYSINIT_PANIC_FILE_LINE:
+ description: Include filename and line number in sysinit panic.
+ value: 0
+
+ SYSINIT_PANIC_MESSAGE:
+ description: Include descriptive message in sysinit panic.
+ value: 0