增加资料。

Signed-off-by: rick.chan <cy@haoan119.com>
This commit is contained in:
rick.chan 2024-08-01 10:37:43 +08:00
parent a43055451a
commit 3a2f0d4c2e
3 changed files with 63 additions and 0 deletions

View File

@ -0,0 +1,63 @@
# [Qt Remote Debug](https://doc.qt.io/qtvstools/qtvstools-how-to-debug-on-linux.html)
Set up Qt VS Tools for cross-compilation on Linux, to debug applications running on Linux devices. First launch the application using gdbserver and then configure GDB to connect to the device and start a remote debugging session.
![qtvstools-remote-debugging](./img/Qt_Remote_Debug/qtvstools-remote-debugging.jpg)
For this to work, the GDB installed in the WSL must support the target device architecture. A simple way to achieve this is to install gdb-multiarch. To ensure that Visual Studio uses the correct debugger, create a symbolic link from gdb to gdb-multiarch.
## Set up remote debugging
To set up the remote debugging session in Visual Studio, you must pass additional commands to GDB:
1. Select a project in the Solution Explorer.
2. Go to Project > Properties > Configuration Properties > Debugging.
![qtvstools-project-properties-debugging](./img/Qt_Remote_Debug/qtvstools-project-properties-debugging.webp)
3. In Debugger to launch, select GDB Debugger.
4. In Additional Debugger Commands, add the following commands:
```bash
target extended-remote <IP_address>:<port>
set remote exec-file <path_to_executable>
```
## Set environment variables
Before starting the remote debugging session:
1. Set the required environment variables:
- LD_LIBRARY_PATH specifies the path to the directory where you installed Qt binaries.
- QT_QPA_PLATFORM specifies the platform plugin, such as EGLFS, LinuxFB, DirectFB, or Wayland
- QT_QPA_PLATFORM_PLUGIN_PATH specifies the path to the directory where you installed the platform plugin.
- For the EGLFS platform, QT_QPA_EGLFS_PHYSICAL_WIDTH and QT_QPA_EGLFS_PHYSICAL_HEIGHT specify the screen width and height in millimeters.
- QML2_IMPORT_PATH specifies the path to the directory where you installed QML modules.
2. Launch gdbserver on the device.
## Start remote debugging
Press F5 to start the remote debugging session.
## Set up debugging on Linux devices
To debug Qt Quick applications on Linux devices:
1. Enable QML debugging for the project.
2. Go to Project > Properties > Configuration Properties > Debugging to set up program arguments for starting a QML debugging session.
3. In Debugger to launch, select GDB Debugger.
4. In Additional Debugger Commands, add the following command:
```bash
-qmljsdebugger=port:<port>,host:<IP_address>,block
```
See also Tutorial:
- [Qt Quick debugging](https://doc.qt.io/qtvstools/qtvstools-tutorial-debug-qt-quick.html)
- [Cross-compile](https://doc.qt.io/qtvstools/qtvstools-how-to-cross-compile.html)
- [Debug applications](https://doc.qt.io/qtvstools/qtvstools-how-to-debug-apps.html)
- [Enable QML debugging](https://doc.qt.io/qtvstools/qtvstools-how-to-enable-qml-debugging.html)
- [Debugging Qt Quick applications](https://doc.qt.io/qtvstools/qtvstools-explanation-debugging-qt-quick.html)

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB