This is the mail archive of the ecos-patches@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Kernel - add debug printing for thread stack checking


Index: kernel/current/ChangeLog
===================================================================
RCS file: /misc/cvsfiles/ecos/packages/kernel/current/ChangeLog,v
retrieving revision 1.93
diff -u -5 -p -r1.93 ChangeLog
--- kernel/current/ChangeLog	10 Feb 2003 21:07:47 -0000	1.93
+++ kernel/current/ChangeLog	10 Feb 2003 22:01:50 -0000
@@ -1,7 +1,9 @@
 2003-02-10  Gary Thomas  <gary@mlbassoc.com>
 
+	* include/thread.inl: Add more debug info to thread stack checking.
+
 	* tests/clocktruth.cxx: 
 	* tests/clockcnv.cxx: Use <cyg/infra/diag.h> for diag_printf()
 	prototype, rather than hard coding (because it was inconsistent).
 
 2003-02-05  Gary Thomas  <gary@mlbassoc.com>
Index: kernel/current/include/thread.inl
===================================================================
RCS file: /misc/cvsfiles/ecos/packages/kernel/current/include/thread.inl,v
retrieving revision 1.14
diff -u -5 -p -r1.14 thread.inl
--- kernel/current/include/thread.inl	23 May 2002 23:06:51 -0000	1.14
+++ kernel/current/include/thread.inl	10 Feb 2003 22:01:51 -0000
@@ -10,10 +10,11 @@
 //==========================================================================
 //####ECOSGPLCOPYRIGHTBEGIN####
 // -------------------------------------------
 // This file is part of eCos, the Embedded Configurable Operating System.
 // Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
+// Copyright (C) 2003 Gary Thomas
 //
 // eCos is free software; you can redistribute it and/or modify it under
 // the terms of the GNU General Public License as published by the Free
 // Software Foundation; either version 2 or (at your option) any later version.
 //
@@ -62,10 +63,11 @@
 
 #include <cyg/kernel/thread.hxx>
 #include <cyg/hal/hal_arch.h>
 
 #include <cyg/kernel/clock.inl>
+#include <cyg/infra/diag.h>
 
 #ifndef CYGNUM_KERNEL_THREADS_STACK_CHECK_DATA_SIZE
 #define CYGNUM_KERNEL_THREADS_STACK_CHECK_DATA_SIZE (0)
 #endif
 
@@ -108,12 +110,22 @@ inline void Cyg_HardwareThread::check_st
                 "Stack_ptr above top" );
 
     for ( i = 0;
           i < CYGNUM_KERNEL_THREADS_STACK_CHECK_DATA_SIZE/sizeof(cyg_uint32);
           i++ ) {
-        CYG_ASSERT( (sig ^ (i * 0x01010101)) == base[i], "Stack base corrupt" );
-        CYG_ASSERT( (sig ^ (i * 0x10101010)) ==  top[i], "Stack top corrupt"  );
+        if ((sig ^ (i * 0x01010101)) != base[i]) {
+            char *reason = "Stack base corrupt";
+            diag_printf("%s - i: %d\n", reason, i);
+            diag_dump_buf(base, CYGNUM_KERNEL_THREADS_STACK_CHECK_DATA_SIZE);
+            CYG_FAIL(reason);
+        }
+        if ((sig ^ (i * 0x10101010)) != top[i]) {
+            char *reason = "Stack top corrupt";
+            diag_printf("%s - i: %d\n", reason, i);
+            diag_dump_buf(top, CYGNUM_KERNEL_THREADS_STACK_CHECK_DATA_SIZE);
+            CYG_FAIL(reason);
+        }
     }            
 
 #ifdef CYGFUN_KERNEL_THREADS_STACK_LIMIT
     // we won't have added check data above the stack limit if it hasn't
     // been incremented
@@ -128,12 +140,16 @@ inline void Cyg_HardwareThread::check_st
         // i.e. + sizeof(cyg_uint32)-1) & ~(sizeof(cyg_uint32)-1);
         
         for ( i = 0;
               i < CYGNUM_KERNEL_THREADS_STACK_CHECK_DATA_SIZE/sizeof(cyg_uint32);
               i++ ) {
-            CYG_ASSERT( (sig ^ (i * 0x01010101)) == p[i],
-                        "Gap between stack limit and base corrupt" );
+            if ((sig ^ (i * 0x01010101)) != p[i]) {
+                char *reason = "Gap between stack limit and base corrupt";
+                diag_printf("%s - i: %d\n", reason, i);
+                diag_dump_buf(p, CYGNUM_KERNEL_THREADS_STACK_CHECK_DATA_SIZE);
+                CYG_FAIL(reason);
+            }
         }
     }
 #endif
 }
 #endif


-- 
------------------------------------------------------------
Gary Thomas                 |
MLB Associates              |  Consulting for the
+1 (970) 229-1963           |    Embedded world
http://www.mlbassoc.com/    |
email: <gary@mlbassoc.com>  |
gpg: http://www.chez-thomas.org/gary/gpg_key.asc
------------------------------------------------------------


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]