tasklwIP - A Lightweight TCP/IP stack - Tasks: task #7499, Current thread information for...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

task #7499: Current thread information for debugging purposes

Submitter:  Simon Goldschmidt <goldsimon>
Submitted:  Fri 30 Nov 2007 09:28:46 AM UTC
   
 
Category:  None Should Start On:  Fri 30 Nov 2007 12:00:00 AM UTC
Should be Finished on:  Fri 30 Nov 2007 12:00:00 AM UTC Priority:  5 - Normal
Status:  Cancelled Privacy:  Public
Assigned to:  None Percent Complete:  0%
Open/Closed:  Closed Planned Release:  None
Effort:  0.00

Wed 05 Dec 2007 01:58:01 PM UTC, comment #4: 

accepted :-)

Simon Goldschmidt <goldsimon>
Group administrator
Wed 05 Dec 2007 01:30:48 PM UTC, comment #3: 

I'm not sure this would add much.  The bug reports are quite common, but I think that would be better solved with some documentation/FAQ that explains what they've probably done wrong.  Also, by the time someone had filed a bug report and been told to try compiling this stuff in, we're already pretty sure that multiple threads are a problem.

Kieran Mansley <kieranm>
Group Member
Fri 30 Nov 2007 05:09:47 PM UTC, comment #2: 

I suppose that we need for to improve the documentation (always) that adding too many "ASSERT" in the source code, which become less readable.

More, I don't know to which bug reports you thought, but I think there is more users mixing sequential and raw api (and protect that would need to add more and more asserts), than users misusing lwIP timers. But perhaps I wrong.

Frédéric Bernon <fbernon>
Group Member
Fri 30 Nov 2007 04:20:54 PM UTC, comment #1: 

I think it may be more useful to put this on top of some genuinely useful functionality, like per-thread data, than to create macros solely for use by debug code. For now we can mark them as optional, but if we wanted to change that, then ports wouldn't have to change anything.

Oh, and you'd need to fix the spelling of THREAD in a few places :-).

Jonathan Larmour <jifl>
Group Member
Fri 30 Nov 2007 09:28:46 AM UTC, original submission:  

Seeing all the 'bug reports' on the users list, I think it would be nice to define debug-functions to get the current thread-ID or pointer or whatever to identify the currently running thread. Most OSes should know how to do that (either get the current prio or a pointer to the thread control block or a unique ID...).

I propose the following debug extensions:

in sys.h:

#if LWIP_DEBUG && !NO_SYS
#define LWIP_DEBUG_TRHEAD_ID_STORAGE(t) LWIP_DEBUG_SYS_ARCH_TRHEAD_ID_STORAGE(t)
#define LWIP_DEBUG_GET_THREAD_ID() LWIP_DEBUG_SYS_ARCH_GET_THREAD_ID()
#define LWIP_DEBUG_INIT_THREAD_ID(t) (t) = LWIP_DEBUG_SYS_ARCH_GET_THREAD_ID()
#define LWIP_DEBUG_ASSERT_THREAD(t) LWIP_ASSERT("function called from the wrong thread", (t) == LWIP_DEBUG_SYS_ARCH_GET_THREAD_ID())
#else /* LWIP_DEBUG && !NO_SYS */
#define LWIP_DEBUG_TRHEAD_ID_STORAGE(t)
#define LWIP_DEBUG_GET_THREAD_ID(t)
#define LWIP_DEBUG_INIT_THREAD_ID(t)
#define LWIP_DEBUG_ASSERT_THREAD(t)
#endif /* LWIP_DEBUG && !NO_SYS */

and in sys_arch.h (example for win32):

__declspec(dllimport) unsigned long __stdcall GetCurrentThreadId();
#define LWIP_DEBUG_SYS_ARCH_TRHEAD_ID_STORAGE(t) unsigned long t
#define LWIP_DEBUG_SYS_ARCH_GET_THREAD_ID() GetCurrentThreadId()

in tcpip.c:
LWIP_DEBUG_TRHEAD_ID_STORAGE(tcpip_thread_id);

Then, in tcpip_thread(), the first thing to do is initialize tcpip_thread_id:
LWIP_DEBUG_INIT_THREAD_ID(tcpip_thread_id);

and in every timer function (e.g. tcpip_tcp_timer()):
LWIP_DEBUG_ASSERT_THREAD(tcpip_thread_id);


Simon Goldschmidt <goldsimon>
Group administrator

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by kieranm (Posted a comment)
  • -email is unavailable- added by fbernon (Posted a comment)
  • -email is unavailable- added by jifl (Posted a comment)
  • -email is unavailable- added by goldsimon (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2007-12-05 goldsimon StatusNone Cancelled
        Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code