To build a debug version of Aspectator you can either run the following command:
$ make -j16 debugor make the appropriate actions by hand. The first action is to create a separate directory for it, say:
$ mkdir build-debug
$ cd build-debugThen you need to configure Aspectator:
$ MAKEINFO=missing ../aspectator/configure --enable-languages=c --disable-multilib --disable-nls --enable-checking=releaseand make its debug version:
$ make STAGE1_CXXFLAGS="-g -O0" all-stage1You can use option -jN for make to essentially speed up building, but it can cause failures (just invoke the command several times to overcome this):
$ make -j16 STAGE1_CXXFLAGS="-g -O0" all-stage1After making some changes to files starting with ldv- prefix it is strongly recommended to rebuild the debug version of Aspectator with -Werror flag to treat all warnings as errors:
$ make STAGE1_CXXFLAGS="-g -O0 -Werror" all-stage1To debug Aspectator you can use gdb or ddd:
$ ddd gcc/cc1 &To debug instrumentation you need to set the following environment variables:
set env LDV_STAGE=3
set env LDV_ASPECT_FILE=$ABS_PATH_TO_ASPECT_FILE
set env LDV_OUT=out.c
To debug C back-end you need to set the following environment variables:
set env LDV_STAGE=4
set env LDV_C_BACKEND_OUT=out.c
Note
These instructions were adapted from http://gcc.gnu.org/wiki/DebuggingGCC.
Sometimes developers need to track whether some memory issues (e.g. memory leaks, use after free, etc.) were introduced and to measure algorithms complexity. First of all you need to build a debug version of Aspectator (Building debug version of Aspectator) and install extra tools such as valgrind, valkyrie and kcachegrind.
To track memory issues you need to run Aspectator under valgrind (do not specify --suppressions if you do not have them):
LDV_ASPECT_FILE=$PATH_TO_ASPECT_FILE \
LDV_STAGE=$STAGE \
LDV_OUT=$PATH_TO_OUT \
valgrind \
--tool=memcheck \
--leak-check=yes \
--suppressions=gcc.supp \
--num-callers=500 \
--xml=yes \
--xml-file=output.xml \
$PATH_TO_ASPECTATOR_BUILD_DEBUG/gcc/cc1 \
$PATH_TO_INPUT_FILE
After that you can either inspect output.xml manually or use valkyrie:
$ valkyrie -l output.xmlTo measure CPU time consumption you need to run Aspectator under valgrind:
LDV_ASPECT_FILE=$PATH_TO_ASPECT_FILE \
LDV_STAGE=$STAGE \
LDV_OUT=$PATH_TO_OUT \
valgrind \
--tool=callgrind \
$PATH_TO_ASPECTATOR_PROFILED_DEBUG/gcc/cc1 \
$PATH_TO_INPUT_FILE
After that you can either inspect files callgrind.out.* manually or use some tool, e.g. kcachegrind:
$ kcachegrind -l callgrind.out.*