@echo off

rem deleting possible previous demo generated files.
if exist MON.sym del MON.sym
if exist MON.dat del MON.dat
if exist profile.txt del profile.txt
if "%OS%" == "Windows_NT" goto is_nt
if exist CTCHTML\index.html deltree /y CTCHTML
goto over
:is_nt
if exist CTCHTML rmdir /s /q CTCHTML
:over

echo.
echo Now instrumenting the example test program stacktest.exe with
echo CTC++. stacktest.exe is a simple C++ program consisting of source
echo files cstack.cpp, revstack.cpp and stacktst.cpp. Program
echo implements a stack data structure and tests its integrity.
echo With CTC++ we can check the thoroughness of this testing.
echo.
echo Now compiling and linking the instrumented version of the program.
echo When working with makefiles, the recommended (and most simple) way
echo to do the instrumentation would be to to prepend the make command
echo with "ctcwrap ctc-options make ....". It could be used also in this
echo case, because the makefile here emits the compile and link command
echo without path.
echo.
echo However, here we arrange the makefile to emit directly the ctc
echo instrumentation commands. The makefile has variables CC and LINK32,
echo which we replace as follows:
echo.
echo nmake "CC=ctc -i m cl" "LINK32=ctc cl" clean all
echo.
pause
nmake /nologo "CC=ctc -i m cl" "LINK32=ctc cl" clean all

echo.
echo As a result we have instrumented executable stacktest.exe.
echo Let's run it:
echo.
pause
echo stacktest.exe
stacktest.exe
echo.
pause

echo.
echo Now we run ctcpost to get Execution Profile Listing to stdout, as follows:
echo.
echo ctcpost MON.sym MON.dat -p - "|" more
echo.
pause
ctcpost MON.sym MON.dat -p - | more

echo.
pause
echo.
echo There's also Untested Code Listing. Let's see how it looks:
echo.
echo ctcpost MON.sym MON.dat -u - | more
pause
ctcpost MON.sym MON.dat -u - | more

echo.
echo ---End of demo---
