2011-07-21 96 views
6

我在嵌入式SH3 linux設備上有一個core文件,在我的主機linux中有交叉編譯環境(sh3-linux-gdb)的gdb。如何使用cross gdb從crosstarget機器檢查覈心文件

但我必須加載使用gdb的核心文件的問題:

$ sh3-linux-gdb ./myprogram ./core 
GNU gdb 6.3 
Copyright 2004 Free Software Foundation, Inc. 
... 
This GDB was configured as "--host=i386-pc-linux-gnu --target=sh3-linux"... 
GDB can't read core files on this machine. 
(gdb) 

爲什麼無法讀取核心文件? 有沒有什麼辦法從目標系統讀取核心文件到cross gdb?

在目標機器(SH3-linux)中有gdbserver,但不是gdb本身。 我可以用gdbserversh3-linux-gdb做目標機器進程的運行時調試,所以sh3-linux-gdb應該被正確編譯。

編輯:請求 readelf轉儲:

[build]$ sh3-linux-readelf -a core 
ELF Header: 
    Magic: 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00 
    Class:        ELF32 
    Data:        2's complement, little endian 
    Version:       1 (current) 
    OS/ABI:       UNIX - System V 
    ABI Version:      0 
    Type:        CORE (Core file) 
    Machine:       Renesas/SuperH SH 
    Version:       0x1 
    Entry point address:    0x0 
    Start of program headers:   52 (bytes into file) 
    Start of section headers:   0 (bytes into file) 
    Flags:        0x0 
    Size of this header:    52 (bytes) 
    Size of program headers:   32 (bytes) 
    Number of program headers:   51 
    Size of section headers:   0 (bytes) 
    Number of section headers:   0 
    Section header string table index: 0 

There are no sections in this file. 

There are no sections in this file. 

Program Headers: 
    Type   Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align 
    NOTE   0x000694 0x00000000 0x00000000 0x00200 0x00000  0 
    LOAD   0x001000 0x00400000 0x00000000 0x00000 0x01000 R E 0x1000 
    ----- several boring lines removed ----- 
    LOAD   0x05a000 0x29952000 0x00000000 0x01000 0x01000 RW 0x1000 
    LOAD   0x05b000 0x7be48000 0x00000000 0x15000 0x15000 RWE 0x1000 

There is no dynamic section in this file. 

There are no relocations in this file. 

There are no unwind sections in this file. 

No version information found in this file. 

Notes at offset 0x00000694 with length 0x00000200: 
    Owner   Data size  Description 
    CORE   0x000000a8  NT_PRSTATUS (prstatus structure) 
    CORE   0x0000007c  NT_PRPSINFO (prpsinfo structure) 
    CORE   0x000000a0  NT_AUXV (auxiliary vector) 
[build]$ 

EDIT2:同樣的問題--core選項:

$ sh3-linux-gdb ./myprogram --core=./core 
GNU gdb 6.3 
Copyright 2004 Free Software Foundation, Inc. 
GDB is free software, covered by the GNU General Public License, and you are 
welcome to change it and/or distribute copies of it under certain conditions. 
Type "show copying" to see the conditions. 
There is absolutely no warranty for GDB. Type "show warranty" for details. 
This GDB was configured as "--host=i386-pc-linux-gnu --target=sh3-linux"...RUN GDB INIT 
GDB can't read core files on this machine. 
(gdb) 
+1

試試這個http://bsdimp.blogspot.com/2007/11/quick-thumbnail-to-cross-debugging-core.html – osgx

+0

不,這沒有幫助。 solib-absolute-prefix技巧也會出現同樣的問題。 – SKi

+0

你可以發佈輸出或'readelf -a核心'嗎? – osgx

回答

-1

它可以調試應用程序,而不是使用gdb直接但與gdb服務器。你必須做的第一件事就是打電話給在目標系統gdbserver的(你在你的問題時說,這個包已經安裝):

gdbserver AAA.BBB.CCC.DDD:port ./myprogram 

據假定目標機器的IP地址進行訪問: AAA.BBB.CCC.DDD:port。一旦你這樣做,你可以通過指定目標遠程服務器調用GDB在你的開發機:

% gdb ./myprogram 
    % [...] 
    (gdb) target remote AAA.BBB.CCC.DDD:port 

注意,目標遠程服務器IP地址是相同的gdbserver的的。

+1

這不是我的問題的答案。我可以使用gdbserver,這不是問題。問題是打開一個核心文件。 – SKi

1

根據http://forums.freescale.com/t5/68K-ColdFire-reg-Microprocessors/GDB-can-t-read-core-files/td-p/70181

sh3-linux-gdb ./myprogram --core=./core 

這可能是在舊的gdb http://sourceware.org/bugzilla/show_bug.cgi?id=9542錯誤試試 - 所以嘗試新的GDB(7)了。

此外,核心可能以不支持的格式轉儲。什麼是目標的操作系統版本?

你可以發佈輸出或readelf -a core

+0

目標操作系統:Linux版本2.6.25.9(gcc版本3.4.5 20060103(3.4.5-10.1a)) – SKi

+0

- 核心選項沒有幫助。 gdb的後來版本6.8沒有幫助。舊的錯誤似乎仍然是開放的。我會接受這個答案,因爲這個錯誤是最可能的原因。 – SKi

+0

這不是一個bug,它是核心文件格式和gdb核心格式解析器不支持的組合。當您使用gdbserver時,其他代碼處於活動狀態,並且不會解析主機gdb所需的內核。 – osgx