Debugging Core Files Using HP WDB

Avoiding Core File Corruption
You can prevent overwriting of core files from a different process by setting the kernel to store
the core file in a process-specific file name, <core.pid> (where pid is the process ID of the
process that dumped the core).
Avoiding Core File Corruption for Applications Running HP-UX 11i v1 and HP-UX
11i v2
To prevent overwriting of core files from different processes for applications running HP–UX
11i v1 or 11i v2 operating systems, you must set the kernel parameter core_addpid to 1. The core
file is stored in a file name, <core.pid> in the current directory. To store core files in a specific
filesystem, you must switch to the required directory (using the cd command) and then run the
required application.
To set the kernel parameter to prevent core file corruption, complete the following steps:
1. Create the following script, corepid, as a superuser of the system before running the
application:
# cat <path>/corepid
case $1 in
on) echo "core_addpid/W 1\ncore_addpid?W 1" | adb -w -k
/stand/vmunix /dev/mem;;
off) echo "core_addpid/W 0\ncore_addpid?W 0" | adb -w -k
/stand/vmunix /dev/mem;;
stat) echo "core_addpid/D\ncore_addpid?D" | adb -w -k
/stand/vmunix /dev/mem;;
*) echo "usage $0: on|off|stat";;
esac
2. To enable or disable the feature to store the core file in a specific file, core.pid , run the
script, corepid, with the following parameter:
#<path>/corepid[on|off]
3. To view the current settings for this feature, run the corepid, with the following parameter:
#<path>/corepid [stat]
The following example illustrates how to use this script:
#cat /tmp/corepid
case $1 in
on) echo "core_addpid/W 1\ncore_addpid?W 1" | adb -w -k
/stand/vmunix /dev/mem;;
off) echo "core_addpid/W 0\ncore_addpid?W 0" | adb -w -k
/stand/vmunix /dev/mem;;
stat) echo "core_addpid/D\ncore_addpid?D" | adb -w -k
/stand/vmunix /dev/mem;;
*) echo "usage $0: on|off|stat";;
esac
#/tmp/corepid stat
core_addpid:
core_addpid: 0
core_addpid:
core_addpid: 0
#/tmp/corepid on
core_addpid: 0 = 1
core_addpid: 0 = 1
#/tmp/corepid stat
core_addpid:
core_addpid: 1
core_addpid:
core_addpid: 1
#/tmp/corepid off
30