3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Ubuntu で core ファイルが出力されない

Last updated at Posted at 2022-08-25

core がない

備忘録です。

ubuntuバージョン
$ cat /etc/os-release
PRETTY_NAME="Ubuntu 24.04.2 LTS"
NAME="Ubuntu"
VERSION_ID="24.04"
VERSION="24.04.2 LTS (Noble Numbat)"
VERSION_CODENAME=noble
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=noble
LOGO=ubuntu-logo

(1) コアファイルの出力先
apport障害情報ツールになっていますので変更します。

出力先の確認
$ sudo sysctl -a | grep core_pattern
 ...
kernel.core_pattern = |/usr/share/apport/apport -p%p -s%s -c%c -d%d -P%P -u%u -g%g -F%F -- %E

tmpに出力、ファイル名は任意で変更 (tmpは再起動でクリア)

出力先の変更
sudo sysctl -w kernel.core_pattern="/tmp/core_%e_%p_%t"

(2) コアファイルのサイズ
が0なので出力されません

サイズの確認
$ ulimit -c
0

無制限に設定

サイズの設定
$ ulimit -S -c unlimited
$ ulimit -c  # 確認
unlimited

(3) コア生成
hoge落とす Segmentation fault (コアダンプ)

core 確認
$ ls core*
core_hoge_2297_1661404598

あとは gdb でデバッグですね。

gdb
$ gdb hoge core_hoge_2297_1661404598
GNU gdb (Ubuntu 9.2-0ubuntu1~20.04) 9.2
...
3
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?