Smalltalk is a powerful environment for software developing. It allows the development of high-level abstractions, and it is highly dynamic and reflective, which promotes analyzing and changing objects at run-time. Debuggers are essential tools, particularly in Smalltalk because they allow developers to understand a program as well as to find and fix defects as they are running.
Debugging native applications, on the other hand, is very hard. Many native applications can't be developed using high level abstractions. Furthermore, as they consist of native- code, debugging them requires understanding and modification of very low-level operations on raw memory at run-time 1, and also a close interaction with the operating system 23.
Using Smalltalk to control and debug low-level code would be a great aid in the native-code development process. It would allow not only to control programs status and trace, but also to easily develop a myriad ofhigh-level tools that analyze and modify native-code as it runs.
Technical Details:
There are many different kinds of debuggers, and many mechanisms are already mature for implementing features in them 4. Warp5 is a recently born project to implement on Pharo a wrapper for the PTrace system call, the essential operating system debugging API. With the addition of already existing powerful high-level tools for low-level programming, as NativeBoost 6 and Waterfall 7, this project will allow to have a native debugger interface for any process from a Smalltalk image, and create a complete ecosystem for Native- Code developing from Smalltalk.
The first steps will include understanding the ptrace system call, and about x86 instructions coding and decoding. This can be done by completing the wrapper of ptrace, which consists of only one function with many different functionalities and improving the disassembler for x86 binary code. After this the student will be able to develop tools for aiding in native-code debugging, like a specialized inspectors and debuggers for watching the value of variables, adding breakpoints, watchpoints, modifying memory andcode.
Benefits to the Student:
* gain experience in high-level and low-level programming.
* learn about how debuggers work under the hood
* gain experience on the usage and development of a complete Smalltalk native-code development toolchain.
* learn about native-code assembling and disassembling
Benefits to the Community:
* Lately, there has been more and more evidence that high-level written software for low-level development is starting to succeed. Smalltalk provides an ideal platform for exploring this domain because of its powerful reflective capabilities. NativeBoost already promotes lot of new possibilities for working dynamically on the Pharo environment with complex low-level tasks. More tools for having a complete and outstanding tool-chain are needed and the native debugging interface is one of the most prominent and promising.
* A native-code debugger will help Smalltalk VM and low-level programmers, because it will leverage all their Smalltalk programming skills into low-level programming. It could even bring closer non-VM programmers to VM code, as it would remove a barrier of entrance to VM programming.
* Having a fully working native-code debugger would be a killer app that can attract lots of low-level developers to Smalltalk, specially Virtual Machine and C/C++ programmers.
4 How debuggers work: algorithms, data structures, and architecture, Jonathan B. Rosenberg, ISBN: 0-471-14966-7
|