[PATCH] D46546: [sanitizer] Add suffix to report file name

Vitaly Buka via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 4 13:50:29 PST 2021


This revision was automatically updated to reflect the committed changes.
Closed by commit rGdd5c2b8de92d: [sanitizer] Add suffix to report file name (authored by WallStProg, committed by vitalybuka).
Herald added a project: Sanitizers.

Changed prior to commit:
  https://reviews.llvm.org/D46546?vs=146369&id=321562#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D46546

Files:
  compiler-rt/lib/sanitizer_common/sanitizer_file.cpp
  compiler-rt/lib/sanitizer_common/sanitizer_flags.inc
  compiler-rt/test/sanitizer_common/TestCases/suffix-log-path_test.c


Index: compiler-rt/test/sanitizer_common/TestCases/suffix-log-path_test.c
===================================================================
--- /dev/null
+++ compiler-rt/test/sanitizer_common/TestCases/suffix-log-path_test.c
@@ -0,0 +1,22 @@
+// RUN: %clang %s -o %T/suffix-log-path_test-binary
+
+// The glob below requires bash.
+// REQUIRES: shell
+
+// Good log_path with suffix.
+// RUN: rm -f %T/sanitizer.log.*.txt
+// RUN: %env_tool_opts=log_path=%T/sanitizer.log:log_exe_name=1:log_suffix=.txt %run %T/suffix-log-path_test-binary 2> %t.out
+// RUN: FileCheck %s < %T/sanitizer.log.suffix-log-path_test-binary.*.txt
+
+// UNSUPPORTED: ios, android
+
+#include <stdlib.h>
+#include <string.h>
+
+#include <sanitizer/common_interface_defs.h>
+
+int main(int argc, char **argv) {
+  __sanitizer_print_stack_trace();
+  return 0;
+}
+// CHECK: #{{.*}} main
Index: compiler-rt/lib/sanitizer_common/sanitizer_flags.inc
===================================================================
--- compiler-rt/lib/sanitizer_common/sanitizer_flags.inc
+++ compiler-rt/lib/sanitizer_common/sanitizer_flags.inc
@@ -59,6 +59,8 @@
     bool, log_exe_name, false,
     "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, (bool)SANITIZER_ANDROID || (bool)SANITIZER_MAC,
     "Write all sanitizer output to syslog in addition to other means of "
Index: compiler-rt/lib/sanitizer_common/sanitizer_file.cpp
===================================================================
--- compiler-rt/lib/sanitizer_common/sanitizer_file.cpp
+++ compiler-rt/lib/sanitizer_common/sanitizer_file.cpp
@@ -58,6 +58,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);
+  }
   error_t err;
   fd = OpenFile(full_path, WrOnly, &err);
   if (fd == kInvalidFd) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D46546.321562.patch
Type: text/x-patch
Size: 2125 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210204/c8123636/attachment.bin>


More information about the llvm-commits mailing list