Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to limit the size of core dump file when generating it using GDB

I am running an embedded application on ARM9 board, where total flash size is 180MB only. I am able to run gdb, but when I do

(gdb) generate-core-dump

I get an error

warning: Memory read failed for corefile section, 1048576 bytes at 0x4156c000.
warning: Memory read failed for corefile section, 1048576 bytes at 0x50c00000.
Saved corefile core.5546
The program is running.  Quit anyway (and detach it)? (y or n) [answered Y; input not from terminal]
Tamper Detected
**********OUTSIDE ifelse 0*********
length validation is failed

I also set ulimit -c 50000 but still the core dump exceeds this limit. When I do ls -l to check file size it is over 300 MB. In this case how should I limit the size of core dump?

like image 874
manav m-n Avatar asked Oct 12 '11 08:10

manav m-n


People also ask

How do I change core file size?

Using ulimit to set core file sizes ulimit is a program, included in most Linux distributions, that allows you to specify many file size limits for the shell and all of its subprocesses. The above commands set the core file size to 100 Mb or "unlimited", respectively.

Is truncated expected core file size GDB?

Truncated Core Files gdb likely performs a calculation similar to the above to calculate the expected core file size. In short, if gdb says your core file is truncated, it is very likely truncated. One of the most likely causes for truncated core dump files is the system ulimit.

How do I change the size of my Ulimit core?

The command "ulimit" can be used to change values. The option "-f" indicates the maximum file size in blocks of 512 bytes. The option "-c" defines the maximum size of Core files in blocks of 512 bytes or unlimited.

How big is a core dump file?

The maximum size of the resulting core filename is 128 bytes (64 bytes in kernels before 2.6. 19). The default value in this file is "core".


2 Answers

GDB does not respect 'ulimit -c', only the kernel does.

It's not clear whether you run GDB on target board, or on a development host (and using gdbserver on target). You probably should use the latter, which will allow you to collect full core dump.

Truncated core dumps are a pain anyway, as often they will not contain exactly the info you need to debug the problem.

like image 101
Employed Russian Avatar answered Sep 28 '22 10:09

Employed Russian


in your shell rc-file:

limit coredumpsize 50000             # or whatever limit size you like

that should set the limit for everything, including GDB

Note:

If you set it to 0 , you can make sure your home directory is not cluttered with core dump files.

like image 43
Tilo Avatar answered Sep 28 '22 09:09

Tilo