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 2018/10/23 17:48:32 UTC

[mynewt-core] 02/02: sys/sys: Add `DEBUG_PANIC()` macro

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

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

commit decc2561fe73e6eabfae2893d8fb722fb25a033c
Author: Christopher Collins <cc...@apache.org>
AuthorDate: Fri Oct 19 10:32:55 2018 -0700

    sys/sys: Add `DEBUG_PANIC()` macro
    
    The `DEBUG_PANIC()` macro triggers a crash if the `DEBUG_PANIC_ENABLED`
    syscfg setting is enabled.  If this setting is disabled, the macro
    expands to nothing.
---
 kernel/os/include/os/mynewt.h                      |  1 +
 .../mynewt.h => sys/sys/include/sys/debug_panic.h  | 16 ++++++++-------
 sys/sys/syscfg.yml                                 | 23 ++++++++++++++++++++++
 3 files changed, 33 insertions(+), 7 deletions(-)

diff --git a/kernel/os/include/os/mynewt.h b/kernel/os/include/os/mynewt.h
index 3f6943e..ca544ee 100644
--- a/kernel/os/include/os/mynewt.h
+++ b/kernel/os/include/os/mynewt.h
@@ -25,5 +25,6 @@
 #include "sysflash/sysflash.h"
 #include "os/os.h"
 #include "defs/error.h"
+#include "sys/debug_panic.h"
 
 #endif
diff --git a/kernel/os/include/os/mynewt.h b/sys/sys/include/sys/debug_panic.h
similarity index 82%
copy from kernel/os/include/os/mynewt.h
copy to sys/sys/include/sys/debug_panic.h
index 3f6943e..1c3ef70 100644
--- a/kernel/os/include/os/mynewt.h
+++ b/sys/sys/include/sys/debug_panic.h
@@ -17,13 +17,15 @@
  * under the License.
  */
 
-#ifndef H_OS_MYNEWT_
-#define H_OS_MYNEWT_
+#ifndef H_DEBUG_PANIC_
+#define H_DEBUG_PANIC_
 
-#include "syscfg/syscfg.h"
-#include "sysinit/sysinit.h"
-#include "sysflash/sysflash.h"
-#include "os/os.h"
-#include "defs/error.h"
+#include "os/mynewt.h"
+
+#if MYNEWT_VAL(DEBUG_PANIC_ENABLED)
+#define DEBUG_PANIC() OS_CRASH()
+#else
+#define DEBUG_PANIC()
+#endif
 
 #endif
diff --git a/sys/sys/syscfg.yml b/sys/sys/syscfg.yml
new file mode 100644
index 0000000..f910e31
--- /dev/null
+++ b/sys/sys/syscfg.yml
@@ -0,0 +1,23 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#  http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+syscfg.defs:
+    DEBUG_PANIC_ENABLED:
+        description: >
+            If enabled, the `DEBUG_PANIC()` macro to trigger a crash.  When
+            disabled, `DEBUG_PANIC()` has no effect.
+        value: 1