-
Notifications
You must be signed in to change notification settings - Fork 225
Prepare for nullable reference types in MICore #1595
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -72,7 +72,7 @@ public bool IsClosed | |
| public uint MaxInstructionSize { get; private set; } | ||
| public bool Is64BitArch { get; private set; } | ||
| public CommandLock CommandLock { get { return _commandLock; } } | ||
| public MICommandFactory MICommandFactory { get; protected set; } | ||
| public MICommandFactory MICommandFactory { get; } | ||
| public Logger Logger { private set; get; } | ||
|
|
||
| [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] | ||
|
|
@@ -124,12 +124,12 @@ public StoppingEventArgs(Results results, BreakRequest asyncRequest = BreakReque | |
| } | ||
|
|
||
| private ITransport _transport; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are changes for |
||
| private CommandLock _commandLock = new CommandLock(); | ||
| private readonly CommandLock _commandLock = new CommandLock(); | ||
|
|
||
| /// <summary> | ||
| /// The last command we sent over the transport. This includes both the command name and arguments. | ||
| /// </summary> | ||
| private string _lastCommandText; | ||
| private string _lastCommandText = string.Empty; | ||
| private uint _lastCommandId; | ||
|
|
||
| /// <summary> | ||
|
|
@@ -169,6 +169,7 @@ public Debugger(LaunchOptions launchOptions, Logger logger) | |
| _debuggeePids = new Dictionary<string, int>(); | ||
| Logger = logger; | ||
| _miResults = new MIResults(logger); | ||
| MICommandFactory = MICommandFactory.GetInstance(launchOptions.DebuggerMIMode, this); | ||
| } | ||
|
|
||
| protected void SetDebuggerPid(int debuggerPid) | ||
|
|
@@ -392,7 +393,7 @@ private async Task<bool> DoInternalBreakActions(bool fIsAsyncBreak) | |
| } | ||
| catch (Exception e) when (ExceptionHelper.BeforeCatch(e, Logger, reportOnlyCorrupting: true)) | ||
| { | ||
| if (firstException != null) | ||
| if (firstException is null) | ||
| { | ||
| firstException = e; | ||
| } | ||
|
|
@@ -404,7 +405,7 @@ private async Task<bool> DoInternalBreakActions(bool fIsAsyncBreak) | |
| { | ||
| if (this.IsClosed) | ||
| { | ||
| source.TrySetException(new DebuggerDisposedException(_closeMessage)); | ||
| source.TrySetException(new DebuggerDisposedException(GetTargetProcessExitedReason())); | ||
| } | ||
| else | ||
| { | ||
|
|
@@ -524,7 +525,7 @@ private void Close(string closeMessage) | |
| Debug.Assert(_closeMessage == null, "Why was Close called more than once? Should be impossible."); | ||
|
|
||
| _closeMessage = closeMessage; | ||
| _transport.Close(); | ||
| _transport?.Close(); | ||
| lock (_waitingOperations) | ||
| { | ||
| foreach (var value in _waitingOperations.Values) | ||
|
|
@@ -905,7 +906,7 @@ private Task<Results> CmdAsyncInternal(string command, ResultClass expectedResul | |
| { | ||
| if (this.IsClosed) | ||
| { | ||
| throw new DebuggerDisposedException(_closeMessage); | ||
| throw new DebuggerDisposedException(GetTargetProcessExitedReason()); | ||
| } | ||
|
|
||
| id = ++_lastCommandId; | ||
|
|
@@ -992,13 +993,13 @@ public void OnDebuggerProcessExit(/*OPTIONAL*/ string exitCode) | |
| if (isMinGWOrCygwin && IsUnsupportedWindowsGdbVersion(_gdbVersion)) | ||
| { | ||
| exception = new MIDebuggerInitializeFailedUnsupportedGdbException( | ||
| this.MICommandFactory.Name, _initialErrors.ToList().AsReadOnly(), _initializationLog.ToList().AsReadOnly(), _gdbVersion); | ||
| this.MICommandFactory.Name, (_initialErrors?.ToList() ?? new List<string>()).AsReadOnly(), (_initializationLog?.ToList() ?? new List<string>()).AsReadOnly(), _gdbVersion); | ||
| SendUnsupportedWindowsGdbEvent(_gdbVersion); | ||
| } | ||
| else | ||
| { | ||
| exception = new MIDebuggerInitializeFailedException( | ||
| this.MICommandFactory.Name, _initialErrors.ToList().AsReadOnly(), _initializationLog.ToList().AsReadOnly()); | ||
| this.MICommandFactory.Name, (_initialErrors?.ToList() ?? new List<string>()).AsReadOnly(), (_initializationLog?.ToList() ?? new List<string>()).AsReadOnly()); | ||
| } | ||
|
|
||
| _initialErrors = null; | ||
|
|
@@ -1029,7 +1030,7 @@ public void OnDebuggerProcessExit(/*OPTIONAL*/ string exitCode) | |
| { | ||
| if (DebuggerExitEvent != null) | ||
| { | ||
| DebuggerExitEvent(this, null); | ||
| DebuggerExitEvent(this, EventArgs.Empty); | ||
| } | ||
| } | ||
| } | ||
|
|
@@ -1419,8 +1420,7 @@ this.LaunchOptions is LocalLaunchOptions && | |
|
|
||
| private void OnNotificationOutput(string cmd) | ||
| { | ||
| Results results = null; | ||
| if ((results = MICommandFactory.IsModuleLoad(cmd)) != null) | ||
| if (MICommandFactory.IsModuleLoad(cmd) is Results results) | ||
| { | ||
| if (LibraryLoadEvent != null) | ||
| { | ||
|
|
@@ -1460,12 +1460,12 @@ private void OnNotificationOutput(string cmd) | |
| else if (cmd.StartsWith("thread-created,", StringComparison.Ordinal)) | ||
| { | ||
| results = _miResults.ParseResultList(cmd.Substring("thread-created,".Length)); | ||
| ThreadCreatedEvent(this, new ResultEventArgs(results, 0)); | ||
| ThreadCreatedEvent?.Invoke(this, new ResultEventArgs(results, 0)); | ||
| } | ||
| else if (cmd.StartsWith("thread-exited,", StringComparison.Ordinal)) | ||
| { | ||
| results = _miResults.ParseResultList(cmd.Substring("thread-exited,".Length)); | ||
| ThreadExitedEvent(this, new ResultEventArgs(results, 0)); | ||
| ThreadExitedEvent?.Invoke(this, new ResultEventArgs(results, 0)); | ||
| } | ||
| else if (cmd.StartsWith("telemetry,", StringComparison.Ordinal)) | ||
| { | ||
|
|
@@ -1619,14 +1619,15 @@ private async void PostCommand(string cmd) | |
|
|
||
| private void SendToTransport(string cmd) | ||
| { | ||
| _transport.Send(cmd); | ||
| ITransport transport = _transport ?? throw new InvalidOperationException(); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this going to cause a crash if we get called via |
||
| transport.Send(cmd); | ||
|
gregg-miskelly marked this conversation as resolved.
|
||
|
|
||
| // https://github.com/Microsoft/MIEngine/issues/616 : | ||
| // If it is local gdb (MinGW/Cygwin) on Windows, we need to send an extra line after commands | ||
| // so that if it errors, the error will come through. | ||
| if (this.SendNewLineAfterCmd) | ||
| { | ||
| _transport.Send(String.Empty); | ||
| transport.Send(String.Empty); | ||
| } | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.