You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by we...@apache.org on 2017/03/30 21:12:30 UTC

[13/37] incubator-mynewt-core git commit: baselibc - Optionally include file/line in assert.

baselibc - Optionally include file/line in assert.

To include filename and line number in assert messages, enable this
syscfg setting: BASELIBC_ASSERT_FILE_LINE

This behavior is disabled by default for non-native BSPs.  The native
bsp enables this setting.


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/537b2200
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/537b2200
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/537b2200

Branch: refs/heads/nrf_cputime
Commit: 537b2200e40ff38b977eb24aeda20b0c30db1960
Parents: 03fa865
Author: Christopher Collins <cc...@apache.org>
Authored: Tue Mar 28 16:24:56 2017 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Tue Mar 28 16:58:41 2017 -0700

----------------------------------------------------------------------
 hw/bsp/native/syscfg.yml       |  1 +
 libc/baselibc/include/assert.h | 11 ++++++++++-
 libc/baselibc/syscfg.yml       |  6 ++++++
 3 files changed, 17 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/537b2200/hw/bsp/native/syscfg.yml
----------------------------------------------------------------------
diff --git a/hw/bsp/native/syscfg.yml b/hw/bsp/native/syscfg.yml
index 89171a5..9ca0608 100644
--- a/hw/bsp/native/syscfg.yml
+++ b/hw/bsp/native/syscfg.yml
@@ -18,6 +18,7 @@
 #
 
 syscfg.vals:
+    BASELIBC_ASSERT_FILE_LINE: 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/537b2200/libc/baselibc/include/assert.h
----------------------------------------------------------------------
diff --git a/libc/baselibc/include/assert.h b/libc/baselibc/include/assert.h
index 68f2f86..8a131b5 100644
--- a/libc/baselibc/include/assert.h
+++ b/libc/baselibc/include/assert.h
@@ -5,6 +5,8 @@
 #ifndef _ASSERT_H
 #define _ASSERT_H
 
+#include "syscfg/syscfg.h"
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -25,7 +27,14 @@ extern "C" {
 extern void __assert_func(const char *, int, const char *, const char *)
     __attribute((noreturn));
 
-#define assert(x) ((x) ? (void)0 : __assert_func(NULL, 0, NULL, NULL))
+#if MYNEWT_VAL(BASELIBC_ASSERT_FILE_LINE)
+#define assert(x) ((x) ? (void)0 : \
+    __assert_func(__FILE__, __LINE__, NULL, NULL))
+#else
+#define assert(x) ((x) ? (void)0 : \
+    __assert_func(NULL, 0, NULL, NULL))
+#endif
+
 
 #endif
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/537b2200/libc/baselibc/syscfg.yml
----------------------------------------------------------------------
diff --git a/libc/baselibc/syscfg.yml b/libc/baselibc/syscfg.yml
index 7ec5b18..62188e1 100644
--- a/libc/baselibc/syscfg.yml
+++ b/libc/baselibc/syscfg.yml
@@ -4,3 +4,9 @@ syscfg.defs:
     BASELIBC_PRESENT:
         description: "Indicates that baselibc is the libc implementation."
         value: 1
+
+    BASELIBC_ASSERT_FILE_LINE:
+        description: >
+            Include filename and line number in assert messages.  Aids in
+            debugging, but increases text size.
+        value: 0