[Lazarus] Can Lazarus IDE debugger attach to already running process?

Graeme Geldenhuys graeme at geldenhuys.co.uk
Fri Sep 27 18:53:09 CEST 2013


Just a follow-up on this thread.

The bad news
------------
No matter what I tried, under Windows, Linux or FreeBSD... I couldn't
successfully debug a CGI application that uses multiple threads (I have
threads that do "log to file" etc). I tried the infinite loop debug
method - as I used to do with Delphi. But Lazarus's integrated debugger
just doesn't want to play ball. The multiple threads just screws up the
whole debugging, and I can't get it to stay on Thread 1 (the main
thread). Thus no stepping through the main thread's code. :-(

The good news
-------------
I found another solution. Insert a Sleep(20000) call in whichever web
module I want to debug. 20 seconds gives me enough time to find the CGI
process id, and tell Lazarus IDE to attach to that process for debugging.

Once Lazarus IDE attaches to the process, it stops the CGI temporarily.
I then set a breakpoint for whatever I want to debug. Then press the
Play button to continue running the CGI app. The breakpoint will hit,
and I can successfully step through my running CGI app.

The not-so-good news
--------------------
One (kinda big) issue though: I cannot query ANY variables to see their
values. This is a bit of a pain, but at least I can step through my CGI
app, and often if..then etc statements can be followed, so I can guess
the values. I can also follow the execution flow of my application -
which is already very useful.


@Martin
Any ideas why using my latest debug method, for CGI apps, doesn't allow
me to query variable values? I'm running Lazarus Trunk from about 5 days
ago. Windows 2000, using FPC 2.6.2 and GDB 7.2. I also tried GDB 7.4 and
that made no difference either.


Regards,
  Graeme






More information about the Lazarus mailing list