Remote Debugging for QNX

2021-12-28  本文已影响0人  贰爷

Sometimes, it is convenient to debug a piece of code on QNX remotely from your Linux desktop. It is straightforward to do that. Firstly, you need to compile your code with debug info enabled (-g) and optimization disabled (-O0). Without debug info, you won't be able to do much with gdb. After that, you can run pdebug on QNX, which serves as the gdb server. On your Linux desktop, you can run the gdb client. After that, you can debug a piece of program just like on your local machine.
Remote Debugging Code with GDB

On QNX target with ip 10.160.64.143, run the following:

    pdebug -f -v 4444                       # 4444 is the port number

On your linux desktop:

    /opt/toolchains/qnx700/host/linux/x86_64/usr/bin/ntoaarch64-gdb            # you need to use the gdb built for QNX
    (gdb) target qnx 10.160.64.143:4444                        # connect to the qnx box with ip 10.160.64.143 at port 4444
    (gdb) file hello.qnx                                                       # load the qnx binary hello.qnx which is under the current working directory
    (gdb) set solib-search-path /opt/toolchains/rti_connext_dds-6.0.0/lib/armv8QNX7.0.0qcc_cxx5.4.0         # set the library search path so that we can load the shared libraries
    (gdb) upload hello.qnx /binzeng/hello.qnx                # upload the binary to target board under /binzeng
    (gdb) break main                                                         # set a breakpoint at main
    (gdb) run                                                                      # run the application

Remote Debugging Coredump with GDB

You can also debug a core file remotely with GDB. All you need to do is to load the core file when you remote debug a piece of program. The following example shows how to debug a core file and get the stacktrace.

On your linux desktop:

    /opt/toolchains/qnx700/host/linux/x86_64/usr/bin/ntoaarch64-gdb            # you need to use the gdb built for QNX
    (gdb) file hello.qnx                                                       # load the qnx binary hello.qnx
    (gdb) set solib-search-path /opt/toolchains/rti_connext_dds-6.0.0/lib/armv8QNX7.0.0qcc_cxx5.4.0         # set the library search path so that we can load the shared libraries
    (gdb) core hello.qnx.core                                            # load the core file which is under the current working directory
    (gdb) bt                                                                         # print the stacktrace of the current thread
    (gdb) thread apply all bt full                                        # print the stacktrace of all threads
上一篇下一篇

猜你喜欢

热点阅读