Explaining project format changes in VisualGDB 5.3

The latest VisualGDB 5.3 release introduces a few improvements in the project format that avoid hardcoding of the paths and settings in the project files and make toolchain management on different machines easier. However some of those changes are not backward compatible with VisualGDB 5.2 and earlier, making it harder to update to v5.3 if some of the developers in your organization are still using v5.2. In this post I will show you the project file format differences between VisualGDB 5.3 and 5.2 and will provide examples on making v5.3 projects compatible with the older VisualGDB versions.

Non-Embedded Projects

The only change for non-embedded projects is the transition from storing the detailed toolchain information in .vgdbsettings files to only storing the toolchain ID and version and loading the details from a directory under %LOCALAPPDATA%. Below is the comparison of a .vgdbsettings file for a simple project targeting Raspberry Pi  created with VisualGDB 5.2 and 5.3 respectively:

VisualGDB 5.2 VisualGDB 5.3
 <Build xsi:type="com.visualgdb.build.msbuild">
  <Toolchain>
     <Name>Raspberry PI</Name>
     <UniqueID>com.visualgdb.raspberry_pi</UniqueID>
     <Location>C:\SysGCC\raspberry</Location>
     <UnixSystem>false</UnixSystem>
     <GCC>C:\SysGCC\raspberry\bin\arm-linux-gnueabihf-gcc.exe</GCC>
     <GXX>C:\SysGCC\raspberry\bin\arm-linux-gnueabihf-g++.exe</GXX>
     <GDB>C:\SysGCC\raspberry\bin\arm-linux-gnueabihf-gdb.exe</GDB>
    <Make>C:\SysGCC\raspberry\bin\make.exe</Make>
     <AdditionalPathDirectories>
       <string>C:\SysGCC\raspberry\bin</string>
     </AdditionalPathDirectories>
   <RequireCmdExe>true</RequireCmdExe>
   <RequireCtrlBreak>false</RequireCtrlBreak>
   <SourceDirMapping>
   <Directories />
     <PathStyle>MinGWUnixSlash</PathStyle>
   </SourceDirMapping>
   </Toolchain>
  <RemoteBuildEnvironment>
   <Records>
     <Record>
       <VariableName>LANG</VariableName>
       <Value>en_US.UTF-8</Value>
     </Record>
     <Record>
       <VariableName>PATH</VariableName>
       <Value>C:\SysGCC\raspberry\bin;%PATH%</Value>
     </Record>
   </Records>
   </RemoteBuildEnvironment>
   <ParallelJobCount>0</ParallelJobCount>
 </Build>
 <Build xsi:type="com.visualgdb.build.msbuild">
  <ToolchainID>
     <ID>com.visualgdb.raspberry_pi</ID>
     <Version>
       <GCC>4.9.2</GCC>
       <GDB>7.7.1</GDB>
       <Revision>4</Revision>
     </Version>
   </ToolchainID>
   <ParallelJobCount>0</ParallelJobCount>
   <SuppressDirectoryChangeMessages>true</SuppressDirectoryChangeMessages>
 </Build>

Note how the Toolchain and RemoteBuildEnvironment elements were replaced by a shorter ToolchainID element. VisualGDB 5.3 will automatically locate the toolchain corresponding to the ID and version from the project file and will automatically set the paths and environment variables from it.

The .vxcproj file will also now store the toolchain ID instead of the toolchain path:

VisualGDB 5.2 VisualGDB 5.3
 <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|VisualGDB'">
   <GNUConfigurationType>Debug</GNUConfigurationType>
   <Toolchain>C:\SysGCC\raspberry</Toolchain>
 </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|VisualGDB'">
   <GNUConfigurationType>Debug</GNUConfigurationType>
   <ToolchainID>com.visualgdb.raspberry_pi</ToolchainID>
   <ToolchainVersion>4.9.2/7.7.1/r4</ToolchainVersion>
 </PropertyGroup>

For non-MSBuild projects, VisualGDB 5.3 also ensures that settings like ‘build command’ do not hardcode the toolchain path:

VisualGDB 5.2 VisualGDB 5.3
 <Build xsi:type="com.visualgdb.build.make">
   <MakeFilePathRelativeToSourceDir>Makefile</MakeFilePathRelativeToSourceDir>
   <MakeConfigurationName>Debug</MakeConfigurationName>
   <Toolchain>
     <!-- ... -->
   </Toolchain>
   <MakeCommandTemplate>
   <SkipWhenRunningCommandList>false</SkipWhenRunningCommandList>
   <RemoteHost>
     <HostName>BuildMachine</HostName>
     <Transport>BuiltinShortcut</Transport>
   </RemoteHost>
   <Command>cmd.exe</Command>
   <Arguments>/c "C:\SysGCC\raspberry\bin\make.exe"</Arguments>
   <WorkingDirectory>$(BuildDir)</WorkingDirectory>
   <Environment>
     <Records>
       <Record>
         <VariableName>LANG</VariableName>
         <Value>en_US.UTF-8</Value>
       </Record>
       <Record>
         <VariableName>PATH</VariableName>
         <Value>C:\SysGCC\raspberry\bin;%PATH%</Value>
       </Record>
     </Records>
   </Environment>
   <BackgroundMode xsi:nil="true" />
   </MakeCommandTemplate>
 </Build>
 <Build xsi:type="com.visualgdb.build.make">
   <ToolchainID>
     <!-- ... -->
   </ToolchainID>
   <MakeFilePathRelativeToSourceDir>Makefile</MakeFilePathRelativeToSourceDir>
   <MakeConfigurationName>Debug</MakeConfigurationName>
   <MakeCommandTemplate>
   <SkipWhenRunningCommandList>false</SkipWhenRunningCommandList>
   <RemoteHost>
     <HostName>BuildMachine</HostName>
     <Transport>BuiltinShortcut</Transport>
   </RemoteHost>
   <Command>$(ToolchainMake)</Command>
   <Arguments>$(ToolchainMakeArgs)</Arguments>
   <WorkingDirectory>$(BuildDir)</WorkingDirectory>
   <BackgroundMode xsi:nil="true" />
   </MakeCommandTemplate>
 </Build>

