Borland Online And The Cobb Group Present:


December, 1995 - Vol. 2 No. 12

Letters - Maintaining up-to-date SYM files for WinSpector


I find Borland's WinSpector utility an invaluable debugging tool. Usually, the really rogue General Protection Fault (GPF) problems surface in our alpha or beta test process­­well away from my development system. Appropriately, I like to use WinSpector to achieve some remote debugging capabilities in that environment.

However, WinSpector's reporting capability is quite limited if you don't provide it with a symbol (SYM) file, which it uses to interpret function and variable addresses. Currently, I use the TMAPSYM.EXE utility that comes with Borland C++ to convert detailed MAP files from my projects into SYM files.

Unfortunately, if I forget to rerun this utility after making some changes to the project, the old SYM file may be useless. Is there some way to create a tool for the Integrated Development Environment (IDE) that will automatically rebuild my SYM files?

Paul Johnstone

via CompuServe


Surprisingly, Paul, the answer is yes! Creating the tool isn't as simple as creating some other IDE tools, though.

A tool to die (or GPF) for

Most of the IDE tools we've discussed in previous issues of Borland C++ Developer's Journal have been either transfer tools­­simple interfaces to external applications­­or viewer tools­­interfaces that pass data from project nodes to external applications. To create a tool that maintains MAP files for a given project, you'll need to create a translator tool­­an interface to an application that converts one file type to another.

You may be wondering which project nodes this new translator tool will convert. As you've probably noticed, neither MAP files nor SYM files appear as nodes in a standard project.

For this technique to work, you'll need to create a new type of node, [.map], that corresponds to the targets for which you want to maintain SYM files. The new IDE tool will simply examine the MAP files that correspond to the [.map] node and automatically rebuild the SYM files if the MAP files' time/date stamps don't match the time/date stamps of the SYM file.

By the way, the [.map] node must appear below its companion target in the project window. If it appears before its companion target, the IDE won't rebuild the MAP file before it executes the Make All command, and therefore the MAP file won't be up-to-date. In addition, since the [.map] node is a separate target, you'll need to either call the Make command for that node explicitly, or you'll need to use the Make All command to update all the nodes in the project. (The latter solution is better.)

In case you're wondering, the IDE uses time/date file information to determine whether it will rebuild a given CPP source file. If the time/date stamp of the OBJ file doesn't match that of the CPP file, the IDE considers the OBJ file out-of-date and calls the appropriate translator tool for the [.cpp] node.

The last element of this technique is to specify that the linker create a detailed MAP file for each [.exe] or [.dll] target node that has a matching [.map] node. When the linker updates the MAP file, the file's time/date stamp will change, and this will force the compiler to rebuild the [.map] node in the manner we just described. Now let's put these pieces together to create an IDE tool that maintains the SYM files for a target.

All over the MAP

To begin, launch Borland C++ (version 4.0 or higher), and choose New Project... from the Project menu. In the New Target dialog box, enter \map2sym\map2sym.ide in the Project Path And Name entry field, select EasyWin [.exe] in the Target Type list box, and click OK.

When the new project window appears, select the map2sym [.def] node, press and hold [Shift] and select the map2sym [.rc] node, then press [Delete]. In the dialog box that appears, click Yes to delete the two selected nodes.

Now, right-click the map2sym [.exe] node and choose Add Node from the popup menu. In the Add To Project List dialog box, enter map2sym.map and click OK.

When the dialog box disappears, you'll see the map2sym [.map] node appear as a sub-node of the map2sym [.exe] node. Press [Alt][<-] to make the map2sym[.map] node an independent node that appears at the bottom of the project window.

Next, choose Tools... from the Options menu to begin creating the new IDE tool. In the Tools dialog box, click New. In the Tool Options dialog box, enter Map2Sym in the Name entry field, enter \bc45\bin\tmapsym.exe in the Path entry field, and enter $SELNODES in the Command Line entry field. (If you're using a version other than 4.5, you'll need to adjust the Path entry accordingly.) Then, enter Make Sym in the Menu Text entry field and Convert MAP file to SYM file in the Help Hint entry field, as shown in Figure A. When you finish, click the Advanced... button.


Figure A - You'll use the Tool Options dialog box to create the new IDE tool.

In the Tool Advanced Options dialog box, select the Translator radio button, deselect the Place On Tools Menu check-box, and then select the Place On SpeedMenu and Target Translator check-boxes. Enter the following text into the appropriate entry field:

The Tool Advanced Options dialog box should now look like Figure B. When you finish, click OK to return to the Tool Options dialog box, and then click OK to save the new IDE tool. When the Tools dialog box reappears, click Close.


Figure B - You'll use the Tool Advanced Options dialog box to identify which project nodes the new tool will translate.

Finally, choose Project... from the Options menu. Double-click Linker in the Topics list box to display its subtopics and then select the Map File subtopic.

In the Map File section of the Project Options dialog box, select the Detailed radio button. Click OK to save this option. (By specifying the Detailed Map File option for the entire project, you're ensuring that each target in the project will have an up-to-date MAP file for which you can create a corresponding [.map] node.) Now the IDE will maintain SYM files for each target in this project, which WinSpector will be able to use as you're debugging the targets.

On-target SYMs

To test the new Make Sym tool, let's add the source code for a do-nothing program to the current target. Double-click the map2sym [.cpp] node to open the source file.

When the source file window appears, enter the following program:

int main()
{ return 0; } 

When you finish, press [F9] to execute the Make All command. When the IDE finishes compiling and linking the MAP2SYM.EXE file, you'll see the Running Tool window appear, as shown in Figure C.


Figure C - The Running Tool window displays the pathname of the TMAPSYM.EXE utility as well as the name of the MAP file the IDE passes to it.

Return to the Borland C++ Developer's Journal index

Subscribe to the Borland C++ Developer's Journal


Copyright (c) 1996 The Cobb Group, a division of Ziff-Davis Publishing Company. All rights reserved. Reproduction in whole or in part in any form or medium without express written permission of Ziff-Davis Publishing Company is prohibited. The Cobb Group and The Cobb Group logo are trademarks of Ziff-Davis Publishing Company.