Quick Start

go back

 

   BTR debug a project. The general steps are:

   1) set bdenug.ini

   2) startup BTR

   3) F2 hotkey

   4) build cmd to compile&link a project

   5) F3 hotkey

   6) startup the project

   7) the project throw a exception( dead , unlimit-loop , unexpect result ......)

   8) F2 hotkey

   9) input some debug command to locate the error code

   10) find out the bug reason 

   11) modify the code and have another try

   12) shutdown to exit BTR when no bug found

      

   The most important command is "build". Where you can use BTR "build" a project, where you can debug the project. 

 

Windows helloworld

1)The demo directory is: demo\win\helloworld. 

2)Start BTR.

          start up bdee.exe( enterprise edition , the BTR server , free version need not this step )

          start up bd.exe

3)Build the demo

          F2 

          build d:\BTR\demo\win\helloworld

          F3

4) Start helloworld.exe

          cd d:\BTR\demo\win\helloworld\debug

          helloworld.exe

5) The program crashed.

6) In bd.exe command prompt

          F2

          flash -s a.txt

7) Use notepad to read d:\BTR\client\a.txt or d:\BTR\a.txt

8) The last code stop at *q++ = *p++;.

9) Analysis the bug reason.

10) Modify the code *q++ = *p++; to *p++ = *q++;

11) Build helloword again

          build d:\BTR\demo\win\helloworld
          F3

12) Run helloworld.exe again

13) Helloworld.exe crashed again

14) In bd.exe command prompt

          F2

          flash -s a.txt

15) Read a.txt and analysis the bug reason.

16) Modify code :

          char buf[ 5 ];  =>  char buf[ 20 ];

          insert *q = 0; before printf("%s" , buf );

17) Build and run helloworld.exe , no bug find.

          build d:\BTR\demo\win\helloworld
          F3


18) Exit BTR( exit bd.exe )

          F2

          shutdown

19) When all BTR client are closed , shutdown BTR server.

          To bdee.exe( enterprise edition):

          shutdown

    

 

Windows hellowindow

1)The demo directory is: demo\win\hellowindow. 

2)Build the project and run demo\win\hellowindow\Debug\hellowindow.exe

3)When hellowindow.exe crashed 

          F2

          flash -s a.txt 

4)Because hellowindow.exe is multithread process, use filter to see clearly:

          flash hellowindowview.cpp -s b.txt

5)Find out the bug reason is wild pointer.

 

 

 

Windows library

1)The demo directory is: demo\win\tstl and demo\win\tstl\usel.  tstl project is library. usel project call the function in tstl.lib. 

2)Use BTR build demo\win\tstl project

3)Use microsoft visual c++ compile&link demo\win\tstl\usel 

4)Run demo\win\tstl\usel\Debug\usel.exe. The process dummyed.

5)Use flash command to find out that process in unlimited loop.

          F2

          flash -s a.txt

6)Find out the bug reason that pointer is not shift. Add

          p++;

 

 

Windows dll

1)The demo directory is: demo\win\tstdll and demo\win\tstdll\usedll.  tstdll project is library. usedll project call the function in tstdll.dll. 

2)Use BTR build demo\win\tstdll project

3)Use microsoft visual c++ compile&link demo\win\usedll 

4)Run demo\win\tstdll\usedll\Debug\usedll.exe. The process crashed.

5)Use flash command to find out that dll is loaded , but function no called.

       F2

       flash -s a.txt

6)Find out the bug reason that dll function pointer is wrong.Modify:

       DEFFUNC pFunc;

       pFunc = ( DEFFUNC )( dll_load.GetDllFunction( dll_handle ,"fntstdll") );

       x = ( *pFunc )( atoi( str ) );

 

7)By the way, you can debug usedll project. Note the bdebug.ini add:

       [PV_FUNCTION]
       ( DllLoad , DllUnload )

  a) bd.exe

  b) run usedll.exe , usedll.exe end

  c) in bd.exe , use F2 to pause. Watch the pv function 

       pv

       Resource:10000000 [usedllDlg.cpp:00186] dll_handle = dll_load.DllLoad( "..\\..\\Debug\\tstdll.dll" );

       1 unfree pointers.

  d) dll_handle is regard as pointer. dll_handle is unreleased in the whole process period. So add the code line:

       dll_load.DllUnload( dll_handle );

8) When you debug usedll project. We sorry to rememer you that you must use vc++ to compile&link the tstdll project, then run usedll.exe, otherwise BTR will throw error.  BTR can not serve two debug modules in one time.     

 

Linux helloWorld

1)The demo directory is: demo/linux/helloworld

2)makefile,  the simplist makefile demo . Include make clean and make , no bdebug.ini file.

3) build

       cd /home/usr/BTR

       ./bd.exe

       F2

       build /home/usr/BTR/linux/helloworld

       F3

