Thursday, December 16, 2021

Source Indexer for RTC repository


As discussed in "Remote Debugging with Symbol Server and Source Indexing" post, Symbol Server along with Source Indexing greatly helps in debugging production issues independent of the installed software version. The source server was configured to work with svn repository.
The current Source Indexing setup from MS doesn't support RTC repository. Writing the same in Perl seems complicated for those unfamiliar with Perl.

Repository agnostic Recipe for Source Indexer Tool Development
Prerequisites
Install Debugging Tools for Windows or just copy files from an existing installation

Steps
1. Gather all the PDBs in a Symbol Server to avoid duplication.
2. Extract source files from PDBs using srctool -r command.
3. Create a source Server stream containing the command to extract the source file from the repository for the PDB.
4. Inject source stream into the PDB

Working with RTC Repository
It's assumed that the the system used for debugging is installed with RTC client. lcsm batch file is added to PATH environment variable.
A file can be extracted using get file command by invoking lscm.bat as below
lscm  get file -r <repository url> -s <snapshot name> -c <component name> -f <file path in the stream> -o <file path on the disk>

Important things to keep in mind are :
1. The user id and password needs to be cached using following command
lscm login -r <repository url> -c
2. It's assumed that a unique snapshot is created containing baselines after successful build
2. If possible use the unique identifier for components instead of the display text
3. The repository path is case sensitive and should include  / for separator
4. The get file command doesn't create the destination folder automatically, therefore it should be created before downloading
5. It's preferable to use component ids over components when querying RTC since the same component name can be assigned to multiple projects

In case working offline, the entire archive can be downloaded using following commands. Here a temporary workspace is created from the snapshot and later deleted after use.
lscm create workspace --snapshot <snapshot name> -r <repository url> mmmm
lscm load -r <repository url> -d <path on disk> mmmm <component name>
lscm delete workspace -r <repositiry url> mmmm

SourceIndexer Tool
Source Indexer source indexes PDBs for RTC repository.
In order to source index, following inputs are needed. These are obtained from the SourceIndexer.config
sourcefileslocation  ->contains root of the source files
pdblocation -> contains symbol store root of the build
lscmlocation -> path to lscm.bat
repository -> url of the repositiry
snapshot -> name of the snapshot
components   ->components display name separated by comma
componentids ->components unique ids separated by comma

Usage Example.
Configuration
       
    <appSettings>
        <add key="sourcefileslocation" value="D:\Github\TechBlog\COM+\APITester - Test any COM component using its typelibrary" />
        <add key="pdblocation" value="D:\Github\TechBlog\COM+\APITester - Test any COM component using its typelibrary\bin" />
        <add key="lscmlocation" value="C:\Program Files (x86)\IBM\TeamConcert\scmtools\eclipse\lscm.bat" />
        <add key="repository" value="https://rtc.vrrao.com:9443/ccm/" />
        <add key="snapshot" value="APITESTER_1969" />
        <add key="components" value="Source" />
        <add key="componentids" value="Khri$ha" />
    </appSettings>
       
 
After executing SourceInder.exe, following will be output:

The output folder under SourceIndexer has following files
files.txt -  contains of output of srctool command querying for source files from APITeser.pdb
APITester.pdb.ssidx - contains the stream that will be injected into the APITeser.pdb

Details
a. runsrctool command returns 380 files 

b. 31 files belonging to APITester project are selected. stream is created in APITester.pdb.ssidx file.
This file contains lscm get  command  for each of the selected 31 files of APITeter project.
example,
d:\github\techblog\com+\apitester - test any com component using its typelibrary\source\superedit.cpp*"https://rtc.vrrao.com:9443/ccm/"*"APITESTER_1969"*"Khri$ha"*SuperEdit.cpp*Source*

c. runpdbstr command  injects  APITester.pdb.ssidx  into  APITeser.pdb

d. This also can be verified by running command pdbstr.exe  -r -p:APITester.pdb -s:srcsrv
The output will be as shown below


Source and Binaries can be found here.




No comments:

Post a Comment