From 1b4cb4d21328b90f2e5f2c6be6c8b2ba537d0814 Mon Sep 17 00:00:00 2001 From: Marc Khouzam Date: Thu, 12 Aug 2010 20:16:26 +0000 Subject: [PATCH] Bug 237306: Added -add-inferior and -remove-inferior commands --- .../mi/service/command/CommandFactory.java | 13 +++++ .../command/commands/MIAddInferior.java | 40 +++++++++++++++ .../command/commands/MIRemoveInferior.java | 30 +++++++++++ .../command/output/MIAddInferiorInfo.java | 50 +++++++++++++++++++ 4 files changed, 133 insertions(+) create mode 100644 dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/MIAddInferior.java create mode 100644 dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/MIRemoveInferior.java create mode 100644 dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/MIAddInferiorInfo.java diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/CommandFactory.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/CommandFactory.java index e3bdb962e01..d72fd9c2514 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/CommandFactory.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/CommandFactory.java @@ -41,6 +41,7 @@ import org.eclipse.cdt.dsf.mi.service.command.commands.CLISource; import org.eclipse.cdt.dsf.mi.service.command.commands.CLIThread; import org.eclipse.cdt.dsf.mi.service.command.commands.CLITrace; import org.eclipse.cdt.dsf.mi.service.command.commands.CLIUnsetEnv; +import org.eclipse.cdt.dsf.mi.service.command.commands.MIAddInferior; import org.eclipse.cdt.dsf.mi.service.command.commands.MIBreakAfter; import org.eclipse.cdt.dsf.mi.service.command.commands.MIBreakCommands; import org.eclipse.cdt.dsf.mi.service.command.commands.MIBreakCondition; @@ -94,6 +95,7 @@ import org.eclipse.cdt.dsf.mi.service.command.commands.MIInferiorTTYSet; import org.eclipse.cdt.dsf.mi.service.command.commands.MIInterpreterExec; import org.eclipse.cdt.dsf.mi.service.command.commands.MIInterpreterExecConsole; import org.eclipse.cdt.dsf.mi.service.command.commands.MIListThreadGroups; +import org.eclipse.cdt.dsf.mi.service.command.commands.MIRemoveInferior; import org.eclipse.cdt.dsf.mi.service.command.commands.MIStackInfoDepth; import org.eclipse.cdt.dsf.mi.service.command.commands.MIStackListArguments; import org.eclipse.cdt.dsf.mi.service.command.commands.MIStackListFrames; @@ -136,6 +138,7 @@ import org.eclipse.cdt.dsf.mi.service.command.output.CLIInfoSharedLibraryInfo; import org.eclipse.cdt.dsf.mi.service.command.output.CLIInfoThreadsInfo; import org.eclipse.cdt.dsf.mi.service.command.output.CLIThreadInfo; import org.eclipse.cdt.dsf.mi.service.command.output.CLITraceInfo; +import org.eclipse.cdt.dsf.mi.service.command.output.MIAddInferiorInfo; import org.eclipse.cdt.dsf.mi.service.command.output.MIBreakInsertInfo; import org.eclipse.cdt.dsf.mi.service.command.output.MIBreakListInfo; import org.eclipse.cdt.dsf.mi.service.command.output.MIDataDisassembleInfo; @@ -252,6 +255,11 @@ public class CommandFactory { return new CLIUnsetEnv(ctx, name); } + /** @since 4.0 */ + public ICommand createMIAddInferior(ICommandControlDMContext ctx) { + return new MIAddInferior(ctx); + } + public ICommand createMIBreakAfter(IBreakpointsTargetDMContext ctx, int breakpoint, int ignoreCount) { return new MIBreakAfter(ctx, breakpoint, ignoreCount); } @@ -592,6 +600,11 @@ public class CommandFactory { return new MIListThreadGroups(ctx, listAll); } + /** @since 4.0 */ + public ICommand createMIRemoveInferior(ICommandControlDMContext ctx, String groupId) { + return new MIRemoveInferior(ctx, groupId); + } + public ICommand createMIStackInfoDepth(IMIExecutionDMContext ctx) { return new MIStackInfoDepth(ctx); } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/MIAddInferior.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/MIAddInferior.java new file mode 100644 index 00000000000..ce8fc202268 --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/MIAddInferior.java @@ -0,0 +1,40 @@ +/******************************************************************************* + * Copyright (c) 2010 Ericsson and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Ericsson - Initial API and implementation + *******************************************************************************/ + +package org.eclipse.cdt.dsf.mi.service.command.commands; + +import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService.ICommandControlDMContext; +import org.eclipse.cdt.dsf.mi.service.command.output.MIAddInferiorInfo; +import org.eclipse.cdt.dsf.mi.service.command.output.MIOutput; + + +/** + * -add-inferior + * ^done,inferior="i2" + * + * Creates a new inferior. The created inferior is not associated with any executable. + * Such association may be established with the '-file-exec-and-symbols' command. + * The command response has a single field, 'thread-group', whose value is the + * identifier of the thread group corresponding to the new inferior. + * + * @since 4.0 + */ +public class MIAddInferior extends MICommand +{ + public MIAddInferior(ICommandControlDMContext dmc) { + super(dmc, "-add-inferior"); //$NON-NLS-1$ + } + + @Override + public MIAddInferiorInfo getResult(MIOutput output) { + return new MIAddInferiorInfo(output); + } +} diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/MIRemoveInferior.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/MIRemoveInferior.java new file mode 100644 index 00000000000..3ef5bc610b0 --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/MIRemoveInferior.java @@ -0,0 +1,30 @@ +/******************************************************************************* + * Copyright (c) 2010 Ericsson and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Ericsson - Initial API and implementation + *******************************************************************************/ + +package org.eclipse.cdt.dsf.mi.service.command.commands; + +import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService.ICommandControlDMContext; +import org.eclipse.cdt.dsf.mi.service.command.output.MIInfo; + +/** + * -remove-inferior GROUPID + * ^done + * + * Remove the specified inferior. + * + * @since 4.0 + */ +public class MIRemoveInferior extends MICommand +{ + public MIRemoveInferior(ICommandControlDMContext dmc, String groupId) { + super(dmc, "-remove-inferior", new String[] { groupId }); //$NON-NLS-1$ + } +} diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/MIAddInferiorInfo.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/MIAddInferiorInfo.java new file mode 100644 index 00000000000..d912b033c06 --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/MIAddInferiorInfo.java @@ -0,0 +1,50 @@ +/******************************************************************************* + * Copyright (c) 2010 Ericsson and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Ericsson - Initial API and implementation + *******************************************************************************/ + +package org.eclipse.cdt.dsf.mi.service.command.output; + +/** + * -add-inferior + * ^done,inferior="i2" + * + * @since 4.0 + */ +public class MIAddInferiorInfo extends MIInfo { + + private String fGroupId; + + public MIAddInferiorInfo(MIOutput record) { + super(record); + if (isDone()) { + MIOutput out = getMIOutput(); + MIResultRecord rr = out.getMIResultRecord(); + if (rr != null) { + MIResult[] results = rr.getMIResults(); + for (int i = 0; i < results.length; i++) { + String var = results[i].getVariable(); + MIValue resultVal = results[i].getMIValue(); + String str = ""; //$NON-NLS-1$ + if (resultVal instanceof MIConst) { + str = ((MIConst)resultVal).getString(); + } + + if (var.equals("inferior")) { //$NON-NLS-1$ + fGroupId = str; + } + } + } + } + } + + public String getGroupId() { + return fGroupId; + } +}