4) run 

       cd /home/usr/BTR/demo/linux/helloworld/release

       ./helloworld.exe

       the program crashed 

5) flash command to see crashed line.

       F2

       flash -s a.txt

       /home/usr/BTR/a.txt 

       ...

6) The error line is :

       [main.cpp : 00016 ]   delete( pCMyHost );

7) Please try to correct the error.

 

 

Linux echo

1)The demo directory is: demo/linux/echo

2)makefile,  like demo/linux/helloworld/makefile.

3)use BTR build the project

       cd /home/usr/BTR

       ./bd.exe

       F2

       build /home/usr/BTR/linux/echo

       F3

4)run echo.exe

       cd /home/usr/BTR/demo/linux/echo/release

       ./echo.exe

       Please input send string(Q: quit):

       Q

5) use pv comannd to see memory leak

       F2

       pv

       There are one pointer unreleased:

       [echosrv.cpp : 00083] m_pCTcp = new CTcp();

6) Please try to correct the error.

 

 

Linux lib & dll

1)The demo directory is: 

       demo/linux/mylib

       demo/linux/mydll

       demo/linux/myexe

       Project myexe call mylib and mydll.

2)Make them.

3)First debug mylib

       ./bd.exe

       F2

       build /home/usr/BTR/linux/mylib

       F3

4) Modify myexe makefile , add -lpthread and -lrt. Then make. Don't use build cmd to compile my.exe.

5) Run /home/usr/BTR/linux/myexe/my.exe

       ./my.exe

       Process crashed .

6) Use flash command in bd.exe terminal

       F2

       flash -s a.txt

       Look a.txt to see that the error is 

       [mycp.cpp : 00019] while( *q ) *q++ = *p++;

       Correct the error and make them. Don't use build cmd to compile my.exe.

7) Second debug myexe. In its bdebug.ini add [PV_FUNCTION]

    ( DllLoad , DllUnload ) , then build myexe project.

       build /home/usr/BTR/linux/myexe

       F3

8) run my.exe

       ./my.exe

       Input number:3    

       Library copy result=3

       Call dll , segma( 3 ) = 6

9) BTR throw out a error.

       Error 20011: [pointer:0 ] wild pointer.

       The line is:

       [main.cpp:00053] delete ( pCMyCP );

       Ignore the error report, use F3 hotkey to continue

       F3    

       The process exit.

10) use pv to see resource management bug.

       F2

       pv

       Resource:09c990f0 [main.cpp:00042] handle = pCDllLoad->DllLoad( "../mydll/segma.so" );

       1 unfree pointers.

       The error shows that DllUnload() not called.

 

Linux KDE form

1) The demo directory is: demo/linux/TheApp1

2) Use linux KDE/c++ IDE to create a project named theapp1

3) After add button and label, add event code. Try run it.

4) Quit KDE , run ./configure , make , make distclean.

  cd demo/linux/TheApp1
  ./configure
  make clean
  make

5) Confirm that the project run ok. 

6) BTR build the KDE project

     ./bd.exe
    F2
    build /home/usr/BTR/linux/TheApp1
    F3

7) Double click the exe file:

    demo/linux/TheApp1/src/theapp1

8) use BTR commands to track the process.

     F2
     flash -s a.txt
     func -s b.txt
     lon
     F3
     ...
     F2
     clog -s c.txt
     loff
     F3

 

 

Java HelloWorld

 

   Make sure that you have already installed JDK ;Make sure that you have already run BTR jshell\java_setup.bat; Make sure that you have already appended %JAVA_HOME%\jre\lib\ext\jni.jar to CLASSPATH.

1) The demo directory is: demo\win\javahello

   Use or not use eclipse to generate a empty project. eclipse put src and class in difference path. Here *.java and it's *.class in same path.

2) Create make.bat

3) Set bdebug.ini

4) Build demo\win\javahello

   bd >

   F2

   build demo\win\javahello

   F3

5) Run java

   cd   demo\win\javahello\top

   java -jar f1.jar

6) See java running code log.

   F2

   flash -s a.txt

7) Add BTR output string API in code. Function bprint() defined at jni\bdg.java. 

   bdg.bprint( "test x+y" );

   bdg.bprint( s );

   If not use BTR later, please delete bdg.bprint() lines, otherwise it will cause error.

8) Build demo\win\javahello again , run java again

9) Watch bdg.bprint() send to BTR output string.

 

 

Java Servlet

  Make sure that you have already installed J2EE before this sample.

1) The demo directory is: demo\win\servlet

2) Create make.bat

3) Set bdebug.ini

The *.java map to its *.class path must assigned in bdebug.ini

[JAVA_PKGMAP]
...\demo\win\servlet\src : ...\demo\win\servlet\test\WEB-INF\classes

4) build 

   bd >

   F2

   build demo\win\servlet

   F3

