2

Thanks to TdwsDebugger I can debug a complete script using:

Debugger := TdwsDebugger.Create(nil);
Debugger.BeginDebug(Execution);

In my use case I don't run the whole script, but only a function of it:

var Func: IInfo;
begin
  [...]
  Func := Execution.Info.Func['MyFunction'];
  Result := Func.Call.Value;
end;

How can I invoke the TdwsDebugger now?

Steffen Binas
  • 1,463
  • 20
  • 30

1 Answers1

1

You have to manually setup the Debugger on your execution (via BeginDebug/EndDebug). You can see some sample code in UDebuggerTests.

You can make your calls before the EndDebug.

Eric Grange
  • 5,931
  • 1
  • 39
  • 61
  • 1
    I don't quite understand. `BeginDebug` runs the whole program and terminates it. When I try to get the function via `Execution.Info.Func['MyFunction']` later (before `EndDebug`) it raises an AV. `UDebuggerTests.pas` didn't help me either, as it also runs the whole program (even multiple times). My aim is to create a simple IDE with a Debugger to step through the script line by line. – Steffen Binas Aug 23 '11 at 12:29
  • Yes, you have to run the program, at least once, as it will initialize the stack, global vars, etc. Though before terminating the execution, you're able to call functions manually. At worst, you could have in your main program a call to a single function (and nothing else, besides the user functions, meaning you can append that call yourself to the user's script), and in the handler for that function, you can call your own functions. – Eric Grange Aug 23 '11 at 15:36