1
/*******************************************************************************
2
* Copyright (c) 2005 QNX Software Systems and others.
3
* All rights reserved. This program and the accompanying materials
4
* are made available under the terms of the Eclipse Public License v1.0
5
* which accompanies this distribution, and is available at
6
* http://www.eclipse.org/legal/epl-v10.html
9
* QNX Software Systems - initial API and implementation
10
*******************************************************************************/
11
package org.eclipse.cdt.debug.testplugin;
14
import java.io.IOException;
16
import org.eclipse.cdt.core.model.CModelException;
17
import org.eclipse.cdt.core.model.IBinary;
18
import org.eclipse.cdt.core.model.ICProject;
19
import org.eclipse.cdt.debug.core.cdi.ICDISession;
20
import org.eclipse.cdt.debug.mi.core.MIException;
21
import org.eclipse.cdt.debug.mi.core.MIPlugin;
22
import org.eclipse.cdt.debug.mi.core.command.MIVersion;
23
import org.eclipse.core.resources.IResource;
24
import org.eclipse.core.runtime.Path;
25
import org.eclipse.core.runtime.Platform;
26
import org.eclipse.swt.widgets.Display;
30
* Helper methods to set up a Debug session.
32
public class CDebugHelper {
37
* Creates a ICDISession.
39
public static ICDISession createSession(String exe) throws IOException, MIException {
42
String os = System.getProperty("os.name");
44
mi=MIPlugin.getDefault();
46
exename=org.eclipse.core.runtime.Platform.getPlugin("org.eclipse.cdt.debug.ui.tests").find(new Path("/")).getFile();
47
exename+="core/org/eclipse/cdt/debug/core/tests/resources/";
49
/* We need to get the correct executable to execute
51
if (os.indexOf("windows")!=-1)
52
exename+="win/"+ exe +".exe";
53
else if (os.indexOf("qnx")!=-1)
54
exename+="qnx/" + exe;
55
else if (os.indexOf("linux")!=-1)
56
exename+="linux/"+exe;
57
else if (os.indexOf("sol")!=-1)
58
exename+="sol/" + exe;
61
session=mi.createCSession(null, MIVersion.MI1, new File(exename), new File("."), null, null);
65
* Creates a ICDISession.
67
public static ICDISession createSession(String exe, ICProject project) throws IOException, MIException, CModelException {
69
String workspacePath= Platform.getLocation().toOSString();
71
mi=MIPlugin.getDefault();
74
project.getProject().refreshLocal(IResource.DEPTH_INFINITE, null);
75
} catch (Exception exc) {}
76
IBinary bins[] = project.getBinaryContainer().getBinaries();
82
session=mi.createCSession(null, MIVersion.MI1, new File(workspacePath +bins[0].getPath().toOSString()), new File("."), null, null);