dbx - attach to process, break when crash

Hey everyone,

I have a process that is crashing, and I'd like to have some way to see where it crashes. Is this possible?

There are two ways you can deal with this problem.
The first, and most obvious one, is to run the program under the debugger (e.g.: dbx). When it crashes, you'll get the debugger's prompt and you can explore the location and causes of the crash.

Since running under the debugger may change the behavior of the program, you may want to let it run normally. If the program crashes due to certain signals (e.g.: SIGSEGV - indicating accessing a bad address, such as address 0), it can produce a core file, at least under Unix variants, including Linux. You can then use the debugger to look at the state of the program at the time of the crash and analyze the reason for the crash.

For example, if the name of the program is prog, then
use: dbx prog core
to explore the state of the program at the time of the crash.

The core file is not always produced even when the program crashes due to a signal such as SIGSEGV. The reason is that there is a limit on the size of the core file. Often, this limit is 0. You can change this limit to "unlimited" and then the core file will be produced when the need arises.
The command to change the core file size limit is shell dependent.
For example, under bash I am using: ulimit -c unlimited
under tcsh, I use: limit coredumpsize unlimited

Wow, great! Thanks for the help, this exactly what I was looking for!

---------- Post updated at 10:28 AM ---------- Previous update was at 10:22 AM ----------

If the limit is exceeded, does that mean the core file will not be created at all? Or will it just be truncated? I guess both wouldn't help much.