5) start tomcat , deploy servlet.

  You can start tomcat , websphere or weblogical, or other 3rd product. If TestServlet.war deployed successful , then you can use BTR debug it.

   

6)use ie brower , input url:

http://127.0.0.1:8080/TestServlet

 

7) use flash command in BTR , look at the servlet code log.

   F2

   flash 

 

 

 

JavaBean

    This sample depend on where your javaweb installed . If C:\apache-tomcat-7.0.23\webapps\examples\WEB-INF\classes\jsp2\examples is a javabean.

     1) copy demo\win\JavaBean\bdebug.ini and make.bat to C:\apache-tomcat-7.0.23\webapps\examples\WEB-INF\classes\jsp2\examples

     2) use BTR build command

     bd >

     F2

     build C:\apache-tomcat-7.0.23\webapps\examples\WEB-INF\classes\jsp2\examples

     F3

     3)  start tomcat

     4)  in IE, input url:

     http://127.0.0.1:8080/index --> JSP sample

     5) use BTR to see the running java bean.

     F2

     flash -s a.txt

     6) open a.txt to see code log.

C#

     

1)The demo directory is: demo\win\cs. 

2)Please look at the debug.ini file to see how to configure C sharp project. 

3)Build the demo

 bd >

 F2

 build ...\demo\win\cs

 F3

4)Run c sharp project.

 Dobule click demo\win\cs\obj\Debug\cs.exe. A form displayed.

5)Use BTR , see the code history:

 F2

 flash -s a.txt

 

Question & Answer

 

 Code sequence:

  1) if ( b )

  Q: Why "[00016][x.cpp]if ( b ) goto LABEL_EXIT;" appears two times?

  A: [00016][x.cpp]if ( b ) goto LABEL_EXIT;

       [00016][x.cpp]if ( b ) goto LABEL_EXIT;

       This is right , because b == true.

  2) thread crash

  Q: The following code log:

       [00016][x.cpp] x = 1;
       [00260][x.cpp] x += strlen( s );
       [05012][y.cpp] while( bOk ) {
       [05013][y.cpp] Sleep( 300 );
       [05013][y.cpp] Sleep( 300 );
        ...
       [05013][y.cpp] Sleep( 300 );

       Which line crashed?

  A: "[00260][x.cpp] x += strlen( s ); " crashed . Because x.cpp in one thread. y.cpp run in another thread. [00260][x.cpp] don't quit function body but quit its thread. So strlen( s ) must be the crashed line.

  3) crashed at int x = 0;

  Q: The following code log:

       [00906][x.cpp] pCSegma->segma( num ) ;

       [01509][segma.cpp] int x = 0;

       The process crashed at line [01509][segma.cpp] , why ?

  A: Because pCSegma is a wild pointer. Sometimes the address of pCSegma is valid, but no ram assigned to pCSegma. Usr should check if  "pCSegma = new ..." line appears.

 

Value Trace

   1) value log

    [00055][x.cpp] bwatch( "NUM" , &num , 4 );
    NUM: 00 00 00 00 [int]=0 [uint]=0
    [01026][y.cpp] num++;
    NUM: 01 00 00 00 [int]=1 [uint]=1
    [01026][y.cpp] num++;
    NUM: 02 00 00 00 [int]=2 [uint]=2
    [03016][x.cpp] num--;
    NUM: 01 00 00 00 [int]=1 [uint]=1
    [03062][z.cpp]    pPersonItem->sex = MAN;
    NUM: 5B 00 00 00 [int]=91 [uint]=91
    [03016][x.cpp] num--;
    NUM: 5A 00 00 00 [int]=90 [uint]=90

   Q: Line [03062][z.cpp] changed num value , why?

   A: Because pPersonItem is wild pointer . The address of sex is the same as num , so the value of num changed.

VC demo 

 1) Can't build

 Q: I copy the demo projects into my harddisk , I can't build some VC project, why?

 A: Please rebuild the project in visual studio first. Because visual studio environment changed, output path changed.

KDE demo 

 1) Can't build

 Q: I copy the KDE demo project into my harddisk , I can't build it, why?

 A: Please create a KDE project again in your linux . Then use ./configure, make clean, make , make distclean , check it . Then try again.

By the way , you can try the others x-window ui IDE tools. Generate Makefile and try to use BTR build them.

 2) Can't build

 Q:I can't build the KDE form demo sample , why?

 A:Please check if your linux has already installed KDE.

 

BTRweb

 1)character disorder

 Q:I use BTRweb , sometimes I find that character is disordered , why? 

 A:Please set UTF charset.

 2)c#

 Q:I use BTRweb and browser test.cs code file, I find disordered char.

 A:Because the first 3 chars (0xEF 0xBB 0xBF) in *.cs is microsoft c# file flag. so the char disordered. IE or firefox can not recognize these characters. 

So you can browser the c# file , but must not modify them use BTRweb.exe.