编译后会产生一个后缀名为MAP的文件,请问有什么用?为什么有这个文件(有的工程编译后没有)

解决方案 »

  1.   

    The compiler has two sets of command-line options that enable you to generate external debugging information: the map file options and the debug info options.Map file (-G) optionsThe -G option instructs the command-line compiler to generate a .map file that shows the layout of the executable file. Unlike the binary format of executable and .dcu files, a .map file is a legible text file that can be output on a printer or loaded into the editor. The -G option must be followed by the letter S, P, or D to indicate the desired level of information in the .map file. A .MAP file is divided into three sections:Segment
    Publics
    Line Numbers-GS outputs only the Segment section, -GP outputs the Segment and Publics section, and -GD outputs all three sections. -GD also generates a .DRC file that contains tables of all string constants declared using the resourcestring keyword.For modules (program and units) compiled in the {$D+,L+} state (the default), the Publics section shows all global variables, procedures, and functions, and the Line Numbers section shows line numbers for all procedures and functions in the module. In the {$D+,L-} state, only symbols defined in a unit's interface part are listed in the Publics section. For modules compiled in the {$D-} state, there are no entries in the Line Numbers section.Debug info (-V) optionsThe -V options (-V, -VN. and -VR), which cause the compiler to generate debug information, can be combined on the command line.Generate Turbo Debugger debug info (-V) optionWhen you specify the -V option on the command line, the compiler appends Turbo Debugger 5.0-compatible debug information at the end of the executable file. Turbo Debugger includes both source- and machine-level debugging and powerful breakpoints.Even though the debug information generated by -V makes the resulting executable file larger, it does not affect the actual code in the executable, and does not require additional memory to run the program.The extent of debug information appended to the executable file depends on the setting of the $D and $L compiler directives in each of the modules (program and units) that make up the application. For modules compiled in the {$D+,L+} state, which is the default, all constant, variable, type, procedure, and function symbols are known to the debugger. In the {$D+,L-} state, only symbols defined in a unit's interface section are known to the debugger. In the {$D-} state, no line-number records are generated, so the debugger cannot display source lines when you debug the application.The IDE internal debugger does not use Turbo Debugger debug information. Because generating Turbo Debugger debug information almost doubles compile/link time, you should turn off Turbo Debugger debug information generation except when you're debugging the application in Turbo Debugger.Generate namespace debug info (-VN) optionWhen you specify the -VN option on the command line, the compiler generates namespace debugging information in the Giant format used in C++. This allows the C++ compiler to find Pascal symbols. Use this switch when you are compiling code that will be used by the C++ compiler.Generate debug symbol info (-VR) optionWhen you specify the -VR option on the command line, the compiler generates debugging symbol information in an .rsm file.
      

  2.   

    简单地讲, MAP 文件是程序的全局符号、源文件和代码行号信息的唯一的文本表示方法,它可以在任何地方、任何时候使用,不需要有额外的程序进行支持。而且,这是唯一能找出程序崩溃的地方的救星。