This is the mail archive of the 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]

header dependency; Was: [rfc] Re-merged regcache.h patch


When revising the regcache.h patch, I knocked up the attatched (perl
free zone :-) script.  It grubs around the source identifying which .c
files actually use functions/variables from a given header file.

While this script is probably best treated as a novelty - it only just
works for regcache.h - I'm wondering if anyone knows of a GPL package
that does this analysis properly.


rm ${parser}
rm ${refs}

# Generate a parser to recognize any reference to a method in "$@"
echo "Creating parse script" 1>&2
cat "$@" | awk '
# external pointer
$0 != n = gensub (/^extern [^\(\*]*\*([_[:alpha:]][_[:alnum:]]*);$/, "\\1", 1) {
    print "/[^[:alnum:]]" n "[[:space:]]*\\[/ { p = 1 } # pointer"
$0 != n = gensub (/^extern [^\(]*[^_\([:alnum:]]([_[:alpha:]][_[:alnum:]]*)[[:space:]]\(.*$/, "\\1", 1) {
    print "/[^[:alnum:]]" n "[[:space:]]*\\(/ { p = 1 } # function"
' >> ${parser}
cat <<EOF >> ${parser}
p { print FILENAME ":" NR ":" \$0; p = 0; }
cat ${parser}

# Parse the source files printing out a list of all references
echo "Parsing" 1>&2
find * \
    -name '*-stub.c' -prune \
    -o -name 'nlm' -prune \
    -o -name 'gdbserver' -prune \
    -o -name 'testsuite' -prune \
    -o -name '*\.c' -type f -print | xargs awk -f ${parser} > ${refs}

# Create a summary file of files containing refs
cut -d: -f1 < ${refs} | sort -u > ${files}

# Check to see if the file includes our target
xargs grep -e '#include *"'$1'"' < ${files} | cut -d: -f 1 | sort > ${good}

diff ${good} ${files}

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