核心和核心文件之间的区别 [英] Difference between core and core-file

查看:50
本文介绍了核心和核心文件之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是在 Ubuntu 12.04 上,GDB 版本 GNU gdb (Ubuntu/Linaro 7.4-2012.04-0ubuntu2.1) 7.4-2012.04

This is on Ubuntu 12.04, GDB version GNU gdb (Ubuntu/Linaro 7.4-2012.04-0ubuntu2.1) 7.4-2012.04

我处理的应用程序转储内核的次数比我想的要多.当我按如下方式启动 gdb 时,我没有得到任何可用的回溯.

The application I work on, does dump core more times than I care to. When I start gdb as follows, I don't get any usable backtrace.

gdb --core <path to core dump>

GDB 确实显示了导致核心转储的进程的完整路径以及命令行参数.

GDB does show full path of process that caused core dump along with command line arguments.

在 gdb 提示符下,如果我执行命令

When on gdb prompt, if I execute commands

file <path to executable>
core-file <path to core dump>

我确实得到了可用的回溯.

I do get usable backtrace.

--core 命令行选项和从 gdb 提示符执行的 core-file 命令有什么区别.

What is the difference between --core command line option and core-file command executed from gdb prompt.

无论如何我可以在命令行中执行此操作.毕竟,gdb 确实知道可执行文件的路径和核心文件名.

Is there anyway I can do this in command line. After all, gdb does know the path to executable and core file name.

推荐答案

无论如何我可以在命令行中执行此操作.

Is there anyway I can do this in command line.

是:gdb/path/to/exe/path/to/core

我的主要兴趣是为什么 gdb 的行为不同.

My main interest is why does gdb behaves differently.

没有.

大多数 UNIX 系统,为了节省磁盘空间,不会将文件支持的只读页面(例如程序代码)转储到核心文件中——该代码已经在磁盘上,为什么还要再写呢?(这实际上是可配置的:参见 man corecoredump_filter).

Most UNIX systems, in order to conserve disk space, do not dump file-backed read-only pages (such as program code) into the core file -- that code is already on disk, so why write it again? (This is actually configurable: see man core and coredump_filter).

但是这些只读页面包含符号(你在 nmbacktrace 输出中看到的),所以如果你不告诉 GDB 可执行文件在哪里,那么它就不能产生有意义的backtrace.

But these read-only pages contain symbols (what you see in nm and in backtrace output), so if you don't tell GDB where the executable file is, then it can't produce a meaningful backtrace.

毕竟,gdb 确实知道可执行文件的路径

After all, gdb does know the path to executable

不,没有.

内核记录了关于生成内核的可执行文件的不完整信息.该信息不可靠:

The kernel records incomplete info about the executable which produced the core. That info is unreliable:

  • 它可以记录相对路径,例如./a.out 并且绝对不能保证您的当前目录在 GDB 分析时与调用可执行文件时相同,并且
  • elf_prpsinfo.pr_fname[] 中只有 16 个字符的空间,超过此长度的将被截断.
  • It may record relative path, e.g. ./a.out and there is absolutely no guarantee that your current directory is the same at GDB analysis time as it was when the executable was invoked, and
  • There is only space for 16 characters in elf_prpsinfo.pr_fname[], and anything longer than that will be truncated.

这篇关于核心和核心文件之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