Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Cortell2010-04-08 16:02:35 -0400
committerJohn Cortell2010-04-08 16:02:35 -0400
commit119d848c62505f121f6c87d3e56109cc37753ad4 (patch)
tree61508861dc47e0de23d9bf3f6769b9a42a5b1b49 /debug/org.eclipse.cdt.gdb
parent5e2d6690ac36cb816acb714621d2ed8caa49312f (diff)
downloadorg.eclipse.cdt-119d848c62505f121f6c87d3e56109cc37753ad4.tar.gz
org.eclipse.cdt-119d848c62505f121f6c87d3e56109cc37753ad4.tar.xz
org.eclipse.cdt-119d848c62505f121f6c87d3e56109cc37753ad4.zip
[305752] Moved gdb event breakpoint constants into new common gdb plugin as well as the registering of the event types (via an extension)
Diffstat (limited to 'debug/org.eclipse.cdt.gdb')
-rw-r--r--debug/org.eclipse.cdt.gdb/META-INF/MANIFEST.MF3
-rw-r--r--debug/org.eclipse.cdt.gdb/src/org/eclipse/cdt/gdb/internal/eventbkpts/GdbCatchpoints.java78
2 files changed, 80 insertions, 1 deletions
diff --git a/debug/org.eclipse.cdt.gdb/META-INF/MANIFEST.MF b/debug/org.eclipse.cdt.gdb/META-INF/MANIFEST.MF
index fa47a80832..e4f695b619 100644
--- a/debug/org.eclipse.cdt.gdb/META-INF/MANIFEST.MF
+++ b/debug/org.eclipse.cdt.gdb/META-INF/MANIFEST.MF
@@ -11,4 +11,5 @@ Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Export-Package: org.eclipse.cdt.gdb.eventbkpts,
- org.eclipse.cdt.gdb.internal;x-internal:=true
+ org.eclipse.cdt.gdb.internal;x-internal:=true,
+ org.eclipse.cdt.gdb.internal.eventbkpts;x-friends:="org.eclipse.cdt.debug.mi.core,org.eclipse.cdt.dsf.gdb,org.eclipse.cdt.tests.dsf.gdb"
diff --git a/debug/org.eclipse.cdt.gdb/src/org/eclipse/cdt/gdb/internal/eventbkpts/GdbCatchpoints.java b/debug/org.eclipse.cdt.gdb/src/org/eclipse/cdt/gdb/internal/eventbkpts/GdbCatchpoints.java
new file mode 100644
index 0000000000..ce2ae65760
--- /dev/null
+++ b/debug/org.eclipse.cdt.gdb/src/org/eclipse/cdt/gdb/internal/eventbkpts/GdbCatchpoints.java
@@ -0,0 +1,78 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Freescale Semiconductor 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:
+ * Freescale Semiconductor - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.gdb.internal.eventbkpts;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.cdt.gdb.eventbkpts.IEventBreakpointConstants;
+
+public class GdbCatchpoints {
+
+ /** Map which services {@link #eventToGdbCatchpointKeyword(String)} */
+ private static final Map<String, String> sIdToKeyword = new HashMap<String, String>();
+ static {
+ // these Ids are also referenced in mi.ui plugin as contribution
+ // to event breakpoints selector
+ sIdToKeyword.put(IEventBreakpointConstants.EVENT_TYPE_CATCH, "catch"); //$NON-NLS-1$
+ sIdToKeyword.put(IEventBreakpointConstants.EVENT_TYPE_THROW, "throw"); //$NON-NLS-1$
+ sIdToKeyword.put(IEventBreakpointConstants.EVENT_TYPE_SIGNAL_CATCH, "signal"); //$NON-NLS-1$
+ sIdToKeyword.put(IEventBreakpointConstants.EVENT_TYPE_EXEC, "exec"); //$NON-NLS-1$
+ sIdToKeyword.put(IEventBreakpointConstants.EVENT_TYPE_FORK, "fork"); //$NON-NLS-1$
+ sIdToKeyword.put(IEventBreakpointConstants.EVENT_TYPE_VFORK, "vfork"); //$NON-NLS-1$
+ sIdToKeyword.put(IEventBreakpointConstants.EVENT_TYPE_EXIT, "exit"); //$NON-NLS-1$
+ sIdToKeyword.put(IEventBreakpointConstants.EVENT_TYPE_PROCESS_START, "start"); //$NON-NLS-1$
+ sIdToKeyword.put(IEventBreakpointConstants.EVENT_TYPE_PROCESS_STOP, "stop"); //$NON-NLS-1$
+ sIdToKeyword.put(IEventBreakpointConstants.EVENT_TYPE_THREAD_START, "thread_start"); //$NON-NLS-1$
+ sIdToKeyword.put(IEventBreakpointConstants.EVENT_TYPE_THREAD_EXIT, "thread_exit"); //$NON-NLS-1$
+ sIdToKeyword.put(IEventBreakpointConstants.EVENT_TYPE_THREAD_JOIN, "thread_join"); //$NON-NLS-1$
+ sIdToKeyword.put(IEventBreakpointConstants.EVENT_TYPE_LIBRARY_LOAD, "load"); //$NON-NLS-1$
+ sIdToKeyword.put(IEventBreakpointConstants.EVENT_TYPE_LIBRARY_UNLOAD, "unload"); //$NON-NLS-1$
+ }
+
+ /**
+ * Get the gdb catchpoint event keyword associated with the given
+ * {@link IEventBreakpointConstants} event type ID. Answer will be, e.g.,
+ * "catch", "throw", "fork", etc.
+ *
+ * @param event
+ * an EVENT_TYPE_XXXX constant from IEventBreakpointConstants
+ * @return the gdb keyword for [event]; null if [event] is unrecognized
+ */
+ public static String eventToGdbCatchpointKeyword(String event) {
+ String keyword = sIdToKeyword.get(event);
+ assert keyword != null : "unexpected catchpoint event id";
+ return keyword;
+ }
+
+ /**
+ * An inversion of the lookup done by
+ * {@link #eventToGdbCatchpointKeyword(String)}
+ *
+ * @param keyword
+ * a gdb catchpoint keyword, e.g., "catch", "throw", "fork"
+ * @return the EVENT_TYPE_XXXX constant from IEventBreakpointConstants
+ * associated with [keyword], or null if not recognized
+ */
+ public static String gdbCatchpointKeywordToEvent(String keyword) {
+ for (String eventId : sIdToKeyword.keySet()) {
+ String thisKeyword = sIdToKeyword.get(eventId);
+ if (thisKeyword.equals(keyword)) {
+ return eventId;
+ }
+ }
+
+ // Don't assert. Caller may be using us to determine if a token is a
+ // catchpoint keyword. He may have parsed the keyword out from gdb/mi
+ // output.
+ return null;
+ }
+}

Back to the top