Search in sources :

Example 1 with OpModelSymbol

use of org.eclipse.linuxtools.internal.oprofile.core.model.OpModelSymbol in project linuxtools by eclipse.

the class TestModelDataParse method testParse.

@Test
public void testParse() {
    // test attributes
    // $NON-NLS-1$
    assertEquals("/test/path/for/image", parsedImage.getName());
    assertEquals(205000, parsedImage.getCount());
    // test symbols
    OpModelSymbol[] symbols = parsedImage.getSymbols();
    assertEquals(2, symbols.length);
    OpModelSymbol sym1 = symbols[0], sym2 = symbols[1];
    // $NON-NLS-1$
    assertEquals("TestFunction1(int)", sym1.getName());
    // $NON-NLS-1$
    assertEquals("/test/path/for/src/image.cpp", sym1.getFilePath());
    assertEquals(180000, sym1.getCount());
    // $NON-NLS-1$
    assertEquals("TestFunction2(int, int)", sym2.getName());
    // $NON-NLS-1$
    assertEquals("/test/path/for/src/image2.cpp", sym2.getFilePath());
    assertEquals(20000, sym2.getCount());
    // test samples
    OpModelSample[] sym1_spls = sym1.getSamples(), sym2_spls = sym2.getSamples();
    assertEquals(4, sym1_spls.length);
    assertEquals(3, sym2_spls.length);
    OpModelSample sym1_spl1 = sym1_spls[0], sym1_spl2 = sym1_spls[1], sym1_spl3 = sym1_spls[2], sym1_spl4 = sym1_spls[3];
    OpModelSample sym2_spl1 = sym2_spls[0], sym2_spl2 = sym2_spls[1], sym2_spl3 = sym2_spls[2];
    assertEquals(130000, sym1_spl1.getCount());
    assertEquals(42, sym1_spl1.getLine());
    assertEquals(40000, sym1_spl2.getCount());
    assertEquals(36, sym1_spl2.getLine());
    assertEquals(9999, sym1_spl3.getCount());
    assertEquals(31, sym1_spl3.getLine());
    assertEquals(1, sym1_spl4.getCount());
    assertEquals(39, sym1_spl4.getLine());
    assertEquals(19998, sym2_spl1.getCount());
    assertEquals(94, sym2_spl1.getLine());
    assertEquals(1, sym2_spl2.getCount());
    assertEquals(12, sym2_spl2.getLine());
    assertEquals(1, sym2_spl3.getCount());
    assertEquals(55, sym2_spl3.getLine());
    // test dependent images
    assertEquals(true, parsedImage.hasDependents());
    assertEquals(5000, parsedImage.getDepCount());
    OpModelImage[] deps = parsedImage.getDependents();
    assertEquals(4, deps.length);
    OpModelImage dep1 = deps[0], dep2 = deps[1], dep3 = deps[2], dep4 = deps[3];
    assertEquals(false, dep1.hasDependents());
    // $NON-NLS-1$
    assertEquals("/no-vmlinux", dep1.getName());
    assertEquals(4400, dep1.getCount());
    assertEquals(false, dep2.hasDependents());
    OpModelSymbol[] dep2_syms = dep2.getSymbols();
    assertEquals(2, dep2_syms.length);
    OpModelSymbol dep2_sym1 = dep2_syms[0], dep2_sym2 = dep2_syms[1];
    OpModelSample[] dep2_sym1_spls = dep2_sym1.getSamples(), dep2_sym2_spls = dep2_sym2.getSamples();
    assertEquals(1, dep2_sym1_spls.length);
    assertEquals(1, dep2_sym2_spls.length);
    OpModelSample dep2_sym1_spl1 = dep2_sym1_spls[0], dep2_sym2_spl1 = dep2_sym2_spls[0];
    // $NON-NLS-1$
    assertEquals("/lib64/ld-2.9.so", dep2.getName());
    assertEquals(300, dep2.getCount());
    // $NON-NLS-1$
    assertEquals("do_lookup_x", dep2_sym1.getName());
    // $NON-NLS-1$
    assertEquals("dl-lookup.c", dep2_sym1.getFilePath());
    assertEquals(299, dep2_sym1.getCount());
    assertEquals(299, dep2_sym1_spl1.getCount());
    assertEquals(0, dep2_sym1_spl1.getLine());
    // $NON-NLS-1$
    assertEquals("_dl_unload_cache", dep2_sym2.getName());
    // $NON-NLS-1$
    assertEquals("rawmemchr.c", dep2_sym2.getFilePath());
    assertEquals(1, dep2_sym2.getCount());
    assertEquals(1, dep2_sym2_spl1.getCount());
    assertEquals(0, dep2_sym2_spl1.getLine());
    assertEquals(false, dep3.hasDependents());
    // $NON-NLS-1$
    assertEquals("/usr/lib64/libstdc++.so.6.0.10", dep3.getName());
    assertEquals(160, dep3.getCount());
    assertEquals(false, dep4.hasDependents());
    OpModelSymbol[] dep4_syms = dep4.getSymbols();
    assertEquals(2, dep4_syms.length);
    OpModelSymbol dep4_sym1 = dep4_syms[0], dep4_sym2 = dep4_syms[1];
    OpModelSample[] dep4_sym1_spls = dep4_sym1.getSamples(), dep4_sym2_spls = dep4_sym2.getSamples();
    assertEquals(1, dep4_sym1_spls.length);
    assertEquals(1, dep4_sym2_spls.length);
    OpModelSample dep4_sym1_spl1 = dep4_sym1_spls[0], dep4_sym2_spl1 = dep4_sym2_spls[0];
    // $NON-NLS-1$
    assertEquals("/lib64/libc-2.9.so", dep4.getName());
    assertEquals(140, dep4.getCount());
    // $NON-NLS-1$
    assertEquals("_IO_new_file_seekoff", dep4_sym1.getName());
    // $NON-NLS-1$
    assertEquals("", dep4_sym1.getFilePath());
    assertEquals(100, dep4_sym1.getCount());
    assertEquals(100, dep4_sym1_spl1.getCount());
    assertEquals(0, dep4_sym1_spl1.getLine());
    // $NON-NLS-1$
    assertEquals("bool std::operator!=<char, std::char_traits<char>, std::allocator<char> >(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, char const*)", dep4_sym2.getName());
    // $NON-NLS-1$
    assertEquals("", dep4_sym2.getFilePath());
    assertEquals(40, dep4_sym2.getCount());
    assertEquals(40, dep4_sym2_spl1.getCount());
    assertEquals(0, dep4_sym2_spl1.getLine());
    assertEquals(OpModelImage.IMAGE_PARSE_ERROR, parsedErrorImage.getCount());
    assertEquals(0, parsedErrorImage.getDepCount());
    assertNull(parsedErrorImage.getDependents());
    assertNull(parsedErrorImage.getSymbols());
    // $NON-NLS-1$
    assertEquals("", parsedErrorImage.getName());
}
Also used : OpModelImage(org.eclipse.linuxtools.internal.oprofile.core.model.OpModelImage) OpModelSymbol(org.eclipse.linuxtools.internal.oprofile.core.model.OpModelSymbol) OpModelSample(org.eclipse.linuxtools.internal.oprofile.core.model.OpModelSample) Test(org.junit.Test)

