bdarnell / plop

Python Low-Overhead Profiler
MIT License
923 stars 69 forks source link

.flame format error or parsing error #26

Closed dimaqq closed 8 years ago

dimaqq commented 8 years ago

I ran some script from scripts directory with -m plop.collector -f flamegraph and it generated a profiles/scripts/xxx.py-xxx.flame file, that starts like this:

None 1
_run_module_as_main ( ... [snip]
_run_module_as_main ( ... [snip]

When I try to view it using -m plop.viewer --datadir=profiles/scripts/ the server part crashes:

[E 160201 08:51:26 web:1524] Uncaught exception GET /data?filename=put_chunked_file.py-20160201-0850-43.flame (::1)
    HTTPServerRequest(protocol='http', host='localhost:8888', method='GET', uri='/data?filename=put_chunked_file.py-20160201-0850-43.flame', version='HTTP/1.1', remote_ip='::1', headers={'Accept-Language': 'en-GB,en-US;q=0.8,en;q=0.6', 'Accept-Encoding': 'gzip, deflate, sdch', 'Host': 'localhost:8888', 'Accept': 'application/json,*/*', 'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.82 Safari/537.36', 'Connection': 'keep-alive', 'Referer': 'http://localhost:8888/view?filename=xxx.py-20160201-0850-43.flame'})
    Traceback (most recent call last):
      File "/dima/plc/lib/python2.7/site-packages/tornado/web.py", line 1443, in _execute
        result = method(*self.path_args, **self.path_kwargs)
      File "/dima/plc/lib/python2.7/site-packages/plop/viewer.py", line 44, in get
        self.write(profile_to_json(self.get_argument('filename')))
      File "/dima/plc/lib/python2.7/site-packages/plop/viewer.py", line 50, in profile_to_json
        graph = CallGraph.load(abspath)
      File "/dima/plc/lib/python2.7/site-packages/plop/callgraph.py", line 87, in load
        data = ast.literal_eval(f.read())
      File "/usr/lib64/python2.7/ast.py", line 49, in literal_eval
        node_or_string = parse(node_or_string, mode='eval')
      File "/usr/lib64/python2.7/ast.py", line 37, in parse
        return compile(source, filename, mode, PyCF_ONLY_AST)
      File "<unknown>", line 1
        None 1
dimaqq commented 8 years ago

If I remove that None 1 line, plop.viewer still crashes:

_run_module_as_main (/usr/lib64/python2.7/runpy.py:136);_run_code (/usr/lib64/python2.7/runpy.py:62);<module> (/dima/plc... [snip]
SyntaxError: invalid syntax

It seems like .flame file ought to be Python-like, but it clearly misses a bunch of quotes at least...

bdarnell commented 8 years ago

plop.viewer only works with the plop output format. The flamegraph output format is for use in (third-party) flamegraph viewers.