mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-24 09:25:31 +02:00
[305752] Moved gdb event breakpoint constants into new common gdb plugin as well as the registering of the event types (via an extension)
This commit is contained in:
parent
5e2d6690ac
commit
119d848c62
14 changed files with 130 additions and 290 deletions
|
@ -25,10 +25,8 @@ public interface ICEventBreakpoint extends ICBreakpoint {
|
|||
/**
|
||||
* Breakpoint attribute storing the event breakpoint event id. Basically,
|
||||
* this indicates what type of event the breakpoint catches--e.g., a C++
|
||||
* exception throw, a library load, a thread exit, etc. Event types can be
|
||||
* contributed via the "breakpointContribution" extension point. Stock CDT
|
||||
* contributes a number of them, which are represented here by the
|
||||
* EVENT_TYPE_XXXXX constants
|
||||
* exception throw, a library load, a thread exit, etc. Event types are
|
||||
* contributed via the "breakpointContribution" extension point.
|
||||
*
|
||||
* <p>
|
||||
* This attribute is a <code>String</code>.
|
||||
|
@ -36,120 +34,6 @@ public interface ICEventBreakpoint extends ICBreakpoint {
|
|||
*/
|
||||
public static final String EVENT_TYPE_ID = "org.eclipse.cdt.debug.core.eventbreakpoint_event_id"; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* An event breakpoint of this type suspends the target program when it
|
||||
* catches a C++ exception. This type of event has no parameters.
|
||||
*
|
||||
* @since 7.0
|
||||
*/
|
||||
public static final String EVENT_TYPE_CATCH = "org.eclipse.cdt.debug.gdb.catch"; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* An event breakpoint of this type suspends the target program when it
|
||||
* throws a C++ exception. This type of event has no parameters.
|
||||
*
|
||||
* @since 7.0
|
||||
*/
|
||||
public static final String EVENT_TYPE_THROW = "org.eclipse.cdt.debug.gdb.throw"; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* An event breakpoint of this type suspends the target program when it
|
||||
* catches a signal (POSIX). This type of event has a single parameter of
|
||||
* type in, indicating the specific signal.
|
||||
*
|
||||
* @since 7.0
|
||||
*/
|
||||
public static final String EVENT_TYPE_SIGNAL_CATCH = "org.eclipse.cdt.debug.gdb.signal"; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* An event breakpoint of this type suspends the target program when it
|
||||
* calls fork() (POSIX). This type of event has no parameters.
|
||||
*
|
||||
* @since 7.0
|
||||
*/
|
||||
public static final String EVENT_TYPE_FORK = "org.eclipse.cdt.debug.gdb.catch_fork"; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* An event breakpoint of this type suspends the target program when it
|
||||
* calls vfork() (POSIX). This type of event has no parameters.
|
||||
*
|
||||
* @since 7.0
|
||||
*/
|
||||
public static final String EVENT_TYPE_VFORK = "org.eclipse.cdt.debug.gdb.catch_vfork"; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* An event breakpoint of this type suspends the target program when it
|
||||
* calls exec() (POSIX). This type of event has no parameters.
|
||||
*
|
||||
* @since 7.0
|
||||
*/
|
||||
public static final String EVENT_TYPE_EXEC = "org.eclipse.cdt.debug.gdb.catch_exec"; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* An event breakpoint of this type suspends the target program when it
|
||||
* calls exit() (POSIX). This type of event has no parameters.
|
||||
*
|
||||
* @since 7.0
|
||||
*/
|
||||
public static final String EVENT_TYPE_EXIT = "org.eclipse.cdt.debug.gdb.catch_exit"; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* An event breakpoint of this type suspends the target program when a new
|
||||
* process starts. This type of event has no parameters.
|
||||
*
|
||||
* @since 7.0
|
||||
*/
|
||||
public static final String EVENT_TYPE_PROCESS_START = "org.eclipse.cdt.debug.gdb.catch_start"; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* An event breakpoint of this type suspends the target program when a
|
||||
* process exits. This type of event has no parameters.
|
||||
*
|
||||
* @since 7.0
|
||||
*/
|
||||
public static final String EVENT_TYPE_PROCESS_STOP = "org.eclipse.cdt.debug.gdb.catch_stop"; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* An event breakpoint of this type suspends the target program when a new
|
||||
* thread starts. This type of event has no parameters.
|
||||
*
|
||||
* @since 7.0
|
||||
*/
|
||||
public static final String EVENT_TYPE_THREAD_START = "org.eclipse.cdt.debug.gdb.catch_thread_start"; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* An event breakpoint of this type suspends the target program when a
|
||||
* thread exits. This type of event has no parameters.
|
||||
*
|
||||
* @since 7.0
|
||||
*/
|
||||
public static final String EVENT_TYPE_THREAD_EXIT = "org.eclipse.cdt.debug.gdb.catch_thread_exit"; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* An event breakpoint of this type suspends the target program when a
|
||||
* thread joins another one (waits for it to exit) This type of event has no
|
||||
* parameters.
|
||||
*
|
||||
* @since 7.0
|
||||
*/
|
||||
public static final String EVENT_TYPE_THREAD_JOIN = "org.eclipse.cdt.debug.gdb.catch_thread_join"; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* An event breakpoint of this type suspends the target program when it
|
||||
* loads a library. This type of event has no parameters.
|
||||
*
|
||||
* @since 7.0
|
||||
*/
|
||||
public static final String EVENT_TYPE_LIBRARY_LOAD = "org.eclipse.cdt.debug.gdb.catch_load"; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* An event breakpoint of this type suspends the target program when it
|
||||
* unloads a library. This type of event has no parameters.
|
||||
*
|
||||
* @since 7.0
|
||||
*/
|
||||
public static final String EVENT_TYPE_LIBRARY_UNLOAD = "org.eclipse.cdt.debug.gdb.catch_unload"; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* Breakpoint attribute storing the event breakpoint argument. This
|
||||
* attribute is a <code>String</code>, though it may be a stringified
|
||||
|
@ -159,9 +43,8 @@ public interface ICEventBreakpoint extends ICBreakpoint {
|
|||
public static final String EVENT_ARG = "org.eclipse.cdt.debug.core.eventbreakpoint_event_arg"; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* Get the event breakpoint type. One of our EVENT_TYPE_XXXXX constants or a
|
||||
* custom type contributed via the <code>breakpointContribution</code>
|
||||
* extension point
|
||||
* Get the event breakpoint type. Same as querying the property
|
||||
* {@link #EVENT_TYPE_ID}
|
||||
*
|
||||
* @return event breakpoint type id (not null)
|
||||
* @throws CoreException
|
||||
|
@ -170,7 +53,8 @@ public interface ICEventBreakpoint extends ICBreakpoint {
|
|||
|
||||
/**
|
||||
* Get the event argument, if the type has one. Currently, an event type can
|
||||
* have at most one argument.
|
||||
* have at most one argument. Same as querying the property
|
||||
* {@link #EVENT_ARG}
|
||||
*
|
||||
* @return event argument, or null if not applicable
|
||||
* @throws CoreException
|
||||
|
|
|
@ -23,7 +23,8 @@ Require-Bundle: org.eclipse.cdt.debug.core;bundle-version="[7.0.0,8.0.0)",
|
|||
org.eclipse.debug.core;bundle-version="[3.2.0,4.0.0)",
|
||||
org.eclipse.cdt.core;bundle-version="[5.0.0,6.0.0)",
|
||||
org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)",
|
||||
org.eclipse.core.variables;bundle-version="3.2.200"
|
||||
org.eclipse.core.variables;bundle-version="3.2.200",
|
||||
org.eclipse.cdt.gdb;bundle-version="7.0.0"
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Bundle-RequiredExecutionEnvironment: J2SE-1.5
|
||||
Import-Package: com.ibm.icu.text
|
||||
|
|
|
@ -37,6 +37,7 @@ import org.eclipse.cdt.debug.mi.core.event.MISignalEvent;
|
|||
import org.eclipse.cdt.debug.mi.core.event.MISteppingRangeEvent;
|
||||
import org.eclipse.cdt.debug.mi.core.event.MIWatchpointScopeEvent;
|
||||
import org.eclipse.cdt.debug.mi.core.event.MIWatchpointTriggerEvent;
|
||||
import org.eclipse.cdt.gdb.internal.eventbkpts.GdbCatchpoints;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -59,7 +60,7 @@ public class SuspendedEvent implements ICDISuspendedEvent {
|
|||
BreakpointManager bkptMgr = session.getBreakpointManager();
|
||||
Breakpoint bkpt = bkptMgr.getBreakpoint(event.getMISession(), ((MIBreakpointHitEvent)event).getNumber());
|
||||
if (bkpt instanceof EventBreakpoint) {
|
||||
return new EventBreakpointHit(session, EventBreakpoint.getGdbEventFromId(((EventBreakpoint)bkpt).getEventType()));
|
||||
return new EventBreakpointHit(session, GdbCatchpoints.eventToGdbCatchpointKeyword(((EventBreakpoint)bkpt).getEventType()));
|
||||
}
|
||||
else {
|
||||
return new BreakpointHit(session, (MIBreakpointHitEvent)event);
|
||||
|
|
|
@ -11,14 +11,13 @@
|
|||
package org.eclipse.cdt.debug.mi.core.cdi.model;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.cdt.debug.core.cdi.ICDICondition;
|
||||
import org.eclipse.cdt.debug.core.cdi.model.ICDIEventBreakpoint;
|
||||
import org.eclipse.cdt.debug.core.model.ICBreakpointType;
|
||||
import org.eclipse.cdt.debug.core.model.ICEventBreakpoint;
|
||||
import org.eclipse.cdt.debug.mi.core.output.MIBreakpoint;
|
||||
import org.eclipse.cdt.gdb.eventbkpts.IEventBreakpointConstants;
|
||||
import org.eclipse.cdt.gdb.internal.eventbkpts.GdbCatchpoints;
|
||||
|
||||
/**
|
||||
* @since 6.0
|
||||
|
@ -29,30 +28,6 @@ public class EventBreakpoint extends Breakpoint implements ICDIEventBreakpoint {
|
|||
private String eventType;
|
||||
private String arg;
|
||||
|
||||
/**
|
||||
* A mapping of ICEventBreakpoint event types to their corresponding gdb
|
||||
* catchpoint keyword
|
||||
*/
|
||||
private static final Map<String, String> idToKeyword = new HashMap<String, String>();
|
||||
static {
|
||||
// these Ids are also referenced in mi.ui plugin as contribution
|
||||
// to event breakpoints selector
|
||||
idToKeyword.put(ICEventBreakpoint.EVENT_TYPE_CATCH, "catch"); //$NON-NLS-1$
|
||||
idToKeyword.put(ICEventBreakpoint.EVENT_TYPE_THROW, "throw"); //$NON-NLS-1$
|
||||
idToKeyword.put(ICEventBreakpoint.EVENT_TYPE_SIGNAL_CATCH, "signal"); //$NON-NLS-1$
|
||||
idToKeyword.put(ICEventBreakpoint.EVENT_TYPE_EXEC, "exec"); //$NON-NLS-1$
|
||||
idToKeyword.put(ICEventBreakpoint.EVENT_TYPE_FORK, "fork"); //$NON-NLS-1$
|
||||
idToKeyword.put(ICEventBreakpoint.EVENT_TYPE_VFORK, "vfork"); //$NON-NLS-1$
|
||||
idToKeyword.put(ICEventBreakpoint.EVENT_TYPE_EXIT, "exit"); //$NON-NLS-1$
|
||||
idToKeyword.put(ICEventBreakpoint.EVENT_TYPE_PROCESS_START, "start"); //$NON-NLS-1$
|
||||
idToKeyword.put(ICEventBreakpoint.EVENT_TYPE_PROCESS_STOP, "stop"); //$NON-NLS-1$
|
||||
idToKeyword.put(ICEventBreakpoint.EVENT_TYPE_THREAD_START, "thread_start"); //$NON-NLS-1$
|
||||
idToKeyword.put(ICEventBreakpoint.EVENT_TYPE_THREAD_EXIT, "thread_exit"); //$NON-NLS-1$
|
||||
idToKeyword.put(ICEventBreakpoint.EVENT_TYPE_THREAD_JOIN, "thread_join"); //$NON-NLS-1$
|
||||
idToKeyword.put(ICEventBreakpoint.EVENT_TYPE_LIBRARY_LOAD, "load"); //$NON-NLS-1$
|
||||
idToKeyword.put(ICEventBreakpoint.EVENT_TYPE_LIBRARY_UNLOAD, "unload"); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
public EventBreakpoint(Target target, String event, String arg, ICDICondition cond, boolean enabled) {
|
||||
super(target, ICBreakpointType.REGULAR, cond, enabled);
|
||||
this.eventType = event;
|
||||
|
@ -72,24 +47,7 @@ public class EventBreakpoint extends Breakpoint implements ICDIEventBreakpoint {
|
|||
* (e.g., "signal", "throw")
|
||||
*/
|
||||
public String getGdbEvent() {
|
||||
return getGdbEventFromId(getEventType());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the gdb catchpoint keyword associated with the given event point
|
||||
* type id (e.g., "signal", "throw")
|
||||
*
|
||||
* @param eventTypeId
|
||||
* one of the EVENT_TYPE_XXXXX constants from
|
||||
* {@link ICEventBreakpoint}
|
||||
*
|
||||
* @since 7.0
|
||||
*/
|
||||
public static String getGdbEventFromId(String eventTypeId) {
|
||||
String key= idToKeyword.get(eventTypeId);
|
||||
if (key!=null) return key;
|
||||
assert false : "Unexpected even breakpoint type ID: " + eventTypeId; //$NON-NLS-1$
|
||||
return "unknown"; //$NON-NLS-1$
|
||||
return GdbCatchpoints.eventToGdbCatchpointKeyword(getEventType());
|
||||
}
|
||||
|
||||
public String getGdbArg() {
|
||||
|
@ -116,24 +74,18 @@ public class EventBreakpoint extends Breakpoint implements ICDIEventBreakpoint {
|
|||
* @return null if unknown type, null cannot be used to create valid EventBreakpoint
|
||||
*/
|
||||
public static String getEventTypeFromMI(MIBreakpoint miBreakpoint) {
|
||||
// Two exceptions to how the message is typically formatted
|
||||
if (miBreakpoint.getWhat().equals("exception catch")) { //$NON-NLS-1$
|
||||
return ICEventBreakpoint.EVENT_TYPE_CATCH;
|
||||
return IEventBreakpointConstants.EVENT_TYPE_CATCH;
|
||||
} else if (miBreakpoint.getWhat().equals("exception throw")) { //$NON-NLS-1$
|
||||
return ICEventBreakpoint.EVENT_TYPE_THROW;
|
||||
} else if (miBreakpoint.getType().equals("catch signal")) { //$NON-NLS-1$
|
||||
// catch signal does not work in gdb
|
||||
return ICEventBreakpoint.EVENT_TYPE_SIGNAL_CATCH;
|
||||
}
|
||||
return IEventBreakpointConstants.EVENT_TYPE_THROW;
|
||||
}
|
||||
|
||||
String miType = miBreakpoint.getType();
|
||||
String prefix = "catch "; //$NON-NLS-1$
|
||||
if (miType.startsWith(prefix)) {
|
||||
String key = miType.substring(prefix.length());
|
||||
for (String id : idToKeyword.keySet()) {
|
||||
String etype = idToKeyword.get(id);
|
||||
if (key.equals(etype)) {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
final String PREFIX = "catch "; //$NON-NLS-1$
|
||||
if (miType.startsWith(PREFIX)) {
|
||||
String keyword = miType.substring(PREFIX.length());
|
||||
return GdbCatchpoints.gdbCatchpointKeywordToEvent(keyword);
|
||||
}
|
||||
return null; // not known/supported
|
||||
}
|
||||
|
|
|
@ -21,24 +21,3 @@ TargetOptionsPage.label=GDB/MI Options
|
|||
|
||||
VerboseMode.label=Verbose Mode
|
||||
VerboseMode.tooltip=Verbose Mode For gdb Console
|
||||
|
||||
|
||||
catchType.label = Event Type
|
||||
catchSignal.label = Signal Caught
|
||||
catchSignal.arg.label = Signal Number
|
||||
catchCatch.label = Exception Caught
|
||||
catchThrow.label = Exception Thrown
|
||||
|
||||
#Note: fork, vfork and exec is not translatable words
|
||||
catchFork.label = Stop on fork
|
||||
catchVfork.label = Stop on vfork
|
||||
catchExec.label = Stop on exec
|
||||
|
||||
catchExit.label = Process exit
|
||||
catchStop.label = Process suspend
|
||||
catchStart.label = Process start
|
||||
catchThreadExit.label = Thread exit
|
||||
catchThreadStart.label = Thread start
|
||||
catchThreadJoin.label = Thread join
|
||||
catchLoad.label = Library load
|
||||
catchUnload.label = Library unload
|
||||
|
|
|
@ -84,58 +84,6 @@
|
|||
</enablement>
|
||||
</consolePageParticipant>
|
||||
</extension>
|
||||
|
||||
<extension point="org.eclipse.cdt.debug.ui.breakpointContribution">
|
||||
<breakpointLabels markerType="org.eclipse.cdt.debug.core.cEventBreakpointMarker">
|
||||
<attribute name="org.eclipse.cdt.debug.core.eventbreakpoint_event_id" label="%catchType.label" type="string">
|
||||
<value value="org.eclipse.cdt.debug.gdb.catch" label="%catchCatch.label">
|
||||
</value>
|
||||
<value value="org.eclipse.cdt.debug.gdb.throw" label="%catchThrow.label"/>
|
||||
<value value="org.eclipse.cdt.debug.gdb.signal" label="%catchSignal.label">
|
||||
<attribute name="org.eclipse.cdt.debug.core.eventbreakpoint_event_arg" label="%catchSignal.arg.label"
|
||||
type="integer" fieldEditor="org.eclipse.jface.preference.IntegerFieldEditor">
|
||||
</attribute>
|
||||
</value>
|
||||
<value
|
||||
label="%catchFork.label"
|
||||
value="org.eclipse.cdt.debug.gdb.catch_fork">
|
||||
</value>
|
||||
<value
|
||||
label="%catchVfork.label"
|
||||
value="org.eclipse.cdt.debug.gdb.catch_vfork">
|
||||
</value>
|
||||
<value
|
||||
label="%catchExec.label"
|
||||
value="org.eclipse.cdt.debug.gdb.catch_exec">
|
||||
</value>
|
||||
<value label="%catchExit.label"
|
||||
value="org.eclipse.cdt.debug.gdb.catch_exit">
|
||||
</value>
|
||||
<value label="%catchStop.label"
|
||||
value="org.eclipse.cdt.debug.gdb.catch_stop">
|
||||
</value>
|
||||
<value label="%catchStart.label"
|
||||
value="org.eclipse.cdt.debug.gdb.catch_start">
|
||||
</value>
|
||||
<value label="%catchThreadStart.label"
|
||||
value="org.eclipse.cdt.debug.gdb.catch_thread_start">
|
||||
</value>
|
||||
<value label="%catchThreadExit.label"
|
||||
value="org.eclipse.cdt.debug.gdb.catch_thread_exit">
|
||||
</value>
|
||||
<value label="%catchThreadJoin.label"
|
||||
value="org.eclipse.cdt.debug.gdb.catch_thread_join">
|
||||
</value>
|
||||
<value label="%catchLoad.label"
|
||||
value="org.eclipse.cdt.debug.gdb.catch_load">
|
||||
</value>
|
||||
<value label="%catchUnload.label"
|
||||
value="org.eclipse.cdt.debug.gdb.catch_unload">
|
||||
</value>
|
||||
</attribute>
|
||||
</breakpointLabels>
|
||||
</extension>
|
||||
|
||||
<extension
|
||||
point="org.eclipse.ui.activities">
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@ Bundle-Name: org.eclipse.cdt.debug.ui.tests
|
|||
Bundle-SymbolicName: org.eclipse.cdt.debug.ui.tests;singleton:=true
|
||||
Bundle-Version: 6.0.0.qualifier
|
||||
Bundle-Activator: org.eclipse.core.internal.compatibility.PluginActivator
|
||||
Bundle-Localization: plugin
|
||||
Export-Package: org.eclipse.cdt.debug.core.tests,
|
||||
org.eclipse.cdt.debug.testplugin,
|
||||
org.eclipse.cdt.debug.testplugin.util
|
||||
|
@ -15,7 +14,8 @@ Require-Bundle: org.eclipse.ui.ide,
|
|||
org.eclipse.cdt.debug.mi.core,
|
||||
org.eclipse.cdt.core,
|
||||
org.eclipse.ui,
|
||||
org.eclipse.core.runtime.compatibility
|
||||
org.eclipse.core.runtime.compatibility,
|
||||
org.eclipse.cdt.gdb;bundle-version="7.0.0"
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Plugin-Class: org.eclipse.cdt.debug.testplugin.CTestPlugin
|
||||
Bundle-Vendor: Eclipse CDT
|
||||
|
|
|
@ -21,8 +21,8 @@ import org.eclipse.cdt.debug.core.cdi.model.ICDIBreakpoint;
|
|||
import org.eclipse.cdt.debug.core.cdi.model.ICDIBreakpointManagement3;
|
||||
import org.eclipse.cdt.debug.core.cdi.model.ICDIEventBreakpoint;
|
||||
import org.eclipse.cdt.debug.core.model.ICBreakpointType;
|
||||
import org.eclipse.cdt.debug.core.model.ICEventBreakpoint;
|
||||
import org.eclipse.cdt.debug.mi.core.MIException;
|
||||
import org.eclipse.cdt.gdb.eventbkpts.IEventBreakpointConstants;
|
||||
|
||||
public class EventBreakpointTests extends AbstractDebugTest {
|
||||
public static Test suite() {
|
||||
|
@ -52,11 +52,11 @@ public class EventBreakpointTests extends AbstractDebugTest {
|
|||
|
||||
|
||||
public void testCatch() throws CModelException, IOException, MIException, CDIException {
|
||||
eventbreakpoints(ICEventBreakpoint.EVENT_TYPE_CATCH, "");
|
||||
eventbreakpoints(IEventBreakpointConstants.EVENT_TYPE_CATCH, "");
|
||||
}
|
||||
|
||||
public void testThrow() throws CModelException, IOException, MIException, CDIException {
|
||||
eventbreakpoints(ICEventBreakpoint.EVENT_TYPE_THROW, "");
|
||||
eventbreakpoints(IEventBreakpointConstants.EVENT_TYPE_THROW, "");
|
||||
}
|
||||
|
||||
private void eventbreakpoints(String type, String arg) throws CModelException, IOException, MIException, CDIException {
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -13,7 +13,8 @@ Require-Bundle: org.eclipse.core.runtime,
|
|||
org.eclipse.cdt.debug.core,
|
||||
org.eclipse.core.variables,
|
||||
org.eclipse.jface,
|
||||
org.eclipse.cdt.launch;bundle-version="6.1.0"
|
||||
org.eclipse.cdt.launch;bundle-version="6.1.0",
|
||||
org.eclipse.cdt.gdb;bundle-version="7.0.0"
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Bundle-RequiredExecutionEnvironment: J2SE-1.5
|
||||
Export-Package: org.eclipse.cdt.dsf.gdb,
|
||||
|
|
|
@ -66,6 +66,7 @@ import org.eclipse.cdt.dsf.mi.service.command.events.MIWatchpointTriggerEvent;
|
|||
import org.eclipse.cdt.dsf.service.AbstractDsfService;
|
||||
import org.eclipse.cdt.dsf.service.DsfServiceEventHandler;
|
||||
import org.eclipse.cdt.dsf.service.DsfSession;
|
||||
import org.eclipse.cdt.gdb.internal.eventbkpts.GdbCatchpoints;
|
||||
import org.eclipse.core.resources.IMarker;
|
||||
import org.eclipse.core.resources.IMarkerDelta;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
|
@ -109,30 +110,6 @@ public class MIBreakpointsManager extends AbstractDsfService implements IBreakpo
|
|||
IBreakpoints fBreakpoints;
|
||||
IBreakpointManager fBreakpointManager; // Platform breakpoint manager (not this!)
|
||||
BreakpointActionManager fBreakpointActionManager;
|
||||
|
||||
/**
|
||||
* A mapping of ICEventBreakpoint event types to their corresponding gdb
|
||||
* catchpoint keyword (as listed in gdb's 'help catch')
|
||||
*/
|
||||
private static final Map<String, String> sEventBkptTypeToGdb = new HashMap<String, String>();
|
||||
static {
|
||||
// these Ids are also referenced in mi.ui plugin as contribution
|
||||
// to event breakpoints selector
|
||||
sEventBkptTypeToGdb.put(ICEventBreakpoint.EVENT_TYPE_CATCH, "catch"); //$NON-NLS-1$
|
||||
sEventBkptTypeToGdb.put(ICEventBreakpoint.EVENT_TYPE_THROW, "throw"); //$NON-NLS-1$
|
||||
sEventBkptTypeToGdb.put(ICEventBreakpoint.EVENT_TYPE_SIGNAL_CATCH, "signal"); //$NON-NLS-1$
|
||||
sEventBkptTypeToGdb.put(ICEventBreakpoint.EVENT_TYPE_EXEC, "exec"); //$NON-NLS-1$
|
||||
sEventBkptTypeToGdb.put(ICEventBreakpoint.EVENT_TYPE_FORK, "fork"); //$NON-NLS-1$
|
||||
sEventBkptTypeToGdb.put(ICEventBreakpoint.EVENT_TYPE_VFORK, "vfork"); //$NON-NLS-1$
|
||||
sEventBkptTypeToGdb.put(ICEventBreakpoint.EVENT_TYPE_EXIT, "exit"); //$NON-NLS-1$
|
||||
sEventBkptTypeToGdb.put(ICEventBreakpoint.EVENT_TYPE_PROCESS_START, "start"); //$NON-NLS-1$
|
||||
sEventBkptTypeToGdb.put(ICEventBreakpoint.EVENT_TYPE_PROCESS_STOP, "stop"); //$NON-NLS-1$
|
||||
sEventBkptTypeToGdb.put(ICEventBreakpoint.EVENT_TYPE_THREAD_START, "thread_start"); //$NON-NLS-1$
|
||||
sEventBkptTypeToGdb.put(ICEventBreakpoint.EVENT_TYPE_THREAD_EXIT, "thread_exit"); //$NON-NLS-1$
|
||||
sEventBkptTypeToGdb.put(ICEventBreakpoint.EVENT_TYPE_THREAD_JOIN, "thread_join"); //$NON-NLS-1$
|
||||
sEventBkptTypeToGdb.put(ICEventBreakpoint.EVENT_TYPE_LIBRARY_LOAD, "load"); //$NON-NLS-1$
|
||||
sEventBkptTypeToGdb.put(ICEventBreakpoint.EVENT_TYPE_LIBRARY_UNLOAD, "unload"); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Breakpoints tracking
|
||||
|
@ -1701,7 +1678,7 @@ public class MIBreakpointsManager extends AbstractDsfService implements IBreakpo
|
|||
}
|
||||
else if (breakpoint instanceof ICEventBreakpoint) {
|
||||
properties.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.CATCHPOINT);
|
||||
properties.put(MIBreakpoints.CATCHPOINT_TYPE, sEventBkptTypeToGdb.get(attributes.get(ICEventBreakpoint.EVENT_TYPE_ID)));
|
||||
properties.put(MIBreakpoints.CATCHPOINT_TYPE, GdbCatchpoints.eventToGdbCatchpointKeyword((String)attributes.get(ICEventBreakpoint.EVENT_TYPE_ID)));
|
||||
|
||||
String arg = (String)attributes.get(ICEventBreakpoint.EVENT_ARG);
|
||||
String[] args;
|
||||
|
|
|
@ -13,7 +13,8 @@ Require-Bundle: org.eclipse.core.runtime,
|
|||
org.eclipse.debug.core,
|
||||
org.eclipse.swt,
|
||||
org.eclipse.cdt.dsf.gdb,
|
||||
org.eclipse.cdt.launch;bundle-version="6.1.0"
|
||||
org.eclipse.cdt.launch;bundle-version="6.1.0",
|
||||
org.eclipse.cdt.gdb;bundle-version="7.0.0"
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Bundle-RequiredExecutionEnvironment: J2SE-1.5
|
||||
Bundle-ClassPath: .
|
||||
|
|
|
@ -13,6 +13,7 @@ package org.eclipse.cdt.tests.dsf.gdb.tests;
|
|||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.math.BigInteger;
|
||||
|
@ -51,6 +52,8 @@ import org.eclipse.cdt.dsf.mi.service.command.events.MIStoppedEvent;
|
|||
import org.eclipse.cdt.dsf.service.DsfServiceEventHandler;
|
||||
import org.eclipse.cdt.dsf.service.DsfServicesTracker;
|
||||
import org.eclipse.cdt.dsf.service.DsfSession;
|
||||
import org.eclipse.cdt.gdb.eventbkpts.IEventBreakpointConstants;
|
||||
import org.eclipse.cdt.gdb.internal.eventbkpts.GdbCatchpoints;
|
||||
import org.eclipse.cdt.tests.dsf.gdb.framework.AsyncCompletionWaitor;
|
||||
import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner;
|
||||
import org.eclipse.cdt.tests.dsf.gdb.framework.BaseTestCase;
|
||||
|
@ -1191,6 +1194,20 @@ public class MICatchpointsTest extends BaseTestCase {
|
|||
resumeAndExpectBkptHit(throwCatchpointNumber, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test some utiility methods we use to convert between event breakpoint ids
|
||||
* and gdb catchpoint keywords
|
||||
*/
|
||||
@Test
|
||||
public void catchpointConversions() throws Throwable {
|
||||
assertEquals("catch", GdbCatchpoints.eventToGdbCatchpointKeyword(IEventBreakpointConstants.EVENT_TYPE_CATCH));
|
||||
assertEquals("signal", GdbCatchpoints.eventToGdbCatchpointKeyword(IEventBreakpointConstants.EVENT_TYPE_SIGNAL_CATCH));
|
||||
assertEquals(IEventBreakpointConstants.EVENT_TYPE_CATCH, GdbCatchpoints.gdbCatchpointKeywordToEvent("catch"));
|
||||
assertEquals(IEventBreakpointConstants.EVENT_TYPE_SIGNAL_CATCH, GdbCatchpoints.gdbCatchpointKeywordToEvent("signal"));
|
||||
assertNull(GdbCatchpoints.gdbCatchpointKeywordToEvent("signa"));
|
||||
assertNull(GdbCatchpoints.gdbCatchpointKeywordToEvent("signals"));
|
||||
}
|
||||
|
||||
/**
|
||||
* This method allows the while-target-running tests to side-step a bug in
|
||||
* Windows gdb. To perform a breakpoint operation while the target is
|
||||
|
|
Loading…
Add table
Reference in a new issue