1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-12 10:45:37 +02:00

[303569] Debug view does not reveal reason when thread is stopped by event breakpoint

This commit is contained in:
John Cortell 2010-02-23 00:23:59 +00:00
parent 1d80af0b96
commit 1e9d430245
8 changed files with 129 additions and 12 deletions

View file

@ -0,0 +1,24 @@
/*******************************************************************************
* 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.core.cdi;
/**
* Represents an information provided by the session when the program is
* stopped by an event breakpoint
* @since 7.0
*/
public interface ICDIEventBreakpointHit extends ICDISessionObject {
/**
* Return the type of event breakpoint, as reported by the debugger backend
* (e.g., gdb) when it reports the target suspended
*/
String getEventBreakpointType();
}

View file

@ -35,6 +35,7 @@ import org.eclipse.cdt.debug.core.cdi.ICDIAddressLocation;
import org.eclipse.cdt.debug.core.cdi.ICDIBreakpointHit;
import org.eclipse.cdt.debug.core.cdi.ICDIEndSteppingRange;
import org.eclipse.cdt.debug.core.cdi.ICDIErrorInfo;
import org.eclipse.cdt.debug.core.cdi.ICDIEventBreakpointHit;
import org.eclipse.cdt.debug.core.cdi.ICDIFunctionLocation;
import org.eclipse.cdt.debug.core.cdi.ICDILineLocation;
import org.eclipse.cdt.debug.core.cdi.ICDILocation;
@ -1164,6 +1165,9 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
else if ( reason instanceof ICDISharedLibraryEvent ) {
handleSuspendedBySolibEvent( (ICDISharedLibraryEvent)reason );
}
else if ( reason instanceof ICDIEventBreakpointHit ) {
handleEventBreakpointHit( (ICDIEventBreakpointHit)reason );
}
else { // reason is not specified
fireSuspendEvent( DebugEvent.UNSPECIFIED );
}
@ -1207,6 +1211,10 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
fireSuspendEvent( DebugEvent.BREAKPOINT );
}
private void handleEventBreakpointHit( ICDIEventBreakpointHit breakpointHit ) {
fireSuspendEvent( DebugEvent.BREAKPOINT );
}
private void handleWatchpointTrigger( ICDIWatchpointTrigger wt ) {
fireSuspendEvent( DebugEvent.BREAKPOINT );
}

View file

@ -0,0 +1,31 @@
/*******************************************************************************
* 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.cdi;
import org.eclipse.cdt.debug.core.cdi.ICDIEventBreakpointHit;
import org.eclipse.cdt.debug.mi.core.event.MICatchpointHitEvent;
/**
* @since 6.1
*/
public class EventBreakpointHit extends SessionObject implements ICDIEventBreakpointHit {
MICatchpointHitEvent fMiEvent;
public EventBreakpointHit(Session session, MICatchpointHitEvent miEvent) {
super(session);
fMiEvent = miEvent;
}
public String getEventBreakpointType() {
return fMiEvent.getCatchpointType();
}
}

View file

@ -16,6 +16,7 @@ import org.eclipse.cdt.debug.core.cdi.model.ICDIObject;
import org.eclipse.cdt.debug.mi.core.cdi.BreakpointHit;
import org.eclipse.cdt.debug.mi.core.cdi.EndSteppingRange;
import org.eclipse.cdt.debug.mi.core.cdi.ErrorInfo;
import org.eclipse.cdt.debug.mi.core.cdi.EventBreakpointHit;
import org.eclipse.cdt.debug.mi.core.cdi.FunctionFinished;
import org.eclipse.cdt.debug.mi.core.cdi.Session;
import org.eclipse.cdt.debug.mi.core.cdi.SharedLibraryEvent;
@ -24,6 +25,7 @@ import org.eclipse.cdt.debug.mi.core.cdi.WatchpointScope;
import org.eclipse.cdt.debug.mi.core.cdi.WatchpointTrigger;
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;
@ -66,6 +68,8 @@ 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) {
return new EventBreakpointHit(session, (MICatchpointHitEvent)event);
}
return session;
}

View file

@ -32,6 +32,7 @@ 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,13 +305,13 @@ public class RxThread extends Thread {
}
}
// GDB does not have reason when stopping on shared, hopefully
// this will be fix in newer version meanwhile, we will use a hack
// to cope. On most platform we can detect by looking at the
// console stream for phrase:
// ~"Stopped due to shared library event\n"
// GDB does not provide reason when stopping on a shared library
// event or because of a catchpoint. 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.
//
// Althought it is a _real_ bad idea to do this, we do not have
// Although it is a _real_ bad idea to do this, we do not have
// any other alternatives.
if (list.isEmpty()) {
String[] logs = getStreamRecords();
@ -320,6 +321,19 @@ public class RxThread extends Thread {
MIEvent e = new MISharedLibEvent(session, exec);
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);
}
MIEvent e = new MICatchpointHitEvent(session, exec, catchpointType);
list.add(e);
}
}
}

