quick-lint / quick-lint-js

quick-lint-js finds bugs in JavaScript programs
https://quick-lint-js.com
GNU General Public License v3.0
1.52k stars 192 forks source link

improve DevX for debug tracing #1050

Open strager opened 1 year ago

strager commented 1 year ago

quick-lint-js's trace format requires a lot of code:

Total: 3454 lines

In addition to being a lot of code, the code is tedious to write and a lot of places need to be updated.

It'd be nice if we should shrink this down to one source of truth and ~1k lines or less (for the current feature set).


Implementation status:

strager commented 1 year ago

We have a few options:

  1. Status quo: Hand-write the format spec (CTF) and hand-write parsers (JS, C++, and 010 Editor) and writers (C++).
  2. Hand-write the format spec (CTF). Write a tool which parses the spec and generates parsers (JS, C++, and 010 Editor) and writers (C++).
  3. Write a tool which has an embedded spec and generates parsers (JS, C++, 010 Editor), writers (C++), and a formal spec (CTF).
  4. Pick some third-party tooling, such as protobuf, which will work similar to option 2 but with the tooling made by someone else. Change: Probably loses 010 Editor support, but probably gains other tooling. Change: Probably not using CTF anymore.
strager commented 1 year ago

I asked about option 2 in the LTTng mailing list: https://lists.lttng.org/pipermail/lttng-dev/2023-August/030593.html

strager commented 1 year ago

In commit c0eeb811d15e986ffbc5f1da37adf6f73c7eef3a, I generated the CTF metadata file from using the C++ code (trace-types.h) as the schema. I'll do similar things to generate readers and writers soon.

strager commented 1 year ago

JS parser generation implemented in commit 9581b8bfa42d9cd83dc3dd7feeb6d049980e0181.

strager commented 1 year ago

C++ parser generation implemented in commit 98473f0feeb4455e064b4bd1db10bc75e6e2d396.

strager commented 1 year ago

C++ writer generation implemented in commit b80c1e84fc36e4da45df4b5731db9c3373b8ac4f.

strager commented 1 year ago

010 Editor template generation implemented in commit 9ce47bb582688289926a3893d198ff84bd0abe8c.

strager commented 1 year ago

New raw line counts for non-generated sources: 4143 lines:

      64 src/quick-lint-js/logging/trace-writer.cpp
      69 test/test-trace-writer.cpp
      80 src/quick-lint-js/logging/trace-writer.h
      86 src/quick-lint-js/logging/trace-reader.h
     111 src/quick-lint-js/logging/trace-types.cpp
     118 test/test-trace-reader.cpp
     169 src/quick-lint-js/logging/trace-reader.cpp
     267 src/quick-lint-js/debug/public/trace.mjs
     274 src/quick-lint-js/logging/trace-types.h
     426 test/test-trace-reader-writer.cpp
     683 src/quick-lint-js/debug/test/test-trace.mjs
    1796 tools/generate-trace-sources.cpp
    4143 total

So we have regressed. =\