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 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 InitializeReproducer(opt::InputArgList &input_args) { +llvm::Optional 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(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(argv[0])); - SBError error = SBDebugger::InitializeWithErrorHandling(); if (error.Fail()) { WithColor::error() << "initialization failed: " << error.GetCString() 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 .">; 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.">;