Skip to content

Commit 7ece35b

Browse files
authored
Add configuration for handling of unknown breakpoints (#1351)
* Add configuration for handling of unknown breakpoints
1 parent 7983eaa commit 7ece35b

File tree

4 files changed

+55
-7
lines changed

4 files changed

+55
-7
lines changed

src/MICore/JsonLaunchOptions.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
using System.Collections.Generic;
66
using System.Diagnostics;
77
using System.Globalization;
8+
using System.Runtime.Serialization;
89
using Newtonsoft.Json;
10+
using Newtonsoft.Json.Converters;
911
using Newtonsoft.Json.Linq;
1012

1113
namespace MICore.Json.LaunchOptions
@@ -113,6 +115,12 @@ public abstract partial class BaseOptions
113115
/// </summary>
114116
[JsonProperty("hardwareBreakpoints", DefaultValueHandling = DefaultValueHandling.Ignore)]
115117
public HardwareBreakpointInfo HardwareBreakpointInfo { get; set; }
118+
119+
/// <summary>
120+
/// Controls how breakpoints set externally (usually via raw GDB commands) are handled when hit. "throw" acts as if an exception was thrown by the application and "stop" only pauses the debug session.
121+
/// </summary>
122+
[JsonProperty("unknownBreakpointHandling", DefaultValueHandling = DefaultValueHandling.Ignore)]
123+
public UnknownBreakpointHandling? UnknownBreakpointHandling { get; set; }
116124
}
117125

118126
public partial class AttachOptions : BaseOptions
@@ -265,6 +273,16 @@ public HardwareBreakpointInfo(bool require = false, int? limit = null)
265273
#endregion
266274
}
267275

276+
[JsonConverter(typeof(StringEnumConverter))]
277+
public enum UnknownBreakpointHandling
278+
{
279+
[EnumMember(Value = "throw")]
280+
Throw,
281+
282+
[EnumMember(Value = "stop")]
283+
Stop
284+
}
285+
268286
public partial class LaunchOptions : BaseOptions
269287
{
270288
#region Public Properties for Serialization

src/MICore/LaunchOptions.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
using Newtonsoft.Json;
2121
using Newtonsoft.Json.Linq;
2222
using System.Text;
23+
using MICore.Json.LaunchOptions;
2324

2425
namespace MICore
2526
{
@@ -1202,6 +1203,18 @@ public int HardwareBreakpointLimit
12021203
}
12031204
}
12041205

1206+
private UnknownBreakpointHandling _unknownBreakpointHandling;
1207+
1208+
public UnknownBreakpointHandling UnknownBreakpointHandling
1209+
{
1210+
get { return _unknownBreakpointHandling; }
1211+
set
1212+
{
1213+
VerifyCanModifyProperty(nameof(UnknownBreakpointHandling));
1214+
_unknownBreakpointHandling = value;
1215+
}
1216+
}
1217+
12051218
public string GetOptionsString()
12061219
{
12071220
try
@@ -1800,6 +1813,8 @@ protected void InitializeCommonOptions(Json.LaunchOptions.BaseOptions options)
18001813
{
18011814
throw new InvalidLaunchOptionsException(String.Format(CultureInfo.InvariantCulture, MICoreResources.Error_OptionNotSupported, nameof(options.HardwareBreakpointInfo.Require), nameof(MIMode.Lldb)));
18021815
}
1816+
1817+
this.UnknownBreakpointHandling = options.UnknownBreakpointHandling ?? UnknownBreakpointHandling.Throw;
18031818
}
18041819

18051820
protected void InitializeCommonOptions(Xml.LaunchOptions.BaseLaunchOptions source)

src/MIDebugEngine/Engine.Impl/DebuggedProcess.cs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1234,13 +1234,20 @@ private async Task HandleBreakModeEvent(ResultEventArgs results, BreakRequest br
12341234
}
12351235
else
12361236
{
1237-
// This is not one of our breakpoints, so stop with a message. Possibly it
1238-
// was set by the user via "-exec break ...", so display the available
1239-
// information.
1240-
string desc = String.Format(CultureInfo.CurrentCulture,
1241-
ResourceStrings.UnknownBreakpoint,
1242-
bkptno, addr);
1243-
_callback.OnException(thread, desc, "", 0);
1237+
// This is not one of our breakpoints. Possibly it was set by the user
1238+
// via "-exec break ...", so display the available information.
1239+
switch (_launchOptions.UnknownBreakpointHandling)
1240+
{
1241+
case MICore.Json.LaunchOptions.UnknownBreakpointHandling.Throw:
1242+
string desc = String.Format(CultureInfo.CurrentCulture,
1243+
ResourceStrings.UnknownBreakpoint,
1244+
bkptno, addr);
1245+
_callback.OnException(thread, desc, "", 0);
1246+
break;
1247+
case MICore.Json.LaunchOptions.UnknownBreakpointHandling.Stop:
1248+
_callback.OnBreakpoint(thread, new ReadOnlyCollection<object>(new AD7BoundBreakpoint[] { }));
1249+
break;
1250+
}
12441251
}
12451252
}
12461253
}

src/MIDebugPackage/OpenFolderSchema.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,14 @@
185185
},
186186
"hardwareBreakpoints": {
187187
"$ref": "#/definitions/cpp_schema/definitions/hardwareBreakpointsOptions"
188+
},
189+
"unknownBreakpointHandling": {
190+
"type": "string",
191+
"enum": [
192+
"throw",
193+
"stop"
194+
],
195+
"description": "Controls how breakpoints set externally (usually via raw GDB commands) are handled when hit.\nAllowed values are \"throw\", which acts as if an exception was thrown by the application, and \"stop\", which only pauses the debug session. The default value is \"throw\"."
188196
}
189197
},
190198
"definitions": {

0 commit comments

Comments
 (0)