Skip to content

Commit

Permalink
Merge pull request #1113 from microsoft/dev/waan/rel_d16_10
Browse files Browse the repository at this point in the history
Merge 'main' into release_mdd
  • Loading branch information
WardenGnaw authored Mar 9, 2021
2 parents 73bc46d + 892d42f commit 102f979
Show file tree
Hide file tree
Showing 14 changed files with 228 additions and 44 deletions.
57 changes: 57 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# EditorConfig is awesome: http://EditorConfig.org
# This configuration is respected by multiple editors
# Using basic settings to unify indentation in repo

# top-most EditorConfig file
root = true

[*]
indent_style = space
indent_size = 4
end_of_line = crlf
trim_trailing_whitespace = true

# XML Formats

[*.{xml,csproj,androidproj,vcxproj,vcxproj.filters,nuspec,vsct,resx,config,targets,props,xsd,natvis,playlist}]
indent_size = 2

# JSON and YML
[*.yml]
[*.json]
indent_size = 2

# .NET

[*.cs]
file_header_template = // Copyright (c) Microsoft. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.
dotnet_sort_system_directives_first = false

# static fields should have s_ prefix
dotnet_naming_rule.static_fields_should_have_prefix.severity = warning
dotnet_naming_rule.static_fields_should_have_prefix.symbols = static_fields
dotnet_naming_rule.static_fields_should_have_prefix.style = static_prefix_style
dotnet_naming_symbols.static_fields.applicable_kinds = field
dotnet_naming_symbols.static_fields.required_modifiers = static
dotnet_naming_symbols.static_fields.applicable_accessibilities = private, internal, private_protected
dotnet_naming_style.static_prefix_style.required_prefix = s_
dotnet_naming_style.static_prefix_style.capitalization = camel_case

# internal and private fields should be _camelCase
dotnet_naming_rule.camel_case_for_private_internal_fields.severity = warning
dotnet_naming_rule.camel_case_for_private_internal_fields.symbols = private_internal_fields
dotnet_naming_rule.camel_case_for_private_internal_fields.style = camel_case_underscore_style
dotnet_naming_symbols.private_internal_fields.applicable_kinds = field
dotnet_naming_symbols.private_internal_fields.applicable_accessibilities = private, internal
dotnet_naming_style.camel_case_underscore_style.required_prefix = _
dotnet_naming_style.camel_case_underscore_style.capitalization = camel_case

dotnet_style_readonly_field = true:warning

# Unix Shell scripts
[*.sh]
charset = utf-8
end_of_line = lf

[*.sln]
indent_style = tab
6 changes: 6 additions & 0 deletions src/MICore/JsonLaunchOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,12 @@ public partial class PipeTransportOptions
[JsonProperty("pipeArgs", DefaultValueHandling = DefaultValueHandling.Ignore)]
public List<string> PipeArgs { get; private set; }

/// <summary>
/// Command line arguments passed to the pipe program to execute a remote command.
/// </summary>
[JsonProperty("pipeCmd", DefaultValueHandling = DefaultValueHandling.Ignore)]
public List<string> PipeCmd { get; private set; }

