Measure the test taker's knowledge about the functions of symbolic files in Visual Studio debugging.

Source: Internet
Author: User

This article will introduce the symbolic files in Visual Studio debugging. We hope this article will help you understand Visual Studio debugging.

For some steps in the Visual Studio debugging process, we need to understand symbol files today. We hope that through this article, we can get twice the result with half the effort.

The preceding checkpoint steps that do not allow you to set breakpoints and the checkpoint advanced sections on Visual Studio debugging refer to debugging symbol files and their functions. This article will introduce some usage of debugging symbol files, skip this article if you are familiar with debugging files.

The debugging symbol file provides the debugger with a ing from the Code address of the binary machine to the code line of the source code file. Therefore, with the symbol file, we can:

1. Set the breakpoint. Because the debugger needs the ing relationship provided by the symbol file, it converts the line number of the source code line to the address of the corresponding machine code.

2. Check the program stack. In short, the debugger converts the address in the stack to the function name containing the address using the ing relationship.

3. view the value of a variable. For the machine, all the variables are just a memory address. When the program reads the value of a variable, it only reads the memory of the specified size according to the type of the variable.

4. Some functions of the program, such as native programs, are even called. After compilation, the program actually only becomes a piece of machine code. When we call a C ++ function in the immediate window, the debugger needs to translate the function name into the starting address of the corresponding machine code, of course, you must follow certain function call rules to call this function.

We can view the functions of symbol files one by one:

View the program Stack

Attach Visual Studio to an opened Notepad program in native debugging mode (Note: Because my system is in English, Chinese menus are translated directly to English, some may be inaccurate, so I will append the English command to the back), and then interrupt the execution of the notepad process-by clicking "debug" in the vs menu) "-" Break all )".

The following figure shows how to attach vs to the notepad process (Sorry, the recorded video is too large and I don't know how to transfer it ).

1. Click "Tools" in Visual Studio-"attach to process ...... (Attach to process ...)".

2. Select notepad.exe. Of course, make sure to "attach... (Attach ...)" The debugging type listed in the text box is "native )".

3. Click OK to attach Visual Studio to the notepad process that you just opened.

In this case, open the Stack window and you will see a result similar to the following:

  

I cannot understand the above stack (my machine is a 64-bit Windows 7, so the address is 8 bytes ). Therefore, we need something to help us translate hard-to-understand addresses (BIRDS) into meaningful words. This work is done by symbol files.

Because notepad is a program that comes with the operating system, we certainly cannot generate its own symbol file, but fortunately, microsoft has long considered that some people may need to debug the Windows Kernel-for example, programmers who write drivers, so Microsoft has published some symbol files for Windows. The public address is:

Http://msdl.microsoft.com/download/symbols

The method used in Visual Studio is:

1. Click "Tools"-"options" in the menu bar )".

2. Select "debugging"-"symbols" in the list box on the left of the "options" dialog box )".

3. If your Visual Studio is Visual Studio 2008 SP 1, click "load symbols from Microsoft symbols server.

4. if it is another version-Of course it is a lower version (. PDB) locations) Add a new row in the list box and input the above link.

Then, in the "cache symbols from symbol servers to this directory :)" text box, enter the path of the folder where you want to cache the symbolic file downloaded from the server-after all, that server it is in the United States. As shown in:

  

5. Click "OK )"

6. For friends who have heard that English is not difficult, you can directly refer to the link below to learn how to set: http://support.microsoft.com/kb/311503/zh-cn

Wait for a long time-because the debugger needs to download the symbolic files of all the dynamic link library files referenced by the Notepad program one by one, you should see the following stack information:

  

In the description of this article, I hope you can understand the importance of the debugging symbol file:

1. If there is no debugging symbol file, you cannot view the stack-This seems redundant. But most of the time, when we analyze the memory files stored in the autopsy debugging, the first step is to check what the stack looks like when the program crashes, if there is no debugging symbol file, we can't do anything.

2. How is the debugging symbolic file generated? The debugging symbol file is generated by the compiler. Because the compiler is responsible for translating the source code file in the text format into a binary program, the ing between the two is not clear. Each time you re-compile, the compiler generates the corresponding debugging symbol file.

Command for generating the debugging symbol file:

Programming Language

Compiler

Command Line Parameters

C #

Csc.exe

/Debug [: Full]

C ++/C

Cl.exe

/Zi

Or

The/debug option of link.exe

3. for example, a customer complained to you that the program could not work and encountered a serious error (Bug). However, he was running a 1.0 version program, however, your company has developed another version 2.0 program. Since the source code is generally not provided to the customer, it is good to find the source code of the original version 1.0 for recompilation and install it on the client to reproduce it, but why don't I directly Save the debugging symbol file of version 1.0, and let the debugger directly find the source code during debugging? This involves the cooperation between the symbol file server and the source code file server, which may be described in later articles.

Original article title: symbolic file for Visual Studio debugging

Link: http://www.cnblogs.com/killmyday/archive/2009/10/14/1582882.html

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.