================ @@ -33,18 +39,59 @@ void RunLLDBCommands(llvm::StringRef prefix, const char *error = result.GetError(); strm << error; } + }; + + lldb::SBCommandInterpreter interp = g_dap.debugger.GetCommandInterpreter(); + for (llvm::StringRef command : commands) { + lldb::SBCommandReturnObject result; + bool quiet_on_success = false; + bool check_error = false; + + while (parse_command_directives) { + if (command.starts_with("?")) { + command = command.drop_front(); + quiet_on_success = true; + } else if (command.starts_with("!")) { + command = command.drop_front(); + check_error = true; + } else { + break; + } + } + + interp.HandleCommand(command.str().c_str(), result); + const bool got_error = !result.Succeeded(); + // The if statement below is assuming we always print out `!` prefixed + // lines. The only time we don't print is when we have `quiet_on_success == + // true` and we don't have an error. + if (quiet_on_success ? got_error : true) + print_result(command, result, strm); + if (check_error && got_error) + return false; // Stop running commands. } + return true; } std::string RunLLDBCommands(llvm::StringRef prefix, - const llvm::ArrayRef<std::string> &commands) { + const llvm::ArrayRef<std::string> &commands, + bool &fatal_error, bool parse_command_directives) { ---------------- clayborg wrote:
The more I think about it `fatal_error` sounds bad, how about we do `required_command_failed` and rename everywhere? https://github.com/llvm/llvm-project/pull/74808 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits