简体   繁体   English

GNU Smalltalk 80调试器。 如何调试小码代码? 启动调试器?

[英]GNU Smalltalk 80 Debugger. How to debug smallcode code ? Start Debugger?

In GNU Smalltalk 80 it is possible to write smalltalk code in your own plain text editor of personal choice. 在GNU Smalltalk 80中,可以在您自己选择的纯文本编辑器中编写smalltalk代码。

Therefore, it is very important to debug the code. 因此,调试代码非常重要。

First you save the file as txt File. 首先将文件保存为txt文件。 Then you open the file from the programmers text editor with the "Tools". 然后使用“工具”从程序员文本编辑器中打开该文件。 Here the tool - link C/programme/GNU/gnu smalltalk/gst.exe. 这里的工具 - 链接C / program / 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. 通常,首先调试smalltalk代码。

GNU Smalltalk includes tools for debugging. GNU Smalltalk包含用于调试的工具。 It implements a Debugger class as mentioned in Smalltalk 80: the language within DebugTool.st . 它实现了Smalltalk 80中提到的Debugger DebugTool.st 的语言 Other classes mentioned alongside Debugger are not necessarily implemented, perhaps because they relate to GUI operations. Debugger旁边提到的其他类不一定是实现的,可能是因为它们与GUI操作有关。

Instead, GNU Smalltalk provides the MiniDebug command line debugger for use with GNU Smalltalk or when the IDE is not available. 相反,GNU Smalltalk提供了与GNU Smalltalk一起使用的MiniDebug命令行调试器,或者当IDE不可用时。 It is more or less a rudimentary subset of GDB. 它或多或少是GDB的基本子集。

Loading MiniDebugger 正在加载MiniDebugger

A simple way to use it is read the file into gst: 一个简单的使用方法是将文件读入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. 请注意, MiniDebugger.st的位置是Ubuntu 16.04的典型位置。 Other operating systems may put the file in a different place. 其他操作系统可能会将文件放在不同的位置。

MiniDebugger Hello World MiniDebugger Hello World

A hello world example of the MiniDebugger is: MiniDebugger的一个问候世界的例子是:

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'. (debug)提示符处输入c表示“继续”。 Other options will be displayed by typing h (or any other invalid command). 键入h (或任何其他无效命令)将显示其他选项。

Making a Debugging Image 制作调试图像

Once MiniDebugger is loaded into a gst REPL, an image containing the debugger can be created: 将MiniDebugger加载到gst REPL后,可以创建包含调试器的图像:

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时重新加载(这假设'myDebuggerImage.im'位于当前目录中或默认情况下gst看起来在另一个地方):

$ gst -I myDebuggerImage.im 

Setting a Breakpoint 设置断点

The MiniDebugger will then appear any time the control flow encounters Object:halt . 每当控制流遇到Object:halt时,MiniDebugger就会出现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)

Different smalltalks target different user groups. 不同的小方块针对不同的用户组。 For learning smalltalk, GNU is a bad choice. 对于学习smalltalk,GNU是一个糟糕的选择。 Smalltalk is a very simple language with a very large library and a really integrated development environment. Smalltalk是一种非常简单的语言,具有非常大的库和真正集成的开发环境。 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 Squeak和Pharo是两个开源实现,具有不错的浏览器和调试器

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM