Search in sources :

Example 1 with OpEvent

use of org.eclipse.linuxtools.internal.oprofile.core.daemon.OpEvent in project linuxtools by eclipse.

the class AbstractEventConfigTab method validateEvents.

/**
 * Validate events specified in the given configuration.
 * @param config
 * @return
 */
private boolean validateEvents(ILaunchConfiguration config) {
    int numEnabledEvents = 0;
    boolean valid = true;
    try {
        if (config.getAttribute(OprofileLaunchPlugin.ATTR_USE_DEFAULT_EVENT, false)) {
            numEnabledEvents = 1;
        } else {
            // This seems like an odd way to validate, but since most of the validation
            // is done with the OprofileDaemonEvent that the counter wraps, this
            // is the easiest way.
            OprofileCounter[] counters = new OprofileCounter[getNumberOfOprofileCounters()];
            for (int i = 0; i < counters.length; i++) {
                counters[i] = getOprofileCounter(i);
                counters[i].loadConfiguration(config);
                for (CounterSubTab counterSubTab : counterSubTabs) {
                    int nr = counterSubTab.counter.getNumber();
                    if (counterSubTab.enabledCheck.getSelection() && config.getAttribute(OprofileLaunchPlugin.attrNumberOfEvents(nr), 0) == 0) {
                        valid = false;
                    }
                    // if target list is empty valid is false
                    // target event list item count
                    int count = counterSubTab.selectedEventList.getList().getItemCount();
                    if (count == 0) {
                        valid = false;
                    }
                }
                if (counters[i].getEnabled()) {
                    ++numEnabledEvents;
                    for (OpEvent event : counters[i].getEvents()) {
                        if (event == null) {
                            valid = false;
                            break;
                        }
                        // First check min count
                        int min = event.getMinCount();
                        if (counters[i].getCount() < min) {
                            setErrorMessage(MessageFormat.format(// $NON-NLS-1$
                            OprofileLaunchMessages.getString("tab.event.counterSettings.count.too-small"), min));
                            valid = false;
                            break;
                        }
                        // Next ask oprofile if it is valid
                        if (!checkEventSetupValidity(counters[i].getNumber(), event.getText(), event.getUnitMask().getMaskValue())) {
                            Object[] args = new Object[] { event.getText() };
                            // $NON-NLS-1$
                            setErrorMessage(MessageFormat.format(OprofileLaunchMessages.getString("tab.event.validation.msg"), args));
                            valid = false;
                            break;
                        }
                    }
                }
            }
        }
    } catch (CoreException e) {
        e.printStackTrace();
    }
    return (numEnabledEvents > 0 && valid);
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) OpEvent(org.eclipse.linuxtools.internal.oprofile.core.daemon.OpEvent)

Example 2 with OpEvent

use of org.eclipse.linuxtools.internal.oprofile.core.daemon.OpEvent in project linuxtools by eclipse.

the class TestInfoParse method testParse.

@Test
public void testParse() {
    // $NON-NLS-1$
    assertEquals("/var/lib/oprofile/samples/", info.getDefault(OpInfo.DEFAULT_SAMPLE_DIR));
    // $NON-NLS-1$
    assertEquals("/var/lib/oprofile/lock", info.getDefault(OpInfo.DEFAULT_LOCK_FILE));
    // $NON-NLS-1$
    assertEquals("/var/lib/oprofile/samples/oprofiled.log", info.getDefault(OpInfo.DEFAULT_LOG_FILE));
    // $NON-NLS-1$
    assertEquals("/var/lib/oprofile/complete_dump", info.getDefault(OpInfo.DEFAULT_DUMP_STATUS));
    assertTrue(info.getTimerMode());
    assertEquals(800, info.getCPUSpeed(), 0);
    assertEquals(2, info.getNrCounters());
    OpEvent[] ctr0_events = info.getEvents(0), ctr1_events = info.getEvents(1);
    assertEquals(3, ctr0_events.length);
    assertEquals(3, ctr1_events.length);
    OpEvent ctr0_e1 = ctr0_events[0], ctr0_e2 = ctr0_events[1], ctr0_e3 = ctr0_events[2], ctr1_e1 = ctr1_events[0], ctr1_e2 = ctr1_events[1], ctr1_e3 = ctr1_events[2];
    // events must be ordered alphabetically
    assertEquals(6000, ctr0_e1.getMinCount());
    // $NON-NLS-1$
    assertEquals("CPU_CLK_UNHALTED", ctr0_e1.getText());
    // $NON-NLS-1$
    assertEquals("Clock cycles when not halted", ctr0_e1.getTextDescription());
    assertEquals(500, ctr0_e2.getMinCount());
    // $NON-NLS-1$
    assertEquals("DTLB_MISSES", ctr0_e2.getText());
    // $NON-NLS-1$
    assertEquals("DTLB miss events", ctr0_e2.getTextDescription());
    assertEquals(6000, ctr0_e3.getMinCount());
    // $NON-NLS-1$
    assertEquals("INST_RETIRED_ANY_P", ctr0_e3.getText());
    // $NON-NLS-1$
    assertEquals("number of instructions retired", ctr0_e3.getTextDescription());
    assertEquals(500, ctr1_e1.getMinCount());
    // $NON-NLS-1$
    assertEquals("EIST_TRANS_ALL", ctr1_e1.getText());
    // $NON-NLS-1$
    assertEquals("Intel(tm) Enhanced SpeedStep(r) Technology transitions", ctr1_e1.getTextDescription());
    assertEquals(500, ctr1_e2.getMinCount());
    // $NON-NLS-1$
    assertEquals("L2_LINES_OUT", ctr1_e2.getText());
    // $NON-NLS-1$
    assertEquals("number of recovered lines from L2", ctr1_e2.getTextDescription());
    assertEquals(500, ctr1_e3.getMinCount());
    // $NON-NLS-1$
    assertEquals("L2_M_LINES_IN", ctr1_e3.getText());
    // $NON-NLS-1$
    assertEquals("number of modified lines allocated in L2", ctr1_e3.getTextDescription());
    OpUnitMask ctr0_e1_mask = ctr0_e1.getUnitMask(), ctr0_e2_mask = ctr0_e2.getUnitMask(), ctr0_e3_mask = ctr0_e3.getUnitMask(), ctr1_e1_mask = ctr1_e1.getUnitMask(), ctr1_e2_mask = ctr1_e2.getUnitMask(), ctr1_e3_mask = ctr1_e3.getUnitMask();
    assertEquals(0, ctr0_e1_mask.getMaskValue());
    assertEquals(OpUnitMask.EXCLUSIVE, ctr0_e1_mask.getType());
    assertEquals(3, ctr0_e1_mask.getNumMasks());
    assertEquals(0, ctr0_e1_mask.getMaskFromIndex(0));
    // $NON-NLS-1$
    assertEquals("Unhalted core cycles", ctr0_e1_mask.getText(0));
    assertEquals(1, ctr0_e1_mask.getMaskFromIndex(1));
    // $NON-NLS-1$
    assertEquals("Unhalted bus cycles", ctr0_e1_mask.getText(1));
    assertEquals(2, ctr0_e1_mask.getMaskFromIndex(2));
    // $NON-NLS-1$
    assertEquals("Unhalted bus cycles of this core while the other core is halted", ctr0_e1_mask.getText(2));
    assertEquals(15, ctr0_e2_mask.getMaskValue());
    assertEquals(OpUnitMask.BITMASK, ctr0_e2_mask.getType());
    assertEquals(4, ctr0_e2_mask.getNumMasks());
    assertEquals(1, ctr0_e2_mask.getMaskFromIndex(0));
    // $NON-NLS-1$
    assertEquals("ANY\tMemory accesses that missed the DTLB.", ctr0_e2_mask.getText(0));
    assertEquals(2, ctr0_e2_mask.getMaskFromIndex(1));
    // $NON-NLS-1$
    assertEquals("MISS_LD\tDTLB misses due to load operations.", ctr0_e2_mask.getText(1));
    assertEquals(4, ctr0_e2_mask.getMaskFromIndex(2));
    // $NON-NLS-1$
    assertEquals("L0_MISS_LD L0 DTLB misses due to load operations.", ctr0_e2_mask.getText(2));
    assertEquals(8, ctr0_e2_mask.getMaskFromIndex(3));
    // $NON-NLS-1$
    assertEquals("MISS_ST\tTLB misses due to store operations.", ctr0_e2_mask.getText(3));
    assertEquals(0, ctr0_e3_mask.getMaskValue());
    assertEquals(OpUnitMask.MANDATORY, ctr0_e3_mask.getType());
    assertEquals(1, ctr0_e3_mask.getNumMasks());
    assertEquals(0, ctr0_e3_mask.getMaskFromIndex(0));
    // $NON-NLS-1$
    assertEquals("No unit mask", ctr0_e3_mask.getText(0));
    assertEquals(1, ctr1_e1_mask.getMaskValue());
    assertEquals(OpUnitMask.INVALID, ctr1_e1_mask.getType());
    assertEquals(1, ctr1_e1_mask.getNumMasks());
    // -1 because of invalid mask type
    assertEquals(-1, ctr1_e1_mask.getMaskFromIndex(0));
    // $NON-NLS-1$
    assertEquals("No unit mask", ctr1_e1_mask.getText(0));
    assertEquals(112, ctr1_e2_mask.getMaskValue());
    assertEquals(OpUnitMask.BITMASK, ctr1_e2_mask.getType());
    assertEquals(5, ctr1_e2_mask.getNumMasks());
    assertEquals(192, ctr1_e2_mask.getMaskFromIndex(0));
    // $NON-NLS-1$
    assertEquals("core: all cores", ctr1_e2_mask.getText(0));
    assertEquals(64, ctr1_e2_mask.getMaskFromIndex(1));
    // $NON-NLS-1$
    assertEquals("core: this core", ctr1_e2_mask.getText(1));
    assertEquals(48, ctr1_e2_mask.getMaskFromIndex(2));
    // $NON-NLS-1$
    assertEquals("prefetch: all inclusive", ctr1_e2_mask.getText(2));
    assertEquals(16, ctr1_e2_mask.getMaskFromIndex(3));
    // $NON-NLS-1$
    assertEquals("prefetch: Hardware prefetch only", ctr1_e2_mask.getText(3));
    assertEquals(0, ctr1_e2_mask.getMaskFromIndex(4));
    // $NON-NLS-1$
    assertEquals("prefetch: exclude hardware prefetch", ctr1_e2_mask.getText(4));
    assertEquals(64, ctr1_e3_mask.getMaskValue());
    assertEquals(OpUnitMask.EXCLUSIVE, ctr1_e3_mask.getType());
    assertEquals(2, ctr1_e3_mask.getNumMasks());
    assertEquals(192, ctr1_e3_mask.getMaskFromIndex(0));
    // $NON-NLS-1$
    assertEquals("All cores", ctr1_e3_mask.getText(0));
    assertEquals(64, ctr1_e3_mask.getMaskFromIndex(1));
    // $NON-NLS-1$
    assertEquals("This core", ctr1_e3_mask.getText(1));
    assertNull(ctr0_e1_mask.getText(-1));
    assertEquals(0, info_0ctr.getNrCounters());
}
Also used : OpEvent(org.eclipse.linuxtools.internal.oprofile.core.daemon.OpEvent) OpUnitMask(org.eclipse.linuxtools.internal.oprofile.core.daemon.OpUnitMask) Test(org.junit.Test)

Example 3 with OpEvent

use of org.eclipse.linuxtools.internal.oprofile.core.daemon.OpEvent in project linuxtools by eclipse.

the class TestInfoParse method testInfo.

@Test
public void testInfo() {
    OpEvent[] result = info.getEvents(-1);
    assertEquals(0, result.length);
    // $NON-NLS-1$
    assertNull(info.findEvent("doesnt exist"));
    // $NON-NLS-1$
    OpEvent event = info.findEvent("CPU_CLK_UNHALTED");
    // $NON-NLS-1$
    assertEquals("CPU_CLK_UNHALTED", event.getText());
}
Also used : OpEvent(org.eclipse.linuxtools.internal.oprofile.core.daemon.OpEvent) Test(org.junit.Test)

Example 4 with OpEvent

use of org.eclipse.linuxtools.internal.oprofile.core.daemon.OpEvent in project linuxtools by eclipse.

the class OprofileTestingEventConfigTab method getOprofileCounter.

@Override
public OprofileCounter getOprofileCounter(int i) {
    // mock mask info
    MaskInfo maskInfo = new MaskInfo();
    // $NON-NLS-1$
    maskInfo.description = "mock mask info";
    maskInfo.value = 0;
    MaskInfo[] maskInfoDescriptions = { maskInfo };
    // mock mask
    OpUnitMask mask = new OpUnitMask();
    mask.setDefault(0);
    mask.setMaskDescriptions(maskInfoDescriptions);
    mask.setType(0);
    mask.setMaskFromIndex(0);
    mask.setMaskValue(0);
    // mock events
    OpEvent event = new OpEvent();
    event.setMinCount(1);
    // $NON-NLS-1$
    event.setText("mock-event");
    // $NON-NLS-1$
    event.setTextDescription("Mock Event");
    event.setUnitMask(mask);
    OpEvent[] events = { event };
    // mock counter
    OprofileCounter ctr = new OprofileCounter(i, events);
    ctr.setCount(1);
    ctr.setEvents(new OpEvent[] { event });
    return ctr;
}
Also used : MaskInfo(org.eclipse.linuxtools.internal.oprofile.core.daemon.OpUnitMask.MaskInfo) OprofileCounter(org.eclipse.linuxtools.internal.oprofile.launch.configuration.OprofileCounter) OpEvent(org.eclipse.linuxtools.internal.oprofile.core.daemon.OpEvent) OpUnitMask(org.eclipse.linuxtools.internal.oprofile.core.daemon.OpUnitMask)

Aggregations

OpEvent (org.eclipse.linuxtools.internal.oprofile.core.daemon.OpEvent)4 OpUnitMask (org.eclipse.linuxtools.internal.oprofile.core.daemon.OpUnitMask)2 Test (org.junit.Test)2 CoreException (org.eclipse.core.runtime.CoreException)1 MaskInfo (org.eclipse.linuxtools.internal.oprofile.core.daemon.OpUnitMask.MaskInfo)1 OprofileCounter (org.eclipse.linuxtools.internal.oprofile.launch.configuration.OprofileCounter)1