From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31542 invoked by alias); 11 Feb 2009 10:38:45 -0000 Received: (qmail 31532 invoked by uid 22791); 11 Feb 2009 10:38:44 -0000 X-SWARE-Spam-Status: No, hits=-3.3 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: sourceware.org Received: from main.gmane.org (HELO ciao.gmane.org) (80.91.229.2) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 11 Feb 2009 10:38:32 +0000 Received: from list by ciao.gmane.org with local (Exim 4.43) id 1LXCU9-0000cl-Oj for ecos-discuss@sources.redhat.com; Wed, 11 Feb 2009 10:38:29 +0000 Received: from 90-231-88-61-no84.business.telia.com ([90.231.88.61]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 11 Feb 2009 10:38:29 +0000 Received: from daniel.neri by 90-231-88-61-no84.business.telia.com with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 11 Feb 2009 10:38:29 +0000 To: ecos-discuss@sources.redhat.com From: daniel.neri@sigicom.com (Daniel =?iso-8859-1?Q?N=E9ri?=) Date: Wed, 11 Feb 2009 10:38:00 -0000 Message-ID: <87hc31z2aq.fsf@dual.hq.sigicom.net> References: <661011.74923.qm@web59508.mail.ac4.yahoo.com> <3fea10110902080617x7397727bo8dd72cd339d40521@mail.gmail.com> <49905C62.5010505@mlbassoc.com> <20090209180239.GC6308@lunn.ch> <20090210073746.GA32351@lunn.ch> <20090210161502.GD32351@lunn.ch> <20090211100916.GE32351@lunn.ch> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" User-Agent: Gnus/5.110011 (No Gnus v0.11) Emacs/23.0.60 (berkeley-unix) X-IsSubscribed: yes Mailing-List: contact ecos-discuss-help@ecos.sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: ecos-discuss-owner@ecos.sourceware.org Subject: [ECOS] Re: Debug eCos kernel X-SW-Source: 2009-02/txt/msg00056.txt.bz2 Andrew Lunn writes: > You are going to have to work on it before it will be > usable. Hopefully you can see the idea what it is trying to do. I did some of that work a while ago, but ended up not using it. I'm attaching a patch with the changes I made to make the code compile without errors (but no promises beyond that). Regards, Daniel --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=trace-splx-fix.patch Content-length: 6017 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 --=-=-= Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Content-length: 74 -- Daniel NĂ©ri Sigicom AB, Stockholm, Sweden --=-=-= Content-Type: text/plain; charset=us-ascii Content-length: 148 -- Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss --=-=-=--