use*_*615 5 chroot dpkg gdb qemu multiarch
我在我的 jessie:x86_64 系统上使用qemu 用户模拟运行 wheezy:armhf chroot 。不知何故,git clone
特定私有存储库上的 a 将挂在 chroot 内,而本机成功。这可能是一个错误,谁知道?为了提高我的业力,我想知道这是怎么回事!
附带说明:我遇到的挂起是在 jessie:armel chroot 中的 git-2.0 中发生的……挂起不会发生在全系统仿真中。所以我继续挖wheezy:armhf 的兔子洞,只是因为我必须选择一个......我无法在本地机器上测试......
所以。没有git-dbg
包,我自己卷。在 wheezy:armhf chroot 里面:
sudo apt-get install build-essential fakeroot
sudo apt-get build-dep git
apt-get source git && cd git-1.7.10.4
DEB_CFLAGS_APPEND="-fno-stack-protector" DEB_CXXFLAGS_APPEND="-fno-stack-protector" DEB_BUILD_MAINT_OPTIONS=hardening=-stackprotector,-fortify DEB_BUILD_OPTIONS="noopt nostrip nocheck" fakeroot dpkg-buildpackage -j´getconf _NPROCESSORS_ONLN`
sudo dpkg -i ../git_1.7.10.4-1+wheezy1_armhf.deb
Run Code Online (Sandbox Code Playgroud)
据我阅读gcc-documentation,不需要设置DEB_CFLAGS_APPEND
和DEB_CXXFLAGS_APPEND
附加-fno-stack-protector
,但无论如何,要确定)
然后,在我正在做的 chroot 中使用 qemu 的内置gdb_stub:
QEMU_GDB=1234 git clone /path/to/breaking/repo /tmp/bla
Run Code Online (Sandbox Code Playgroud)
在 qemu 内部调试会引发不受支持的 syscal 26错误。
发射了gdb-multiarch
chroot环境外,连接:
gdb-multiarch -q
(gdb) set architecture arm # prevents "warning: Architecture rejected target-supplied description"
(gdb) target remote localhost:1234
(gdb) set sysroot /opt/chroots/wheezy:armhf
(gdb) file /opt/chroots/wheezy:armhf/usr/bin/git
Reading symbols from /opt/chroots/wheezy:armhf/usr/bin/git...done. # good! has debug symbols!
(gdb) list # works! code is not stripped
(gdb) step
Cannot find bounds of current function # meh...
(gdb) backtracke
#0 0xf67e0c90 in ?? ()
#1 0x00000000 in ?? () # wtf?
Run Code Online (Sandbox Code Playgroud)
给 acontinue
让克隆发生将导致挂起,发送 actrl-c
被忽略。
生成一个核心文件并将其加载到 gdb(在 chroot 内)会给我一个损坏的堆栈:
gdb -q /usr/bin/git qemu_git_20140514-160951_22373.core
Reading symbols from /usr/bin/git...done.
[New LWP 22373]
Cannot access memory at address 0xf67fe948
Cannot access memory at address 0xf67fe944
(gdb) bt
#0 0xf678b3e4 in ?? ()
#1 0xf678b3d4 in ?? ()
#2 0xf678b3d4 in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
Run Code Online (Sandbox Code Playgroud)
现在我迷路了。
问题出在哪儿?我是否错过了 qemu-user-emulation 中的一些细节?我必须使用完全模拟的手臂机器吗?对交叉调试的误解?gdb-multiarch 限制?调试包的创建?
感谢您提供任何建议、指示、提示、技巧、评论和其他内容。
我目前最好的猜测是基于git
执行克隆的事实(我可以看到两个进程/线程),但是QEMU_GDB
使用后 qemu 未设置环境变量。因此,只有初始进程会转到 gdb。例如,请参见此处。
但仍然:我应该能够正确调试父进程?我可以轻松地交叉调试 hello-world MWE。
事实证明,“git clone”的这个特殊挂起是一个与 qemu 相关的问题...qemu-user-emulation 中的其他问题占主导地位,所以我必须退回到全系统模拟...;-(
使用qemu-user-static
从他们的 git 编译的(目前在 jessie 中的 qemu-2.0.0+dfsg-4+b1 修复较少,并且不适用于我的情况...):
git clone git://git.qemu-project.org/qemu.git $HOME/qemu.git && cd $HOME/qemu.git
./configure --static --disable-system --target-list=arm-linux-user --prefix=$HOME/qemu.install --disable-libssh2
make && make install
sudo cp $HOME/qemu.install/bin/qemu-arm /opt/chroots/wheezy:armhf/usr/bin/qemu-arm-static
Run Code Online (Sandbox Code Playgroud)
所以...
但是,我仍然无法获得复杂程序的回溯......