Remote Debugging
Remote Debugging
ESF natively supports a debugging modality that allows you to perform full code debugging through Eclipse.
With ESF 3.1.x, the debugging modality has been modified to increase the overall framework security. During debugging operations, the framework uses a backup snapshot folder that is separate from the ones used during normal execution. Also, the overall functionalities are reduced while debugging is enabled.
This section describes the steps needed to enable the debugging modality in the device and configure Eclipse to be able to connect to the device and perform the remote debugging.
Enable Device’s Remote Debugging
Remote debugging can be enabled through SSH access. To do so, first stop ESF by entering the following command:
/etc/init.d/monit stop
This command stops the monit service that is responsible for verifying the state of ESF and restarting it if the framework collapsed.
Next, enter the following command to effectively stop the ESF framework:
/etc/init.d/kura stop
To start ESF as a root user invoke the following script:
/opt/eurotech/esf/bin/start_kura_debug.sh
The script starts the ESF framework and opens port 8000 that is used by Eclipse to connect to the device. At the end of startup, the command line returns a Telnet prompt as shown below.
Listening for transport dt_socket at address: 8000 osgi>
At this prompt, you may enter the ss command to display a list of the installed bundles as shown below.
osgi> ss "Framework is launched." id State Bundle 0 ACTIVE org.eclipse.osgi_3.8.1.v20120830-144521 1 ACTIVE org.eclipse.equinox.cm_1.0.400.v20120522-1841 2 ACTIVE org.eclipse.equinox.common_3.6.100.v20120522-1841 3 ACTIVE org.eclipse.equinox.registry_3.5.200.v20120522-1841 4 ACTIVE org.eclipse.equinox.http.registry_1.1.200.v20120522-2049 5 ACTIVE org.eclipse.equinox.console_1.0.0.v20120522-1841 6 ACTIVE org.eclipse.equinox.ds_1.4.0.v20120522-1841 7 ACTIVE org.eclipse.equinox.event_1.2.200.v20120522-2049 8 ACTIVE org.eclipse.equinox.io_1.0.400.v20120522-2049 9 ACTIVE org.eclipse.equinox.metatype_1.2.0.v20120522-1841 10 ACTIVE org.eclipse.equinox.util_1.0.400.v20120522-2049 11 ACTIVE org.eclipse.osgi.services_3.3.100.v20120522-1822 12 ACTIVE org.eclipse.osgi.util_3.2.300.v20120522-1822 13 ACTIVE org.apache.felix.gogo.command_0.8.0.v201108120515 14 ACTIVE org.apache.felix.gogo.runtime_0.8.0.v201108120515 15 ACTIVE org.apache.felix.gogo.shell_0.8.0.v201110170705 16 ACTIVE org.knowhowlab.osgi.monitoradmin_1.0.2 17 ACTIVE org.apache.felix.dependencymanager_3.0.0 18 ACTIVE org.apache.felix.deploymentadmin_0.9.5 19 ACTIVE osgi.cmpn_4.3.0.201111022214
You may also may enter the ls command to display the status of the installed bundles as shown below.
osgi> ls All Components: ID State Component Name Located in bundle 1 Active org.eclipse.equinox.event org.eclipse.equinox.event(bid=7) 2 Active org.eclipse.kura.deployment.agent org.eclipse.kura.deployment.agent(bid=49) 3 Active org.eclipse.kura.data.DataService org.eclipse.kura.core(bid=51) 4 Active org.eclipse.kura.db.DbService org.eclipse.kura.core(bid=51) 5 Active org.eclipse.kura.core.data.transport.mqtt.MqttDataTransport org.eclipse.kura.core(bid=51) 6 Active org.eclipse.kura.ssl.SslManagerService org.eclipse.kura.core(bid=51) 7 Active org.eclipse.kura.system.SystemService org.eclipse.kura.core(bid=51) 8 Active org.eclipse.kura.system.SystemAdminService org.eclipse.kura.core(bid=51) 9 Active org.eclipse.kura.certificate.CertificatesService com.eurotech.framework.security.certificatesmanager(bid=52) 10 Active org.eclipse.kura.cloud.app.command.CommandCloudApp org.eclipse.kura.core.cloud(bid=53) 11 Active org.eclipse.kura.cloud.CloudCallService org.eclipse.kura.core.cloud(bid=53) 12 Active org.eclipse.kura.cloud.CloudService org.eclipse.kura.core.cloud(bid=53) 13 Active org.eclipse.kura.core.comm.CommConnectionFactory org.eclipse.kura.core.comm(bid=54) 14 Active org.eclipse.kura.configuration.ConfigurationService org.eclipse.kura.core.configuration(bid=55) 15 Active org.eclipse.kura.crypto.CryptoService org.eclipse.kura.core.crypto(bid=56) 16 Active org.eclipse.kura.core.deployment org.eclipse.kura.core.deployment(bid=57)
From the ESF Gateway Administration Console, you can modify the firewall rules to enable port 8000 that is used for debugging by selecting the Firewall option from the System area as shown in the screen capture that follows.
Finally, the bundle that is to be debugged must be installed on the device. At this point, debugging is enabled at the device level.
The next section explains how to setup Eclipse to start the remote debugging.
Enable Remote Debugging in Eclipse
To enable remote debugging in Eclipse, select the Debug panel and select Debug Configurations.
In the Debug Configurations window, right-click the Remote Java Application option and select New.
The Debug Configuration window provides the ability to specify the Project where the debugging has to be executed, the Connection Type, and the Connection Properties including the host address and the port where the device is listening.
Enter the configuration parameters as appropriate and select the Debug button. The Java Connector attempts to communicate with the specified device.
If the connection is successful, debugging starts as shown in the screen capture that follows.