Debugging Core Files Using HP WDB (5900-1573; WDB 6.2; January 2011)
The file command is the simplest method to analyze the cause of a core dump at the
HP-UX prompt.
The file command displays the signal that triggered the core dump.
For example:
$ file core
core: core file from 'a' - received SIGBUS
This example illustrates that the program dumped a core after receiving the SIGBUS
signal.
Common Signals That Cause Core Dumps
Following are some signals that commonly cause core dumps:
• SIGBUS
One reason why aSIGBUS signal is sent to a process is when the program attempts
to load or store a data item at a non-aligned address.
Example 1 illustrates a load or store operation of a data item at a non-aligned
address.
Example 1 SIGBUS Causes a Core Dump
$ cat a.c
#include <stdio.h>
int main()
{
char a[64], *b;
int *i;
b = a;
b++;
i = (int *)b;
printf("%i", *i);
return 0;
}
$ aCC a.c -o a
$ ./a
Memory fault(core dump)
$file core
core: core file from 'a' - received SIGBUS
In this example, the program attempts to load a data item at a non-aligned address,
which results in a SIGBUS signal.
The variable a is a local variable on the stack. The pointer b is set to point to the
start of a. The pointer b is set to increment such that it does not point to a word
aligned address. The value in pointer b is assigned to pointer i. When pointer i
is de-referenced, a SIGBUS signal is encountered.
Common Signals That Cause Core Dumps 7