尝试在 Linux (Ubuntu 16.04) 上运行可执行文件时,我可以在 gdb
下运行可执行文件:
gdb ./bazel-bin/drake/systems/sensors/rgbd_camera_test
但是,如果我尝试在 gdbserver
下运行可执行文件并连接,情况就不同了:
tty1$ gdbserver localhost:9999 ./bazel-bin/drake/systems/sensors/rgbd_camera_test
tty2$ gdb
(gdb) target remote localhost:9999
Remote debugging using localhost:9999
Reading ${BAZEL_ROOT}/bazel-out/clang-3.9-linux-dbg/bin/drake/systems/sensors/rgbd_camera_test from remote target...
warning: File transfers from remote targets can be slow. Use "set sysroot" to access files locally instead.
"target:${BAZEL_ROOT}/bazel-out/clang-3.9-linux-dbg/bin/drake/systems/sensors/rgbd_camera_test": not in executable format: Success
我正在使用 bazel
(0.4.5) 和 clang-3.9
。如果我使用:
bazel run --run_under=gdb //drake/systems/sensors:rgbd_camera_test`
和--run_under 'gdbserver localhost:9999'
。
最佳答案
问题是我的二进制文件对于远程传输来说太大了。我通过阅读 gdb
中的上述提示,在 gdb
中调用 set sysroot
来实现这一点。使用它,我可以使用 gdbserver
调试可执行文件。
请注意,这可以添加到您的 ~/.gdbinit
中,如果您将\仅进行本地调试。在我的情况下,我在使用 CLion 调试时使用 gdbserver
(因为有时直接调试似乎不起作用...)
关于c++ - 为什么我从 gdbserver 得到 "not in executable format: Success",但在 gdb 中一切正常?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44791385/