Software

zhaozj2021-02-16  51

Join Sybase soon, a friend who has not been unable to ask me what I am doing. I said the software repairman (I maintained Powerbuilder in Sybase). When I said this, I didn't degrade the mechanics. On the contrary, I envy outstanding repairs from a small. The radius of unat is, they kick, they rang; the machine that does not work, they drums.

A debugging master is a value of the company. Once, some people asked a senior vice president of the company: Who is the most important person in his hand. The answer is: Two senior engineers, because some faults can only solve them. In my opinion, the error is not only a means of making a living, or a puzzle game. So, when you check the error, don't panic, you have to calm down, enjoy the pleasure.

Incidents account for a large proportion in software development and maintenance. Whether it can be made as soon as possible, as soon as possible, high quality is related to the success or failure of software. A development expert must be an unambiguous master. The error is basically divided into two parts: find out the cause and correct the error. How can I quickly locate the wrong reason?

Have you familiar with your tool

Workers must be good, and must first make a tool. Although this idiom can be familiar, I think our Chinese seem to have a person who can do something more than any tool. If you use a line, you can give people a vein. But how many people can you reach this kind of realm? What's more, if they have the right tool, isn't it possible to do it faster?

With a good tool, you have to explore its function. In terms of Visual Studio, it provides a powerful defective function. Fully grasp the function, which will greatly shorten the extension cycle.

Breakpoints play a crucial role in the extension. Reasonable setting breakpoints can make you more time. The most commonly used breakpoint is the location breakpoint. The program will stop immediately when running to breakpoints. At this time, you can check the value of the variable, check the contents of memory, and so on. I hope to see some spider silk.

1.1 Conditional breakpoint

Sometimes, the program has to go through a breakpoint to reach the scene you want. The F5 key (Go) is simply not bored back and forth. Fortunately, Visual Studio allows us to set conditions for location breakpoints through the breakpoint dialog. This breakpoint only works only when the conditions set. The condition of the breakpoint is a Boolean expression, for example: a == 100 || (B> 10 && c <1.5). Where A, B, and C may be partial variables, members variables, or global variables.

It should be noted that there is no function call in the conditional expression, including overloaded operators. So, since you can't use the strcmp function, can you make the condition breakpoint in a certain string variable to be a particular value? can. Suppose you have a string variable STR, and hope to work on the STR equal to "ABC", you can use the following conditions express: str [0] == 'a' && str [1] == 'b' && str [ 2] == 'c'.

You can also make a bit of breakpoints to jump after a few times. Suppose you are excluding a GPF. You set a location breakpoint and want to see the situation at the breakpoint before the GPF. But you don't know how many times to press F5 keys to reach the scene you want. Even if you know how many times, you don't want to press that. Fortunately, Visual Studio allows a location breakpoint to play after a few times. You can let the breakpoint skip 1000 times, then execute the program. After the crash, how many times will be seen when the breakpoint is skipped. Reset the number of breakpoints with this time. When the program is executed, the program will stop at the moment before the dead.

1.2 data breakpoint

In some cases, the data breakpoint will become your savior. When you find the error, if you find that a data is inexplicably, how can you find when the data is changed? Use data breakpoints. The address and length of the data are given by the breakpoint dialog. In the future, when any code changes the value of the data, the program will stop immediately and let you analyze whether the change is reasonable. 1.3 Stop Always

If your program uses C exception handling function, when tracking, you may find that the program suddenly ran to a very far Catch statement. That is because C exception handling functions work. When the program is running normally, the exception handling function is your friend, but when tracking, it may not be, because you don't know where the program is wrong. Fortunately, Visual Studio allows you to cancel an exception handler during tracking. Select the Debug-Exceptions menu, in the pop-up dialog box, change the action taken when the debugger is taken when an exception occurs. You can set the action into stop always, as long as the class is abnormal, the program stops.

Visual Studio also offers a variety of windows that allow you to check the program call stack, variables, accumulators, and memory.

1.4 other tools

In addition to Visual Studio, some useful tools, such as the Performance Monitor, Visual Studio provided by the Windows NT operating system, and Handleex, Filemon, and Regmon, which provide www.sysinternals.com. Proficiency in these tools will be beneficial to you.

2. Familiar with your procedure

With a decent tool, you can't make you an unscrupulous master. A repairman who does not know how to work hard, even if there is a good tool, it is difficult to repair the machine and high quality. Why in some major projects, some faults only have a few people to exclude? The main reason is that only they can understand their procedures more fully.

To become a real unity master, you have to take the initiative to attack, understand the overall structure of the program, familiar with the code. How can I understand the overall structure of the program? How to understand the overall structure of the program? If you have a complete document, you are lucky. If not, it is only by yourself. My personal experience is painting UML map. There is a "one trip to one thousand words". Look at the Component Diagram, you can think of which blocks have been made throughout the program; see the class diagram, you can recall the relationship between these classes immediately; see a time chart (sequence) Diagram, you can think of how these objects are interactive. The tool for the drawing can be Rational Rose, or Sybase PowerDesigner, Microsoft Visio, and even PowerPoint. Then use a Word file to string these maps, Check IN to the Source Control System (Source Control System), to replenish the modification.

When there is no emergency task, I will roughly analyze the source code (not a line-by-line reading), and supplement it. Sometimes, I will also consciously track the program, study the function calls each function in the stack (Call Stack), find out the relationship between the class and record the book. It is worth noting that you must record your discovery, otherwise you may have to come back. Good memory is not as bad as a pen. In addition, the error-changing process is also a good opportunity to understand the source code. I will record it for those of the Call Stack that is important. Yicheng Moon, you will find that you have a deep understanding of the overall structure, but also mastered a lot of details. At this time, the error is no longer the sea, nor is it a maze because you already have a topographic map.

3. Manage the management

Proficiency in advanced tools, which have a considerable understanding of the procedure, and you have already have the conditions for defective masters. And good software management can make you half a meal. Software management basically includes:

l code control system

l Quality tracking system

l Software release and archive system

3.1 Code Control System

The code control system has many benefits: preventing accidental loss, ensuring code synchronization, allowing retrospective to any point in the development process, allowing multiple engineers to simultaneously modify the same file, etc. Since each modification has records, engineers can promote the quality of the program to avoid being jokes by others. In addition, the code control system is also important in the defect. The following will be described in detail below.

3.2 Quality Tracking System

Sybase has a quite rigorous quality tracking system. Quality control engineers, technical support engineers, and even develop engineers enter new error reports in quality tracking systems (Sybase called Change Request). Each error report requires a detailed description, severity, error Reproduction step, and corresponding Test Case. Test Case should be as small as possible.

Each product has a group that is responsible by the technical support manager, and the most serious mistake is selected every week and notify the corresponding development team leader. The team leader then divides the error to the corresponding engineer. The engineer identifies the cause of the error and proposes a solution. After the program review, the modified code Check IN to the code control system. At the same time, the error report is transferred to the Quality Control Team. The Quality Control Panel closes the error report after confirming the error is resolved.

3.3 Software Publishing and Archive System

Every important build of the program must be archive, and can be downloaded at any time.

4. Some practical skills

A very important ring of check-in is to set breakpoints. Breakpoint location is good to make you faster. Here is a tip: If the error is the program popping up a dialog, you can start Visual Studio, attach to your program, then select the debug-break menu pause program. From the function call stack, maybe it will be found. This trick can be used if the program is in a dead cycle. If the wrong performance is a dead machine, it is easier to find the entry point.

When debugging multi-threading programs, write the program running in the file (logging) is a common method. In the function you think there is a problem, you should write important data into the file. After the problem occurs, carefully study the document, trying to find some spider silk. Gradually narrow the range, know what the problem is found.

Memory Leak is a common problem of C programs. Checking memory leaks to have tools. Usually I will prove the procedure using the Performance Monitor proven to have a leak. Then use BoundSchecker or other tools to help determine the root of memory leakage. Sometimes the program will degenerate, that is, a certain function suddenly does not work. If you can't quickly find the reason, we usually use the Binary Search to find out which change list is caused by the Change List. The method is to find out what is the problem from which one Build starts, and then find which change list. Suppose the Build 1000 is working properly, and Build 1010 has a problem. We download Build 1005 from the program archive to see if there is a problem. If you have any questions, download Build 1003, otherwise download Build 1007. Up to this class until the Build is found. Then, from the code control system, this build and the last buildation have those CHANGE LIST, and use the method of folding. The method is to synchronize the program to a Change List, compile and run the program, see if there is a problem. So this is until you find a problem that caused a problem. Cut the CHENGE LIST's colleagues found the cause of the problem and resolved.

The most people 's headache is the random incident, it is difficult to reproduce the error. These errors are usually caused by the cause of variables that are not assigned, or memory is destroyed. If the program randomly crashes, you can use the setunhandledExceptionFilter function provided by the Windows operating system to set your own unhandled exception filter. Windows automatically calls the filter function when the program has an exception that has not been processed. In the filter function, you can run the program to run the site, such as the function call the stack, the value of the register, etc., write a file to analyze. If you have the most basic debugging information in Release Build, you can see the real function name in the function call stack instead of a password average function address. If there is no debugging information in Release Build, you can find problems when you generate from the MAP file generated when you compile the source file. So if you don't want the Release Build with debug information, you must archive the Map file to prepare for the need.

If you use your trick, you can't find the root of the error. You may wish to ask your colleagues to help, or call external forces. As the saying goes: I haven't had a flame mountain. As long as you are not discouraged, the group is willing to solve the problem. After all, the computer is logical.

After the error is resolved, you better summarize the process and experience of the error. If your program has a unit test program (Unit Test), you should add some unit test procedures to prevent similar situations from happening again. If your program has an automatic integration test, you should also join the corresponding test.

In addition, it is better to take you with an error with you passive and other errors. One of the methods is to conduct code reviews (CODE REVORW). Select a file, review the file by the team member, then collectively discuss, find all the mistakes and the place to be improved. The code review can not only prevent problems, or improve the programming level.

The attitude also plays an important role in the degne, especially when suffering from a lot of pressure. Since this error software cannot be released, the order is put on hold. But you must stay calm. "This is definitely the fault of the compiler", "This is definitely the wrong system", "This is definitely the fault of third-party software", etc. Say these words are not calm. You have to "get evidence". In short, don't blame the people. It is your own fault, courage to admit. It is the fault of others, and I'm so sad. Mastering the method, there is a good attitude, why can't you become a master?

5. References:

"Debugging Applications"

"MSDN" Microsoft

"UML DISTILED" Martin Fowler

"Refactoring" Martin Fowler

转载请注明原文地址:https://www.9cbs.com/read-23971.html

New Post(0)