1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Patch for bugs 229486 and 229491

This commit is contained in:
Francois Chouinard 2008-04-30 20:01:31 +00:00
parent d36e8f3b7c
commit 159f480771
10 changed files with 326 additions and 260 deletions

View file

@ -538,7 +538,7 @@ public class DisassemblyDocument extends REDDocument {
* @return the document position or <code>null</code>
*/
protected Position getSourcePosition(SourceFileInfo info, int lineNumber) {
if (info == null) {
if (info == null || info.fSource == null) {
return null;
}
try {

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2007 Ericsson and others.
* Copyright (c) 2007, 2008 Ericsson 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
@ -448,6 +448,15 @@ public class MIBreakpoints extends AbstractDsfService implements IBreakpoints
} else {
location = fileName + ":" + function; //$NON-NLS-1$
}
} else if (!function.equals(NULL_STRING)) {
// function location without source
location = function;
} else if (location.length() > 0) {
// address location
if (Character.isDigit(location.charAt(0))) {
// numeric address needs '*' prefix
location = '*' + location;
}
}
return location;
@ -472,6 +481,13 @@ public class MIBreakpoints extends AbstractDsfService implements IBreakpoints
// Extract the relevant parameters (providing default values to avoid potential NPEs)
String location = formatLocation(attributes);
if (location.equals(NULL_STRING)) {
drm.setStatus(new Status(IStatus.ERROR, MIPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_BREAKPOINT_CONTEXT, null));
drm.done();
return;
}
Boolean isTemporary = (Boolean) getProperty(attributes, MIBreakpointDMData.IS_TEMPORARY, false);
Boolean isHardware = (Boolean) getProperty(attributes, MIBreakpointDMData.IS_HARDWARE, false);
final String condition = (String) getProperty(attributes, CONDITION, NULL_STRING);

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2007 Wind River and others.
* Copyright (c) 2007, 2008 Wind River 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
@ -27,6 +27,7 @@ import java.util.concurrent.RejectedExecutionException;
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
import org.eclipse.cdt.debug.core.breakpointactions.BreakpointActionManager;
import org.eclipse.cdt.debug.core.model.ICAddressBreakpoint;
import org.eclipse.cdt.debug.core.model.ICBreakpoint;
import org.eclipse.cdt.debug.core.model.ICBreakpointExtension;
import org.eclipse.cdt.debug.core.model.ICLineBreakpoint;
@ -516,7 +517,7 @@ public class MIBreakpointsManager extends AbstractDsfService implements IBreakpo
}
// Ensure the breakpoint has a valid debugger source path
if (!(breakpoint instanceof ICWatchpoint)) {
if (breakpoint instanceof ICLineBreakpoint && !(breakpoint instanceof ICAddressBreakpoint)) {
String debuggerPath = (String) attributes.get(ATTR_DEBUGGER_PATH);
if (debuggerPath == null || debuggerPath == NULL_STRING) {
rm.setStatus(new Status(IStatus.ERROR, MIPlugin.PLUGIN_ID, REQUEST_FAILED, NO_DEBUGGER_PATH, null));
@ -1530,13 +1531,15 @@ public class MIBreakpointsManager extends AbstractDsfService implements IBreakpo
properties.put(MIBreakpoints.READ, attributes.get(ICWatchpoint.READ));
properties.put(MIBreakpoints.WRITE, attributes.get(ICWatchpoint.WRITE));
}
else {
else if (breakpoint instanceof ICLineBreakpoint) {
// Convert the CDI breakpoint to an IBreakpoint
properties.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.BREAKPOINT);
properties.put(MIBreakpoints.FILE_NAME, attributes.get(ATTR_DEBUGGER_PATH));
properties.put(MIBreakpoints.LINE_NUMBER, attributes.get(IMarker.LINE_NUMBER));
properties.put(MIBreakpoints.FUNCTION, attributes.get(ICLineBreakpoint.FUNCTION));
properties.put(MIBreakpoints.ADDRESS, attributes.get(ICLineBreakpoint.ADDRESS));
} else {
// catchpoint?
}
// Common fields

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2007 Ericsson and others.
* Copyright (c) 2007, 2008 Ericsson 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
@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.dd.tests.gdb;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
@ -706,7 +707,7 @@ public class MIBreakpointsTest extends BaseTestCase {
// Create an address breakpoint
Map<String, Object> breakpoint = new HashMap<String, Object>();
breakpoint.put(BREAKPOINT_TYPE_TAG, BREAKPOINT_TAG);
breakpoint.put(ADDRESS_TAG, "0x0");
breakpoint.put(ADDRESS_TAG, "0x0z");
// Perform the test
String expected = BREAKPOINT_INSERTION_FAILURE;
@ -720,6 +721,52 @@ public class MIBreakpointsTest extends BaseTestCase {
+ fBreakpointEventCount, fBreakpointEventCount == 0);
}
// ------------------------------------------------------------------------
// insertBreakpoint_Address
// Set a breakpoint on an address
// Ensure that it is set correctly at the back-end.
// ------------------------------------------------------------------------
@Test
public void insertBreakpoint_Address() throws Throwable {
// Create an address breakpoint
Map<String, Object> breakpoint = new HashMap<String, Object>();
breakpoint.put(BREAKPOINT_TYPE_TAG, BREAKPOINT_TAG);
final BigInteger ADDRESS= new BigInteger("00affe00", 16);
breakpoint.put(ADDRESS_TAG, "0x"+ADDRESS.toString(16));
// Perform the test
IBreakpointDMContext ref = insertBreakpoint(fGdbControlDmc, breakpoint);
// Ensure that right BreakpointEvents were received
waitForBreakpointEvent();
assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT event(s), received "
+ fBreakpointEventCount, fBreakpointEventCount == 1);
assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT_ADDED event(s), received "
+ getBreakpointEventCount(BP_ADDED), getBreakpointEventCount(BP_ADDED) == 1);
clearEventCounters();
// Ensure that the breakpoint was correctly installed
MIBreakpointDMData breakpoint1 = (MIBreakpointDMData) getBreakpoint(ref);
assertEquals("BreakpointService problem: breakpoint mismatch (wrong address)",
breakpoint1.getAddresses()[0].getValue(), ADDRESS);
assertTrue("BreakpointService problem: breakpoint mismatch (wrong condition)",
breakpoint1.getCondition().equals(NO_CONDITION));
assertTrue("BreakpointService problem: breakpoint mismatch (wrong ignore count)",
breakpoint1.getIgnoreCount() == 0);
assertTrue("BreakpointService problem: breakpoint mismatch (wrong state)",
breakpoint1.isEnabled());
// Ensure the BreakpointService holds only the right breakpoints
IBreakpointDMContext[] breakpoints = getBreakpoints(fGdbControlDmc);
assertTrue("BreakpointService problem: expected " + 1 + " breakpoint(s), received "
+ breakpoints.length, breakpoints.length == 1);
MIBreakpointDMData breakpoint2 = (MIBreakpointDMData) getBreakpoint(breakpoints[0]);
assertTrue("BreakpointService problem: breakpoint mismatch",
breakpoint1.equals(breakpoint2));
}
// ------------------------------------------------------------------------
// insertBreakpoint_LineNumber
// Set a breakpoint on a line number.