# Perform remote GDB debugging Source: [https://docs.qualcomm.com/doc/80-88500-3/topic/79_Perform_remote_GDB_debugging_.html](https://docs.qualcomm.com/doc/80-88500-3/topic/79_Perform_remote_GDB_debugging_.html) The images generated by `qti-console-image` are equipped to enable remote debugging using GDB. ## Linux Ubuntu After successfully building an HLOS debug build image, the qti-ubuntu-robotics-image-qrb5165-rb5-sysfs.ext4 system image is displayed on the host machine. To start remote GDB debugging, do the following: 1. Set up the debug directory on the host system by running the following commands: 1. To mount system.img, understand the type of partition. If the partition is an Android sparse image, then unsparse it before mounting. Check whether the system.img is an Android sparse image as follows. file qti-Ubuntu-robotics-image-qrb5165-rb5-sysfs.ext4Copy to clipboard qti-Ubuntu-robotics-image-qrb5165-rb5-sysfs.ext4: Android sparse image, version: 1.0, Total: 8192000 4096‑byte output blocks in 11950 input chunks. 2. Run the following command to convert sparse image to raw image. simg2img qti-Ubuntu-robotics-image-qrb5165-rb5-sysfs.ext4 system_raw.imgCopy to clipboard 3. Mount system\_raw.img. mkdir data sudo mount system_raw.img dataCopy to clipboard 4. Unmount the system\_raw.img. sudo umount dataCopy to clipboard 2. Set up the ADB port forwarding by running the following command. (host) adb forward tcp:8888 tcp:8888Copy to clipboard 3. Start the `gdbserver` on the target by running the following command. (target) gdbserver localhost:8888 Copy to clipboard Example: (target) gdbserver localhost:8888 /usr/bin/systemd-pathCopy to clipboard 4. Start GDB on the host and connect to the remote `gdbserver` on the target by running the following commands. gdb-multiarch /usr/bin/systemd-pathCopy to clipboard 5. Run the following commands after the `gdb-multiarch` starts on the GDB console. (gdb) set sysroot Copy to clipboard (gdb) target remote :8888Copy to clipboard (gdb) b mainCopy to clipboard (gdb) cCopy to clipboard Breakpoint 1, 0x7f55596c in main ()Copy to clipboard 6. Proceed with the GDB remote. ## Linux Embedded After successfully building an HLOS debug build, `build-qti-distro-rb-debug/` directory is displayed on the host machine. To start remote GDB debugging, do the following: 1. Set up the debug directory on the host system by running the following commands: locate /build-qti-distro-rb-debug/tmp-glibc/deploy/images/ qrb5165-rb5/qti-robotics-image-qrb5165-rb5-dbg.rootfs.tar.bz2 bunzip2 qti-robotics-image-qrb5165-rb5-dbg.rootfs.tar.bz2 mkdir Copy to clipboard tar -C -xvf / qti-robotics-image-qrb5165-rb5-dbg.rootfs.tar Copy to clipboard The binary libraries and debug directories get created after the successful set up of the debug directory on the host system. 2. Set up the ADB port forwarding by running the following command. (host) adb forward tcp:8888 tcp:8888Copy to clipboard 3. Start the `gdbserver` on the target by running the following command. (target) gdbserver localhost:8888 Copy to clipboard Example: (target) gdbserver localhost:8888 /usr/bin/systemd-pathCopy to clipboard 4. Start GDB on the host and connect to the remote `gdbserver` on the target by running the following commands. cd gdb-multiarch /usr/bin/systemd-pathCopy to clipboard 5. Run the following commands after the `gdb-multiarch` starts on the GDB console. (gdb) set sysroot Copy to clipboard (gdb) target remote :8888Copy to clipboard (gdb) b mainCopy to clipboard (gdb) cCopy to clipboard Continuing.Copy to clipboard Breakpoint 1, 0x7f55596c in main ()Copy to clipboard 6. Proceed with the GDB remote. - **[Use GDB on coredumps](https://docs.qualcomm.com/doc/80-88500-3/topic/80_Use_GDB_on_coredumps_.html)** **Parent Topic:** [Debug mechanisms](https://docs.qualcomm.com/doc/80-88500-3/topic/77_Debugging_procedures.html) Last Published: Sep 26, 2023 [Previous Topic Enable coredump](https://docs.qualcomm.com/bundle/publicresource/80-88500-3/topics/78_Enable_coredump.md) [Next Topic Use GDB on coredumps](https://docs.qualcomm.com/bundle/publicresource/80-88500-3/topics/80_Use_GDB_on_coredumps_.md)