【问题标题】:How to use cross gdb to examine core file from crosstarget machine如何使用cross gdb从crosstarget机器检查核心文件
【发布时间】:2011-07-21 10:23:18
【问题描述】:

我有一个来自嵌入式 SH3 linux 设备的 core 文件,以及我的主机 linux 中的交叉编译器环境 (sh3-linux-gdb) 的 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)

为什么无法读取核心文件? 有什么办法可以将目标系统的core文件读到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)

【问题讨论】:

  • 不,这没有帮助。 solib-absolute-prefix 技巧也会出现同样的问题。
  • 你能发布输出或readelf -a core吗?
  • 完成,已将 readelf 打印输出添加到问题中。
  • 所以,现在您可以将您的问题重新发布到 gdb 邮件列表并询问为什么您的核心格式无法识别。

标签: c linux gdb cross-compiling gdbserver


【解决方案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 吗?

【讨论】:

  • 目标操作系统:Linux 版本 2.6.25.9(gcc 版本 3.4.5 20060103 (3.4.5-10.1a))
  • --core 选项没有帮助。后来的 gdb 6.8 版也没有帮助。旧的错误似乎仍然存在。我会接受这个答案,因为错误是最可能的原因。
  • 这不是bug,它是不支持核心文件格式和gdb核心格式解析器的组合。当您使用 gdbserver 时,其他代码处于活动状态,并且主机 gdb 不需要解析内核。
【解决方案2】:

可以调试您的应用程序,而不是直接使用 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相同。

【讨论】:

  • 这不是我的问题的答案。我可以使用 gdbserver,这不是问题。问题是打开核心文件。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-01-21
  • 2011-04-30
  • 1970-01-01
相关资源
最近更新 更多