help-smalltalk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-smalltalk] How does one use the debugger?


From: Paolo Bonzini
Subject: Re: [Help-smalltalk] How does one use the debugger?
Date: Sat, 23 Oct 2010 13:54:01 +0200
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.9) Gecko/20100907 Fedora/3.1.3-1.fc13 Lightning/1.0b3pre Mnenhy/0.8.3 Thunderbird/3.1.3

On 10/23/2010 12:37 PM, Stephen wrote:
> Hi All,
> 
> Could someone give me a hint on how to use the debugger please.
> 
> I tried this to see what would happen..
| db a b |
a := b := 1.
db := Debugger on:
[a := 5.
b := 6.] newProcess.
a displayNl.
db step.
a displayNl.
> 
> However no change to a.

You are not waiting enough. :)

First of all, there is some book-keeping to do before starting the process,
so it will take 3 step invocations just to reach your block.  After that,
remember that variables in the REPL are actually globals so they have to go
through the hashed collection machinery.  Better to use "next".  For example:

db := Debugger on: ([ 'now do next' basicPrint.
a := 5.
b := 6 ] newProcess).
db step
db step
db step          "prints Object: 'now do next'"
db next
a                "prints 5"
b                "prints nil"
db step
db process suspendedContext "prints DeferredVariableBinding>>value:"
b                "prints nil"
db finish
b                "prints 6"

> In any case, the code above isn't interactive.

Yes, the Debugger class implements the tools to step through a controlled 
process, and to attach to a running process.

> Also found MiniDebugger which has menu options with exactly the 
> functions I want, and is interactive. Is this working (the code has old 
> formatting) and if so, how does one use it?

Just load it in the image with "gst -Kexamples/MiniDebugger.st -S".

$ gst -Kexamples/MiniDebugger.st -S
"Global garbage collection... done"
Loading package DebugTools
"Global garbage collection... done"
$ gst
st> self halt
Eval [ self halt. 100 factorial ]
'nil error: halt encountered'
Halt(Exception)>>signal (ExcHandling.st:254)
Halt(Exception)>>signal: (ExcHandling.st:264)
UndefinedObject(Object)>>halt: (SysExcept.st:1423)
UndefinedObject(Object)>>halt (Object.st:1325)
UndefinedObject>>executeStatements (a String:1)
      6         ^self activateHandler: (onDoBlock isNil and: [ self isResumable 
])
(debug) f 4
UndefinedObject>>executeStatements (a String:1)
      1 self halt. 100 factorial 
(debug) s
SmallInteger(Integer)>>factorial (Integer.st:246)
      1 factorial [
(debug) c
93326215443944152681699238856266700490715968264381621468592963895217599993229915608941463976156518286253697920827223758251185210916864000000000000000000000000


Paolo



reply via email to

[Prev in Thread] Current Thread [Next in Thread]