Dear all, Atached is a small unit that makes debugging cgi applications easier. When used in a program it will as part of the initialization launch a new process which opens a terminal (windows:cmd, linux:xterm) and starts gdb attaching to the calling proces. A short "sleep" makes sure gdb breaks the program while still initializing. It has been tested on windows xp32 with apache 2.2 running as an application or as a service and on ubuntu 10.04 64 with apache 2.2. Further instructions are in the unit.
I've also tested this unit sucessfully in a windows library. It helps debugging of dll's where the "Host Application" method fails. Ludo
unit SelfDebug; { Instructions: -Include unit anyware in the program. -Change DEBUGGER constant to match your debugger -For Windows, if the program to debug is running as a service (fe. CGI application from apache running as a service), make sure the service is configured with "Interact with desktop" checked. Failing to do so, the debugger will be started without a console, break the program and hang waiting for input. Killing the debugger is your only option. -For Linux, if the program to debug is running as a different user (fe. CGI application), run "xhost +" in a terminal to enable all users to connect to xserver. If needed, change DISPLAY to match your DISPLAY environment variable } {$mode objfpc}{$H+} interface uses Classes, SysUtils,Process; implementation const {$ifdef windows} DEBUGGER='C:\lazarus\mingw\bin\7.3\gdb.exe'; {$endif} {$ifdef linux} DEBUGGER='gdb'; DISPLAY=':0.0'; {$endif} MSWAIT=2000; var AProcess: TProcess; initialization AProcess := TProcess.Create(nil); {$ifdef windows} AProcess.CommandLine := format('cmd /C START "Debugging %s" /WAIT "%s" "%s" %d"',[paramstr(0),debugger,paramstr(0),GetProcessID]); {$endif} {$ifdef linux} AProcess.CommandLine := format('xterm -display %s -T "Debugging %s" -e "%s" "%s" %d',[DISPLAY,paramstr(0),DEBUGGER,paramstr(0),GetProcessID]); {$endif} AProcess.Execute; sleep(MSWAIT); finalization AProcess.Free; end.
_______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal