Time for action – debugging the platform

To debug the platform, make sure that at least one plug-in project is open and that it depends on the plug-ins that need to be debugged. This allows the editor to be opened for any of the classes for debugging.

  1. Ensure that a plug-in that uses the Eclipse UI is open in the workspace, such as com.packtpub.e4.hello.ui or com.packtpub.e4.clock.ui. This will ensure that the platform classes are available.
  2. Use the Navigate | Open Type menu or press Ctrl + Shift + T (Cmd + Shift + T on macOS) to open the Open Type search dialog. Type in Shell and select the Shell from the org.eclipse.swt.widgets package. Double-click or click on OK to open the file.

    Tip

    If the source code isn't shown, verify that the Eclipse Platform Plug-in Developer Resources plug-in has been installed and that there is an open plug-in project that depends on org.eclipse.ui or org.eclipse.swt. If the Open Type menu isn't shown, switch to the Java perspective or the Java Browsing perspective to enable it, or open a Java source file.

  3. Go to the setText method and put a breakpoint in at the start of the method.
  4. Go to the Debug | Debug Configurations menu, and underneath the Eclipse Application, click on the new icon to create a new launch configuration. Ensure that the org.eclipse.sdk.ide product is selected in the Program to Run section:
    Time for action – debugging the platform
  5. Click on Debug to launch the Eclipse instance. It should stop at the breakpoint shortly afterwards, for the workspace chooser dialog with a title like Eclipse or Eclipse SDK or for the main platform with Eclipse Platform.

What just happened?

Being able to understand Eclipse bugs and start to fix them requires being able to debug through the platform. This requires being able to see the source code and know how to be able to step through the code as it's executing.

When a class file is loaded in the debugger, or a file is opened through direct (or indirect) navigation, Eclipse tries to find the source code associated with the plug-in and show that instead. Each Jar on the project's classpath can have an associated Java Source Attachment or a Javadoc Location with it.

When PDE loads a project, the entries under the Plug-in Dependencies tab will show the dependencies for the project, and if the corresponding source plug-in is also installed and available in the workspace, then it will be wired up to both the Java Source Attachment and the Javadoc Location as well. As a result, when the class file is loaded, the source attachment will be searched for the corresponding file and will be shown automatically.

The title being set triggers the breakpoint in the Shell class (which is SWT's equivalent of a window). This call will be triggered from a number of different call paths; one way of understanding how Eclipse works is to put a breakpoint in a known location and see where it is being called.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.120.109