aras-p / ClangBuildAnalyzer

Clang build analysis tool using -ftime-trace
The Unlicense
969 stars 60 forks source link

ERROR: no clang -ftime-trace .json files found under <dir> #45

Closed tomager closed 4 years ago

tomager commented 4 years ago

I am not able to get simple trace running successfully through this tool. From a freshly cloned and built tree, I run:

# ./ClangBuildAnalyzer  --start /tmp
Build tracing started. Do some Clang builds with '-ftime-trace', then run 'ClangBuildAnalyzer --stop /tmp <filename>' to stop tracing and save session to a file.
# clang <various options...> -o /tmp/main.cc.o -c /tmp/main.cc -ftime-trace -ftime-report
ls /tmp
# ls /tmp/main*
/tmp/main.cc.json  /tmp/main.cc.o
# ./ClangBuildAnalyzer --stop /tmp /tmp/report
Stopping build tracing and saving to '/tmp/report'...
ERROR: no clang -ftime-trace .json files found under '/tmp'.

Seems to find the json file and fail while parsing it (within ParseBuildEvents in the code). The clang version is 11/head, downloaded and built today. Chrome can read and display the file successfully within chrome://tracing.

Any ideas? My apologies if I'm missing something obvious, and thank you for producing this tool and -ftime-trace. Incredibly useful.

aras-p commented 4 years ago

Can you share the /tmp/main.cc.json file?

tomager commented 4 years ago

Unfortunately, no.. I will see if I can reproduce the issue with something isolated and update the post.

On Sun, Apr 26, 2020, at 5:41 AM, Aras Pranckevičius wrote:

Can you share the /tmp/main.cc.json file?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/aras-p/ClangBuildAnalyzer/issues/45#issuecomment-619543594, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIQDPFCF4SGVX7XTDOGHUH3ROQTW7ANCNFSM4MRANZIQ.

tomager commented 4 years ago

test.json:

{"traceEvents":[{"pid":43147,"tid":43147,"ph":"X","ts":1905,"dur":1568,"name":"Frontend"},{"pid":43147,"tid":43147,"ph":"X","ts":5589,"dur":639,"name":"RunPass","args":{"detail":"Expand Atomic instructions"}},{"pid":43147,"tid":43147,"ph":"X","ts":5588,"dur":712,"name":"OptFunction","args":{"detail":"main"}},{"pid":43147,"tid":43147,"ph":"X","ts":6303,"dur":535,"name":"OptFunction","args":{"detail":"main"}},{"pid":43147,"tid":43147,"ph":"X","ts":5433,"dur":1565,"name":"OptModule","args":{"detail":"test.cc"}},{"pid":43147,"tid":43147,"ph":"X","ts":5410,"dur":1604,"name":"CodeGenPasses"},{"pid":43147,"tid":43147,"ph":"X","ts":3534,"dur":3537,"name":"Backend"},{"pid":43147,"tid":43147,"ph":"X","ts":11,"dur":7270,"name":"ExecuteCompiler"},{"pid":43147,"tid":43148,"ph":"X","ts":0,"dur":7270,"name":"Total ExecuteCompiler","args":{"count":1,"avg ms":7}},{"pid":43147,"tid":43149,"ph":"X","ts":0,"dur":3536,"name":"Total Backend","args":{"count":1,"avg ms":3}},{"pid":43147,"tid":43150,"ph":"X","ts":0,"dur":1622,"name":"Total Frontend","args":{"count":2,"avg ms":0}},{"pid":43147,"tid":43151,"ph":"X","ts":0,"dur":1603,"name":"Total CodeGenPasses","args":{"count":1,"avg ms":1}},{"pid":43147,"tid":43152,"ph":"X","ts":0,"dur":1585,"name":"Total OptModule","args":{"count":2,"avg ms":0}},{"pid":43147,"tid":43153,"ph":"X","ts":0,"dur":1299,"name":"Total OptFunction","args":{"count":3,"avg ms":0}},{"pid":43147,"tid":43154,"ph":"X","ts":0,"dur":1258,"name":"Total RunPass","args":{"count":61,"avg ms":0}},{"pid":43147,"tid":43155,"ph":"X","ts":0,"dur":384,"name":"Total CodeGen Function","args":{"count":1,"avg ms":0}},{"pid":43147,"tid":43156,"ph":"X","ts":0,"dur":73,"name":"Total PerFunctionPasses","args":{"count":1,"avg ms":0}},{"pid":43147,"tid":43157,"ph":"X","ts":0,"dur":26,"name":"Total PerModulePasses","args":{"count":1,"avg ms":0}},{"pid":43147,"tid":43158,"ph":"X","ts":0,"dur":4,"name":"Total PerformPendingInstantiations","args":{"count":1,"avg ms":0}},{"cat":"","pid":43147,"tid":43147,"ts":0,"ph":"M","name":"process_name","args":{"name":"clang-11"}},{"cat":"","pid":43147,"tid":43147,"ts":0,"ph":"M","name":"thread_name","args":{"name":"clang"}}],"beginningOfTime":1587922998882842}

test.cc:


int main(int argc, const char** argv) {
  return 0;
}

steps:

# /local/ClangBuildAnalyzer/ClangBuildAnalyzer  --start .
Build tracing started. Do some Clang builds with '-ftime-trace', then run 'ClangBuildAnalyzer --stop . <filename>' to stop tracing and save session to a file.
# /build/llvm/bin/clang -o test -c test.cc -ftime-trace
# /local/ClangBuildAnalyzer/ClangBuildAnalyzer  --stop . report
Stopping build tracing and saving to 'report'...
ERROR: no clang -ftime-trace .json files found under '.'.
aras-p commented 4 years ago

Ah seems that latest Clang/LLVM head has changed the format a bit, your repro was very helpful. Should be fixed now, thanks!

tomager commented 4 years ago

This fixes it for me. Thank you!