Core dump

来自百问网嵌入式Linux wiki
Wiki讨论 | 贡献2020年11月2日 (一) 13:09的版本 (创建页面,内容为“==Article purpose== This article provides the initial information set needed to start the '''core dump''' Linux<sup>®</sup> service. == Introduction == {{:Trace…”)
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)

Article purpose

This article provides the initial information set needed to start the core dump Linux® service.

Introduction

The following table provides a brief description of the tool, as well as its availability depending on the software packages:

Yes: this tool is either present (ready to use or to be activated), or can be integrated and activated on the software package.

No: this tool is not present and cannot be integrated, or it is present but cannot be activated on the software package.

Tool STM32MPU Embedded Software distribution STM32MPU Embedded Software distribution for Android™
Name Category Purpose Starter Package Developer Package Distribution Package Starter Package Developer Package Distribution Package
systemd core dump Debugging tools systemd core dump: generates core dump files on Linux
Yes No Yes No No No

core dump records the states of the working program memory before an abnormal termination. The dump record assists in diagnosing and debugging program errors.

Systemd provides, via a configuration file, a way to generate and store core dump for Linux system.

Installing the trace and debug tool on your target board

Using STM32MPU Embedded Software Distribution

Distribution Package

ST via OpenSTLinux layer provides a recipe named systemd-conf, which provides a core dump configuration for systemd.

The core dump configuration is available only via OpenSTLinux distribution. If this configuration is activated via another distribution, an add-on must be made in the systemd-conf recipe.

recipes-core/systemd/systemd-conf.bbappend:

do_install_append() {
    install -d ${D}${sysconfdir}/systemd/coredump.conf.d/
    echo "[Coredump]" > ${D}${sysconfdir}/systemd/coredump.conf.d/coredump-custom.conf
    echo "Storage=external" >> ${D}${sysconfdir}/systemd/coredump.conf.d/coredump-custom.conf
}

Getting started

Verify setup

  • Verify configuration are present
Board $> ls /etc/systemd/coredump.conf.d/
coredump-custom.conf
  • Verify if core dump is registered by Linux
Board $> cat /proc/sys/kernel/core_pattern
|/lib/systemd/systemd-coredump %P %u %g %s %t %c %h %e

Crash append

If an application/program has crashed and generated a core dump while running, the core dump result is stored in /var/lib/systemd/coredump.

(See the How to test core dump service below ).

How to test core dump

  • Launch a program

Launch a program (for example: "weston-flower")

Board $> weston-flower &
  • Get the pid of this program with the ps command
Board $> ps ax | grep <program>
  • kill the program with specific ILL (4) signal (ILL: Illegal instruction)
Board $> kill -4 <pid of program>

Force to generate core dump (for example)

Board $> kill -4 `pidof weston-flower`
  • check /var/lib/systemd/coredump/, the core dump associated to this abnormal termination:
Board $> find /var/lib/systemd/coredump/

/var/lib/systemd/coredump/ /var/lib/systemd/coredump/core.weston-flower.0.47f9def8d0f44af5919d0e4cd5ee04ae.554.1543488316000000.xz


The core dump generated has a size of around 300 Kbytes

Board $> du -sh /var/lib/systemd/coredump/*
295K /var/lib/systemd/coredump/core.weston-flower.0.47f9def8d0f44af5919d0e4cd5ee04ae.554.1543488316000000.xz

To go further

To make core analysis please refer to GDB#Core_dump_analysis_using_GDB

Documentation and web articles


"External links"
Document link Document Type Description
systemd man page for core dump configuration Standard systemd man page

<securetransclude src="ProtectedTemplate:ArticleBasedOnModel" params="Trace and debug tools article model"></securetransclude> <securetransclude src="ProtectedTemplate:PublicationRequestId" params="10302 | 16Jan'19 |"></securetransclude>