This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Finding orphan files


FYI,

I've added the attached script to the ARI.  Revealing ...
http://sources.redhat.com/gdb/current/ari/

Andrew
#!/bin/sh

usage ()
{
    cat <<EOF
Usage: $0 [--print-doc] path-to-gdb
EOF
    exit 1
}

print_doc=
case "$1" in
    --print-doc ) print_doc=true ; shift ;;
esac

if test ! "${print_doc}"
then
    if test $# -ne 1
    then
	usage
    fi
    gdb=$1 ; shift
    configure_tgt=${gdb}/configure.tgt
    configure_host=${gdb}/configure.host
    config=${gdb}/config
fi



# Check that there is a directory for all host/target CPUs

obsolete_cpu ()
{
    # ari.*.bug: <FILE>:<LINE>: <CATEGORY>: <BUG>: <DOC>
    cat <<EOF
$1: $2: regression: obsolete cpu: No config directory for cpu
EOF
}

if test "${print_doc}"
then
    obsolete_cpu "" ""
else
    awk '
/gdb_(target|host)_cpu=[a-z]/ {
    cpu = gensub(/^.*gdb_(target|host)_cpu=([-a-z0-9]*).*$/, "\\2", 1)
    print cpu, FILENAME, FNR
}
' ${configure_tgt} ${configure_host} | sort -u | while read cpu filename fnr
    do
	if test ! -d ${config}/${cpu}
	then
	    obsolete_cpu ${filename} ${fnr}
	fi
    done
fi



# Check that there is a .mt file for all targets

obsolete_target ()
{
    # ari.*.bug: <FILE>:<LINE>: <CATEGORY>: <BUG>: <DOC>
    cat <<EOF
$1: $2: regression: obsolete target: No .mt file for target
EOF
}

if test "${print_doc}"
then
    obsolete_target "" ""
else
    awk '
/gdb_target=/ {
    print gensub(/^.*gdb_target=([-a-z0-9]*).*$/, "\\1", 1), FNR
}
' < ${configure_tgt} | sort -u | while read target fnr
    do
	if find ${config} -name ${target}.mt -print | awk '
BEGIN { status = 0 }
{ status = 1}
END { exit status}'
	then
	    obsolete_target ${configure_tgt} ${fnr}
	fi
    done
fi



# Check that there is a .mh file for all hosts

obsolete_host ()
{
    # ari.*.bug: <FILE>:<LINE>: <CATEGORY>: <BUG>: <DOC>
    cat <<EOF
$1: $2: regression: obsolete host: No .mh file for host
EOF
}

if test "${print_doc}"
then
    obsolete_host "" ""
else
    awk '
/gdb_host=/ {
    print gensub(/^.*gdb_host=([-a-z0-9]*).*$/, "\\1", 1), FNR
}
' < ${configure_host} | sort -u | while read host fnr
    do
	if find ${config} -name ${host}.mh -print | awk '
BEGIN { status = 0 }
{ status = 1}
END { exit status}'
	then
	    obsolete_host ${configure_host} ${fnr}
	fi
    done
fi


# Check that every .mh file has a gdb_host=
obsolete_mh ()
{
    # ari.*.bug: <FILE>:<LINE>: <CATEGORY>: <BUG>: <DOC>
    cat <<EOF
$1: $2: regression: obsolete .mh file: No host for .mh file
EOF
}

if test "${print_doc}"
then
    obsolete_mh "" ""
else
    find ${config} -name *.mh -print | while read mh
    do
	host=`basename $mh .mh`
	if grep "gdb_host=${host}[^-a-z0-9]" ${configure_host} > /dev/null
	then
	    :
	else
	    obsolete_mh ${mh} 0
	fi
    done
fi



# Check that every .mt file has a gdb_target=

obsolete_mt ()
{
	# ari.*.bug: <FILE>:<LINE>: <CATEGORY>: <BUG>: <DOC>
	cat <<EOF
${mt}: 0: regression: obsolete .mt file: No target for .mt file
EOF
}

if test "${print_doc}"
then
    obsolete_mt "" ""
else
    find ${config} -name *.mt -print | while read mt
    do
	target=`basename $mt .mt`
	if grep "gdb_target=${target}[^-a-z0-9]" ${configure_target} > /dev/null
	then
	    :
	else
	    obsolete_mt ${mt} 0
	fi
    done
fi



# Check that every config .h file is used

obsolete_h ()
{
    # ari.*.bug: <FILE>:<LINE>: <CATEGORY>: <BUG>: <DOC>
    cat <<EOF
$1: $2: regression: obsolete .h file: The .h file is not used
EOF
}

if test "${print_doc}"
then
    obsolete_h "" ""
else
    find ${config} -name '*.h' -print | while read h
    do
	f=`basename $h .h`
	if find ${config} -name CVS -prune -o -type f -print \
		| xargs grep "[^-a-z0-9]$f\.h" \
		| awk '
BEGIN { status = 0 }
{ status = 1}
END { exit status}'
	then
	    obsolete_h ${h} 0
	fi
    done
fi

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]