From: Nicholas Nethercote Date: Sun, 16 Apr 2023 23:34:11 +0000 (+1000) Subject: cg_annotate: Remove the `-I`/`--include` option. X-Git-Tag: VALGRIND_3_21_0~45 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fheads%2Fusers%2Fnjn%2Ftry-rm-I;p=thirdparty%2Fvalgrind.git cg_annotate: Remove the `-I`/`--include` option. For much the same reasons that I removed user annotations recently: it's rarely/never used, and complicates things. --- diff --git a/cachegrind/cg_annotate.in b/cachegrind/cg_annotate.in index 0b68e094c3..5e64a94485 100755 --- a/cachegrind/cg_annotate.in +++ b/cachegrind/cg_annotate.in @@ -51,7 +51,6 @@ class Args(Namespace): show_percs: bool annotate: bool context: int - include: list[str] cgout_filename: list[str] @staticmethod @@ -142,14 +141,6 @@ class Args(Namespace): help="print N lines of context before and after annotated lines " "(default: %(default)s)", ) - p.add_argument( - "-I", - "--include", - action="append", - default=[], - metavar="D", - help="add D to the list of searched source file directories", - ) p.add_argument( "cgout_filename", nargs=1, @@ -663,14 +654,6 @@ def print_metadata(desc: str, cmd: str, events: Events) -> None: print("Events shown: ", *events.show_events) print("Event sort order:", *events.sort_events) print("Threshold: ", args.threshold) - - if len(args.include) == 0: - print("Include dirs: ") - else: - print(f"Include dirs: {args.include[0]}") - for include_dirname in args.include[1:]: - print(f" {include_dirname}") - print("Annotation: ", "on" if args.annotate else "off") print() @@ -920,40 +903,23 @@ def print_annotated_src_files( dict_line_cc = dict_fl_dict_line_cc.pop("???", None) add_dict_line_cc_to_cc(dict_line_cc, annotated_ccs.files_unknown_cc) - # Prepend "" to the include dirnames so things work in the case where the - # filename has the full path. - include_dirnames = args.include.copy() - include_dirnames.insert(0, "") - def print_ann_fancy(src_filename: str) -> None: print_fancy(f"Annotated source file: {src_filename}") for src_filename in sorted(ann_src_filenames): - readable = False - for include_dirname in include_dirnames: - if include_dirname == "": - full_src_filename = src_filename - else: - full_src_filename = os.path.join(include_dirname, src_filename) - - try: - with open(full_src_filename, "r", encoding="utf-8") as src_file: - dict_line_cc = dict_fl_dict_line_cc.pop(src_filename, None) - assert dict_line_cc is not None - print_ann_fancy(src_file.name) # includes full path - print_annotated_src_file( - events, - dict_line_cc, - src_file, - annotated_ccs, - summary_cc, - ) - readable = True - break - except OSError: - pass - - if not readable: + try: + with open(src_filename, "r", encoding="utf-8") as src_file: + dict_line_cc = dict_fl_dict_line_cc.pop(src_filename, None) + assert dict_line_cc is not None + print_ann_fancy(src_filename) + print_annotated_src_file( + events, + dict_line_cc, + src_file, + annotated_ccs, + summary_cc, + ) + except OSError: dict_line_cc = dict_fl_dict_line_cc.pop(src_filename, None) add_dict_line_cc_to_cc(dict_line_cc, annotated_ccs.unreadable_cc) diff --git a/cachegrind/tests/Makefile.am b/cachegrind/tests/Makefile.am index 0c7219a9bc..d38d300b90 100644 --- a/cachegrind/tests/Makefile.am +++ b/cachegrind/tests/Makefile.am @@ -24,7 +24,6 @@ EXTRA_DIST = \ ann2.post.exp ann2.stderr.exp ann2.vgtest ann2.cgout \ ann2-basic.rs ann2-more-recent-than-cgout.rs \ ann2-negatives.rs ann2-past-the-end.rs \ - ann2-aux/ann2-via-I.rs \ chdir.vgtest chdir.stderr.exp \ clreq.vgtest clreq.stderr.exp \ dlclose.vgtest dlclose.stderr.exp dlclose.stdout.exp \ diff --git a/cachegrind/tests/ann-diff1.post.exp b/cachegrind/tests/ann-diff1.post.exp index 4e13f0c089..54962b513d 100644 --- a/cachegrind/tests/ann-diff1.post.exp +++ b/cachegrind/tests/ann-diff1.post.exp @@ -8,7 +8,6 @@ Events recorded: Ir I1mr ILmr Dr D1mr DLmr Dw D1mw DLmw Events shown: Ir I1mr ILmr Dr D1mr DLmr Dw D1mw DLmw Event sort order: Ir I1mr ILmr Dr D1mr DLmr Dw D1mw DLmw Threshold: 0.1 -Include dirs: Annotation: on -------------------------------------------------------------------------------- diff --git a/cachegrind/tests/ann-diff2.post.exp b/cachegrind/tests/ann-diff2.post.exp index bcf09ea9ca..e1060dbd23 100644 --- a/cachegrind/tests/ann-diff2.post.exp +++ b/cachegrind/tests/ann-diff2.post.exp @@ -8,7 +8,6 @@ Events recorded: One Two Events shown: One Two Event sort order: One Two Threshold: 0.1 -Include dirs: Annotation: on -------------------------------------------------------------------------------- diff --git a/cachegrind/tests/ann-merge1.post.exp b/cachegrind/tests/ann-merge1.post.exp index f12f1c235d..1f47332b8a 100644 --- a/cachegrind/tests/ann-merge1.post.exp +++ b/cachegrind/tests/ann-merge1.post.exp @@ -9,7 +9,6 @@ Events recorded: A Events shown: A Event sort order: A Threshold: 0.1 -Include dirs: Annotation: on -------------------------------------------------------------------------------- diff --git a/cachegrind/tests/ann1a.post.exp b/cachegrind/tests/ann1a.post.exp index a83767cb0a..bde53e6501 100644 --- a/cachegrind/tests/ann1a.post.exp +++ b/cachegrind/tests/ann1a.post.exp @@ -10,7 +10,6 @@ Events recorded: Ir I1mr ILmr Dr D1mr DLmr Dw D1mw DLmw Events shown: Ir I1mr ILmr Event sort order: Ir I1mr ILmr Dr D1mr DLmr Dw D1mw DLmw Threshold: 0.1 -Include dirs: Annotation: on -------------------------------------------------------------------------------- diff --git a/cachegrind/tests/ann1b.post.exp b/cachegrind/tests/ann1b.post.exp index b76b4236f2..3ec4288cb4 100644 --- a/cachegrind/tests/ann1b.post.exp +++ b/cachegrind/tests/ann1b.post.exp @@ -10,7 +10,6 @@ Events recorded: Ir I1mr ILmr Dr D1mr DLmr Dw D1mw DLmw Events shown: Dw Dr Ir Event sort order: Dr Threshold: 0.1 -Include dirs: Annotation: off -------------------------------------------------------------------------------- diff --git a/cachegrind/tests/ann2-aux/ann2-via-I.rs b/cachegrind/tests/ann2-aux/ann2-via-I.rs deleted file mode 100644 index 5626abf0f7..0000000000 --- a/cachegrind/tests/ann2-aux/ann2-via-I.rs +++ /dev/null @@ -1 +0,0 @@ -one diff --git a/cachegrind/tests/ann2-past-the-end.rs b/cachegrind/tests/ann2-past-the-end.rs index 4cb29ea38f..b2f931a673 100644 --- a/cachegrind/tests/ann2-past-the-end.rs +++ b/cachegrind/tests/ann2-past-the-end.rs @@ -1,3 +1,5 @@ one two three +four +five diff --git a/cachegrind/tests/ann2.cgout b/cachegrind/tests/ann2.cgout index b5d62b1806..2be80fe1ea 100644 --- a/cachegrind/tests/ann2.cgout +++ b/cachegrind/tests/ann2.cgout @@ -71,9 +71,11 @@ fn=neg4 # File with source newer than the cgout file. fl=ann2-past-the-end.rs -# This filename is repeated in ann2-could-not-be-found.rs above. +# No `fn=` line yet, so the function name falls back to ``. +1 1000 500 0 +# This funcname is repeated in ann2-could-not-be-found.rs above. fn=f1 -1 200 100 0 +2 200 100 0 20 300 100 0 21 300 100 0 22 200 0 -1000 @@ -85,11 +87,6 @@ fn=f1 101 3000 2000 0 102 3000 2000 0 -# File found in ann2-aux/, via -I. -fl=ann2-via-I.rs -# No `fn=` line, so the function name falls back to ``. -1 1000 500 0 - # File below the threshold. (It also doesn't exist, but that doesn't matter. We # don't try to open it because it's below the threshold.) fl=ann2-below-threshold.rs diff --git a/cachegrind/tests/ann2.post.exp b/cachegrind/tests/ann2.post.exp index 5cfdbfd1df..8db35f136f 100644 --- a/cachegrind/tests/ann2.post.exp +++ b/cachegrind/tests/ann2.post.exp @@ -7,9 +7,6 @@ Events recorded: A SomeCount VeryLongEventName Events shown: A SomeCount VeryLongEventName Event sort order: A SomeCount VeryLongEventName Threshold: 0.5 -Include dirs: ann2-no-such-dir - ann2-no-such-dir-2 - ann2-aux Annotation: on -------------------------------------------------------------------------------- @@ -33,9 +30,9 @@ A_______________ SomeCount_______ VeryLongEventName > 9,000 (9.0%, 95.6%) 6,000 (6.0%, 99.0%) 0 (n/a, n/a) ann2-could-not-be-found.rs:f1 -> 1,000 (1.0%, 96.6%) 500 (0.5%, 99.5%) 0 (n/a, n/a) ann2-via-I.rs: - -> 1,000 (1.0%, 97.6%) 300 (0.3%, 99.8%) -1,000 (n/a, n/a) ann2-past-the-end.rs:f1 +> 2,000 (2.0%, 97.6%) 800 (0.8%, 99.8%) -1,000 (n/a, n/a) ann2-past-the-end.rs: + 1,000 (1.0%) 500 (0.5%) 0 + 1,000 (1.0%) 300 (0.3%) -1,000 (n/a) f1 > 1,000 (1.0%, 98.6%) 0 (0.0%, 99.8%) 0 (n/a, n/a) ann2-more-recent-than-cgout.rs:new @@ -66,7 +63,7 @@ A_______________ SomeCount_______ VeryLongEventName > 2,000 (2.0%, 95.1%) 100 (0.1%, 97.3%) 0 (n/a, n/a) f2:ann2-basic.rs -> 1,000 (1.0%, 96.1%) 500 (0.5%, 97.8%) 0 (n/a, n/a) :ann2-via-I.rs +> 1,000 (1.0%, 96.1%) 500 (0.5%, 97.8%) 0 (n/a, n/a) :ann2-past-the-end.rs > 1,000 (1.0%, 97.1%) 0 (0.0%, 97.8%) 0 (n/a, n/a) unknown:??? @@ -154,16 +151,17 @@ A____________________ SomeCount_____ VeryLongEventName -------------------------------------------------------------------------------- -- Annotated source file: ann2-past-the-end.rs -------------------------------------------------------------------------------- -A_________ SomeCount_ VeryLongEventName +A___________ SomeCount_ VeryLongEventName -200 (0.2%) 100 (0.1%) 0 one - . . . two - . . . three --- line 3 ---------------------------------------- +1,000 (1.0%) 500 (0.5%) 0 one + 200 (0.2%) 100 (0.1%) 0 two + . . . three + . . . four +-- line 4 ---------------------------------------- -300 (0.3%) 100 (0.1%) 0 -300 (0.3%) 100 (0.1%) 0 -200 (0.2%) 0 -1,000 (n/a) + 300 (0.3%) 100 (0.1%) 0 + 300 (0.3%) 100 (0.1%) 0 + 200 (0.2%) 0 -1,000 (n/a) @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@ WARNING @@ WARNING @@ WARNING @@ WARNING @@ WARNING @@ WARNING @@ WARNING @@ @@ -171,13 +169,6 @@ A_________ SomeCount_ VeryLongEventName @@ Information recorded about lines past the end of 'ann2-past-the-end.rs'. @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ --------------------------------------------------------------------------------- --- Annotated source file: ann2-aux/ann2-via-I.rs --------------------------------------------------------------------------------- -A___________ SomeCount_ VeryLongEventName - -1,000 (1.0%) 500 (0.5%) 0 one - -------------------------------------------------------------------------------- -- Annotation summary -------------------------------------------------------------------------------- diff --git a/cachegrind/tests/ann2.vgtest b/cachegrind/tests/ann2.vgtest index 9fb0d1b86f..4add2fe4cc 100644 --- a/cachegrind/tests/ann2.vgtest +++ b/cachegrind/tests/ann2.vgtest @@ -8,6 +8,6 @@ vgopts: --cachegrind-out-file=cachegrind.out # The `sleep` is to ensure the mtime of the second touched file is greater than # the mtime of the first touched file. -post: touch ann2.cgout && sleep 0.1 && touch ann2-more-recent-than-cgout.rs && python3 ../cg_annotate --context 2 --annotate --show-percs=yes --threshold=0.5 -Iann2-no-such-dir --include ann2-no-such-dir-2 -I=ann2-aux ann2.cgout +post: touch ann2.cgout && sleep 0.1 && touch ann2-more-recent-than-cgout.rs && python3 ../cg_annotate --context 2 --annotate --show-percs=yes --threshold=0.5 ann2.cgout cleanup: rm cachegrind.out