Configuration
Before you can debug a project . The project must be compiled by BTR first.
cd d:\BTR
bd.exe
bd > F2
bd > build d:\test\myproject
bd.exe read the file d:\test\myproject\bdebug.ini, collect all parameters to compile.
Almost all of the parameters are copyed from microsoft visual studio, or copyed from makefile in linux.
Where is the bdebug.ini ? The file bdebug.ini must be saved at the same directory with the project
You may debug microsoft vc projects without any configuration.
bd > build d:\test\myproject
If your project have no syntax error . BTR debugger will build it successfully.
You may debug g++ ,gcc projects without any configuration.
bd > build \home\usr\test\myproject
If your project have no syntax error . BTR debugger will build it successfully.
If your [MAKE_CLEAN_COMMAND] is not "make clean" or [MAKE_COMMAND] is not "make" 。 The following parameters must config in bdebug.ini.
[MAKE_CLEAN_COMMAND]
make clean
<--- your make clean maybe make clear , make empty ,...
[MAKE_COMMAND]
make
<--- your make maybe make install , make all , make menu ,...
bdebug.ini is the same directory as makefile.In linux , gcc compiler maybe cc or g++ compiler. bd.exe need [MAKE_CLEAN_COMMAND] and [MAKE_COMMAND]. The items can not be empty.
A example of Makefile:
TEST_OBJS = ./test/test1.o
TEST_OBJS += ./test/alist.o
MAIN_OBJS = ./main/main.o ./main/init/init.o
HANDLE_OBJS = ./handle/hd.o
OBJS = $(TEST_OBJS) $(MAIN_OBJS) $(HANDLE_OBJS)
TARGET = Release/test.exe
CC = g++
CXXFLAGS = -Wall -O -g
LIBFLAG = -lpthread
%.o : %.cpp
$(CC) $(CXXFLAGS) -c $< -o $@
$(TARGET) : $(OBJS)
$(CC) $(CXXFLAGS) $(LIBFLAG) $^ -o $@
clean:
rm -rf test/*.o
rm -rf main/*.o
rm -rf main/init/*.o
rm -rf Release/*.exe
How to compile java project? javac.exe general *.class files. How to package java obj files? jar.exe general *.jar , *.war , *.ear.
bd.exe use shell to compile java. The shell file must generate manually. The shell file are component of commands:
( 1 )javac
( 2 )jar
( 3 )copy(cp)
( 4 )del(rm) ( 5 )cd
( 6 )rem(#)
You had best not delete *.class *.jar *.ear *.war files after javac.exe executed in the shell file.
The shell file is the same directory as bdebug.ini. The following parameters maybe set in bdebug.ini.
[JAVA_SHELL]
......
[JAVA_PKGMAP]
......
[JAVA_SHELL] is java shell file name. [JAVA_PKGMAP] is the path map. The homepath of *.java map to the home of package path of *.class , *.jar *.war , *.ear. If path of src equals to path of class , [JAVA_PKGMAP] can be empty.
Example1 ( application in win ):
make.bat:
cd top
del xxx\*.class
del main\*.class
del *.jar
javac xxx\subc.java
javac main\hello.java
jar cvfm f1.jar manifest.mf xxx\subc.class main\hello.class
cd ..
bdebug.ini:
[JAVA_SHELL]
make.bat
[JAVA_PKGMAP]
cd d:\BTR
bd.exe
bd >F2
bd >build E:\tool\JAVA_PRJ\App1
Example2 ( servlet in win ):
make.bat :
cd ..\servlet\src
javac TestServlet.java
copy TestServlet.class ..\test\WEB-INF\classes\.
cd ..
jar -cvf test.war test
copy test.war C:\tomcat\apache-tomcat-6.0.14\webapps\.
bdebug.ini:
[JAVA_SHELL]
make.bat
[JAVA_PKGMAP]
E:\JAVA_PRJ\servlet\src : E:\JAVA_PRJ\servlet\test\WEB-INF\classes
cd d:\BTR
bd.exe
bd >F2
bd >build E:\tool\JAVA_PRJ\servlet
C# has only one parameter config in bdebug.ini:
[C#_COMPILE_COMMAND]
......
C#_COMPILE_COMMAND] comes from the output window of vc#:
When c# project rebuild all succeeded , the compile command line will show as above.
[C#_COMPILE_COMMAND] command line usually very long, It is about 2000-4000 chars length. Note you should not split the command line into multiple lines.
For example:
[C#_COMPILE_COMMAND]
C:\WINDOWS\Microsoft.NET\Framework\v3.5\Csc.exe /noconfig /nowarn:17......
The last, build E:\BTR\demo\win\cs
PV functions are P function and V function. P function like:
handle = pfunc(....);
or
pointer = pfunc(....);
V function like:
vfunc( handle );
or
vfunc( pointer );
Where handle is int type( int or short ) , pointer is ram address.
PV function is resource management function, The first use of resource is P function . The last use of resource is V function.
( malloc , free ) is a pair of c , c++ PV functions.
pointer = ( PSTRUCT )malloc( size );
free( ( void *)pointer );
Java and C# PV function only like:
handle = pfunc(....);
vfunc( handle );
By default, BTR trace the ( malloc, free ) , ( new , delete ) functions in any time. Others PV function must defined in bdebug.ini.
For example:
file bdebug.ini:
[MAKE_CLEAN_COMMAND]
make clean
[MAKE_COMMAND]
make
[PV_FUNCTION]
( fopen , fclose )
( myopensock , myclosesock )
( AddANode , DelANode )
When debug a project, use command "pv" to see the un-released resource. BTR look resource handle as pointer.
bd.exe
bd >F2
bd >pv
VC
1) build failed
Q:Sometimes , I use BTR build vc project failed?
A:Please compile and link vc project in visual studio first , then you use BTR build the project.
GCC
1) make clean
Q: My makefile have no make clean, what should I do ?
A: Add make clean in makefile. bdebug.ini need make clean . [MAKE_CLEAN_COMMAND] param can't be empty. You can learn from BTR demo.
2) make command
Q:My make command in makefile is only one line , is that right?
A: Command only one line like: "gcc hello.c -o hello.out" is not right. Please split it into multiple lines. Please learn from BTR demo samples.
3) KDE makefile
Q:Sometimes I find KDE makefile make clean will cause error after BTR build them. Why?
A: BTR build KDE makefile , the makefile generated or execute by the following steps:
./configure
make clean
make
make distclean
make distclean again when make clean cause error.
4) -lrt -lpthread
Q: BTR built libtest.a ok. Then I use the libtest.a in another makefile of proejct, but make error. why ?
A; BTR insert time functions and thread functions in libtest.a , so -lpthread and -lrt parameter should append in your calling makefile.
Java
1) make.bat or make.sh
Q: My make.bat can compile my java project , but BTR can't. why?
A: Because del command added in the middle of the make.bat , sometimes BTR can't find *.class file. so BTR report error. The right way is :
del file1
del filen
javac ...
javac ...
copy ...
..
cd path
javac ...
javac ...
copy ...
jar ...
del ...
C#
1) [C#_COMPILE_COMMAND]
Q: I split the [C#_COMPILE_COMMAND] into multiple lines , is that right?
A: It is not right , though [C#_COMPILE_COMMAND] parameter has 3000-5000 bytes, but you can't change or spilt them even a single character.
2) [C#_COMPILE_COMMAND]
Q: I can not find param which [C#_COMPILE_COMMAND] needs?
A: Sorry , this version only support c# in VISUAL STUDIO 2008.net. VISUAL STUDIO 2010.net does not support, we will correct it.
PV Function
1) wrong pv function
Q: error_num = fopen_s( &fstream , fname , "wb" ); Is fopen_s pv function ?
A: fopen_s( ... ) is not pv function , because error_num is not resource handle or pointer. You can convert fopen_s( ... ) into pv funtion. For example:
FILE *CConvert::myfopen( const char *fname , const char *mode )
{
FILE *fstream ;
errrno_t error_num;
error_num = fopen_s( &fstream , fname , mode );
if ( !error_num ) fstream = NULL;
return fstream;
}
Then , ( myfopen , fclose ) is a pair of pv function.
2) ( malloc , free ) , ( new , delete )
Q: I add ( malloc , free ) for [PV_FUNCTION] parameter in bdebug.ini. Is that right?
A: You should not add ( malloc , free ) , ( new , delete ) in bdebug.ini. BTR has already regards them as pv functions. Bye the way , ram pointer resource pv functions only in C project is valid. Java and c# have integer handle resource pv functions only.
command
1) build slowly
Q: I use BTR debug my project , why its log have no [file][no] location information.
A: Because your project is too large and BTR is free version. This problem isn't exist in BTR enterprise version.
2) command no response
Q: I use "flash" command , BTR has no response any more , why?
A: You should input F2 hot key first, BTR in pause mode ,then you input BTR command. After doing these , you should press F3 hot key to go into continue mode .