我正在使用 Olimex 的 Allwinner A33(四核 ARM)开发套件。它运行的是 Ubuntu 16.04 根文件系统。我的主机运行的是 64 位 Kubuntu 16.04。我使用 GCC 6.1.1(Linaro 构建)作为交叉编译器和 QT v5.5。仅使用通过包管理器预构建的 .deb 包。没有什么是我自己从源头构建的。
我使用下面描述的场景测试了一个简单的 QT 应用程序(带有一个标签的主窗口,没有其他应用程序代码)。在所有场景中,只有 QT Creator 的调试才会导致问题:
我使用 X11 转发 (-X) ssh 到远程目标。主窗口出现在我的主机上并且功能正常,即使存在这些警告:
libEGL warning: DRI2: failed to authenticate
QXcbConnection: XCB error: 1 (BadRequest), sequence: 380, resource id:
102760451, major code: 154 (Unknown), minor code: 1
QXcbShmImage: shmget() failed (38) for size 480000 (400x300)
1) 从远程目标上的命令行手动启动应用程序
2) 直接在远程目标上启动命令行 gdb 会话
(gdb) 信息线程
Id Target Id Frame
1 Thread 0xb6ff1220 (LWP 984) "DemoApp" 0xb635da50 in poll () at
../sysdeps/unix/syscall-template.S:84
2 Thread 0xb3c2c440 (LWP 988) "QXcbEventReader" 0xb635da50 in poll ()
at ../sysdeps/unix/syscall-template.S:84
3 Thread 0xb0c42440 (LWP 989) "llvmpipe-0" __libc_do_syscall () at
../sysdeps/unix/sysv/linux/arm/libc-do-syscall.S:46
4 Thread 0xb0442440 (LWP 990) "llvmpipe-1" __libc_do_syscall () at
../sysdeps/unix/sysv/linux/arm/libc-do-syscall.S:46
5 Thread 0xafc42440 (LWP 991) "llvmpipe-2" __libc_do_syscall () at
../sysdeps/unix/sysv/linux/arm/libc-do-syscall.S:46
6 Thread 0xaf442440 (LWP 992) "llvmpipe-3" __libc_do_syscall () at
../sysdeps/unix/sysv/linux/arm/libc-do-syscall.S:46
3) 在远程主机上运行 GDB 服务器并使用命令行 gdb 从主机 PC 连接到它
远程目标
$ gdbserver :5555 DemoApp
Process DemoApp created; pid = 4265
Listening on port 5555
Remote debugging from host 192.168.7.2
libEGL warning: DRI2: failed to authenticate
Detaching from process 4272
QXcbConnection: XCB error: 1 (BadRequest), sequence: 380, resource id:
10485763, major code: 154 (Unknown), minor code: 1
QXcbShmImage: shmget() failed (38) for size 480000 (400x300)
主机端
.gdbinit 的内容
set debug-file-directory /opt/arm-linux-gnueabihf-rootfs/usr/lib/debug
set sysroot /opt/arm-linux-gnueabihf-rootfs
target remote 192.168.7.1:5555
$ /opt/arm-linux-gnueabihf-v6.1.1/bin/arm-linux-gnueabihf-gdb 演示应用程序
Reading symbols from DemoApp...done.
0xb6fd7a40 in _start () from /opt/arm-linux-gnueabihf-rootfs/lib/ld-
linux-armhf.so.3
(gdb)
(gdb) continue
Continuing.
Cannot parse expression `.L966 4@r4'.
warning: Probes-based dynamic linker interface failed.
Reverting to original interface.
(gdb) info threads
Id Target Id Frame
1 Thread 999.999 "DemoApp2" 0xb635da50 in poll () at
../sysdeps/unix/syscall-template.S:84
2 Thread 999.1001 "QXcbEventReader" 0xb635da50 in poll () at
../sysdeps/unix/syscall-template.S:84
3 Thread 999.1002 "llvmpipe-0" __libc_do_syscall () at
../sysdeps/unix/sysv/linux/arm/libc-do-syscall.S:46
4 Thread 999.1003 "llvmpipe-1" __libc_do_syscall () at
../sysdeps/unix/sysv/linux/arm/libc-do-syscall.S:46
5 Thread 999.1004 "llvmpipe-2" __libc_do_syscall () at
../sysdeps/unix/sysv/linux/arm/libc-do-syscall.S:46
6 Thread 999.1005 "llvmpipe-3" __libc_do_syscall () at
../sysdeps/unix/sysv/linux/arm/libc-do-syscall.S:46
4) 使用“运行”按钮从 QT 创建者中启动应用程序可以正常工作。
远程目标上的进程列表:
978 pts/8 S 0:00 dbus-launch --autolaunch
e0b04e02d3bd48f29553fcf6f7149394 --binary-syntax --close-stderr
979 ? Ss 0:00 /usr/bin/dbus-daemon --fork --print-pid 5 --print-
address 7 --session
1033 ? Ss 0:00 bash -c test -f /etc/profile && . /etc/profile;test -f
$HOME/.profile && . $HOME/.profile; DISPLAY=':10.0' /DemoApp ''
1034 ? Sl 0:00 /DemoApp
5) 从 QT Creator 中调试会话
唯一不起作用的情况是从 QT Creator 本身启动远程调试。 QT Creator 现在有 7 个线程在运行
而不是前面场景中的 6 个。
Thread #1: DemoApp2: _dbus_read
Thread #2: DemoApp2: __libc_fork, __libc_do_syscall <<-- Extra
Thread #3: QXcbEventReader: poll
单步执行和变量监视工作正常。主窗口未创建。调试器挂在 MainWindow::MainWindow(QWidget *parent) 处,输入 ui->setupUi(this) --> retranslateUi() --> MainWindow->setWindowTitle()
QTCreator 中的应用程序输出:
Debugging starts
Listening on port 10000
Remote debugging from host 192.168.7.2
Process /opt/cellair/DemoApp created; pid = 4300
Probes-based dynamic linker interface failed.
Reverting to original interface.
libEGL warning: DRI2: failed to authenticate
注意:这些错误不再出现:QXcbConnection: XCB error: 1 或
QXcbShmImage:shmget() 失败 (38)
远程目标上的进程列表
877 ? Ss 0:00 bash -c test -f /etc/profile && .
/etc/profile;test -f $HOME/.profile && . $HOME/.profile;
DISPLAY=':10.0' gdbserver --multi :10000
878 ? S 0:00 gdbserver --multi :10000
881 ? Sl 0:00 /DemoApp
888 ? t 0:00 /DemoApp
应用程序的两个副本正在远程目标上运行。