int foo(int x, int y) {return 42;}
int foo(int x, int y) {TRACE_EVENT0("test", "foo");return 42;}
int foo(int x, int y) {TRACE_EVENT1("test", "foo", "arguments", [&]() {auto traced_value = std::make_unique<base::trace_event::TracedValue>();traced_value->AddValue(x, "x");traced_value->AddValue(y, "y");return traced_value;}());return 42;}
Is the idea that a developer could run this against a source file locally, and the tool would annotate all the methods with the trace macros? But the result wouldn't be checked in?
> Do you have any tips or ideas regarding the tool?LibTooling, run_tool.py, et cetera aren't really officially maintained in Chromium; they're generally maintained on an ad-hoc basis, with the potential for extended breakage that doesn't get fixed until the next dev notices.
> How can we supply such a tool to Chromium developers?One way could be to ship it like clang-format does in a google storage bucket: https://source.chromium.org/chromium/chromium/src/+/master:DEPS;l=4379;drc=4f4593f8ccea72814337794b9bc5ecccd22f6271Someone would have to be responsible for building it/uploading packages though.
> What form is the best for such a tool?Can you clarify this question? Is this asking if we should be investigating an alternative other than clang tooling? As mentioned previously, I find LibTooling to be rather sharp and fiddly around the edges: due to gradual changes over time, things tend to randomly break (as you recently discovered with the empty_string tool). But I'd suggest that if we want to pursue a LIbTooling-based approach, we'd definitely want a frontend script that performs all the magic invocations. Developers would only have to run this script, rather than invoking run_tool.py directly.
Thank you for the response!Is the idea that a developer could run this against a source file locally, and the tool would annotate all the methods with the trace macros? But the result wouldn't be checked in?I believe there would be two use-cases:
- Debugging: run the tool against source file(s) locally, do not make a patch out of the resulting traces (but fix the original issue).
- Bulk adding TRACE_EVENTs: run the tool locally, check the generated code by hand, make a patch out of this. This has already been done.
> Do you have any tips or ideas regarding the tool?LibTooling, run_tool.py, et cetera aren't really officially maintained in Chromium; they're generally maintained on an ad-hoc basis, with the potential for extended breakage that doesn't get fixed until the next dev notices.Yes. In some sense this tool would not be all that critical.But I have not yet found a way how to build (e.g. empty_string) and be able to use it reliably after multiple |gclient sync|. And having to build Clang in order to be able to run a binary would not be pleasant...> How can we supply such a tool to Chromium developers?One way could be to ship it like clang-format does in a google storage bucket: https://source.chromium.org/chromium/chromium/src/+/master:DEPS;l=4379;drc=4f4593f8ccea72814337794b9bc5ecccd22f6271Someone would have to be responsible for building it/uploading packages though.@Alexander Timin Would this be a good option for this tool?
On Wed, 12 Aug 2020 at 15:52, Karel Král <kare...@google.com> wrote:Thank you for the response!Is the idea that a developer could run this against a source file locally, and the tool would annotate all the methods with the trace macros? But the result wouldn't be checked in?I believe there would be two use-cases:
- Debugging: run the tool against source file(s) locally, do not make a patch out of the resulting traces (but fix the original issue).
- Bulk adding TRACE_EVENTs: run the tool locally, check the generated code by hand, make a patch out of this. This has already been done.
> Do you have any tips or ideas regarding the tool?LibTooling, run_tool.py, et cetera aren't really officially maintained in Chromium; they're generally maintained on an ad-hoc basis, with the potential for extended breakage that doesn't get fixed until the next dev notices.Yes. In some sense this tool would not be all that critical.But I have not yet found a way how to build (e.g. empty_string) and be able to use it reliably after multiple |gclient sync|. And having to build Clang in order to be able to run a binary would not be pleasant...
On Wed, Aug 12, 2020 at 8:00 AM Alexander Timin <alt...@google.com> wrote:On Wed, 12 Aug 2020 at 15:52, Karel Král <kare...@google.com> wrote:Thank you for the response!Is the idea that a developer could run this against a source file locally, and the tool would annotate all the methods with the trace macros? But the result wouldn't be checked in?I believe there would be two use-cases:
- Debugging: run the tool against source file(s) locally, do not make a patch out of the resulting traces (but fix the original issue).
- Bulk adding TRACE_EVENTs: run the tool locally, check the generated code by hand, make a patch out of this. This has already been done.
> Do you have any tips or ideas regarding the tool?LibTooling, run_tool.py, et cetera aren't really officially maintained in Chromium; they're generally maintained on an ad-hoc basis, with the potential for extended breakage that doesn't get fixed until the next dev notices.Yes. In some sense this tool would not be all that critical.But I have not yet found a way how to build (e.g. empty_string) and be able to use it reliably after multiple |gclient sync|. And having to build Clang in order to be able to run a binary would not be pleasant...To clarify, this happens because the build scripts dump the output into //third_party/llvm-build/Release+Asserts. However, when you run gclient sync, it updates the clang toolchain... which is stored in the same place.In addition, having your own local build prevents goma from working so this confirms that having a prebuilt version is best if you expect other people to use the tool.
Sorry I missed this email!This sounds familiar, and it looks like what we did for rewrite_to_chrome_style: https://codereview.chromium.org/2806033003Sadly, I think that storage bucket was deleted a long time ago, so the contents are lost to the mists of space and time. I really wonder why the tool needs these and can't simply use whatever is normally packaged with the build in Chrome though. Might be worth investigating...