Skip to content

Commit

Permalink
Merge pull request #1434 from microsoft/main
Browse files Browse the repository at this point in the history
Merge main into release-cpptools
  • Loading branch information
WardenGnaw committed Jan 3, 2024
2 parents a293696 + 4017519 commit ec430af
Show file tree
Hide file tree
Showing 34 changed files with 531 additions and 293 deletions.
26 changes: 13 additions & 13 deletions build/package_versions.settings.targets
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Microsoft_VisualStudio_Debugger_Interop_Portable_Version>1.0.1</Microsoft_VisualStudio_Debugger_Interop_Portable_Version>
<Microsoft_VisualStudio_Interop_Version>17.0.0-previews-1-31410-258</Microsoft_VisualStudio_Interop_Version>
<Newtonsoft_Json_Version>13.0.1</Newtonsoft_Json_Version>
<Microsoft_VisualStudio_Interop_Version>17.8.37221</Microsoft_VisualStudio_Interop_Version>
<Newtonsoft_Json_Version>13.0.3</Newtonsoft_Json_Version>
<Microsoft_VisualStudio_Shared_VSCodeDebugProtocol_Version>17.2.60629.1</Microsoft_VisualStudio_Shared_VSCodeDebugProtocol_Version>

<!-- Test Packages -->
Expand All @@ -19,20 +19,20 @@
<PropertyGroup>
<Microsoft_VisualStudio_ComponentModelHost_Version>17.0.28-g439d20ddd3</Microsoft_VisualStudio_ComponentModelHost_Version>
<Microsoft_VisualStudio_Debugger_Engine_Version>17.0.1051901-preview</Microsoft_VisualStudio_Debugger_Engine_Version>
<Microsoft_VisualStudio_Debugger_Interop_10_0_Version>17.0.0-previews-1-31410-258</Microsoft_VisualStudio_Debugger_Interop_10_0_Version>
<Microsoft_VisualStudio_Debugger_Interop_11_0_Version>17.0.0-previews-1-31410-258</Microsoft_VisualStudio_Debugger_Interop_11_0_Version>
<Microsoft_VisualStudio_Debugger_Interop_12_0_Version>17.0.0-previews-1-31410-258</Microsoft_VisualStudio_Debugger_Interop_12_0_Version>
<Microsoft_VisualStudio_Debugger_Interop_15_0_Version>17.0.0-previews-1-31410-258</Microsoft_VisualStudio_Debugger_Interop_15_0_Version>
<Microsoft_VisualStudio_Debugger_Interop_16_0_Version>17.0.0-previews-1-31410-258</Microsoft_VisualStudio_Debugger_Interop_16_0_Version>
<Microsoft_VisualStudio_Debugger_InteropA_Version>17.0.0-previews-1-31410-258</Microsoft_VisualStudio_Debugger_InteropA_Version>
<Microsoft_VisualStudio_Shell_15_0_Version>17.0.0-previews-1-31410-258</Microsoft_VisualStudio_Shell_15_0_Version>
<Microsoft_VisualStudio_Shell_Framework_Version>17.0.0-previews-1-31410-258</Microsoft_VisualStudio_Shell_Framework_Version>
<Microsoft_VisualStudio_Threading_Version>17.0.17-alpha</Microsoft_VisualStudio_Threading_Version>
<Microsoft_VisualStudio_Utilities_Version>17.0.0-previews-1-31410-258</Microsoft_VisualStudio_Utilities_Version>
<Microsoft_VisualStudio_Debugger_Interop_10_0_Version>17.5.33428.388</Microsoft_VisualStudio_Debugger_Interop_10_0_Version>
<Microsoft_VisualStudio_Debugger_Interop_11_0_Version>17.5.33428.366</Microsoft_VisualStudio_Debugger_Interop_11_0_Version>
<Microsoft_VisualStudio_Debugger_Interop_12_0_Version>17.5.33428.366</Microsoft_VisualStudio_Debugger_Interop_12_0_Version>
<Microsoft_VisualStudio_Debugger_Interop_15_0_Version>17.5.33428.366</Microsoft_VisualStudio_Debugger_Interop_15_0_Version>
<Microsoft_VisualStudio_Debugger_Interop_16_0_Version>17.5.33428.366</Microsoft_VisualStudio_Debugger_Interop_16_0_Version>
<Microsoft_VisualStudio_Debugger_InteropA_Version>17.5.33428.366</Microsoft_VisualStudio_Debugger_InteropA_Version>
<Microsoft_VisualStudio_Shell_15_0_Version>17.8.37221</Microsoft_VisualStudio_Shell_15_0_Version>
<Microsoft_VisualStudio_Shell_Framework_Version>17.8.37221</Microsoft_VisualStudio_Shell_Framework_Version>
<Microsoft_VisualStudio_Threading_Version>17.8.14</Microsoft_VisualStudio_Threading_Version>
<Microsoft_VisualStudio_Utilities_Version>17.8.37221</Microsoft_VisualStudio_Utilities_Version>
<Microsoft_VisualStudio_Shell_Interop_15_0_DesignTime_Version>15.0.26932</Microsoft_VisualStudio_Shell_Interop_15_0_DesignTime_Version>
<Microsoft_VisualStudio_Workspace_Version>15.0.392</Microsoft_VisualStudio_Workspace_Version>
<Microsoft_VisualStudio_Workspace_VSIntegration_Version>15.0.392</Microsoft_VisualStudio_Workspace_VSIntegration_Version>
<Microsoft_VisualStudio_TextManager_Interop_Version>17.0.0-previews-1-31410-258</Microsoft_VisualStudio_TextManager_Interop_Version>
<Microsoft_VisualStudio_TextManager_Interop_Version>17.8.37221</Microsoft_VisualStudio_TextManager_Interop_Version>
<Microsoft_VSSDK_BuildTools_Version>17.3.2093</Microsoft_VSSDK_BuildTools_Version>
<System_Runtime_Loader_Version>4.3.0</System_Runtime_Loader_Version>
</PropertyGroup>
Expand Down
4 changes: 2 additions & 2 deletions build/version.settings.targets
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<!--SxS: These three properties should be changed at the start of a new version, VersionZeroYear should be the year
before the start of the project.-->
<MajorVersion>17</MajorVersion>
<MinorVersion>4</MinorVersion>
<VersionZeroYear>2020</VersionZeroYear>
<MinorVersion>8</MinorVersion>
<VersionZeroYear>2022</VersionZeroYear>
<!-- Note: for compatibility, we leave the default assembly version of the repo at 14.0.
If we ever decide to change this, make sure that you notify partner teams such as C++ IOT -->
<AssemblyVersion Condition="'$(AssemblyVersion)'==''">14.0.0.0</AssemblyVersion>
Expand Down
2 changes: 0 additions & 2 deletions src/DebugEngineHost/DebugEngineHost.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,6 @@
<IncludeAssets>compile</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>

<PackageReference Include="Microsoft.VisualStudio.Validation" Version="17.0.16-alpha" />
</ItemGroup>

<ItemGroup Label="Assembly to Generate">
Expand Down
2 changes: 2 additions & 0 deletions src/DebugEngineHost/HostLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ public static ILogChannel GetNatvisLogChannel()

public static void Reset()
{
s_natvisLogChannel?.Close();
s_natvisLogChannel = null;
s_engineLogChannel?.Close();
s_engineLogChannel = null;
}
}
Expand Down
7 changes: 6 additions & 1 deletion src/MICore/LaunchOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ public static ReadOnlyCollection<SourceMapEntry> CreateCollection(Xml.LaunchOpti

public static ReadOnlyCollection<SourceMapEntry> CreateCollection(Dictionary<string, object> source)
{
IList<SourceMapEntry> sourceMaps = new List<SourceMapEntry>(source.Keys.Count);
var sourceMaps = new List<SourceMapEntry>(source.Keys.Count);

foreach (var item in source)
{
Expand Down Expand Up @@ -416,6 +416,11 @@ public static ReadOnlyCollection<SourceMapEntry> CreateCollection(Dictionary<str
throw new InvalidLaunchOptionsException(String.Format(CultureInfo.CurrentCulture, MICoreResources.Error_SourceFileMapInvalidEditorPath));
}
}

// Ensure the map is sorted such that more specific directories are in front of less specific by sorting the map
// in descending order of the compile time path
sourceMaps.Sort((x, y) => string.CompareOrdinal(y.CompileTimePath, x.CompileTimePath));

return new ReadOnlyCollection<SourceMapEntry>(sourceMaps);
}
}
Expand Down
1 change: 1 addition & 0 deletions src/MICore/Logger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ public static void Reset()
{
HostLogger.Reset();
s_isEnabled = false;
s_isInitialized = false;
}
}

