[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]

Re: Help - core dumps



Rajat Patni forced the electrons to say:
> Hi all,
> What are core dumps, and how can they be debugged?
> 

When a program that is running tells the operating system to do something
which the OS cannot do, either because it is beyond the capabilities of
the OS/processor (eg: x = 0; y = 1/x;) or because it tries to access
memory in which it has no business (eg: char *p = malloc (5); p[10] =
'a';), the OS kills the program, and stores the memory information
about the program in a file called core in the working directory of
the program. The core file has the details of the stack of the program
to aid in debugging. Thus, by just invoking gdb on the core file (gdb
a.out core) and tracing the stack backwards, one can exactly pinpoint
the location where the program crashed. The gdb command to trace the
stack is bt or backtrace.

Note that SUID root programs don't dump core. You can also manually force a
core dump by doing a kill -ABRT <pid> to maybe find out why a particular
program is taking too much time to run.

You should compile the source code with the -g flag to the compiler to enable
debugging.

Binand

- -- 
#include <stdio.h>                                   | Binand Raj S.
char *p = "#include <stdio.h>%cchar *p = %c%s%c;     | This is a self-
int main(){printf(p,10,34,p,34,10);return 0;}%c";    | printing program.
int main(){printf(p,10,34,p,34,10);return 0;}        | Try it!!

- --------------------------------------------------------------------
For more information on Linux in India visit http://www.linux-india.org/
The Linux India mailing list does not accept postings in HTML format.

------------------------------