Driver.h revision 321369
1//===-- Driver.h ------------------------------------------------*- C++ -*-===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9 10#ifndef lldb_Driver_h_ 11#define lldb_Driver_h_ 12 13#include "Platform.h" 14#include "lldb/Host/PseudoTerminal.h" 15 16#include <bitset> 17#include <set> 18#include <string> 19#include <vector> 20 21#include "lldb/API/SBBroadcaster.h" 22#include "lldb/API/SBDebugger.h" 23#include "lldb/API/SBDefines.h" 24#include "lldb/API/SBError.h" 25 26class IOChannel; 27 28class Driver : public lldb::SBBroadcaster { 29public: 30 typedef enum CommandPlacement { 31 eCommandPlacementBeforeFile, 32 eCommandPlacementAfterFile, 33 eCommandPlacementAfterCrash, 34 } CommandPlacement; 35 36 Driver(); 37 38 virtual ~Driver(); 39 40 void MainLoop(); 41 42 lldb::SBError ParseArgs(int argc, const char *argv[], FILE *out_fh, 43 bool &do_exit); 44 45 const char *GetFilename() const; 46 47 const char *GetCrashLogFilename() const; 48 49 const char *GetArchName() const; 50 51 lldb::ScriptLanguage GetScriptLanguage() const; 52 53 void WriteCommandsForSourcing(CommandPlacement placement, 54 lldb::SBStream &strm); 55 56 bool GetDebugMode() const; 57 58 class OptionData { 59 public: 60 OptionData(); 61 ~OptionData(); 62 63 void Clear(); 64 65 void AddInitialCommand(const char *command, CommandPlacement placement, 66 bool is_file, lldb::SBError &error); 67 68 // static OptionDefinition m_cmd_option_table[]; 69 70 struct InitialCmdEntry { 71 InitialCmdEntry(const char *in_contents, bool in_is_file, 72 bool is_cwd_lldbinit_file_read, bool in_quiet = false) 73 : contents(in_contents), is_file(in_is_file), 74 is_cwd_lldbinit_file_read(is_cwd_lldbinit_file_read), 75 source_quietly(in_quiet) {} 76 77 std::string contents; 78 bool is_file; 79 bool is_cwd_lldbinit_file_read; // if this is reading ./.lldbinit - so we 80 // may skip if not permitted 81 bool source_quietly; 82 }; 83 84 std::vector<std::string> m_args; 85 lldb::ScriptLanguage m_script_lang; 86 std::string m_core_file; 87 std::string m_crash_log; 88 std::vector<InitialCmdEntry> m_initial_commands; 89 std::vector<InitialCmdEntry> m_after_file_commands; 90 std::vector<InitialCmdEntry> m_after_crash_commands; 91 bool m_debug_mode; 92 bool m_source_quietly; 93 bool m_print_version; 94 bool m_print_python_path; 95 bool m_print_help; 96 bool m_wait_for; 97 bool m_repl; 98 lldb::LanguageType m_repl_lang; 99 std::string m_repl_options; 100 std::string m_process_name; 101 lldb::pid_t m_process_pid; 102 bool m_use_external_editor; // FIXME: When we have set/show variables we can 103 // remove this from here. 104 bool m_batch; 105 typedef std::set<char> OptionSet; 106 OptionSet m_seen_options; 107 }; 108 109 static lldb::SBError SetOptionValue(int option_idx, const char *option_arg, 110 Driver::OptionData &data); 111 112 lldb::SBDebugger &GetDebugger() { return m_debugger; } 113 114 void ResizeWindow(unsigned short col); 115 116private: 117 lldb::SBDebugger m_debugger; 118 OptionData m_option_data; 119 120 void ResetOptionValues(); 121 122 void ReadyForCommand(); 123}; 124 125#endif // lldb_Driver_h_ 126