Debugging ROS project with core dump
Published:
Debugging ROS project with core dump
[Step1]
Check core dump file check
$ ulimit -a
core file size (blocks, -c) 0 # <-- Prevents core dumps
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 20
file size (blocks, -f) unlimited
pending signals (-i) 16382
max locked memory (kbytes, -l) 64
max memory size (kbytes, -m) unlimited
open files (-n) 1024
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) unlimited
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
Default corefile size is 0, it means it will not generate coredump file
Set the core size to unlimited:
ulimit -c unlimited
Then again ulimit -a
$ ulimit -a
core file size (blocks, -c) unlimited
core file size is changed as unlimited
[Step2]
Let’s check coredump file generation with pid
$ cat /proc/sys/kernel/core_uses_pid
0
0 means core dump file pid is deactivated. let’s activate
echo 1 | sudo tee /proc/sys/kernel/core_uses_pid ...
$ cat /proc/sys/kernel/core_uses_pid
1
Now, it can generate coredump with pid
Example
let’s make segmentation fault
(base) ri@ri-GS75-Stealth-9SD:~/bumblebee_one$ roslaunch module module.launch
~~~
[module-1] process has died [pid 10821, exit code -11, cmd
~~~
The PID number is 10821
let’s check coredump file
$ cd ~/.ros
$ ls
~~~
core.10821
~~~
Finally, you can run coredump with gdb
$ gdb ~/yourprojectdir/devel/lib/module/module core.10821