Example 2 with OpModelSymbol

use of org.eclipse.linuxtools.internal.oprofile.core.model.OpModelSymbol in project linuxtools by eclipse.

the class SymbolsProcessor method reset.

@Override
public void reset(Object callData) {
    symbol = new OpModelSymbol();
    symbols = new ArrayList<>();
}
Also used : OpModelSymbol(org.eclipse.linuxtools.internal.oprofile.core.model.OpModelSymbol)

Example 3 with OpModelSymbol

use of org.eclipse.linuxtools.internal.oprofile.core.model.OpModelSymbol in project linuxtools by eclipse.

the class SymbolsProcessor method endElement.

@Override
public void endElement(String name, Object callData) {
    if (name.equals(SYMBOL_TAG)) {
        symbol.setSamples(samplesProcessor.getSamples());
        symbols.add(symbol);
        symbol = new OpModelSymbol();
    } else if (name.equals(SYMBOLS_TAG)) {
        OprofileSAXHandler.getInstance(callData).pop(SYMBOLS_TAG);
    }
}
Also used : OpModelSymbol(org.eclipse.linuxtools.internal.oprofile.core.model.OpModelSymbol)

Aggregations

OpModelSymbol (org.eclipse.linuxtools.internal.oprofile.core.model.OpModelSymbol)3 OpModelImage (org.eclipse.linuxtools.internal.oprofile.core.model.OpModelImage)1 OpModelSample (org.eclipse.linuxtools.internal.oprofile.core.model.OpModelSample)1 Test (org.junit.Test)1