Blob


1 Let's say you're debugging something on linux. Let's say that thing
2 crashed. What do you do? I will open gdb, load the executable and the
3 core file and try to figure it out why the thing crashed.
5 Well, it's exactly what happened. But there was no core file for
6 me. Poor me.
8 The defaults on OpenBSD, if I recall correctly, are to generate a core
9 file named `$prgname.core` in the directory where the program was
10 running before the crash. Also, but mind that I might be wrong, the
11 default ulimit settings is `unlimited` for the core files.
13 So, here's a quick description on *how to get that cores* on linux,
14 primarly aimed at myself:
16 #### ulimit
18 A `ulimit -c unlimited` is needed since the default may be 0. This can
19 cause big core dumps in the `$HOME` if something like firefox or chrome
20 chrashes, but I prefer to have it in `.profile` than to have to remember
21 to execute the command.
23 #### pattern
25 On systems with systemd there should be a systemd-*somethingsomething*
26 daemon and *somethingsomething*-ctl to manage 'em. I prefer have those
27 cores in the directory I'm in. Bonus points if they are called like
28 I'm used.
30 ```sh
31 echo %e.core | sudo tee /proc/sys/kernel/core_pattern
32 ```
34 `%e` is replaced with the program name.
36 However, on my machine, the core files are called
37 `$prgname.core.$pid`. To disable the `.pid` at the end
39 ```sh
40 echo 0 | sudo tee /proc/sys/kernel/core_uses_pid
41 ```
43 And that's all!