[PATCH] D46546: add suffix to report file name
Bill Torpey via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri May 11 11:34:16 PDT 2018
WallStProg updated this revision to Diff 146369.
WallStProg added a comment.
Herald added a subscriber: srhines.
Well, I've added a test pgm but the only way I've been able to is within asan (using monkey-see, monkey-do approach ;-) The test is modeled on existing verbose-log-path_test, and appears to run successfully with "make check-all".
Getting this into sanitizer-common is way beyond what I can hope to do at this point. If you can provide some pointers on writing tests I can take another shot at it (although frankly I'd much rather not ;-)
Hope this is sufficient -- pls let me know.
https://reviews.llvm.org/D46546
Files:
projects/compiler-rt/lib/sanitizer_common/sanitizer_file.cc
projects/compiler-rt/lib/sanitizer_common/sanitizer_flags.inc
projects/compiler-rt/test/asan/TestCases/suffix-log-path_test.cc
Index: projects/compiler-rt/test/asan/TestCases/suffix-log-path_test.cc
===================================================================
--- projects/compiler-rt/test/asan/TestCases/suffix-log-path_test.cc
+++ projects/compiler-rt/test/asan/TestCases/suffix-log-path_test.cc
@@ -0,0 +1,26 @@
+// RUN: %clangxx_asan %s -o %T/suffix-log-path_test-binary
+
+// The glob below requires bash.
+// REQUIRES: shell
+
+// Good log_path with suffix.
+// RUN: rm -f %T/asan.log.*.txt
+// RUN: %env_asan_opts=log_path=%T/asan.log:log_exe_name=1:log_suffix=.txt not %run %T/suffix-log-path_test-binary 2> %t.out
+// RUN: FileCheck %s --check-prefix=CHECK-ERROR < %T/asan.log.suffix-log-path_test-binary.*.txt
+
+// FIXME: only FreeBSD, NetBSD and Linux have verbose log paths now.
+// XFAIL: win32,android
+// UNSUPPORTED: ios
+
+#include <stdlib.h>
+#include <string.h>
+int main(int argc, char **argv) {
+ if (argc > 2) return 0;
+ char *x = (char*)malloc(10);
+ memset(x, 0, 10);
+ int res = x[argc * 10]; // BOOOM
+ free(x);
+ return res;
+}
+// CHECK-ERROR: ERROR: AddressSanitizer
+
Index: projects/compiler-rt/lib/sanitizer_common/sanitizer_flags.inc
===================================================================
--- projects/compiler-rt/lib/sanitizer_common/sanitizer_flags.inc
+++ projects/compiler-rt/lib/sanitizer_common/sanitizer_flags.inc
@@ -56,6 +56,9 @@
"Mention name of executable when reporting error and "
"append executable name to logs (as in \"log_path.exe_name.pid\").")
COMMON_FLAG(
+ const char *, log_suffix, nullptr,
+ "String to append to log file name, e.g. \".txt\".")
+COMMON_FLAG(
bool, log_to_syslog, SANITIZER_ANDROID || SANITIZER_MAC,
"Write all sanitizer output to syslog in addition to other means of "
"logging.")
Index: projects/compiler-rt/lib/sanitizer_common/sanitizer_file.cc
===================================================================
--- projects/compiler-rt/lib/sanitizer_common/sanitizer_file.cc
+++ projects/compiler-rt/lib/sanitizer_common/sanitizer_file.cc
@@ -59,6 +59,9 @@
} else {
internal_snprintf(full_path, kMaxPathLength, "%s.%zu", path_prefix, pid);
}
+ if (common_flags()->log_suffix) {
+ internal_strlcat(full_path, common_flags()->log_suffix, kMaxPathLength);
+ }
fd = OpenFile(full_path, WrOnly);
if (fd == kInvalidFd) {
const char *ErrorMsgPrefix = "ERROR: Can't open file: ";
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D46546.146369.patch
Type: text/x-patch
Size: 2412 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180511/a271057c/attachment.bin>
More information about the llvm-commits
mailing list