Repository: incubator-mynewt-core
Updated Branches:
  refs/heads/develop 0266b2249 -> 18ef5db15


os; to reduce codesize, don't print/use filename in assert().


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

Branch: refs/heads/develop
Commit: 5c5374977b2712754b79e6a51d474cc5c32abd80
Parents: 0266b22
Author: Marko Kiiskila <[email protected]>
Authored: Wed Jan 18 13:41:01 2017 -0800
Committer: Marko Kiiskila <[email protected]>
Committed: Wed Jan 18 13:41:01 2017 -0800

----------------------------------------------------------------------
 kernel/os/src/arch/cortex_m0/os_fault.c | 3 ++-
 kernel/os/src/arch/cortex_m4/os_fault.c | 3 ++-
 kernel/os/src/arch/mips/os_fault.c      | 3 ++-
 kernel/os/src/arch/sim-mips/os_fault.c  | 9 +++++++--
 kernel/os/src/arch/sim/os_fault.c       | 9 +++++++--
 libc/baselibc/include/assert.h          | 2 +-
 6 files changed, 21 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/5c537497/kernel/os/src/arch/cortex_m0/os_fault.c
----------------------------------------------------------------------
diff --git a/kernel/os/src/arch/cortex_m0/os_fault.c 
b/kernel/os/src/arch/cortex_m0/os_fault.c
index ed8d1be..5a3af9d 100644
--- a/kernel/os/src/arch/cortex_m0/os_fault.c
+++ b/kernel/os/src/arch/cortex_m0/os_fault.c
@@ -116,7 +116,8 @@ __assert_func(const char *file, int line, const char *func, 
const char *e)
     OS_ENTER_CRITICAL(sr);
     (void)sr;
     console_blocking_mode();
-    console_printf("Assert %s; failed in %s:%d\n", e ? e : "", file, line);
+    console_printf("Assert @ 0x%x\n",
+                   (unsigned int)__builtin_return_address(0));
     if (hal_debugger_connected()) {
        /*
         * If debugger is attached, breakpoint before the trap.

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/5c537497/kernel/os/src/arch/cortex_m4/os_fault.c
----------------------------------------------------------------------
diff --git a/kernel/os/src/arch/cortex_m4/os_fault.c 
b/kernel/os/src/arch/cortex_m4/os_fault.c
index 2f84a3d..8bd881f 100644
--- a/kernel/os/src/arch/cortex_m4/os_fault.c
+++ b/kernel/os/src/arch/cortex_m4/os_fault.c
@@ -116,7 +116,8 @@ __assert_func(const char *file, int line, const char *func, 
const char *e)
     OS_ENTER_CRITICAL(sr);
     (void)sr;
     console_blocking_mode();
-    console_printf("Assert %s; failed in %s:%d\n", e ? e : "", file, line);
+    console_printf("Assert @ 0x%x\n",
+                   (unsigned int)__builtin_return_address(0));
     if (hal_debugger_connected()) {
        /*
         * If debugger is attached, breakpoint before the trap.

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/5c537497/kernel/os/src/arch/mips/os_fault.c
----------------------------------------------------------------------
diff --git a/kernel/os/src/arch/mips/os_fault.c 
b/kernel/os/src/arch/mips/os_fault.c
index 1c3abfd..5dc952a 100644
--- a/kernel/os/src/arch/mips/os_fault.c
+++ b/kernel/os/src/arch/mips/os_fault.c
@@ -86,7 +86,8 @@ __assert_func(const char *file, int line, const char *func, 
const char *e)
     OS_ENTER_CRITICAL(sr);
     (void)sr;
     console_blocking_mode();
-    console_printf("Assert %s; failed in %s:%d\n", e ? e : "", file, line);
+    console_printf("Assert @ 0x%x\n",
+                   (unsigned int)__builtin_return_address(0));
     if (hal_debugger_connected()) {
        /*
         * If debugger is attached, breakpoint before the trap.

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/5c537497/kernel/os/src/arch/sim-mips/os_fault.c
----------------------------------------------------------------------
diff --git a/kernel/os/src/arch/sim-mips/os_fault.c 
b/kernel/os/src/arch/sim-mips/os_fault.c
index 15c40fe..a58440e 100644
--- a/kernel/os/src/arch/sim-mips/os_fault.c
+++ b/kernel/os/src/arch/sim-mips/os_fault.c
@@ -6,7 +6,7 @@
  * 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,
@@ -28,7 +28,12 @@ __assert_func(const char *file, int line, const char *func, 
const char *e)
 {
     char msg[256];
 
-    snprintf(msg, sizeof(msg), "assert at %s:%d\n", file, line);
+    if (file) {
+        snprintf(msg, sizeof(msg), "assert at %s:%d\n", file, line);
+    } else {
+        snprintf(msg, sizeof(msg), "assert @ %p\n",
+                 __builtin_return_address(0));
+    }
     write(1, msg, strlen(msg));
     _exit(1);
 }

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/5c537497/kernel/os/src/arch/sim/os_fault.c
----------------------------------------------------------------------
diff --git a/kernel/os/src/arch/sim/os_fault.c 
b/kernel/os/src/arch/sim/os_fault.c
index cc6f7a6..964202e 100644
--- a/kernel/os/src/arch/sim/os_fault.c
+++ b/kernel/os/src/arch/sim/os_fault.c
@@ -6,7 +6,7 @@
  * 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,
@@ -28,7 +28,12 @@ __assert_func(const char *file, int line, const char *func, 
const char *e)
 {
     char msg[256];
 
-    snprintf(msg, sizeof(msg), "assert at %s:%d\n", file, line);
+    if (file) {
+        snprintf(msg, sizeof(msg), "assert @ %s:%d\n", file, line);
+    } else {
+        snprintf(msg, sizeof(msg), "assert @ %p\n",
+                 __builtin_return_address(0));
+    }
     write(1, msg, strlen(msg));
     _exit(1);
 }

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/5c537497/libc/baselibc/include/assert.h
----------------------------------------------------------------------
diff --git a/libc/baselibc/include/assert.h b/libc/baselibc/include/assert.h
index 851ad4c..68f2f86 100644
--- a/libc/baselibc/include/assert.h
+++ b/libc/baselibc/include/assert.h
@@ -25,7 +25,7 @@ extern "C" {
 extern void __assert_func(const char *, int, const char *, const char *)
     __attribute((noreturn));
 
-#define assert(x) ((x) ? (void)0 : __assert_func(__FILE__, __LINE__, NULL, 
NULL))
+#define assert(x) ((x) ? (void)0 : __assert_func(NULL, 0, NULL, NULL))
 
 #endif
 

Reply via email to