# Use GDB on coredumps 

Source: [https://docs.qualcomm.com/doc/80-88500-3/topic/80_Use_GDB_on_coredumps_.html](https://docs.qualcomm.com/doc/80-88500-3/topic/80_Use_GDB_on_coredumps_.html)

The GDB package is available by default in the build. Coredumps are generated by default for
      any process crash. Check the size of coredumps settings by using the command `ulimit
        -c`. If the coredumps size is unlimited, use the command ` ulimit -c
        unlimited`.

If GDB is not available on target, add `gdb` to `
        poky/meta-qti-bsp/recipes-core/packagegroups/packagegroup-qti-debug-tools.bb` and
      re-build.

Check, if flashed build on target contains `gdb`. If not, install
      manually.

Example: 

    adb root
    adb push libreadline8_8.0-r0.13_aarch64.ipk /data/.
    adb push gdb_9.1-r0.13_aarch64.ipk.ipk /data/.
    adb shell
    mount -o rw,remount /
    opkg --nodeps install /data/libreadline8_8.0-r0.13_aarch64.ipk
    opkg --nodeps install /data/gdb_9.1-r0.13_aarch64.ipk.ipkCopy to clipboard

Note: By default, coredumps is saved at location: cat /proc/sys/kernel/core\_pattern.

1. Push the GDB binary on the device, and use the following commands to debug the core.

        gdb <PROCESS_PATH> <CORE_DUMP_PATH>Copy to clipboard

Example:

        gdb /usr/bin/abc  /data/core-abcCopy to clipboard

Useful commands:

        (gdb) bt ---- >> Backtrace of current thread
        (gdb) info threads     
        (gdb) thread 2
        (gdb) where    --- >> Similar to backtrace.
        (gdb) thread apply all bt full ----- >> Backtrace of all threads
        (gdb) info sharedlibrary
        (gdb) info regCopy to clipboard
2. Attach GDB to any running process, use the command `gdb attach <PID>`.
3. Compile all the required executables or shared libraries with `-g CFLAG` to
        enable debug symbols for better debugging.
4. Verify the binary for debug symbols or not using the commands.

        readelf --debug-dump=decodedline <BIN_FILE> 
        objdump --syms <BIN_NAME> | grep -i ‘debug’   ---- >> Check if any debug symbols are present or not.Copy to clipboard

Sometimes, the flashed binary can be with the stripped symbols. However, the build binary at build-qti-distro-fullstack-noselinux-debug\tmp-glibc\work can still have the debug symbols. In such a case, push the required bins directly to the device.

**Parent Topic:** Perform remote GDB debugging

Last Published: Sep 26, 2023

Previous Topic
 
Perform remote GDB debugging Next Topic

RPMh debugging