Debugging FoxPro code from .NET

Top  Previous  Next

Guineu offers a debugging hook that allows you to trace your FoxPro code as it executes. Enabling debugging support is a three step process.

 

1) In your FoxPro program you must enable debugging by using SYS(8003):

 

Sys(8003,1)

 

2) Define a delegate that is called before or after each line of FoxPro code is executed. The delegate receives an event argument with detailed information:

 

static void DebugListener(Object sender, Core.DebugEventArgs e)

{

 Console.WriteLine("{0}, {1} in {2}", e.Line.ToString(), e.Module, e.File);

 Console.WriteLine("{0} variables declared.",e.Locals.Count);

}

 

Please note the e.Line is the line number in the compiled program. It doesn't match the source code line number in the PRG.

 

3) Subscribe to the event in your main program before you execute the compiled program:

 

GuineuInstance.InitInstance();

GuineuInstance.DebugBefore += new EventHandler<Guineu.Core.DebugEventArgs>(DebugListener);

GuineuInstance.Do(Filename);

 

The sample above creates a simplified coverage log, when you execute the application

 

C:\Source\Guineu.EXE\bin\Debug>Guineu.exe test2.FXP

1,  in C:\SOURCE\GUINEU.EXE\BIN\DEBUG\TEST2.FXP

0 variables declared.

0, TEST in C:\SOURCE\GUINEU.EXE\BIN\DEBUG\TEST2.FXP

0 variables declared.

1, TEST in C:\SOURCE\GUINEU.EXE\BIN\DEBUG\TEST2.FXP

1 variables declared.

2, TEST in C:\SOURCE\GUINEU.EXE\BIN\DEBUG\TEST2.FXP

1 variables declared.

2,  in C:\SOURCE\GUINEU.EXE\BIN\DEBUG\TEST2.FXP

0 variables declared.