You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ma...@apache.org on 2017/01/18 21:47:43 UTC

[1/2] incubator-mynewt-core git commit: os; to reduce codesize, don't print/use filename in assert().

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 <ma...@runtime.io>
Authored: Wed Jan 18 13:41:01 2017 -0800
Committer: Marko Kiiskila <ma...@runtime.io>
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
 


[2/2] incubator-mynewt-core git commit: sysinit; change the function prototype of sysinit_panic_fn to match __assert_func(). Use __assert_func() as the default panic function.

Posted by ma...@apache.org.
sysinit; change the function prototype of sysinit_panic_fn to
match __assert_func(). Use __assert_func() as the default panic function.


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

Branch: refs/heads/develop
Commit: 18ef5db1581de100c50f9ac22cd28f56fda2b982
Parents: 5c53749
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Wed Jan 18 13:45:40 2017 -0800
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Wed Jan 18 13:45:40 2017 -0800

----------------------------------------------------------------------
 sys/sysinit/include/sysinit/sysinit.h | 5 +++--
 sys/sysinit/src/sysinit.c             | 9 +--------
 2 files changed, 4 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/18ef5db1/sys/sysinit/include/sysinit/sysinit.h
----------------------------------------------------------------------
diff --git a/sys/sysinit/include/sysinit/sysinit.h b/sys/sysinit/include/sysinit/sysinit.h
index 4b250c0..32df52b 100644
--- a/sys/sysinit/include/sysinit/sysinit.h
+++ b/sys/sysinit/include/sysinit/sysinit.h
@@ -37,13 +37,14 @@ extern uint8_t sysinit_active;
 void sysinit_start(void);
 void sysinit_end(void);
 
-typedef void sysinit_panic_fn(const char *file, int line);
+typedef void sysinit_panic_fn(const char *file, int line, const char *func,
+                              const char *expr);
 
 extern sysinit_panic_fn *sysinit_panic_cb;
 
 void sysinit_panic_set(sysinit_panic_fn *panic_fn);
 
-#define SYSINIT_PANIC() sysinit_panic_cb(__FILE__, __LINE__)
+#define SYSINIT_PANIC() sysinit_panic_cb(NULL, 0, NULL, NULL)
 
 #define SYSINIT_PANIC_ASSERT(rc) do \
 {                                   \

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/18ef5db1/sys/sysinit/src/sysinit.c
----------------------------------------------------------------------
diff --git a/sys/sysinit/src/sysinit.c b/sys/sysinit/src/sysinit.c
index 4e560c7..767032f 100644
--- a/sys/sysinit/src/sysinit.c
+++ b/sys/sysinit/src/sysinit.c
@@ -22,17 +22,10 @@
 #include "os/os_fault.h"
 #include "sysinit/sysinit.h"
 
-static void sysinit_panic_dflt(const char *file, int line);
-sysinit_panic_fn *sysinit_panic_cb = sysinit_panic_dflt;
+sysinit_panic_fn *sysinit_panic_cb = __assert_func;
 
 uint8_t sysinit_active;
 
-static void
-sysinit_panic_dflt(const char *file, int line)
-{
-    __assert_func(file, line, NULL, NULL);
-}
-
 /**
  * Sets the sysinit panic function; i.e., the function which executes when
  * initialization fails.  By default, a panic triggers a failed assertion.