]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
cg_annotate: Remove the `-I`/`--include` option. users/njn/try-rm-I
authorNicholas Nethercote <n.nethercote@gmail.com>
Sun, 16 Apr 2023 23:34:11 +0000 (09:34 +1000)
committerNicholas Nethercote <n.nethercote@gmail.com>
Tue, 18 Apr 2023 22:41:08 +0000 (08:41 +1000)
For much the same reasons that I removed user annotations recently: it's
rarely/never used, and complicates things.

12 files changed:
cachegrind/cg_annotate.in
cachegrind/tests/Makefile.am
cachegrind/tests/ann-diff1.post.exp
cachegrind/tests/ann-diff2.post.exp
cachegrind/tests/ann-merge1.post.exp
cachegrind/tests/ann1a.post.exp
cachegrind/tests/ann1b.post.exp
cachegrind/tests/ann2-aux/ann2-via-I.rs [deleted file]
cachegrind/tests/ann2-past-the-end.rs
cachegrind/tests/ann2.cgout
cachegrind/tests/ann2.post.exp
cachegrind/tests/ann2.vgtest

index 0b68e094c3a66260d2c4f71842bf4456c60a6533..5e64a94485b95a53d04d5068eaa03631f455504d 100755 (executable)
@@ -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)
 
index 0c7219a9bc091ed7b5d1b42306f80b1f78305b9e..d38d300b90b489cbe40d91eb561446de5142eb1c 100644 (file)
@@ -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 \
index 4e13f0c0896b5311924e9386b503916b78398ff0..54962b513d3ba301ea3ca63ebdac797ceb9549f9 100644 (file)
@@ -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
 
 --------------------------------------------------------------------------------
index bcf09ea9cad73cbb275fc59f8ddf28831f15f707..e1060dbd232c5d5ea8f51190ac333af15da8532f 100644 (file)
@@ -8,7 +8,6 @@ Events recorded:  One Two
 Events shown:     One Two
 Event sort order: One Two
 Threshold:        0.1
-Include dirs:     
 Annotation:       on
 
 --------------------------------------------------------------------------------
index f12f1c235de35ee389d67e42cc09c64724fa20fb..1f47332b8a586321150ebb373b695d020d2ead46 100644 (file)
@@ -9,7 +9,6 @@ Events recorded:  A
 Events shown:     A
 Event sort order: A
 Threshold:        0.1
-Include dirs:     
 Annotation:       on
 
 --------------------------------------------------------------------------------
index a83767cb0a74d37c42f37bf466adb79efd93002f..bde53e650116bdfdec78200288cf4fb358d78514 100644 (file)
@@ -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
 
 --------------------------------------------------------------------------------
index b76b4236f2e56aa8916d88c88c273d6f1a15c26c..3ec4288cb493df000a97e20461b16495a28a11fb 100644 (file)
@@ -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 (file)
index 5626abf..0000000
+++ /dev/null
@@ -1 +0,0 @@
-one
index 4cb29ea38f70d7c61b2a3a25b02e3bdf44905402..b2f931a67315c95c5daab3aac6de62e534808476 100644 (file)
@@ -1,3 +1,5 @@
 one
 two
 three
+four
+five
index b5d62b1806fd7fd7e44dc16fd25064036f863716..2be80fe1ea0d5a59518fd6722909cacffa3f0a40 100644 (file)
@@ -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 `<unspecified>`.
+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 `<unspecified>`.
-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
index 5cfdbfd1df913efdfd44194589c2494bd66f3154..8db35f136fd98c9d30c8a0d5575afb7d32ad915b 100644 (file)
@@ -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:<unspecified>
-
->      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               <unspecified>
+       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)  <unspecified>:ann2-via-I.rs
+>      1,000     (1.0%,    96.1%)    500  (0.5%, 97.8%)        0 (n/a, n/a)  <unspecified>: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        <bogus line 20>
-300 (0.3%) 100 (0.1%)           0        <bogus line 21>
-200 (0.2%)   0             -1,000 (n/a)  <bogus line 22>
+  300 (0.3%) 100 (0.1%)           0        <bogus line 20>
+  300 (0.3%) 100 (0.1%)           0        <bogus line 21>
+  200 (0.2%)   0             -1,000 (n/a)  <bogus line 22>
 
 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 @@ 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
 --------------------------------------------------------------------------------
index 9fb0d1b86f462f1d703ae9c9058432069949aa4b..4add2fe4ccc3601baa6df60c3c4707706976f73f 100644 (file)
@@ -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