[PATCH] D140388: llvm-reduce: Disable crash reports, symbolization and core dumps
Matt Arsenault via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 20 04:49:20 PST 2022
arsenm updated this revision to Diff 484220.
arsenm added a comment.
Use consistent overwrite behavior
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D140388/new/
https://reviews.llvm.org/D140388
Files:
llvm/test/tools/llvm-reduce/Inputs/test-crash-vars.py
llvm/test/tools/llvm-reduce/disable-crash-reports.test
llvm/tools/llvm-reduce/llvm-reduce.cpp
Index: llvm/tools/llvm-reduce/llvm-reduce.cpp
===================================================================
--- llvm/tools/llvm-reduce/llvm-reduce.cpp
+++ llvm/tools/llvm-reduce/llvm-reduce.cpp
@@ -18,9 +18,9 @@
#include "ReducerWorkItem.h"
#include "TestRunner.h"
#include "llvm/CodeGen/CommandFlags.h"
-
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/InitLLVM.h"
+#include "llvm/Support/Process.h"
#include "llvm/Support/WithColor.h"
#include "llvm/Support/raw_ostream.h"
#include <system_error>
@@ -35,6 +35,12 @@
static cl::opt<bool> Version("v", cl::desc("Alias for -version"), cl::Hidden,
cl::cat(LLVMReduceOptions));
+static cl::opt<bool> PreserveDebugEnvironment(
+ "preserve-debug-environment",
+ cl::desc("Don't disable features used for crash "
+ "debugging (crash reports, llvm-symbolizer and core dumps)"),
+ cl::cat(LLVMReduceOptions));
+
static cl::opt<bool>
PrintDeltaPasses("print-delta-passes",
cl::desc("Print list of delta passes, passable to "
@@ -93,6 +99,23 @@
bool isReduced(ReducerWorkItem &M, const TestRunner &Test);
+/// Turn off crash debugging features
+///
+/// Crash is expected, so disable crash reports and symbolization to reduce
+/// output clutter and avoid potentially slow symbolization.
+static void disableEnvironmentDebugFeatures() {
+ sys::Process::PreventCoreFiles();
+
+ // TODO: Copied from not. Should have a wrapper around setenv.
+#ifdef _WIN32
+ SetEnvironmentVariableA("LLVM_DISABLE_CRASH_REPORT", "1");
+ SetEnvironmentVariableA("LLVM_DISABLE_SYMBOLIZATION", "1");
+#else
+ setenv("LLVM_DISABLE_CRASH_REPORT", "1", /*overwrite=*/1);
+ setenv("LLVM_DISABLE_SYMBOLIZATION", "1", /*overwrite=*/1);
+#endif
+}
+
static std::pair<StringRef, bool> determineOutputType(bool IsMIR,
bool InputIsBitcode) {
bool OutputBitcode = ForceOutputBitcode || InputIsBitcode;
@@ -146,6 +169,9 @@
return 0;
}
+ if (!PreserveDebugEnvironment)
+ disableEnvironmentDebugFeatures();
+
LLVMContext Context;
std::unique_ptr<TargetMachine> TM;
Index: llvm/test/tools/llvm-reduce/disable-crash-reports.test
===================================================================
--- /dev/null
+++ llvm/test/tools/llvm-reduce/disable-crash-reports.test
@@ -0,0 +1,6 @@
+# RUN: llvm-reduce --delta-passes=global-variables --test %python --test-arg %p/Inputs/test-crash-vars.py %p/Inputs/test-output-format.ll 2>&1 | FileCheck -check-prefix=INTERESTING %s
+
+# RUN: not llvm-reduce --preserve-debug-environment --delta-passes=global-variables --test %python --test-arg %p/Inputs/test-crash-vars.py %p/Inputs/test-output-format.ll 2>&1 | FileCheck -check-prefix=NOTINTERESTING %s
+
+INTERESTING: Done reducing! Reduced testcase:
+NOTINTERESTING: Input isn't interesting! Verify interesting-ness test
Index: llvm/test/tools/llvm-reduce/Inputs/test-crash-vars.py
===================================================================
--- /dev/null
+++ llvm/test/tools/llvm-reduce/Inputs/test-crash-vars.py
@@ -0,0 +1,7 @@
+import os
+import sys
+
+disable_crash_report = os.getenv("LLVM_DISABLE_CRASH_REPORT")
+disable_symbolization = os.getenv("LLVM_DISABLE_SYMBOLIZATION")
+
+sys.exit(disable_crash_report != "1" or disable_symbolization != "1")
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D140388.484220.patch
Type: text/x-patch
Size: 3360 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221220/2d4d34de/attachment.bin>
More information about the llvm-commits
mailing list