diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/data/launch/src/PatternMatchingExpressionsTestApp.cc b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/data/launch/src/PatternMatchingExpressionsTestApp.cc index de2cca25c85..09411f719a3 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/data/launch/src/PatternMatchingExpressionsTestApp.cc +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/data/launch/src/PatternMatchingExpressionsTestApp.cc @@ -13,7 +13,7 @@ int testArrayMatching() { int array[20]; int arrayInt[10]; bool arrayBool[20]; - int arrayNot,array2,array3; + int arrayNot=1,array2=2,array3=3; array[0] = 20; array[1] = 21; diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/framework/ServiceEventWaitor.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/framework/ServiceEventWaitor.java index b64c80f21f8..3acf3646c99 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/framework/ServiceEventWaitor.java +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/framework/ServiceEventWaitor.java @@ -205,8 +205,6 @@ public class ServiceEventWaitor { fEventQueue.add(event); notifyAll(); } - } else { - System.out.println("NOT QUEUEING: SevericeEventWaitor: Class: " + fEventTypeClass.getName() + " is NOT assignable from event class: " + event.getClass()); } } } diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/GDBPatternMatchingExpressionsTest.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/GDBPatternMatchingExpressionsTest.java index 5020794bf68..b1c2ed48009 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/GDBPatternMatchingExpressionsTest.java +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/GDBPatternMatchingExpressionsTest.java @@ -39,20 +39,22 @@ import org.eclipse.cdt.dsf.debug.service.IFormattedValues.FormattedValueDMData; import org.eclipse.cdt.dsf.debug.service.IRegisters; import org.eclipse.cdt.dsf.debug.service.IRegisters.IRegisterDMContext; import org.eclipse.cdt.dsf.debug.service.IRegisters.IRegisterGroupDMContext; +import org.eclipse.cdt.dsf.debug.service.IRunControl.IContainerDMContext; import org.eclipse.cdt.dsf.debug.service.IRunControl.StepType; import org.eclipse.cdt.dsf.debug.service.IStack.IFrameDMContext; import org.eclipse.cdt.dsf.mi.service.ClassAccessor.MIExpressionDMCAccessor; +import org.eclipse.cdt.dsf.mi.service.IMICommandControl; import org.eclipse.cdt.dsf.mi.service.IMIExecutionDMContext; import org.eclipse.cdt.dsf.mi.service.IMIExpressions; import org.eclipse.cdt.dsf.mi.service.MIRegisters.MIRegisterDMC; import org.eclipse.cdt.dsf.mi.service.command.events.MIStoppedEvent; +import org.eclipse.cdt.dsf.mi.service.command.output.MIDataListRegisterNamesInfo; import org.eclipse.cdt.dsf.service.DsfServicesTracker; import org.eclipse.cdt.dsf.service.DsfSession; import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner; import org.eclipse.cdt.tests.dsf.gdb.framework.BaseTestCase; import org.eclipse.cdt.tests.dsf.gdb.framework.SyncUtil; import org.eclipse.cdt.tests.dsf.gdb.launching.TestsPlugin; -import org.eclipse.core.runtime.Platform; import org.junit.Test; import org.junit.runner.RunWith; @@ -102,18 +104,44 @@ public class GDBPatternMatchingExpressionsTest extends BaseTestCase { // Utility methods //************************************************************************************** - protected List get_X86_REGS() { - // Because we are dealing with expressions for the registers, we must prefix them with '$' - List list = new LinkedList(Arrays.asList("$eax","$ecx","$edx","$ebx","$esp","$ebp","$esi","$edi","$eip","$eflags", - "$cs","$ss","$ds","$es","$fs","$gs","$st0","$st1","$st2","$st3", - "$st4","$st5","$st6","$st7","$fctrl","$fstat","$ftag","$fiseg","$fioff","$foseg", - "$fooff","$fop","$xmm0","$xmm1","$xmm2","$xmm3","$xmm4","$xmm5","$xmm6","$xmm7", - "$mxcsr","$orig_eax","$mm0","$mm1","$mm2","$mm3","$mm4","$mm5","$mm6","$mm7")); - // On Windows, gdb doesn't report "orig_eax" as a register. Apparently it does on Linux - if (Platform.getOS().equals(Platform.OS_WIN32)) { - list.remove("$orig_eax"); - } - return list; + // Static list of register names as obtained directly from GDB. + // We make it static so it does not get re-set for every test + protected static List fRegisterNames = null; + + protected List get_X86_REGS() throws Throwable { + + if (fRegisterNames == null) { + // The tests must run on different machines, so the set of registers can change. + // To deal with this we ask GDB for the list of registers. + // Note that we send an MI Command in this code and do not use the IRegister service; + // this is because we want to test the service later, comparing it to what we find + // by asking GDB directly. + final IContainerDMContext container = SyncUtil.getContainerContext(); + Query query = new Query() { + @Override + protected void execute(DataRequestMonitor rm) { + IMICommandControl controlService = fServicesTracker.getService(IMICommandControl.class); + controlService.queueCommand( + controlService.getCommandFactory().createMIDataListRegisterNames(container), rm); + } + }; + fSession.getExecutor().execute(query); + + MIDataListRegisterNamesInfo data = query.get(); + String[] names = data.getRegisterNames(); + + // Remove registers with empty names since the service also + // remove them. I don't know why GDB returns such empty names. + fRegisterNames = new LinkedList(); + for (String name : names) { + if (!name.isEmpty()) { + // Add the '$' prefix + fRegisterNames.add("$"+name); + } + } + } + // Return a copy since it will be modified by each test + return new LinkedList(fRegisterNames); } final static String[] fAllVariables = new String[] { "firstarg", "firstvar", "ptrvar", "secondarg", "secondvar", "var", "var2" }; @@ -376,8 +404,10 @@ public class GDBPatternMatchingExpressionsTest extends BaseTestCase { */ @Test public void testMatchRegWithStar() throws Throwable { - final String exprString = "=$e*"; - final String[] children = new String[] { "$eax","$ebp","$ebx","$ecx","$edi","$edx","$eflags","$eip","$es", "$esi","$esp" }; + // Add the $eip register first as it is present for 32bit but not 64bit machines. + // When we put it first like that, we force it to be included in the list all the time. + final String exprString = "$eip;=$e*"; + final String[] children = new String[] { "$eip","$eax","$ebp","$ebx","$ecx","$edi","$edx","$eflags","$es", "$esi","$esp" }; SyncUtil.runToLocation("foo"); MIStoppedEvent stoppedEvent = SyncUtil.step(5, StepType.STEP_OVER); @@ -492,8 +522,10 @@ public class GDBPatternMatchingExpressionsTest extends BaseTestCase { */ @Test public void testMatchRegWithQuestionMark() throws Throwable { - final String exprString = "=$e??"; - final String[] children = new String[] { "$eax","$ebp","$ebx","$ecx","$edi","$edx","$eip", "$esi","$esp" }; + // Add the $eip register first as it is present for 32bit but not 64bit machines. + // When we put it first like that, we force it to be included in the list all the time. + final String exprString = "$eip;=$e??"; + final String[] children = new String[] { "$eip","$eax","$ebp","$ebx","$ecx","$edi","$edx", "$esi","$esp" }; SyncUtil.runToLocation("foo"); MIStoppedEvent stoppedEvent = SyncUtil.step(5, StepType.STEP_OVER); diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_2/GDBPatternMatchingExpressionsTest_7_2.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_2/GDBPatternMatchingExpressionsTest_7_2.java index b4fafad52f3..0dffc7c628f 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_2/GDBPatternMatchingExpressionsTest_7_2.java +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_2/GDBPatternMatchingExpressionsTest_7_2.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2012 Ericsson and others. + * Copyright (c) 2012, 2013 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,14 +10,9 @@ *******************************************************************************/ package org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_2; -import java.util.Arrays; -import java.util.LinkedList; -import java.util.List; - 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.tests_7_1.GDBPatternMatchingExpressionsTest_7_1; -import org.eclipse.core.runtime.Platform; import org.junit.runner.RunWith; @RunWith(BackgroundRunner.class) @@ -26,23 +21,4 @@ public class GDBPatternMatchingExpressionsTest_7_2 extends GDBPatternMatchingExp protected void setGdbVersion() { setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_7_2); } - - // GDB's list of registers is different with GDB 7.2 - @Override - protected List get_X86_REGS() { - // Because we are dealing with expressions for the registers, we must prefix them with '$' - List list = new LinkedList(Arrays.asList("$eax","$ecx","$edx","$ebx","$esp","$ebp","$esi","$edi","$eip","$eflags", - "$cs","$ss","$ds","$es","$fs","$gs","$st0","$st1","$st2","$st3", - "$st4","$st5","$st6","$st7","$fctrl","$fstat","$ftag","$fiseg","$fioff","$foseg", - "$fooff","$fop","$xmm0","$xmm1","$xmm2","$xmm3","$xmm4","$xmm5","$xmm6","$xmm7", - "$mxcsr",/*"","","","","","","","",*/"$orig_eax", - "$al","$cl","$dl","$bl","$ah","$ch","$dh","$bh","$ax","$cx", - "$dx","$bx",/*"",*/"$bp","$si","$di","$mm0","$mm1","$mm2","$mm3", - "$mm4","$mm5","$mm6","$mm7")); - // On Windows, gdb doesn't report "orig_eax" as a register. Apparently it does on Linux - if (Platform.getOS().equals(Platform.OS_WIN32)) { - list.remove("$orig_eax"); - } - return list; - } }