~ubuntu-branches/debian/sid/eclipse-cdt/sid

« back to all changes in this revision

Viewing changes to results/plugins/org.eclipse.cdt.debug.ui.tests/src/org/eclipse/cdt/debug/testplugin/CDebugHelper.java

  • Committer: Package Import Robot
  • Author(s): Jakub Adam
  • Date: 2011-10-06 21:15:04 UTC
  • mfrom: (1.1.4)
  • Revision ID: package-import@ubuntu.com-20111006211504-8dutmljjih0zikfv
Tags: 8.0.1-1
* New upstream release.
* Split the JNI packages into a separate architecture dependent
  package and made eclipse-cdt architecture independent.
* Install JNI libraries into multiarch aware location
* Bumped Standards-Version to 3.9.2.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
7
 
 *
8
 
 * Contributors:
9
 
 *     QNX Software Systems - initial API and implementation
10
 
 *******************************************************************************/
11
 
package org.eclipse.cdt.debug.testplugin;
12
 
 
13
 
import java.io.File;
14
 
import java.io.IOException;
15
 
 
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;
27
 
 
28
 
 
29
 
/**
30
 
 * Helper methods to set up a Debug session.
31
 
 */
32
 
public class CDebugHelper {
33
 
        
34
 
        
35
 
 
36
 
        /**
37
 
         * Creates a ICDISession.
38
 
         */     
39
 
        public static ICDISession createSession(String exe) throws IOException, MIException  {
40
 
                MIPlugin mi;
41
 
        ICDISession session;
42
 
        String os = System.getProperty("os.name");
43
 
        String exename;
44
 
        mi=MIPlugin.getDefault();
45
 
        
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/";
48
 
        os=os.toLowerCase();
49
 
        /* We need to get the correct executable to execute
50
 
         */
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;
59
 
        else
60
 
           return(null);
61
 
        session=mi.createCSession(null, MIVersion.MI1, new File(exename), new File("."), null, null);
62
 
                return(session);
63
 
        }
64
 
        /**
65
 
         * Creates a ICDISession.
66
 
         */     
67
 
        public static ICDISession createSession(String exe, ICProject project) throws IOException, MIException, CModelException  {
68
 
                MIPlugin mi;
69
 
                String  workspacePath= Platform.getLocation().toOSString();
70
 
                ICDISession session;
71
 
                mi=MIPlugin.getDefault();
72
 
                
73
 
                try {
74
 
                        project.getProject().refreshLocal(IResource.DEPTH_INFINITE, null);
75
 
                } catch (Exception exc) {}
76
 
                IBinary bins[] = project.getBinaryContainer().getBinaries();
77
 
                if (bins.length!=1) {
78
 
                        //SHOULD NOT HAPPEN
79
 
                        return(null);        
80
 
                }
81
 
                
82
 
                session=mi.createCSession(null, MIVersion.MI1, new File(workspacePath +bins[0].getPath().toOSString()), new File("."), null, null);
83
 
                return(session);
84
 
        }
85
 
        
86
 
 
87
 
}
88