[Lldb-commits] [PATCH] D83496: [Reproducers] Add --reproducer-no-generate-on-signal to avoid installing the signal handler.
Jonas Devlieghere via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Thu Jul 9 11:42:30 PDT 2020
JDevlieghere updated this revision to Diff 276790.
JDevlieghere retitled this revision from "[Reproducers] Add --reproducer-no-signal-handler to avoid installing the signal handler." to "[Reproducers] Add --reproducer-no-generate-on-signal to avoid installing the signal handler.".
JDevlieghere added a comment.
Detach flag name from implementation.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D83496/new/
https://reviews.llvm.org/D83496
Files:
lldb/test/Shell/Reproducer/TestCrash.test
lldb/tools/driver/Driver.cpp
lldb/tools/driver/Options.td
Index: lldb/tools/driver/Options.td
===================================================================
--- lldb/tools/driver/Options.td
+++ lldb/tools/driver/Options.td
@@ -234,6 +234,8 @@
HelpText<"Tells the debugger to replay a reproducer from <filename>.">;
def no_version_check: F<"reproducer-no-version-check">,
HelpText<"Disable the reproducer version check.">;
+def no_generate_on_signal: F<"reproducer-no-generate-on-signal">,
+ HelpText<"Don't generate reproducer when a signal is received.">;
def generate_on_exit: F<"reproducer-generate-on-exit">,
HelpText<"Generate reproducer on exit.">;
Index: lldb/tools/driver/Driver.cpp
===================================================================
--- lldb/tools/driver/Driver.cpp
+++ lldb/tools/driver/Driver.cpp
@@ -797,7 +797,8 @@
llvm::outs() << examples << '\n';
}
-llvm::Optional<int> InitializeReproducer(opt::InputArgList &input_args) {
+llvm::Optional<int> InitializeReproducer(llvm::StringRef argv0,
+ opt::InputArgList &input_args) {
if (auto *replay_path = input_args.getLastArg(OPT_replay)) {
const bool no_version_check = input_args.hasArg(OPT_no_version_check);
if (const char *error =
@@ -818,6 +819,12 @@
}
if (capture || capture_path) {
+ // Register the reproducer signal handler.
+ if (!input_args.hasArg(OPT_no_generate_on_signal)) {
+ llvm::sys::AddSignalHandler(reproducer_handler,
+ const_cast<char *>(argv0.data()));
+ }
+
if (capture_path) {
if (!capture)
WithColor::warning() << "-capture-path specified without -capture\n";
@@ -867,13 +874,10 @@
return 1;
}
- if (auto exit_code = InitializeReproducer(input_args)) {
+ if (auto exit_code = InitializeReproducer(argv[0], input_args)) {
return *exit_code;
}
- // Register the reproducer signal handler.
- llvm::sys::AddSignalHandler(reproducer_handler, const_cast<char *>(argv[0]));
-
SBError error = SBDebugger::InitializeWithErrorHandling();
if (error.Fail()) {
WithColor::error() << "initialization failed: " << error.GetCString()
Index: lldb/test/Shell/Reproducer/TestCrash.test
===================================================================
--- lldb/test/Shell/Reproducer/TestCrash.test
+++ lldb/test/Shell/Reproducer/TestCrash.test
@@ -10,3 +10,8 @@
# CHECK: Crash reproducer for
# CHECK: Reproducer written to
# CHECK: ********************
+
+# RUN: %lldb -b --capture --capture-path %t.repro --reproducer-no-generate-on-signal -o 'reproducer xcrash -s SIGSEGV' | FileCheck %s --check-prefix NOHANDLER
+
+# NOHANDLER-NOT: Crash reproducer
+# NOHANDLER-NOT: Reproducer written
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83496.276790.patch
Type: text/x-patch
Size: 2709 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20200709/b35dcf14/attachment-0001.bin>
More information about the lldb-commits
mailing list