在基於 qemu-user-emulation 的 arm-chroot 中運行的「git clone」的回溯

在基於 qemu-user-emulation 的 arm-chroot 中運行的「git clone」的回溯

我正在運行 wheezy:armhf chroot 使用qemu 用戶模擬在我的 jessie:x86_64 系統上。不知何故,git clone特定私有儲存庫上的 a 將掛在 chroot 內,同時在本機上成功。這可能是個錯誤,誰知道呢?為了提升自己的業力,我想弄清楚到底是怎麼回事!

順便一提:我遇到的掛起也是在 jessie:armel chroot 內的 git-2.0 中發生的......掛起不會發生在全系統模擬中。所以我繼續挖掘喘息聲: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

據我讀到gcc 文檔,設定DEB_CFLAGS_APPENDDEB_CXXFLAGS_APPEND另外 with-fno-stack-protector是不需要的,但無論如何,要確定)

然後,使用 qemu 的內置gdb_存根在 chroot 裡面我正在做:

QEMU_GDB=1234 git clone /path/to/breaking/repo /tmp/bla

在 qemu 內部調試會拋出一個不支援的系統 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?

發送 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?)

現在我迷路了。

哪裡有問題?我是否錯過了 qemu-user-emulation 中的一些細節?我必須使用完全模擬的手臂機器嗎?交叉調試的誤區? gdb-multiarch 限制?創建調試包?

感謝您提供任何建議、指點、提示、提示、評論以及諸如此類的資訊。

我目前最好的猜測是基於git執行克隆的事實(我可以看到兩個進程/線程),但QEMU_GDB使用後 qemu 未設定環境變數。因此,只有初始進程才會進入 gdb。看這裡例如。

但仍然:我應該能夠正確調試父進程?我可以輕鬆地交叉調試 hello-world MWE。

答案1

事實證明,「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

所以...

但是,我仍然無法獲得複雜程序的回溯......

相關內容