diff options
Diffstat (limited to 'dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/MIDPrintfInsert.java')
-rw-r--r-- | dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/MIDPrintfInsert.java | 176 |
1 files changed, 87 insertions, 89 deletions
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/MIDPrintfInsert.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/MIDPrintfInsert.java index d37a6d6a22f..78305277abc 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/MIDPrintfInsert.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/MIDPrintfInsert.java @@ -25,15 +25,15 @@ import org.eclipse.cdt.dsf.mi.service.command.output.MIOutput; /** * -dprintf-insert [ -t ] [ -f ] [ -d ] * [ -c CONDITION ] [ -i IGNORE-COUNT ] - * [ -p THREAD ] [ LOCATION ] [ FORMAT ] [ ARGUMENT ] - * + * [ -p THREAD ] [ LOCATION ] [ FORMAT ] [ ARGUMENT ] + * * If specified, LOCATION, can be one of: * * function * * filename:linenum * * filename:function * * *address - * - * + * + * * The possible optional parameters of this command are: * * '-t' @@ -46,115 +46,113 @@ import org.eclipse.cdt.dsf.mi.service.command.output.MIOutput; * Initialize the IGNORE-COUNT. * * '-f' - * If location cannot be parsed (for example if it refers to unknown files or + * If location cannot be parsed (for example if it refers to unknown files or * functions), create a pending dprintf. Without this flag, if a location * cannot be parsed, the dprintf will not be created and an error will be * reported. * * '-d' * Create a disabled dprintf. - * + * * '-p THREAD' * THREAD on which to apply the dprintf - * + * * Available with GDB 7.7. - * + * * @since 4.4 */ -public class MIDPrintfInsert extends MICommand<MIBreakInsertInfo> -{ - public MIDPrintfInsert(IBreakpointsTargetDMContext ctx, boolean isTemporary, - String condition, int ignoreCount, int tid, boolean disabled, - boolean allowPending, String location, String printfStr) { +public class MIDPrintfInsert extends MICommand<MIBreakInsertInfo> { + public MIDPrintfInsert(IBreakpointsTargetDMContext ctx, boolean isTemporary, String condition, int ignoreCount, + int tid, boolean disabled, boolean allowPending, String location, String printfStr) { super(ctx, "-dprintf-insert"); //$NON-NLS-1$ - // Determine the number of optional parameters that are present - // and allocate a corresponding string array - int i = 0; - if (isTemporary) { - i++; - } - if (condition != null && !condition.isEmpty()) { - i += 2; - } - if (ignoreCount > 0) { - i += 2; - } - if (tid > 0) { - i += 2; - } - if (disabled) { - i++; - } - if (allowPending) { - i ++; - } - - String[] opts = new String[i]; - - // Fill in the optional parameters - i = 0; - if (isTemporary) { - opts[i] = "-t"; //$NON-NLS-1$ - i++; - } - if (condition != null && !condition.isEmpty()) { - opts[i] = "-c"; //$NON-NLS-1$ - i++; - opts[i] = condition; - i++; - } - if (ignoreCount > 0) { - opts[i] = "-i"; //$NON-NLS-1$ - i++; - opts[i] = Integer.toString(ignoreCount); - i++; - } - if (tid > 0) { - opts[i] = "-p"; //$NON-NLS-1$ - i++; - opts[i] = Integer.toString(tid); - i++; - } - if (disabled) { - opts[i] = "-d"; //$NON-NLS-1$ - i++; - } - if (allowPending) { - opts[i] = "-f"; //$NON-NLS-1$ - i ++; - } - - if (opts.length > 0) { - setOptions(opts); - } - - setParameters(createParameters(location, printfStr)); - } + // Determine the number of optional parameters that are present + // and allocate a corresponding string array + int i = 0; + if (isTemporary) { + i++; + } + if (condition != null && !condition.isEmpty()) { + i += 2; + } + if (ignoreCount > 0) { + i += 2; + } + if (tid > 0) { + i += 2; + } + if (disabled) { + i++; + } + if (allowPending) { + i++; + } + + String[] opts = new String[i]; + + // Fill in the optional parameters + i = 0; + if (isTemporary) { + opts[i] = "-t"; //$NON-NLS-1$ + i++; + } + if (condition != null && !condition.isEmpty()) { + opts[i] = "-c"; //$NON-NLS-1$ + i++; + opts[i] = condition; + i++; + } + if (ignoreCount > 0) { + opts[i] = "-i"; //$NON-NLS-1$ + i++; + opts[i] = Integer.toString(ignoreCount); + i++; + } + if (tid > 0) { + opts[i] = "-p"; //$NON-NLS-1$ + i++; + opts[i] = Integer.toString(tid); + i++; + } + if (disabled) { + opts[i] = "-d"; //$NON-NLS-1$ + i++; + } + if (allowPending) { + opts[i] = "-f"; //$NON-NLS-1$ + i++; + } + + if (opts.length > 0) { + setOptions(opts); + } + + setParameters(createParameters(location, printfStr)); + } private Adjustable[] createParameters(String location, String printfStr) { List<Adjustable> paramsList = new ArrayList<Adjustable>(); - + paramsList.add(new MIStandardParameterAdjustable(location)); - - GDBDynamicPrintfUtils.GDBDynamicPrintfString parsedStr = - new GDBDynamicPrintfUtils.GDBDynamicPrintfString(printfStr); - + + GDBDynamicPrintfUtils.GDBDynamicPrintfString parsedStr = new GDBDynamicPrintfUtils.GDBDynamicPrintfString( + printfStr); + if (parsedStr.isValid()) { paramsList.add(new DPrintfAdjustable(parsedStr.getString())); for (String arg : parsedStr.getArguments()) { - paramsList.add(new MIStandardParameterAdjustable(arg)); - } + paramsList.add(new MIStandardParameterAdjustable(arg)); + } } - + return paramsList.toArray(new Adjustable[paramsList.size()]); } - @Override - public MIBreakInsertInfo getResult(MIOutput output) { - return new MIBreakInsertInfo(output); - } - + @Override + public MIBreakInsertInfo getResult(MIOutput output) { + return new MIBreakInsertInfo(output); + } + /** * This adjustable makes sure that the dprintf parameters will not be modified * any further. The reason for that is that the -dprintf-insert command |