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

« back to all changes in this revision

Viewing changes to results/plugins/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/EventBreakpoint.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) 2000, 2007 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.mi.core.cdi.model;
12
 
 
13
 
import java.util.Arrays;
14
 
import java.util.HashMap;
15
 
 
16
 
import org.eclipse.cdt.debug.core.cdi.ICDICondition;
17
 
import org.eclipse.cdt.debug.core.cdi.model.ICDIEventBreakpoint;
18
 
import org.eclipse.cdt.debug.core.model.ICBreakpointType;
19
 
import org.eclipse.cdt.debug.mi.core.output.MIBreakpoint;
20
 
 
21
 
/**
22
 
 * @since 6.0
23
 
 */
24
 
public class EventBreakpoint extends Breakpoint implements ICDIEventBreakpoint {
25
 
        
26
 
        public static final String CATCH = "org.eclipse.cdt.debug.gdb.catch";
27
 
        public static final String THROW = "org.eclipse.cdt.debug.gdb.throw";
28
 
        public static final String SIGNAL_CATCH = "org.eclipse.cdt.debug.gdb.signal";
29
 
        public static final String STOP_ON_FORK = "org.eclipse.cdt.debug.gdb.catch_fork";
30
 
        public static final String STOP_ON_VFORK = "org.eclipse.cdt.debug.gdb.catch_vfork";
31
 
        public static final String STOP_ON_EXEC = "org.eclipse.cdt.debug.gdb.catch_exec";
32
 
        /**
33
 
         * @since 6.0
34
 
         */
35
 
        public static final String CATCH_EXIT = "org.eclipse.cdt.debug.gdb.catch_exit";
36
 
        /**
37
 
         * @since 6.0
38
 
         */
39
 
        public static final String CATCH_START = "org.eclipse.cdt.debug.gdb.catch_start";
40
 
        /**
41
 
         * @since 6.0
42
 
         */
43
 
        public static final String CATCH_STOP = "org.eclipse.cdt.debug.gdb.catch_stop";
44
 
        /**
45
 
         * @since 6.0
46
 
         */
47
 
        public static final String CATCH_THREAD_START = "org.eclipse.cdt.debug.gdb.catch_thread_start";
48
 
        /**
49
 
         * @since 6.0
50
 
         */
51
 
        public static final String CATCH_THREAD_EXIT = "org.eclipse.cdt.debug.gdb.catch_thread_exit";
52
 
        /**
53
 
         * @since 6.0
54
 
         */
55
 
        public static final String CATCH_THREAD_JOIN = "org.eclipse.cdt.debug.gdb.catch_thread_join";
56
 
        /**
57
 
         * @since 6.0
58
 
         */
59
 
        public static final String CATCH_LOAD = "org.eclipse.cdt.debug.gdb.catch_load";
60
 
        /**
61
 
         * @since 6.0
62
 
         */
63
 
        public static final String CATCH_UNLOAD = "org.eclipse.cdt.debug.gdb.catch_unload";
64
 
 
65
 
        private String eventType;
66
 
        private String arg;
67
 
        private static final HashMap<String, String> idToKeyword = new HashMap<String, String>();
68
 
        static {
69
 
                // these Ids are also referenced in mi.ui plugin as contribution
70
 
                // to event breakpoints selector
71
 
                idToKeyword.put(CATCH, "catch");
72
 
                idToKeyword.put(THROW, "throw");
73
 
                idToKeyword.put(SIGNAL_CATCH, "signal");
74
 
                idToKeyword.put(STOP_ON_EXEC, "exec");
75
 
                idToKeyword.put(STOP_ON_FORK, "fork");
76
 
                idToKeyword.put(STOP_ON_VFORK, "vfork");
77
 
                idToKeyword.put(CATCH_EXIT, "exit");
78
 
                idToKeyword.put(CATCH_START, "start");
79
 
                idToKeyword.put(CATCH_STOP, "stop");
80
 
                idToKeyword.put(CATCH_THREAD_START, "thread_start");
81
 
                idToKeyword.put(CATCH_THREAD_EXIT, "thread_exit");
82
 
                idToKeyword.put(CATCH_THREAD_JOIN, "thread_join");
83
 
                idToKeyword.put(CATCH_LOAD, "load");
84
 
                idToKeyword.put(CATCH_UNLOAD, "unload");
85
 
        }
86
 
 
87
 
        public EventBreakpoint(Target target, String event, String arg, ICDICondition cond, boolean enabled) {
88
 
                super(target, ICBreakpointType.REGULAR, cond, enabled);
89
 
                this.eventType = event;
90
 
                this.arg = arg==null?"":arg;
91
 
        }
92
 
 
93
 
        public String getEventType()  {
94
 
                return eventType;
95
 
        }
96
 
 
97
 
        public String getExtraArgument() {
98
 
                return arg;
99
 
        }
100
 
 
101
 
 
102
 
        public String getGdbEvent() {
103
 
                String etype = getEventType();
104
 
                String key= idToKeyword.get(etype);
105
 
                if (key!=null) return key;
106
 
                return "unknown";
107
 
        }
108
 
 
109
 
        public String getGdbArg() {
110
 
                return getExtraArgument();
111
 
        }
112
 
        
113
 
        @Override
114
 
        public int hashCode() {
115
 
                return eventType.hashCode();
116
 
        }
117
 
        @Override
118
 
        public boolean equals(Object arg0) {
119
 
                if (this == arg0) return true;
120
 
                if (!(arg0 instanceof EventBreakpoint)) return false;
121
 
                MIBreakpoint[] breakpoints = getMIBreakpoints();
122
 
                if (breakpoints==null || breakpoints.length==0) {
123
 
                        return super.equals(arg0);
124
 
                }
125
 
                return Arrays.equals(breakpoints, ((EventBreakpoint)arg0).getMIBreakpoints());
126
 
        }
127
 
        /**
128
 
         * Returns event type by using miBreakpoint parameters
129
 
         * @param miBreakpoint
130
 
         * @return null if unknown type, null cannot be used to create valid EventBreakpoint
131
 
         */
132
 
        public static String getEventTypeFromMI(MIBreakpoint miBreakpoint) {
133
 
                if (miBreakpoint.getWhat().equals("exception catch")) {
134
 
                        return  EventBreakpoint.CATCH;
135
 
                } else if (miBreakpoint.getWhat().equals("exception throw")) {
136
 
                        return  EventBreakpoint.THROW;
137
 
                } else if (miBreakpoint.getType().equals("catch signal")) {
138
 
                        // catch signal does not work in gdb 
139
 
                        return  EventBreakpoint.SIGNAL_CATCH;
140
 
                } 
141
 
                String miType = miBreakpoint.getType();
142
 
                String prefix = "catch "; 
143
 
                if (miType.startsWith(prefix)) {
144
 
                        String key = miType.substring(prefix.length());
145
 
                        for (String id : idToKeyword.keySet()) {
146
 
                                String etype = idToKeyword.get(id);
147
 
                                if (key.equals(etype)) {
148
 
                                        return id;
149
 
                                }
150
 
                        }
151
 
                }
152
 
                return null; // not known/supported
153
 
        }
154
 
        
155
 
        public static String getEventArgumentFromMI(MIBreakpoint miBreakpoint) {
156
 
                // need a working gdb command command that support catch event argument test test
157
 
                return "";
158
 
        }
159
 
 
160
 
}