5

I can't find a way to use the source server tools from the Debugging Tools for Windows on a static library project, which is built separately from the solutions actually using that library: The output of "ssindex.cmd" always displays "zero source files found" for the PDB file generated for the library (using compiler options /ZI and /Fd).

Running "srctool.exe -r" on this PDB displays nothing, which probably means that the PDB file does not contain any source file information. Running the same command on the PDB file of a test application which is also build as part of the the same solution yields a list of all expected source files.

Is there a way to use source indexing for a static library project when it should be built seperately from the solutions using it?

Thanks for any suggestions!

Peter Schneider
  • 121
  • 1
  • 6

3 Answers3

4

You can use the "/Save" and "/Load" options to store and load source information for a static library, respectively. Using these options allows you to store information for your library and then later import it when indexing a project that links against your library.

When indexing your library solution, you specify the "/Save" flag with a directory in which to store index information about the library's source files. For example (assuming you are using Subversion for source control),

ssindex.cmd /System=SVN /Save=c:\source\libproj\srcinfo /Source=c:\source\libproj /Symbols=c:\source\libproj\Release\*.pdb 

When later indexing your project that includes your library, you specify the "/Load" flag with the directory containing the library's source file information. For example,

ssindex.cmd /System=SVN /Load=c:\source\libproj\srcinfo /Source=c:\source\binproj /Symbols=c:\source\binproj\Release\*.pdb 

There are two potential issues that may affect your ability to use this technique. First, it appears that some source control providers may not support saving and loading source control information. I know that the Subversion provider does and it looks like the SourceSafe provider does, but I haven't checked any others.

Second, this technique appears to only work for one external static library out-of-the-box. There does not seem to be a way to load information from multiple directories and the scripts currently overwrite the contents of the directory each time you use the "/Save" option. You could probably edit the source control provider module to append to the files in the save directory rather than overwrite them, but I have not tried it.

Also, note as you mentioned above that you only need to do this if your library is being built as part of a separate solution. If the static library is part of the solution you are indexing, its source files will be included if they are in the path specified by the "/Source" option.

Trevor A.
  • 278
  • 3
  • 11
0

It probably means you haven't inputed the correct directories when running "ssindex" so for ssindex you need to have: /source=C:/SourceCode/ /symbols=C:/SourceCode/bin/Debug I'm not sure if the "source" has an upper case S or not but that should be it!

  • Path name issues are not the problem in my case. I found out the following using the dia2dump tool from msdn: For the PDB of a binary project (EXE or DLL), the output of dia2dump contains a list of source files in a section labeled with "Found table: SourceFiles". With a PDB file generated for a static library project, the corresponding section always seems to be empty. So I guess this is the reason why "ssindex" does not work on static library projects. But I have no idea why this information is not included in the PDB and have not found any compiler setting which "cures" this. – Peter Schneider Oct 12 '09 at 12:58
0

when run svnindex.cmd, it always tell you "zero source files found"

after a painful diggin into svn.pm (the perl module to deal with svn), i found that:

  1. first, svn.pm invokes "svn info -R $SourceRoot" to get all version info of files in $SourceRoot (passed by /source option),

  2. then svn.pm stores all files in a dictionary which using the local file path as key

  3. svnindex.cmd call srctool -r to get all source files info in *.pdb, and use the source file name as a key to query info saved in step2

the problem is:

svn.pm uses relative path, but *.pdb uses absolute path, so you will never find a svn log info for any file, then "zero source files found"

fixup:

change svn.pm line 162:

$LocalFile = lc $1;

to   

$LocalFile = $SourceRoot . "\" . lc $1; #make path absolute