View file

@ -0,0 +1,31 @@
/*******************************************************************************
* 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 6.1
*/
public class MICatchpointHitEvent extends MIStoppedEvent {
private String fCatchpointType;
public MICatchpointHitEvent(MISession source, MIExecAsyncOutput async, String catchpointType) {
super(source, async);
fCatchpointType = catchpointType;
}
public String getCatchpointType() {
return fCatchpointType;
}
}

View file

@ -24,6 +24,7 @@ import org.eclipse.cdt.core.resources.FileStorage;
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
import org.eclipse.cdt.debug.core.CDebugUtils;
import org.eclipse.cdt.debug.core.cdi.ICDIBreakpointHit;
import org.eclipse.cdt.debug.core.cdi.ICDIEventBreakpointHit;
import org.eclipse.cdt.debug.core.cdi.ICDIExitInfo;
import org.eclipse.cdt.debug.core.cdi.ICDISharedLibraryEvent;
import org.eclipse.cdt.debug.core.cdi.ICDISignalExitInfo;
@ -705,22 +706,25 @@ public class CDebugModelPresentation extends LabelProvider implements IDebugMode
ICDebugElement element = (ICDebugElement)thread.getAdapter( ICDebugElement.class );
if ( element != null ) {
Object info = element.getCurrentStateInfo();
if ( info != null && info instanceof ICDISignalReceived ) {
if ( info instanceof ICDISignalReceived ) {
ICDISignal signal = ((ICDISignalReceived)info).getSignal();
reason = MessageFormat.format( CDebugUIMessages.getString( "CDTDebugModelPresentation.13" ), new String[]{ signal.getName(), signal.getDescription() } ); //$NON-NLS-1$
}
else if ( info != null && info instanceof ICDIWatchpointTrigger ) {
else if ( info instanceof ICDIWatchpointTrigger ) {
reason = MessageFormat.format( CDebugUIMessages.getString( "CDTDebugModelPresentation.14" ), new String[]{ ((ICDIWatchpointTrigger)info).getOldValue(), ((ICDIWatchpointTrigger)info).getNewValue() } ); //$NON-NLS-1$
}
else if ( info != null && info instanceof ICDIWatchpointScope ) {
else if ( info instanceof ICDIWatchpointScope ) {
reason = CDebugUIMessages.getString( "CDTDebugModelPresentation.15" ); //$NON-NLS-1$
}
else if ( info != null && info instanceof ICDIBreakpointHit ) {
else if ( info instanceof ICDIBreakpointHit ) {
reason = CDebugUIMessages.getString( "CDTDebugModelPresentation.16" ); //$NON-NLS-1$
}
else if ( info != null && info instanceof ICDISharedLibraryEvent ) {
else if ( info instanceof ICDISharedLibraryEvent ) {
reason = CDebugUIMessages.getString( "CDTDebugModelPresentation.17" ); //$NON-NLS-1$
}
else if ( info instanceof ICDIEventBreakpointHit ) {
reason = MessageFormat.format( CDebugUIMessages.getString( "CDTDebugModelPresentation.20" ), new String[]{ ((ICDIEventBreakpointHit)info).getEventBreakpointType() } ); //$NON-NLS-1$
}
}
return MessageFormat.format( CDebugUIMessages.getString( "CDTDebugModelPresentation.18" ), new String[] { thread.getName(), reason } ); //$NON-NLS-1$
}

View file

@ -25,6 +25,7 @@ CDTDebugModelPresentation.9=Thread [{0}] (Terminated)
CDTDebugModelPresentation.4=<Error. {0}>
CDTDebugModelPresentation.10=Thread [{0}] (Stepping)
CDTDebugModelPresentation.11=Thread [{0}] (Running)
CDTDebugModelPresentation.12=signal
CDTDebugModelPresentation.13=: Signal ''{0}'' received. Description: {1}.
CDTDebugModelPresentation.14=: Watchpoint triggered. Old value: ''{0}''. New value: ''{1}''.
CDTDebugModelPresentation.15=: Watchpoint is out of scope.
@ -32,7 +33,7 @@ CDTDebugModelPresentation.16=: Breakpoint hit.
CDTDebugModelPresentation.17=: Shared library event.
CDTDebugModelPresentation.18=Thread [{0}] (Suspended{1})
CDTDebugModelPresentation.19=Thread [{0}]
CDTDebugModelPresentation.12=signal
CDTDebugModelPresentation.20=: Event breakpoint hit [{0}].
CDTDebugModelPresentation.21=<symbol is not available>
CDTDebugModelPresentation.22=(disabled)
CDTDebugModelPresentation.23=Infinity