Pre-setting locations for looking for source files in Visual C++ 6.0

a 夏天 提交于 2019-12-13 16:37:00

问题


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:


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.




回答2:



Yes.
go into


TOOLS
OPTIONS
DIRECTORY (tab)

and you can set the SOURCES/LIBRARIES/INCLUDE directory locations. These values apply to all projects within the workspace.


I do not know if setting those values will allow the information to be seen using direct makefiles.




回答3:


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!



来源:https://stackoverflow.com/questions/154661/pre-setting-locations-for-looking-for-source-files-in-visual-c-6-0

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!