|  | 
 
 In this tutorial I will take you through the basic steps you need to go through in order to debug a DLL you are writing for Blitz in Visual C++. This is not going to be a tutorial on all of the debugging features of Visual C++, or how to debug, just what you need to do to start! 
 First off all, I am assuming you have set up your DLL in accordance with the article written by Speccyman: Creating a DLL in Microsoft VC++ 6 for use with BB. That also means I am assuming that you are using Visual C++ version 6. I'm not sure how much it varies between versions! 
 Pick one of your blitz source files that uses the DLL and that you can create an executable file from. I'm using ClockDemo.bb which uses the Win Blitz DLL. Pick "Program->Create Executable..." and save it somewhere you will remember it, in this case I have saved it to the C root.  
 
 You now need to start up Visual C++ and open up your workspace with the DLL in it, go to one of the functions that will be called, and set a breakpoint. This will be where the code will stop running, and you will be able to watch it and see what happens! You set a breakpoint by clicking on the line you want the debugger to stop at, and pressing F9. You can also press the right mouse-button and pick "Insert/Remove Breakpoint" from the pop-up menu. Pressing F9 on a line that already has a breakpoint will get rid of that breakpoint. When you have set one, a red dot will appear next to the line the code will stop at... 
 I have set mine right at the start of the function. 
 You will need to create a debug version of your DLL, and tell Visual C++ where to put it. From the "Build" menu, pick "Set Active Configuration". 
 Select the debug configuration like I have. You now need to save the debug version of your DLL in the same directory as your executable. From the "Project" menu pick "Settings" (or press ALT-F7). 
 Click on the "Link" tab, and specify the output file-name. See how I have put it in C:\ where the executable is. 
 Well you can't just run the DLL, it needs something to call its functions. So press "F5" to start debugging the DLL. Visual C++ now asks you where the executable is that calls this DLL... 
 Here I have set it to my clockdemo.exe file. Once you click on OK you will get a warning that is telling you that there is no debugging information in the executable you have specified, don't worry, you are not going to be debugging that, just your DLL! So just click on OK. You may also be warned that not all your breakpoints are valid. Again, ignore this. However, it will mean that rather than just launching the program and running straight off, it will start the application, and stop it straight away in the rather distressing disassembly view! 
 That yellow arrow is showing you where the debugger is currently. This will make almost no sense to most of us, so press F5 to run to the next break-point. 
 As soon as one of your break-points is reached the Visual C++ debugger will pop up and you can use all the normal Visual C++ debugging instructions (pick them from the Debug menu) to do the normal Blitz Debugger type things (Step Into, Step Over etc). In this picture I have stepped on a few instructions, and am ready to see if my timer gets set! 
 
 Play around with the debugger features, they are very powerful, and when you want to know if that parameter is getting across right, or which call is failing this is a very useful way to sort out the Blitz bugs from the C bugs! Feel free to email me if you have any questions! 
 For a printable copy of this article, please click HERE. 
 This site is Copyright© 2000-2004, BlitzCoder. All rights reserved.   |