Problem
What tools are there to help debug a core file and is there a script to produce a table of system call names and numbers?
Solution
- How do I analyze the core dump?What is a core dump?A core dump is the contents of the chief registers in the CPU.
Core files generated on SCO UnixWare 2.1.X and UnixWare 7 are given file names of the form core.pid, where pid is the process id of the process causing the core dump. On SCO OpenServer, core files are named simply core. Portable applications should not make assumptions about core file naming on target systems.
See: http://en.wikipedia.org/wiki/Core_dumphttp://uw714doc.xinuos.com/en/man/html.4/core.4.htmlSo core dumps are created by abnormal program termination.
How can I find core files?cd / ; find . -print | grep coreWhat can we do with a core file?Use the "grab" command within "debug":http://uw714doc.xinuos.com/en/SDK_cdebug/_Debug_menu.htmlhttp://uw714doc.xinuos.com/en/SDK_cdebug/_Session_2_Why_Did_it_Dump_core.htmlFor more information see:http://uw714doc.xinuos.com/en/SDK_cdebug/CONTENTS.htmlYou can just run the "core" file through "strings",
eg. # strings core[.[pid]] | pg and normally the first lines give
you the clue as to the culprit.Here's an example:/etc/rc2.d server # strings core.1076 | pg
CORE
CORE
pppd
/usr/sbin/pppd
CORE
CORE
UnixWare
server
7.1.4
Pentium III
CORE/etc/rc2.d server # debug
debug> grab -c core.1076
Using /usr/sbin/pppd as executable
Warning: No debugging information in /usr/sbin/pppd
Core image of pppd (process p1) created
Created core image(s) of 5 thread(s) for process p1
CORE FILE [_kill]
SIGNALED 6 (abrt) in p1.5
0xa7f914fc (_kill+12:) jb 0xa4e <a7f91f50>
debug>Alternatively, try the Skunkware core dump analysis package, procdump which is available from:
ftp://ftp2.sco.com/pub/skunkware/uw7/Packages/procdump-1.0.pkg- To understand then what system calls have been made,I need to map a system call entry number and system call name when, for example, analyzing a core dump:
The following script prints out a table of system call numbers and the corresponding system call names. For instance, to find out the system call name associated with system call number 54, you could run
/local/bin/syscalls | grep 54On an OpenServer 5 system, you would find the result to be "ioctl".
NOTE: The script assumes that the operating system's "sysent"
(system call entry) table has a "zero sentinel value", that
is, the end of the table is marked by a zeroed system call entry.
This is indeed the case for the SCO operating system releases
listed above, but may not be the case for others. Hence the
script may fail or report erroneous results for releases other
than those listed above.===============================/cut&paste/=====================================
#!/bin/ksh
# /local/bin/syscalls
# print list of system call numbers and names
# 99-03 john h. dubois iii (john@armory.com)
crash |&
integer i=0
typeset -i16 offset
while [ i -lt 300 ]; do
offset=$((i*8+4))
line="od sysent+${offset#16#}"
print -p "$line"
read -p cline
[[ "$cline" = *umpfile* ]] && read -p cline
[[ "$cline" = *ngine* ]] && read -p cline
set -- $cline
shift $(($#-1))
[ "16#$1" -eq 0 ] && break
print -p -r "ts $1"
read -p cline2
[[ "$cline2" == *+* || "$cline2" == *" T "* ]] && print -r "$cline2"
let i+=1
done | awk '
BEGIN {
count = 0
}
/ \+ / || $0 ~ " T " {
if ($0 ~ " T ")
syscall = $NF
else
syscall = $1
if (syscall != "nosys") {
calls[count] = syscall
maxcount = count
}
++count
}
END {
n = 0
minwidth = 8
fwidth = minwidth + 5
maxcol = int(80/fwidth)
for (i = 1; i <= maxcol; i++)
printf "%3s %-*s ","Num",minwidth,"Syscall"
print ""
for (i = 1; i <= maxcount; i++)
if (i in calls) {
len = length(calls[i])
if (len > minwidth)
totwidth = fwidth * 2
else
totwidth = fwidth
pos = pos + totwidth
if (pos > 79) {
print ""
pos = totwidth
}
printf "%3d %-*s ",i,totwidth-5,calls[i]
}
print ""
}
'
print -p quit
===============================/cut&paste/===================================== See also
The manual pages for crash, ksh, and awk"Unix Internals -- A Practical Approach", by Steve D. Pate, ISBN 0-201-87721-X, sections 7.3.4 and 5 for related discussion.