From 169508e98e66a348c32370d382d10c200b4fc7e6 Mon Sep 17 00:00:00 2001 From: Marc Khouzam Date: Mon, 14 Jul 2008 19:59:45 +0000 Subject: [PATCH] Bug 240525 This patch cleans up MITargetAttach/Detach to use the context properly. Since these classes are new, we don't need to worry about an API change. A new class IMIProcessDMContext is introduced to be able to access the pid. --- .../dd/mi/service/IMIProcessDMContext.java | 25 +++++++++++++++++++ .../command/commands/MITargetAttach.java | 11 ++++---- .../command/commands/MITargetDetach.java | 11 ++++---- 3 files changed, 37 insertions(+), 10 deletions(-) create mode 100644 plugins/org.eclipse.dd.mi/src/org/eclipse/dd/mi/service/IMIProcessDMContext.java diff --git a/plugins/org.eclipse.dd.mi/src/org/eclipse/dd/mi/service/IMIProcessDMContext.java b/plugins/org.eclipse.dd.mi/src/org/eclipse/dd/mi/service/IMIProcessDMContext.java new file mode 100644 index 00000000000..2a1252b00a7 --- /dev/null +++ b/plugins/org.eclipse.dd.mi/src/org/eclipse/dd/mi/service/IMIProcessDMContext.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright (c) 2008 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: + * Ercisson - initial API and implementation + *******************************************************************************/ +package org.eclipse.dd.mi.service; + +import org.eclipse.dd.dsf.debug.service.IProcesses.IProcessDMContext; + +/** + * A process context object. In the GDB/MI protocol, processes are represented + * by an string identifier, which is the basis for this context. + */ +public interface IMIProcessDMContext extends IProcessDMContext { + /** + * Returns the GDB/MI process identifier of this context. + * @return + */ + public String getProcId(); +} diff --git a/plugins/org.eclipse.dd.mi/src/org/eclipse/dd/mi/service/command/commands/MITargetAttach.java b/plugins/org.eclipse.dd.mi/src/org/eclipse/dd/mi/service/command/commands/MITargetAttach.java index 5b6dbd9d6ef..7aabeb04b9f 100644 --- a/plugins/org.eclipse.dd.mi/src/org/eclipse/dd/mi/service/command/commands/MITargetAttach.java +++ b/plugins/org.eclipse.dd.mi/src/org/eclipse/dd/mi/service/command/commands/MITargetAttach.java @@ -10,7 +10,8 @@ *******************************************************************************/ package org.eclipse.dd.mi.service.command.commands; -import org.eclipse.dd.dsf.datamodel.IDMContext; +import org.eclipse.dd.mi.service.IMIExecutionGroupDMContext; +import org.eclipse.dd.mi.service.IMIProcessDMContext; import org.eclipse.dd.mi.service.command.output.MIInfo; /** @@ -21,11 +22,11 @@ import org.eclipse.dd.mi.service.command.output.MIInfo; */ public class MITargetAttach extends MICommand { - public MITargetAttach(IDMContext ctx, String threadGroupId) { - super(ctx, "-target-attach", new String[] {threadGroupId}); //$NON-NLS-1$ + public MITargetAttach(IMIExecutionGroupDMContext ctx) { + super(ctx, "-target-attach", new String[] {ctx.getGroupId()}); //$NON-NLS-1$ } - public MITargetAttach(IDMContext ctx, int pid) { - super(ctx, "-target-attach" , new String[] {"--pid " + pid}); //$NON-NLS-1$//$NON-NLS-2$ + public MITargetAttach(IMIProcessDMContext ctx) { + super(ctx, "-target-attach", new String[] {"--pid " + ctx.getProcId()}); //$NON-NLS-1$//$NON-NLS-2$ } } diff --git a/plugins/org.eclipse.dd.mi/src/org/eclipse/dd/mi/service/command/commands/MITargetDetach.java b/plugins/org.eclipse.dd.mi/src/org/eclipse/dd/mi/service/command/commands/MITargetDetach.java index b2e56274e14..1681587f4fc 100644 --- a/plugins/org.eclipse.dd.mi/src/org/eclipse/dd/mi/service/command/commands/MITargetDetach.java +++ b/plugins/org.eclipse.dd.mi/src/org/eclipse/dd/mi/service/command/commands/MITargetDetach.java @@ -10,7 +10,8 @@ *******************************************************************************/ package org.eclipse.dd.mi.service.command.commands; -import org.eclipse.dd.dsf.datamodel.IDMContext; +import org.eclipse.dd.mi.service.IMIExecutionGroupDMContext; +import org.eclipse.dd.mi.service.IMIProcessDMContext; import org.eclipse.dd.mi.service.command.output.MIInfo; /** @@ -21,11 +22,11 @@ import org.eclipse.dd.mi.service.command.output.MIInfo; */ public class MITargetDetach extends MICommand { - public MITargetDetach(IDMContext ctx, String threadGroupId) { - super(ctx, "-target-detach", new String[] {threadGroupId}); //$NON-NLS-1$ + public MITargetDetach(IMIExecutionGroupDMContext ctx) { + super(ctx, "-target-detach", new String[] {ctx.getGroupId()}); //$NON-NLS-1$ } - public MITargetDetach(IDMContext ctx, int pid) { - super(ctx, "-target-detach" , new String[] {"--pid " + pid}); //$NON-NLS-1$//$NON-NLS-2$ + public MITargetDetach(IMIProcessDMContext ctx) { + super(ctx, "-target-detach", new String[] {"--pid " + ctx.getProcId()}); //$NON-NLS-1$//$NON-NLS-2$ } }