Skip to content

Commit e83b4b5

Browse files
author
Rakesh Ganesh
authored
Merge branch 'main' into Introduce-New-Options
2 parents a90c822 + f530168 commit e83b4b5

4 files changed

Lines changed: 81 additions & 10 deletions

File tree

src/MICore/CommandFactories/MICommandFactory.cs

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,17 @@ public enum ExceptionBreakpointStates
3535
BreakThrown = 0x2
3636
}
3737

38+
/// <summary>
39+
/// The signals that are using for async-break.
40+
/// None will be used for no signal or signals that are not listed in the enum
41+
/// </summary>
42+
public enum AsyncBreakSignal
43+
{
44+
None = 0,
45+
SIGTRAP = 2,
46+
SIGINT = 5
47+
}
48+
3849
public abstract class MICommandFactory
3950
{
4051
protected Debugger _debugger;
@@ -664,19 +675,22 @@ public virtual bool SupportsFrameFormatting
664675
get { return false; }
665676
}
666677

667-
public virtual bool IsAsyncBreakSignal(Results results)
678+
public virtual AsyncBreakSignal GetAsyncBreakSignal(Results results)
668679
{
669-
bool isAsyncBreak = false;
670-
671680
if (results.TryFindString("reason") == "signal-received")
672681
{
673-
if (results.TryFindString("signal-name") == "SIGTRAP")
682+
string signalName = results.TryFindString("signal-name");
683+
if (signalName == "SIGTRAP")
684+
{
685+
return MICore.AsyncBreakSignal.SIGTRAP;
686+
}
687+
else if (signalName == "SIGINT")
674688
{
675-
isAsyncBreak = true;
689+
return MICore.AsyncBreakSignal.SIGINT;
676690
}
677691
}
678692

679-
return isAsyncBreak;
693+
return MICore.AsyncBreakSignal.None;
680694
}
681695

682696
public Results IsModuleLoad(string cmd)

src/MICore/Debugger.cs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -283,8 +283,9 @@ private async void OnStopped(Results results)
283283
results = results.Add("frame", frameResult.Find("frame"));
284284
}
285285

286-
bool fIsAsyncBreak = MICommandFactory.IsAsyncBreakSignal(results);
287-
if (await DoInternalBreakActions(fIsAsyncBreak))
286+
AsyncBreakSignal signal = MICommandFactory.GetAsyncBreakSignal(results);
287+
bool isAsyncBreak = signal == AsyncBreakSignal.SIGTRAP || (IsUsingExecInterrupt && signal == AsyncBreakSignal.SIGINT);
288+
if (await DoInternalBreakActions(isAsyncBreak))
288289
{
289290
return;
290291
}
@@ -409,6 +410,8 @@ private async Task<bool> DoInternalBreakActions(bool fIsAsyncBreak)
409410
{
410411
CmdContinueAsync();
411412
processContinued = true;
413+
// Reset since this -exec-interrupt was for an internal breakpoint.
414+
IsUsingExecInterrupt = false;
412415
}
413416

414417
if (firstException != null)
@@ -591,7 +594,7 @@ internal bool IsLocalGdbTarget()
591594
_launchOptions is LocalLaunchOptions && !IsLocalLaunchUsingServer());
592595
}
593596

594-
private bool IsRemoteGdbTarget()
597+
internal bool IsRemoteGdbTarget()
595598
{
596599
return MICommandFactory.Mode == MIMode.Gdb &&
597600
(_launchOptions is PipeLaunchOptions || _launchOptions is UnixShellPortLaunchOptions ||
@@ -606,6 +609,11 @@ protected bool IsCoreDump
606609
}
607610
}
608611

612+
/// <summary>
613+
/// Flag to indicate that '-exec-interrupt' was used for async-break scenarios.
614+
/// </summary>
615+
public bool IsUsingExecInterrupt { get; protected set; } = false;
616+
609617
public async Task<Results> CmdTerminate()
610618
{
611619
if (!_terminating)
@@ -749,6 +757,7 @@ public Task CmdBreakInternal()
749757
}
750758
}
751759

760+
IsUsingExecInterrupt = true;
752761
var res = CmdAsync("-exec-interrupt", ResultClass.done);
753762
return res.ContinueWith((t) =>
754763
{

src/MIDebugEngine/Engine.Impl/DebuggedProcess.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1332,14 +1332,18 @@ private async Task HandleBreakModeEvent(ResultEventArgs results, BreakRequest br
13321332
else if (reason == "signal-received")
13331333
{
13341334
string name = results.Results.TryFindString("signal-name");
1335+
AsyncBreakSignal signal = MICommandFactory.GetAsyncBreakSignal(results.Results);
1336+
bool isAsyncBreak = signal == AsyncBreakSignal.SIGTRAP || (IsUsingExecInterrupt && signal == AsyncBreakSignal.SIGINT);
13351337
if ((name == "SIG32") || (name == "SIG33"))
13361338
{
13371339
// we are going to ignore these (Sigma) signals for now
13381340
CmdContinueAsyncConditional(breakRequest);
13391341
}
1340-
else if (MICommandFactory.IsAsyncBreakSignal(results.Results))
1342+
else if (isAsyncBreak)
13411343
{
13421344
_callback.OnAsyncBreakComplete(thread);
1345+
// Reset flag for real async break
1346+
IsUsingExecInterrupt = false;
13431347
}
13441348
else
13451349
{

src/OpenDebugAD7/AD7DebugSession.cs

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,35 @@ public AD7DebugSession(Stream debugAdapterStdIn, Stream debugAdapterStdOut, List
128128
m_dataBreakpoints = new Dictionary<string, IDebugPendingBreakpoint2>();
129129
m_exceptionBreakpoints = new List<string>();
130130
m_variableManager = new VariableManager();
131+
132+
//Register sendInvalidate request
133+
Protocol.RegisterRequestType<SendInvalidateRequest, SendInvalidateArguments>(r => this.HandleSendInvalidateRequestAsync(r));
134+
131135
}
132136

137+
private void HandleSendInvalidateRequestAsync(IRequestResponder<SendInvalidateArguments> responder)
138+
{
139+
InvalidatedEvent invalidated = new InvalidatedEvent();
140+
141+
// Setting the area and adding it to the result
142+
invalidated.Areas.Add(responder.Arguments.Areas);
143+
144+
// Setting the StackFrameId if passed (and the 'threadId' is ignored).
145+
if (null != responder.Arguments.StackFrameId)
146+
{
147+
invalidated.StackFrameId = responder.Arguments.StackFrameId;
148+
}
149+
150+
// Setting the ThreadId if passed
151+
else if (null != responder.Arguments.ThreadId)
152+
{
153+
invalidated.ThreadId = responder.Arguments.ThreadId;
154+
}
155+
156+
157+
Protocol.SendEvent(invalidated);
158+
159+
}
133160
#endregion
134161

135162
#region Utility
@@ -3874,4 +3901,21 @@ int IDebugSettingsCallback110.ShouldSuppressImplicitToStringCalls(out int pfSupp
38743901
}
38753902
}
38763903
}
3904+
3905+
internal class SendInvalidateRequest : DebugRequest<SendInvalidateArguments>
3906+
{
3907+
3908+
public SendInvalidateRequest(): base("sendInvalidate")
3909+
{
3910+
}
3911+
}
3912+
3913+
internal class SendInvalidateArguments : DebugRequestArguments
3914+
{
3915+
3916+
public InvalidatedAreas Areas { get; set; }
3917+
public int? ThreadId { get; set; }
3918+
public int? StackFrameId { get; set; }
3919+
3920+
}
38773921
}

0 commit comments

Comments
 (0)