[Lazarus] Multi-Threaded Debugging under Linux (GDB CRASH Work-Around)

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[Lazarus] Multi-Threaded Debugging under Linux (GDB CRASH Work-Around)

Andrew Brunner
I have great news regarding debugging multi-threaded apps under Linux
without crashing the Gnome Desktop Manager.

If you are having problems with GDB and GDM crashing under Linux when
you trace into lines use Synchronize.  I just write a debug wrapper
for the desired thread's execution code and pass that into
Synchronize.  I am now able to debug line by line for minutes with no
crashes!  Just use a compile directive and you can switch for
production builds.

This is so much sweeter.

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Multi-Threaded Debugging under Linux (GDB CRASH Work-Around)

Michael Schnell
On 02/06/2011 04:08 AM, Andrew Brunner wrote:

This might sometimes be a workaround, but in fact the synchronized
method runs (much later than being called) in the main thread and not in
the thread, while the thread is stalled. So this changed the behavior of
the thread greatly.

-Michael

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Multi-Threaded Debugging under Linux (GDB CRASH Work-Around)

Andrew Brunner
On Mon, Feb 7, 2011 at 6:09 AM, Michael Schnell <[hidden email]> wrote:
> On 02/06/2011 04:08 AM, Andrew Brunner wrote:
>
> This might sometimes be a workaround, but in fact the synchronized method
> runs (much later than being called) in the main thread and not in the
> thread, while the thread is stalled. So this changed the behavior of the
> thread greatly.
>
> -Michael
>

I think what makes this solution for me so valuable is that these are
worker threads that I need to debug.  I use an elaborate system of
methods that don't wait or need to wait for another event.  If they
do, I exit the event and keep that task pending.  This way the manager
thread gets to say which thread executes what method and at the
desired time.

If you use a flagging system on the worker objects to keep track of
what methods are needed or complete, you may remove all intricate
waits, you will find your manager's thread/process merely iterating
ptrs to worker objects (not threads), and examining the operation
flag, and the manager will execute as needed.  If you switched to that
model, it would most likely payoff in debugging because one manager
thread is "managing" all worker objects and all methods are coded to
the manager class.  But *you* know your project and what it was
intended for and how best to design it.

I'm just trying to let people know how to get around a long-standing
albeit crippling issue I had under Linux.

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus