mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Avoid gdb bug in StepIntoSelectionTests for gdb <= 7.3
When a breakpoint is set directly at the start of a function, and you step into that function, gdb <= 7.3 will generate a "stopped" event with two reason fields. The first to indicate that the step range ended and the other to indicate that a breakpoint was hit. While this is not really correct from gdb to include the same field twice in a single event, the implementation of MIRunControlEventProcessor_7_0 will generate two distinct MIStoppedEvent events. This confuses the step-into-selection mechanism, who will issue two finish/step-return instead of one. For all gdbs, we will have a test where the breakpoint is a not at the function entry. Then, for gdb > 7.3, we will have the same test but with the breakpoint at the function entry, to test that particular case. This case is known to be broken with gdb <= 7.3 (rather old) and will stay that way unless somebody feels like fixing it. So, for both: - atDoubleMethodStopAtBreakpoint - atDoubleMethodSkipBreakpoint I extracted the code in a common function which takes in parameter the line to set the breakpoint at. Change-Id: I2ae4bc527afe0ab195e9b066279ed92f74d652f3 Signed-off-by: Simon Marchi <simon.marchi@polymtl.ca> Reviewed-on: https://git.eclipse.org/r/38717 Tested-by: Hudson CI Reviewed-by: Marc Khouzam <marc.khouzam@ericsson.com> Tested-by: Marc Khouzam <marc.khouzam@ericsson.com>
This commit is contained in:
parent
b74feb2c3d
commit
1333b20ec5
2 changed files with 93 additions and 36 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2013 Ericsson and others.
|
* Copyright (c) 2013, 2014 Ericsson and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Alvaro Sanchez-Leon (Ericsson AB) - Support for Step into selection (bug 244865)
|
* Alvaro Sanchez-Leon (Ericsson AB) - Support for Step into selection (bug 244865)
|
||||||
|
* Simon Marchi (Ericsson) - Fix atDoubleMethod* tests for older gdb (<= 7.3)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.tests.dsf.gdb.tests;
|
package org.eclipse.cdt.tests.dsf.gdb.tests;
|
||||||
|
|
||||||
|
@ -36,6 +37,7 @@ import org.eclipse.cdt.tests.dsf.gdb.framework.BaseTestCase;
|
||||||
import org.eclipse.cdt.tests.dsf.gdb.framework.ServiceEventWaitor;
|
import org.eclipse.cdt.tests.dsf.gdb.framework.ServiceEventWaitor;
|
||||||
import org.eclipse.cdt.tests.dsf.gdb.framework.SyncUtil;
|
import org.eclipse.cdt.tests.dsf.gdb.framework.SyncUtil;
|
||||||
import org.eclipse.cdt.tests.dsf.gdb.launching.TestsPlugin;
|
import org.eclipse.cdt.tests.dsf.gdb.launching.TestsPlugin;
|
||||||
|
import org.junit.Ignore;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
|
@ -428,48 +430,84 @@ public class StepIntoSelectionTest extends BaseTestCase {
|
||||||
validateLocation(suspendedEvent, targetFunction.getElementName(), SRC_FILE, FOO_LINE, originalDepth + 1);
|
validateLocation(suspendedEvent, targetFunction.getElementName(), SRC_FILE, FOO_LINE, originalDepth + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void atDoubleMethodStopAtBreakpointCommon(int foo_line) throws Throwable {
|
||||||
|
MIStoppedEvent stoppedEvent = SyncUtil.runToLocation("doubleMethodTest");
|
||||||
|
int originalDepth = SyncUtil.getStackDepth(stoppedEvent.getDMContext());
|
||||||
|
|
||||||
|
// Set a breakpoint inside foo, which will hit before our
|
||||||
|
// StepInto is finished
|
||||||
|
SyncUtil.addBreakpoint(Integer.toString(foo_line));
|
||||||
|
|
||||||
|
FunctionDeclaration targetFunction = funcBar;
|
||||||
|
int line = stoppedEvent.getFrame().getLine() + 1; // The method to stepInto is one line below the start of the method
|
||||||
|
// StepInto the method
|
||||||
|
ISuspendedDMEvent suspendedEvent = triggerStepIntoSelection(stoppedEvent.getDMContext(), SRC_FILE,
|
||||||
|
line, targetFunction, false); // Set not to skip breakpoints, but it should have no effect
|
||||||
|
|
||||||
|
validateLocation(suspendedEvent, targetFunction.getElementName(), SRC_FILE, BAR_LINE, originalDepth + 1);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This test verifies that we will not stop at a breakpoint if it is in the middle
|
* This test verifies that we will not stop at a breakpoint if it is in the middle
|
||||||
* of the step-in operations when the run-to-line skip breakpoint option is not selected.
|
* of the step-in operations when the run-to-line skip breakpoint option is not selected.
|
||||||
|
*
|
||||||
|
* It is only enabled for gdb > 7.3. gdb <= 7.3 generates a stopped event with two
|
||||||
|
* reasons, resulting in two MIStoppedEvent in the step-into-selection machinery. Later
|
||||||
|
* gdbs generate a stopped event with only one reason, as they should.
|
||||||
|
*/
|
||||||
|
@Ignore
|
||||||
|
@Test
|
||||||
|
public void atDoubleMethodStopAtBreakpointFunctionEntry() throws Throwable {
|
||||||
|
atDoubleMethodStopAtBreakpointCommon(FOO_LINE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This test is just like atDoubleMethodStopAtBreakpointFunctionEntry, but avoids placing
|
||||||
|
* the breakpoint at the beginning of foo().
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void atDoubleMethodStopAtBreakpoint() throws Throwable {
|
public void atDoubleMethodStopAtBreakpoint() throws Throwable {
|
||||||
MIStoppedEvent stoppedEvent = SyncUtil.runToLocation("doubleMethodTest");
|
atDoubleMethodStopAtBreakpointCommon(FOO_LINE + 1);
|
||||||
int originalDepth = SyncUtil.getStackDepth(stoppedEvent.getDMContext());
|
}
|
||||||
|
|
||||||
// Set a breakpoint inside foo, which will hit before our
|
private void atDoubleMethodSkipBreakpointCommon(int foo_line) throws Throwable {
|
||||||
// StepInto is finished
|
MIStoppedEvent stoppedEvent = SyncUtil.runToLocation("doubleMethodTest");
|
||||||
SyncUtil.addBreakpoint(Integer.toString(FOO_LINE));
|
int originalDepth = SyncUtil.getStackDepth(stoppedEvent.getDMContext());
|
||||||
|
|
||||||
FunctionDeclaration targetFunction = funcBar;
|
// Set a breakpoint inside foo, which will hit before our
|
||||||
int line = stoppedEvent.getFrame().getLine() + 1; // The method to stepInto is one line below the start of the method
|
// StepInto is finished
|
||||||
// StepInto the method
|
SyncUtil.addBreakpoint(Integer.toString(foo_line));
|
||||||
ISuspendedDMEvent suspendedEvent = triggerStepIntoSelection(stoppedEvent.getDMContext(), SRC_FILE,
|
|
||||||
line, targetFunction, false); // Set not to skip breakpoints, but it should have no effect
|
|
||||||
|
|
||||||
validateLocation(suspendedEvent, targetFunction.getElementName(), SRC_FILE, BAR_LINE, originalDepth + 1);
|
FunctionDeclaration targetFunction = funcBar;
|
||||||
|
int line = stoppedEvent.getFrame().getLine() + 1; // The method to stepInto is one line below the start of the method
|
||||||
|
// StepInto the method
|
||||||
|
ISuspendedDMEvent suspendedEvent = triggerStepIntoSelection(stoppedEvent.getDMContext(), SRC_FILE,
|
||||||
|
line, targetFunction, true); // Set skip breakpoints, which should have non impact
|
||||||
|
|
||||||
|
validateLocation(suspendedEvent, targetFunction.getElementName(), SRC_FILE, BAR_LINE, originalDepth + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This test verifies that we will not stop at a breakpoint if it is in the middle
|
* This test verifies that we will not stop at a breakpoint if it is in the middle
|
||||||
* of the step-in operations even if the run-to-line skip breakpoint option is selected.
|
* of the step-in operations even if the run-to-line skip breakpoint option is selected.
|
||||||
|
*
|
||||||
|
* It is only enabled for gdb > 7.3. gdb <= 7.3 generates a stopped event with two
|
||||||
|
* reasons, resulting in two MIStoppedEvent in the step-into-selection machinery. Later
|
||||||
|
* gdbs generate a stopped event with only one reason, as they should.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
@Ignore
|
||||||
|
public void atDoubleMethodSkipBreakpointFunctionEntry() throws Throwable {
|
||||||
|
atDoubleMethodSkipBreakpointCommon(FOO_LINE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This test is just like atDoubleMethodSkipBreakpointFunctionEntry, but avoids placing
|
||||||
|
* the breakpoint at the beginning of foo().
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void atDoubleMethodSkipBreakpoint() throws Throwable {
|
public void atDoubleMethodSkipBreakpoint() throws Throwable {
|
||||||
MIStoppedEvent stoppedEvent = SyncUtil.runToLocation("doubleMethodTest");
|
atDoubleMethodSkipBreakpointCommon(FOO_LINE + 1);
|
||||||
int originalDepth = SyncUtil.getStackDepth(stoppedEvent.getDMContext());
|
|
||||||
|
|
||||||
// Set a breakpoint inside foo, which will hit before our
|
|
||||||
// StepInto is finished
|
|
||||||
SyncUtil.addBreakpoint(Integer.toString(FOO_LINE));
|
|
||||||
|
|
||||||
FunctionDeclaration targetFunction = funcBar;
|
|
||||||
int line = stoppedEvent.getFrame().getLine() + 1; // The method to stepInto is one line below the start of the method
|
|
||||||
// StepInto the method
|
|
||||||
ISuspendedDMEvent suspendedEvent = triggerStepIntoSelection(stoppedEvent.getDMContext(), SRC_FILE,
|
|
||||||
line, targetFunction, true); // Set skip breakpoints, which should have non impact
|
|
||||||
|
|
||||||
validateLocation(suspendedEvent, targetFunction.getElementName(), SRC_FILE, BAR_LINE, originalDepth + 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Marc Khouzam (Ericsson) - Support for Step into selection (bug 244865)
|
* Marc Khouzam (Ericsson) - Support for Step into selection (bug 244865)
|
||||||
|
* Simon Marchi (Ericsson) - Fix atDoubleMethod* tests for older gdb (<= 7.3)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_4;
|
package org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_4;
|
||||||
|
|
||||||
|
@ -14,12 +15,30 @@ import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner;
|
||||||
import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants;
|
import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants;
|
||||||
import org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_3.StepIntoSelectionTest_7_3;
|
import org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_3.StepIntoSelectionTest_7_3;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
@RunWith(BackgroundRunner.class)
|
@RunWith(BackgroundRunner.class)
|
||||||
public class StepIntoSelectionTest_7_4 extends StepIntoSelectionTest_7_3 {
|
public class StepIntoSelectionTest_7_4 extends StepIntoSelectionTest_7_3 {
|
||||||
@Override
|
@Override
|
||||||
protected void setGdbVersion() {
|
protected void setGdbVersion() {
|
||||||
setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_7_4);
|
setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_7_4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enable test for gdb >= 7.4.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Test
|
||||||
|
public void atDoubleMethodStopAtBreakpointFunctionEntry() throws Throwable {
|
||||||
|
super.atDoubleMethodStopAtBreakpointFunctionEntry();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enable test for gdb >= 7.4.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Test
|
||||||
|
public void atDoubleMethodSkipBreakpointFunctionEntry() throws Throwable {
|
||||||
|
super.atDoubleMethodSkipBreakpointFunctionEntry();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue