| 1 | #!/usr/bin/env bash
 | 
| 2 | #
 | 
| 3 | # Miscellaneous scripts for figuring out OVM.
 | 
| 4 | #
 | 
| 5 | # Usage:
 | 
| 6 | #   ./ovm.sh <function name>
 | 
| 7 | 
 | 
| 8 | set -o nounset
 | 
| 9 | set -o pipefail
 | 
| 10 | set -o errexit
 | 
| 11 | 
 | 
| 12 | source build/common.sh  # $PY27
 | 
| 13 | 
 | 
| 14 | grep-cpython() {
 | 
| 15 |   find $PY27 -type f | xargs grep "$@"
 | 
| 16 | }
 | 
| 17 | 
 | 
| 18 | grep-cpython-c() {
 | 
| 19 |   find $PY27 -type f -a -name '*.[ch]' | xargs grep "$@"
 | 
| 20 | }
 | 
| 21 | 
 | 
| 22 | # https://stackoverflow.com/questions/2224334/gcc-dump-preprocessor-defines
 | 
| 23 | 
 | 
| 24 | # 493 variables.
 | 
| 25 | pp-vars() {
 | 
| 26 |   gcc -E -dM - < $PY27/pyconfig.h
 | 
| 27 | }
 | 
| 28 | 
 | 
| 29 | # Modify this function to trace imports.  It helped with 're'.
 | 
| 30 | # Where do codecs.c and codecs.py get imported?
 | 
| 31 | # codecs.py is from encodings, but I don't know where that gets imported.
 | 
| 32 | #
 | 
| 33 | # I think runpy use encodings.
 | 
| 34 | blame-import() {
 | 
| 35 |   PYTHONVERBOSE=9 \
 | 
| 36 |   _OVM_RESOURCE_ROOT=. PYTHONPATH=. \
 | 
| 37 |     python -S -c 'from bin import oil; import sys; print sys.modules["codecs"]'
 | 
| 38 | }
 | 
| 39 | 
 | 
| 40 | "$@"
 |