如何使用cross gdb检查来自crosstarget机器的核心文件

时间:2021-02-06 12:18:01

I have a core file from embedded SH3 linux device, and gdb of the cross compiler environment (sh3-linux-gdb) in my host linux.

我有一个来自嵌入式SH3 linux设备的核心文件,以及我主机linux中的交叉编译环境(sh3-linux-gdb)的gdb。

But I have problems loading the core file with gdb:

但我在使用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)

Why it can't read the core file? Is there any way to read the core file from target system to the cross gdb?

为什么它无法读取核心文件?有没有办法从目标系统读取核心文件到交叉gdb?

There is gdbserver in target machine (SH3-linux), but not gdb itself. I am able to do runtime debuging of processes of target machine with gdbserver and sh3-linux-gdb, so sh3-linux-gdb should be correctly compiled.

目标机器(SH3-linux)中有gdbserver,但不是gdb本身。我能够使用gdbserver和sh3-linux-gdb对目标机器的进程进行运行时调试,因此应该正确编译sh3-linux-gdb。

EDIT: readelf dump was requested:

编辑:请求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: Same problem with --core option:

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)

2 个解决方案

#1


1  

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

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

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

It may be a bug in the old gdb http://sourceware.org/bugzilla/show_bug.cgi?id=9542 - so try newer gdb (7) too.

它可能是旧的gdb http://sourceware.org/bugzilla/show_bug.cgi?id=9542中的一个错误 - 所以也尝试更新的gdb(7)。

Also possible that core was dumped in unsupported format. What is target's OS, version?

也可能以不支持的格式转储核心。什么是目标的操作系统,版本?

Can you post the output or readelf -a core ?

你可以发布输出或readelf -a核心?

#2


-1  

It is possible to debug your application, not with gdb directly but with gdb server. The first thing you have to do is to call gdbserver in the target system (you said in your question that this package is already installed) :

可以调试您的应用程序,而不是直接使用gdb,而是使用gdb服务器。你要做的第一件事就是在目标系统中调用gdbserver(你在问题中说你已经安装了这个包):

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

It is assume that the target machine is accessible to an IP address : AAA.BBB.CCC.DDD:port. Once, you have done that, you can call gdb in your development machine by specifying the target remote server :

假设目标机器可以访问IP地址:AAA.BBB.CCC.DDD:port。完成后,您可以通过指定目标远程服务器在开发计算机中调用gdb:

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

Note that the target remote server IP address are the same of the gdbserver.

请注意,目标远程服务器IP地址与gdbserver相同。

#1


1  

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

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

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

It may be a bug in the old gdb http://sourceware.org/bugzilla/show_bug.cgi?id=9542 - so try newer gdb (7) too.

它可能是旧的gdb http://sourceware.org/bugzilla/show_bug.cgi?id=9542中的一个错误 - 所以也尝试更新的gdb(7)。

Also possible that core was dumped in unsupported format. What is target's OS, version?

也可能以不支持的格式转储核心。什么是目标的操作系统,版本?

Can you post the output or readelf -a core ?

你可以发布输出或readelf -a核心?

#2


-1  

It is possible to debug your application, not with gdb directly but with gdb server. The first thing you have to do is to call gdbserver in the target system (you said in your question that this package is already installed) :

可以调试您的应用程序,而不是直接使用gdb,而是使用gdb服务器。你要做的第一件事就是在目标系统中调用gdbserver(你在问题中说你已经安装了这个包):

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

It is assume that the target machine is accessible to an IP address : AAA.BBB.CCC.DDD:port. Once, you have done that, you can call gdb in your development machine by specifying the target remote server :

假设目标机器可以访问IP地址:AAA.BBB.CCC.DDD:port。完成后,您可以通过指定目标远程服务器在开发计算机中调用gdb:

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

Note that the target remote server IP address are the same of the gdbserver.

请注意,目标远程服务器IP地址与gdbserver相同。