Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Cortell2010-03-18 14:09:10 -0400
committerJohn Cortell2010-03-18 14:09:10 -0400
commitd42788838e685c1847ed000f264e2790e6d9f945 (patch)
tree9f15f0645898296d51dd0d29c325c8dc62014d78 /debug/org.eclipse.cdt.debug.mi.core
parent30dffe83b57d530fd113ed1f5e3e8fd9de47d515 (diff)
downloadorg.eclipse.cdt-d42788838e685c1847ed000f264e2790e6d9f945.tar.gz
org.eclipse.cdt-d42788838e685c1847ed000f264e2790e6d9f945.tar.xz
org.eclipse.cdt-d42788838e685c1847ed000f264e2790e6d9f945.zip
[303569] Realized there's no need for a catchpoint-hit object in order to support gdb < 7.0. We can use a breakpoint-hit one just with gdb >= 7.0
Diffstat (limited to 'debug/org.eclipse.cdt.debug.mi.core')
-rw-r--r--debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/event/SuspendedEvent.java13
-rw-r--r--debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/RxThread.java23
-rw-r--r--debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIBreakpointHitEvent.java15
-rw-r--r--debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MICatchpointHitEvent.java42
4 files changed, 30 insertions, 63 deletions
diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/event/SuspendedEvent.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/event/SuspendedEvent.java
index 57ab84504a..18e4caa9d3 100644
--- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/event/SuspendedEvent.java
+++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/event/SuspendedEvent.java
@@ -28,7 +28,6 @@ import org.eclipse.cdt.debug.mi.core.cdi.model.Breakpoint;
import org.eclipse.cdt.debug.mi.core.cdi.model.EventBreakpoint;
import org.eclipse.cdt.debug.mi.core.cdi.model.Target;
import org.eclipse.cdt.debug.mi.core.event.MIBreakpointHitEvent;
-import org.eclipse.cdt.debug.mi.core.event.MICatchpointHitEvent;
import org.eclipse.cdt.debug.mi.core.event.MIErrorEvent;
import org.eclipse.cdt.debug.mi.core.event.MIEvent;
import org.eclipse.cdt.debug.mi.core.event.MIFunctionFinishedEvent;
@@ -54,14 +53,11 @@ public class SuspendedEvent implements ICDISuspendedEvent {
public ICDISessionObject getReason() {
if (event instanceof MIBreakpointHitEvent) {
+ // A Catchpoint hit is reported by gdb as a breakpoint hit. We can
+ // tell it's a catchpoint by looking at why kind of CDT-created
+ // platform breakpoint is associated with it
BreakpointManager bkptMgr = session.getBreakpointManager();
Breakpoint bkpt = bkptMgr.getBreakpoint(event.getMISession(), ((MIBreakpointHitEvent)event).getNumber());
- // In versions prior to 7.0, a catchpoint (Event Breakpoint in
- // CDT speak) is reported by gdb as a generic stopped event; gdb
- // does not indicate it was caused by a breakpoint. In 7.0 and
- // above, it does. Here we handle the >= 7.0 case. In the < 7.0
- // case, we generate a MICatchpointHitEvent, and that's handled
- // below
if (bkpt instanceof EventBreakpoint) {
return new EventBreakpointHit(session, EventBreakpoint.getGdbEventFromId(((EventBreakpoint)bkpt).getEventType()));
}
@@ -84,9 +80,6 @@ public class SuspendedEvent implements ICDISuspendedEvent {
return new ErrorInfo(session, (MIErrorEvent)event);
} else if (event instanceof MISharedLibEvent) {
return new SharedLibraryEvent(session);
- } else if (event instanceof MICatchpointHitEvent) {
- // See note above. If we get here, we're dealing with a gdb < 7.0
- return new EventBreakpointHit(session, ((MICatchpointHitEvent)event).getCatchpointType());
}
return session;
}
diff --git a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/RxThread.java b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/RxThread.java
index 28417e95de..2687606e99 100644
--- a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/RxThread.java
+++ b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/RxThread.java
@@ -19,6 +19,7 @@ import java.io.OutputStream;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
+import java.util.StringTokenizer;
import org.eclipse.cdt.debug.mi.core.command.CLICommand;
import org.eclipse.cdt.debug.mi.core.command.Command;
@@ -32,7 +33,6 @@ import org.eclipse.cdt.debug.mi.core.command.MIExecStepInstruction;
import org.eclipse.cdt.debug.mi.core.command.MIExecUntil;
import org.eclipse.cdt.debug.mi.core.command.MIInterpreterExecConsole;
import org.eclipse.cdt.debug.mi.core.event.MIBreakpointHitEvent;
-import org.eclipse.cdt.debug.mi.core.event.MICatchpointHitEvent;
import org.eclipse.cdt.debug.mi.core.event.MIErrorEvent;
import org.eclipse.cdt.debug.mi.core.event.MIEvent;
import org.eclipse.cdt.debug.mi.core.event.MIFunctionFinishedEvent;
@@ -304,7 +304,7 @@ public class RxThread extends Thread {
}
// GDB does not provide reason when stopping on a shared library
- // event or because of a catchpoint (in some versions).
+ // event or because of a catchpoint (in gdb < 7.0).
// Hopefully this will be fixed in a future version. Meanwhile,
// we will use a hack to cope. On most platform we can detect by
// looking at the console stream for phrase. Although it is a
@@ -319,17 +319,18 @@ public class RxThread extends Thread {
list.add(e);
}
else if (logs[i].startsWith("Catchpoint ")) { //$NON-NLS-1$
- // Example: "Catchpoint 1 (exception caught)"
session.getMIInferior().setSuspended();
- String log = logs[i];
- String catchpointType = "???"; //$NON-NLS-1$
- int startIndex = log.lastIndexOf('(');
- int stopIndex = log.lastIndexOf(')');
- if ((startIndex >= 0) && (stopIndex >= 0) && (stopIndex > startIndex)) {
- catchpointType = log.substring(startIndex+1, stopIndex);
+
+ // Example: "Catchpoint 1 (exception caught)"
+ StringTokenizer tokenizer = new StringTokenizer(logs[i]);
+ tokenizer.nextToken(); // "Catchpoint"
+ try {
+ int bkptNumber = Integer.parseInt(tokenizer.nextToken()); // 1
+ list.add(new MIBreakpointHitEvent(session, exec, bkptNumber));
+ }
+ catch (NumberFormatException exc) {
+ assert false : "unexpected catchpoint stream record format: " + logs[i]; //$NON-NLS-1$
}
- MIEvent e = new MICatchpointHitEvent(session, exec, catchpointType);
- list.add(e);
}
}
}
diff --git a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIBreakpointHitEvent.java b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIBreakpointHitEvent.java
index 61f688fce8..3504357a1d 100644
--- a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIBreakpointHitEvent.java
+++ b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIBreakpointHitEvent.java
@@ -38,6 +38,21 @@ public class MIBreakpointHitEvent extends MIStoppedEvent {
parse();
}
+ /**
+ * This constructor is used for catchpoint hits with gdb < 7.0. In that
+ * environment, we have to get creative as gdb doesn't send us a reason with
+ * the stopped event. Fortunately, a stream record tells us the target has
+ * stopped because of a catchpoint and the associated breakpoint number.
+ *
+ * @since 7.0
+ */
+ public MIBreakpointHitEvent(MISession source, MIExecAsyncOutput record, int bkptNumber) {
+ super(source, record);
+ parse();
+ bkptno = bkptNumber;
+ assert bkptNumber > 0; // we know gdb bkpt numbers are 1-based
+ }
+
public int getNumber() {
return bkptno;
}
diff --git a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MICatchpointHitEvent.java b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MICatchpointHitEvent.java
deleted file mode 100644
index fae38e46ee..0000000000
--- a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MICatchpointHitEvent.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*******************************************************************************
- * 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.debug.mi.core.event;
-
-import org.eclipse.cdt.debug.mi.core.MISession;
-import org.eclipse.cdt.debug.mi.core.output.MIExecAsyncOutput;
-
-/**
- * @since 7.0
- */
-public class MICatchpointHitEvent extends MIStoppedEvent {
-
- /**
- * See catcpointType parameter in constructor
- */
- private String fCatchpointType;
-
- /**
- * @param source
- * @param async
- * @param catchpointType
- * the type of catchpoint as reported by gdb via the gdb console
- * when the catchpoint is hit. We parse the stream record to get
- * this.
- */
- public MICatchpointHitEvent(MISession source, MIExecAsyncOutput async, String catchpointType) {
- super(source, async);
- fCatchpointType = catchpointType;
- }
-
- public String getCatchpointType() {
- return fCatchpointType;
- }
-}

Back to the top