For this example, we chose an enhanced push down automata (PDA) assembly language and a simple interpreter implemented. Each line contains a single operation and any number of arguments. Our language differs from a standard PDA in two major ways:
The interpreter itself is written in Java. When the debugger is launched a new Java process is created which executes the interpreter.
Here is an annotated example of the Fibonacci computation (note that the annotations themselves are not valid syntax in this language – in this language, all comments must start at column 1 and be the entire line):
push 6
call Fibonacci function call with one argument on the data stack
output print result to stdout
halt
#
# f(n) = f(n-1) + f(n-2)
# f(0) = 1
# f(1) = 1
#
:fibonacci
var n define variable n on control stack
pop $n get n from data stack
push $n
branch_not_zero gt0
push 1 f(0) = 1
return return with one value on data stack
:gt0
push $n
dec
branch_not_zero gt1
push 1 f(1) = 1
return return with one value on data stack
:gt1
push $n stack: n
dec stack: n-1
call fibonacci stack: f(n-1)
push $n stack: f(n-1) n
dec stack: f(n-1) n-1
dec stack: f(n-1) n-2
call Fibonacci stack: f(n-1) f(n-2)
add stack: f(n-1)+f(n-2)
return return with one value on data stack
To support the editing and viewing of the PDA laungage programs in
Eclipse. The PDA Debugger example includes a specialized PDA
Editor. The implementation of this editor is beyond the scope of
the debugger APIs so it will not be described here in more detail.
Our PDA assembly language interpreter can be started in either run
mode or debug mode. When started in debug mode, the interpreter listens
for debug commands on a specified local TCP socket and sends debug
events to a separate local TCP socket. In our Eclipse debugger
integration, each PDA debugger command and event has a corresponding
object, which can be found in the org.eclipse.debug.examples.core.pda.protocol
package. Some of the comamnds and events are described below:
The commands include:
The debug events that are reported asynchronously to the second socket include:
org.eclipse.debug.examples.pda.core/samples
folder.
Image of the ;aunch configuration
dialog editing a PDA Debugger launch.
pda.launchType
declaration (org.eclipse.debug.core.launchConfigurationTypes
extension point) in org.eclipse.debug.examples.pda.core/plugin.xml
org.eclipse.debug.examples.core.pda.launcher.PDALaunchDelegate
implementationpda.tabGroup
declaration (org.eclipse.debug.ui.launchConfigurationTabGroups
extension point)org.eclipse.debug.examples.ui.pda.launcher.PDAMainTab
Image of PDA Debugger elements in
Debug view.
org.eclipse.debug.examples.core.pda.model
package.
Image of the Breakpoints view with
PDA breakpoints.
markerType.lineBreakpoint
and markerType.watchpoint
declarations (org.eclipse.core.resources.markers
extension point) in org.eclipse.debug.examples.pda.core/plugin.xml
pda.lineBreakpoint
and markerType.watchpoint
declarations (org.eclipse.debug.core.breakpoints
extension point) in org.eclipse.debug.examples.pda.core/plugin.xml
To see how this is implemented, look at the following:
pda.rulerActions
declaration (org.eclipse.ui.editorActions
extension point) in org.eclipse.debug.examples.pda.ui/plugin.xml
.org.eclipse.debug.examples.ui.pda.breakpoints.PDABreakpointAdapter
org.eclipse.debug.examples.ui.pda.breakpoints.PDAEditorAdapterFactory
and its declaration (org.eclipse.core.runtime.adapters
extension point) in org.eclipse.debug.examples.pda.ui/plugin.xml
To see how this view is implemented look at the the org.eclipse.debug.examples.ui.pda.views
package in the example code.