forked from OSchip/llvm-project
[Driver] Remove unused functions (NFC)
Remove unused from the driver class. I noticed a bunch of small thing while doing this that didn't warrant separate commits, so I've lumped them together into this patch. llvm-svn: 359355
This commit is contained in:
parent
2b29b432d2
commit
de3d12f954
|
@ -163,22 +163,6 @@ void Driver::OptionData::AddInitialCommand(std::string command,
|
||||||
command_set->push_back(InitialCmdEntry(command, is_file, false));
|
command_set->push_back(InitialCmdEntry(command, is_file, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *Driver::GetFilename() const {
|
|
||||||
if (m_option_data.m_args.empty())
|
|
||||||
return nullptr;
|
|
||||||
return m_option_data.m_args.front().c_str();
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *Driver::GetCrashLogFilename() const {
|
|
||||||
if (m_option_data.m_crash_log.empty())
|
|
||||||
return nullptr;
|
|
||||||
return m_option_data.m_crash_log.c_str();
|
|
||||||
}
|
|
||||||
|
|
||||||
lldb::ScriptLanguage Driver::GetScriptLanguage() const {
|
|
||||||
return m_option_data.m_script_lang;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Driver::WriteCommandsForSourcing(CommandPlacement placement,
|
void Driver::WriteCommandsForSourcing(CommandPlacement placement,
|
||||||
SBStream &strm) {
|
SBStream &strm) {
|
||||||
std::vector<OptionData::InitialCmdEntry> *command_set;
|
std::vector<OptionData::InitialCmdEntry> *command_set;
|
||||||
|
@ -236,8 +220,6 @@ void Driver::WriteCommandsForSourcing(CommandPlacement placement,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Driver::GetDebugMode() const { return m_option_data.m_debug_mode; }
|
|
||||||
|
|
||||||
// Check the arguments that were passed to this program to make sure they are
|
// Check the arguments that were passed to this program to make sure they are
|
||||||
// valid and to get their argument values (if any). Return a boolean value
|
// valid and to get their argument values (if any). Return a boolean value
|
||||||
// indicating whether or not to start up the full debugger (i.e. the Command
|
// indicating whether or not to start up the full debugger (i.e. the Command
|
||||||
|
@ -321,7 +303,7 @@ SBError Driver::ProcessArgs(const opt::InputArgList &args, bool &exiting) {
|
||||||
|
|
||||||
if (auto *arg = args.getLastArg(OPT_script_language)) {
|
if (auto *arg = args.getLastArg(OPT_script_language)) {
|
||||||
auto arg_value = arg->getValue();
|
auto arg_value = arg->getValue();
|
||||||
m_option_data.m_script_lang = m_debugger.GetScriptingLanguage(arg_value);
|
m_debugger.SetScriptLanguage(m_debugger.GetScriptingLanguage(arg_value));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.hasArg(OPT_no_use_colors)) {
|
if (args.hasArg(OPT_no_use_colors)) {
|
||||||
|
@ -474,7 +456,7 @@ static inline int OpenPipe(int fds[2], std::size_t size) {
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
return _pipe(fds, size, O_BINARY);
|
return _pipe(fds, size, O_BINARY);
|
||||||
#else
|
#else
|
||||||
(void) size;
|
(void)size;
|
||||||
return pipe(fds);
|
return pipe(fds);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -494,10 +476,10 @@ static ::FILE *PrepareCommandsForSourcing(const char *commands_data,
|
||||||
if (size_t(nrwr) != commands_size) {
|
if (size_t(nrwr) != commands_size) {
|
||||||
WithColor::error()
|
WithColor::error()
|
||||||
<< format(
|
<< format(
|
||||||
"write(%i, %p, %" PRIu64
|
"write(%i, %p, %" PRIu64
|
||||||
") failed (errno = %i) when trying to open LLDB commands pipe",
|
") failed (errno = %i) when trying to open LLDB commands pipe",
|
||||||
fds[WRITE], static_cast<const void *>(commands_data),
|
fds[WRITE], static_cast<const void *>(commands_data),
|
||||||
static_cast<uint64_t>(commands_size), errno)
|
static_cast<uint64_t>(commands_size), errno)
|
||||||
<< '\n';
|
<< '\n';
|
||||||
llvm::sys::Process::SafelyCloseFileDescriptor(fds[READ]);
|
llvm::sys::Process::SafelyCloseFileDescriptor(fds[READ]);
|
||||||
llvm::sys::Process::SafelyCloseFileDescriptor(fds[WRITE]);
|
llvm::sys::Process::SafelyCloseFileDescriptor(fds[WRITE]);
|
||||||
|
@ -549,8 +531,8 @@ int Driver::MainLoop() {
|
||||||
|
|
||||||
m_debugger.SetErrorFileHandle(stderr, false);
|
m_debugger.SetErrorFileHandle(stderr, false);
|
||||||
m_debugger.SetOutputFileHandle(stdout, false);
|
m_debugger.SetOutputFileHandle(stdout, false);
|
||||||
m_debugger.SetInputFileHandle(stdin,
|
// Don't take ownership of STDIN yet...
|
||||||
false); // Don't take ownership of STDIN yet...
|
m_debugger.SetInputFileHandle(stdin, false);
|
||||||
|
|
||||||
m_debugger.SetUseExternalEditor(m_option_data.m_use_external_editor);
|
m_debugger.SetUseExternalEditor(m_option_data.m_use_external_editor);
|
||||||
|
|
||||||
|
@ -567,7 +549,7 @@ int Driver::MainLoop() {
|
||||||
// .lldbinit file in the user's home directory.
|
// .lldbinit file in the user's home directory.
|
||||||
SBCommandReturnObject result;
|
SBCommandReturnObject result;
|
||||||
sb_interpreter.SourceInitFileInHomeDirectory(result);
|
sb_interpreter.SourceInitFileInHomeDirectory(result);
|
||||||
if (GetDebugMode()) {
|
if (m_option_data.m_debug_mode) {
|
||||||
result.PutError(m_debugger.GetErrorFileHandle());
|
result.PutError(m_debugger.GetErrorFileHandle());
|
||||||
result.PutOutput(m_debugger.GetOutputFileHandle());
|
result.PutOutput(m_debugger.GetOutputFileHandle());
|
||||||
}
|
}
|
||||||
|
@ -589,7 +571,8 @@ int Driver::MainLoop() {
|
||||||
const size_t num_args = m_option_data.m_args.size();
|
const size_t num_args = m_option_data.m_args.size();
|
||||||
if (num_args > 0) {
|
if (num_args > 0) {
|
||||||
char arch_name[64];
|
char arch_name[64];
|
||||||
if (lldb::SBDebugger::GetDefaultArchitecture(arch_name, sizeof(arch_name)))
|
if (lldb::SBDebugger::GetDefaultArchitecture(arch_name,
|
||||||
|
sizeof(arch_name)))
|
||||||
commands_stream.Printf("target create --arch=%s %s", arch_name,
|
commands_stream.Printf("target create --arch=%s %s", arch_name,
|
||||||
EscapeString(m_option_data.m_args[0]).c_str());
|
EscapeString(m_option_data.m_args[0]).c_str());
|
||||||
else
|
else
|
||||||
|
@ -613,8 +596,9 @@ int Driver::MainLoop() {
|
||||||
commands_stream.Printf("target create --core %s\n",
|
commands_stream.Printf("target create --core %s\n",
|
||||||
EscapeString(m_option_data.m_core_file).c_str());
|
EscapeString(m_option_data.m_core_file).c_str());
|
||||||
} else if (!m_option_data.m_process_name.empty()) {
|
} else if (!m_option_data.m_process_name.empty()) {
|
||||||
commands_stream.Printf("process attach --name %s",
|
commands_stream.Printf(
|
||||||
EscapeString(m_option_data.m_process_name).c_str());
|
"process attach --name %s",
|
||||||
|
EscapeString(m_option_data.m_process_name).c_str());
|
||||||
|
|
||||||
if (m_option_data.m_wait_for)
|
if (m_option_data.m_wait_for)
|
||||||
commands_stream.Printf(" --waitfor");
|
commands_stream.Printf(" --waitfor");
|
||||||
|
@ -630,16 +614,16 @@ int Driver::MainLoop() {
|
||||||
} else if (!m_option_data.m_after_file_commands.empty()) {
|
} else if (!m_option_data.m_after_file_commands.empty()) {
|
||||||
// We're in repl mode and after-file-load commands were specified.
|
// We're in repl mode and after-file-load commands were specified.
|
||||||
WithColor::warning() << "commands specified to run after file load (via -o "
|
WithColor::warning() << "commands specified to run after file load (via -o "
|
||||||
"or -s) are ignored in REPL mode.\n";
|
"or -s) are ignored in REPL mode.\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GetDebugMode()) {
|
if (m_option_data.m_debug_mode) {
|
||||||
result.PutError(m_debugger.GetErrorFileHandle());
|
result.PutError(m_debugger.GetErrorFileHandle());
|
||||||
result.PutOutput(m_debugger.GetOutputFileHandle());
|
result.PutOutput(m_debugger.GetOutputFileHandle());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool handle_events = true;
|
const bool handle_events = true;
|
||||||
bool spawn_thread = false;
|
const bool spawn_thread = false;
|
||||||
|
|
||||||
// Check if we have any data in the commands stream, and if so, save it to a
|
// Check if we have any data in the commands stream, and if so, save it to a
|
||||||
// temp file
|
// temp file
|
||||||
|
@ -653,8 +637,8 @@ int Driver::MainLoop() {
|
||||||
bool stopped_for_crash = false;
|
bool stopped_for_crash = false;
|
||||||
if ((commands_data != nullptr) && (commands_size != 0u)) {
|
if ((commands_data != nullptr) && (commands_size != 0u)) {
|
||||||
bool success = true;
|
bool success = true;
|
||||||
FILE *commands_file = PrepareCommandsForSourcing(
|
FILE *commands_file =
|
||||||
commands_data, commands_size);
|
PrepareCommandsForSourcing(commands_data, commands_size);
|
||||||
if (commands_file != nullptr) {
|
if (commands_file != nullptr) {
|
||||||
m_debugger.SetInputFileHandle(commands_file, true);
|
m_debugger.SetInputFileHandle(commands_file, true);
|
||||||
|
|
||||||
|
@ -681,16 +665,16 @@ int Driver::MainLoop() {
|
||||||
crash_commands_stream);
|
crash_commands_stream);
|
||||||
const char *crash_commands_data = crash_commands_stream.GetData();
|
const char *crash_commands_data = crash_commands_stream.GetData();
|
||||||
const size_t crash_commands_size = crash_commands_stream.GetSize();
|
const size_t crash_commands_size = crash_commands_stream.GetSize();
|
||||||
commands_file = PrepareCommandsForSourcing(
|
commands_file = PrepareCommandsForSourcing(crash_commands_data,
|
||||||
crash_commands_data, crash_commands_size);
|
crash_commands_size);
|
||||||
if (commands_file != nullptr) {
|
if (commands_file != nullptr) {
|
||||||
bool local_quit_requested;
|
bool local_quit_requested;
|
||||||
bool local_stopped_for_crash;
|
bool local_stopped_for_crash;
|
||||||
m_debugger.SetInputFileHandle(commands_file, true);
|
m_debugger.SetInputFileHandle(commands_file, true);
|
||||||
|
|
||||||
m_debugger.RunCommandInterpreter(
|
m_debugger.RunCommandInterpreter(handle_events, spawn_thread, options,
|
||||||
handle_events, spawn_thread, options, num_errors,
|
num_errors, local_quit_requested,
|
||||||
local_quit_requested, local_stopped_for_crash);
|
local_stopped_for_crash);
|
||||||
if (local_quit_requested)
|
if (local_quit_requested)
|
||||||
quit_requested = true;
|
quit_requested = true;
|
||||||
}
|
}
|
||||||
|
@ -722,7 +706,8 @@ int Driver::MainLoop() {
|
||||||
const char *repl_options = nullptr;
|
const char *repl_options = nullptr;
|
||||||
if (!m_option_data.m_repl_options.empty())
|
if (!m_option_data.m_repl_options.empty())
|
||||||
repl_options = m_option_data.m_repl_options.c_str();
|
repl_options = m_option_data.m_repl_options.c_str();
|
||||||
SBError error(m_debugger.RunREPL(m_option_data.m_repl_lang, repl_options));
|
SBError error(
|
||||||
|
m_debugger.RunREPL(m_option_data.m_repl_lang, repl_options));
|
||||||
if (error.Fail()) {
|
if (error.Fail()) {
|
||||||
const char *error_cstr = error.GetCString();
|
const char *error_cstr = error.GetCString();
|
||||||
if ((error_cstr != nullptr) && (error_cstr[0] != 0))
|
if ((error_cstr != nullptr) && (error_cstr[0] != 0))
|
||||||
|
|
|
@ -43,19 +43,9 @@ public:
|
||||||
|
|
||||||
lldb::SBError ProcessArgs(const llvm::opt::InputArgList &args, bool &exiting);
|
lldb::SBError ProcessArgs(const llvm::opt::InputArgList &args, bool &exiting);
|
||||||
|
|
||||||
const char *GetFilename() const;
|
|
||||||
|
|
||||||
const char *GetCrashLogFilename() const;
|
|
||||||
|
|
||||||
const char *GetArchName() const;
|
|
||||||
|
|
||||||
lldb::ScriptLanguage GetScriptLanguage() const;
|
|
||||||
|
|
||||||
void WriteCommandsForSourcing(CommandPlacement placement,
|
void WriteCommandsForSourcing(CommandPlacement placement,
|
||||||
lldb::SBStream &strm);
|
lldb::SBStream &strm);
|
||||||
|
|
||||||
bool GetDebugMode() const;
|
|
||||||
|
|
||||||
struct OptionData {
|
struct OptionData {
|
||||||
void AddLocalLLDBInit();
|
void AddLocalLLDBInit();
|
||||||
void AddInitialCommand(std::string command, CommandPlacement placement,
|
void AddInitialCommand(std::string command, CommandPlacement placement,
|
||||||
|
@ -79,7 +69,6 @@ public:
|
||||||
|
|
||||||
std::vector<std::string> m_args;
|
std::vector<std::string> m_args;
|
||||||
|
|
||||||
lldb::ScriptLanguage m_script_lang = lldb::eScriptLanguageDefault;
|
|
||||||
lldb::LanguageType m_repl_lang = lldb::eLanguageTypeUnknown;
|
lldb::LanguageType m_repl_lang = lldb::eLanguageTypeUnknown;
|
||||||
lldb::pid_t m_process_pid = LLDB_INVALID_PROCESS_ID;
|
lldb::pid_t m_process_pid = LLDB_INVALID_PROCESS_ID;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue