Skip to content

Commit e39a919

Browse files
authored
Merge pull request #1012 from microsoft/master
Merge master into release-cpptools
2 parents a2515f6 + 62b1e70 commit e39a919

File tree

17 files changed

+691
-409
lines changed

17 files changed

+691
-409
lines changed

IL/liblinux.il

Lines changed: 346 additions & 343 deletions
Large diffs are not rendered by default.

src/DebugEngineHost.VSCode/VSCode/EngineConfiguration.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public sealed class EngineConfiguration
3232
private readonly ExceptionSettings _exceptionSettings = new ExceptionSettings();
3333
private bool _conditionalBP;
3434
private bool _functionBP;
35+
private bool _clipboardContext;
3536

3637
// NOTE: CoreCLR doesn't support providing a code base when loading assemblies. So all debug engines
3738
// must be placed in the directory of OpenDebugAD7.exe
@@ -67,6 +68,13 @@ public bool FunctionBP
6768
set { SetProperty(out _functionBP, value); }
6869
}
6970

71+
public bool ClipboardContext
72+
{
73+
get { return _clipboardContext; }
74+
set { SetProperty(out _clipboardContext, value); }
75+
}
76+
77+
7078
/// <summary>
7179
/// Provides the directory of the debug adapter. This is the directory where
7280
/// configuration files are read from.

src/MICore/LaunchOptions.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,8 @@ private static string ResolveFromPath(string command)
541541
{
542542
string pathVar = System.Environment.GetEnvironmentVariable("PATH");
543543

544+
bool checkForWindowsExe = PlatformUtilities.IsWindows() && String.IsNullOrEmpty(Path.GetExtension(command));
545+
544546
// Check each portion of the PATH environment variable to see if it contains the requested file
545547
foreach (string pathPart in pathVar.Split(Path.PathSeparator))
546548
{
@@ -551,6 +553,15 @@ private static string ResolveFromPath(string command)
551553
{
552554
return candidate;
553555
}
556+
557+
if (checkForWindowsExe)
558+
{
559+
string exeCandidate = candidate + ".exe";
560+
if (File.Exists(exeCandidate))
561+
{
562+
return exeCandidate;
563+
}
564+
}
554565
}
555566

556567
return null;

src/MIDebugEngine.sln

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MakePIAPortable", "MakePIAP
100100
{D582C0B6-032F-4686-B01D-EB55694059CB} = {D582C0B6-032F-4686-B01D-EB55694059CB}
101101
EndProjectSection
102102
EndProject
103+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.VisualStudio.Debugger.Interop.DAP", "Microsoft.VisualStudio.Debugger.Interop.DAP\Microsoft.VisualStudio.Debugger.Interop.DAP.csproj", "{23DE943C-1F84-4E23-9490-50FE1DEDE858}"
104+
EndProject
103105
Global
104106
GlobalSection(SolutionConfigurationPlatforms) = preSolution
105107
Debug|Any CPU = Debug|Any CPU
@@ -302,6 +304,18 @@ Global
302304
{114039A0-87B5-425B-90C9-6AFC1960A247}.Lab.Debug|Any CPU.ActiveCfg = Desktop.Release|Any CPU
303305
{114039A0-87B5-425B-90C9-6AFC1960A247}.Lab.Release|Any CPU.ActiveCfg = Desktop.Release|Any CPU
304306
{114039A0-87B5-425B-90C9-6AFC1960A247}.Release|Any CPU.ActiveCfg = Desktop.Release|Any CPU
307+
{23DE943C-1F84-4E23-9490-50FE1DEDE858}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
308+
{23DE943C-1F84-4E23-9490-50FE1DEDE858}.Debug|Any CPU.Build.0 = Debug|Any CPU
309+
{23DE943C-1F84-4E23-9490-50FE1DEDE858}.Desktop.Debug|Any CPU.ActiveCfg = Desktop.Debug|Any CPU
310+
{23DE943C-1F84-4E23-9490-50FE1DEDE858}.Desktop.Debug|Any CPU.Build.0 = Desktop.Debug|Any CPU
311+
{23DE943C-1F84-4E23-9490-50FE1DEDE858}.Desktop.Release|Any CPU.ActiveCfg = Desktop.Release|Any CPU
312+
{23DE943C-1F84-4E23-9490-50FE1DEDE858}.Desktop.Release|Any CPU.Build.0 = Desktop.Release|Any CPU
313+
{23DE943C-1F84-4E23-9490-50FE1DEDE858}.Lab.Debug|Any CPU.ActiveCfg = Lab.Debug|Any CPU
314+
{23DE943C-1F84-4E23-9490-50FE1DEDE858}.Lab.Debug|Any CPU.Build.0 = Lab.Debug|Any CPU
315+
{23DE943C-1F84-4E23-9490-50FE1DEDE858}.Lab.Release|Any CPU.ActiveCfg = Lab.Release|Any CPU
316+
{23DE943C-1F84-4E23-9490-50FE1DEDE858}.Lab.Release|Any CPU.Build.0 = Lab.Release|Any CPU
317+
{23DE943C-1F84-4E23-9490-50FE1DEDE858}.Release|Any CPU.ActiveCfg = Release|Any CPU
318+
{23DE943C-1F84-4E23-9490-50FE1DEDE858}.Release|Any CPU.Build.0 = Release|Any CPU
305319
EndGlobalSection
306320
GlobalSection(SolutionProperties) = preSolution
307321
HideSolutionNode = FALSE

src/MIDebugEngine/AD7.Impl/AD7Expression.cs

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@
66
using System.Text;
77
using Microsoft.VisualStudio.Debugger.Interop;
88
using System.Threading.Tasks;
9+
using Microsoft.VisualStudio.Debugger.Interop.DAP;
910

1011
namespace Microsoft.MIDebugEngine
1112
{
1213
// This class represents a succesfully parsed expression to the debugger.
1314
// It is returned as a result of a successful call to IDebugExpressionContext2.ParseText
1415
// It allows the debugger to obtain the values of an expression in the debuggee.
1516
// For the purposes of this sample, this means obtaining the values of locals and parameters from a stack frame.
16-
public class AD7Expression : IDebugExpression2
17+
public class AD7Expression : IDebugExpression2, IDebugExpressionDAP
1718
{
1819
private AD7Engine _engine;
1920
private IVariableInformation _var;
@@ -65,6 +66,22 @@ int IDebugExpression2.EvaluateAsync(enum_EVALFLAGS dwFlags, IDebugEventCallback2
6566

6667
// This method evaluates the expression synchronously.
6768
int IDebugExpression2.EvaluateSync(enum_EVALFLAGS dwFlags, uint dwTimeout, IDebugEventCallback2 pExprCallback, out IDebugProperty2 ppResult)
69+
{
70+
return EvaluateSyncInternal(dwFlags, DAPEvalFlags.NONE, dwTimeout, pExprCallback, out ppResult);
71+
}
72+
73+
#endregion
74+
75+
#region IDebugExpressionDAP
76+
77+
int IDebugExpressionDAP.EvaluateSync(enum_EVALFLAGS dwFlags, DAPEvalFlags dapFlags, uint dwTimeout, IDebugEventCallback2 pExprCallback, out IDebugProperty2 ppResult)
78+
{
79+
return EvaluateSyncInternal(dwFlags, dapFlags, dwTimeout, pExprCallback, out ppResult);
80+
}
81+
82+
#endregion
83+
84+
private int EvaluateSyncInternal(enum_EVALFLAGS dwFlags, DAPEvalFlags dapFlags, uint dwTimeout, IDebugEventCallback2 pExprCallback, out IDebugProperty2 ppResult)
6885
{
6986
ppResult = null;
7087
if ((dwFlags & enum_EVALFLAGS.EVAL_NOSIDEEFFECTS) != 0 && _var.IsVisualized)
@@ -82,11 +99,10 @@ int IDebugExpression2.EvaluateSync(enum_EVALFLAGS dwFlags, uint dwTimeout, IDebu
8299
return Constants.S_OK;
83100
}
84101

85-
_var.SyncEval(dwFlags);
102+
_var.SyncEval(dwFlags, dapFlags);
86103
ppResult = new AD7Property(_engine, _var);
87104
return Constants.S_OK;
88105
}
89106

90-
#endregion
91107
}
92108
}

src/MIDebugEngine/Engine.Impl/Variables.cs

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
using System.Threading.Tasks;
1313
using System.Text.RegularExpressions;
1414
using System.Globalization;
15+
using Microsoft.VisualStudio.Debugger.Interop.DAP;
1516

1617
namespace Microsoft.MIDebugEngine
1718
{
@@ -32,7 +33,7 @@ internal interface IVariableInformation : IDisposable
3233
void EnsureChildren();
3334
void AsyncEval(IDebugEventCallback2 pExprCallback);
3435
void AsyncError(IDebugEventCallback2 pExprCallback, IDebugProperty2 error);
35-
void SyncEval(enum_EVALFLAGS dwFlags = 0);
36+
void SyncEval(enum_EVALFLAGS dwFlags = 0, DAPEvalFlags dwDAPFlags = 0);
3637
ThreadContext ThreadContext { get; }
3738
VariableInformation FindChildByName(string name);
3839
string EvalDependentExpression(string expr);
@@ -399,11 +400,11 @@ public void AsyncError(IDebugEventCallback2 pExprCallback, IDebugProperty2 error
399400
AsyncErrorImpl(pExprCallback != null ? new EngineCallback(_engine, pExprCallback) : _engine.Callback, this, error);
400401
}
401402

402-
public void SyncEval(enum_EVALFLAGS dwFlags = 0)
403+
public void SyncEval(enum_EVALFLAGS dwFlags = 0, DAPEvalFlags dwDAPFlags = 0)
403404
{
404405
Task eval = Task.Run(async () =>
405406
{
406-
await Eval(dwFlags);
407+
await Eval(dwFlags, dwDAPFlags);
407408
});
408409
eval.Wait();
409410
}
@@ -444,7 +445,7 @@ private bool IsConsoleExecCmd(string command, out string strippedCommand)
444445
return false;
445446
}
446447

447-
internal async Task Eval(enum_EVALFLAGS dwFlags = 0)
448+
internal async Task Eval(enum_EVALFLAGS dwFlags = 0, DAPEvalFlags dwDAPFlags = 0)
448449
{
449450
this.VerifyNotDisposed();
450451

@@ -469,6 +470,22 @@ internal async Task Eval(enum_EVALFLAGS dwFlags = 0)
469470
}
470471
else
471472
{
473+
bool canRunClipboardContextCommands = this._debuggedProcess.MICommandFactory.Mode == MIMode.Gdb && dwDAPFlags.HasFlag(DAPEvalFlags.CLIPBOARD_CONTEXT);
474+
int numElements = 200;
475+
476+
if (canRunClipboardContextCommands)
477+
{
478+
string showPrintElementsResult = await MIDebugCommandDispatcher.ExecuteCommand("show print elements", _debuggedProcess, ignoreFailures: true);
479+
// Possible values for 'numElementsStr'
480+
// "Limit on string chars or array elements to print is <number>."
481+
// "Limit on string chars or array elements to print is unlimited."
482+
string numElementsStr = Regex.Match(showPrintElementsResult, @"\d+").Value;
483+
if (!string.IsNullOrEmpty(numElementsStr) && int.TryParse(numElementsStr, out numElements) && numElements != 0)
484+
{
485+
await MIDebugCommandDispatcher.ExecuteCommand("set print elements 0", _debuggedProcess, ignoreFailures: true);
486+
}
487+
}
488+
472489
int threadId = Client.GetDebuggedThread().Id;
473490
uint frameLevel = _ctx.Level;
474491
Results results = await _engine.DebuggedProcess.MICommandFactory.VarCreate(_strippedName, threadId, frameLevel, dwFlags, ResultClass.None);
@@ -522,7 +539,7 @@ internal async Task Eval(enum_EVALFLAGS dwFlags = 0)
522539
}
523540
else
524541
{
525-
Debug.Fail("Weird msg from -var-evaluate-expression");
542+
Debug.Fail("Unexpected format of msg from -var-evaluate-expression");
526543
}
527544
}
528545
}
@@ -533,7 +550,12 @@ internal async Task Eval(enum_EVALFLAGS dwFlags = 0)
533550
}
534551
else
535552
{
536-
Debug.Fail("Weird msg from -var-create");
553+
Debug.Fail("Unexpected format of msg from -var-create");
554+
}
555+
556+
if (canRunClipboardContextCommands && numElements != 0)
557+
{
558+
await MIDebugCommandDispatcher.ExecuteCommand(string.Format(CultureInfo.InvariantCulture, "set print elements {0}", numElements), _debuggedProcess, ignoreFailures: true);
537559
}
538560
}
539561
}
@@ -570,7 +592,7 @@ internal async Task Format()
570592
}
571593
else
572594
{
573-
Debug.Fail("Weird msg from expression formatting");
595+
Debug.Fail("Unexpected format of msg from expression formatting");
574596
}
575597
}
576598

src/MIDebugEngine/MIDebugEngine.csproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,11 @@
169169
<Project>{54c33afa-438d-4932-a2f0-d0f2bb2fadc9}</Project>
170170
<Name>MICore</Name>
171171
</ProjectReference>
172+
<ProjectReference Include="..\Microsoft.VisualStudio.Debugger.Interop.DAP\Microsoft.VisualStudio.Debugger.Interop.DAP.csproj">
173+
<Project>{23DE943C-1F84-4E23-9490-50FE1DEDE858}</Project>
174+
<Name>Microsoft.VisualStudio.Debugger.Interop.DAP</Name>
175+
<EmbedInteropTypes>True</EmbedInteropTypes>
176+
</ProjectReference>
172177
<ProjectReference Include="..\Microsoft.VisualStudio.Debugger.Interop.UnixPortSupplier\Microsoft.VisualStudio.Debugger.Interop.UnixPortSupplier.DesignTime.csproj">
173178
<Project>{7654cfbb-30db-4c20-bde3-a960cba2036c}</Project>
174179
<Name>Microsoft.VisualStudio.Debugger.Interop.UnixPortSupplier.DesignTime</Name>

src/MIDebugEngine/Microsoft.MIDebugEngine.pkgdef

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
@="MI Debug Engine"
6060
"CLSID"="{DAB324E9-7B35-454C-ACA8-F6BB0D5C8673}"
6161
"Adapter"="$PackageFolder$\vscode\OpenDebugAD7.exe"
62+
; "AdapterArgs"=""
6263
"Language"="C++"
6364
"LanguageId"="{3A12D0B7-C26C-11D0-B442-00A0244A1DD2}"
6465
; "AddressBP"=dword:00000001

