--- /dev/null
+#!/bin/sh
+
+# Invocation: ./get_macro_value.sh <kernel_src> <method_list_file> <method_symbol>
+kernel_src="$1"
+method_list_file="$2"
+method_symbol="$3"
+
+if [ $# -ne 3 ]; then
+ echo "bad invocation"
+ exit 1
+fi
+
+if [ ! -d "$kernel_src" ]; then
+ echo "error: $kernel_src is not a directory"
+ exit 1
+fi
+
+# first search for the file containing the symbol
+symbol_file="$(grep "[,:]$method_symbol\(,\|$\)" "$method_list_file" | cut -d':' -f1)"
+if [ -z "$symbol_file" ]; then
+ echo "error: can't find method in method list file"
+ exit 1
+fi
+echo "$symbol_file"
+if [ "$(echo "$symbol_file"|wc -l)" -gt 1 ]; then
+ echo "error: too many hits"
+ exit 1
+fi
+cd "$kernel_src"
+grep_res="$(grep -R -n "\(^\| \)$method_symbol *\($\|(\)" "$symbol_file")"
+if [ -z "$grep_res" ]; then
+ echo "error: can't find method in source"
+ exit 1
+fi
+echo "$grep_res"
+if [ "$(echo "$grep_res"|wc -l)" -gt 1 ]; then
+ echo "error: too many results"
+fi
+symbol_line="$(echo "$grep_res" | cut -d':' -f1)"
+echo "symbol is in $symbol_file, line $symbol_line"
+
+# now isolate the method's code
+partial_symbol_file="$(cat "$symbol_file" | tail -n "+$symbol_line")"
+symbol_lines="$(echo "$partial_symbol_file" | grep -n '^}' | head -n 1 | cut -d':' -f1)"
+echo "symbol is $symbol_lines lines long"
+symbol_code="$(echo "$partial_symbol_file" | head -n "$symbol_lines")"
+echo "dumping symbol code:"
+echo ""
+echo "$(echo "$symbol_code" | sed 's|^| |g')"
+echo ""
+
+# grep for case statements
+case_exprs="$(echo "$symbol_code" | grep 'case *[a-zA-Z0-9_]*:' | sed 's|.*case *\([a-zA-Z0-9_]*\):.*|\1|g')"
+echo "ioctls found: $(echo "$case_exprs" | tr '\n' ' ')"
+