PDA

View Full Version : GNU debugger for freepascal IDE



{MSX}
15-11-2004, 08:52 PM
Ok, let's talk about how to implement a gdb interface for a pascal IDE (like dev-pas) :mrgreen:

First, the things we need:

- Running and stopping the program
- Breakpoints and eventually watchpoint and catchpoint
- Variable watch
- Step into & step over
- Modify variable at runtime
- Stack trace
- MultiThread support (maybe ?)

Now, interfacing gdb can be done in two way: using the libgdb API or running it and capturing/parsing the output.
I'm for the second option, since there's really few libgdb docs around.
There are also command line option that can help the parsing (ie -f). It is not that hard anyway, output is always clearly formatted.

Basically, we should define a class that implements methods for every possible action (not that many), and methods for quering current status.

{MSX}
15-11-2004, 09:02 PM
Here a possible minimal interface:

Start() start the program in debug mode
Stop() stops it :P
StepOver() execute the next instruction, eventually returning new current file/linenum
StepInto() jumps in current function, eventually returning new current file/linenum
SetBreakpoint (file, linenum) set a breakpoint
Evaluate(expression) :string
GetStackTrace() obtain the stack trace, as an array of something like [procedure, file, line].
Status() return the current status, running, paused, stopped

Each of this method basically sends a single command to gdb, and eventually capture the command output.
This should not be that hard to do.

The IDE should interface with it and display obtained data. Also, it should deal with locating file/linenum when requested (ie after a step operation, or at a breakpoint stop).

Anonymous
31-12-2004, 12:51 PM
Now, interfacing gdb can be done in two way: using the libgdb API or running

OTOH libgdb is technically superior, and there already is an example and interface, the (textmode) FPC ide in fpc/ide and the libgdbinterface in fpc/packages/base/gdbint