我有兩個相同的64位的Centos 5機,被連網和共享他們的/ home掛載。我編譯一個簡單的Hello World程序,然後我想通了如何使用gdb的一臺機器上遠程調試它的另一臺機器上運行。當每個人都默認64位時,似乎工作正常。但是,如果我用-m32編譯我的Hello World以生成32位二進制文件,我們的完整系統正在編譯的方式,那麼我不知道如何讓gdb和gdbserver正確連接。在我嘗試完全升級系統之前,我想我應該把它和你好打交道。根據我再怎麼連接GDB和gdbserver的,我要麼獲得有關格式錯誤寄存器,約架構不匹配,或非法的內存引用的警告消息。用gdb和gdbserver的具有64位機的Centos 5上32位二進制抱怨存儲器存取或格式數據
我似乎有一個什麼樣的-m32的影響是在我的編譯一點了解也沒有對如何啓動gdb和gdbserver的或正確的順序指定架構或文件什麼的想法。 :(
怎樣才能對一個64位的Linux操作系統中使用GDB和gdbserver的在32位(-m32)可執行文件?以下
例子,謝謝你,
傑裏
你好。CPP:
#include <iostream>
int main(int argc, char *argv[])
{
std::cout << "Hello World." << std::endl;
return -1;
}
這裏有三個運行:
- 在gdb中,集架構的i386 /再連接到gdbserver的=>壞架構
- 在gdb中,集架構的i386 /文件你好/再連接到gdbserver的=>壞架構
- 在gdb中,集架構(錯誤地)I386:X86-64 /文件你好/再連接到gdbserver的=>無法訪問存儲器
或者在稍微詳細:
==============================
對於每次運行,遠程gdbserver的說:
$ gdbserver --multi rdev6:2010 hello
Process hello created; pid = 32603
Listening on port 2010
Remote debugging from host 134.51.26.149
readchar: Got EOF
Remote side has terminated connection. GDBserver will reopen the connection.
Listening on port 2010
而且我們本地:
============================ ==
- 假設它是i386 32位,設置archi到I386,然後連接 注:在GDB側,可執行尚未指定或裝載
$ gdb
GNU gdb Fedora (6.8-37.el5)
his GDB was configured as "x86_64-redhat-linux-gnu".
(gdb) set archi i386
The target architecture is assumed to be i386
(gdb) target extended-remote rdev6:2010
Remote debugging using rdev6:2010
warning: Selected architecture i386 is not compatible with reported target architecture i386:x86-64
Remote register badly formatted: T0506:0000000000000000;07:b0dcdfff00000000;10:1018620000000000;thread:7f5b;
here: 0000000;07:b0dcdfff00000000;10:1018620000000000;thread:7f5b;
Try to load the executable by `file' first,
you may also check `set/show architecture'.
(gdb)
=================== ===========
- 假設這是I386 32位,設置ARCHI到I386,然後連接 注:在GDB側,可執行已裝載有文件
$ gdb
GNU gdb Fedora (6.8-37.el5)
his GDB was configured as "x86_64-redhat-linux-gnu".
(gdb) set archi i386
The target architecture is assumed to be i386
(gdb) file hello
Reading symbols from /home/j/hello...done.
(gdb) target extended-remote rdev6:2010
Remote debugging using rdev6:2010
warning: Selected architecture i386 is not compatible with reported target architecture i386:x86-64
Remote register badly formatted: T0506:0000000000000000;07:b0dcdfff00000000;10:1018620000000000;thread:7f5b;
here: 0000000;07:b0dcdfff00000000;10:1018620000000000;thread:7f5b;
Try to load the executable by `file' first,
you may also check `set/show architecture'.
(gdb) sho archi
The target architecture is assumed to be i386
(gdb)
==============================
- 假設(它應該是不正確的),這是I386: X86-64,設置阿爾基到I386:X86-64,然後連接 注:在GDB側,可執行文件已加載文件
$ gdb
GNU gdb Fedora (6.8-37.el5)
This GDB was configured as "x86_64-redhat-linux-gnu".
(gdb) set archi i386:x86-64
The target architecture is assumed to be i386:x86-64
(gdb) file hello
Reading symbols from /home/j/hello...done.
(gdb) show archi
The target architecture is assumed to be i386:x86-64
(gdb) target extended-remote rdev6:2010
Remote debugging using rdev6:2010
[New Thread 32667]
Cannot access memory at address 0x800000008
(gdb)
非常感謝,我非常感謝你的幫助,明天我會在工作中嘗試。 – 2010-06-21 05:49:37
是的,我在2天前查看了最新的gdbserver的手冊,當我找到漂亮的打印機時,幾乎情節化。 – 2010-06-21 05:50:59
對不起,要恢復一個非常古老的話題,但我想知道沒有更新GDB有什麼辦法。我正在使用Windows機器進行連接,所以我可以爲Windows構建32位gdb模式的gdb? – 2013-12-13 18:29:10