Skip to content

Commit

Permalink
Merge pull request #1376 from microsoft/main
Browse files Browse the repository at this point in the history
Merge main into 'release-cpptools' for v1.13.5
  • Loading branch information
WardenGnaw committed Nov 17, 2022
2 parents e5ef4f7 + cf94006 commit ecb1165
Show file tree
Hide file tree
Showing 10 changed files with 1,294 additions and 1,515 deletions.
9 changes: 4 additions & 5 deletions src/MICore/CommandFactories/MICommandFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ public virtual IEnumerable<Guid> GetSupportedExceptionCategories()
/// exceptions in the category. Note that this clear all previous exception breakpoints set in this category.</param>
/// <param name="exceptionBreakpointState">Indicates when the exception breakpoint should fire</param>
/// <returns>Task containing the exception breakpoint id's for the various set exceptions</returns>
public virtual Task<IEnumerable<ulong>> SetExceptionBreakpoints(Guid exceptionCategory, /*OPTIONAL*/ IEnumerable<string> exceptionNames, ExceptionBreakpointStates exceptionBreakpointState)
public virtual Task<IEnumerable<long>> SetExceptionBreakpoints(Guid exceptionCategory, /*OPTIONAL*/ IEnumerable<string> exceptionNames, ExceptionBreakpointStates exceptionBreakpointState)
{
// NOTES:
// GDB /MI has no support for exceptions. Though they do have it through the non-MI through a 'catch' command. Example:
Expand All @@ -573,7 +573,7 @@ public virtual Task<IEnumerable<ulong>> SetExceptionBreakpoints(Guid exceptionCa
throw new NotImplementedException();
}

public virtual Task RemoveExceptionBreakpoint(Guid exceptionCategory, IEnumerable<ulong> exceptionBreakpoints)
public virtual Task RemoveExceptionBreakpoint(Guid exceptionCategory, IEnumerable<long> exceptionBreakpoints)
{
throw new NotImplementedException();
}
Expand Down Expand Up @@ -658,8 +658,7 @@ public virtual bool IsAsyncBreakSignal(Results results)

if (results.TryFindString("reason") == "signal-received")
{
if (results.TryFindString("signal-name") == "SIGINT" ||
results.TryFindString("signal-name") == "SIGTRAP")
if (results.TryFindString("signal-name") == "SIGTRAP")
{
isAsyncBreak = true;
}
Expand Down Expand Up @@ -700,4 +699,4 @@ public virtual bool SupportsBreakpointChecksums()
}
#endregion
}
}
}
8 changes: 4 additions & 4 deletions src/MICore/CommandFactories/gdb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -310,11 +310,11 @@ public override IEnumerable<Guid> GetSupportedExceptionCategories()
return new Guid[] { new Guid(CppExceptionCategoryString) };
}

