Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/MICore/Checksum.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ public enum MIHashAlgorithmName

public class Checksum
{
private string _checksumString = null;
private byte[] _bytes = null;
private string? _checksumString = null;
private byte[] _bytes;

public readonly MIHashAlgorithmName MIHashAlgorithmName;

Expand Down
17 changes: 8 additions & 9 deletions src/MICore/CommandFactories/MICommandFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading.Tasks;
using System.IO;
using System.Text;
Expand Down Expand Up @@ -48,7 +47,7 @@ public enum AsyncBreakSignal

public abstract class MICommandFactory
{
protected Debugger _debugger;
protected Debugger _debugger = null!;

public MIMode Mode { get; private set; }

Expand Down Expand Up @@ -77,7 +76,7 @@ public static MICommandFactory GetInstance(MIMode mode, Debugger debugger)
return commandFactory;
}

public static string SpanNextAddr(string line, out ulong addr)
public static string? SpanNextAddr(string line, out ulong addr)
{
addr = 0;
char[] endOfNum = { ' ', '\t', '\"' };
Expand Down Expand Up @@ -479,7 +478,7 @@ internal bool PreparePath(string path, bool useUnixFormat, out string pathMI)
return requiresQuotes;
}

public virtual async Task<Results> BreakInsert(string filename, bool useUnixFormat, uint line, string condition, bool enabled, IEnumerable<Checksum> checksums = null, ResultClass resultClass = ResultClass.done)
public virtual async Task<Results> BreakInsert(string filename, bool useUnixFormat, uint line, string condition, bool enabled, IEnumerable<Checksum>? checksums = null, ResultClass resultClass = ResultClass.done)
{
StringBuilder cmd = await BuildBreakInsert(condition, enabled);

Expand Down Expand Up @@ -529,7 +528,7 @@ public virtual Task<Results> BreakWatch(string address, uint size, ResultClass r

public virtual bool SupportsDataBreakpoints { get { return false; } }

public virtual async Task<TupleValue> BreakInfo(string bkptno)
public virtual async Task<TupleValue?> BreakInfo(string bkptno)
{
Results bindResult = await _debugger.CmdAsync("-break-info " + bkptno, ResultClass.None);
if (bindResult.ResultClass != ResultClass.done)
Expand Down Expand Up @@ -559,7 +558,7 @@ public virtual async Task BreakDelete(string bkptno, ResultClass resultClass = R

public virtual async Task BreakCondition(string bkptno, string expr)
{
if (string.IsNullOrWhiteSpace(expr))
if (IsNullOrWhiteSpace(expr))
{
expr = string.Empty;
}
Expand Down Expand Up @@ -628,7 +627,7 @@ public virtual void DecodeExceptionReceivedProperties(Results miExceptionResult,

#region Miscellaneous

public virtual Task<string[]> AutoComplete(string command, int threadId, uint frameLevel)
public virtual Task<string[]?> AutoComplete(string command, int threadId, uint frameLevel)
{
throw new NotImplementedException();
}
Expand Down Expand Up @@ -704,9 +703,9 @@ public virtual AsyncBreakSignal GetAsyncBreakSignal(Results results)
return MICore.AsyncBreakSignal.None;
}

public Results IsModuleLoad(string cmd)
public Results? IsModuleLoad(string cmd)
{
Results results = null;
Results? results = null;
if (cmd.StartsWith("library-loaded,", StringComparison.Ordinal))
{
MIResults res = new MIResults(_debugger.Logger);
Expand Down
11 changes: 5 additions & 6 deletions src/MICore/CommandFactories/gdb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading.Tasks;
using System.IO;
using System.Text;
Expand Down Expand Up @@ -52,7 +51,7 @@ protected override async Task<Results> ThreadFrameCmdAsync(string command, strin
{
// first aquire an exclusive lock. This is used as we don't want to fight with other commands that also require the current
// thread to be set to a particular value
ExclusiveLockToken lockToken = await _debugger.CommandLock.AquireExclusive();
ExclusiveLockToken? lockToken = await _debugger.CommandLock.AquireExclusive();

try
{
Expand Down Expand Up @@ -98,7 +97,7 @@ protected override async Task<Results> ThreadCmdAsync(string command, string arg
{
// first aquire an exclusive lock. This is used as we don't want to fight with other commands that also require the current
// thread to be set to a particular value
ExclusiveLockToken lockToken = await _debugger.CommandLock.AquireExclusive();
ExclusiveLockToken? lockToken = await _debugger.CommandLock.AquireExclusive();

try
{
Expand Down Expand Up @@ -188,7 +187,7 @@ public override async Task<List<ulong>> StartAddressesForLine(string file, uint
{
while (true)
{
string resultLine = stringReader.ReadLine();
string? resultLine = stringReader.ReadLine();
if (resultLine == null)
break;

Expand Down Expand Up @@ -276,7 +275,7 @@ public override TargetArchitecture ParseTargetArchitectureResult(string result)
{
while (true)
{
string resultLine = stringReader.ReadLine();
string? resultLine = stringReader.ReadLine();
if (resultLine == null)
break;

Expand Down Expand Up @@ -322,7 +321,7 @@ public override async Task Catch(string name, bool onlyOnce = false, ResultClass
await _debugger.ConsoleCmdAsync(command + name, allowWhileRunning: false);
}

public override async Task<string[]> AutoComplete(string command, int threadId, uint frameLevel)
public override async Task<string[]?> AutoComplete(string command, int threadId, uint frameLevel)
{
string cmd = "-complete";
string args = $"\"{command}\"";
Expand Down
9 changes: 4 additions & 5 deletions src/MICore/CommandFactories/lldb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading.Tasks;
using System.IO;
using System.Text;
Expand Down Expand Up @@ -111,13 +110,13 @@ protected override async Task<Results> ThreadCmdAsync(string command, string arg

public override Task<List<ulong>> StartAddressesForLine(string file, uint line)
{
return Task.FromResult<List<ulong>>(null);
return Task.FromResult(new List<ulong>());
}

public override Task EnableTargetAsyncOption()
{
// lldb-mi doesn't support target-async mode, and doesn't seem to need to
return Task.FromResult((object)null);
return Task.FromResult<object?>(null);
}

public override string GetTargetArchitectureCommand()
Expand All @@ -131,7 +130,7 @@ public override TargetArchitecture ParseTargetArchitectureResult(string result)
{
while (true)
{
string resultLine = stringReader.ReadLine();
string? resultLine = stringReader.ReadLine();
if (resultLine == null)
break;

Expand Down Expand Up @@ -211,7 +210,7 @@ private async Task<bool> RequiresOnKeywordForBreakInsert()
{
// Query for the version.
string version = await Version();
if (!string.IsNullOrWhiteSpace(version) && version.Trim().Equals(OldLLDBMIVersionString, StringComparison.Ordinal))
if (!IsNullOrWhiteSpace(version) && version.Trim().Equals(OldLLDBMIVersionString, StringComparison.Ordinal))
{
_requiresOnKeywordForBreakInsert = true;
}
Expand Down
21 changes: 11 additions & 10 deletions src/MICore/CommandLock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading;
Expand All @@ -18,7 +17,7 @@ sealed public class ExclusiveLockToken : IDisposable
// NOTE: I tried to make this a value object, but value objects don't work quite as expected in async methods and calling 'Close'
// wasn't updating the backing value object which was stored in the state machine class
{
private CommandLock _commandLock;
private CommandLock? _commandLock;
private int _value;

internal ExclusiveLockToken(CommandLock commandLock, int value)
Expand All @@ -39,7 +38,7 @@ public static bool IsNullOrClosed(ExclusiveLockToken token)
return (token == null || token._value == 0);
}

public override bool Equals(object obj)
public override bool Equals(object? obj)
{
throw new NotImplementedException(); // this method should never be called
}
Expand All @@ -66,6 +65,7 @@ public void ConvertToSharedLock()
_value = 0;
_commandLock = null;

Debug.Assert(commandLock is not null, "Should be impossible. A non-zero _value implies _commandLock is set.");
commandLock.ConvertExclusiveLockToShared(value);
}

Expand All @@ -78,6 +78,7 @@ public void Close()
_value = 0;
_commandLock = null;

Debug.Assert(commandLock is not null, "Should be impossible. A non-zero _value implies _commandLock is set.");
commandLock.ReleaseExclusive(value);
}
}
Expand All @@ -99,9 +100,9 @@ sealed public class CommandLock

private int _prevExclusiveToken;
private int _pendingSharedLockRequests;
private TaskCompletionSource<int> _waitingSharedLockSource;
private TaskCompletionSource<int>? _waitingSharedLockSource;
private readonly Queue<TaskCompletionSource<ExclusiveLockToken>> _waitingExclusiveLockRequests = new Queue<TaskCompletionSource<ExclusiveLockToken>>();
private string _closeMessage;
private string _closeMessage = string.Empty;

public CommandLock()
{
Expand Down Expand Up @@ -184,7 +185,7 @@ public Task AquireShared()
// Internal method called from the ExclusiveLockToken class as part of closing an exclusive lock
internal void ReleaseExclusive(int tokenValue)
{
Action actionAfterReleaseLock = null;
Action? actionAfterReleaseLock = null;

lock (this.LockObject)
{
Expand Down Expand Up @@ -212,7 +213,7 @@ internal void ReleaseExclusive(int tokenValue)
// Internal method called from the ExclusiveLockToken class to convert an exclusive lock into a shared lock
internal void ConvertExclusiveLockToShared(int tokenValue)
{
Action actionAfterReleaseLock = null;
Action? actionAfterReleaseLock = null;

lock (this.LockObject)
{
Expand Down Expand Up @@ -240,7 +241,7 @@ internal void ConvertExclusiveLockToShared(int tokenValue)

public void ReleaseShared()
{
Action actionAfterReleaseLock = null;
Action? actionAfterReleaseLock = null;

lock (this.LockObject)
{
Expand Down Expand Up @@ -269,7 +270,7 @@ public void ReleaseShared()
}

// NOTE: This method MUST be called with this.LockObject held
private Action GetAfterReleaseLockAction()
private Action? GetAfterReleaseLockAction()
{
Debug.Assert(_lockStatus == StatusFree, "Why is GetAfterReleaseLockAction called when the lock is not free?");

Expand Down Expand Up @@ -298,7 +299,7 @@ private ExclusiveLockToken GetNextExclusiveLockToken()
}

// NOTE: This method MUST be called with this.LockObject held
private Action MaybeSignalPendingSharedLockRequests()
private Action? MaybeSignalPendingSharedLockRequests()
{
Debug.Assert(_lockStatus >= 0, "Why is MaybeGetSharedLockAction called when the lock is not free/reading?");

Expand Down
Loading
Loading