[PATCH] D139543: [DFSan] Add callback that allows to track which function tainted data reaches

Andrew via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 7 10:35:15 PST 2022


browneee added inline comments.


================
Comment at: compiler-rt/test/dfsan/reaches_function.c:4
+// RUN: %run %t
+//
+// REQUIRES: x86_64-target-arch
----------------
Can you make this test build and run a second time with origin tracking enabled?
e.g. https://github.com/llvm/llvm-project/blob/91b38c6aaddefabad2a4c959ea3865e356761ed5/compiler-rt/test/dfsan/flush.c#L3

When origin tracking is enabled (use #ifdef), you could also call dfsan_print_origin_id_trace and add filecheck expectations for that output.


================
Comment at: compiler-rt/test/dfsan/reaches_function.c:20-21
+                                        const char *function) {
+  assert(line == 26 || line == 36);
+  assert(strcmp(function, "main") == 0 || strcmp(function, "add.dfsan") == 0);
+}
----------------
It may be a better approach to:
- print the file,line,function here
- pipe the output into filecheck
- add filecheck expectations to match for the printed lines, put them at each function and use [[@LINE-1]]

The advantages of this would be:
- you can use https://llvm.org/docs/CommandGuide/FileCheck.html#filecheck-pseudo-numeric-variables instead of integer constants, easier to keep test up to date
- you would be testing for function + line pair together
- if it failed you could easily see the file,line,function values
- Can also check origin traces.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D139543/new/

https://reviews.llvm.org/D139543



More information about the llvm-commits mailing list