1254721Semaste//===-- Driver.h ------------------------------------------------*- C++ -*-===// 2254721Semaste// 3353358Sdim// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4353358Sdim// See https://llvm.org/LICENSE.txt for license information. 5353358Sdim// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6254721Semaste// 7254721Semaste//===----------------------------------------------------------------------===// 8254721Semaste 9254721Semaste#ifndef lldb_Driver_h_ 10254721Semaste#define lldb_Driver_h_ 11254721Semaste 12258054Semaste#include "Platform.h" 13254721Semaste 14254721Semaste#include "lldb/API/SBBroadcaster.h" 15254721Semaste#include "lldb/API/SBDebugger.h" 16314564Sdim#include "lldb/API/SBDefines.h" 17254721Semaste#include "lldb/API/SBError.h" 18254721Semaste 19344779Sdim#include "llvm/Option/Arg.h" 20344779Sdim#include "llvm/Option/ArgList.h" 21344779Sdim#include "llvm/Option/Option.h" 22254721Semaste 23344779Sdim#include <set> 24344779Sdim#include <string> 25344779Sdim#include <vector> 26344779Sdim 27314564Sdimclass Driver : public lldb::SBBroadcaster { 28254721Semastepublic: 29353358Sdim enum CommandPlacement { 30314564Sdim eCommandPlacementBeforeFile, 31314564Sdim eCommandPlacementAfterFile, 32314564Sdim eCommandPlacementAfterCrash, 33353358Sdim }; 34280031Sdim 35314564Sdim Driver(); 36254721Semaste 37314564Sdim virtual ~Driver(); 38254721Semaste 39341825Sdim /// Runs the main loop. 40341825Sdim /// 41353358Sdim /// \return The exit code that the process should return. 42341825Sdim int MainLoop(); 43254721Semaste 44344779Sdim lldb::SBError ProcessArgs(const llvm::opt::InputArgList &args, bool &exiting); 45254721Semaste 46314564Sdim void WriteCommandsForSourcing(CommandPlacement placement, 47314564Sdim lldb::SBStream &strm); 48254721Semaste 49344779Sdim struct OptionData { 50344779Sdim void AddInitialCommand(std::string command, CommandPlacement placement, 51314564Sdim bool is_file, lldb::SBError &error); 52254721Semaste 53314564Sdim struct InitialCmdEntry { 54344779Sdim InitialCmdEntry(std::string contents, bool in_is_file, 55353358Sdim bool in_quiet = false) 56344779Sdim : contents(std::move(contents)), is_file(in_is_file), 57353358Sdim source_quietly(in_quiet) {} 58280031Sdim 59314564Sdim std::string contents; 60314564Sdim bool is_file; 61314564Sdim bool source_quietly; 62254721Semaste }; 63254721Semaste 64314564Sdim std::vector<std::string> m_args; 65344779Sdim 66344779Sdim lldb::LanguageType m_repl_lang = lldb::eLanguageTypeUnknown; 67344779Sdim lldb::pid_t m_process_pid = LLDB_INVALID_PROCESS_ID; 68344779Sdim 69314564Sdim std::string m_core_file; 70314564Sdim std::string m_crash_log; 71344779Sdim std::string m_repl_options; 72344779Sdim std::string m_process_name; 73344779Sdim 74314564Sdim std::vector<InitialCmdEntry> m_initial_commands; 75314564Sdim std::vector<InitialCmdEntry> m_after_file_commands; 76314564Sdim std::vector<InitialCmdEntry> m_after_crash_commands; 77344779Sdim 78344779Sdim bool m_debug_mode = false; 79344779Sdim bool m_source_quietly = false; 80344779Sdim bool m_print_version = false; 81344779Sdim bool m_print_python_path = false; 82344779Sdim bool m_wait_for = false; 83344779Sdim bool m_repl = false; 84344779Sdim bool m_batch = false; 85344779Sdim 86344779Sdim // FIXME: When we have set/show variables we can remove this from here. 87344779Sdim bool m_use_external_editor = false; 88344779Sdim 89344779Sdim using OptionSet = std::set<char>; 90314564Sdim OptionSet m_seen_options; 91314564Sdim }; 92254721Semaste 93314564Sdim lldb::SBDebugger &GetDebugger() { return m_debugger; } 94254721Semaste 95314564Sdim void ResizeWindow(unsigned short col); 96254721Semaste 97254721Semasteprivate: 98314564Sdim lldb::SBDebugger m_debugger; 99314564Sdim OptionData m_option_data; 100254721Semaste}; 101254721Semaste 102254721Semaste#endif // lldb_Driver_h_ 103