Expand Down
10 changes: 8 additions & 2 deletions src/MIDebugEngine/AD7.Impl/AD7Disassembly.cs
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,14 @@ public int GetCodeContext(ulong uCodeLocationId, out IDebugCodeContext2 ppCodeCo
public int GetCodeLocationId(IDebugCodeContext2 pCodeContext, out ulong puCodeLocationId)
{
AD7MemoryAddress addr = pCodeContext as AD7MemoryAddress;
puCodeLocationId = addr.Address;
return Constants.S_OK;
if (addr != null)
{
puCodeLocationId = addr.Address;
return Constants.S_OK;
}

puCodeLocationId = 0;
return Constants.E_FAIL;
}

public int GetCurrentLocation(out ulong puCodeLocationId)
Expand Down
4 changes: 2 additions & 2 deletions src/MIDebugEngine/AD7.Impl/AD7Engine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ public int Attach(IDebugProgram2[] portProgramArray, IDebugProgramNode2[] progra
{
Debug.Assert(_ad7ProgramId == Guid.Empty);

Logger.LoadMIDebugLogger();
Logger.EnsureInitialized();

if (celtPrograms != 1)
{
Expand Down Expand Up @@ -539,7 +539,7 @@ int IDebugEngineLaunch2.LaunchSuspended(string pszServer, IDebugPort2 port, stri
Debug.Assert(_ad7ProgramId == Guid.Empty);

// Check if the logger was enabled late.
Logger.LoadMIDebugLogger();
Logger.EnsureInitialized();

process = null;

Expand Down
30 changes: 28 additions & 2 deletions src/MIDebugEngine/AD7.Impl/AD7Property.cs
Original file line number Diff line number Diff line change
Expand Up @@ -229,11 +229,37 @@ public int GetMemoryContext(out IDebugMemoryContext2 ppMemory)
{
return AD7_HRESULT.S_GETMEMORYCONTEXT_NO_MEMORY_CONTEXT;
}
v = v.Trim();

if ((v[0] == '[') && (v[v.Length-1] == ']'))
{
// this is an array evaluation result from GDB, which does not contain an address
// VS on the other hand supports direct array evaluations without address operator
// therefore we need to re-evaluate with an address operator
//
VariableInformation viArray = new VariableInformation("&(" + _variableInformation.FullName() + ")", (VariableInformation)_variableInformation);
viArray.SyncEval();
if (viArray.Error)
{
return AD7_HRESULT.S_GETMEMORYCONTEXT_NO_MEMORY_CONTEXT;
}
v = viArray.Value;
v.Trim();
if (v.Length == 0)
{
return AD7_HRESULT.S_GETMEMORYCONTEXT_NO_MEMORY_CONTEXT;
}
}

if (v[0] == '{')
{
var index = v.IndexOf('}');
if (index == -1)
{
// syntax error!
return AD7_HRESULT.S_GETMEMORYCONTEXT_NO_MEMORY_CONTEXT;
}
// strip type name and trailing spaces
v = v.Substring(v.IndexOf('}') + 1);
v = v.Substring(index+1);
v = v.Trim();
}
int i = v.IndexOf(' ');
Expand Down
36 changes: 27 additions & 9 deletions src/MIDebugEngine/Engine.Impl/DebuggedProcess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -690,17 +690,11 @@ private async Task<List<LaunchCommand>> GetInitializeCommands()
LocalLaunchOptions localLaunchOptions = _launchOptions as LocalLaunchOptions;
if (this.IsCoreDump)
{
// Add executable information
this.AddExecutablePathCommand(commands);
// Load executable and core dump
this.AddExecutableAndCorePathCommand(commands);

// Important: this must occur after file-exec-and-symbols but before anything else.
// Important: this must occur after executable load but before anything else.
this.AddGetTargetArchitectureCommand(commands);

// Add core dump information (linux/mac does not support quotes around this path but spaces in the path do work)
string coreDump = this.UseUnixPathSeparators ? _launchOptions.CoreDumpPath : this.EnsureProperPathSeparators(_launchOptions.CoreDumpPath, true);
string coreDumpCommand = _launchOptions.DebuggerMIMode == MIMode.Lldb ? String.Concat("target create --core ", coreDump) : String.Concat("-target-select core ", coreDump);
string coreDumpDescription = String.Format(CultureInfo.CurrentCulture, ResourceStrings.LoadingCoreDumpMessage, _launchOptions.CoreDumpPath);
commands.Add(new LaunchCommand(coreDumpCommand, coreDumpDescription, ignoreFailures: false));
}
else if (_launchOptions.ProcessId.HasValue)
{
Expand Down Expand Up @@ -918,6 +912,30 @@ private void AddExecutablePathCommand(IList<LaunchCommand> commands)
commands.Add(new LaunchCommand("-file-exec-and-symbols " + exe, description, ignoreFailures: false, failureHandler: failureHandler));
}

private void AddExecutableAndCorePathCommand(IList<LaunchCommand> commands)
{
string command;
if (_launchOptions.DebuggerMIMode == MIMode.Lldb)
{
// LLDB requires loading the executable and the core into the same target, using one command. Quotes in the path are supported.
string exePath = this.EnsureProperPathSeparators(_launchOptions.ExePath, true);
string corePath = this.EnsureProperPathSeparators(_launchOptions.CoreDumpPath, true);
command = String.Concat("file ", exePath, " -c ", corePath);
}
else
{
// GDB requires loading the executable and core separately.
// Note: Linux/mac do not support quotes around this path, but spaces in the path do work.
this.AddExecutablePathCommand(commands);
string corePathNoQuotes = this.EnsureProperPathSeparators(_launchOptions.CoreDumpPath, true, true);
command = String.Concat("-target-select core ", corePathNoQuotes);
}

// Load core dump information
string description = String.Format(CultureInfo.CurrentCulture, ResourceStrings.LoadingCoreDumpMessage, _launchOptions.CoreDumpPath);
commands.Add(new LaunchCommand(command, description, ignoreFailures: false));
}

private void DetermineAndAddExecutablePathCommand(IList<LaunchCommand> commands, UnixShellPortLaunchOptions launchOptions)
{
// TODO: connecting to OSX via SSH doesn't work yet. Show error after connection manager dialog gets dismissed.
Expand Down
17 changes: 15 additions & 2 deletions src/MIDebugEngine/Engine.Impl/Disassembly.cs
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,21 @@ private void DeleteRangeFromCache(DisassemblyBlock block)
// this is inefficient so we try and grab everything in one gulp
internal static async Task<DisasmInstruction[]> Disassemble(DebuggedProcess process, ulong startAddr, ulong endAddr)
{
string cmd = "-data-disassemble -s " + EngineUtils.AsAddr(startAddr, process.Is64BitArch) + " -e " + EngineUtils.AsAddr(endAddr, process.Is64BitArch) + " -- 2";
Results results = await process.CmdAsync(cmd, ResultClass.None);
string cmd;
string startAddrStr;
string endAddrStr;
int i = 0;
Results results;
do
{
startAddrStr = EngineUtils.AsAddr(startAddr, process.Is64BitArch);
endAddrStr = EngineUtils.AsAddr(endAddr, process.Is64BitArch);
cmd = "-data-disassemble -s " + startAddrStr + " -e " + endAddrStr + " -- 2";
results = await process.CmdAsync(cmd, ResultClass.None);
--startAddr;
++i;
} while (results.ResultClass != ResultClass.done && i < process.MaxInstructionSize);

if (results.ResultClass != ResultClass.done)
{
return null;
Expand Down
3 changes: 3 additions & 0 deletions src/MIDebugEngine/Engine.Impl/Variables.cs
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,9 @@ private string ProcessFormatSpecifiers(string exp, out string formatSpecifier)
case "su":
case "sub":
return "(const char16_t*)(" + exp.Substring(0, lastComma) + ")";
case "s32":
case "s32b":
return "(const char32_t*)(" + exp.Substring(0, lastComma) + ")";
case "c":
return "(char)(" + exp.Substring(0, lastComma) + ")";
// just remove and ignore these
Expand Down
18 changes: 18 additions & 0 deletions src/MIDebugEngine/MIDebugCommandDispatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using MICore;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
Expand Down Expand Up @@ -89,6 +90,23 @@ private static void process_DebuggerExitEvent(object sender, EventArgs e)

public static void EnableLogging(bool output, string logFile)
{
if (!string.IsNullOrEmpty(logFile))
{
string tempDirectory = Path.GetTempPath();
if (Path.IsPathRooted(logFile) || (!string.IsNullOrEmpty(tempDirectory) && Directory.Exists(tempDirectory)))
{
string filePath = Path.Combine(tempDirectory, logFile);

File.CreateText(filePath).Dispose(); // Test to see if we can create a text file in HostLogChannel. This will allow the error to be shown when enabling the setting.

logFile = filePath;
}
else
{
throw new ArgumentOutOfRangeException(nameof(logFile));
}
}

Logger.CmdLogInfo.logFile = logFile;
if (output)
Logger.CmdLogInfo.logToOutput = WriteLogToOutput;
Expand Down
2 changes: 0 additions & 2 deletions src/MIDebugPackage/MIDebugPackage.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@
<PackageReference Include="Microsoft.VisualStudio.Shell.15.0" Version="$(Microsoft_VisualStudio_Shell_15_0_Version)" />
<PackageReference Include="Microsoft.VisualStudio.OLE.Interop" Version="17.0.0-previews-1-31410-258" />

<PackageReference Include="Microsoft.VisualStudio.Validation" Version="17.0.16-alpha" />

<PackageReference Include="Microsoft.VisualStudio.Debugger.Interop.16.0" Version="$(Microsoft_VisualStudio_Debugger_Interop_16_0_Version)">
<IncludeAssets>compile</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
Expand Down
10 changes: 10 additions & 0 deletions src/MIDebugPackage/MIDebugPackagePackage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,16 @@ private void LaunchDebugTarget(string filePath, string options)
private void EnableLogging(bool sendToOutputWindow, string logFile)
{
ThreadHelper.ThrowIfNotOnUIThread();

IVsDebugger debugger = (IVsDebugger)GetService(typeof(IVsDebugger));
DBGMODE[] mode = new DBGMODE[] { DBGMODE.DBGMODE_Design };
int hr = debugger.GetMode(mode);

if (hr == VSConstants.S_OK && mode[0] != DBGMODE.DBGMODE_Design)
{
throw new ArgumentException("Unable to update MIDebugLog while debugging.");
}

try
{
MIDebugCommandDispatcher.EnableLogging(sendToOutputWindow, logFile);
Expand Down
14 changes: 7 additions & 7 deletions src/MakePIAPortable/MakePIAPortable.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@
</ItemGroup>

<ItemGroup>
<MakePIAPortableFiles Include="$(PkgMicrosoft_VisualStudio_Debugger_InteropA)\lib\net45\Microsoft.VisualStudio.Debugger.InteropA.dll" />
<MakePIAPortableFiles Include="$(PkgMicrosoft_VisualStudio_Debugger_Interop_10_0)\lib\net45\Microsoft.VisualStudio.Debugger.Interop.10.0.dll" />
<MakePIAPortableFiles Include="$(PkgMicrosoft_VisualStudio_Debugger_Interop_11_0)\lib\net45\Microsoft.VisualStudio.Debugger.Interop.11.0.dll" />
<MakePIAPortableFiles Include="$(PkgMicrosoft_VisualStudio_Debugger_Interop_12_0)\lib\net45\Microsoft.VisualStudio.Debugger.Interop.12.0.dll" />
<MakePIAPortableFiles Include="$(PkgMicrosoft_VisualStudio_Debugger_Interop_15_0)\lib\net45\Microsoft.VisualStudio.Debugger.Interop.15.0.dll" />
<MakePIAPortableFiles Include="$(PkgMicrosoft_VisualStudio_Debugger_Interop_16_0)\lib\net45\Microsoft.VisualStudio.Debugger.Interop.16.0.dll" />
<MakePIAPortableFiles Include="$(PkgMicrosoft_VisualStudio_Interop)\lib\net45\Microsoft.VisualStudio.Interop.dll" />
<MakePIAPortableFiles Include="$(PkgMicrosoft_VisualStudio_Debugger_InteropA)\lib\net472\Microsoft.VisualStudio.Debugger.InteropA.dll" />
<MakePIAPortableFiles Include="$(PkgMicrosoft_VisualStudio_Debugger_Interop_10_0)\lib\net472\Microsoft.VisualStudio.Debugger.Interop.10.0.dll" />
<MakePIAPortableFiles Include="$(PkgMicrosoft_VisualStudio_Debugger_Interop_11_0)\lib\net472\Microsoft.VisualStudio.Debugger.Interop.11.0.dll" />
<MakePIAPortableFiles Include="$(PkgMicrosoft_VisualStudio_Debugger_Interop_12_0)\lib\net472\Microsoft.VisualStudio.Debugger.Interop.12.0.dll" />
<MakePIAPortableFiles Include="$(PkgMicrosoft_VisualStudio_Debugger_Interop_15_0)\lib\net472\Microsoft.VisualStudio.Debugger.Interop.15.0.dll" />
<MakePIAPortableFiles Include="$(PkgMicrosoft_VisualStudio_Debugger_Interop_16_0)\lib\net472\Microsoft.VisualStudio.Debugger.Interop.16.0.dll" />
<MakePIAPortableFiles Include="$(PkgMicrosoft_VisualStudio_Interop)\lib\net472\Microsoft.VisualStudio.Interop.dll" />
</ItemGroup>

<PropertyGroup>
Expand Down
Loading

0 comments on commit ec430af

Please sign in to comment.