Emacs Extensions for
GE Smallworld Magik Development
Screen-casts, tutorials, and productivity tools for Magik programmers who use Emacs. From tab-mode and code folding to the Magik Debugger and object inspector — explore features built by a developer, for developers.
Learn MoreNine screen-casts published between November 2010 and January 2011 — covering everything from ECB mode to the Tree Item GUI control. Read the story behind the project →
Get in Touch
Magik’s debugger meets Emacs RealGUD
Smallworld applications often fail in ways ordinary unit tests miss: a method resolves against the wrong collection class, a transaction sees stale data, or a workspace interaction changes the path through the code. Magik’s built-in debugger understands these language-level events, while Emacs offers the editing, source navigation and inspection workflow many developers already know.
Magik’s debugger is the semantic layer: it knows about method dispatch, transactions, collections and workspace objects. RealGUD is the interaction layer: it renders a debugger session as Emacs buffers and gives commands a consistent graphical front end. Treating them as separate layers prevents a familiar GDB display from being mistaken for native understanding of every Magik value.
A practical integration usually needs a small bridge that translates session events between the Magik runtime and the protocol RealGUD expects. That bridge can expose breakpoints, stack frames, stepping actions and variable expressions without forcing RealGUD to become a Smallworld object browser. The result is a repeatable debugging loop that remains inside Emacs.
The workflow is especially useful for application code, collection browsing and database-aware investigations. It still needs discipline around permissions, transactions and sensitive records because an interactive session can expose more than a failing test. The following setup treats RealGUD as a dependable front end to a language-aware debugging core.
Separate the debugger’s jobs
Start by assigning each component a clear responsibility. The Magik debugger should execute and evaluate Magik code, report the active method and stack, and retain knowledge of Smallworld-specific semantics. RealGUD should provide the session buffer, graphical breakpoints, frame selection, watch expressions and Emacs-native source navigation.
The Magik side should remain authoritative for values that GDB cannot interpret directly. A Smallworld object, collection or transaction state needs a stable textual representation before it can be shown in a variable pane. Trying to force those values through a native pointer display produces noise and can conceal the information needed to diagnose the fault.
RealGUD adds useful interaction patterns without replacing the debugger. Its graph-oriented views make it easier to move between source locations, call frames and inspected values. When the adapter reports logical Magik source locations rather than machine addresses, developers can navigate directly to the relevant method in Emacs.
Build a reproducible environment
Check the versions before connecting anything. The Emacs release, RealGUD package, adapter, Magik runtime and Smallworld image must agree on source paths and protocol expectations. RealGUD normally works with a GDB-compatible debugger, so confirm whether the Magik debugger exposes GDB/MI output directly or needs a translation service.
Keep the Smallworld image, application code and debug adapter together in a controlled workspace. Record the image build, loaded modules and source root in a launch script or project configuration. Absolute paths can prevent intermittent failures, while relative paths make a session portable between a developer’s workstation and a shared test host.
Prepare a dedicated environment with the same database permissions and collection visibility required by the defect. A debugger that cannot open the relevant collection may appear to work while silently omitting the failing state. Reproduce the issue against a disposable or reset transaction, and capture the launch options, workspace identifier, user role and relevant environment settings alongside the first session transcript.
Configure the RealGUD connection
Install RealGUD from a configured Emacs package archive, then load it with use-package or require. The integration depends on realgud being available before commands such as realgud and realgud-gdb are invoked. Package installation alone does not connect Emacs to Smallworld; it only supplies the debugger interface.
The bridge must translate commands and asynchronous events in both directions. Breakpoint requests, continuation, stepping and frame selection travel toward the Magik debugger, while acknowledgements, stop locations, stack frames, variable scopes and evaluation results return as structured events. A thin adapter based on GDB/MI is a practical option when RealGUD already understands that protocol.
An illustrative Emacs configuration might look like this:
(use-package realgud
:ensure t
:commands (realgud realgud-gdb)
:init
(setq realgud-program "magik-debug-adapter")
(setq realgud-extra-args
'("--interpreter=mi2"
"--workspace=/work/smallworld")))
The arguments depend on the adapter contract, so treat this as a starting configuration rather than a universal command line. Restrict the adapter’s filesystem and network permissions, and avoid placing passwords, access tokens or customer identifiers directly in its arguments.
Source mapping needs particular care. The adapter should translate a loaded Magik method into a file and line that Emacs can open, then return that same identity when execution stops. Test the mapping with a method containing nested calls and one located in a module outside the current working directory. Any mismatch will make a correct breakpoint appear ineffective.
Work through a Magik debugging session
Begin with a narrow reproduction and a breakpoint in the .magik source. Once the adapter reports the stop, select the relevant stack frame in RealGUD and inspect its local scopes. Variables should be labelled by Magik meaning, including the receiver, method arguments and relevant collection references, instead of being exposed as unexplained memory addresses.
Map each RealGUD action to the corresponding Magik debugger operation. Continuing should resume the current process, while stepping into and over should follow Magik method boundaries. Frame selection must update the active context before a variable request is evaluated; otherwise values from the wrong receiver or transaction can appear in the inspection pane.
Watch expressions are valuable for collection size, method return values and changing transaction fields. Keep each expression small and deterministic. A request that renders an entire collection can stall the session or consume substantial memory, so the adapter should expose counts, keys, selected members and bounded previews rather than complete object graphs. The built-in Magik object inspector remains valuable for deeper investigation.
Compare the available workflows
The Magik debugger, RealGUD alone and the combined workflow solve different problems. Choosing the right combination depends on whether the investigation concerns Magik semantics, a native runtime failure or the broader Smallworld application.
| Workflow | Runtime authority | Interaction model | Strongest use | Main constraint |
|---|---|---|---|---|
| Magik debugger only | Magik runtime and workspace | Terminal prompts and language-specific output | Isolated language and collection investigation | Less integrated with Emacs navigation |
| RealGUD with a native backend | GDB and native process state | Graphical Emacs session | Native crashes, stack traces and low-level inspection | Limited Smallworld semantics without translation |
| Magik debugger through RealGUD | Magik debugger plus adapter | Graphical Emacs session with translated values | Application debugging, stepping and source inspection | The adapter must maintain accurate mappings |
This division keeps each tool accountable for the information it understands best. RealGUD becomes most useful when the adapter preserves Magik semantics, while the underlying debugger remains responsible for execution, transactions and object state.
Adapt the workflow for Australian teams
Australian development teams are often distributed across Sydney, Melbourne, Brisbane and Perth. A fault reproduced in Brisbane may pass to a colleague in Melbourne after a train commute or connect to a Perth specialist during a recorded call. Store adapter versions, breakpoint definitions and transcript excerpts in the shared workspace rather than relying on a live screen share or informal verbal handover.
Several Australian time zones and daylight-saving changes can move a breakpoint or database transaction across different local times. Put timestamps in UTC, state the workspace time zone in session notes and record whether a reproduction depends on wall-clock time. For an Australian resource-sector or geospatial customer, the relevant test image may also enforce restricted network access, so prepare an approved path to the adapter instead of disabling controls for convenience.
Where debugging data includes personal information from Australian clients, follow the Privacy Act 1988 and the Australian Privacy Principles. Minimise displayed fields, redact identifiers and restrict access to shared transcripts. An accidental disclosure may also engage the Notifiable Data Breaches scheme, so diagnostic tooling should be covered by the organisation’s data-handling and incident-response procedures.
Long investigations need human boundaries as well as technical ones. A proper break can restore attention, and this short break aside can serve as an optional external diversion between test runs. Keep production records outside the routine debugging path, and use synthetic or masked data whenever the defect does not depend on authentic customer content.
Troubleshoot, document, and put it into practice
When a session stalls, check the adapter process, protocol handshake, source mapping and database connection in that order. Confirm that the image is still running, that the breakpoint maps to a loaded method and that the user can access the required collection. A stale process or mismatched image can resemble a debugger defect, especially when method numbering changes between builds.
Keep a short launch recipe beside each integration project. Record the RealGUD configuration, adapter version, workspace setup, source root and a command that reproduces the failing case. Save the smallest useful transcript, redact sensitive values and record any transaction rollback required during inspection. This makes the session reproducible for another developer rather than dependent on the original author’s memory.
Install RealGUD in a disposable development workspace, connect it to one failing Magik method and measure the time from breakpoint to verified diagnosis. Keep the adapter, source mapping and launch options under version control, then explore the Magik Emacs tutorials and screencasts for related productivity workflows. HydePark Consulting can also assess an existing debugger setup and help teams turn a successful pilot into a documented, repeatable Magik debugging process.
Core Features
Tab Mode & ECB
Quick tab switching and Emacs Code Browsing mode for navigating Magik codebases efficiently.
Magik Smeller
Code analysis tool that helps identify potential issues in Magik source files.
Code Folding
Hide/Show mode for collapsing and expanding Magik code blocks to focus on what matters.
Visual Bookmarks
Quick visual bookmarks for jumping between key locations in your Smallworld session buffers.
Object Inspector
Inspect Magik objects and display them in an Emacs Deep Print buffer for detailed examination.
Magik Debugger
Set breakpoints and monitor slots and variables directly from within Emacs.
Development Tools
Direct links between Emacs and the Smallworld Development Tools application, including Click Monitor.
Screen-casts & Tutorials
Screen-cast 1: Tab Mode, ECB & More
Covers tab-mode, ECB, Magik Smeller, code folding, visual bookmarks, pragma toggling, moving code, external editor, and MS Explorer.
Screen-cast 5: Object Inspection & Deep Print
Inspect a Magik object, prompt for an expression evaluated within a Smallworld session, and display results in a Deep Print buffer.
Screen-cast 7: Magik Debugger
Useful tools for application developers: Object Inspector and Magik Debugger with breakpoints and slot/variable monitoring.
Screen-cast 9: Tree Item GUI Control
Tree Item is a GUI control providing extensive facilities for displaying lists with rows, columns, trees, and in-place editing.