Debug App
The following tutorial uses the linglong-builder-demo project mentioned in the "Building Tools" section as an example. We put the project in /path/to/project. Make sure to replace the path when referring to this tutorial.
Since the Linglong application runs in a container, we need to use gdbserver to run the application in the container to debug it on the host. So you'll need to install gdbserver first.
We can use the gdbserver provided by the distribution, using apt as an example:
sudo apt install gdbserver gdb -yNext, refer to the tutorial in "Run compiled App", run bash in the container through the ll-build run command, and run the application to be debugged through gdbserver:
ll-build run --exec /bin/bash
# In the container:
gdbserver:10240 deepin-drawIn the above command, :10240 is any tcp port that is not currently occupied. Then we need to do two more things:
- Use
gdboutside the container to connect to thegdbserverin the container; - Set the source map path.
Debugging with gdb in terminal
Find the location of the executable file executed in the container on the host. For the above project, the file is located in
/path/to/project/.linglong-target/overlayfs/up/opt/apps/org.deepin. demo/files/bin/demo.For applications installed via
ll-cli, the executables are generally located under$LINGLONG_ROOT/layers/[appid]/[version]/[arch]/files/bin.Use
gdbto load the program outside the container:bashgdb /path/to/project/.linglong-target/overlayfs/up/opt/apps/org.deepin.demo/files/bin/demoUse the
targetcommand ingdbto connect to thegdbserveras follows:bashtarget remote :10240Enter the following command in
gdbto set the path mapping and helpgdbto find the corresponding source code, assuming the source code is placed in theDesktopof the host, the command is as follows:bashset substitute-path /source /path/to/project
Then just use gdb normally.
QtCreator configuration
Referring to the above process, we can easily complete the configuration of QtCreator:
Click: Debug > Start Debugging > Connect to the Running Debug Server, and fill in the dialog box:
Server port: `10240`
Local executable file: `/path/to/project/.linglong-target/overlayfs/up/opt/apps/org.deepin.demo/files/bin/demo`
Init Commands: `set substitute-path /source /path/to/project`The general configuration is shown in the following figure:

After the configuration is complete, you can use QtCreator to debug normally.