mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-09-10 12:03:16 +02:00
[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
This commit is contained in:
parent
30dffe83b5
commit
d42788838e
4 changed files with 30 additions and 63 deletions
|
@ -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.EventBreakpoint;
|
||||||
import org.eclipse.cdt.debug.mi.core.cdi.model.Target;
|
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.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.MIErrorEvent;
|
||||||
import org.eclipse.cdt.debug.mi.core.event.MIEvent;
|
import org.eclipse.cdt.debug.mi.core.event.MIEvent;
|
||||||
import org.eclipse.cdt.debug.mi.core.event.MIFunctionFinishedEvent;
|
import org.eclipse.cdt.debug.mi.core.event.MIFunctionFinishedEvent;
|
||||||
|
@ -54,14 +53,11 @@ public class SuspendedEvent implements ICDISuspendedEvent {
|
||||||
|
|
||||||
public ICDISessionObject getReason() {
|
public ICDISessionObject getReason() {
|
||||||
if (event instanceof MIBreakpointHitEvent) {
|
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();
|
BreakpointManager bkptMgr = session.getBreakpointManager();
|
||||||
Breakpoint bkpt = bkptMgr.getBreakpoint(event.getMISession(), ((MIBreakpointHitEvent)event).getNumber());
|
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) {
|
if (bkpt instanceof EventBreakpoint) {
|
||||||
return new EventBreakpointHit(session, EventBreakpoint.getGdbEventFromId(((EventBreakpoint)bkpt).getEventType()));
|
return new EventBreakpointHit(session, EventBreakpoint.getGdbEventFromId(((EventBreakpoint)bkpt).getEventType()));
|
||||||
}
|
}
|
||||||
|
@ -84,9 +80,6 @@ public class SuspendedEvent implements ICDISuspendedEvent {
|
||||||
return new ErrorInfo(session, (MIErrorEvent)event);
|
return new ErrorInfo(session, (MIErrorEvent)event);
|
||||||
} else if (event instanceof MISharedLibEvent) {
|
} else if (event instanceof MISharedLibEvent) {
|
||||||
return new SharedLibraryEvent(session);
|
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;
|
return session;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ import java.io.OutputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
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.CLICommand;
|
||||||
import org.eclipse.cdt.debug.mi.core.command.Command;
|
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.MIExecUntil;
|
||||||
import org.eclipse.cdt.debug.mi.core.command.MIInterpreterExecConsole;
|
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.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.MIErrorEvent;
|
||||||
import org.eclipse.cdt.debug.mi.core.event.MIEvent;
|
import org.eclipse.cdt.debug.mi.core.event.MIEvent;
|
||||||
import org.eclipse.cdt.debug.mi.core.event.MIFunctionFinishedEvent;
|
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
|
// 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,
|
// Hopefully this will be fixed in a future version. Meanwhile,
|
||||||
// we will use a hack to cope. On most platform we can detect by
|
// 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
|
// looking at the console stream for phrase. Although it is a
|
||||||
|
@ -319,17 +319,18 @@ public class RxThread extends Thread {
|
||||||
list.add(e);
|
list.add(e);
|
||||||
}
|
}
|
||||||
else if (logs[i].startsWith("Catchpoint ")) { //$NON-NLS-1$
|
else if (logs[i].startsWith("Catchpoint ")) { //$NON-NLS-1$
|
||||||
// Example: "Catchpoint 1 (exception caught)"
|
|
||||||
session.getMIInferior().setSuspended();
|
session.getMIInferior().setSuspended();
|
||||||
String log = logs[i];
|
|
||||||
String catchpointType = "???"; //$NON-NLS-1$
|
// Example: "Catchpoint 1 (exception caught)"
|
||||||
int startIndex = log.lastIndexOf('(');
|
StringTokenizer tokenizer = new StringTokenizer(logs[i]);
|
||||||
int stopIndex = log.lastIndexOf(')');
|
tokenizer.nextToken(); // "Catchpoint"
|
||||||
if ((startIndex >= 0) && (stopIndex >= 0) && (stopIndex > startIndex)) {
|
try {
|
||||||
catchpointType = log.substring(startIndex+1, stopIndex);
|
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,6 +38,21 @@ public class MIBreakpointHitEvent extends MIStoppedEvent {
|
||||||
parse();
|
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() {
|
public int getNumber() {
|
||||||
return bkptno;
|
return bkptno;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Add table
Reference in a new issue