This is the mail archive of the ecos-discuss@sourceware.org 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]

Re: Debug eCos kernel


diff --git a/net/bsd_tcpip/current/include/sys/param.h b/net/bsd_tcpip/current/include/sys/param.h
--- a/net/bsd_tcpip/current/include/sys/param.h
+++ b/net/bsd_tcpip/current/include/sys/param.h
@@ -815,9 +815,11 @@
 #define splclock() cyg_splclock(__FUNCTION__, __LINE__)
 #define splsoftnet() cyg_splsoftnet(__FUNCTION__, __LINE__)
 #define splx(x)    cyg_splx(x, __FUNCTION__, __LINE__)
+#if 0
 #define cyg_scheduler_lock() _cyg_scheduler_lock(__FUNCTION__, __LINE__)
 #define cyg_scheduler_safe_lock() _cyg_scheduler_safe_lock(__FUNCTION__, __LINE__)
 #define cyg_scheduler_unlock() _cyg_scheduler_unlock(__FUNCTION__, __LINE__)
+#endif
 #else
 extern cyg_uint32  cyg_splimp(void);
 extern cyg_uint32  cyg_splnet(void);
diff --git a/net/bsd_tcpip/current/src/ecos/synch.c b/net/bsd_tcpip/current/src/ecos/synch.c
--- a/net/bsd_tcpip/current/src/ecos/synch.c
+++ b/net/bsd_tcpip/current/src/ecos/synch.c
@@ -115,9 +115,10 @@
 
 
 #ifdef CYGIMPL_TRACE_SPLX   
+static void do_sched_event(const char *, const char *, int, void *, cyg_uint32);
 #define SPLXARGS const char *file, const int line
-#define SPLXMOREARGS , const char *file, const int line
-#define SPLXTRACE do_sched_event(__FUNCTION__, file, line, spl_state)
+#define SPLXMOREARGS , SPLXARGS
+#define SPLXTRACE do_sched_event(__FUNCTION__, file, line, __builtin_return_address(0), spl_state)
 #else
 #define SPLXARGS void
 #define SPLXMOREARGS
@@ -357,13 +358,15 @@
 #define MAX_SCHED_EVENTS 256
 static struct _sched_event {
     char *fun, *file;
-    int line, lock;
+    int line;
+    cyg_uint32 lock;
+    void *ret;
 } sched_event[MAX_SCHED_EVENTS];
 static int next_sched_event = 0;
 static int total_sched_events = 0;
 
 static void
-do_sched_event(char *fun, char *file, int line, int lock)
+do_sched_event(const char *fun, const char *file, int line, void *ret, cyg_uint32 lock)
 {
     struct _sched_event *se = &sched_event[next_sched_event];
     if (++next_sched_event == MAX_SCHED_EVENTS) {
@@ -373,6 +376,7 @@
     se->file = file;
     se->line = line;
     se->lock = lock;
+    se->ret = ret;
     total_sched_events++;
 }
 
@@ -390,7 +394,7 @@
     diag_printf("%d total scheduler events\n", total_sched_events);
     while (i != next_sched_event) {
         se = &sched_event[i];
-        diag_printf("%s - lock: %d, called from %s.%d\n", se->fun, se->lock, se->file, se->line);
+        diag_printf("%s - lock: %d, called from %s:%d @ %p\n", se->fun, se->lock, se->file, se->line, se->ret);
         if (++i == MAX_SCHED_EVENTS) i = 0;
     }
 }
@@ -401,21 +405,21 @@
 _cyg_scheduler_lock(char *file, int line)
 {
     cyg_scheduler_lock();
-    do_sched_event(__FUNCTION__, file, line, SPLX_TRACE_DATA());
+    do_sched_event(__FUNCTION__, file, line, __builtin_return_address(0), SPLX_TRACE_DATA());
 }
 
 void
 _cyg_scheduler_safe_lock(char *file, int line)
 {
     cyg_scheduler_safe_lock();
-    do_sched_event(__FUNCTION__, file, line, SPLX_TRACE_DATA());
+    do_sched_event(__FUNCTION__, file, line, __builtin_return_address(0), SPLX_TRACE_DATA());
 }
 
 void
 _cyg_scheduler_unlock(char *file, int line)
 {
     cyg_scheduler_unlock();
-    do_sched_event(__FUNCTION__, file, line, SPLX_TRACE_DATA());
+    do_sched_event(__FUNCTION__, file, line, __builtin_return_address(0), SPLX_TRACE_DATA());
 }
 #endif // CYGIMPL_TRACE_SPLX
 
diff --git a/net/bsd_tcpip/current/src/ecos/timeout.c b/net/bsd_tcpip/current/src/ecos/timeout.c
--- a/net/bsd_tcpip/current/src/ecos/timeout.c
+++ b/net/bsd_tcpip/current/src/ecos/timeout.c
@@ -74,7 +74,13 @@
 
 // ------------------------------------------------------------------------
 // This routine exists so that this module can synchronize:
+#ifdef CYGIMPL_TRACE_SPLX
+extern cyg_uint32  cyg_splinternal(const char *, int);
+#define splinternal() cyg_splinternal(__FUNCTION__, __LINE__)
+#else
 extern cyg_uint32 cyg_splinternal(void);
+#define splinternal() cyg_splinternal()
+#endif
 
 #ifdef TIMEOUT_DEBUG
 static void
@@ -213,7 +219,7 @@
 #endif // CYGPKG_NET_FAST_THREAD_TICKLE_DEVS
         CYG_ASSERT( !((~3) & x), "Extra bits" );
 
-        spl = cyg_splinternal();
+        spl = splinternal();
 
         CYG_ASSERT( 0 == spl, "spl nonzero" );
 
@@ -230,7 +236,7 @@
         if ( 1 & x )
             do_timeout();
 
-        cyg_splx(spl);
+        splx(spl);
     }
 }
 
@@ -272,7 +278,7 @@
 
     // this needs to be atomic - recursive calls from the alarm
     // handler thread itself are allowed:
-    int spl = cyg_splinternal();
+    int spl = splinternal();
 
     stamp = 0;  // Assume no slots available
     for (e = _timeouts, i = 0;  i < NTIMEOUTS;  i++, e++) {
@@ -285,7 +291,7 @@
             break;
         }
     }
-    cyg_splx(spl);
+    splx(spl);
     return stamp;
 }
 
@@ -298,7 +304,7 @@
 {
     int i;
     timeout_entry *e;
-    int spl = cyg_splinternal();
+    int spl = splinternal();
 
     for (e = _timeouts, i = 0; i < NTIMEOUTS; i++, e++) {
         if (e->delta && (e->fun == fun) && (e->arg == arg)) {
@@ -306,7 +312,7 @@
             break;
         }
     }
-    cyg_splx(spl);
+    splx(spl);
 }
 
 void 
@@ -318,7 +324,7 @@
 void 
 callout_reset(struct callout *c, int delta, timeout_fun *f, void *p) 
 {
-    int spl = cyg_splinternal();
+    int spl = splinternal();
 
     CYG_ASSERT( 0 < delta, "delta is right now, or even sooner!" );
 
@@ -431,20 +437,20 @@
         CYG_ASSERT( delta >= last_delta, "We didn't pick the smallest delta!" );
     }
 #endif
-    cyg_splx(spl);
+    splx(spl);
 }
 
 void 
 callout_stop(struct callout *c) 
 {
-    int spl = cyg_splinternal();
+    int spl = splinternal();
 
 #ifdef TIMEOUT_DEBUG
     diag_printf("%s(%p) = %x\n", __FUNCTION__, c, c->flags);
 #endif
     if ((c->flags & CALLOUT_PENDING) == 0) {
         c->flags &= ~CALLOUT_ACTIVE;
-        cyg_splx(spl);
+        splx(spl);
         return;
     }
     c->flags &= ~(CALLOUT_PENDING | CALLOUT_ACTIVE);
@@ -456,7 +462,7 @@
     } else {
         timeouts = c->next;
     }
-    cyg_splx(spl);
+    splx(spl);
 }
 
 int  
-- 
Daniel Néri <daniel.neri@sigicom.com>
Sigicom AB, Stockholm, Sweden

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

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