summaryrefslogtreecommitdiffstats
path: root/lldb/tools/driver/Driver.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/tools/driver/Driver.cpp')
-rw-r--r--lldb/tools/driver/Driver.cpp51
1 files changed, 34 insertions, 17 deletions
diff --git a/lldb/tools/driver/Driver.cpp b/lldb/tools/driver/Driver.cpp
index ad611426560..46532430549 100644
--- a/lldb/tools/driver/Driver.cpp
+++ b/lldb/tools/driver/Driver.cpp
@@ -849,6 +849,38 @@ EXAMPLES:
llvm::outs() << examples;
}
+llvm::Optional<int> InitializeReproducer(opt::InputArgList &input_args) {
+ if (auto *replay_path = input_args.getLastArg(OPT_replay)) {
+ if (const char *error = SBReproducer::Replay(replay_path->getValue())) {
+ WithColor::error() << "reproducer replay failed: " << error << '\n';
+ return 1;
+ }
+ return 0;
+ }
+
+ bool capture = input_args.hasArg(OPT_capture);
+ auto *capture_path = input_args.getLastArg(OPT_capture_path);
+
+ if (capture || capture_path) {
+ if (capture_path) {
+ if (!capture)
+ WithColor::warning() << "-capture-path specified without -capture\n";
+ if (const char *error = SBReproducer::Capture(capture_path->getValue())) {
+ WithColor::error() << "reproducer capture failed: " << error << '\n';
+ return 1;
+ }
+ } else {
+ const char *error = SBReproducer::Capture();
+ if (error) {
+ WithColor::error() << "reproducer capture failed: " << error << '\n';
+ return 1;
+ }
+ }
+ }
+
+ return llvm::None;
+}
+
int
#ifdef _MSC_VER
wmain(int argc, wchar_t const *wargv[])
@@ -889,23 +921,8 @@ main(int argc, char const *argv[])
<< '\n';
}
- if (auto *arg = input_args.getLastArg(OPT_capture)) {
- auto arg_value = arg->getValue();
- const char *error = SBReproducer::Capture(arg_value);
- if (error) {
- WithColor::error() << "reproducer capture failed: " << error << '\n';
- return 1;
- }
- }
-
- if (auto *arg = input_args.getLastArg(OPT_replay)) {
- auto arg_value = arg->getValue();
- const char *error = SBReproducer::Replay(arg_value);
- if (error) {
- WithColor::error() << "reproducer replay failed: " << error << '\n';
- return 1;
- }
- return 0;
+ if (auto exit_code = InitializeReproducer(input_args)) {
+ return *exit_code;
}
SBError error = SBDebugger::InitializeWithErrorHandling();
OpenPOWER on IntegriCloud