Skip to content

Commit

Permalink
Improve messages for unknown breakpoints and watchpoints. (#1282) (#1283
Browse files Browse the repository at this point in the history
)

The C/C++ extension does not support all the features of GDB
breakpoints and watchpoints, so users may need to set breakpoints via
"-exec break ..." in the DEBUG CONSOLE, and similarly for watchpoints
via "-exec watch ...". When these are hit, include the available
information in the exception message.
  • Loading branch information
gareth-rees authored Mar 4, 2022
1 parent 4029844 commit de8db64
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 4 deletions.
45 changes: 41 additions & 4 deletions src/MIDebugEngine/Engine.Impl/DebuggedProcess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1234,8 +1234,13 @@ private async Task HandleBreakModeEvent(ResultEventArgs results, BreakRequest br
}
else
{
// not one of our breakpoints, so stop with a message
_callback.OnException(thread, "Unknown breakpoint", "", 0);
// This is not one of our breakpoints, so stop with a message. Possibly it
// was set by the user via "-exec break ...", so display the available
// information.
string desc = String.Format(CultureInfo.CurrentCulture,
ResourceStrings.UnknownBreakpoint,
bkptno, addr);
_callback.OnException(thread, desc, "", 0);
}
}
}
Expand Down Expand Up @@ -1263,8 +1268,40 @@ private async Task HandleBreakModeEvent(ResultEventArgs results, BreakRequest br
}
else
{
// not one of our breakpoints, so stop with a message
_callback.OnException(thread, "Unknown watchpoint", "", 0);
// This is not one of our watchpoints, so stop with a message. Possibly it
// was set by the user via "-exec watch ...", so display the available
// information.
string desc = string.Empty;
string exp = wpt.TryFindString("exp");
if (string.IsNullOrEmpty(exp)) {
desc = String.Format(CultureInfo.CurrentCulture,
ResourceStrings.UnknownWatchpoint,
bkptno, addr);
}
else
{
desc = String.Format(CultureInfo.CurrentCulture,
ResourceStrings.UnknownWatchpointWithExpression,
bkptno, exp, addr);
}
var value = results.Results.TryFind<TupleValue>("value");
if (value != null) {
string oldValue = value.TryFindString("old");
if (!string.IsNullOrEmpty(oldValue)) {
desc += "\n";
desc += String.Format(CultureInfo.CurrentCulture,
ResourceStrings.UnknownWatchpointOldValue,
oldValue);
}
string newValue = value.TryFindString("new");
if (!string.IsNullOrEmpty(newValue)) {
desc += "\n";
desc += String.Format(CultureInfo.CurrentCulture,
ResourceStrings.UnknownWatchpointNewValue,
newValue);
}
}
_callback.OnException(thread, desc, "", 0);
}
}
}
Expand Down
45 changes: 45 additions & 0 deletions src/MIDebugEngine/ResourceStrings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions src/MIDebugEngine/ResourceStrings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -270,4 +270,24 @@ See https://aka.ms/miengine-gdb-troubleshooting for details.</value>
<value>Exception{0} thrown at 0x{1:X} in {2}.</value>
<comment>0 = optional exception name, 1 = address, 2 = exception file</comment>
</data>
<data name="UnknownBreakpoint" xml:space="preserve">
<value>Hit breakpoint {0} at 0x{1:x}.</value>
<comment>0 = breakpoint number, 1 = address</comment>
</data>
<data name="UnknownWatchpoint" xml:space="preserve">
<value>Hit watchpoint {0} at 0x{1:x}.</value>
<comment>0 = watchpoint number, 1 = address</comment>
</data>
<data name="UnknownWatchpointWithExpression" xml:space="preserve">
<value>Hit watchpoint {0}: {1} at 0x{2:x}.</value>
<comment>0 = watchpoint number, 1 = expression, 2 = address</comment>
</data>
<data name="UnknownWatchpointOldValue" xml:space="preserve">
<value>Old value = {0}</value>
<comment>0 = old value of watchpoint</comment>
</data>
<data name="UnknownWatchpointNewValue" xml:space="preserve">
<value>New value = {0}</value>
<comment>0 = new value of watchpoint</comment>
</data>
</root>

0 comments on commit de8db64

Please sign in to comment.