]> sourceware.org Git - valgrind.git/commit
Rewrite `cg_annotate` in Python.
authorNicholas Nethercote <n.nethercote@gmail.com>
Thu, 9 Mar 2023 04:41:31 +0000 (15:41 +1100)
committerNicholas Nethercote <n.nethercote@gmail.com>
Tue, 21 Mar 2023 23:12:27 +0000 (10:12 +1100)
commit4650b7949ae3a41326e52ae454a9202493c41444
tree8061575a08b74e243d2dfa9a4145e78f5fc7e54f
parent394fa9223aff48b6b344f0d55f8bc409a5425486
Rewrite `cg_annotate` in Python.

Perl was a reasonable choice for `cg_annotate` in 2002, but not in 2023.
Also, the existing structure of the code is not good. These two things
make it hard to modify `cg_annotate` in any significant way.

Benefits of the change:
- Now written in a language that is (a) nice, and (b) not moribund.
- Easier to maintain, due to (a) abovementioned better language, (b)
  better code structure, and (c) better language tooling, such as
  formatters, type checkers, and linters.
- The new version is a little shorter.
- It runs about 2x faster.
- Argument handling is more standard. E.g. things like `--context 2`,
  `--auto`, `--no-auto` are supported. (The old forms that require `=`
  are still supported, though the `=yes`/`=no` forms are deprecated.)

The behaviour and output of the new version is identical for typical
uses, but there are some very minor changes for edge cases, which nobody
is likely to notice. For example:
- The file format is slightly changed: I removed support for '.'
  counts, which had the same meaning as '0'. This was a feature that
  Cachegrind never used, and the old script handled it inconsistently.
- The new version will abort on a malformed data line. The old version
  would just print a warning and continue.

The commit also adds a new test `ann3` that tests many parts of
`cg_annotate` that weren't tested previously, and tweaks the existing
`ann2` test.
18 files changed:
NEWS
cachegrind/Makefile.am
cachegrind/cg_annotate.in [changed mode: 0644->0755]
cachegrind/docs/cg-manual.xml
cachegrind/pylintrc [new file with mode: 0644]
cachegrind/tests/ann2.post.exp
cachegrind/tests/ann2.vgtest
cachegrind/tests/ann3-aux/ann3-via-I.rs [new file with mode: 0644]
cachegrind/tests/ann3-basic.rs [new file with mode: 0644]
cachegrind/tests/ann3-more-recent-than-cgout.rs [new file with mode: 0644]
cachegrind/tests/ann3-negatives.rs [new file with mode: 0644]
cachegrind/tests/ann3-past-the-end.rs [new file with mode: 0644]
cachegrind/tests/ann3-unmentioned.rs [new file with mode: 0644]
cachegrind/tests/ann3.post.exp [new file with mode: 0644]
cachegrind/tests/ann3.stderr.exp [new file with mode: 0644]
cachegrind/tests/ann3.vgtest [new file with mode: 0644]
cachegrind/tests/cgout-test3 [new file with mode: 0644]
cachegrind/tests/diff.post.exp
This page took 0.035143 seconds and 5 git commands to generate.