views:

464

answers:

3

Due to the legacy nature of some of our code, we're still using Microsoft Visual 6.0 (SP6). When I attach to a running process to debug it for the first time, it has no knowledge of where the source files are located when I break into the process. It therefore asks me to navigate to the appropriate directory in my source tree, given a source file name. It remembers these directories, so I don't have to enter the same directory twice, but it's still painful.

Is there a way of pre-configuring VC6 with all the source file directories in my tree? Note that our project is built using makefiles (using nmake), rather than via DSPs.

+1  A: 

The paths to the source files are recorded in the debugging information (Program Database, .pdb). Make the build tree on your machine the same as the machine it was built on.

Mike Dimmick
Mike, we're building (using cl.exe and link.exe) without absolute path names, which means the PDBs don't have the full path to the files (or so I am guessing). That's why I'm after an alternative way of specifying the source file directories.
Jason Etheridge
A: 
EvilTeach
A: 

Absolute path information is not recorded in our PDBs files, since we are deliberately not wanting to tie our source tree to a particular top-level directory; when it is deployed, it is not possible to drop the source tree in the same position as was used on the build machine.

EvilTeach's solution certainly gives the desired effect, though our source tree consists of literally hundreds of directories, making entering them manually somewhat cumbersome. There's also the problem that a developer may have multiple source trees that they're running from at any given time, so being able to switch between those trees when debugging a given executable is essential.

I subsequently found that you can programmatically (well, at least from the command line) switch a set of source directories by directly updating the registry:

REGEDIT4

[HKEY_CURRENT_USER\Software\Microsoft\Devstudio\6.0\Build
System\Components\Platforms\Win32 (x86)\Directories]
"Source Dirs"="<path1>;<path2>"

That's not too bad, and would certainly do the trick.

However, the solution I settled upon was setting the SOURCE environment variable to contain all the source paths (as a semicolon-separated list of directories). A very simple batch file could do this, and allow switching between different trees. Then, you run up Visual C++ from the command line, using the option telling it from read SOURCE (and INCLUDE, LIB and PATH) from the environment:

msdev /useenv

Looking under Tools->Options, you'll see that the directories from SOURCE have indeed been loaded. I was then able to attach to a running process, and the debugger was able to locate any code that I debugged into.

Life just got that much easier!

Jason Etheridge
nice solution.thanks.
EvilTeach