← Back to team overview

sslug-teknik team mailing list archive

Re: core fil

 

> Jeg har opsaveret at der ligger en fil ved navn "core" nogle forskellige
> steder på maskinen. Jeg blev nød til at shutdown maskinen pga af denne
> fil, fordi jeg ikke kunne starte netscape op. Hvad gør denne fil og
> hvorfor er den der

Detta script hjälper dig att hitta programmet som orsakade core filen.

----------Klipp här----
#!/bin/sh

# name:      idcore  --  identify which binary caused a core dump
# author:    c.l.s. (cspiel@xxxxxxxxxxxxxxxxxxxxx)
# last rev.: 1998-01-22  11:14
# bash ver.: 1.14.7(1)
# $Id$

# display help message
# char* disp_help(void)
function disp_help
{
        echo "usage:"
        echo "  idcore [OPTION] [[COREDUMP] ...]"
        echo
        echo "  If COREDUMP is omitted the core file in the current"
        echo "  directory is used."
        echo
        echo "  -h, --help      display this help message"
        echo "  -v, --version   show version of idcore"
        echo "  -b, --brief     brief format, i.e. filename only"
        echo "  -l, --long      long format, with filename, signal,
user,"
        echo "                  date, and backtrace"
}

# retrieve name binary that caused core dump via gdb
# char* get_name(const char* mode, const char* name)
function get_name
{
        case "$1" in
                brief)
                        echo q | gdb --quiet --core="$2" 2>&1 | head -1
| \
                        sed -ne "s/^.*\`\(.*\)'\.$/\1/p"
                        ;;
                standard)
                        echo q | gdb --quiet --core="$2" 2>&1 | head -2
                        ;;
                long)
                        dump=$(echo -e "where\nq" | \
                                gdb --quiet --core="$2" 2>&1)
                        echo "$dump" | head -2 | sed -ne '2,2s/\.$//p'
                        ls -l "$2" | \
                        awk '{ print "on", $6, $7, $8, "caused by", $3
}'
                        echo
                        echo "backtrace:"
                        echo "$dump" | sed -ne '/^(gdb) /s/^(gdb) //p'
                        ;;
        esac                            
}
#
# start of main
#
myname=$(basename "$0")         # name of shell-script
mode=standard                   # normal mode of operation

case "$1" in
        -h | --help)
                disp_help
                exit 1
                ;;
        -v | --version)
                echo "version 0.1.0"
                exit 0
                ;;
        -b | --brief)
                mode=brief
                shift
                ;;
        -l | --long)
                mode=long
                shift
                ;;
        -* | --*)
                echo "$myname: unknown option $1"
                exit 2
                ;;
esac

if [ -z "$1" ]; then
        # no argument -> look at core in the current directory
        get_name "$mode" core
else
        # process all arguments
        for c; do
                # echo file we are processing
                if [ "$mode" != "brief" ]; then
                        echo "$c: "
                fi
                get_name "$mode" "$c"
        done
fi
exit 0
----------Klipp här----

-- 
E-mail: diver1@xxxxxxxxxx          Home: http://www.algonet.se/~diver1
<@       Software is like sex, it's best when it's free!
( )    Find out more about linux now! <http://www.linux.org>
~ ~


References