> ## Documentation Index
> Fetch the complete documentation index at: https://dragonwingdocs-staging.qualcomm.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 收集 coredump

<Note>
  coredump 功能目前尚不支持，将在未来版本中添加。
</Note>

coredump 是用户空间进程的内存快照，可用于分析进程崩溃的原因。

系统会按照 Yocto Project Linux 标准为所有用户空间进程崩溃收集 coredump。默认情况下，构建允许生成 coredump。设备将生成的 coredump 保存在 `/var/coredump` 目录中。

* 要验证 coredump 的位置，请运行以下命令：
  > > ```text theme={null}
  > > cat /proc/sys/kernel/core_pattern
  > > ```
  >
  > **示例输出：**
  >
  > /var/coredump/%e.core

* 要验证 coredump 的大小，请运行以下命令（coredump 大小必须大于 0 \[零]）：
  > ```text theme={null}
  > ulimit -c
  > ```
  >
  > **示例输出：**
  >
  > unlimited

* 如果未启用 coredump，请使用以下文件启用它：
  > `meta-qcom-distro/recipes-products/packagegroups/packagegroup-qcom-utilities.bb`。
  >
  > > ```text theme={null}
  > > RDEPENDS:${PN}-support-utils = " \
  > > dtc \
  > > efivar \
  > > file \
  > > less \
  > > ltrace \
  > > ++  procps \
  > >  tinyalsa \
  > > ```
  <Note>
    * 使用此补丁启用 coredump，然后重新构建并重新烧写设备。
  </Note>

## **使用 GDB 分析 coredump**

您可以通过强制终止进程来生成 coredump。为此，请运行以下命令：

```text theme={null}
ps -ef | grep -i 'tqftp*'
```

**示例输出：**

root 1024 1 0 17:46 ? 00:00:00 /usr/bin/tqftpserv

root 1047 934 0 17:47 pts/0 00:00:00 grep -i tqftp\*

```text theme={null}
kill -11 1024
```

```text theme={null}
cd /var/coredump
```

```text theme={null}
ls
```

**示例输出：**

tqftpserv.core

`tqftpserv.core` 就是 coredump 文件。

如果设备上已有调试符号，请运行以下命令对 coredump 使用 GDB 工具：

```text theme={null}
cd /usr/bin/
```

```text theme={null}
gdb tqftpserv /var/coredump/tqftpserv.core
```

**示例输出：**

```text theme={null}
gdb: warning: Couldn't determine a path for the index cache directory.
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
Type "apropos word" to search for commands related to "word"...
Reading symbols from tqftpserv...

warning: exec file is newer than core file.
[New LWP 1024]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/libthread_db.so.1".
Core was generated by `/usr/bin/tqftpserv'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x0000ffff8629ef34 in __GI___select (nfds=4,
  readfds=readfds@entry=0xffffd04ccb28, writefds=writefds@entry=0x0,
--Type <RET> for more, q to quit, c to continue without paging--
  exceptfds=exceptfds@entry=0x0, timeout=timeout@entry=0x0)
  at ../sysdeps/unix/sysv/linux/select.c:69
69      ../sysdeps/unix/sysv/linux/select.c: No such file or directory.
(gdb) bt
#0  0x0000ffff8629ef34 in __GI___select (nfds=4,
  readfds=readfds@entry=0xffffd04ccb28, writefds=writefds@entry=0x0,
  exceptfds=exceptfds@entry=0x0, timeout=timeout@entry=0x0)
  at ../sysdeps/unix/sysv/linux/select.c:69
#1  0x00000000004013cc in main (argc=<optimized out>, argv=<optimized out>)
  at tqftpserv.c:552
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
(gdb)
```

有关更多信息，请参阅 [Linux 手册页](https://man7.org/linux/man-pages/man5/core.5.html)。
