Presentation is loading. Please wait.

Presentation is loading. Please wait.

Ten debugging techniques. The execution process Execution proceeds in a standard series of steps Compute values of subexpressions first Then call value.

Similar presentations


Presentation on theme: "Ten debugging techniques. The execution process Execution proceeds in a standard series of steps Compute values of subexpressions first Then call value."— Presentation transcript:

1 ten debugging techniques

2 The execution process Execution proceeds in a standard series of steps Compute values of subexpressions first Then call value of first subexpression With values of other subexpressions as inputs The most important thing for the programming portion of this class is to learn the rules of execution [+ [× 2 a] (assuming a=7, b=8) b] Look up +  procedure Compute [× 2 a] Look up ×  procedure “Execute” 2  2 Look up a  7 Call the procedure with 2 and 7 as inputs Return 14 Look up b  8 Call procedure with 14 and 8 as inputs Return 22

3 The stack The system keeps track of its what it’s executing using a stack The stack holds the expressions and subexpressions being executed Each time it starts a new subexpression, it’s added to the stack Every time it finishes a subexpression, it’s removed Starting stack: [+ [× 2 a] b] Later: [× 2 a] [+ [× 2 a] b] Later: 14 [+ [× 2 a] b] Later: 22

4 Single-stepping You can watch the execution of an expression by using the “Execute 1 Step” command The system will display the stack after one step of execution Notice that it appears in the debugger window

5 Single-stepping Doing “Execute 1 Step” again, executes one more step and redisplays the stack You can type control-1 instead of selecting “Execute 1 Step” from the Execute menu

6 Single-stepping Lines in normal font are the expressions being executed Lines in boldface show the procedure calls Give the actual arguments being passed to the procedures

7 Single-stepping Lines that are just numbers are the outputs of procedure calls So the result of [× 2 a] was 14

8 Single-stepping Once the [× 2 a] subexpression has been executed We have the inputs for + And can call it

9 Single-stepping And get the final answer

10 Single-stepping FYI: You can’t execute a new command while single- stepping another Closing the debugger window aborts the current command

11 Handling errors Suppose we type: [define square [n → [× n n]]] [square box] We get an error And the debugger pops up

12 Handling errors Clicking the [explain] box will show you a general explanation of the type of error this is and its likely causes

13 Handling errors The title bar now shows the error message And the stack shows The exception that occurred And the current state of the stack when the error occurred (Note: we can’t single-step it anymore because the computation has failed)

14 Handling errors The procedure running is a call to × With the inputs:, and is the system’s way of saying The data object being passed as input is a procedure named name So we know that the × procedure was called with two procedures as its input But it needs numbers as its input

15 Handling errors Why is it getting called with procedures as arguments? Well, we can see the procedure was called as part of executing [× n n] Click on the [× n n] expression …

16 Handling errors Click on the [× n n] expression … … and it gives us the values of the local variables So n was set to the box procedure Now click the  to return to the stack

17 Handling errors We can also see that was an argument to square And the expression that called square was [square box] So the problem is that we passed a nonsensical argument to sqaure

18 Handling errors When you finish gathering information from the debugger Click the close box to remove it


Download ppt "Ten debugging techniques. The execution process Execution proceeds in a standard series of steps Compute values of subexpressions first Then call value."

Similar presentations


Ads by Google