Skip to content

Commit

Permalink
Fix for GDB 13 "script" field in breakpoint
Browse files Browse the repository at this point in the history
"script" field of a breakpoint used to be output as a tuple (<= GDB 12),
though it is a list. There are cases of flags that can be applied to
get old or new behaviour too.
This code handles both cases transparently.
See https://sourceware.org/bugzilla/show_bug.cgi?id=24285

Part of eclipse-cdt#816
  • Loading branch information
jonahgraham committed Jan 23, 2025
1 parent be5037f commit 1afe51b
Showing 1 changed file with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -626,8 +626,8 @@ void parse(MITuple tuple) {
// Only supported starting with GDB 6.8
pending = true;
} else if (var.equals("script")) { //$NON-NLS-1$
if (value instanceof MITuple) {
parseCommands((MITuple) value);
if (value instanceof MITuple || value instanceof MIList) {
parseCommands(value);
}
} else if (var.equals("thread-groups")) { //$NON-NLS-1$
if (value instanceof MIList) {
Expand All @@ -639,8 +639,20 @@ void parse(MITuple tuple) {
}
}

void parseCommands(MITuple tuple) {
MIValue[] values = tuple.getMIValues();
void parseCommands(MIValue miValue) {
// "script" field of a breakpoint used to be output as a tuple (<= GDB 12),
// though it is a list. There are cases of flags that can be applied to
// get old or new behaviour too.
// This code handles both cases transparently.
// See https://sourceware.org/bugzilla/show_bug.cgi?id=24285
MIValue[] values;
if (miValue instanceof MITuple tuple) {
values = tuple.getMIValues();
} else if (miValue instanceof MIList list) {
values = list.getMIValues();
} else {
throw new IllegalStateException("miValue must be tuple or list"); //$NON-NLS-1$
}
StringBuilder cmds = new StringBuilder();
for (int i = 0; i < values.length; i++) {
MIValue value = values[i];
Expand Down

0 comments on commit 1afe51b

Please sign in to comment.