Here, we document tips, tricks, and good practices for debugging RCE. Since RCE is written in Java, many of the standard good practices for debugging Java code apply to debugging RCE as well, such as getting comfortable with the debugger integrated in Eclipse. As there are good general-purpose tutorials out there, our aim in this section is not to repeat already existing general advice. Instead, we discuss tools and techniques that experience shows are not as well known.
Recall that SWT resources (such as Composite, Button, or
Label) are not cleaned up completely by the garbage collector. Instead,
they must be manually cleaned up by the developer via their dispose method
(cf. this
article for more information on managing SWT objects). Since this behavior
differs from virtually all other Java objects, it is easy for developers to overlook
this cleanup. This leads to "leaked" SWT resources, i.e., to resources that are created,
but never disposed of afterwards.
S-Leak is a tool that aids in finding leaked SWT resources. It allows developers to take snapshots of the currently allocated SWT resources and to create the diff between two such snapshots. Thus, the developer can determine which resources have been allocated during certain user actions and compare these allocations with their expectations.
In order to use S-Leak, you have to start RCE with the system property
rce.debug.sleak defined. When starting RCE via Eclipse, you can do so
by editing your preferred run configuration (Run -> Run Configurations
-> Arguments -> VM Arguments -> Add
-Drce.debug.sleak). When starting RCE as a standalone application, edit
the file rce.ini to include the line -Drce.debug.sleak at some
point after -vmargs. The class
de.rcenvironment.core.start.gui.GUIInstanceRunner interprets this
system property and starts S-Leak during startup of RCE.
When developing GUIs using Eclipse SWT, one often wants to have more information about how the GUI of the running software is composed and what properties are set. One of the tools giving such an overview is SWT spy (https://eclipsesource.com/de/blogs/2018/01/10/swt-spy-debugging-swt-layouts/). In order to use this tool to debug the GUI of RCE started from Eclipse, follow these steps:
Add the plug-in "SWT Tools" available from https://download.eclipse.org/eclipse/updates/4.7/ to the target
platform
(de.rcenvironment/eclipse/tp/remote/default_release_or_snapshot.target
-> Add -> Software Site -> Work with
https://download.eclipse.org/eclipse/updates/4.7/
-> Check the plug-in "SWT Tools", located in the folder
"Eclipse Tests, Tools, Examples and Extras" -> Finish). We show
the wizard for adding this plug-in below.
Reload the target platform.
Add the newly available feature org.eclipse.swt.tools.feature to the product
definition of RCE
(de.rcenvironment/maven/modules/repository.mainProduct/rce_default.product
-> Contents -> Add).

After rebuilding and restarting RCE from Eclipse, you should now have the view "SWT Spy"
available in RCE. When clicking the spy-icon in its upper menu bar, this view will show
information about the SWT construct that the cursor is currently pointing at. Using the
shortcut Ctrl+Alt+Shift+. you can toggle the SWT spy to keep the
information about the currently selected element in the view of the SWT spy to allow for
further investigation about the information.