Second closer look
1. Debug executable programs to prepare pre-
2. Engineering options
3. Set breakpoints and broke into the executable program
4. This value is stored in variable
5. Use Watches (Watch)
6. Use Inspectors (inspection device)
7. Using Evaluate / Modify (evaluated / modified)
8. In the code block inside and outside Stepping (single-step tracking)
9. Stepping type
10. Stepping annotation
11. Other tips
Okay, (then little to prepare it) now on track, after searching through the efforts of the previous code in the bug is still hiding in time, that is, before the article began tracking code in marking off bug / exception. The first is the preparatory stage.
1. Debug executable programs to prepare pre-
Before we begin the debugging executable programs, we need to ensure that some settings in most cases is correct. I will take one over a again, and briefly explain why it is necessary to do so. (If you are interested in something, then press the Help button, there will be many more detailed content). Now get started, first open the Project | Options option.
2. Engineering options
First of all, we “Compiler” (compilation) label office stopped. You just simply click the “Full debug” (full debug mode) button, we need to set the vast majority of the rest had buttoned up. The “Code optimization” (code optimization) is set to “None” (no) is always a good thing to do actually tell the compiler: All things have been good, just generate machine code on the line. In order to improve a little bit and not try to run the speed of other intelligent optimization. (Of course, everything is complete, you can open this.) Benefits of doing so is greatly reduced our debugging difficult. Because the process of writing the code and we like the compiler is not optimized. In the “debugging” (debug) panel, the “Debug information” (debugging information) elected (Tap), and must be set to “Line number information” (line number information). I also recommend the “Disable inline expansions” (disable inline expansion) of a selected. Inline expansion of the released code is good, but better to turn off the debugging, he will only make you more headache.
Then the “Pascal” label, especially in your project in Pascal unit or connected to use of the VCL controls based on Pascal (if you have the Pascal source code, the compiler will automatically use the settings in this section to re-compile). Here you have to “Optimization” optimization option to disable, and then usually I will “debugging” (debugging) of all the options chosen (box).
Next is the “Linker” (link) tag, we need to select the “Create debug information” (to generate debug information). “Use dynamic RTL” (with dynamic RTL) and “Don't generate state files” (do not generate the state file) is the option that caused the trouble. I usually use the status file (this allows incremental link, but the build directory will be produced in a 4-fold or greater in the executable file), from another perspective, this link will increase the speed of large projects. Use dynamic RTL itself is a controversy, there are a lot of support and opposition to the discussion.
Next is the “Directories / Conditionals” (path / conditions) label. Here we want to set the “Directories / Conditionals” (debug source path) value. We should be here forever set $ (BCB) sourcevcl, but if you have any other additional components if their paths are usually coupled with a good idea (the path between the path and use “;” separated or you can press the … button to pop up a dialog box to set them).
Finally and most important settings are in the “Packages” (package) on the label. Appropriately according to the debugging experience for all you have to disable the “Build with runtime packages” (compiled with runtime packages). The reason for this is the package itself does not contain and can not contain debugging information. This may not help you keep track of the standard VCL code, for example, would like to look at the parameters VCL function y when x is how to work. But most of the time, you will find the debugger to do the vast majority of your “symptoms” boils down to the VCL, despite the “cause” in your source code (or in other components (this is in our everyone who happened)). Once you post your final version, you can decide whether to use package. (Translator's Note: The nature of the package is a special DLL, run the package without (static) compilation of your program can run independently from the Cbuilder.), But in debugging, disable the swap. Press the OK button, and we are ready Well. The next dialog box opens only once, but our best to check the following settings are correct here. Well, open the “Tools | Debugger Options …” it.
Dialog box at the bottom of the “Integrated debugging” (integrated debugger) option is the key. Confident that we have hit the bait. Press the OK button and ready to compile the executable program it. I suggest to a thorough re-compile (choose Project | Build All), if you changed your settings, then (especially to change the “building with packages” after the manner of). This will ensure that all of our units in accordance with procedures as we want to be compiled.
3. Set breakpoints and broke into the executable program
As you've seen a debugger, like any other, C + + Builder provides powerful functions to set breakpoints. Basically, the code breakpoint is a point, thus stopping program execution (and out of different, this is only the implementation of the suspension) will return control to the debugger. Fairly easy to set a breakpoint. Just code you want to set the left and click on the gray trough area, you will see a red dot appears, this line will be red. This will run to the suspension, will return control to the debugger.
You may want to ask every time if I do not want to stop it? Of course, and very easy to do, depending on your criteria for suspension of the program? (Translator's Note: conditional breakpoint). In just the breakpoint (red dot) on the right-click pop-up menu, select from the “Breakpoint Properties” (Breakpoint Properties). Here you can set two attributes “Condition” (condition) and “Pass Count” (by number). Condition (condition) attribute too convenient. You can use the if () statement to input almost any conditions. But keep in mind the conditions in all variables, this break should be visible. Condition attributes have not been to the implementation of the compiler to compile the program, but at run time, when the program runs to break pause, examine whether the conditions meet the breakpoint. Condition is true, stop, or let the program continue running. Another attribute “Pass Count” (by number) are also easy to understand. Breakpoint will be stopped through the Pass Count times. Combination of these two properties, in debugging your code, you can set breakpoints very strict.
There is something to keep in mind that when you are in the debugger when an exception occurs, will produce abnormal Department breakpoint on the line code form. It is very easy to make. Once you get an exception should do after the steps I will show you how later in the stack trace back and find the real cause of abnormal (eg, caused by abnormal production of that little bit of code).
Another tips to keep in mind is that when you run your program, the code window at any point of the left blue line can be set to break. All illegal break point will become red with a yellow cross that line of code will become brown. Breakpoints are legitimate points into the red with a little green hook. Runtime, you can set / modify at any point, breakpoint immediately without having to recompile.
4. This value is stored in variable
Once your program in your breakpoint stopped, what to do? One thing you want to do and must do, that is stored in your program, look at all the variable real value. This section covers many aspects, you must adhere to put up with these boring things. Fortunately, when you read these, you'll be part of the debugger that features some of the most powerful new understanding. There are many ways to look at the value of the variable, mainly according to your purpose to decide. I will look at the current function from the Local Variables (local variables) start to finish they have.
View local variables do not have much to talk about. Just click on “View | Debug Windows | Local Variables”, or press ctrl-alt-L will pop up a window shows the current function of local variables. Window variables will be with you a single heading back under the executive or body of the update function to update.
5. Use Watches (Watch)
Next you can set a variable watch (variable observation) to see the program variables. As expressed by its name, the behavior of a variable and its value displayed in the variable observation window (click “View | Debug Windows | Watches” or press ctrl-alt-W). You can add an observation of two ways, first is a highlight in the code window, select your observation of the variable or expression (yes! Its most simple expression can be understood and evaluated, such as (i * j) +05 or SomeVector [i]. Name) and right-click and select “Debug | Add Watch at Cursor” or press ctrl-f5, will join the observation window. If necessary, will also open the observation window
You can also double-click an empty space in the observation window to add. Add watch dialog box pops up, “Expression” (expression) field do not mean to say, but others I would like to explain a few fields, they are also convenient.
“Repeat count” (duplicates) for you to observe a known length of the array of variables (such as a blah [50] array). You want to Expression (expression) set to the name of the array (in this case is blah). “Repeat count” set to the number of array elements (in this case is 50). Then every element of the array will be displayed (eg: blah [0], blah [1], blah [2] …).
“Digits” (decimal digits) is used to set the displayed decimal floating-point decimal digits. Click below to set the variable set is used to force the display type (an unsigned long integer will be displayed in hexadecimal format). Another point to highlight is that if you watch window using the mouse right-click pop-up menu after a watch will appear on the “Break When Changed” option, which will set a breakpoint in the variable in the change this variable will pause the program.
6. Use Inspectors (inspection device)
Inspect variables are variables in the data look a third way. Almost a full class of data observed the best way. There are two ways to inspect a variable. The first is the local variable window (local variables window), double-click a variable, it will pop-up “Debug Inspector” (debug inspection device) window, which displays all the variable “Data” (variables) (data (variable)), “Methods” (functions) (method (function)) and “Properties” (properties). If this is a simple data, this variable will display the name and its values. (Translator's Note: If it is an array then? Really good!)
You will notice, Debug Inspector (debug inspection device) is like the property editor (property editor). Of course this, more important is the fact that you can run in real time to change these values! ! ! Careful to use it! Changed into the bad value of the results will make you unspeakable grief. Inspection device can be used to quickly test the ability of (hypothetical) game levels (Translator note: as FPE, GM), rather than a compile – run – modify – compile – run cycle.
(For example visiting Form1) in the properties (attributes) page, you will see some of the property did not actually show its value, but rather shows the (read =, write =). If these values can be assigned, then, when you click in this area, you will notice a “?” Button to the right in property. Click this button system to perform the appropriate function will be to try to retrieve property values. We can give an example here – will give it the properties of Form1's MDIChildCount. Property values in MDIChildCoun area, click in the press “?” Button, wow, 0 (non-MDI is the procedure of the specified value). Powerful debugging capabilities inspection device not end here. Member variable in the inspection device can double-click the appropriate regional member variable inspection window open, and you begin to open the window to provide the same capabilities.
Inspection window of another useful feature is the ability to inherit from the object. This is to the area by right click on the appropriate choice “Descend” (inheritance) to do so. Inheritance result was a new variable. You will notice at the top of the drop-down List box in the variable names have been replaced by a new variable name. You can switch directly in the ListBox inspect variables. This allows different parts of the object switch quickly becomes very simple and not make visits to large and small window disrupt your work space.
One thing to keep in mind is that if you leave the function, or leave a variable scope, commissioning inspection device will lose track of the variables. If you need to look again, please re-set the inspection device. But your function code in the current step to run, then will automatically refresh visits.
7. Using Evaluate / Modify (evaluated / modified)
The final block shows the value of the variable or the way that Evaluate / Modify (evaluated / modified) window. This window can be as open as open inspection device, you want to Evaluate / Modify (evaluated / modified) Right-click the selected line of code “Debug | Evaluate / Modify” will pop up Evaluate / Modify (evaluated / modified) window . This window is used on the expression / variable evaluation and / or modified. Watches and / or inspectors can achieve the same function. But if you want to modify it, this is probably the best.
“This variable has heard enough, and now I want to see how my code in the end, instead of sitting here dry.” I hear you say so. The next section we will step in vivo tracking function until the breakpoint (remember the things in front of What?).
8. In the code block inside and outside Stepping (single step / trace)
In this there is one thing to keep in mind that the vast majority of speaking in front of the approach is to look at variable dynamic updates. So when you track to the new line when the value of the variable will be automatically re-evaluated and the value displayed in the window is updated as new current value.
Okay, when you click to set your breakpoints, you will see the variables you need to check. The next step is to step through the code and close observation of what actually happened and you guess are the same (by using the watches / inspectors and follow the code execution path forward).
9. Stepping type
This part of the explanation sounds rather simple. However, most of the following to discuss what do you use them (if have not heard elsewhere?). You can tell the debugger five “stepping types” (single-step type). Run menu, we will explain the order. I will also give them shortcuts. In debugging the frequency of use shortcut keys to use the menu options for more than (10 times more by the keyboard and menu selection 10 times, I think you know better).
The first is a “Step Over” (in a single step function in vitro) or f8. This will allow the debugger to execute code on the next line shows the current function of the code to stop, or when running to the last line of the current function, the debugger returns to the calling function to stop. When you call the function does not know the problem, stepping over function is very convenient.
The next one is “Trace Into” (track to the function body) or f7. If you are running the current line is to call a function, the debugger will call the function we have taken the first line (even implicitly call the function, such as a write property). Otherwise, the implementation of the current line to the next line. When you want to see what this function in the end, this feature is very handy.
Next is the “Trace to Next Source Line” (track to the next source line) or shift-f7. The debugger will run to the next line of code with debugging information. This “Trace Into” the difference between, let us take an example to illustrate. When we call a no source code windows API functions and the API function calls in our code in a callback function. “Trace to Next Source Line” will be the first line in the callback function to stop, and “Trace Into” will ignore this callback function and the next line in the current program to stop.
And then “Run to Cursor” (run to cursor) or f4. Debugger will run the code until the cursor line. This makes no need to set a breakpoint and can skip large areas of the code becomes very easy (pause to consider just one case).
There is “Run until Return” (to run to the back) or shift-f8. Debugger will run the code until the current function returns the call to his function. When you do not want to manually step through to the end of the function (if you are caught in a loop, then this process becomes very long), the do will be very convenient to jump to the end of the function.
The last one is “Program Reset” (program reset) or ctrl-f2. Debugger break has been running the program and return to the debugger. Do not do this unless forced to, ??? object using ??resources have not been Shifang!!! (In a database application, such a 2-3 Ci ?? you will have Guanbi and Zhong Qi IDE, internal resources will be depleted because of BDE . You have been warned Rights). When you have to stop an executable program, it is very useful.
Last (but the menu is the top position) is “Run” (run) or f9. The debugger will run to the end of the process, unless you clicked on a new breakpoint encountered, or abnormal.
10. Stepping annotation
Should be borne in mind that all of these single-step approach through the breakpoints in the debugger, the debugger will break evaluation, if the breakpoints need to stop. If exception, the debugger will stop.
As you can see, in the right place to set breakpoints, view variables and step in the code tracking, we can observe a very close distance program is doing the same as if it really runs. These features are the most difficult to trace bugs — logic bug, the very convenient.
11. Other tips
If you are really brave and have experience in assembly language, you can click “View | Debug Windows | Cpu” open a “cpu view” CPU window. Here not only shows the current compilation of instructions executable instructions, as well as the CPU mark, register and update the contents of the memory image
Use the Call Stack (“View | Debug Windows | Call Stack”) can easily identify abnormal or encountered a breakpoint before the function call history before. Keep in mind, here is what to display what function call function is over, not really call the process of history. Therefore, the window may first make you feel confused. But as long as it is open to stepping through single-step tracking code to the function body, take a look you'll completely understand.
C + + BUILDER4, 5 in, watch, local variable, and call stack can reside in the code window of the main window, use the more convenient. C + + BUILDER5 can also set the debug layout for use in debugging (for use when you design the layout design in terms of).
All I have to use all the technology announced with a touch of patience and a pair of eyes that, you should be able to resolve 99% of the bug. If you find a bug, patience is necessary. Take the time to take a deep breath, do not let setbacks intimidated. If necessary, go out 5 minutes doing something else, you will be surprised to find himself a new perspective or find any missing steps in the beginning.
If you have other tips and tricks that should be added to this article, please feel free to let us know and we will add in future versions of your comments.
Well, I hope this article helps in some way patient readers. If it is the case, I would be very glad to have done a nice piece of work. Maybe you all the bugs have been negligible.
????:
RFID into the COMPETITION for the critical period
Optic bound former president Of EA games live on their own exclusive rights to operate
ASF converter
All roads lead to full high-definition VIDEO equipment HD Thunder
3GPP Converter
“Cottage XP” national dream
Recode Utube To Iaudio A3
Catalogs Icon Tools
Easy Hobby
Storage Dictionaries Education
DV To AVI
CCTV denied billion purchase broadcast rights for English Premier League: or 25 million U.S. dollars
Children's Books list: Foreign Books victory, was embarrassing domestic Children's books
Picked Components And Libraries
How to create a series of domain users AND groups