My C file is: test.c
>cc test.c --> gave me a.out
>./a/out -->Running this generated the core dump in the same location
My test.c file:
int myFunc(int *p);
int main (void)
{
int *p = 0; /* null pointer */
printf("Hello,World\n");
return myFunc (p);
}
int myFunc (int *p)
{
int y = *p;
return y+y;
}
Now I am using the dbx tool to analyze the core
> dbx a.out core
For information about new features see `help changes'
To remove this message, put `dbxenv suppress_startup_message 7.4' in your .dbxrc
Reading a.out
core file header read successfully
Reading ld.so.1
Reading libc.so.1
Reading libdl.so.1
Reading libc_psr.so.1
program terminated by signal SEGV (no mapping at the fault address)
Current function is a
14 int y = *p;
(dbx) where --> this displays the call stack of the current procedure and the parameters
=>[1] myFunc(p = (nil)), line 14 in "test.c"
[2] main(), line 7 in "test.c"
(dbx) list --> displays the current source code file
14 int y = *p;
15 return y+y;
16 }
(dbx) dump myFunc --> displays the values of variables in a function
p = (nil)
y = -39942352
(dbx) print p --> disaply the value of a variable or expression
p = (nil)
(dbx) quit --> exit from dbx command
Related :
- Creating and analyzing core dumps - Covers multiple platforms.Good to start with
- Core dump management on Solaris OS
- Core dump analysis on HP UX
- dbx man page
- gdb and dbx debuggers in Unix
The above program didn't crash on an AIX unix machine.May be it allows to access the 0X00 memory location.So what I think the kind of errors that are considered/handled might vary from unix OS to OS.Refer this link for an example of analyzing the core on AIX machine.
No comments:
Post a Comment