GNU Smalltalk 80 Debugger. How to debug smallcode code ? Start Debugger?
Asked Answered
M

2

6

In GNU Smalltalk 80 it is possible to write smalltalk code in your own plain text editor of personal choice.

Therefore, it is very important to debug the code.

First you save the file as txt File. Then you open the file from the programmers text editor with the "Tools". Here the tool - link C/programme/GNU/gnu smalltalk/gst.exe. The code is running. The debug option is not included. Under these circumstances programming is not possible. There must be a "debug" option to activate.

My question is: how to include that debug option? Normally the smalltalk code is debugged first.

Maynard answered 26/8, 2015 at 15:49 Comment(5)
Writing smalltalk code is mostly done in the debugger, and therefore not in a file based text editor. Using a text editor is so much less productive, that it is only done if absolutely necessary.Sight
Hello Nathaniel , let us assume that i "dont care about in what system the smalltalk 80 is involved". I only want to write code and then structure it in my OWN manner. How about that ?Maynard
Then you'll never get smalltalkSight
It's unclear to me what you're actually doing. What platform? (Windows or Linux?) What program(s) exactly are you using when you say, you open the file from the programmers text editor with the "Tools"? Are you trying to use a 3rd party IDE? I don't know what you mean by, link C/programme/GNU/gnu smalltalk/gst.exe.Router
Its easy. Very easy.Maynard
A
2

GNU Smalltalk includes tools for debugging. It implements a Debugger class as mentioned in Smalltalk 80: the language within DebugTool.st. Other classes mentioned alongside Debugger are not necessarily implemented, perhaps because they relate to GUI operations.

Instead, GNU Smalltalk provides the MiniDebug command line debugger for use with GNU Smalltalk or when the IDE is not available. It is more or less a rudimentary subset of GDB.

Loading MiniDebugger

A simple way to use it is read the file into gst:

$ gst
GNU Smalltalk ready

st> FileStream fileIn: '/usr/share/gnu-smalltalk/examples/MiniDebugger.st'
"Global garbage collection... done"
Loading package DebugTools
FileStream
st>

Note that the location of MiniDebugger.st is typical for Ubuntu 16.04. Other operating systems may put the file in a different place.

MiniDebugger Hello World

A hello world example of the MiniDebugger is:

st> self halt
'nil error: halt encountered'
Halt(Exception)>>signal (ExcHandling.st:254)
Halt(Exception)>>signal: (ExcHandling.st:264)
UndefinedObject(Object)>>halt: (SysExcept.st:1464)
UndefinedObject(Object)>>halt (Object.st:1325)
UndefinedObject>>executeStatements (a String:1)
      6         ^self activateHandler: (onDoBlock isNil and: [ self isResumable ])
(debug) c
st>

The entry of c at the (debug) prompt is for 'continue'. Other options will be displayed by typing h (or any other invalid command).

Making a Debugging Image

Once MiniDebugger is loaded into a gst REPL, an image containing the debugger can be created:

st> ObjectMemory snapshot: 'myDebuggerImage.im'

and later reloaded when starting gst (this assumes 'myDebuggerImage.im' is located in the current directory or in another place gst looks by default):

$ gst -I myDebuggerImage.im 

Setting a Breakpoint

The MiniDebugger will then appear any time the control flow encounters Object:halt. For example if I have the file:

"Halter.st"
Object subclass: Halter [
  breakpoint [
    self halt.
  ]
]

Then:

st> h := Halter new
a Halter
st> h breakpoint
'a Halter error: halt encountered'
...
(debug)
Asthma answered 18/8, 2017 at 19:5 Comment(0)
S
0

Different smalltalks target different user groups. For learning smalltalk, GNU is a bad choice. Smalltalk is a very simple language with a very large library and a really integrated development environment. Your preference in text editor is not important for this phase (and as you might find, nor any other). You will spend much more time reading and navigating code than typing in new code or changing existing code. Squeak and Pharo are two open source implementations with decent browsers and debuggers

Sight answered 25/3, 2017 at 11:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.