Driver.h revision 296417
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/Utility/PseudoTerminal.h" 15 16#include <set> 17#include <bitset> 18#include <string> 19#include <vector> 20 21#include "lldb/API/SBDefines.h" 22#include "lldb/API/SBBroadcaster.h" 23#include "lldb/API/SBDebugger.h" 24#include "lldb/API/SBError.h" 25 26class IOChannel; 27 28class Driver : public lldb::SBBroadcaster 29{ 30public: 31 typedef enum CommandPlacement 32 { 33 eCommandPlacementBeforeFile, 34 eCommandPlacementAfterFile, 35 eCommandPlacementAfterCrash, 36 } CommandPlacement; 37 38 Driver (); 39 40 virtual 41 ~Driver (); 42 43 void 44 MainLoop (); 45 46 lldb::SBError 47 ParseArgs (int argc, const char *argv[], FILE *out_fh, bool &do_exit); 48 49 const char * 50 GetFilename() const; 51 52 const char * 53 GetCrashLogFilename() const; 54 55 const char * 56 GetArchName() const; 57 58 lldb::ScriptLanguage 59 GetScriptLanguage() const; 60 61 void 62 WriteCommandsForSourcing (CommandPlacement placement, lldb::SBStream &strm); 63 64 bool 65 GetDebugMode() const; 66 67 68 class OptionData 69 { 70 public: 71 OptionData (); 72 ~OptionData (); 73 74 void 75 Clear(); 76 77 void 78 AddInitialCommand (const char *command, CommandPlacement placement, bool is_file, lldb::SBError &error); 79 80 //static OptionDefinition m_cmd_option_table[]; 81 82 struct InitialCmdEntry 83 { 84 InitialCmdEntry (const char *in_contents, bool in_is_file, bool in_quiet = false) : 85 contents (in_contents), 86 is_file (in_is_file), 87 source_quietly(in_quiet) 88 {} 89 90 std::string contents; 91 bool is_file; 92 bool source_quietly; 93 }; 94 95 std::vector<std::string> m_args; 96 lldb::ScriptLanguage m_script_lang; 97 std::string m_core_file; 98 std::string m_crash_log; 99 std::vector<InitialCmdEntry> m_initial_commands; 100 std::vector<InitialCmdEntry> m_after_file_commands; 101 std::vector<InitialCmdEntry> m_after_crash_commands; 102 bool m_debug_mode; 103 bool m_source_quietly; 104 bool m_print_version; 105 bool m_print_python_path; 106 bool m_print_help; 107 bool m_wait_for; 108 bool m_repl; 109 lldb::LanguageType m_repl_lang; 110 std::string m_repl_options; 111 std::string m_process_name; 112 lldb::pid_t m_process_pid; 113 bool m_use_external_editor; // FIXME: When we have set/show variables we can remove this from here. 114 bool m_batch; 115 typedef std::set<char> OptionSet; 116 OptionSet m_seen_options; 117 }; 118 119 120 static lldb::SBError 121 SetOptionValue (int option_idx, 122 const char *option_arg, 123 Driver::OptionData &data); 124 125 126 lldb::SBDebugger & 127 GetDebugger() 128 { 129 return m_debugger; 130 } 131 132 void 133 ResizeWindow (unsigned short col); 134 135private: 136 lldb::SBDebugger m_debugger; 137 OptionData m_option_data; 138 139 void 140 ResetOptionValues (); 141 142 void 143 ReadyForCommand (); 144}; 145 146#endif // lldb_Driver_h_ 147