Eclipse

Eclipse is an Integrated Development Environment that can be used for C and C++ development and debugging. The default debugger is GDB, but this can be replaced with UndoDB to allow reversible debugging.

This section of the user guide describes the steps that are required in order to use UndoDB in Eclipse in the following contexts:

Compatible versions

UndoDB is known to work well with a compatible with a number of Eclipse versions, including Mars (4.5.1), Luna (4.4.2) and 3.8.1, and is likely to work with other versions too. The following instructions are written for Eclipse Mars (4.5.1), and some minor adjustment may be required for different Eclipse versions.

First steps

In all debugging scenarios, the following steps are required in order to enable reverse debugging buttons in the Eclipse GUI:

  1. Choose Window -> Perspective -> Customize Perspective...

    _images/eclipse9.png
  2. Choose the Action Set Availability sub-tab and check the Reverse Debugging option on the left hand side (note that it may be grayed out, but it can still be checked). Then click OK.

    _images/eclipse10.png

Debugging a local target

  1. Enable the Eclipse reverse debugging buttons as explained in First steps

  2. Open Debug configurations...

    _images/eclipse0.png
  3. Choose C/C++ Application from the left hand side.

  4. Choose the Debugger tab and enter the path to udb in the GDB Debugger box. Check the Enable Reverse Debugging at startup check box.

    _images/eclipse6.png
  5. Click Debug to start the debug session.

  6. Eclipse will stop at the beginning of main. The target can be debugged normally, including with reverse operations that are available as buttons on the toolbar.

    _images/eclipse8.png

Debugging a remote target

  1. Enable the Eclipse reverse debugging buttons as explained in First steps

  2. Copy the UndoDB remote server files onto the remote target, e.g.

    scp key undodb-server_armhf user@board:
    

    Note that the server binary (undodb-server_armhf in the above example) must match the architecture of the remote machine and that both files must be in the same directory or undodb-server_<arch> will be unable to find the key.

  3. Open Debug configurations...

    _images/eclipse0.png
  4. Choose C/C++ Remote Application from the left hand side and click the New button.

    _images/eclipse1.png
  5. Click the New button next to Connection.

    _images/eclipse2.png
  6. Choose SSH Only and click Next.

    _images/eclipse3.png
  7. Put the IP address of the remote system into the Host Name: box and give the connection a name.

    _images/eclipse4.png
  8. Continue pressing Next, then Finish.

  9. Make sure the new connection is selected in the Connection: drop down.

  10. Specify a valid destination path for the binary on the remote machine in the Remote Absolute File Path for C/C++ Application: box.

    _images/eclipse5.png
  11. Choose the Debugger tab and fill in the path to udb on the host machine (i.e. the machine running Eclipse) in the GDB Debugger box. Check the Enable Reverse Debugging at startup check box.

    _images/eclipse6.png
  12. Choose the Gdbserver Settings sub-tab and put the remote machine’s path to undodb-server_<arch> in the Gdbserver path box.

    _images/eclipse7.png
  13. Click Debug then (if required) fill in the remote user and password in the SSH box that appears.

  14. The binary will be copied to the remote machine and started with undodb-server. Eclipse will stop at the beginning of main. The target can now be debugged normally, including with reverse operations that are available as buttons on the toolbar.

    _images/eclipse8.png

Replaying Undo Recordings

Undo Recordings can be replayed in Eclipse with the use of a remote undodb-server instance.

If the recording was created on a foreign CPU architecture, e.g. ARM, then it must be replayed through a remote session on a device matching that architecture.

If the recording was created on a machine with the same CPU architecutre as that of the machine running Eclipse, the recording can be replayed on the local host but a remote debugging configuration is still required in Eclipse.

Note

Make sure the binary being recorded is the one compiled by Eclipse. On replay, Eclipse will issue a gdb file command with that binary, and if it doesn’t match the binary used to make the recording, no source code or function names will be displayed.

To configure Eclipse to replay recordings, follow the steps in Debugging a remote target, with the following additional steps:

  1. Write a wrapper script on the remote machine that starts the right undodb-server (see above) with the recording you’ve just made, and uses the port number that Eclipse will pass through:

    #!/bin/bash
    ./undodb-server_<arch> --eclipse-port $1 --load-file <recording>.undo
    

    The architecture of the undodb-server instance (represented by <arch>) must match the architecture of the machine on which the recording was originally created.

    Note

    Eclipse passes some additional arguments to the script containing the binary being replayed and any specified arguments, but these can safely be ignored because the binary and the arguments used during recording are contained in the recording file.

  2. Change the path in the Gdbserver path box so that it points to the wrapper script on the remote machine.

    _images/eclipselr1.png
  3. Start the debug session.

Note that when replaying a foreign-architecture recording (e.g. ARM), the following additional steps are required:

  1. Write a gdbinit script on the host machine that specifies the architecture of the remote machine. It should contain the following text:

    set architecture arm
    
  2. Tell Eclipse to run that file by adjusting the debug configuration set up previously so that its name is in the GDB Command file: box

    _images/eclipselr0.png

Troubleshooting

If you encounter any problems when using UndoDB in Eclipse, the following information may be helpful.

If Eclipse displays the error Error during file upload. Missing element for : '' it might mean that either the source or the destination of the scp of the binary to the remote machine is invalid. Check that the contents of the Remote Absolute File Path for C/C++ Application: contain a valid absolute path on the remote machine. It may also be required to fully specify an absolute path to the source binary (on the machine running Eclipse) in the C/C++ Application box of the same dialog.

The message Operation failed. File system input or output error indicates that the SSH connection to the remote machine has either closed or has become confused in some way. This can be corrected by forcing a disconnect. Find the Remote Systems panel. You may have to choose Window -> Show View -> Other...

_images/eclipse11.png

then type “remote” into the filter box and select Remote Systems.

_images/eclipse12.png

Choose the right connection from the connection list and choose Disconnect

_images/eclipse13.png

then restart the debug session by clicking the Debug button on the Debug configurations dialog.

The following message:

Session.connect: java.security.InvalidAlgorithmParameterException: Prime size must be multiple of 64, and can only range from 512 to 1024 (inclusive)

means that your Java Virtual Machine (JVM) is too old. Upgrade to at least 1.8.0.

If GDB prints messages about lack of XML support, or not in executable format: File format is ambiguous, the host GDB can’t understand the architecture of the remote machine. You may have to specify an alternative gdb by passing the --undodb-gdb-exe option to udb.

_images/eclipse14.png

If Eclipse says

Could not determine GDB version using command: udb --version

It might mean that you have not copied the key file onto the target.