public override async Task<IEnumerable<ulong>> SetExceptionBreakpoints(Guid exceptionCategory, IEnumerable<string> exceptionNames, ExceptionBreakpointStates exceptionBreakpointStates)
public override async Task<IEnumerable<long>> SetExceptionBreakpoints(Guid exceptionCategory, IEnumerable<string> exceptionNames, ExceptionBreakpointStates exceptionBreakpointStates)
{
string command;
Results result;
List<ulong> breakpointNumbers = new List<ulong>();
List<long> breakpointNumbers = new List<long>();

if (exceptionNames == null) // set breakpoint for all exceptions in exceptionCategory
{
Expand Down Expand Up @@ -353,9 +353,9 @@ public override async Task<IEnumerable<ulong>> SetExceptionBreakpoints(Guid exce
return breakpointNumbers;
}

public override async Task RemoveExceptionBreakpoint(Guid exceptionCategory, IEnumerable<ulong> exceptionBreakpoints)
public override async Task RemoveExceptionBreakpoint(Guid exceptionCategory, IEnumerable<long> exceptionBreakpoints)
{
foreach (ulong breakpointNumber in exceptionBreakpoints)
foreach (long breakpointNumber in exceptionBreakpoints)
{
await BreakDelete(breakpointNumber.ToString(CultureInfo.InvariantCulture));
}
Expand Down
3 changes: 3 additions & 0 deletions src/MICore/Debugger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -784,6 +784,9 @@ private string Escape(string str)
case '\\':
outStr.Append("\\\\");
break;
case '\n':
outStr.Append("\\n");
break;
default:
outStr.Append(str[i]);
break;
Expand Down
2 changes: 1 addition & 1 deletion src/MICore/UnixUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ internal static void Interrupt(int pid)

private static void Kill(int pid, int signal)
{
var k = Process.Start("/bin/kill", String.Format(CultureInfo.InvariantCulture, "-{0} {1}", signal, pid));
var k = Process.Start("kill", String.Format(CultureInfo.InvariantCulture, "-{0} {1}", signal, pid));
k.WaitForExit();
}
}
Expand Down
20 changes: 10 additions & 10 deletions src/MIDebugEngine/Engine.Impl/ExceptionManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ private class ExceptionCategorySettings
// 1. Writes and reads when *NOT* on the FlushSettingsUpdates thread - collection should be locked on itself
// 2. Reads on the FlushSettingsUpdates thread - no locking is needed
public ExceptionBreakpointStates CategoryState;
public readonly Dictionary<string, ulong> CurrentRules = new Dictionary<string, ulong>();
public readonly Dictionary<string, long> CurrentRules = new Dictionary<string, long>();

private readonly object _updateLock = new object();
/*OPTIONAL*/
Expand Down Expand Up @@ -302,7 +302,7 @@ public bool TryGetExceptionBreakpoint(string bkptno, ulong address, TupleValue f
ExceptionCategorySettings categorySettings;
if (_categoryMap.TryGetValue(CppExceptionCategoryGuid, out categorySettings))
{
ulong breakpointNumber = Convert.ToUInt32(bkptno, CultureInfo.InvariantCulture);
long breakpointNumber = Convert.ToInt32(bkptno, CultureInfo.InvariantCulture);
lock (categorySettings.CurrentRules)
{
exceptionName = categorySettings.CurrentRules.FirstOrDefault(pair => pair.Value == breakpointNumber).Key;
Expand Down Expand Up @@ -511,8 +511,8 @@ private async Task UpdateCategory(Guid categoryId, ExceptionCategorySettings cat
{
try
{
IEnumerable<ulong> breakpointIds = await _commandFactory.SetExceptionBreakpoints(categoryId, null, newCategoryState);
ulong breakpointId = breakpointIds.Single();
IEnumerable<long> breakpointIds = await _commandFactory.SetExceptionBreakpoints(categoryId, null, newCategoryState);
long breakpointId = breakpointIds.Single();
lock (categorySettings.CurrentRules)
{
categorySettings.CurrentRules.Add("*", breakpointId);
Expand All @@ -531,12 +531,12 @@ private async Task UpdateCategory(Guid categoryId, ExceptionCategorySettings cat
if (updates.RulesToRemove.Count > 0)
{
// Detach these exceptions from 'CurrentRules'
List<ulong> breakpointsToRemove = new List<ulong>();
List<long> breakpointsToRemove = new List<long>();
lock (categorySettings.CurrentRules)
{
foreach (string exceptionToRemove in updates.RulesToRemove)
{
ulong breakpointId;
long breakpointId;
if (!categorySettings.CurrentRules.TryGetValue(exceptionToRemove, out breakpointId))
continue;

Expand Down Expand Up @@ -575,7 +575,7 @@ private async Task UpdateCategory(Guid categoryId, ExceptionCategorySettings cat
{
try
{
IEnumerable<ulong> breakpointIds = await _commandFactory.SetExceptionBreakpoints(categoryId, exceptionNames, grouping.Key);
IEnumerable<long> breakpointIds = await _commandFactory.SetExceptionBreakpoints(categoryId, exceptionNames, grouping.Key);

lock (categorySettings.CurrentRules)
{
Expand All @@ -584,7 +584,7 @@ private async Task UpdateCategory(Guid categoryId, ExceptionCategorySettings cat
// remove old breakpoint if exceptionName is in categorySettings.CurrentRules.Keys
if (categorySettings.CurrentRules.ContainsKey(exceptionName))
{
_commandFactory.RemoveExceptionBreakpoint(categoryId, new ulong[] { categorySettings.CurrentRules[exceptionName] });
_commandFactory.RemoveExceptionBreakpoint(categoryId, new long[] { categorySettings.CurrentRules[exceptionName] });
}
categorySettings.CurrentRules[exceptionName] = breakpointId;
return 1;
Expand All @@ -609,15 +609,15 @@ private async Task UpdateCategory(Guid categoryId, ExceptionCategorySettings cat
}
if (!isBreakThrown)
{
ulong breakpointId;
long breakpointId;
lock (categorySettings.CurrentRules)
{
foreach (string exceptionName in exceptionNames)
{
if (!categorySettings.CurrentRules.TryGetValue(exceptionName, out breakpointId))
continue;

_commandFactory.RemoveExceptionBreakpoint(categoryId, new ulong[] { breakpointId });
_commandFactory.RemoveExceptionBreakpoint(categoryId, new long[] { breakpointId });
categorySettings.CurrentRules.Remove(exceptionName);
}
}
Expand Down
Loading

0 comments on commit ecb1165

Please sign in to comment.