Debugging 调试核心文件

Debugging 调试核心文件,debugging,core,Debugging,Core,我想写一个程序,可以在Linux中读取核心文件。然而,我找不到任何可以在这方面指导我的文件。有人能告诉我在哪里可以找到一些资源吗?看看gcore的源代码可能会有帮助。看看gcore的源代码可能会有帮助。你也可以看看GDB,GDB/core* 例如,在gdb/corelow.c中,您可以在末尾阅读: static struct target_ops core_ops; core_ops.to_shortname = "core"; core_ops.to_longname = "Lo

我想写一个程序,可以在Linux中读取核心文件。然而,我找不到任何可以在这方面指导我的文件。有人能告诉我在哪里可以找到一些资源吗?

看看gcore的源代码可能会有帮助。

看看gcore的源代码可能会有帮助。

你也可以看看GDB,
GDB/core*

例如,在
gdb/corelow.c
中,您可以在末尾阅读:

  static struct target_ops core_ops;

  core_ops.to_shortname = "core";
  core_ops.to_longname = "Local core dump file";
  core_ops.to_doc = "Use a core file as a target.  Specify the filename of the core file.";
  core_ops.to_open = core_open;
  core_ops.to_close = core_close;
  core_ops.to_attach = find_default_attach;
  core_ops.to_detach = core_detach;
  core_ops.to_fetch_registers = get_core_registers;
  core_ops.to_xfer_partial = core_xfer_partial;
  core_ops.to_files_info = core_files_info;
  core_ops.to_insert_breakpoint = ignore;
  core_ops.to_remove_breakpoint = ignore;
  core_ops.to_create_inferior = find_default_create_inferior;
  core_ops.to_thread_alive = core_thread_alive;
  core_ops.to_read_description = core_read_description;
  core_ops.to_pid_to_str = core_pid_to_str;
  core_ops.to_stratum = process_stratum;
  core_ops.to_has_memory = core_has_memory;
  core_ops.to_has_stack = core_has_stack;
  core_ops.to_has_registers = core_has_registers;
struct target_ops
定义了一个通用接口,GDB的上部将使用该接口与目标进行通信。此目标可以是本地unix进程、远程进程、核心文件等

因此,如果您只研究这些函数背后的原因,就不会被调试器实现的通用部分所左右


(根据您的最终目标,您可能还希望在应用程序中重用此接口及其实现,它不应该依赖于太多其他东西。

您也可以看看GDB,
GDB/core*

例如,在
gdb/corelow.c
中,您可以在末尾阅读:

  static struct target_ops core_ops;

  core_ops.to_shortname = "core";
  core_ops.to_longname = "Local core dump file";
  core_ops.to_doc = "Use a core file as a target.  Specify the filename of the core file.";
  core_ops.to_open = core_open;
  core_ops.to_close = core_close;
  core_ops.to_attach = find_default_attach;
  core_ops.to_detach = core_detach;
  core_ops.to_fetch_registers = get_core_registers;
  core_ops.to_xfer_partial = core_xfer_partial;
  core_ops.to_files_info = core_files_info;
  core_ops.to_insert_breakpoint = ignore;
  core_ops.to_remove_breakpoint = ignore;
  core_ops.to_create_inferior = find_default_create_inferior;
  core_ops.to_thread_alive = core_thread_alive;
  core_ops.to_read_description = core_read_description;
  core_ops.to_pid_to_str = core_pid_to_str;
  core_ops.to_stratum = process_stratum;
  core_ops.to_has_memory = core_has_memory;
  core_ops.to_has_stack = core_has_stack;
  core_ops.to_has_registers = core_has_registers;
struct target_ops
定义了一个通用接口,GDB的上部将使用该接口与目标进行通信。该目标可以是本地unix进程、远程进程、核心文件等

因此,如果您只研究这些函数背后的原因,就不会被调试器实现的通用部分所左右


(根据您的最终目标,您可能还希望在应用程序中重用此接口及其实现,它不应该依赖于太多其他东西。

可以使用
dbx(1)
mdb(1)
proc(1)
工具之一检查核心文件。

可以使用
dbx检查核心文件(1) 
mdb(1)
proc(1)
工具之一