Solution to Problem 1: ====================== Initially copy the file "bb.py" to the build directory, this is the tool we will be using and is among the resources of the assignment, then open terminal go to the $BUILD directory and run the given tool in interactive mode, $ ./bb.py -i -s $SOURCE once the tool has started, type toplev.o for name of file and for level enter 1, this will generate following output : ------------------------------------------------------------------------- $BUILD/gcc/toplev.o |--/home/pritam/gcc_4.7/gcc-4.7.2/gcc/toplev.c [s1] NOTE:Here "/home/pritam/gcc_4.7/gcc-4.7.2/" is $SOURCE directory ------------------------------------------------------------------------- Solution to Problem 2: ====================== Run the given tool in interactive mode, $ ./bb.py -i -s $SOURCE once the tool has started, type insn-output.c for name of file and for level enter 3, this will generate following tree. $BUILD/gcc/insn-output.c |--$BUILD/gcc/tmp-output.c [s1] |--|--$BUILD/gcc/build/genoutput [s1] |--|--|--$BUILD/build-i686-pc-linux-gnu/libiberty/libiberty.a [s1] |--|--|--$BUILD/gcc/build/errors.o [s1] |--|--|--$BUILD/gcc/build/genoutput.o [s1] |--|--|--$BUILD/gcc/build/gensupport.o [s1] |--|--|--$BUILD/gcc/build/ggc-none.o [s1] |--|--|--$BUILD/gcc/build/min-insn-modes.o [s1] |--|--|--$BUILD/gcc/build/print-rtl.o [s1] |--|--|--$BUILD/gcc/build/read-md.o [s1] |--|--|--$BUILD/gcc/build/read-rtl.o [s1] |--|--|--$BUILD/gcc/build/rtl.o [s1] |--|--|--$BUILD/gcc/build/vec.o [s1] |--|--$BUILD/gcc/insn-conditions.md [s1] |--|--|--$BUILD/gcc/tmp-cond.md [s1] |--|--/home/pritam/gcc_4.7/gcc-4.7.2/gcc/config/i386/i386.m NOTE:Here "/home/pritam/gcc_4.7/gcc-4.7.2/" is $SOURCE directory As you can see the insn-output.c is dependent on genoutput which is an executable file which when run makes use of the target machine's `.md' files, and generate insn-output.c. Among the dependencies you will find insn-conditons.md. This file is also generated at build time of gcc and is target machine dependent. Similarly we can generate trees for insn-emit.c and insn-recog.c $BUILD/gcc/insn-recog.c |--$BUILD/gcc/tmp-recog.c [s1] |--|--$BUILD/gcc/build/genrecog [s1] |--|--|--$BUILD/build-i686-pc-linux-gnu/libiberty/libiberty.a [s1] |--|--|--$BUILD/gcc/build/errors.o [s1] |--|--|--$BUILD/gcc/build/genrecog.o [s1] |--|--|--$BUILD/gcc/build/gensupport.o [s1] |--|--|--$BUILD/gcc/build/ggc-none.o [s1] |--|--|--$BUILD/gcc/build/min-insn-modes.o [s1] |--|--|--$BUILD/gcc/build/print-rtl.o [s1] |--|--|--$BUILD/gcc/build/read-md.o [s1] |--|--|--$BUILD/gcc/build/read-rtl.o [s1] |--|--|--$BUILD/gcc/build/rtl.o [s1] |--|--|--$BUILD/gcc/build/vec.o [s1] |--|--$BUILD/gcc/insn-conditions.md [s1] |--|--|--$BUILD/gcc/tmp-cond.md [s1] |--|--/home/pritam/gcc_4.7/gcc-4.7.2/gcc/config/i386/i386.md [s1] $BUILD/gcc/insn-emit.c |--$BUILD/gcc/tmp-emit.c [s1] |--|--$BUILD/gcc/build/genemit [s1] |--|--|--$BUILD/build-i686-pc-linux-gnu/libiberty/libiberty.a [s1] |--|--|--$BUILD/gcc/build/errors.o [s1] |--|--|--$BUILD/gcc/build/genemit.o [s1] |--|--|--$BUILD/gcc/build/gensupport.o [s1] |--|--|--$BUILD/gcc/build/ggc-none.o [s1] |--|--|--$BUILD/gcc/build/min-insn-modes.o [s1] |--|--|--$BUILD/gcc/build/print-rtl.o [s1] |--|--|--$BUILD/gcc/build/read-md.o [s1] |--|--|--$BUILD/gcc/build/read-rtl.o [s1] |--|--|--$BUILD/gcc/build/rtl.o [s1] |--|--|--$BUILD/gcc/build/vec.o [s1] |--|--$BUILD/gcc/insn-conditions.md [s1] |--|--|--$BUILD/gcc/tmp-cond.md [s1] |--|--/home/pritam/gcc_4.7/gcc-4.7.2/gcc/config/i386/i386.md [s1] Both of these files also have a similar dependency tree as insn-output.c. That means these files are generated in the similar manner i.e. by an exeutable which makes use of target machine`s md file. There is one important thing to notice here that whatever files was generated from the gen* executable files have names of the format tmp-* which are then renamed to insn-*. For example: tmp-output.c ===>>> insn-output.c tmp-recog.c ===>>> insn-recog.c tmp-emit.c ===>>> insn-emit.c Solution to Problem 3: ====================== To find all '.c' files that depend on regex.o write following command: ./bb.py -i -r -s ./../gcc-4.6.2/ This will generate the following result after giving filename as 'libiberty.a', level as '10', and file extension as '.c' : ------------------------------------------------------------------------------- Ctrl + D to exit Enter the file name [^cc1$]:regex.o Enter the level [1]:10 Expression for stages for selective view Possible stage options for three stages and post stage3: 1 2 3 4/p Possible connectors (in priority): not and or Ex: 1 and not 2 and not 3 or p (Default is any stage) [1 or 2 or 3 or p] Enter the expression: Enter the file extensions for selective browsing (Default: all extensions) [.c .h .o exe (no extension) .S .cc .tmp etc]: .c Do you want to display intermediate dependencies of files with non-specified extensions (y/n) [Default y]:n **************** /home/pritam/gcc_4.7/build/build-i686-pc-linux-gnu/libiberty/regex.o ******************** ^--^--^--$BUILD/gcc/tmp-attrtab.c [s1] ^--^--^--^--$BUILD/gcc/insn-attrtab.c [s1] ^--^--^--^--^--^--^--^--$BUILD/gcc/cc1-checksum.c [s1] ^--^--^--$BUILD/gcc/tmp-automata.c [s1] ^--^--^--^--$BUILD/gcc/insn-automata.c [s1] ^--^--^--^--^--^--^--^--$BUILD/gcc/cc1-checksum.c [s1] ^--^--^--^--$BUILD/gcc/cc1-checksum.c [s1] ^--^--^--$BUILD/gcc/tmp-condmd.c [s1] ^--^--^--^--$BUILD/gcc/build/gencondmd.c [s1] ^--^--^--^--^--^--^--^--^--$BUILD/gcc/tmp-attrtab.c [s1] ^--^--^--^--^--^--^--^--^--^--$BUILD/gcc/insn-attrtab.c [s1] ^--^--^--^--^--^--^--^--^--$BUILD/gcc/tmp-automata.c [s1] ^--^--^--^--^--^--^--^--^--^--$BUILD/gcc/insn-automata.c [s1] ^--^--^--^--^--^--^--^--^--$BUILD/gcc/tmp-emit.c [s1] ^--^--^--^--^--^--^--^--^--^--$BUILD/gcc/insn-emit.c [s1] ^--^--^--^--^--^--^--^--^--$BUILD/gcc/tmp-extract.c [s1] ^--^--^--^--^--^--^--^--^--^--$BUILD/gcc/insn-extract.c [s1] ^--^--^--^--^--^--^--^--^--$BUILD/gcc/tmp-opinit.c [s1] ^--^--^--^--^--^--^--^--^--^--$BUILD/gcc/insn-opinit.c [s1] ^--^--^--^--^--^--^--^--^--$BUILD/gcc/tmp-output.c [s1] ^--^--^--^--^--^--^--^--^--^--$BUILD/gcc/insn-output.c [s1] ^--^--^--^--^--^--^--^--^--$BUILD/gcc/tmp-peep.c [s1] ^--^--^--^--^--^--^--^--^--^--$BUILD/gcc/insn-peep.c [s1] ^--^--^--^--^--^--^--^--^--$BUILD/gcc/tmp-recog.c [s1] ^--^--^--^--^--^--^--^--^--^--$BUILD/gcc/insn-recog.c [s1] ^--^--^--^--^--$BUILD/gcc/tmp-attrtab.c [s1] ^--^--^--^--^--^--$BUILD/gcc/insn-attrtab.c [s1] ^--^--^--^--^--^--^--^--^--^--$BUILD/gcc/cc1-checksum.c [s1] ^--^--^--^--^--$BUILD/gcc/tmp-automata.c [s1] ^--^--^--^--^--^--$BUILD/gcc/insn-automata.c [s1] ^--^--^--^--^--^--^--^--^--^--$BUILD/gcc/cc1-checksum.c [s1] ^--^--^--^--^--$BUILD/gcc/tmp-emit.c [s1] ^--^--^--^--^--^--$BUILD/gcc/insn-emit.c [s1] ^--^--^--^--^--^--^--^--^--^--$BUILD/gcc/cc1-checksum.c [s1] ^--^--^--^--^--$BUILD/gcc/tmp-extract.c [s1] ^--^--^--^--^--^--$BUILD/gcc/insn-extract.c [s1] ^--^--^--^--^--^--^--^--^--^--$BUILD/gcc/cc1-checksum.c [s1] ^--^--^--^--^--$BUILD/gcc/tmp-opinit.c [s1] ^--^--^--^--^--^--$BUILD/gcc/insn-opinit.c [s1] ^--^--^--^--^--^--^--^--^--^--$BUILD/gcc/cc1-checksum.c [s1] ^--^--^--^--^--$BUILD/gcc/tmp-output.c [s1] ^--^--^--^--^--^--$BUILD/gcc/insn-output.c [s1] ^--^--^--^--^--^--^--^--^--^--$BUILD/gcc/cc1-checksum.c [s1] ^--^--^--^--^--$BUILD/gcc/tmp-peep.c [s1] ^--^--^--^--^--^--$BUILD/gcc/insn-peep.c [s1] ^--^--^--^--^--^--^--^--^--^--$BUILD/gcc/cc1-checksum.c [s1] ^--^--^--^--^--$BUILD/gcc/tmp-recog.c [s1] ^--^--^--^--^--^--$BUILD/gcc/insn-recog.c [s1] ^--^--^--^--^--^--^--^--^--^--$BUILD/gcc/cc1-checksum.c [s1] ^--^--^--$BUILD/gcc/tmp-emit.c [s1] ^--^--^--^--$BUILD/gcc/insn-emit.c [s1] ^--^--^--^--^--^--^--^--$BUILD/gcc/cc1-checksum.c [s1] ^--^--^--$BUILD/gcc/tmp-enums.c [s1] ^--^--^--^--$BUILD/gcc/insn-enums.c [s1] ^--^--^--^--^--^--^--^--$BUILD/gcc/cc1-checksum.c [s1] ^--^--^--$BUILD/gcc/tmp-extract.c [s1] ^--^--^--^--$BUILD/gcc/insn-extract.c [s1] ^--^--^--^--^--^--^--^--$BUILD/gcc/cc1-checksum.c [s1] ^--^--^--$BUILD/gcc/tmp-min-modes.c [s1] ^--^--^--^--$BUILD/gcc/min-insn-modes.c [s1] ^--^--^--^--^--^--^--$BUILD/gcc/tmp-attrtab.c [s1] ^--^--^--^--^--^--^--^--$BUILD/gcc/insn-attrtab.c [s1] ^--^--^--^--^--^--^--$BUILD/gcc/tmp-automata.c [s1] ^--^--^--^--^--^--^--^--$BUILD/gcc/insn-automata.c [s1] ^--^--^--^--^--^--^--$BUILD/gcc/tmp-condmd.c [s1] ^--^--^--^--^--^--^--^--$BUILD/gcc/build/gencondmd.c [s1] ^--^--^--^--^--^--^--$BUILD/gcc/tmp-emit.c [s1] ^--^--^--^--^--^--^--^--$BUILD/gcc/insn-emit.c [s1] ^--^--^--^--^--^--^--$BUILD/gcc/tmp-extract.c [s1] ^--^--^--^--^--^--^--^--$BUILD/gcc/insn-extract.c [s1] ^--^--^--^--^--^--^--$BUILD/gcc/tmp-opinit.c [s1] ^--^--^--^--^--^--^--^--$BUILD/gcc/insn-opinit.c [s1] ^--^--^--^--^--^--^--$BUILD/gcc/tmp-output.c [s1] ^--^--^--^--^--^--^--^--$BUILD/gcc/insn-output.c [s1] ^--^--^--^--^--^--^--$BUILD/gcc/tmp-peep.c [s1] ^--^--^--^--^--^--^--^--$BUILD/gcc/insn-peep.c [s1] ^--^--^--^--^--^--^--$BUILD/gcc/tmp-preds.c [s1] ^--^--^--^--^--^--^--^--$BUILD/gcc/insn-preds.c [s1] ^--^--^--^--^--^--^--$BUILD/gcc/tmp-recog.c [s1] ^--^--^--^--^--^--^--^--$BUILD/gcc/insn-recog.c [s1] ^--^--^--$BUILD/gcc/tmp-modes.c [s1] ^--^--^--^--$BUILD/gcc/insn-modes.c [s1] ^--^--^--^--^--^--^--^--$BUILD/gcc/cc1-checksum.c [s1] ^--^--^--$BUILD/gcc/tmp-opinit.c [s1] ^--^--^--^--$BUILD/gcc/insn-opinit.c [s1] ^--^--^--^--^--^--^--^--$BUILD/gcc/cc1-checksum.c [s1] ^--^--^--$BUILD/gcc/tmp-output.c [s1] ^--^--^--^--$BUILD/gcc/insn-output.c [s1] ^--^--^--^--^--^--^--^--$BUILD/gcc/cc1-checksum.c [s1] ^--^--^--$BUILD/gcc/tmp-peep.c [s1] ^--^--^--^--$BUILD/gcc/insn-peep.c [s1] ^--^--^--^--^--^--^--^--$BUILD/gcc/cc1-checksum.c [s1] ^--^--^--$BUILD/gcc/tmp-preds.c [s1] ^--^--^--^--$BUILD/gcc/insn-preds.c [s1] ^--^--^--^--^--^--^--^--$BUILD/gcc/cc1-checksum.c [s1] ^--^--^--$BUILD/gcc/tmp-recog.c [s1] ^--^--^--^--$BUILD/gcc/insn-recog.c [s1] ^--^--^--^--^--^--^--^--$BUILD/gcc/cc1-checksum.c [s1] **************** /home/pritam/gcc_4.7/build/libiberty/regex.o ******************** ^--^--^--$BUILD/gcc/cc1-checksum.c [s1] --------------------------------------------------------------------------------------------- Solution to Problem 4: ====================== To get the number of generator executable write the following command : ./bb.py -i -g -b . -s ./../gcc-4.7.2/ make.log This will generate the following output: ---------------------------------------------------------------------------------------------- ******************** Generator Executables ******************** genattr gencheck gencondmd genenums gengtype genopinit genrecog genattr-common genchecksum genconfig genextract genhooks genoutput genattrtab gencodes genconstants genflags genmddeps genpeep genautomata genconditions genemit gengenrtl genmodes genpreds Generator Executables count:25 ------------------------------------------------------------------------------------------------ Solution to Problem 5: ====================== To get the differences among dependencies upto 3 levels for cc1 among the 3 stages write the following command : ./bb.py -i -s ./../gcc-4.6.2/ For generating the result following inputs are given in the interative session : 1) As, default file name is cc1, we need not give file name. 2) For the number of levels, 3 is given as input. 3) Following are the 3 expressions entered : 1 and not 2 and not 3 and not p not 1 and 2 and not 3 and not p not 1 and not 2 and 3 and not p Following is the output : -------------------------------------------------------------------------------------------------------- Ctrl + D to exit Enter the file name [^cc1$]: Enter the level [1]:3 Expression for stages for selective view Possible stage options for three stages and post stage3: 1 2 3 4/p Possible connectors (in priority): not and or Ex: 1 and not 2 and not 3 or p (Default is any stage) [1 or 2 or 3 or p] Enter the expression: 1 and not 2 and not 3 and not p Enter the file extensions for selective browsing (Default: all extensions) [.c .h .o exe (no extension) .S .cc .tmp etc]: **************** /home/avantika/Desktop/gccpackage/build/gcc/cc1 ******************** $BUILD/gcc/cc1 |--$BUILD/gcc/tree-browser.o [s1] |--|--/home/avantika/Desktop/gccpackage/gcc-4.7.2/gcc/tree-browser.c [s1] Ctrl + D to exit Enter the file name [^cc1$]: Enter the level [1]:3 Expression for stages for selective view Possible stage options for three stages and post stage3: 1 2 3 4/p Possible connectors (in priority): not and or Ex: 1 and not 2 and not 3 or p (Default is any stage) [1 or 2 or 3 or p] Enter the expression: not 1 and 2 and not 3 and not p Enter the file extensions for selective browsing (Default: all extensions) [.c .h .o exe (no extension) .S .cc .tmp etc]: **************** /home/avantika/Desktop/gccpackage/build/gcc/cc1 ******************** $BUILD/gcc/cc1 Ctrl + D to exit Enter the file name [^cc1$]: Enter the level [1]:3 Expression for stages for selective view Possible stage options for three stages and post stage3: 1 2 3 4/p Possible connectors (in priority): not and or Ex: 1 and not 2 and not 3 or p (Default is any stage) [1 or 2 or 3 or p] Enter the expression: not 1 and not 2 and 3 and not p Enter the file extensions for selective browsing (Default: all extensions) [.c .h .o exe (no extension) .S .cc .tmp etc]: **************** /home/avantika/Desktop/gccpackage/build/gcc/cc1 ******************** $BUILD/gcc/cc1 -------------------------------------------------------------------------------------------------------- As, is clear from the ouput only stage 1 has 2 files which are not present in other two stages.