Skip to main content

3 posts tagged with "coredump"

View All Tags

· 3 min read
Hreniuc Cristian-Alexandru

Some things were taken from this post, be sure to check it out.

Prepare pretty printers for GDB

The first thing you should always do is to get the pretty printers and use them to print the variables in gdb. To do this you will need to find the install path of thec gcc that was used to build the executable that has generated a coredump, and inside that path there should be some pretty printers. Usually, this path can be found here(on ubuntu): /usr/share/gcc-10/python/.

In my case it was in /opt/gcc/9.2.0/share/gcc-9.2.0/python/, because the gcc that I was using was built from sources.

That folder contains a folder called: libstdcxx which contains some python scripts that are used to print the variables nicer.

If you are investigating a coredump on a different server, you can copy that folder to the server using scp: scp -r /usr/share/gcc-10/python/ user@server:/path/to/server/.

Activate the pretty printers from the gdb config file

Pretty printers, added this in ~/.gdbinit:

python
import sys
# gcc-9
sys.path.insert(0, '/usr/share/gcc/python')
from libstdcxx.v6.printers import register_libstdcxx_printers
register_libstdcxx_printers (None)
end

# Will print the whoile object
set pagination off
set print array on

# It will format the output
set print pretty on

· One min read
Hreniuc Cristian-Alexandru

Where are the coredumps generated?

$ cat /proc/sys/kernel/core_pattern

/tmp/core-%e.%p.%h.%t

Before running your executable, set the limit for the coredump:

$ ulimit -c unlimited

You can add ulimit -n 99999 in your ~/.bashrc. But if you want all gui apps(qtcreator) to use it, you should also include it in your ~/.xsession:

#!/bin/bash

ulimit -n 99999

You mai also need to update the limits(only if setting the limit returns error):

sudo nano /etc/security/limits.conf

* hard nofile 99999

# --------------------

sudo nano /etc/pam.d/common-session

session required pam_limits.so