Technical article 110108

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?

OpenServer 6.0.0OpenServer 5.0.0OpenServer 5.0.2OpenServer 5.0.4OpenServer 5.0.5OpenServer 5.0.6OpenServer 5.0.7UnixWare 7.0.0UnixWare 7.0.1UnixWare 7.1.0UnixWare 7.1.1UnixWare 7.1.2UnixWare 7.1.3UnixWare 7.1.4Open UNIX 8

Written · Last revised

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_dump
http://uw714doc.xinuos.com/en/man/html.4/core.4.html

So core dumps are created by abnormal program termination.

How can I find core files?
cd / ; find . -print | grep core
What can we do with a core file?
Use the "grab" command within "debug":
http://uw714doc.xinuos.com/en/SDK_cdebug/_Debug_menu.html
http://uw714doc.xinuos.com/en/SDK_cdebug/_Session_2_Why_Did_it_Dump_core.html
For more information see:
http://uw714doc.xinuos.com/en/SDK_cdebug/CONTENTS.html

You 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 54

On 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.

From the Xinuos technical article database, record 110108. Reproduced with permission. The original is at www.sco.com/ta/110108, which is reachable but blocked from search engines.

Next step

Need this fixed rather than explained?

Tell us the release, what the system runs and what it is doing. We will reply by email with what we would do next.

  • You deal with the people who do the work
  • No obligation, and no upgrade required before we will help
  • We tell you plainly if something is not worth doing

Send an enquiry

We reply by email. If a server is down, say so in the first line. You can also write to help@scoexpert.com.