/// <summary>
/// The full path to the debugger on the target machine, for example /usr/bin/gdb.
/// </summary>
Expand Down
5 changes: 4 additions & 1 deletion src/MICore/LaunchOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ static internal PipeLaunchOptions CreateFromJson(JObject parsedOptions)
string pipeCwd = pipeTransport.PipeCwd;
string pipeProgram = pipeTransport.PipeProgram;
List<string> pipeArgs = pipeTransport.PipeArgs;
List<string> pipeCmd = pipeTransport.PipeCmd;
string debuggerPath = pipeTransport.DebuggerPath;
bool quoteArgs = pipeTransport.QuoteArgs.GetValueOrDefault(true);
Dictionary<string, string> pipeEnv = pipeTransport.PipeEnv;
Expand All @@ -128,6 +129,7 @@ static internal PipeLaunchOptions CreateFromJson(JObject parsedOptions)
{
pipeProgram = platformSpecificTransportOptions.PipeProgram ?? pipeProgram;
pipeArgs = platformSpecificTransportOptions.PipeArgs ?? pipeArgs;
pipeCmd = platformSpecificTransportOptions.PipeCmd ?? pipeCmd;
pipeCwd = platformSpecificTransportOptions.PipeCwd ?? pipeCwd;
pipeEnv = platformSpecificTransportOptions.PipeEnv ?? pipeEnv;
debuggerPath = platformSpecificTransportOptions.DebuggerPath ?? pipeTransport.DebuggerPath;
Expand All @@ -137,7 +139,7 @@ static internal PipeLaunchOptions CreateFromJson(JObject parsedOptions)
PipeLaunchOptions pipeOptions = new PipeLaunchOptions(
pipePath: pipeProgram,
pipeArguments: EnsurePipeArguments(pipeArgs, debuggerPath, gdbPathDefault, quoteArgs),
pipeCommandArguments: ParseArguments(pipeArgs, quoteArgs),
pipeCommandArguments: ParseArguments(pipeCmd, quoteArgs),
pipeCwd: pipeCwd,
pipeEnvironment: GetEnvironmentEntries(pipeEnv)
);
Expand Down Expand Up @@ -1909,6 +1911,7 @@ public void InitializeLaunchOptions(Json.LaunchOptions.LaunchOptions launch)

public void InitializeAttachOptions(Json.LaunchOptions.AttachOptions attach)
{
this.DebuggerMIMode = ConvertMIModeString(RequireAttribute(attach.MIMode, nameof(attach.MIMode)));
this.ProcessId = attach.ProcessId;
}

Expand Down
3 changes: 2 additions & 1 deletion src/MIDebugEngine.sln
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Android", "Android", "{2865
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{CF02407C-BF37-4D51-83F4-845A7F36C101}"
ProjectSection(SolutionItems) = preProject
..\.editorconfig = ..\.editorconfig
IDECodeAnalysis.ruleset = IDECodeAnalysis.ruleset
EndProjectSection
EndProject
Expand Down Expand Up @@ -59,7 +60,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.VisualStudio.Debu
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MIDebugPackage", "MIDebugPackage\MIDebugPackage.csproj", "{A8D8E02F-4258-4F2E-88B6-A50FEBD5AD8C}"
ProjectSection(ProjectDependencies) = postProject
{15BCBEF4-1C2B-412B-925B-34A049097E62} = {15BCBEF4-1C2B-412B-925B-34A049097E62}
{15BCBEF4-1C2B-412B-925B-34A049097E62} = {15BCBEF4-1C2B-412B-925B-34A049097E62}
EndProjectSection
EndProject
Global
Expand Down
2 changes: 1 addition & 1 deletion src/MIDebugEngine/AD7.Impl/AD7Engine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,7 @@ public int EnumCodeContexts(IDebugDocumentPosition2 docPosition, out IEnumDebugC
{
var codeCxt = new AD7MemoryAddress(this, a, null);
TEXT_POSITION pos;
pos.dwLine = line;
pos.dwLine = line - 1;
pos.dwColumn = 0;
MITextPosition textPosition = new MITextPosition(documentName, pos, pos);
codeCxt.SetDocumentContext(new AD7DocumentContext(textPosition, codeCxt));
Expand Down
2 changes: 1 addition & 1 deletion src/MIDebugEngine/AD7.Impl/AD7Events.cs
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ public AD7ExceptionEvent(string name, string description, uint code, Guid? excep
{
_name = name;
_code = code;
_description = description ?? name;
_description = string.IsNullOrEmpty(description) ? name : description;
_category = exceptionCategory ?? EngineConstants.EngineId;

switch (state)
Expand Down
34 changes: 18 additions & 16 deletions src/MIDebugEngine/AD7.Impl/AD7MemoryAddress.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,16 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.VisualStudio.Debugger.Interop;
using MICore;
using Microsoft.MIDebugEngine.Natvis;

namespace Microsoft.MIDebugEngine
{
// And implementation of IDebugCodeContext2 and IDebugMemoryContext2.
// IDebugMemoryContext2 represents a position in the address space of the machine running the program being debugged.
// IDebugCodeContext2 represents the starting position of a code instruction.
// For most run-time architectures today, a code context can be thought of as an address in a program's execution stream.
internal class AD7MemoryAddress : IDebugCodeContext2
internal sealed class AD7MemoryAddress : IDebugCodeContext2
{
private readonly AD7Engine _engine;
private readonly ulong _address;
Expand Down Expand Up @@ -42,6 +39,9 @@ public void SetDocumentContext(IDebugDocumentContext2 docContext)
// Adds a specified value to the current context's address to create a new context.
public int Add(ulong dwCount, out IDebugMemoryContext2 newAddress)
{
// NB: this is not correct for IDebugCodeContext2 according to the docs
// https://docs.microsoft.com/en-us/visualstudio/extensibility/debugger/reference/idebugcodecontext2#remarks
// But it's not used in practice (instead: IDebugDisassemblyStream2.Seek)
newAddress = new AD7MemoryAddress(_engine, (uint)dwCount + _address, null);
return Constants.S_OK;
}
Expand Down Expand Up @@ -160,19 +160,22 @@ public int GetInfo(enum_CONTEXT_INFO_FIELDS dwFields, CONTEXT_INFO[] pinfo)
{
pinfo[0].dwFields = 0;

if ((dwFields & enum_CONTEXT_INFO_FIELDS.CIF_ADDRESS) != 0)
if ((dwFields & (enum_CONTEXT_INFO_FIELDS.CIF_ADDRESS | enum_CONTEXT_INFO_FIELDS.CIF_ADDRESSABSOLUTE)) != 0)
{
pinfo[0].bstrAddress = EngineUtils.AsAddr(_address, _engine.DebuggedProcess.Is64BitArch);
pinfo[0].dwFields |= enum_CONTEXT_INFO_FIELDS.CIF_ADDRESS;
string addr = EngineUtils.AsAddr(_address, _engine.DebuggedProcess.Is64BitArch);
if ((dwFields & enum_CONTEXT_INFO_FIELDS.CIF_ADDRESS) != 0)
{
pinfo[0].bstrAddress = addr;
pinfo[0].dwFields |= enum_CONTEXT_INFO_FIELDS.CIF_ADDRESS;
}
if ((dwFields & enum_CONTEXT_INFO_FIELDS.CIF_ADDRESSABSOLUTE) != 0)
{
pinfo[0].bstrAddressAbsolute = addr;
pinfo[0].dwFields |= enum_CONTEXT_INFO_FIELDS.CIF_ADDRESSABSOLUTE;
}
}

// Fields not supported by the sample
if ((dwFields & enum_CONTEXT_INFO_FIELDS.CIF_ADDRESSOFFSET) != 0) { }
if ((dwFields & enum_CONTEXT_INFO_FIELDS.CIF_ADDRESSABSOLUTE) != 0)
{
pinfo[0].bstrAddressAbsolute = EngineUtils.AsAddr(_address, _engine.DebuggedProcess.Is64BitArch);
pinfo[0].dwFields |= enum_CONTEXT_INFO_FIELDS.CIF_ADDRESSABSOLUTE;
}
if ((dwFields & enum_CONTEXT_INFO_FIELDS.CIF_MODULEURL) != 0)
{
DebuggedModule module = _engine.DebuggedProcess.ResolveAddress(_address);
Expand All @@ -195,7 +198,6 @@ public int GetInfo(enum_CONTEXT_INFO_FIELDS dwFields, CONTEXT_INFO[] pinfo)
pinfo[0].dwFields |= enum_CONTEXT_INFO_FIELDS.CIF_FUNCTION;
}
}
if ((dwFields & enum_CONTEXT_INFO_FIELDS.CIF_FUNCTIONOFFSET) != 0) { }

return Constants.S_OK;
}
Expand All @@ -210,10 +212,10 @@ public int GetInfo(enum_CONTEXT_INFO_FIELDS dwFields, CONTEXT_INFO[] pinfo)
}

// Gets the user-displayable name for this context
// This is not supported by the sample engine.
public int GetName(out string pbstrName)
{
throw new NotImplementedException();
pbstrName = _functionName ?? Engine.GetAddressDescription(_address);
return Constants.S_OK;
}

// Subtracts a specified value from the current context's address to create a new context.
Expand Down
8 changes: 2 additions & 6 deletions src/MIDebugEngine/AD7.Impl/AD7StackFrame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace Microsoft.MIDebugEngine
{
// Represents a logical stack frame on the thread stack.
// Also implements the IDebugExpressionContext interface, which allows expression evaluation and watch windows.
internal class AD7StackFrame : IDebugStackFrame2, IDebugExpressionContext2
internal sealed class AD7StackFrame : IDebugStackFrame2, IDebugExpressionContext2
{
public AD7Engine Engine { get; private set; }
public AD7Thread Thread { get; private set; }
Expand Down Expand Up @@ -53,11 +53,7 @@ public AD7StackFrame(AD7Engine engine, AD7Thread thread, ThreadContext threadCon
if (_textPosition != null)
{
_documentCxt = new AD7DocumentContext(_textPosition, _codeCxt);

if (_codeCxt != null)
{
_codeCxt.SetDocumentContext(_documentCxt);
}
_codeCxt?.SetDocumentContext(_documentCxt);
}
}

Expand Down
19 changes: 15 additions & 4 deletions src/MIDebugPackage/OpenFolderSchema.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,14 @@
"type": "object",
"description": "Optional source file mappings passed to the debug engine. Format: '{ \"<Compiler source location>\": \"<Editor source location>\" }' OR '{ \"<Compiler source location>\": { \"editorPath\": \"<Editor source location>\", \"useForBreakpoints\": true } }'. \nExample: '{ \"/home/user/foo\": \"C:\\foo\" }' OR '{ \"/home/user/foo\": { \"editorPath\": \"c:\\foo\", \"useForBreakpoints\": true } }'.",
"additionalProperties": {
"anyOf": {
"type": "string",
"$ref": "#/definitions/cpp_schema/definitions/sourceFileMapOptions"
}
"anyOf": [
{
"type": "string"
},
{
"$ref": "#/definitions/cpp_schema/definitions/sourceFileMapOptions"
}
]
}
},
"MIMode": {
Expand Down Expand Up @@ -205,6 +209,13 @@
"type": "string"
}
},
"pipeCmd": {
"type": "array",
"description": "Arguments passed to the pipe executable to run a remote Unix (ex: bash or similar) shell command. This is used for running 'kill' on the remote system, or other commands that the debugger may need. If not specified, the debugger will do its best without the shell. But some features, such as setting breakpoints in run mode, may not work. This string should contain the string '{0}' which will be replaced with the command to execute.",
"items": {
"type": "string"
}
},
"debuggerPath": {
"type": "string",
"description": "The full path to the debugger on the target machine, for example /usr/bin/gdb."
Expand Down
Loading

0 comments on commit 102f979

Please sign in to comment.