Esempio n. 1
0
def test_exception_recover():
    # weird file provided, fails without returning anything
    fobj = FileObj([0x0])
    with pytest.raises(ParseException):
        _parse_jitlog(fobj)

    # incomplete log, bails and adds exception
    fobj = FileObj([
        const.MARK_JITLOG_HEADER, b'\x01\x00\x00',
        encode_str('x86_64'), b'\x00'
    ])
    f = _parse_jitlog(fobj)
    assert hasattr(f, 'exc')
    assert "marker unknown" in f.exc.args[0]

    # some valid data, but most of it missing
    fobj = FileObj([
        const.MARK_JITLOG_HEADER,
        b'\x01\x00\x00',
        encode_str('x86_64'),
        const.MARK_START_TRACE,
        encode_le_u64(0xffaa),
        encode_str('loop'),
        encode_le_u64(0),
        const.MARK_TRACE,
        encode_le_u64(0xffaa),
        const.MARK_START_TRACE  # uff, trace ends here, data missing
    ])
    f = _parse_jitlog(fobj)
    assert len(f.traces) == 1
    assert hasattr(f, 'exc')
Esempio n. 2
0
def test_exception_recover():
    # weird file provided, fails without returning anything
    fobj = FileObj([0x0])
    with pytest.raises(ParseException):
        _parse_jitlog(fobj)

    # incomplete log, bails and adds exception
    fobj = FileObj([const.MARK_JITLOG_HEADER,
                    b'\x01\x00\x00', encode_str('x86_64'),
                   b'\x00'
                   ])
    f = _parse_jitlog(fobj)
    assert hasattr(f, 'exc')
    assert "marker unknown" in f.exc.args[0]

    # some valid data, but most of it missing
    fobj = FileObj([const.MARK_JITLOG_HEADER,
                    b'\x01\x00\x00', encode_str('x86_64'),
                    const.MARK_START_TRACE, encode_le_u64(0xffaa), encode_str('loop'), encode_le_u64(0),
                    const.MARK_TRACE, encode_le_u64(0xffaa),
                    const.MARK_START_TRACE # uff, trace ends here, data missing
                   ])
    f = _parse_jitlog(fobj)
    assert len(f.traces) == 1
    assert hasattr(f, 'exc')
Esempio n. 3
0
def test_32bit_log_header():
    fobj = FileObj([const.MARK_JITLOG_HEADER+ b"\x01\x00\x01"+\
                    encode_str('ppc64le')])
    forest = _parse_jitlog(fobj)
    assert forest.version == 1
    assert forest.word_size == 4
    assert forest.machine == 'ppc64le'
Esempio n. 4
0
def test_32bit_log_header():
    fobj = FileObj([const.MARK_JITLOG_HEADER+ b"\x01\x00\x01"+\
                    encode_str('ppc64le')])
    forest = _parse_jitlog(fobj)
    assert forest.version == 1
    assert forest.word_size == 4
    assert forest.machine == 'ppc64le'
Esempio n. 5
0
 def decode_forest(self):
     # ultra slow, especially when run on cpython 3.5
     # see vmcache.cache for a faster impl. using pypy.
     # it caches the results as well (not using pickle)
     with get_reader(self.file.name) as fd:
         forest = _parse_jitlog(fd)
         return forest
Esempio n. 6
0
 def decode_forest(self):
     # ultra slow, especially when run on cpython 3.5
     # see vmcache.cache for a faster impl. using pypy.
     # it caches the results as well (not using pickle)
     with get_reader(self.file.name) as fd:
         forest = _parse_jitlog(fd)
         return forest
Esempio n. 7
0
def test_32bit_read_trace():
    fobj = FileObj([const.MARK_JITLOG_HEADER+ b"\x01\x00\x01"+encode_str('s390x'),
                    const.MARK_START_TRACE, encode_le_u32(0x15), encode_str('loop'), encode_le_u32(0),
                   ])
    forest = _parse_jitlog(fobj)
    assert forest.version == 1
    assert forest.word_size == 4
    assert len(forest.traces) == 1
    assert forest.machine == 's390x'
Esempio n. 8
0
 def decode_forest(self):
     forest = FOREST_CACHE.get(self.checksum)
     if forest:
         FOREST_CACHE.set(self.checksum, forest)  # refresh the cache
         return forest
     with get_reader(self.file.name) as fd:
         forest = _parse_jitlog(fd)
         FOREST_CACHE.set(self.checksum, forest)
         return forest
Esempio n. 9
0
def test_32bit_read_trace():
    fobj = FileObj([
        const.MARK_JITLOG_HEADER + b"\x01\x00\x01" + encode_str('s390x'),
        const.MARK_START_TRACE,
        encode_le_u32(0x15),
        encode_str('loop'),
        encode_le_u32(0),
    ])
    forest = _parse_jitlog(fobj)
    assert forest.version == 1
    assert forest.word_size == 4
    assert len(forest.traces) == 1
    assert forest.machine == 's390x'
Esempio n. 10
0
    def load(self, type, filename, checksum):
        profile = self.cache.get(checksum)
        if profile:
            log.msg("cached profile (checksum %s)" % (checksum,))
            return profile

        with get_reader(filename) as fobj:
            if type == "cpu" or type == "mem" or type == "metacpu":
                profile = read_cpu_profile(fobj)
            else:
                profile = parser._parse_jitlog(fobj)
            self.cache.put(checksum, profile)
        assert self.cache.get(checksum) is not None
        log.msg("parsed jitlog in file %s (checksum %s)" % (filename, checksum))
        return profile
Esempio n. 11
0
    def load(self, type, filename, checksum):
        profile = self.cache.get(checksum)
        if profile:
            log.msg("cached profile (checksum %s)" % (checksum, ))
            return profile

        with get_reader(filename) as fobj:
            if type == "cpu" or type == "mem" or type == "metacpu":
                profile = read_cpu_profile(fobj)
            else:
                profile = parser._parse_jitlog(fobj)
            self.cache.put(checksum, profile)
        assert self.cache.get(checksum) is not None
        log.msg("parsed jitlog in file %s (checksum %s)" %
                (filename, checksum))
        return profile