Microsoft KB Archive/216356

= Description of Visual C++ project settings and .dbg file creation =

Article ID: 216356

Article Last Modified on 9/2/2005

-

APPLIES TO

 Microsoft Visual C++ 4.0 Standard Edition, when used with:  Microsoft Windows NT 4.0

 Microsoft Windows 95

 Microsoft Windows 98 Standard Edition  Microsoft Visual C++ 6.0 Service Pack 5, when used with:  Microsoft Windows NT 4.0</li></ul>

 Microsoft Windows 95</li></ul>

 Microsoft Windows 98 Standard Edition</li></ul> </li> Microsoft Visual C++ 5.0 Standard Edition, when used with:  Microsoft Windows NT 4.0</li></ul>

 Microsoft Windows 95</li></ul>

 Microsoft Windows 98 Standard Edition</li></ul> </li></ul>

-

<div class="notice_section">

This article was previously published under Q216356

<div class="summary_section">

SUMMARY
This article explains the process of creating a debug (.dbg) file using the REBASE utility from any executable file or dynamic link library (DLL) generated using Microsoft Visual C++ 32-Bit Edition.

<div class="moreinformation_section">

MORE INFORMATION
To create a debug file using the REBASE utility from any executable file or DLL generated using Microsoft Visual C++ 32-Bit Edition, complete the following steps: <ol> From the Project menu, click Settings. Make the following settings, and then click OK. <ol style="list-style-type: lower-alpha;"> In the Project Settings dialog box, select the build configuration which needs to generate a .dbg file symbol from the Settings for dropdown list. To apply the new settings to all configurations, select All Configurations.</li> Select the names of the projects which will contribute symbol information to .dbg files, such as static libraries. Projects which build DLLs need to generate separate .dbg files, and need to have their settings changed as well. Select more than one project name by holding down the Ctrl key when clicking on the name.</li> <li>Click the C/C++ tab. Select the General category, then select the type of debug information to be generated for each source file from the Debug Info dropdown list. We recommend Program Database.

Note In Visual C++ version 6.0, you may select Program Database for Edit and Continue for the Debug configuration; however, that setting is incompatible with the default optimization settings for the Release configuration. Notice that it is set to None by default for the Release configuration. Changing this setting will not make the Release build run slower.</li> <li>Click the Link tab. Select Debug and choose the Debug info box, and select either COFF format or Both Formats.</li> <li>Also under the Link tab, select the Customize category. Clear the Use program database box.</li> <li>If you did not select All Configurations in step a, repeat steps a through e for each build configuration which should generate .dbg files.</li></ol> </li> <li>Build the executable file or DLL with the embedded debug information.</li> <li>By default, REBASE is installed to the \bin subdirectory of the Visual C++ installation path. In order to run it, you may need to run the Vcvars32.bat file in the command window first to set the system path properly. For more information, click the following article number to view the article in the Microsoft Knowledge Base:

168403 BUG: Setup doesn't ask to register environment variables

</li> <li>Get the image base address by executing DUMPBIN as follows. This action is required to extract the symbols without changing the base address of the module.

dumpbin /headers IMAGE_FILE

Where IMAGE_FILE is the name of the executable or DLL file. DUMPBIN /headers will dump an ample amount of header information. The image base value can be found in the OPTIONAL HEADER VALUES section labeled image base. By default, the image base value is 0x400000 for executable files and 0x10000000 for DLLs.</li> <li>Strip the symbols from the executable file or DLL and place them in a .dbg file by using REBASE as follows:

rebase -b IMAGE_BASE -x DBG_PATH IMAGE_FILE

Where IMAGE_BASE is the preferred base address of the image.

DBG_PATH is the directory where the .dbg file will be created. DBG_PATH can be either "." or an absolute or relative path. If an absolute or relative path is specified, then the .dbg file is created in a subdirectory corresponding to the file type; for example: \exe or \dll, in that directory. If "." is specified, then the .dbg file will is created in the directory where IMAGE_FILE is located. IMAGE_FILE is the name of the executable or DLL file.

e.g. rebase -b 0x10000000 -x. sample.dll

This strips the debug information from the sample.dll file and creates the sample.dbg file in the directory where the sample.dll file is located.</li></ol>

<div class="references_section">