1

using Indy with Delphi XE8 for a Tcp Server application I had necessity to inspect some local variables inside OnExecute event.

But setting a Breakpoint I do not understand why I get error "E2003 undeclared identifier" trying to inspect or watch such local variables, as frame.

procedure TformMain.IdTCPServer1Execute(AContext: TIdContext);
var
  frame, answer: string;
begin
    ... 
    frame := ReadLn(cETX, 50, 1024); 
    ...
    Thread.Queue(nil, procedure
                  begin
                    mmLog.Lines.Add(AContext.Binding.IP +'Bad Frame: '+ frame);
                  end
    ...
end;

Instead, in the thread queue I use to send info to the GUI, I can inspect correctly the Binding.IP, dispite to local strings...

Any idea if I am using the Delphi debugger in the right/wrong way ?

Mark
  • 11
  • 4
  • Where is your break point? Inside `IdTCPServer1Execute` or inside the anon method? – David Heffernan Oct 07 '16 at 12:49
  • Inside IdTCPServer1Execute, after frame := ReadLn(); to inspect the frame local variable. – Mark Oct 11 '16 at 15:31
  • The thing about `frame` is that it is captured by the anon method. It is no longer lives in the stack frame for `IdTCPServer1Execute`. Now it is a data member of the [compiler generated class that implements the anon method interface](http://stackoverflow.com/questions/39955052/how-are-anonymous-methods-implemented-under-the-hood/39955392#39955392). I guess that just confuses the debugger. Delphi's debugger is a bit like that. Not much you can do beyond resorting to trace debugging. – David Heffernan Oct 11 '16 at 15:51
  • Many thanks David, so I don't waste time trying to understand what happens. At least I can rely in the old debug methods :-) – Mark Oct 12 '16 at 12:45

0 Answers0