Professional Documents
Culture Documents
• Cons:
– To run on a different platform, code has to be
recompiled
Interpreters: Pros and Cons
• Pros:
– No need to compile before running the program;
program can just be run straight away
– Program can be run on different platforms without
recompiling (provided an interpreter is available for
that platform)
• Cons:
– Program execution is slower than with compiled code
Java Virtual Machine
x = 10
while (x > 5) {
x++
}
print $x
Program with print Statements
x = 10
print "Got past initialisation\n"
while (x > 5) {
print "Entered while loop\n"
x++
print "incremented x\n"
}
print "Exited while loop\n"
print $x
Output of Buggy Program
$ awkInfinite.sh
Got past initialisation
Entered while Loop
incremented x
Entered while Loop
incremented x
Entered while Loop
incremented x
Entered while Loop
incremented x
More Print Statements
x = 10
print "Got past initialisation\n"
while (x > 5) {
print "Entered while Loop\n"
print $x ”\n"
x++
print "incremented x\n“
print $x ”\n”
}
print "Exited while loop\n"
print $x
More Output
$ awkInfinite.sh
Got past initialisation
Entered while Loop
10
incremented x
11
Entered while Loop
11
incremented x
12
Debugging Tools
• Interpretive Debuggers
– work by reading a program and simulating its
execution one line at a time.
• Direct Execution
– Faster
– More accurate, the actual program instructions are
being executed
Two Styles of Use
• Line-at-a-time
– A programmer loads the program into the debugger
and “steps” through the program one line at a time.
– The debugger stops the program after each line and
gives the programmer a chance to check the
program’s variables to see if it is operating correctly.
Two Styles of Use (2)
• Breakpoints
– A Programmer loads a program into the debugger
and specifies “breakpoints” at various locations in
the program.
– The program runs until it hits a breakpoint.
How are Breakpoints Useful?
• If you think you have function that might have a fault.
– Set a breakpoint at the beginning of the function.
– Set another breakpoint at the end of the function.
– If a program’s data is correct at the beginning of the
function but incorrect at the end, then there is a fault in
the function.
– They also allow you to skip over “init” code and
debugged code quickly; letting the programmer focus
on finding the fault.
Editing Variables