src/MIDebugEngine/Natvis.Impl/Natvis.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
using System.Reflection;
2020

2121
using Logger = MICore.Logger;
22+
using Microsoft.VisualStudio.Debugger.Interop.DAP;
2223

2324
namespace Microsoft.MIDebugEngine.Natvis
2425
{
@@ -53,7 +54,7 @@ public SimpleWrapper(string name, AD7Engine engine, IVariableInformation underly
5354
public VariableInformation FindChildByName(string name) => Parent.FindChildByName(name);
5455
public string EvalDependentExpression(string expr) => Parent.EvalDependentExpression(expr);
5556
public void AsyncEval(IDebugEventCallback2 pExprCallback) => Parent.AsyncEval(pExprCallback);
56-
public void SyncEval(enum_EVALFLAGS dwFlags) => Parent.SyncEval(dwFlags);
57+
public void SyncEval(enum_EVALFLAGS dwFlags, DAPEvalFlags dwDAPFlags) => Parent.SyncEval(dwFlags, dwDAPFlags);
5758
public virtual string FullName() => Name;
5859
public void EnsureChildren() => Parent.EnsureChildren();
5960
public void AsyncError(IDebugEventCallback2 pExprCallback, IDebugProperty2 error)
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
using System;
2+
using System.Runtime.InteropServices;
3+
4+
namespace Microsoft.VisualStudio.Debugger.Interop.DAP
5+
{
6+
/// <summary>
7+
/// An extended set of evaluate flags that are in Debug Adapter Protocol but not listed in AD7
8+
/// </summary>
9+
[Flags]
10+
public enum DAPEvalFlags
11+
{
12+
/// <summary>
13+
/// No additional Eval Flags from DAP
14+
/// </summary>
15+
NONE = 0,
16+
/// <summary>
17+
/// Evaluation is for a clipboard context
18+
/// </summary>
19+
CLIPBOARD_CONTEXT = 1
20+
}
21+
22+
/// <summary>
23+
/// IDebugExpression for Debug Adapter Protocol
24+
/// </summary>
25+
[ComImport()]
26+
[ComVisible(true)]
27+
[Guid("76C710C4-CE66-4422-AC7C-1E41B3FC0BE3")]
28+
[InterfaceType(1)]
29+
public interface IDebugExpressionDAP
30+
{
31+
/// <summary>
32+
/// The IDebugExpression.EvaluateSync interface which includes DAPEvalFlags.
33+
/// This method is to be used with calls from clients using the Debug Adapter Protocol.
34+
/// </summary>
35+
[PreserveSig]
36+
int EvaluateSync([In] enum_EVALFLAGS dwFlags, [In] DAPEvalFlags dapFlags, [In] uint dwTimeout, [In][MarshalAs(UnmanagedType.Interface)] IDebugEventCallback2 pExprCallback, [Out, MarshalAs(UnmanagedType.Interface)] out IDebugProperty2 ppResult);
37+
}
38+
}

0 commit comments

Comments
 (0)