103 lines · c
1//===-- Driver.h ------------------------------------------------*- C++ -*-===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8 9#ifndef LLDB_TOOLS_DRIVER_DRIVER_H10#define LLDB_TOOLS_DRIVER_DRIVER_H11 12#include "Platform.h"13 14#include "lldb/API/SBBroadcaster.h"15#include "lldb/API/SBDebugger.h"16#include "lldb/API/SBDefines.h"17#include "lldb/API/SBError.h"18 19#include "llvm/Option/Arg.h"20#include "llvm/Option/ArgList.h"21#include "llvm/Option/Option.h"22 23#include <set>24#include <string>25#include <vector>26 27class Driver : public lldb::SBBroadcaster {28public:29 enum CommandPlacement {30 eCommandPlacementBeforeFile,31 eCommandPlacementAfterFile,32 eCommandPlacementAfterCrash,33 };34 35 Driver();36 37 virtual ~Driver();38 39 /// Runs the main loop.40 ///41 /// \return The exit code that the process should return.42 int MainLoop();43 44 lldb::SBError ProcessArgs(const llvm::opt::InputArgList &args, bool &exiting);45 46 void WriteCommandsForSourcing(CommandPlacement placement,47 lldb::SBStream &strm);48 49 struct OptionData {50 void AddInitialCommand(std::string command, CommandPlacement placement,51 bool is_file, lldb::SBError &error);52 53 struct InitialCmdEntry {54 InitialCmdEntry(std::string contents, bool in_is_file,55 bool in_quiet = false)56 : contents(std::move(contents)), is_file(in_is_file),57 source_quietly(in_quiet) {}58 59 std::string contents;60 bool is_file;61 bool source_quietly;62 };63 64 std::vector<std::string> m_args;65 66 lldb::LanguageType m_repl_lang = lldb::eLanguageTypeUnknown;67 lldb::pid_t m_process_pid = LLDB_INVALID_PROCESS_ID;68 69 std::string m_core_file;70 std::string m_crash_log;71 std::string m_repl_options;72 std::string m_process_name;73 74 std::vector<InitialCmdEntry> m_initial_commands;75 std::vector<InitialCmdEntry> m_after_file_commands;76 std::vector<InitialCmdEntry> m_after_crash_commands;77 78 bool m_source_quietly = false;79 bool m_print_version = false;80 bool m_print_python_path = false;81 bool m_print_script_interpreter_info = false;82 bool m_wait_for = false;83 bool m_repl = false;84 bool m_batch = false;85 86 // FIXME: When we have set/show variables we can remove this from here.87 bool m_use_external_editor = false;88 89 using OptionSet = std::set<char>;90 OptionSet m_seen_options;91 };92 93 lldb::SBDebugger &GetDebugger() { return m_debugger; }94 95 void UpdateWindowSize();96 97private:98 lldb::SBDebugger m_debugger;99 OptionData m_option_data;100};101 102#endif // LLDB_TOOLS_DRIVER_DRIVER_H103