This is the mail archive of the
gdb@sources.redhat.com
mailing list for the GDB project.
script to figure what's in one igen model and not in another.
- From: cgd at broadcom dot com
- To: gdb at sources dot redhat dot com
- Cc: echristo at redhat dot com
- Date: 30 Jul 2002 15:35:37 -0700
- Subject: script to figure what's in one igen model and not in another.
"I hope you never have to use this, but if you do..."
I wrote a little script that, if pointed at an igen file, will make a
stab at telling you which instructions, functions, etc., are defined
for a specific model but not for another model.
run like:
compare_igen_models mipsI mipsII mips.igen
or:
compare_igen_models sb1 mdmx *.igen
(multiple file names are allowed, w/ no file names will take input
from stdin.)
*twitch*
If anybody has improvements, i'll be glad to see them... 8-)
chris
=============================================================================
#!/bin/sh
# $Id: compare_igen_models,v 1.1 2002/07/30 22:34:09 cgd Exp $
if [ "$#" -lt 2 ]; then
echo "usage: $0 model1 model2 [file ...]" 1>&2
exit 1
fi
model1="$1"
model2="$2"
shift; shift
gawk -v model1="$model1" -v model2="$model2" -F: -- '
BEGIN {
thang_count = 0
}
function thang_has_model(t, m) {
# printf("thang_has_model(%s, %s) (@ %s:%d)\n", t, m,
# thangs[t,"file"], thangs[t,"line"]);
if (thangs[t,"nmodels"] == 0) return 1;
for (j = 0; j < thangs[t,"nmodels"]; j++) {
# printf("\tmodel \"%s\"\n", thangs[t,"models",j]);
if (thangs[t,"models",j] == m) return 1;
}
# printf("\t-> 0\n");
return 0
}
function compare_models(m1, m2) {
# printf("compare_models(%s, %s)\n", m1, m2);
seen_any=0
for (i = 0; i < thang_count; i++) {
if (thang_has_model(i, m1) && !thang_has_model(i, m2)) {
if (!seen_any) {
printf("Things in %s but not in %s:\n", m1, m2);
seen_any = 1
}
printf("%s:%d: %s\n", thangs[i,"file"],
thangs[i,"line"], thangs[i,"contents"]);
}
}
}
$0 ~ /^:/ && $2 == "model" {
# ignore.
# print "model " $0
}
($0 ~ /^:/ && $2 == "function") || \
($0 ~ /^:/ && $2 == "internal") || \
($0 ~ /^[0-9]/) {
# a function, internal, or instruction.
current_thang = thang_count
thang_count++
thangs[current_thang,"file"] = FILENAME
thangs[current_thang,"line"] = NR
thangs[current_thang,"contents"] = $0
thangs[current_thang,"nmodels"] = 0
if ($0 ~ /^:/) {
thangs[current_thang,"type"] = $2
} else {
thangs[current_thang,"type"] = "instruction"
}
}
$0 ~ /^\*/ {
split(substr($1, 2), tmp_models, /,/)
for (key in tmp_models) {
current_model = thangs[current_thang,"nmodels"]
thangs[current_thang,"nmodels"]++
thangs[current_thang,"models",current_model] = tmp_models[key]
}
}
END {
compare_models(model1, model2)
if (seen_any) printf("\n");
compare_models(model2, model1)
}' "$@"