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

Martin lazarus at mfriebe.de
Thu Sep 19 15:05:50 CEST 2013


On 19/09/2013 13:20, Graeme Geldenhuys wrote:
> On 2013-09-18 18:30, Martin wrote:
>> If you use an integer var, you can modify it from the IDE.
>> Do not modify managed types
> OK, I got the latest Lazarus from Trunk and compiled it with FPC 2.6.2
> and using GDB 7.2 under Win2000 (a VM).
>
> I enter the PID and click OK. The Lazarus IDE shows "Debugging..." in
> the title bar, but I can't do anything else.
You do have to run to a breakpoin, see below. Did you?
> I can't evaluate local
> variables, cannot modify the local lDebug (integer) variable. The
> login.cgi application is also compiled with debug information - contrary
> to what the GDB log output seems to say.
Actually it is there.
> Not sure if I'm doing wrong. I'll try with GDB command line and MSEide
> under Windows now.
>


Strange. It has found the debug info:
> <info file>
> ~"Symbols from
> \"c:\\programming\\m2_system\\Bin\\i386-win32\\html\\mmaths\\login.cgi\".\n"
and
> <info line "c:\Programming\m2_system\Source\browser\cgiLoginMain.pas":648>
> \"c:\\Programming\\m2_system\\Source\\browser\\cgiLoginMain.pas\":648\n"
> ~"Line 648 of \"cgiLoginMain.pas\" starts at address 0x43816d
> <TCGILOGIN__RUN+205> and ends at 0x438182 <TCGILOGIN__RUN+226>.\n"
> ^done
> (gdb)
> <-break-insert -f cgiLoginMain.pas:648>
> ^done,bkpt={number="10",type="breakpoint",disp="keep",enabled="y",addr="0x0043816d",func="TCGILOGIN__RUN",file="cgiLoginMain.pas",fullname="c:/Programming/m2_system/Source/browser/cgiLoginMain.pas",line="648",times="0",original-location="cgiLoginMain.pas:648"}
> (gdb)
So I would expect, that when you hit run (attach will pause the process, 
and keep it paused. but it may be somewhere in the kernel...) you would 
reach one of the breakpoints...

Actually looking at the threads, if you switch to 1, then you need net 
run, but should see your app.


> <-thread-info>
> ^done,threads=[
> {id="3",...,frame={...,func="ntdll!DbgUiConnectToDbg",...,state="stopped"},
> {id="2",...,frame={...,func="ntdll!ZwDelayExecution",...,state="stopped"},
>
> {id="1",...,frame={level="0",...,func="TCGILOGIN__RUN",
> args=[{name="this",value="0x19da268"}],file="cgiLoginMain.pas",fullname="c:/Programming/m2_system/Source/browser/cgiLoginMain.pas",line="642"},state="stopped"}],
>
> current-thread-id="3"
> (gdb)
and then run (F9)
> <-exec-continue>
> ^running
> *running,thread-id="all"
> (gdb)
> =thread-exited,id="3",group-id="i1"

Looks normal too: DbgUiConnectToDbg , is created by windows, when the 
debugger pauses the app. So it ends on continue. [1]

Your main thread still runs.

[1] Just realising, the attach module does not currently "fix" this 
extra thread. It should probably automatically select the main thread.










More information about the Lazarus mailing list