25.2   Debugging HDevEngine from HDevelop

HDevEngine applications can be debugged remotely using HDevelop. The application must explicitly enable remote debugging itself. This will start a debug server, which accepts debug connections from HDevelop. How to attach to an application from HDevelop is described in the HDevelop User's Guide. The following sections describe remote debugging from the perspective of HDevEngine. Two of the supplied example programs illustrate how to deploy the debug server in an application:

25.2.1   Configuring the Debug Server

The debug server is configured using calls to HDevEngine::SetEngineAttribute. It is recommended to set up the debug server before starting it. For example, to set up a password:

private HDevEngine MyEngine = new HDevEngine();
MyEngine.SetEngineAttribute("debug_password", "mysecretpassword");

The following attributes are supported:

Attribute Default value Description

debug_port 57786 Specifies the port number of the socket where the debug server waits for incoming connections.
debug_password "" Specifying a password provides a basic layer of protection against misuse. For security reasons, it is highly recommended to always supply a password. If a password is set, it must be entered in HDevelop to allow the connection.
debug_wait_for_connection false If true, the engine switches into “stopped state” after starting the debug server (see below). This has the effect that any application thread that enters procedure execution via HDevEngine will stop on the first line of script code. This way, you can start debugging from the beginning of your code upon connecting from HDevelop.

25.2.2   Controlling the Debug Server

HDevEngine provides two member functions to start and stop the debug server.

MyEngine.StartDebugServer();
...
MyEngine.StopDebugServer();

Usually, HDevEngine executes HDevelop code continuously without any interruption. However, once the debug server has started, the execution of HDevelop code can be interrupted for debugging purposes.

There are multiple ways for HDevEngine to enter a stopped state. The first two are available through the API. They work regardless of whether HDevelop is actually attached. Please note that the only way to continue program execution is to actually attach HDevelop to the debug server and control the execution from there.

Other ways to stop the program execution are triggered only if HDevelop is attached to the debug server:

Regardless of the reason the stopped state is always global, i.e., other application threads will also stop when executing HDevelop code.

25.2.3   Security Implications

Like any remotely accessible server, careful attention must be paid in order to prevent unauthorized access to the debug server. Although the firewall must be configured to allow connections to the configured port, it is your responsibility to limit the access to authorized clients only.

As a minimal security measure, always set up a password for the debug server. Please note that the debug server itself provides no measures against brute-force or denial-of-service attacks.

Note the following if the debug server is running and no password is set:

Apart from the transmission of passwords, the communication between HDevelop and the debug server is not encrypted. Protected procedures are transmitted in their encrypted binary form. If you worry about other sensitive data like images, you should use a VPN (e.g., an SSH tunnel) when connecting from the outside to the local network.

25.2.4   Limitations

Further limitations of remote debugging from the HDevelop side are listed in the HDevelop User's Guide.