Note the new $(ToolchainMake) and $(ToolchainMakeArgs) variables that are automatically set by VisualGDB when it locates a toolchain matching the ID.

When you open a VisualGDB 5.2 project in VisualGDB 5.3, it will suggest automatically upgrading it:upgrade

The upgrade process will locate a toolchain in the local toolchain list that matches the explicit definition inside the <Toolchain> element and will insert a <ToolchainID> element referencing it. If no such toolchain is found, VisualGDB will suggest importing it:toolchain

Converted projects will have both the old <Toolchain> and the new <ToolchainID> elements.

You will be able to continue building the converted non-embedded projects with both VisualGDB 5.2 and VisualGDB 5.3. However changing the toolchain settings via v5.2 GUI will remove the <ToolchainID> element and change the <Toolchain> instead. Changing  the toolchain via v5.3 GUI will change <ToolchainID>, but will keep <Toolchain> unchanged.

If you want to build a project created with v5.3 using VisualGDB 5.2, simply add a <Toolchain> element to the .vgdbsettings file manually so that VisualGDB 5.2 can recognize it. If this is an MSBuild-based projects, also ensure you have the <Toolchain> property set in the .vcxproj file.

Embedded projects

VisualGDB improves the usability of embedded projects by using variables like $(BSP_ROOT) throughout the .vcxproj files instead of hardcoding any paths:

VisualGDB 5.2 VisualGDB 5.3
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" 
  xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
 <!-- ... -->
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|VisualGDB'">
     <Toolchain>C:\SysGCC\arm-eabi</Toolchain>
   </PropertyGroup>
   <ItemGroup>
     <ClCompile Include="..\..\..\Users\<...>\EmbeddedBSPs\<...>\drivers\AnalogIn.cpp" />
   <!-- ... -->
   </ItemGroup>
 <!-- ... -->
</Project>
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0"
 xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
 <!-- ... -->
 <PropertyGroup Label="Globals">
   <VCProjectVersion>15.0</VCProjectVersion>
   <ProjectGuid>...</ProjectGuid>
   <BSP_ID>com.sysprogs.arm.stm32</BSP_ID>
   <BSP_VERSION>4.3</BSP_VERSION>
   <InPlaceBSPSubdir />
 </PropertyGroup>
 <PropertyGroup Condition="...">
   <GNUConfigurationType>Debug</GNUConfigurationType>
   <ToolchainID>com.visualgdb.arm-eabi</ToolchainID>
   <ToolchainVersion>6.2.0/7.12/r4</ToolchainVersion>
 </PropertyGroup>
 <!-- ... -->
 <ItemGroup>
   <ClCompile Include="$(BSP_ROOT)\drivers\AnalogIn.cpp" />
 <!-- ... -->
 </ItemGroup>
</Project>

This allows opening the project on different machines with different locations of the BSP and lets VisualGDB find the files without hardcoding anything. On non-MSBuild projects VisualGDB explicitly inserts a reference to the file that defines those variables:

 <ImportGroup Label="VisualGDBFindComponents">
   <Import Project="$(LOCALAPPDATA)\VisualGDB\FindComponents.props" />
 </ImportGroup>

VisualGDB 5.3 automatically maintains the FindComponents.props file to reflect the locations of all installed toolchains and BSPs. If you want to build VisualGDB 5.3 projects on VisualGDB 5.2, simply create the FindComponents.props file manually and define the variables like BSP_ROOT conditionally:

<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
 <PropertyGroup Condition="'$(BSP_ID)' != ''">
 <BSP_ROOT Condition="('$(BSP_ID)' == 'com.sysprogs.arm.stm32') and (('$(BSP_VERSION)' == '4.3') or ('$(BSP_VERSION)' == ''))">C:/Users/virtual.SYSPROGS/AppData/Local/VisualGDB/EmbeddedBSPs/arm-eabi/com.sysprogs.arm.stm32</BSP_ROOT>
 </PropertyGroup>
</Project>

Ensure you import if from your .vcxproj file, as pre-v5.3 VisualGDB won’t to this automatically.

Automatic updating

You can prevent VisualGDB 5.3 from automatically upgrading v5.2 projects by disabling the following setting under Tools->Options:pkg

To disable automatic toolchain definition upgrading use the setting shown below:oldtc

If you haven’t tried VisualGDB 5.3 yet, give it a try. It includes numerous improvements to building and debugging experience, supports profiling and code coverage for Linux projects and many more features. You can find the detailed changelog here: https://visualgdb.com/history/.