核心文件到底是什么以及它为何有用?

发布于 12-03 06:47 字数 118 浏览 0 评论 0原文

正如标题所说:

核心文件到底是什么以及它为什么有用?

我知道 UNIX 何时生成一个,并且我知道如何检查它。我知道它们对于调试很有用...但我不完全确定它包含什么,所以我不确定为什么它有用!

As the title says:

What exactly is a core file and why is it useful?

I know when one is generated by UNIX, and I know how to check for one. I'm aware they're useful for debugging... but I'm not entirely sure what it contains so I'm not sure why its useful!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

一紙繁鸢2024-12-10 06:47:16

核心文件本质上是程序崩溃时内存和寄存器的转储。在调试器中查看时,您可以获得有关崩溃时程序所在位置的信息,以及获取堆栈跟踪或查看堆内存的状态。基本上,它可以让您在崩溃时使用附加的调试器执行任何操作,而不需要实际运行代码。

A core file is, essentially, a dump of the memory and registers of the program at the time that it crashed. When viewed in a debugger, you can get information on where the program was at the time of the crash, as well as getting stack traces or viewing the state of heap memory. Basically it lets you do anything you could with a debugger attached at the time of the crash, short of actually running code.

征﹌骨岁月お2024-12-10 06:47:16

它基本上包含进程的内存,并允许您查看/理解导致问题的原因(堆栈跟踪、检查变量等)。有关更多详细信息,请参见 男人核心

It basically contains the memory of the process and allows you to see/understand what caused the problem (stacktrace, examine variables etc.) For more details see man core

孤独患者2024-12-10 06:47:16

它基本上是进程内存的快照。

它通常是在进程异常结束时自动创建的(例如分段错误)。

可以通过gdb等调试工具加载它来尝试确定崩溃的原因。例如,可以检查发生故障时进程正在执行的内容、变量的值、堆栈回溯(调用有问题的函数的函数、调用该函数的函数等等), ETC。

It's basically a snapshot of a process's memory.

It's usually created automatically when process ends abnormally (e.g. segmentation fault).

It can be loaded by debugging tools like gdb to try to determine the cause of the crash. For example, one can examine what the process was executing at the time of the failure, the values the variables had, the stack backtrace (the function that called the function that had the problem, the function that called it, and so on), etc.

镜花水月2024-12-10 06:47:16

核心文件基本上包含进程内存映射的副本以及寄存器的值,包括 IP(程序计数器)。这对于调试非常有用,因为如果在编译原始程序时包含调试符号,调试器可以向您显示实际状态(变量、数据部分等以及调用堆栈)。

A core file basically contain a copy of the process' memory map, and the values of the registers, including the IP (program counter). This is very useful for debugging, as a debugger can show you the actual state (variables, data sections, etc., and call stack) if you included debugging symbols when compiled the original program.

心舞飞扬2024-12-10 06:47:16

core 文件包含创建时的内存状态。当程序崩溃时(大小可能受到操作系统属性 coredumpsize 的限制)或当程序收到告诉它进行核心转储的终止信号时,它们会在 *nix 系统上创建。

当与已符合调试信息的可执行文件结合使用时,它们特别有用,因为调试器可以读取它们,帮助确定出了什么问题。使用调试器,您可以查看导致崩溃的堆栈跟踪并检查相应堆栈帧中变量的状态。

core files contain the state of memory at the time they are created. The are created on *nix systems when a program crashes (size can be limited by the OS property coredumpsize) or when the program receives a kill signal that tells it to core dump.

They especially useful when combined with an executable that has been complied with debug info as they can be read by debuggers help determine what went wrong. With debuggers, you can see the stack trace that lead up to the crash and examine the state of variables in the corresponding stack frames.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文