diff options
Diffstat (limited to 'contrib/llvm/tools/lldb/source/Commands')
33 files changed, 1207 insertions, 664 deletions
diff --git a/contrib/llvm/tools/lldb/source/Commands/CommandCompletions.cpp b/contrib/llvm/tools/lldb/source/Commands/CommandCompletions.cpp index c65dd9d..37696e3 100644 --- a/contrib/llvm/tools/lldb/source/Commands/CommandCompletions.cpp +++ b/contrib/llvm/tools/lldb/source/Commands/CommandCompletions.cpp @@ -7,8 +7,6 @@ // //===----------------------------------------------------------------------===// -#include "lldb/lldb-python.h" - // C Includes #include <sys/stat.h> #if defined(__APPLE__) || defined(__linux__) @@ -25,6 +23,7 @@ #include "lldb/Interpreter/Args.h" #include "lldb/Interpreter/CommandCompletions.h" #include "lldb/Interpreter/CommandInterpreter.h" +#include "lldb/Interpreter/OptionValueProperties.h" #include "lldb/Symbol/CompileUnit.h" #include "lldb/Symbol/Variable.h" #include "lldb/Target/Target.h" diff --git a/contrib/llvm/tools/lldb/source/Commands/CommandObjectApropos.cpp b/contrib/llvm/tools/lldb/source/Commands/CommandObjectApropos.cpp index 02dc726..47890b1 100644 --- a/contrib/llvm/tools/lldb/source/Commands/CommandObjectApropos.cpp +++ b/contrib/llvm/tools/lldb/source/Commands/CommandObjectApropos.cpp @@ -7,8 +7,6 @@ // //===----------------------------------------------------------------------===// -#include "lldb/lldb-python.h" - #include "CommandObjectApropos.h" // C Includes @@ -17,6 +15,7 @@ // Project includes #include "lldb/Interpreter/Args.h" #include "lldb/Interpreter/Options.h" +#include "lldb/Interpreter/Property.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" diff --git a/contrib/llvm/tools/lldb/source/Commands/CommandObjectArgs.cpp b/contrib/llvm/tools/lldb/source/Commands/CommandObjectArgs.cpp index b0fe42b..cf32d10 100644 --- a/contrib/llvm/tools/lldb/source/Commands/CommandObjectArgs.cpp +++ b/contrib/llvm/tools/lldb/source/Commands/CommandObjectArgs.cpp @@ -7,8 +7,6 @@ // //===----------------------------------------------------------------------===// -#include "lldb/lldb-python.h" - #include "CommandObjectArgs.h" // C Includes @@ -25,8 +23,10 @@ #include "lldb/Host/Host.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" +#include "lldb/Symbol/ClangASTContext.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Symbol/Variable.h" +#include "lldb/Target/ABI.h" #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" diff --git a/contrib/llvm/tools/lldb/source/Commands/CommandObjectBreakpoint.cpp b/contrib/llvm/tools/lldb/source/Commands/CommandObjectBreakpoint.cpp index 3d4b3af..4cbcb70 100644 --- a/contrib/llvm/tools/lldb/source/Commands/CommandObjectBreakpoint.cpp +++ b/contrib/llvm/tools/lldb/source/Commands/CommandObjectBreakpoint.cpp @@ -7,8 +7,6 @@ // //===----------------------------------------------------------------------===// -#include "lldb/lldb-python.h" - #include "CommandObjectBreakpoint.h" #include "CommandObjectBreakpointCommand.h" @@ -19,13 +17,16 @@ #include "lldb/Breakpoint/Breakpoint.h" #include "lldb/Breakpoint/BreakpointIDList.h" #include "lldb/Breakpoint/BreakpointLocation.h" +#include "lldb/Host/StringConvert.h" #include "lldb/Interpreter/Options.h" +#include "lldb/Interpreter/OptionValueBoolean.h" #include "lldb/Interpreter/OptionValueString.h" #include "lldb/Interpreter/OptionValueUInt64.h" #include "lldb/Core/RegularExpression.h" #include "lldb/Core/StreamString.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" +#include "lldb/Target/LanguageRuntime.h" #include "lldb/Target/Target.h" #include "lldb/Interpreter/CommandCompletions.h" #include "lldb/Target/StackFrame.h" @@ -109,9 +110,11 @@ public: m_catch_bp (false), m_throw_bp (true), m_hardware (false), - m_language (eLanguageTypeUnknown), + m_exception_language (eLanguageTypeUnknown), m_skip_prologue (eLazyBoolCalculate), - m_one_shot (false) + m_one_shot (false), + m_all_files (false), + m_move_to_nearest_code (eLazyBoolCalculate) { } @@ -134,15 +137,23 @@ public: } break; + case 'A': + m_all_files = true; + break; + case 'b': m_func_names.push_back (option_arg); m_func_name_type_mask |= eFunctionNameTypeBase; break; case 'C': - m_column = Args::StringToUInt32 (option_arg, 0); + { + bool success; + m_column = StringConvert::ToUInt32 (option_arg, 0, 0, &success); + if (!success) + error.SetErrorStringWithFormat("invalid column number: %s", option_arg); break; - + } case 'c': m_condition.assign(option_arg); break; @@ -161,15 +172,16 @@ public: case eLanguageTypeC: case eLanguageTypeC99: case eLanguageTypeC11: - m_language = eLanguageTypeC; + m_exception_language = eLanguageTypeC; break; case eLanguageTypeC_plus_plus: case eLanguageTypeC_plus_plus_03: case eLanguageTypeC_plus_plus_11: - m_language = eLanguageTypeC_plus_plus; + case eLanguageTypeC_plus_plus_14: + m_exception_language = eLanguageTypeC_plus_plus; break; case eLanguageTypeObjC: - m_language = eLanguageTypeObjC; + m_exception_language = eLanguageTypeObjC; break; case eLanguageTypeObjC_plus_plus: error.SetErrorStringWithFormat ("Set exception breakpoints separately for c++ and objective-c"); @@ -207,7 +219,7 @@ public: case 'i': { - m_ignore_count = Args::StringToUInt32(option_arg, UINT32_MAX, 0); + m_ignore_count = StringConvert::ToUInt32(option_arg, UINT32_MAX, 0); if (m_ignore_count == UINT32_MAX) error.SetErrorStringWithFormat ("invalid ignore count '%s'", option_arg); break; @@ -229,8 +241,28 @@ public: break; case 'l': - m_line_num = Args::StringToUInt32 (option_arg, 0); + { + bool success; + m_line_num = StringConvert::ToUInt32 (option_arg, 0, 0, &success); + if (!success) + error.SetErrorStringWithFormat ("invalid line number: %s.", option_arg); break; + } + + case 'm': + { + bool success; + bool value; + value = Args::StringToBoolean (option_arg, true, &success); + if (value) + m_move_to_nearest_code = eLazyBoolYes; + else + m_move_to_nearest_code = eLazyBoolNo; + + if (!success) + error.SetErrorStringWithFormat ("Invalid boolean value for move-to-nearest-code option: '%s'", option_arg); + break; + } case 'M': m_func_names.push_back (option_arg); @@ -251,6 +283,11 @@ public: m_one_shot = true; break; + case 'O': + m_exception_extra_args.AppendArgument ("-O"); + m_exception_extra_args.AppendArgument (option_arg); + break; + case 'p': m_source_text_regexp.assign (option_arg); break; @@ -276,7 +313,7 @@ public: case 't' : { - m_thread_id = Args::StringToUInt64(option_arg, LLDB_INVALID_THREAD_ID, 0); + m_thread_id = StringConvert::ToUInt64(option_arg, LLDB_INVALID_THREAD_ID, 0); if (m_thread_id == LLDB_INVALID_THREAD_ID) error.SetErrorStringWithFormat ("invalid thread id string '%s'", option_arg); } @@ -297,7 +334,7 @@ public: case 'x': { - m_thread_index = Args::StringToUInt32(option_arg, UINT32_MAX, 0); + m_thread_index = StringConvert::ToUInt32(option_arg, UINT32_MAX, 0); if (m_thread_id == UINT32_MAX) error.SetErrorStringWithFormat ("invalid thread index string '%s'", option_arg); @@ -332,11 +369,14 @@ public: m_catch_bp = false; m_throw_bp = true; m_hardware = false; - m_language = eLanguageTypeUnknown; + m_exception_language = eLanguageTypeUnknown; m_skip_prologue = eLazyBoolCalculate; m_one_shot = false; m_use_dummy = false; m_breakpoint_names.clear(); + m_all_files = false; + m_exception_extra_args.Clear(); + m_move_to_nearest_code = eLazyBoolCalculate; } const OptionDefinition* @@ -370,10 +410,13 @@ public: bool m_catch_bp; bool m_throw_bp; bool m_hardware; // Request to use hardware breakpoints - lldb::LanguageType m_language; + lldb::LanguageType m_exception_language; LazyBool m_skip_prologue; bool m_one_shot; bool m_use_dummy; + bool m_all_files; + Args m_exception_extra_args; + LazyBool m_move_to_nearest_code; }; @@ -411,7 +454,7 @@ protected: break_type = eSetTypeFunctionRegexp; else if (!m_options.m_source_text_regexp.empty()) break_type = eSetTypeSourceRegexp; - else if (m_options.m_language != eLanguageTypeUnknown) + else if (m_options.m_exception_language != eLanguageTypeUnknown) break_type = eSetTypeException; Breakpoint *bp = NULL; @@ -451,7 +494,8 @@ protected: check_inlines, m_options.m_skip_prologue, internal, - m_options.m_hardware).get(); + m_options.m_hardware, + m_options.m_move_to_nearest_code).get(); } break; @@ -503,7 +547,7 @@ protected: { const size_t num_files = m_options.m_filenames.GetSize(); - if (num_files == 0) + if (num_files == 0 && !m_options.m_all_files) { FileSpec file; if (!GetDefaultFile (target, file, result)) @@ -532,15 +576,27 @@ protected: &(m_options.m_filenames), regexp, internal, - m_options.m_hardware).get(); + m_options.m_hardware, + m_options.m_move_to_nearest_code).get(); } break; case eSetTypeException: { - bp = target->CreateExceptionBreakpoint (m_options.m_language, + Error precond_error; + bp = target->CreateExceptionBreakpoint (m_options.m_exception_language, m_options.m_catch_bp, m_options.m_throw_bp, - m_options.m_hardware).get(); + internal, + &m_options.m_exception_extra_args, + &precond_error).get(); + if (precond_error.Fail()) + { + result.AppendErrorWithFormat("Error setting extra exception arguments: %s", + precond_error.AsCString()); + target->RemoveBreakpointByID(bp->GetID()); + result.SetStatus(eReturnStatusFailed); + return false; + } } break; default: @@ -652,6 +708,7 @@ private: #define LLDB_OPT_FILE ( LLDB_OPT_SET_FROM_TO(1, 9) & ~LLDB_OPT_SET_2 ) #define LLDB_OPT_NOT_10 ( LLDB_OPT_SET_FROM_TO(1, 10) & ~LLDB_OPT_SET_10 ) #define LLDB_OPT_SKIP_PROLOGUE ( LLDB_OPT_SET_1 | LLDB_OPT_SET_FROM_TO(3,8) ) +#define LLDB_OPT_MOVE_TO_NEAREST_CODE ( LLDB_OPT_SET_1 | LLDB_OPT_SET_9 ) OptionDefinition CommandObjectBreakpointSet::CommandOptions::g_option_table[] = @@ -727,6 +784,9 @@ CommandObjectBreakpointSet::CommandOptions::g_option_table[] = "specified with the -f option. The -f option can be specified more than once. " "If no source files are specified, uses the current \"default source file\"" }, + { LLDB_OPT_SET_9, false, "all-files", 'A', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, + "All files are searched for source pattern matches." }, + { LLDB_OPT_SET_10, true, "language-exception", 'E', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeLanguage, "Set the breakpoint on exceptions thrown by the specified language (without options, on throw but not catch.)" }, @@ -736,6 +796,10 @@ CommandObjectBreakpointSet::CommandOptions::g_option_table[] = { LLDB_OPT_SET_10, false, "on-catch", 'h', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeBoolean, "Set the breakpoint on exception catcH." }, +// Don't add this option till it actually does something useful... +// { LLDB_OPT_SET_10, false, "exception-typename", 'O', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeTypeName, +// "The breakpoint will only stop if an exception Object of this type is thrown. Can be repeated multiple times to stop for multiple object types" }, + { LLDB_OPT_SKIP_PROLOGUE, false, "skip-prologue", 'K', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeBoolean, "sKip the prologue if the breakpoint is at the beginning of a function. If not set the target.skip-prologue setting is used." }, @@ -745,6 +809,9 @@ CommandObjectBreakpointSet::CommandOptions::g_option_table[] = { LLDB_OPT_SET_ALL, false, "breakpoint-name", 'N', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeBreakpointName, "Adds this to the list of names for this breakopint."}, + { LLDB_OPT_MOVE_TO_NEAREST_CODE, false, "move-to-nearest-code", 'm', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeBoolean, + "Move breakpoints to nearest code. If not set the target.move-to-nearest-code setting is used." }, + { 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL } }; @@ -838,7 +905,7 @@ public: break; case 'i': { - m_ignore_count = Args::StringToUInt32(option_arg, UINT32_MAX, 0); + m_ignore_count = StringConvert::ToUInt32(option_arg, UINT32_MAX, 0); if (m_ignore_count == UINT32_MAX) error.SetErrorStringWithFormat ("invalid ignore count '%s'", option_arg); } @@ -865,7 +932,7 @@ public: } else { - m_thread_id = Args::StringToUInt64(option_arg, LLDB_INVALID_THREAD_ID, 0); + m_thread_id = StringConvert::ToUInt64(option_arg, LLDB_INVALID_THREAD_ID, 0); if (m_thread_id == LLDB_INVALID_THREAD_ID) error.SetErrorStringWithFormat ("invalid thread id string '%s'", option_arg); else @@ -896,7 +963,7 @@ public: } else { - m_thread_index = Args::StringToUInt32 (option_arg, UINT32_MAX, 0); + m_thread_index = StringConvert::ToUInt32 (option_arg, UINT32_MAX, 0); if (m_thread_id == UINT32_MAX) error.SetErrorStringWithFormat ("invalid thread index string '%s'", option_arg); else @@ -1555,7 +1622,7 @@ public: break; case 'l': - m_line_num = Args::StringToUInt32 (option_arg, 0); + m_line_num = StringConvert::ToUInt32 (option_arg, 0); break; default: @@ -1938,15 +2005,15 @@ public: { case 'N': if (BreakpointID::StringIsBreakpointName(option_value, error) && error.Success()) - m_name.SetValueFromCString(option_value); + m_name.SetValueFromString(option_value); break; case 'B': - if (m_breakpoint.SetValueFromCString(option_value).Fail()) + if (m_breakpoint.SetValueFromString(option_value).Fail()) error.SetErrorStringWithFormat ("unrecognized value \"%s\" for breakpoint", option_value); break; case 'D': - if (m_use_dummy.SetValueFromCString(option_value).Fail()) + if (m_use_dummy.SetValueFromString(option_value).Fail()) error.SetErrorStringWithFormat ("unrecognized value \"%s\" for use-dummy", option_value); break; @@ -2186,7 +2253,6 @@ public: } protected: -protected: virtual bool DoExecute (Args& command, CommandReturnObject &result) { diff --git a/contrib/llvm/tools/lldb/source/Commands/CommandObjectBreakpointCommand.cpp b/contrib/llvm/tools/lldb/source/Commands/CommandObjectBreakpointCommand.cpp index 8f8404b..180ab60 100644 --- a/contrib/llvm/tools/lldb/source/Commands/CommandObjectBreakpointCommand.cpp +++ b/contrib/llvm/tools/lldb/source/Commands/CommandObjectBreakpointCommand.cpp @@ -7,8 +7,6 @@ // //===----------------------------------------------------------------------===// -#include "lldb/lldb-python.h" - // C Includes // C++ Includes diff --git a/contrib/llvm/tools/lldb/source/Commands/CommandObjectBugreport.cpp b/contrib/llvm/tools/lldb/source/Commands/CommandObjectBugreport.cpp new file mode 100644 index 0000000..f171d2f --- /dev/null +++ b/contrib/llvm/tools/lldb/source/Commands/CommandObjectBugreport.cpp @@ -0,0 +1,145 @@ +//===-- CommandObjectBugreport.cpp ------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "CommandObjectBugreport.h" + +// C Includes +#include <cstdio> + +// C++ Includes +// Other libraries and framework includes + +// Project includes +#include "lldb/Interpreter/CommandInterpreter.h" +#include "lldb/Interpreter/CommandReturnObject.h" +#include "lldb/Interpreter/OptionGroupOutputFile.h" +#include "lldb/Target/Thread.h" + +using namespace lldb; +using namespace lldb_private; + +//------------------------------------------------------------------------- +// "bugreport unwind" +//------------------------------------------------------------------------- + +class CommandObjectBugreportUnwind : public CommandObjectParsed +{ +public: + CommandObjectBugreportUnwind(CommandInterpreter &interpreter) : + CommandObjectParsed(interpreter, + "bugreport unwind", + "Create a bugreport for a bug in the stack unwinding code.", + nullptr), + m_option_group(interpreter), + m_outfile_options() + { + m_option_group.Append (&m_outfile_options, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1 | LLDB_OPT_SET_2 | LLDB_OPT_SET_3); + m_option_group.Finalize(); + } + + ~CommandObjectBugreportUnwind() + { + } + + Options * + GetOptions() override + { + return &m_option_group; + } + +protected: + bool + DoExecute(Args& command, CommandReturnObject &result) override + { + StringList commands; + commands.AppendString("thread backtrace"); + + Thread *thread = m_exe_ctx.GetThreadPtr(); + if (thread) + { + char command_buffer[256]; + + uint32_t frame_count = thread->GetStackFrameCount(); + for (uint32_t i = 0; i < frame_count; ++i) + { + StackFrameSP frame = thread->GetStackFrameAtIndex(i); + lldb::addr_t pc = frame->GetStackID().GetPC(); + + snprintf(command_buffer, sizeof(command_buffer), "disassemble --bytes --address 0x%" PRIx64, pc); + commands.AppendString(command_buffer); + + snprintf(command_buffer, sizeof(command_buffer), "image show-unwind --address 0x%" PRIx64, pc); + commands.AppendString(command_buffer); + } + } + + const FileSpec &outfile_spec = m_outfile_options.GetFile().GetCurrentValue(); + if (outfile_spec) + { + char path[PATH_MAX]; + outfile_spec.GetPath (path, sizeof(path)); + + uint32_t open_options = File::eOpenOptionWrite | + File::eOpenOptionCanCreate | + File::eOpenOptionAppend | + File::eOpenOptionCloseOnExec; + + const bool append = m_outfile_options.GetAppend().GetCurrentValue(); + if (!append) + open_options |= File::eOpenOptionTruncate; + + StreamFileSP outfile_stream = std::make_shared<StreamFile>(); + Error error = outfile_stream->GetFile().Open(path, open_options); + if (error.Fail()) + { + result.AppendErrorWithFormat("Failed to open file '%s' for %s: %s\n", + path, + append ? "append" : "write", + error.AsCString()); + result.SetStatus(eReturnStatusFailed); + return false; + } + + result.SetImmediateOutputStream(outfile_stream); + } + + CommandInterpreterRunOptions options; + options.SetStopOnError(false); + options.SetEchoCommands(true); + options.SetPrintResults(true); + options.SetAddToHistory(false); + m_interpreter.HandleCommands(commands, &m_exe_ctx, options, result); + + return result.Succeeded(); + } + +private: + OptionGroupOptions m_option_group; + OptionGroupOutputFile m_outfile_options; +}; + +#pragma mark CommandObjectMultiwordBugreport + +//------------------------------------------------------------------------- +// CommandObjectMultiwordBugreport +//------------------------------------------------------------------------- + +CommandObjectMultiwordBugreport::CommandObjectMultiwordBugreport(CommandInterpreter &interpreter) : + CommandObjectMultiword(interpreter, + "bugreport", + "Set of commands for creating domain specific bugreports.", + "bugreport <subcommand> [<subcommand-options>]") +{ + + LoadSubCommand("unwind", CommandObjectSP(new CommandObjectBugreportUnwind(interpreter))); +} + +CommandObjectMultiwordBugreport::~CommandObjectMultiwordBugreport () +{ +} diff --git a/contrib/llvm/tools/lldb/source/Commands/CommandObjectBugreport.h b/contrib/llvm/tools/lldb/source/Commands/CommandObjectBugreport.h new file mode 100644 index 0000000..d062e0d --- /dev/null +++ b/contrib/llvm/tools/lldb/source/Commands/CommandObjectBugreport.h @@ -0,0 +1,36 @@ +//===-- CommandObjectBugreport.h --------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef liblldb_CommandObjectBugreport_h_ +#define liblldb_CommandObjectBugreport_h_ + +// C Includes +// C++ Includes +// Other libraries and framework includes +// Project includes +#include "lldb/Interpreter/CommandObjectMultiword.h" + +namespace lldb_private { + +//------------------------------------------------------------------------- +// CommandObjectMultiwordBugreport +//------------------------------------------------------------------------- + +class CommandObjectMultiwordBugreport : public CommandObjectMultiword +{ +public: + CommandObjectMultiwordBugreport(CommandInterpreter &interpreter); + + virtual + ~CommandObjectMultiwordBugreport(); +}; + +} // namespace lldb_private + +#endif // liblldb_CommandObjectBugreport_h_ diff --git a/contrib/llvm/tools/lldb/source/Commands/CommandObjectCommands.cpp b/contrib/llvm/tools/lldb/source/Commands/CommandObjectCommands.cpp index f98eac0..5fd99cf 100644 --- a/contrib/llvm/tools/lldb/source/Commands/CommandObjectCommands.cpp +++ b/contrib/llvm/tools/lldb/source/Commands/CommandObjectCommands.cpp @@ -7,8 +7,6 @@ // //===----------------------------------------------------------------------===// -#include "lldb/lldb-python.h" - #include "CommandObjectCommands.h" // C Includes @@ -29,7 +27,6 @@ #include "lldb/Interpreter/OptionValueUInt64.h" #include "lldb/Interpreter/Options.h" #include "lldb/Interpreter/ScriptInterpreter.h" -#include "lldb/Interpreter/ScriptInterpreterPython.h" using namespace lldb; using namespace lldb_private; @@ -85,7 +82,7 @@ protected: switch (short_option) { case 'c': - error = m_count.SetValueFromCString(option_arg,eVarSetOperationAssign); + error = m_count.SetValueFromString(option_arg,eVarSetOperationAssign); break; case 's': if (option_arg && strcmp("end", option_arg) == 0) @@ -94,10 +91,10 @@ protected: m_start_idx.SetOptionWasSet(); } else - error = m_start_idx.SetValueFromCString(option_arg,eVarSetOperationAssign); + error = m_start_idx.SetValueFromString(option_arg,eVarSetOperationAssign); break; case 'e': - error = m_stop_idx.SetValueFromCString(option_arg,eVarSetOperationAssign); + error = m_stop_idx.SetValueFromString(option_arg,eVarSetOperationAssign); break; case 'C': m_clear.SetCurrentValue(true); @@ -326,15 +323,15 @@ protected: switch (short_option) { case 'e': - error = m_stop_on_error.SetValueFromCString(option_arg); + error = m_stop_on_error.SetValueFromString(option_arg); break; case 'c': - error = m_stop_on_continue.SetValueFromCString(option_arg); + error = m_stop_on_continue.SetValueFromString(option_arg); break; case 's': - error = m_silent_run.SetValueFromCString(option_arg); + error = m_silent_run.SetValueFromString(option_arg); break; default: @@ -1430,6 +1427,130 @@ protected: }; +class CommandObjectScriptingObject : public CommandObjectRaw +{ +private: + StructuredData::GenericSP m_cmd_obj_sp; + ScriptedCommandSynchronicity m_synchro; + bool m_fetched_help_short:1; + bool m_fetched_help_long:1; + +public: + + CommandObjectScriptingObject (CommandInterpreter &interpreter, + std::string name, + StructuredData::GenericSP cmd_obj_sp, + ScriptedCommandSynchronicity synch) : + CommandObjectRaw (interpreter, + name.c_str(), + NULL, + NULL), + m_cmd_obj_sp(cmd_obj_sp), + m_synchro(synch), + m_fetched_help_short(false), + m_fetched_help_long(false) + { + StreamString stream; + stream.Printf("For more information run 'help %s'",name.c_str()); + SetHelp(stream.GetData()); + if (ScriptInterpreter* scripter = m_interpreter.GetScriptInterpreter()) + GetFlags().Set(scripter->GetFlagsForCommandObject(cmd_obj_sp)); + } + + virtual + ~CommandObjectScriptingObject () + { + } + + virtual bool + IsRemovable () const + { + return true; + } + + StructuredData::GenericSP + GetImplementingObject () + { + return m_cmd_obj_sp; + } + + ScriptedCommandSynchronicity + GetSynchronicity () + { + return m_synchro; + } + + virtual const char * + GetHelp () + { + if (!m_fetched_help_short) + { + ScriptInterpreter* scripter = m_interpreter.GetScriptInterpreter(); + if (scripter) + { + std::string docstring; + m_fetched_help_short = scripter->GetShortHelpForCommandObject(m_cmd_obj_sp,docstring); + if (!docstring.empty()) + SetHelp(docstring); + } + } + return CommandObjectRaw::GetHelp(); + } + + virtual const char * + GetHelpLong () + { + if (!m_fetched_help_long) + { + ScriptInterpreter* scripter = m_interpreter.GetScriptInterpreter(); + if (scripter) + { + std::string docstring; + m_fetched_help_long = scripter->GetLongHelpForCommandObject(m_cmd_obj_sp,docstring); + if (!docstring.empty()) + SetHelpLong(docstring); + } + } + return CommandObjectRaw::GetHelpLong(); + } + +protected: + virtual bool + DoExecute (const char *raw_command_line, CommandReturnObject &result) + { + ScriptInterpreter* scripter = m_interpreter.GetScriptInterpreter(); + + Error error; + + result.SetStatus(eReturnStatusInvalid); + + if (!scripter || scripter->RunScriptBasedCommand(m_cmd_obj_sp, + raw_command_line, + m_synchro, + result, + error, + m_exe_ctx) == false) + { + result.AppendError(error.AsCString()); + result.SetStatus(eReturnStatusFailed); + } + else + { + // Don't change the status if the command already set it... + if (result.GetStatus() == eReturnStatusInvalid) + { + if (result.GetOutputData() == NULL || result.GetOutputData()[0] == '\0') + result.SetStatus(eReturnStatusSuccessFinishNoResult); + else + result.SetStatus(eReturnStatusSuccessFinishResult); + } + } + + return result.Succeeded(); + } + +}; + //------------------------------------------------------------------------- // CommandObjectCommandsScriptImport //------------------------------------------------------------------------- @@ -1449,7 +1570,7 @@ public: // Define the first (and only) variant of this arg. cmd_arg.arg_type = eArgTypeFilename; - cmd_arg.arg_repetition = eArgRepeatPlain; + cmd_arg.arg_repetition = eArgRepeatPlus; // There is only one variant this argument could be; put it into the argument entry. arg1.push_back (cmd_arg); @@ -1549,7 +1670,6 @@ protected: bool DoExecute (Args& command, CommandReturnObject &result) { - if (m_interpreter.GetDebugger().GetScriptLanguage() != lldb::eScriptLanguagePython) { result.AppendError ("only scripting language supported for module importing is currently Python"); @@ -1558,36 +1678,40 @@ protected: } size_t argc = command.GetArgumentCount(); - - if (argc != 1) + if (0 == argc) { - result.AppendError ("'command script import' requires one argument"); + result.AppendError("command script import needs one or more arguments"); result.SetStatus (eReturnStatusFailed); return false; } - std::string path = command.GetArgumentAtIndex(0); - Error error; - - const bool init_session = true; - // FIXME: this is necessary because CommandObject::CheckRequirements() assumes that - // commands won't ever be recursively invoked, but it's actually possible to craft - // a Python script that does other "command script imports" in __lldb_init_module - // the real fix is to have recursive commands possible with a CommandInvocation object - // separate from the CommandObject itself, so that recursive command invocations - // won't stomp on each other (wrt to execution contents, options, and more) - m_exe_ctx.Clear(); - if (m_interpreter.GetScriptInterpreter()->LoadScriptingModule(path.c_str(), - m_options.m_allow_reload, - init_session, - error)) - { - result.SetStatus (eReturnStatusSuccessFinishNoResult); - } - else + for (size_t i = 0; + i < argc; + i++) { - result.AppendErrorWithFormat("module importing failed: %s", error.AsCString()); - result.SetStatus (eReturnStatusFailed); + std::string path = command.GetArgumentAtIndex(i); + Error error; + + const bool init_session = true; + // FIXME: this is necessary because CommandObject::CheckRequirements() assumes that + // commands won't ever be recursively invoked, but it's actually possible to craft + // a Python script that does other "command script imports" in __lldb_init_module + // the real fix is to have recursive commands possible with a CommandInvocation object + // separate from the CommandObject itself, so that recursive command invocations + // won't stomp on each other (wrt to execution contents, options, and more) + m_exe_ctx.Clear(); + if (m_interpreter.GetScriptInterpreter()->LoadScriptingModule(path.c_str(), + m_options.m_allow_reload, + init_session, + error)) + { + result.SetStatus (eReturnStatusSuccessFinishNoResult); + } + else + { + result.AppendErrorWithFormat("module importing failed: %s", error.AsCString()); + result.SetStatus (eReturnStatusFailed); + } } return result.Succeeded(); @@ -1652,7 +1776,11 @@ protected: public: CommandOptions (CommandInterpreter &interpreter) : - Options (interpreter) + Options (interpreter), + m_class_name(), + m_funct_name(), + m_short_help(), + m_synchronicity(eScriptedCommandSynchronicitySynchronous) { } @@ -1671,6 +1799,10 @@ protected: if (option_arg) m_funct_name.assign(option_arg); break; + case 'c': + if (option_arg) + m_class_name.assign(option_arg); + break; case 'h': if (option_arg) m_short_help.assign(option_arg); @@ -1691,6 +1823,7 @@ protected: void OptionParsingStarting () { + m_class_name.clear(); m_funct_name.clear(); m_short_help.clear(); m_synchronicity = eScriptedCommandSynchronicitySynchronous; @@ -1708,6 +1841,7 @@ protected: // Instance variables to hold the values for command options. + std::string m_class_name; std::string m_funct_name; std::string m_short_help; ScriptedCommandSynchronicity m_synchronicity; @@ -1812,20 +1946,55 @@ protected: m_short_help.assign(m_options.m_short_help); m_synchronicity = m_options.m_synchronicity; - if (m_options.m_funct_name.empty()) + if (m_options.m_class_name.empty()) { - m_interpreter.GetPythonCommandsFromIOHandler (" ", // Prompt - *this, // IOHandlerDelegate - true, // Run IOHandler in async mode - NULL); // Baton for the "io_handler" that will be passed back into our IOHandlerDelegate functions + if (m_options.m_funct_name.empty()) + { + m_interpreter.GetPythonCommandsFromIOHandler (" ", // Prompt + *this, // IOHandlerDelegate + true, // Run IOHandler in async mode + NULL); // Baton for the "io_handler" that will be passed back into our IOHandlerDelegate functions + } + else + { + CommandObjectSP new_cmd(new CommandObjectPythonFunction(m_interpreter, + m_cmd_name, + m_options.m_funct_name, + m_options.m_short_help, + m_synchronicity)); + if (m_interpreter.AddUserCommand(m_cmd_name, new_cmd, true)) + { + result.SetStatus (eReturnStatusSuccessFinishNoResult); + } + else + { + result.AppendError("cannot add command"); + result.SetStatus (eReturnStatusFailed); + } + } } else { - CommandObjectSP new_cmd(new CommandObjectPythonFunction(m_interpreter, - m_cmd_name, - m_options.m_funct_name, - m_options.m_short_help, - m_synchronicity)); + ScriptInterpreter *interpreter = GetCommandInterpreter().GetScriptInterpreter(); + if (!interpreter) + { + result.AppendError("cannot find ScriptInterpreter"); + result.SetStatus(eReturnStatusFailed); + return false; + } + + auto cmd_obj_sp = interpreter->CreateScriptCommandObject(m_options.m_class_name.c_str()); + if (!cmd_obj_sp) + { + result.AppendError("cannot create helper object"); + result.SetStatus(eReturnStatusFailed); + return false; + } + + CommandObjectSP new_cmd(new CommandObjectScriptingObject(m_interpreter, + m_cmd_name, + cmd_obj_sp, + m_synchronicity)); if (m_interpreter.AddUserCommand(m_cmd_name, new_cmd, true)) { result.SetStatus (eReturnStatusSuccessFinishNoResult); @@ -1859,8 +2028,9 @@ OptionDefinition CommandObjectCommandsScriptAdd::CommandOptions::g_option_table[] = { { LLDB_OPT_SET_1, false, "function", 'f', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypePythonFunction, "Name of the Python function to bind to this command name."}, + { LLDB_OPT_SET_2, false, "class", 'c', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypePythonClass, "Name of the Python class to bind to this command name."}, { LLDB_OPT_SET_1, false, "help" , 'h', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeHelpText, "The help text to display for this command."}, - { LLDB_OPT_SET_1, false, "synchronicity", 's', OptionParser::eRequiredArgument, NULL, g_script_synchro_type, 0, eArgTypeScriptedCommandSynchronicity, "Set the synchronicity of this command's executions with regard to LLDB event system."}, + { LLDB_OPT_SET_ALL, false, "synchronicity", 's', OptionParser::eRequiredArgument, NULL, g_script_synchro_type, 0, eArgTypeScriptedCommandSynchronicity, "Set the synchronicity of this command's executions with regard to LLDB event system."}, { 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL } }; diff --git a/contrib/llvm/tools/lldb/source/Commands/CommandObjectDisassemble.cpp b/contrib/llvm/tools/lldb/source/Commands/CommandObjectDisassemble.cpp index 8124ce1..1e575fe 100644 --- a/contrib/llvm/tools/lldb/source/Commands/CommandObjectDisassemble.cpp +++ b/contrib/llvm/tools/lldb/source/Commands/CommandObjectDisassemble.cpp @@ -7,8 +7,6 @@ // //===----------------------------------------------------------------------===// -#include "lldb/lldb-python.h" - #include "CommandObjectDisassemble.h" // C Includes @@ -19,7 +17,7 @@ #include "lldb/Core/Disassembler.h" #include "lldb/Core/Module.h" #include "lldb/Core/SourceManager.h" -#include "lldb/Interpreter/Args.h" +#include "lldb/Host/StringConvert.h" #include "lldb/Interpreter/CommandCompletions.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" @@ -76,13 +74,13 @@ CommandObjectDisassemble::CommandOptions::SetOptionValue (uint32_t option_idx, c break; case 'C': - num_lines_context = Args::StringToUInt32(option_arg, 0, 0, &success); + num_lines_context = StringConvert::ToUInt32(option_arg, 0, 0, &success); if (!success) error.SetErrorStringWithFormat ("invalid num context lines string: \"%s\"", option_arg); break; case 'c': - num_instructions = Args::StringToUInt32(option_arg, 0, 0, &success); + num_instructions = StringConvert::ToUInt32(option_arg, 0, 0, &success); if (!success) error.SetErrorStringWithFormat ("invalid num of instructions string: \"%s\"", option_arg); break; diff --git a/contrib/llvm/tools/lldb/source/Commands/CommandObjectExpression.cpp b/contrib/llvm/tools/lldb/source/Commands/CommandObjectExpression.cpp index b4c559c..f4bb8fb 100644 --- a/contrib/llvm/tools/lldb/source/Commands/CommandObjectExpression.cpp +++ b/contrib/llvm/tools/lldb/source/Commands/CommandObjectExpression.cpp @@ -7,15 +7,12 @@ // //===----------------------------------------------------------------------===// -#include "lldb/lldb-python.h" - #include "CommandObjectExpression.h" // C Includes // C++ Includes // Other libraries and framework includes // Project includes -#include "lldb/Interpreter/Args.h" #include "lldb/Core/Value.h" #include "lldb/Core/ValueObjectVariable.h" #include "lldb/DataFormatters/ValueObjectPrinter.h" @@ -24,6 +21,7 @@ #include "lldb/Expression/ClangFunction.h" #include "lldb/Expression/DWARFExpression.h" #include "lldb/Host/Host.h" +#include "lldb/Host/StringConvert.h" #include "lldb/Core/Debugger.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" @@ -119,7 +117,7 @@ CommandObjectExpression::CommandOptions::SetOptionValue (CommandInterpreter &int { bool success; uint32_t result; - result = Args::StringToUInt32(option_arg, 0, 0, &success); + result = StringConvert::ToUInt32(option_arg, 0, 0, &success); if (success) timeout = result; else @@ -196,7 +194,7 @@ CommandObjectExpression::CommandObjectExpression (CommandInterpreter &interprete "expression", "Evaluate a C/ObjC/C++ expression in the current program context, using user defined variables and variables currently in scope.", NULL, - eFlagProcessMustBePaused | eFlagTryTargetAPILock), + eCommandProcessMustBePaused | eCommandTryTargetAPILock), IOHandlerDelegate (IOHandlerDelegate::Completion::Expression), m_option_group (interpreter), m_format_options (eFormatDefault), @@ -487,7 +485,7 @@ CommandObjectExpression::DoExecute if (end_options) { - Args args (command, end_options - command); + Args args (llvm::StringRef(command, end_options - command)); if (!ParseOptions (args, result)) return false; diff --git a/contrib/llvm/tools/lldb/source/Commands/CommandObjectFrame.cpp b/contrib/llvm/tools/lldb/source/Commands/CommandObjectFrame.cpp index ce540a5..d8b65e3 100644 --- a/contrib/llvm/tools/lldb/source/Commands/CommandObjectFrame.cpp +++ b/contrib/llvm/tools/lldb/source/Commands/CommandObjectFrame.cpp @@ -7,8 +7,6 @@ // //===----------------------------------------------------------------------===// -#include "lldb/lldb-python.h" - #include "CommandObjectFrame.h" // C Includes @@ -27,6 +25,7 @@ #include "lldb/DataFormatters/DataVisualization.h" #include "lldb/DataFormatters/ValueObjectPrinter.h" #include "lldb/Host/Host.h" +#include "lldb/Host/StringConvert.h" #include "lldb/Interpreter/Args.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" @@ -64,10 +63,10 @@ public: "frame info", "List information about the currently selected frame in the current thread.", "frame info", - eFlagRequiresFrame | - eFlagTryTargetAPILock | - eFlagProcessMustBeLaunched | - eFlagProcessMustBePaused ) + eCommandRequiresFrame | + eCommandTryTargetAPILock | + eCommandProcessMustBeLaunched | + eCommandProcessMustBePaused ) { } @@ -119,7 +118,7 @@ public: switch (short_option) { case 'r': - relative_frame_offset = Args::StringToSInt32 (option_arg, INT32_MIN, 0, &success); + relative_frame_offset = StringConvert::ToSInt32 (option_arg, INT32_MIN, 0, &success); if (!success) error.SetErrorStringWithFormat ("invalid frame offset argument '%s'", option_arg); break; @@ -155,10 +154,10 @@ public: "frame select", "Select a frame by index from within the current thread and make it the current frame.", NULL, - eFlagRequiresThread | - eFlagTryTargetAPILock | - eFlagProcessMustBeLaunched | - eFlagProcessMustBePaused ), + eCommandRequiresThread | + eCommandTryTargetAPILock | + eCommandProcessMustBeLaunched | + eCommandProcessMustBePaused ), m_options (interpreter) { CommandArgumentEntry arg; @@ -191,7 +190,7 @@ protected: bool DoExecute (Args& command, CommandReturnObject &result) { - // No need to check "thread" for validity as eFlagRequiresThread ensures it is valid + // No need to check "thread" for validity as eCommandRequiresThread ensures it is valid Thread *thread = m_exe_ctx.GetThreadPtr(); uint32_t frame_idx = UINT32_MAX; @@ -246,7 +245,7 @@ protected: { const char *frame_idx_cstr = command.GetArgumentAtIndex(0); bool success = false; - frame_idx = Args::StringToUInt32 (frame_idx_cstr, UINT32_MAX, 0, &success); + frame_idx = StringConvert::ToUInt32 (frame_idx_cstr, UINT32_MAX, 0, &success); if (!success) { result.AppendErrorWithFormat ("invalid frame index argument '%s'", frame_idx_cstr); @@ -313,11 +312,11 @@ public: "Children of aggregate variables can be specified such as " "'var->child.x'.", NULL, - eFlagRequiresFrame | - eFlagTryTargetAPILock | - eFlagProcessMustBeLaunched | - eFlagProcessMustBePaused | - eFlagRequiresProcess), + eCommandRequiresFrame | + eCommandTryTargetAPILock | + eCommandProcessMustBeLaunched | + eCommandProcessMustBePaused | + eCommandRequiresProcess), m_option_group (interpreter), m_option_variable(true), // Include the frame specific options by passing "true" m_option_format (eFormatDefault), @@ -384,7 +383,7 @@ protected: virtual bool DoExecute (Args& command, CommandReturnObject &result) { - // No need to check "frame" for validity as eFlagRequiresFrame ensures it is valid + // No need to check "frame" for validity as eCommandRequiresFrame ensures it is valid StackFrame *frame = m_exe_ctx.GetFramePtr(); Stream &s = result.GetOutputStream(); @@ -521,30 +520,31 @@ protected: { var_sp = variable_list->GetVariableAtIndex(i); bool dump_variable = true; + std::string scope_string; switch (var_sp->GetScope()) { case eValueTypeVariableGlobal: dump_variable = m_option_variable.show_globals; if (dump_variable && m_option_variable.show_scope) - s.PutCString("GLOBAL: "); + scope_string = "GLOBAL: "; break; case eValueTypeVariableStatic: dump_variable = m_option_variable.show_globals; if (dump_variable && m_option_variable.show_scope) - s.PutCString("STATIC: "); + scope_string = "STATIC: "; break; case eValueTypeVariableArgument: dump_variable = m_option_variable.show_args; if (dump_variable && m_option_variable.show_scope) - s.PutCString(" ARG: "); + scope_string = " ARG: "; break; case eValueTypeVariableLocal: dump_variable = m_option_variable.show_locals; if (dump_variable && m_option_variable.show_scope) - s.PutCString(" LOCAL: "); + scope_string = " LOCAL: "; break; default: @@ -554,7 +554,7 @@ protected: if (dump_variable) { // Use the variable object code to make sure we are - // using the same APIs as the the public API will be + // using the same APIs as the public API will be // using... valobj_sp = frame->GetValueObjectForFrameVariable (var_sp, m_varobj_options.use_dynamic); @@ -567,6 +567,13 @@ protected: // that are not in scope to avoid extra unneeded output if (valobj_sp->IsInScope ()) { + if (false == valobj_sp->GetTargetSP()->GetDisplayRuntimeSupportValues() && + true == valobj_sp->IsRuntimeSupportValue()) + continue; + + if (!scope_string.empty()) + s.PutCString(scope_string.c_str()); + if (m_option_variable.show_decl && var_sp->GetDeclaration ().GetFile()) { var_sp->GetDeclaration ().DumpStopContext (&s, false); diff --git a/contrib/llvm/tools/lldb/source/Commands/CommandObjectGUI.cpp b/contrib/llvm/tools/lldb/source/Commands/CommandObjectGUI.cpp index 3d05335..0991c7e 100644 --- a/contrib/llvm/tools/lldb/source/Commands/CommandObjectGUI.cpp +++ b/contrib/llvm/tools/lldb/source/Commands/CommandObjectGUI.cpp @@ -7,8 +7,6 @@ // //===----------------------------------------------------------------------===// -#include "lldb/lldb-python.h" - #include "CommandObjectGUI.h" // C Includes @@ -42,10 +40,22 @@ CommandObjectGUI::DoExecute (Args& args, CommandReturnObject &result) if (args.GetArgumentCount() == 0) { Debugger &debugger = m_interpreter.GetDebugger(); - IOHandlerSP io_handler_sp (new IOHandlerCursesGUI (debugger)); - if (io_handler_sp) - debugger.PushIOHandler(io_handler_sp); - result.SetStatus (eReturnStatusSuccessFinishResult); + + lldb::StreamFileSP input_sp = debugger.GetInputFile(); + if (input_sp && + input_sp->GetFile().GetIsRealTerminal() && + input_sp->GetFile().GetIsInteractive()) + { + IOHandlerSP io_handler_sp (new IOHandlerCursesGUI (debugger)); + if (io_handler_sp) + debugger.PushIOHandler(io_handler_sp); + result.SetStatus (eReturnStatusSuccessFinishResult); + } + else + { + result.AppendError("the gui command requires an interactive terminal."); + result.SetStatus (eReturnStatusFailed); + } } else { diff --git a/contrib/llvm/tools/lldb/source/Commands/CommandObjectHelp.cpp b/contrib/llvm/tools/lldb/source/Commands/CommandObjectHelp.cpp index f73d9d2..18dc44a 100644 --- a/contrib/llvm/tools/lldb/source/Commands/CommandObjectHelp.cpp +++ b/contrib/llvm/tools/lldb/source/Commands/CommandObjectHelp.cpp @@ -7,8 +7,6 @@ // //===----------------------------------------------------------------------===// -#include "lldb/lldb-python.h" - #include "CommandObjectHelp.h" // C Includes @@ -54,9 +52,10 @@ CommandObjectHelp::~CommandObjectHelp() OptionDefinition CommandObjectHelp::CommandOptions::g_option_table[] = { - { LLDB_OPT_SET_ALL, false, "show-aliases", 'a', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Show aliases in the command list."}, + { LLDB_OPT_SET_ALL, false, "hide-aliases", 'a', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Hide aliases in the command list."}, { LLDB_OPT_SET_ALL, false, "hide-user-commands", 'u', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Hide user-defined commands from the list."}, - { 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL } + { LLDB_OPT_SET_ALL, false, "show-hidden-commands", 'h', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Include commands prefixed with an underscore."}, + { 0, false, NULL, 0, 0, 0, NULL, 0, eArgTypeNone, NULL } }; bool @@ -75,6 +74,8 @@ CommandObjectHelp::DoExecute (Args& command, CommandReturnObject &result) cmd_types |= CommandInterpreter::eCommandTypesAliases; if (m_options.m_show_user_defined) cmd_types |= CommandInterpreter::eCommandTypesUserDef; + if (m_options.m_show_hidden) + cmd_types |= CommandInterpreter::eCommandTypesHidden; result.SetStatus (eReturnStatusSuccessFinishNoResult); m_interpreter.GetHelp (result, cmd_types); // General help @@ -136,17 +137,19 @@ CommandObjectHelp::DoExecute (Args& command, CommandReturnObject &result) else if (!sub_cmd_obj) { result.AppendErrorWithFormat("'%s' is not a known command.\n" - "Try 'help' to see a current list of commands.\n", - cmd_string.c_str()); + "Try '%shelp' to see a current list of commands.\n", + cmd_string.c_str(), + m_interpreter.GetCommandPrefix()); result.SetStatus (eReturnStatusFailed); return false; } else { result.GetOutputStream().Printf("'%s' is not a known command.\n" - "Try 'help' to see a current list of commands.\n" + "Try '%shelp' to see a current list of commands.\n" "The closest match is '%s'. Help on it follows.\n\n", cmd_string.c_str(), + m_interpreter.GetCommandPrefix(), sub_cmd_obj->GetCommandName()); } } @@ -183,8 +186,9 @@ CommandObjectHelp::DoExecute (Args& command, CommandReturnObject &result) else { result.AppendErrorWithFormat - ("'%s' is not a known command.\nTry 'help' to see a current list of commands.\n", - command.GetArgumentAtIndex(0)); + ("'%s' is not a known command.\nTry '%shelp' to see a current list of commands.\n", + command.GetArgumentAtIndex(0), + m_interpreter.GetCommandPrefix()); result.SetStatus (eReturnStatusFailed); } } diff --git a/contrib/llvm/tools/lldb/source/Commands/CommandObjectHelp.h b/contrib/llvm/tools/lldb/source/Commands/CommandObjectHelp.h index 6e8f9d4..7db659c 100644 --- a/contrib/llvm/tools/lldb/source/Commands/CommandObjectHelp.h +++ b/contrib/llvm/tools/lldb/source/Commands/CommandObjectHelp.h @@ -62,11 +62,14 @@ public: switch (short_option) { case 'a': - m_show_aliases = true; + m_show_aliases = false; break; case 'u': m_show_user_defined = false; break; + case 'h': + m_show_hidden = true; + break; default: error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option); break; @@ -78,8 +81,9 @@ public: void OptionParsingStarting () { - m_show_aliases = false; + m_show_aliases = true; m_show_user_defined = true; + m_show_hidden = false; } const OptionDefinition* @@ -95,7 +99,8 @@ public: // Instance variables to hold the values for command options. bool m_show_aliases; - bool m_show_user_defined; + bool m_show_user_defined; + bool m_show_hidden; }; virtual Options * diff --git a/contrib/llvm/tools/lldb/source/Commands/CommandObjectLanguage.cpp b/contrib/llvm/tools/lldb/source/Commands/CommandObjectLanguage.cpp new file mode 100644 index 0000000..9d4b856 --- /dev/null +++ b/contrib/llvm/tools/lldb/source/Commands/CommandObjectLanguage.cpp @@ -0,0 +1,44 @@ +//===-- CommandObjectLanguage.cpp -------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "CommandObjectLanguage.h" + +#include "lldb/Host/Host.h" + +#include "lldb/Interpreter/CommandInterpreter.h" +#include "lldb/Interpreter/CommandReturnObject.h" + +#include "lldb/Target/LanguageRuntime.h" + +using namespace lldb; +using namespace lldb_private; + +CommandObjectLanguage::CommandObjectLanguage (CommandInterpreter &interpreter) : +CommandObjectMultiword (interpreter, + "language", + "A set of commands for managing language-specific functionality.'.", + "language <language-name> <subcommand> [<subcommand-options>]" + ) +{ + //Let the LanguageRuntime populates this command with subcommands + LanguageRuntime::InitializeCommands(this); +} + +void +CommandObjectLanguage::GenerateHelpText (Stream &output_stream) { + CommandObjectMultiword::GenerateHelpText(output_stream); + + output_stream << "\nlanguage name can be one of the following:\n"; + + LanguageRuntime::PrintAllLanguages(output_stream, " ", "\n"); +} + +CommandObjectLanguage::~CommandObjectLanguage () +{ +} diff --git a/contrib/llvm/tools/lldb/source/Commands/CommandObjectLanguage.h b/contrib/llvm/tools/lldb/source/Commands/CommandObjectLanguage.h new file mode 100644 index 0000000..751fe14 --- /dev/null +++ b/contrib/llvm/tools/lldb/source/Commands/CommandObjectLanguage.h @@ -0,0 +1,41 @@ +//===-- CommandObjectLanguage.h ---------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef liblldb_CommandObjectLanguage_h_ +#define liblldb_CommandObjectLanguage_h_ + +// C Includes +// C++ Includes + + +// Other libraries and framework includes +// Project includes + +#include "lldb/lldb-types.h" +#include "lldb/Interpreter/CommandObjectMultiword.h" + +namespace lldb_private { + class CommandObjectLanguage : public CommandObjectMultiword + { + public: + CommandObjectLanguage (CommandInterpreter &interpreter); + + virtual + ~CommandObjectLanguage (); + + virtual void + GenerateHelpText (Stream &output_stream); + + protected: + bool + DoExecute (Args& command, CommandReturnObject &result); + }; +} // namespace lldb_private + +#endif // liblldb_CommandObjectLanguage_h_ diff --git a/contrib/llvm/tools/lldb/source/Commands/CommandObjectLog.cpp b/contrib/llvm/tools/lldb/source/Commands/CommandObjectLog.cpp index 7d32cc6..e68eaf1 100644 --- a/contrib/llvm/tools/lldb/source/Commands/CommandObjectLog.cpp +++ b/contrib/llvm/tools/lldb/source/Commands/CommandObjectLog.cpp @@ -7,16 +7,12 @@ // //===----------------------------------------------------------------------===// -#include "lldb/lldb-python.h" - #include "CommandObjectLog.h" // C Includes // C++ Includes // Other libraries and framework includes // Project includes -#include "lldb/lldb-private-log.h" - #include "lldb/Interpreter/Args.h" #include "lldb/Core/Debugger.h" #include "lldb/Host/FileSpec.h" @@ -29,6 +25,7 @@ #include "lldb/Core/Timer.h" #include "lldb/Core/Debugger.h" +#include "lldb/Host/StringConvert.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" @@ -147,6 +144,7 @@ public: case 'p': log_options |= LLDB_LOG_OPTION_PREPEND_PROC_AND_THREAD;break; case 'n': log_options |= LLDB_LOG_OPTION_PREPEND_THREAD_NAME; break; case 'S': log_options |= LLDB_LOG_OPTION_BACKTRACE; break; + case 'a': log_options |= LLDB_LOG_OPTION_APPEND; break; default: error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option); break; @@ -224,6 +222,7 @@ CommandObjectLogEnable::CommandOptions::g_option_table[] = { LLDB_OPT_SET_1, false, "pid-tid", 'p', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Prepend all log lines with the process and thread ID that generates the log line." }, { LLDB_OPT_SET_1, false, "thread-name",'n', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Prepend all log lines with the thread name for the thread that generates the log line." }, { LLDB_OPT_SET_1, false, "stack", 'S', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Append a stack backtrace to each log line." }, +{ LLDB_OPT_SET_1, false, "append", 'a', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Append to the log file instead of overwriting." }, { 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL } }; @@ -444,7 +443,7 @@ protected: if (strcasecmp(sub_command, "enable") == 0) { bool success; - uint32_t depth = Args::StringToUInt32(args.GetArgumentAtIndex(1), 0, 0, &success); + uint32_t depth = StringConvert::ToUInt32(args.GetArgumentAtIndex(1), 0, 0, &success); if (success) { Timer::SetDisplayDepth (depth); diff --git a/contrib/llvm/tools/lldb/source/Commands/CommandObjectMemory.cpp b/contrib/llvm/tools/lldb/source/Commands/CommandObjectMemory.cpp index 6c06ec8..d589800 100644 --- a/contrib/llvm/tools/lldb/source/Commands/CommandObjectMemory.cpp +++ b/contrib/llvm/tools/lldb/source/Commands/CommandObjectMemory.cpp @@ -7,8 +7,6 @@ // //===----------------------------------------------------------------------===// -#include "lldb/lldb-python.h" - #include "CommandObjectMemory.h" // C Includes @@ -16,6 +14,7 @@ // C++ Includes // Other libraries and framework includes +#include "clang/AST/Decl.h" // Project includes #include "lldb/Core/DataBufferHeap.h" #include "lldb/Core/DataExtractor.h" @@ -24,6 +23,8 @@ #include "lldb/Core/StreamString.h" #include "lldb/Core/ValueObjectMemory.h" #include "lldb/DataFormatters/ValueObjectPrinter.h" +#include "lldb/Expression/ClangPersistentVariables.h" +#include "lldb/Host/StringConvert.h" #include "lldb/Interpreter/Args.h" #include "lldb/Interpreter/CommandReturnObject.h" #include "lldb/Interpreter/CommandInterpreter.h" @@ -94,7 +95,7 @@ public: switch (short_option) { case 'l': - error = m_num_per_line.SetValueFromCString (option_arg); + error = m_num_per_line.SetValueFromString (option_arg); if (m_num_per_line.GetCurrentValue() == 0) error.SetErrorStringWithFormat("invalid value for --num-per-line option '%s'", option_arg); break; @@ -104,7 +105,7 @@ public: break; case 't': - error = m_view_as_type.SetValueFromCString (option_arg); + error = m_view_as_type.SetValueFromString (option_arg); break; case 'r': @@ -312,7 +313,7 @@ public: "memory read", "Read from the memory of the process being debugged.", NULL, - eFlagRequiresTarget | eFlagProcessMustBePaused), + eCommandRequiresTarget | eCommandProcessMustBePaused), m_option_group (interpreter), m_format_options (eFormatBytesWithASCII, 1, 8), m_memory_options (), @@ -385,7 +386,7 @@ protected: virtual bool DoExecute (Args& command, CommandReturnObject &result) { - // No need to check "target" for validity as eFlagRequiresTarget ensures it is valid + // No need to check "target" for validity as eCommandRequiresTarget ensures it is valid Target *target = m_exe_ctx.GetTargetPtr(); const size_t argc = command.GetArgumentCount(); @@ -531,7 +532,7 @@ protected: clang::TypeDecl *tdecl = target->GetPersistentVariables().GetPersistentType(ConstString(lookup_type_name)); if (tdecl) { - clang_ast_type.SetClangType(&tdecl->getASTContext(),(lldb::clang_type_t)tdecl->getTypeForDecl()); + clang_ast_type.SetClangType(&tdecl->getASTContext(),(const lldb::clang_type_t)tdecl->getTypeForDecl()); } } @@ -566,7 +567,7 @@ protected: --pointer_count; } - m_format_options.GetByteSizeValue() = clang_ast_type.GetByteSize(); + m_format_options.GetByteSizeValue() = clang_ast_type.GetByteSize(nullptr); if (m_format_options.GetByteSizeValue() == 0) { @@ -689,7 +690,7 @@ protected: if (m_format_options.GetFormatValue().OptionWasSet() == false) m_format_options.GetFormatValue().SetCurrentValue(eFormatDefault); - bytes_read = clang_ast_type.GetByteSize() * m_format_options.GetCountValue().GetCurrentValue(); + bytes_read = clang_ast_type.GetByteSize(nullptr) * m_format_options.GetCountValue().GetCurrentValue(); } else if (m_format_options.GetFormatValue().GetCurrentValue() != eFormatCString) { @@ -741,6 +742,7 @@ protected: auto data_addr = addr; auto count = item_count; item_count = 0; + bool break_on_no_NULL = false; while (item_count < count) { std::string buffer; @@ -753,17 +755,24 @@ protected: result.SetStatus(eReturnStatusFailed); return false; } + if (item_byte_size == read) { result.AppendWarningWithFormat("unable to find a NULL terminated string at 0x%" PRIx64 ".Consider increasing the maximum read length.\n", data_addr); - break; + --read; + break_on_no_NULL = true; } - read+=1; // account for final NULL byte + else + ++read; // account for final NULL byte + memcpy(data_ptr, &buffer[0], read); data_ptr += read; data_addr += read; bytes_read += read; item_count++; // if we break early we know we only read item_count strings + + if (break_on_no_NULL) + break; } data_sp.reset(new DataBufferHeap(data_sp->GetBytes(),bytes_read+1)); } @@ -980,20 +989,20 @@ public: switch (short_option) { case 'e': - m_expr.SetValueFromCString(option_arg); + m_expr.SetValueFromString(option_arg); break; case 's': - m_string.SetValueFromCString(option_arg); + m_string.SetValueFromString(option_arg); break; case 'c': - if (m_count.SetValueFromCString(option_arg).Fail()) + if (m_count.SetValueFromString(option_arg).Fail()) error.SetErrorString("unrecognized value for count"); break; case 'o': - if (m_offset.SetValueFromCString(option_arg).Fail()) + if (m_offset.SetValueFromString(option_arg).Fail()) error.SetErrorString("unrecognized value for dump-offset"); break; @@ -1023,7 +1032,7 @@ public: "memory find", "Find a value in the memory of the process being debugged.", NULL, - eFlagRequiresProcess | eFlagProcessMustBeLaunched), + eCommandRequiresProcess | eCommandProcessMustBeLaunched), m_option_group (interpreter), m_memory_options () { @@ -1069,7 +1078,7 @@ protected: virtual bool DoExecute (Args& command, CommandReturnObject &result) { - // No need to check "process" for validity as eFlagRequiresProcess ensures it is valid + // No need to check "process" for validity as eCommandRequiresProcess ensures it is valid Process *process = m_exe_ctx.GetProcessPtr(); const size_t argc = command.GetArgumentCount(); @@ -1113,7 +1122,7 @@ protected: if (process->GetTarget().EvaluateExpression(m_memory_options.m_expr.GetStringValue(), frame, result_sp) && result_sp.get()) { uint64_t value = result_sp->GetValueAsUnsigned(0); - switch (result_sp->GetClangType().GetByteSize()) + switch (result_sp->GetClangType().GetByteSize(nullptr)) { case 1: { uint8_t byte = (uint8_t)value; @@ -1293,7 +1302,7 @@ public: case 'o': { bool success; - m_infile_offset = Args::StringToUInt64(option_arg, 0, 0, &success); + m_infile_offset = StringConvert::ToUInt64(option_arg, 0, 0, &success); if (!success) { error.SetErrorStringWithFormat("invalid offset string '%s'", option_arg); @@ -1324,7 +1333,7 @@ public: "memory write", "Write to the memory of the process being debugged.", NULL, - eFlagRequiresProcess | eFlagProcessMustBeLaunched), + eCommandRequiresProcess | eCommandProcessMustBeLaunched), m_option_group (interpreter), m_format_options (eFormatBytes, 1, UINT64_MAX), m_memory_options () @@ -1401,7 +1410,7 @@ protected: virtual bool DoExecute (Args& command, CommandReturnObject &result) { - // No need to check "process" for validity as eFlagRequiresProcess ensures it is valid + // No need to check "process" for validity as eCommandRequiresProcess ensures it is valid Process *process = m_exe_ctx.GetProcessPtr(); const size_t argc = command.GetArgumentCount(); @@ -1446,7 +1455,7 @@ protected: if (m_memory_options.m_infile) { size_t length = SIZE_MAX; - if (item_byte_size > 0) + if (item_byte_size > 1) length = item_byte_size; lldb::DataBufferSP data_sp (m_memory_options.m_infile.ReadFileContents (m_memory_options.m_infile_offset, length)); if (data_sp) @@ -1539,7 +1548,7 @@ protected: case eFormatPointer: // Decode hex bytes - uval64 = Args::StringToUInt64(value_str, UINT64_MAX, 16, &success); + uval64 = StringConvert::ToUInt64(value_str, UINT64_MAX, 16, &success); if (!success) { result.AppendErrorWithFormat ("'%s' is not a valid hex string value.\n", value_str); @@ -1567,7 +1576,7 @@ protected: break; case eFormatBinary: - uval64 = Args::StringToUInt64(value_str, UINT64_MAX, 2, &success); + uval64 = StringConvert::ToUInt64(value_str, UINT64_MAX, 2, &success); if (!success) { result.AppendErrorWithFormat ("'%s' is not a valid binary string value.\n", value_str); @@ -1607,7 +1616,7 @@ protected: break; case eFormatDecimal: - sval64 = Args::StringToSInt64(value_str, INT64_MAX, 0, &success); + sval64 = StringConvert::ToSInt64(value_str, INT64_MAX, 0, &success); if (!success) { result.AppendErrorWithFormat ("'%s' is not a valid signed decimal value.\n", value_str); @@ -1624,7 +1633,7 @@ protected: break; case eFormatUnsigned: - uval64 = Args::StringToUInt64(value_str, UINT64_MAX, 0, &success); + uval64 = StringConvert::ToUInt64(value_str, UINT64_MAX, 0, &success); if (!success) { result.AppendErrorWithFormat ("'%s' is not a valid unsigned decimal string value.\n", value_str); @@ -1641,7 +1650,7 @@ protected: break; case eFormatOctal: - uval64 = Args::StringToUInt64(value_str, UINT64_MAX, 8, &success); + uval64 = StringConvert::ToUInt64(value_str, UINT64_MAX, 8, &success); if (!success) { result.AppendErrorWithFormat ("'%s' is not a valid octal string value.\n", value_str); @@ -1691,7 +1700,7 @@ public: "memory history", "Prints out the recorded stack traces for allocation/deallocation of a memory address.", NULL, - eFlagRequiresTarget | eFlagRequiresProcess | eFlagProcessMustBePaused | eFlagProcessMustBeLaunched) + eCommandRequiresTarget | eCommandRequiresProcess | eCommandProcessMustBePaused | eCommandProcessMustBeLaunched) { CommandArgumentEntry arg1; CommandArgumentData addr_arg; diff --git a/contrib/llvm/tools/lldb/source/Commands/CommandObjectMultiword.cpp b/contrib/llvm/tools/lldb/source/Commands/CommandObjectMultiword.cpp index 69b178d..2f0e2a7 100644 --- a/contrib/llvm/tools/lldb/source/Commands/CommandObjectMultiword.cpp +++ b/contrib/llvm/tools/lldb/source/Commands/CommandObjectMultiword.cpp @@ -7,8 +7,6 @@ // //===----------------------------------------------------------------------===// -#include "lldb/lldb-python.h" - #include "lldb/Interpreter/CommandObjectMultiword.h" // C Includes // C++ Includes @@ -153,7 +151,7 @@ CommandObjectMultiword::Execute(const char *args_string, CommandReturnObject &re error_msg.append (GetCommandName()); error_msg.append (" "); error_msg.append (sub_command); - error_msg.append ("'"); + error_msg.append ("'."); if (num_subcmd_matches > 0) { @@ -251,23 +249,27 @@ CommandObjectMultiword::HandleCompletion &temp_matches); if (cmd_obj != NULL) { - matches.DeleteStringAtIndex (0); - input.Shift(); - cursor_char_position = 0; - input.AppendArgument (""); - return cmd_obj->HandleCompletion (input, - cursor_index, - cursor_char_position, - match_start_point, - max_return_elements, - word_complete, - matches); + if (input.GetArgumentCount() == 1) + { + word_complete = true; + } + else + { + matches.DeleteStringAtIndex (0); + input.Shift(); + cursor_char_position = 0; + input.AppendArgument (""); + return cmd_obj->HandleCompletion (input, + cursor_index, + cursor_char_position, + match_start_point, + max_return_elements, + word_complete, + matches); + } } - else - return matches.GetSize(); } - else - return matches.GetSize(); + return matches.GetSize(); } else { diff --git a/contrib/llvm/tools/lldb/source/Commands/CommandObjectPlatform.cpp b/contrib/llvm/tools/lldb/source/Commands/CommandObjectPlatform.cpp index d176d52..866587f 100644 --- a/contrib/llvm/tools/lldb/source/Commands/CommandObjectPlatform.cpp +++ b/contrib/llvm/tools/lldb/source/Commands/CommandObjectPlatform.cpp @@ -7,8 +7,6 @@ // //===----------------------------------------------------------------------===// -#include "lldb/lldb-python.h" - #include "CommandObjectPlatform.h" // C Includes @@ -19,6 +17,7 @@ #include "lldb/Core/Debugger.h" #include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.h" +#include "lldb/Host/StringConvert.h" #include "lldb/Interpreter/Args.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandOptionValidators.h" @@ -104,7 +103,7 @@ public: case 'v': { bool ok; - uint32_t perms = Args::StringToUInt32(option_arg, 777, 8, &ok); + uint32_t perms = StringConvert::ToUInt32(option_arg, 777, 8, &ok); if (!ok) error.SetErrorStringWithFormat("invalid value for permissions: %s", option_arg); else @@ -248,6 +247,8 @@ protected: PlatformSP platform_sp (m_platform_options.CreatePlatformWithOptions (m_interpreter, ArchSpec(), select, error, platform_arch)); if (platform_sp) { + m_interpreter.GetDebugger().GetPlatformList().SetSelectedPlatform(platform_sp); + platform_sp->GetStatus (result.GetOutputStream()); result.SetStatus (eReturnStatusSuccessFinishResult); } @@ -555,7 +556,7 @@ protected: if (platform_sp) { if (m_option_working_dir.GetOptionValue().OptionWasSet()) - platform_sp->SetWorkingDirectory (ConstString(m_option_working_dir.GetOptionValue().GetCurrentValue().GetPath().c_str())); + platform_sp->SetWorkingDirectory(m_option_working_dir.GetOptionValue().GetCurrentValue()); } else { @@ -569,10 +570,7 @@ protected: GetOptions () { if (m_options.DidFinalize() == false) - { - m_options.Append(new OptionPermissions()); m_options.Finalize(); - } return &m_options; } protected: @@ -613,12 +611,12 @@ public: std::string cmd_line; args.GetCommandString(cmd_line); uint32_t mode; - const OptionPermissions* options_permissions = (OptionPermissions*)m_options.GetGroupWithOption('r'); + const OptionPermissions* options_permissions = (const OptionPermissions*)m_options.GetGroupWithOption('r'); if (options_permissions) mode = options_permissions->m_permissions; else mode = lldb::eFilePermissionsUserRWX | lldb::eFilePermissionsGroupRWX | lldb::eFilePermissionsWorldRX; - Error error = platform_sp->MakeDirectory(cmd_line.c_str(), mode); + Error error = platform_sp->MakeDirectory(FileSpec{cmd_line, false}, mode); if (error.Success()) { result.SetStatus (eReturnStatusSuccessFinishResult); @@ -682,7 +680,7 @@ public: std::string cmd_line; args.GetCommandString(cmd_line); mode_t perms; - const OptionPermissions* options_permissions = (OptionPermissions*)m_options.GetGroupWithOption('r'); + const OptionPermissions* options_permissions = (const OptionPermissions*)m_options.GetGroupWithOption('r'); if (options_permissions) perms = options_permissions->m_permissions; else @@ -751,7 +749,7 @@ public: { std::string cmd_line; args.GetCommandString(cmd_line); - const lldb::user_id_t fd = Args::StringToUInt64(cmd_line.c_str(), UINT64_MAX); + const lldb::user_id_t fd = StringConvert::ToUInt64(cmd_line.c_str(), UINT64_MAX); Error error; bool success = platform_sp->CloseFile(fd, error); if (success) @@ -803,7 +801,7 @@ public: { std::string cmd_line; args.GetCommandString(cmd_line); - const lldb::user_id_t fd = Args::StringToUInt64(cmd_line.c_str(), UINT64_MAX); + const lldb::user_id_t fd = StringConvert::ToUInt64(cmd_line.c_str(), UINT64_MAX); std::string buffer(m_options.m_count,0); Error error; uint32_t retcode = platform_sp->ReadFile(fd, m_options.m_offset, &buffer[0], m_options.m_count, error); @@ -849,12 +847,12 @@ protected: switch (short_option) { case 'o': - m_offset = Args::StringToUInt32(option_arg, 0, 0, &success); + m_offset = StringConvert::ToUInt32(option_arg, 0, 0, &success); if (!success) error.SetErrorStringWithFormat("invalid offset: '%s'", option_arg); break; case 'c': - m_count = Args::StringToUInt32(option_arg, 0, 0, &success); + m_count = StringConvert::ToUInt32(option_arg, 0, 0, &success); if (!success) error.SetErrorStringWithFormat("invalid offset: '%s'", option_arg); break; @@ -930,7 +928,7 @@ public: std::string cmd_line; args.GetCommandString(cmd_line); Error error; - const lldb::user_id_t fd = Args::StringToUInt64(cmd_line.c_str(), UINT64_MAX); + const lldb::user_id_t fd = StringConvert::ToUInt64(cmd_line.c_str(), UINT64_MAX); uint32_t retcode = platform_sp->WriteFile (fd, m_options.m_offset, &m_options.m_data[0], @@ -977,7 +975,7 @@ protected: switch (short_option) { case 'o': - m_offset = Args::StringToUInt32(option_arg, 0, 0, &success); + m_offset = StringConvert::ToUInt32(option_arg, 0, 0, &success); if (!success) error.SetErrorStringWithFormat("invalid offset: '%s'", option_arg); break; @@ -1198,7 +1196,7 @@ public: } else { - result.AppendMessageWithFormat("Eroor getting file size of %s (remote)\n", remote_file_path.c_str()); + result.AppendMessageWithFormat("Error getting file size of %s (remote)\n", remote_file_path.c_str()); result.SetStatus (eReturnStatusFailed); } } @@ -1238,8 +1236,8 @@ public: const char* dst = args.GetArgumentAtIndex(1); FileSpec src_fs(src, true); - FileSpec dst_fs(dst, false); - + FileSpec dst_fs(dst ? dst : src_fs.GetFilename().GetCString(), false); + PlatformSP platform_sp (m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform()); if (platform_sp) { @@ -1274,7 +1272,7 @@ public: "platform process launch", "Launch a new process on a remote platform.", "platform process launch program", - eFlagRequiresTarget | eFlagTryTargetAPILock), + eCommandRequiresTarget | eCommandTryTargetAPILock), m_options (interpreter) { } @@ -1537,37 +1535,37 @@ protected: switch (short_option) { case 'p': - match_info.GetProcessInfo().SetProcessID (Args::StringToUInt32 (option_arg, LLDB_INVALID_PROCESS_ID, 0, &success)); + match_info.GetProcessInfo().SetProcessID (StringConvert::ToUInt32 (option_arg, LLDB_INVALID_PROCESS_ID, 0, &success)); if (!success) error.SetErrorStringWithFormat("invalid process ID string: '%s'", option_arg); break; case 'P': - match_info.GetProcessInfo().SetParentProcessID (Args::StringToUInt32 (option_arg, LLDB_INVALID_PROCESS_ID, 0, &success)); + match_info.GetProcessInfo().SetParentProcessID (StringConvert::ToUInt32 (option_arg, LLDB_INVALID_PROCESS_ID, 0, &success)); if (!success) error.SetErrorStringWithFormat("invalid parent process ID string: '%s'", option_arg); break; case 'u': - match_info.GetProcessInfo().SetUserID (Args::StringToUInt32 (option_arg, UINT32_MAX, 0, &success)); + match_info.GetProcessInfo().SetUserID (StringConvert::ToUInt32 (option_arg, UINT32_MAX, 0, &success)); if (!success) error.SetErrorStringWithFormat("invalid user ID string: '%s'", option_arg); break; case 'U': - match_info.GetProcessInfo().SetEffectiveUserID (Args::StringToUInt32 (option_arg, UINT32_MAX, 0, &success)); + match_info.GetProcessInfo().SetEffectiveUserID (StringConvert::ToUInt32 (option_arg, UINT32_MAX, 0, &success)); if (!success) error.SetErrorStringWithFormat("invalid effective user ID string: '%s'", option_arg); break; case 'g': - match_info.GetProcessInfo().SetGroupID (Args::StringToUInt32 (option_arg, UINT32_MAX, 0, &success)); + match_info.GetProcessInfo().SetGroupID (StringConvert::ToUInt32 (option_arg, UINT32_MAX, 0, &success)); if (!success) error.SetErrorStringWithFormat("invalid group ID string: '%s'", option_arg); break; case 'G': - match_info.GetProcessInfo().SetEffectiveGroupID (Args::StringToUInt32 (option_arg, UINT32_MAX, 0, &success)); + match_info.GetProcessInfo().SetEffectiveGroupID (StringConvert::ToUInt32 (option_arg, UINT32_MAX, 0, &success)); if (!success) error.SetErrorStringWithFormat("invalid effective group ID string: '%s'", option_arg); break; @@ -1730,7 +1728,7 @@ protected: for (size_t i=0; i<argc; ++ i) { const char *arg = args.GetArgumentAtIndex(i); - lldb::pid_t pid = Args::StringToUInt32 (arg, LLDB_INVALID_PROCESS_ID, 0, &success); + lldb::pid_t pid = StringConvert::ToUInt32 (arg, LLDB_INVALID_PROCESS_ID, 0, &success); if (success) { ProcessInstanceInfo proc_info; @@ -1805,7 +1803,7 @@ public: { case 'p': { - lldb::pid_t pid = Args::StringToUInt32 (option_arg, LLDB_INVALID_PROCESS_ID, 0, &success); + lldb::pid_t pid = StringConvert::ToUInt32 (option_arg, LLDB_INVALID_PROCESS_ID, 0, &success); if (!success || pid == LLDB_INVALID_PROCESS_ID) { error.SetErrorStringWithFormat("invalid process ID '%s'", option_arg); @@ -1972,7 +1970,7 @@ CommandObjectPlatformProcessAttach::CommandOptions::g_option_table[] = { LLDB_OPT_SET_ALL, false, "plugin", 'P' , OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypePlugin, "Name of the process plugin you want to use."}, { LLDB_OPT_SET_1, false, "pid", 'p' , OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypePid, "The process ID of an existing process to attach to."}, { LLDB_OPT_SET_2, false, "name", 'n' , OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeProcessName, "The name of the process to attach to."}, - { LLDB_OPT_SET_2, false, "waitfor", 'w' , OptionParser::eNoArgument , NULL, NULL, 0, eArgTypeNone, "Wait for the the process with <process-name> to launch."}, + { LLDB_OPT_SET_2, false, "waitfor", 'w' , OptionParser::eNoArgument , NULL, NULL, 0, eArgTypeNone, "Wait for the process with <process-name> to launch."}, { 0, false, NULL , 0 , 0 , NULL, NULL, 0, eArgTypeNone, NULL } }; @@ -2055,7 +2053,7 @@ public: case 't': { bool success; - timeout = Args::StringToUInt32(option_value, 10, 10, &success); + timeout = StringConvert::ToUInt32(option_value, 10, 10, &success); if (!success) error.SetErrorStringWithFormat("could not convert \"%s\" to a numeric value.", option_value); break; @@ -2082,7 +2080,7 @@ public: CommandObjectPlatformShell (CommandInterpreter &interpreter) : CommandObjectRaw (interpreter, "platform shell", - "Run a shell command on a the selected platform.", + "Run a shell command on the selected platform.", "platform shell <shell-command>", 0), m_options(interpreter) @@ -2139,7 +2137,7 @@ public: if (end_options) { - Args args (raw_command_line, end_options - raw_command_line); + Args args (llvm::StringRef(raw_command_line, end_options - raw_command_line)); if (!ParseOptions (args, result)) return false; } @@ -2152,7 +2150,7 @@ public: Error error; if (platform_sp) { - const char *working_dir = NULL; + FileSpec working_dir{}; std::string output; int status = -1; int signo = -1; @@ -2278,19 +2276,16 @@ CommandObjectPlatform::CommandObjectPlatform(CommandInterpreter &interpreter) : LoadSubCommand ("connect", CommandObjectSP (new CommandObjectPlatformConnect (interpreter))); LoadSubCommand ("disconnect", CommandObjectSP (new CommandObjectPlatformDisconnect (interpreter))); LoadSubCommand ("settings", CommandObjectSP (new CommandObjectPlatformSettings (interpreter))); -#ifdef LLDB_CONFIGURATION_DEBUG LoadSubCommand ("mkdir", CommandObjectSP (new CommandObjectPlatformMkDir (interpreter))); LoadSubCommand ("file", CommandObjectSP (new CommandObjectPlatformFile (interpreter))); LoadSubCommand ("get-file", CommandObjectSP (new CommandObjectPlatformGetFile (interpreter))); LoadSubCommand ("get-size", CommandObjectSP (new CommandObjectPlatformGetSize (interpreter))); LoadSubCommand ("put-file", CommandObjectSP (new CommandObjectPlatformPutFile (interpreter))); -#endif LoadSubCommand ("process", CommandObjectSP (new CommandObjectPlatformProcess (interpreter))); LoadSubCommand ("shell", CommandObjectSP (new CommandObjectPlatformShell (interpreter))); LoadSubCommand ("target-install", CommandObjectSP (new CommandObjectPlatformInstall (interpreter))); } - //---------------------------------------------------------------------- // Destructor //---------------------------------------------------------------------- diff --git a/contrib/llvm/tools/lldb/source/Commands/CommandObjectPlugin.cpp b/contrib/llvm/tools/lldb/source/Commands/CommandObjectPlugin.cpp index 658c077..63fa4a8 100644 --- a/contrib/llvm/tools/lldb/source/Commands/CommandObjectPlugin.cpp +++ b/contrib/llvm/tools/lldb/source/Commands/CommandObjectPlugin.cpp @@ -7,8 +7,6 @@ // //===----------------------------------------------------------------------===// -#include "lldb/lldb-python.h" - #include "CommandObjectPlugin.h" #include "lldb/Host/Host.h" diff --git a/contrib/llvm/tools/lldb/source/Commands/CommandObjectProcess.cpp b/contrib/llvm/tools/lldb/source/Commands/CommandObjectProcess.cpp index ec7b478..4414bdf 100644 --- a/contrib/llvm/tools/lldb/source/Commands/CommandObjectProcess.cpp +++ b/contrib/llvm/tools/lldb/source/Commands/CommandObjectProcess.cpp @@ -7,8 +7,6 @@ // //===----------------------------------------------------------------------===// -#include "lldb/lldb-python.h" - #include "CommandObjectProcess.h" // C Includes @@ -22,6 +20,7 @@ #include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.h" #include "lldb/Host/Host.h" +#include "lldb/Host/StringConvert.h" #include "lldb/Interpreter/Args.h" #include "lldb/Interpreter/Options.h" #include "lldb/Interpreter/CommandInterpreter.h" @@ -31,6 +30,7 @@ #include "lldb/Target/StopInfo.h" #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" +#include "lldb/Target/UnixSignals.h" using namespace lldb; using namespace lldb_private; @@ -91,7 +91,7 @@ protected: } else { - Error destroy_error (process->Destroy()); + Error destroy_error (process->Destroy(false)); if (destroy_error.Success()) { result.SetStatus (eReturnStatusSuccessFinishResult); @@ -123,7 +123,7 @@ public: "process launch", "Launch the executable in the debugger.", NULL, - eFlagRequiresTarget, + eCommandRequiresTarget, "restart"), m_options (interpreter) { @@ -248,9 +248,7 @@ protected: if (launch_args.GetArgumentCount() == 0) { - Args target_setting_args; - if (target->GetRunArguments(target_setting_args)) - m_options.launch_info.GetArguments().AppendArguments (target_setting_args); + m_options.launch_info.GetArguments().AppendArguments (target->GetProcessLaunchInfo().GetArguments()); } else { @@ -264,13 +262,18 @@ protected: if (error.Success()) { - const char *archname = exe_module_sp->GetArchitecture().GetArchitectureName(); ProcessSP process_sp (target->GetProcessSP()); if (process_sp) { + // There is a race condition where this thread will return up the call stack to the main command + // handler and show an (lldb) prompt before HandlePrivateEvent (from PrivateStateThread) has + // a chance to call PushProcessIOHandler(). + process_sp->SyncIOHandler (0, 2000); + const char *data = stream.GetData(); if (data && strlen(data) > 0) result.AppendMessage(stream.GetData()); + const char *archname = exe_module_sp->GetArchitecture().GetArchitectureName(); result.AppendMessageWithFormat ("Process %" PRIu64 " launched: '%s' (%s)\n", process_sp->GetID(), exe_module_sp->GetFileSpec().GetPath().c_str(), archname); result.SetStatus (eReturnStatusSuccessFinishResult); result.SetDidChangeProcessState (true); @@ -353,7 +356,7 @@ public: case 'p': { - lldb::pid_t pid = Args::StringToUInt32 (option_arg, LLDB_INVALID_PROCESS_ID, 0, &success); + lldb::pid_t pid = StringConvert::ToUInt32 (option_arg, LLDB_INVALID_PROCESS_ID, 0, &success); if (!success || pid == LLDB_INVALID_PROCESS_ID) { error.SetErrorStringWithFormat("invalid process ID '%s'", option_arg); @@ -488,6 +491,8 @@ protected: DoExecute (Args& command, CommandReturnObject &result) { + PlatformSP platform_sp (m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform()); + Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); // N.B. The attach should be synchronous. It doesn't help much to get the prompt back between initiating the attach // and the target actually stopping. So even if the interpreter is set to be asynchronous, we wait for the stop @@ -530,118 +535,75 @@ protected: { result.AppendErrorWithFormat("Invalid arguments for '%s'.\nUsage: %s\n", m_cmd_name.c_str(), m_cmd_syntax.c_str()); result.SetStatus (eReturnStatusFailed); + return false; } - else + + m_interpreter.UpdateExecutionContext(nullptr); + StreamString stream; + const auto error = target->Attach(m_options.attach_info, &stream); + if (error.Success()) { - if (state != eStateConnected) + ProcessSP process_sp (target->GetProcessSP()); + if (process_sp) { - const char *plugin_name = m_options.attach_info.GetProcessPluginName(); - process = target->CreateProcess (m_interpreter.GetDebugger().GetListener(), plugin_name, NULL).get(); + if (stream.GetData()) + result.AppendMessage(stream.GetData()); + result.SetStatus (eReturnStatusSuccessFinishNoResult); + result.SetDidChangeProcessState (true); } - - if (process) + else { - Error error; - // If no process info was specified, then use the target executable - // name as the process to attach to by default - if (!m_options.attach_info.ProcessInfoSpecified ()) - { - if (old_exec_module_sp) - m_options.attach_info.GetExecutableFile().GetFilename() = old_exec_module_sp->GetPlatformFileSpec().GetFilename(); + result.AppendError("no error returned from Target::Attach, and target has no process"); + result.SetStatus (eReturnStatusFailed); + } + } + else + { + result.AppendErrorWithFormat ("attach failed: %s\n", error.AsCString()); + result.SetStatus (eReturnStatusFailed); + } - if (!m_options.attach_info.ProcessInfoSpecified ()) - { - error.SetErrorString ("no process specified, create a target with a file, or specify the --pid or --name command option"); - } - } + if (!result.Succeeded()) + return false; - if (error.Success()) - { - // Update the execution context so the current target and process are now selected - // in case we interrupt - m_interpreter.UpdateExecutionContext(NULL); - ListenerSP listener_sp (new Listener("lldb.CommandObjectProcessAttach.DoExecute.attach.hijack")); - m_options.attach_info.SetHijackListener(listener_sp); - process->HijackProcessEvents(listener_sp.get()); - error = process->Attach (m_options.attach_info); - - if (error.Success()) - { - result.SetStatus (eReturnStatusSuccessContinuingNoResult); - StreamString stream; - StateType state = process->WaitForProcessToStop (NULL, NULL, false, listener_sp.get(), &stream); + // Okay, we're done. Last step is to warn if the executable module has changed: + char new_path[PATH_MAX]; + ModuleSP new_exec_module_sp (target->GetExecutableModule()); + if (!old_exec_module_sp) + { + // We might not have a module if we attached to a raw pid... + if (new_exec_module_sp) + { + new_exec_module_sp->GetFileSpec().GetPath(new_path, PATH_MAX); + result.AppendMessageWithFormat("Executable module set to \"%s\".\n", new_path); + } + } + else if (old_exec_module_sp->GetFileSpec() != new_exec_module_sp->GetFileSpec()) + { + char old_path[PATH_MAX]; - process->RestoreProcessEvents(); + old_exec_module_sp->GetFileSpec().GetPath (old_path, PATH_MAX); + new_exec_module_sp->GetFileSpec().GetPath (new_path, PATH_MAX); - result.SetDidChangeProcessState (true); - - if (stream.GetData()) - result.AppendMessage(stream.GetData()); + result.AppendWarningWithFormat("Executable module changed from \"%s\" to \"%s\".\n", + old_path, new_path); + } - if (state == eStateStopped) - { - result.SetStatus (eReturnStatusSuccessFinishNoResult); - } - else - { - const char *exit_desc = process->GetExitDescription(); - if (exit_desc) - result.AppendErrorWithFormat ("attach failed: %s", exit_desc); - else - result.AppendError ("attach failed: process did not stop (no such process or permission problem?)"); - process->Destroy(); - result.SetStatus (eReturnStatusFailed); - } - } - else - { - result.AppendErrorWithFormat ("attach failed: %s\n", error.AsCString()); - result.SetStatus (eReturnStatusFailed); - } - } - } + if (!old_arch_spec.IsValid()) + { + result.AppendMessageWithFormat ("Architecture set to: %s.\n", target->GetArchitecture().GetTriple().getTriple().c_str()); } - - if (result.Succeeded()) + else if (!old_arch_spec.IsExactMatch(target->GetArchitecture())) { - // Okay, we're done. Last step is to warn if the executable module has changed: - char new_path[PATH_MAX]; - ModuleSP new_exec_module_sp (target->GetExecutableModule()); - if (!old_exec_module_sp) - { - // We might not have a module if we attached to a raw pid... - if (new_exec_module_sp) - { - new_exec_module_sp->GetFileSpec().GetPath(new_path, PATH_MAX); - result.AppendMessageWithFormat("Executable module set to \"%s\".\n", new_path); - } - } - else if (old_exec_module_sp->GetFileSpec() != new_exec_module_sp->GetFileSpec()) - { - char old_path[PATH_MAX]; - - old_exec_module_sp->GetFileSpec().GetPath (old_path, PATH_MAX); - new_exec_module_sp->GetFileSpec().GetPath (new_path, PATH_MAX); - - result.AppendWarningWithFormat("Executable module changed from \"%s\" to \"%s\".\n", - old_path, new_path); - } - - if (!old_arch_spec.IsValid()) - { - result.AppendMessageWithFormat ("Architecture set to: %s.\n", target->GetArchitecture().GetTriple().getTriple().c_str()); - } - else if (!old_arch_spec.IsExactMatch(target->GetArchitecture())) - { - result.AppendWarningWithFormat("Architecture changed from %s to %s.\n", - old_arch_spec.GetTriple().getTriple().c_str(), - target->GetArchitecture().GetTriple().getTriple().c_str()); - } - - // This supports the use-case scenario of immediately continuing the process once attached. - if (m_options.attach_info.GetContinueOnceAttached()) - m_interpreter.HandleCommand("process continue", eLazyBoolNo, result); + result.AppendWarningWithFormat("Architecture changed from %s to %s.\n", + old_arch_spec.GetTriple().getTriple().c_str(), + target->GetArchitecture().GetTriple().getTriple().c_str()); } + + // This supports the use-case scenario of immediately continuing the process once attached. + if (m_options.attach_info.GetContinueOnceAttached()) + m_interpreter.HandleCommand("process continue", eLazyBoolNo, result); + return result.Succeeded(); } @@ -675,10 +637,10 @@ public: "process continue", "Continue execution of all threads in the current process.", "process continue", - eFlagRequiresProcess | - eFlagTryTargetAPILock | - eFlagProcessMustBeLaunched | - eFlagProcessMustBePaused ), + eCommandRequiresProcess | + eCommandTryTargetAPILock | + eCommandProcessMustBeLaunched | + eCommandProcessMustBePaused ), m_options(interpreter) { } @@ -714,7 +676,7 @@ protected: switch (short_option) { case 'i': - m_ignore = Args::StringToUInt32 (option_arg, 0, 0, &success); + m_ignore = StringConvert::ToUInt32 (option_arg, 0, 0, &success); if (!success) error.SetErrorStringWithFormat ("invalid value for ignore option: \"%s\", should be a number.", option_arg); break; @@ -798,6 +760,8 @@ protected: } } + const uint32_t iohandler_id = process->GetIOHandlerID(); + StreamString stream; Error error; if (synchronous_execution) @@ -808,9 +772,9 @@ protected: if (error.Success()) { // There is a race condition where this thread will return up the call stack to the main command - // handler and show an (lldb) prompt before HandlePrivateEvent (from PrivateStateThread) has - // a chance to call PushProcessIOHandler(). - process->SyncIOHandler(2000); + // handler and show an (lldb) prompt before HandlePrivateEvent (from PrivateStateThread) has + // a chance to call PushProcessIOHandler(). + process->SyncIOHandler(iohandler_id, 2000); result.AppendMessageWithFormat ("Process %" PRIu64 " resuming\n", process->GetID()); if (synchronous_execution) @@ -936,9 +900,9 @@ public: "process detach", "Detach from the current process being debugged.", "process detach", - eFlagRequiresProcess | - eFlagTryTargetAPILock | - eFlagProcessMustBeLaunched), + eCommandRequiresProcess | + eCommandTryTargetAPILock | + eCommandProcessMustBeLaunched), m_options(interpreter) { } @@ -1217,10 +1181,10 @@ public: "process load", "Load a shared library into the current process.", "process load <filename> [<filename> ...]", - eFlagRequiresProcess | - eFlagTryTargetAPILock | - eFlagProcessMustBeLaunched | - eFlagProcessMustBePaused ) + eCommandRequiresProcess | + eCommandTryTargetAPILock | + eCommandProcessMustBeLaunched | + eCommandProcessMustBePaused ) { } @@ -1274,10 +1238,10 @@ public: "process unload", "Unload a shared library from the current process using the index returned by a previous call to \"process load\".", "process unload <index>", - eFlagRequiresProcess | - eFlagTryTargetAPILock | - eFlagProcessMustBeLaunched | - eFlagProcessMustBePaused ) + eCommandRequiresProcess | + eCommandTryTargetAPILock | + eCommandProcessMustBeLaunched | + eCommandProcessMustBePaused ) { } @@ -1297,7 +1261,7 @@ protected: for (uint32_t i=0; i<argc; ++i) { const char *image_token_cstr = command.GetArgumentAtIndex(i); - uint32_t image_token = Args::StringToUInt32(image_token_cstr, LLDB_INVALID_IMAGE_TOKEN, 0); + uint32_t image_token = StringConvert::ToUInt32(image_token_cstr, LLDB_INVALID_IMAGE_TOKEN, 0); if (image_token == LLDB_INVALID_IMAGE_TOKEN) { result.AppendErrorWithFormat ("invalid image index argument '%s'", image_token_cstr); @@ -1338,7 +1302,7 @@ public: "process signal", "Send a UNIX signal to the current process being debugged.", NULL, - eFlagRequiresProcess | eFlagTryTargetAPILock) + eCommandRequiresProcess | eCommandTryTargetAPILock) { CommandArgumentEntry arg; CommandArgumentData signal_arg; @@ -1371,7 +1335,7 @@ protected: const char *signal_name = command.GetArgumentAtIndex(0); if (::isxdigit (signal_name[0])) - signo = Args::StringToSInt32(signal_name, LLDB_INVALID_SIGNAL_NUMBER, 0); + signo = StringConvert::ToSInt32(signal_name, LLDB_INVALID_SIGNAL_NUMBER, 0); else signo = process->GetUnixSignals().GetSignalNumberFromName (signal_name); @@ -1420,9 +1384,9 @@ public: "process interrupt", "Interrupt the current process being debugged.", "process interrupt", - eFlagRequiresProcess | - eFlagTryTargetAPILock | - eFlagProcessMustBeLaunched) + eCommandRequiresProcess | + eCommandTryTargetAPILock | + eCommandProcessMustBeLaunched) { } @@ -1482,9 +1446,9 @@ public: "process kill", "Terminate the current process being debugged.", "process kill", - eFlagRequiresProcess | - eFlagTryTargetAPILock | - eFlagProcessMustBeLaunched) + eCommandRequiresProcess | + eCommandTryTargetAPILock | + eCommandProcessMustBeLaunched) { } @@ -1507,7 +1471,7 @@ protected: if (command.GetArgumentCount() == 0) { - Error error (process->Destroy()); + Error error (process->Destroy(true)); if (error.Success()) { result.SetStatus (eReturnStatusSuccessFinishResult); @@ -1543,9 +1507,9 @@ public: "process save-core", "Save the current process as a core file using an appropriate file type.", "process save-core FILE", - eFlagRequiresProcess | - eFlagTryTargetAPILock | - eFlagProcessMustBeLaunched) + eCommandRequiresProcess | + eCommandTryTargetAPILock | + eCommandProcessMustBeLaunched) { } @@ -1607,7 +1571,7 @@ public: "process status", "Show the current status and location of executing process.", "process status", - eFlagRequiresProcess | eFlagTryTargetAPILock) + eCommandRequiresProcess | eCommandTryTargetAPILock) { } @@ -1621,7 +1585,7 @@ public: { Stream &strm = result.GetOutputStream(); result.SetStatus (eReturnStatusSuccessFinishNoResult); - // No need to check "process" for validity as eFlagRequiresProcess ensures it is valid + // No need to check "process" for validity as eCommandRequiresProcess ensures it is valid Process *process = m_exe_ctx.GetProcessPtr(); const bool only_threads_with_stop_reason = true; const uint32_t start_frame = 0; @@ -1754,7 +1718,7 @@ public: else { // If the value isn't 'true' or 'false', it had better be 0 or 1. - real_value = Args::StringToUInt32 (option.c_str(), 3); + real_value = StringConvert::ToUInt32 (option.c_str(), 3); if (real_value != 0 && real_value != 1) okay = false; } @@ -1765,8 +1729,8 @@ public: void PrintSignalHeader (Stream &str) { - str.Printf ("NAME PASS STOP NOTIFY\n"); - str.Printf ("========== ===== ===== ======\n"); + str.Printf ("NAME PASS STOP NOTIFY\n"); + str.Printf ("=========== ===== ===== ======\n"); } void @@ -1776,7 +1740,7 @@ public: bool suppress; bool notify; - str.Printf ("%-10s ", sig_name); + str.Printf ("%-11s ", sig_name); if (signals.GetSignalInfo (signo, suppress, stop, notify)) { bool pass = !suppress; diff --git a/contrib/llvm/tools/lldb/source/Commands/CommandObjectQuit.cpp b/contrib/llvm/tools/lldb/source/Commands/CommandObjectQuit.cpp index dd0efc6..31f82b9 100644 --- a/contrib/llvm/tools/lldb/source/Commands/CommandObjectQuit.cpp +++ b/contrib/llvm/tools/lldb/source/Commands/CommandObjectQuit.cpp @@ -7,8 +7,6 @@ // //===----------------------------------------------------------------------===// -#include "lldb/lldb-python.h" - #include "CommandObjectQuit.h" // C Includes @@ -17,6 +15,7 @@ // Project includes #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" +#include "lldb/Target/Process.h" using namespace lldb; using namespace lldb_private; diff --git a/contrib/llvm/tools/lldb/source/Commands/CommandObjectRegister.cpp b/contrib/llvm/tools/lldb/source/Commands/CommandObjectRegister.cpp index 81b79b8..fae5af4 100644 --- a/contrib/llvm/tools/lldb/source/Commands/CommandObjectRegister.cpp +++ b/contrib/llvm/tools/lldb/source/Commands/CommandObjectRegister.cpp @@ -7,8 +7,6 @@ // //===----------------------------------------------------------------------===// -#include "lldb/lldb-python.h" - #include "CommandObjectRegister.h" // C Includes @@ -25,6 +23,7 @@ #include "lldb/Interpreter/Options.h" #include "lldb/Interpreter/OptionGroupFormat.h" #include "lldb/Interpreter/OptionValueArray.h" +#include "lldb/Interpreter/OptionValueBoolean.h" #include "lldb/Interpreter/OptionValueUInt64.h" #include "lldb/Target/ExecutionContext.h" #include "lldb/Target/Process.h" @@ -47,10 +46,10 @@ public: "register read", "Dump the contents of one or more register values from the current frame. If no register is specified, dumps them all.", NULL, - eFlagRequiresFrame | - eFlagRequiresRegContext | - eFlagProcessMustBeLaunched | - eFlagProcessMustBePaused ), + eCommandRequiresFrame | + eCommandRequiresRegContext | + eCommandProcessMustBeLaunched | + eCommandProcessMustBePaused ), m_option_group (interpreter), m_format_options (eFormatDefault), m_command_options () @@ -143,7 +142,7 @@ public: const RegisterSet * const reg_set = reg_ctx->GetRegisterSet(set_idx); if (reg_set) { - strm.Printf ("%s:\n", reg_set->name); + strm.Printf ("%s:\n", (reg_set->name ? reg_set->name : "unknown") ); strm.IndentMore (); const size_t num_registers = reg_set->num_registers; for (size_t reg_idx = 0; reg_idx < num_registers; ++reg_idx) @@ -376,10 +375,10 @@ public: "register write", "Modify a single register value.", NULL, - eFlagRequiresFrame | - eFlagRequiresRegContext | - eFlagProcessMustBeLaunched | - eFlagProcessMustBePaused) + eCommandRequiresFrame | + eCommandRequiresRegContext | + eCommandProcessMustBeLaunched | + eCommandProcessMustBePaused) { CommandArgumentEntry arg1; CommandArgumentEntry arg2; diff --git a/contrib/llvm/tools/lldb/source/Commands/CommandObjectSettings.cpp b/contrib/llvm/tools/lldb/source/Commands/CommandObjectSettings.cpp index ed677af..ccbf98c 100644 --- a/contrib/llvm/tools/lldb/source/Commands/CommandObjectSettings.cpp +++ b/contrib/llvm/tools/lldb/source/Commands/CommandObjectSettings.cpp @@ -7,8 +7,6 @@ // //===----------------------------------------------------------------------===// -#include "lldb/lldb-python.h" - #include "CommandObjectSettings.h" // C Includes @@ -18,6 +16,7 @@ #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" #include "lldb/Interpreter/CommandCompletions.h" +#include "lldb/Interpreter/OptionValueProperties.h" using namespace lldb; using namespace lldb_private; @@ -243,7 +242,7 @@ protected: // Split the raw command into var_name and value pair. llvm::StringRef raw_str(command); std::string var_value_string = raw_str.split(var_name).second.str(); - const char *var_value_cstr = Args::StripSpaces(var_value_string, true, true, false); + const char *var_value_cstr = Args::StripSpaces(var_value_string, true, false, false); Error error; if (m_options.m_global) diff --git a/contrib/llvm/tools/lldb/source/Commands/CommandObjectSource.cpp b/contrib/llvm/tools/lldb/source/Commands/CommandObjectSource.cpp index 8fb03e6..7c5f127 100644 --- a/contrib/llvm/tools/lldb/source/Commands/CommandObjectSource.cpp +++ b/contrib/llvm/tools/lldb/source/Commands/CommandObjectSource.cpp @@ -7,15 +7,12 @@ // //===----------------------------------------------------------------------===// -#include "lldb/lldb-python.h" - #include "CommandObjectSource.h" // C Includes // C++ Includes // Other libraries and framework includes // Project includes -#include "lldb/Interpreter/Args.h" #include "lldb/Core/Debugger.h" #include "lldb/Core/FileLineResolver.h" #include "lldb/Core/Module.h" @@ -24,6 +21,7 @@ #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" #include "lldb/Host/FileSpec.h" +#include "lldb/Host/StringConvert.h" #include "lldb/Symbol/CompileUnit.h" #include "lldb/Symbol/Function.h" #include "lldb/Symbol/Symbol.h" @@ -63,7 +61,7 @@ class CommandObjectSourceInfo : public CommandObjectParsed switch (short_option) { case 'l': - start_line = Args::StringToUInt32 (option_arg, 0); + start_line = StringConvert::ToUInt32 (option_arg, 0); if (start_line == 0) error.SetErrorStringWithFormat("invalid line number: '%s'", option_arg); break; @@ -171,13 +169,13 @@ class CommandObjectSourceList : public CommandObjectParsed switch (short_option) { case 'l': - start_line = Args::StringToUInt32 (option_arg, 0); + start_line = StringConvert::ToUInt32 (option_arg, 0); if (start_line == 0) error.SetErrorStringWithFormat("invalid line number: '%s'", option_arg); break; case 'c': - num_lines = Args::StringToUInt32 (option_arg, 0); + num_lines = StringConvert::ToUInt32 (option_arg, 0); if (num_lines == 0) error.SetErrorStringWithFormat("invalid line count: '%s'", option_arg); break; @@ -253,7 +251,7 @@ public: "source list", "Display source code (as specified) based on the current executable's debug info.", NULL, - eFlagRequiresTarget), + eCommandRequiresTarget), m_options (interpreter) { } @@ -539,9 +537,9 @@ protected: { SymbolContext sc; sc_list_symbols.GetContextAtIndex (i, sc); - if (sc.symbol) + if (sc.symbol && sc.symbol->ValueIsAddress()) { - const Address &base_address = sc.symbol->GetAddress(); + const Address &base_address = sc.symbol->GetAddressRef(); Function *function = base_address.CalculateSymbolContextFunction(); if (function) { @@ -690,13 +688,15 @@ protected: bool show_module = true; bool show_inlined_frames = true; const bool show_function_arguments = true; + const bool show_function_name = true; sc.DumpStopContext(&result.GetOutputStream(), m_exe_ctx.GetBestExecutionContextScope(), sc.line_entry.range.GetBaseAddress(), show_fullpaths, show_module, show_inlined_frames, - show_function_arguments); + show_function_arguments, + show_function_name); result.GetOutputStream().EOL(); if (m_options.num_lines == 0) diff --git a/contrib/llvm/tools/lldb/source/Commands/CommandObjectSyntax.cpp b/contrib/llvm/tools/lldb/source/Commands/CommandObjectSyntax.cpp index 5093c3b..e9fa084 100644 --- a/contrib/llvm/tools/lldb/source/Commands/CommandObjectSyntax.cpp +++ b/contrib/llvm/tools/lldb/source/Commands/CommandObjectSyntax.cpp @@ -7,8 +7,6 @@ // //===----------------------------------------------------------------------===// -#include "lldb/lldb-python.h" - #include "CommandObjectSyntax.h" // C Includes diff --git a/contrib/llvm/tools/lldb/source/Commands/CommandObjectTarget.cpp b/contrib/llvm/tools/lldb/source/Commands/CommandObjectTarget.cpp index 0d9ffda..448da0e 100644 --- a/contrib/llvm/tools/lldb/source/Commands/CommandObjectTarget.cpp +++ b/contrib/llvm/tools/lldb/source/Commands/CommandObjectTarget.cpp @@ -7,8 +7,6 @@ // //===----------------------------------------------------------------------===// -#include "lldb/lldb-python.h" - #include "CommandObjectTarget.h" // C Includes @@ -27,6 +25,7 @@ #include "lldb/Core/Timer.h" #include "lldb/Core/ValueObjectVariable.h" #include "lldb/DataFormatters/ValueObjectPrinter.h" +#include "lldb/Host/StringConvert.h" #include "lldb/Host/Symbols.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" @@ -49,6 +48,7 @@ #include "lldb/Symbol/SymbolVendor.h" #include "lldb/Symbol/UnwindPlan.h" #include "lldb/Symbol/VariableList.h" +#include "lldb/Target/ABI.h" #include "lldb/Target/Process.h" #include "lldb/Target/SectionLoadList.h" #include "lldb/Target/StackFrame.h" @@ -159,7 +159,6 @@ public: NULL), m_option_group (interpreter), m_arch_option (), - m_platform_options(true), // Do include the "--platform" option in the platform settings by passing true m_core_file (LLDB_OPT_SET_1, false, "core", 'c', 0, eArgTypeFilename, "Fullpath to a core file to use for this target."), m_platform_path (LLDB_OPT_SET_1, false, "platform-path", 'P', 0, eArgTypePath, "Path to the remote file to use for this target."), m_symbol_file (LLDB_OPT_SET_1, false, "symfile", 's', 0, eArgTypeFilename, "Fullpath to a stand alone debug symbols file for when debug symbols are not in the executable."), @@ -180,7 +179,6 @@ public: m_arguments.push_back (arg); m_option_group.Append (&m_arch_option, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1); - m_option_group.Append (&m_platform_options, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1); m_option_group.Append (&m_core_file, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1); m_option_group.Append (&m_platform_path, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1); m_option_group.Append (&m_symbol_file, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1); @@ -282,70 +280,83 @@ protected: bool must_set_platform_path = false; Debugger &debugger = m_interpreter.GetDebugger(); - PlatformSP platform_sp(debugger.GetPlatformList().GetSelectedPlatform ()); - if (remote_file) + TargetSP target_sp; + const char *arch_cstr = m_arch_option.GetArchitectureName(); + const bool get_dependent_files = m_add_dependents.GetOptionValue().GetCurrentValue(); + Error error (debugger.GetTargetList().CreateTarget (debugger, + file_path, + arch_cstr, + get_dependent_files, + NULL, + target_sp)); + + if (target_sp) { - // I have a remote file.. two possible cases - if (file_spec && file_spec.Exists()) + // Only get the platform after we create the target because we might have + // switched platforms depending on what the arguments were to CreateTarget() + // we can't rely on the selected platform. + + PlatformSP platform_sp = target_sp->GetPlatform(); + + if (remote_file) { - // if the remote file does not exist, push it there - if (!platform_sp->GetFileExists (remote_file)) + if (platform_sp) { - Error err = platform_sp->PutFile(file_spec, remote_file); - if (err.Fail()) + // I have a remote file.. two possible cases + if (file_spec && file_spec.Exists()) { - result.AppendError(err.AsCString()); - result.SetStatus (eReturnStatusFailed); - return false; + // if the remote file does not exist, push it there + if (!platform_sp->GetFileExists (remote_file)) + { + Error err = platform_sp->PutFile(file_spec, remote_file); + if (err.Fail()) + { + result.AppendError(err.AsCString()); + result.SetStatus (eReturnStatusFailed); + return false; + } + } } - } - } - else - { - // there is no local file and we need one - // in order to make the remote ---> local transfer we need a platform - // TODO: if the user has passed in a --platform argument, use it to fetch the right platform - if (!platform_sp) - { - result.AppendError("unable to perform remote debugging without a platform"); - result.SetStatus (eReturnStatusFailed); - return false; - } - if (file_path) - { - // copy the remote file to the local file - Error err = platform_sp->GetFile(remote_file, file_spec); - if (err.Fail()) + else { - result.AppendError(err.AsCString()); - result.SetStatus (eReturnStatusFailed); - return false; + // there is no local file and we need one + // in order to make the remote ---> local transfer we need a platform + // TODO: if the user has passed in a --platform argument, use it to fetch the right platform + if (!platform_sp) + { + result.AppendError("unable to perform remote debugging without a platform"); + result.SetStatus (eReturnStatusFailed); + return false; + } + if (file_path) + { + // copy the remote file to the local file + Error err = platform_sp->GetFile(remote_file, file_spec); + if (err.Fail()) + { + result.AppendError(err.AsCString()); + result.SetStatus (eReturnStatusFailed); + return false; + } + } + else + { + // make up a local file + result.AppendError("remote --> local transfer without local path is not implemented yet"); + result.SetStatus (eReturnStatusFailed); + return false; + } } } else { - // make up a local file - result.AppendError("remote --> local transfer without local path is not implemented yet"); + result.AppendError("no platform found for target"); result.SetStatus (eReturnStatusFailed); return false; } } - } - - TargetSP target_sp; - const char *arch_cstr = m_arch_option.GetArchitectureName(); - const bool get_dependent_files = m_add_dependents.GetOptionValue().GetCurrentValue(); - Error error (debugger.GetTargetList().CreateTarget (debugger, -// remote_file ? remote_file : file_spec, - file_path, - arch_cstr, - get_dependent_files, - &m_platform_options, - target_sp)); - if (target_sp) - { if (symfile || remote_file) { ModuleSP module_sp (target_sp->GetExecutableModule()); @@ -376,6 +387,12 @@ protected: core_file.GetPath(core_path, sizeof(core_path)); if (core_file.Exists()) { + if (!core_file.Readable()) + { + result.AppendMessageWithFormat ("Core file '%s' is not readable.\n", core_path); + result.SetStatus (eReturnStatusFailed); + return false; + } FileSpec core_file_dir; core_file_dir.GetDirectory() = core_file.GetDirectory(); target_sp->GetExecutableSearchPaths ().Append (core_file_dir); @@ -426,7 +443,7 @@ protected: } else { - result.AppendErrorWithFormat("'%s' takes exactly one executable path argument, or use the --core-file option.\n", m_cmd_name.c_str()); + result.AppendErrorWithFormat("'%s' takes exactly one executable path argument, or use the --core option.\n", m_cmd_name.c_str()); result.SetStatus (eReturnStatusFailed); } return result.Succeeded(); @@ -435,7 +452,6 @@ protected: private: OptionGroupOptions m_option_group; OptionGroupArchitecture m_arch_option; - OptionGroupPlatform m_platform_options; OptionGroupFile m_core_file; OptionGroupFile m_platform_path; OptionGroupFile m_symbol_file; @@ -522,7 +538,7 @@ protected: { bool success = false; const char *target_idx_arg = args.GetArgumentAtIndex(0); - uint32_t target_idx = Args::StringToUInt32 (target_idx_arg, UINT32_MAX, 0, &success); + uint32_t target_idx = StringConvert::ToUInt32 (target_idx_arg, UINT32_MAX, 0, &success); if (success) { TargetList &target_list = m_interpreter.GetDebugger().GetTargetList(); @@ -589,10 +605,20 @@ public: "Delete one or more targets by target index.", NULL, 0), - m_option_group (interpreter), - m_cleanup_option (LLDB_OPT_SET_1, false, "clean", 'c', "Perform extra cleanup to minimize memory consumption after deleting the target.", false, false) - { - m_option_group.Append (&m_cleanup_option, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1); + m_option_group(interpreter), + m_all_option(LLDB_OPT_SET_1, false, "all", 'a', "Delete all targets.", false, true), + m_cleanup_option( + LLDB_OPT_SET_1, + false, + "clean", 'c', + "Perform extra cleanup to minimize memory consumption after deleting the target. " + "By default, LLDB will keep in memory any modules previously loaded by the target as well " + "as all of its debug info. Specifying --clean will unload all of these shared modules and " + "cause them to be reparsed again the next time the target is run", + false, true) + { + m_option_group.Append(&m_all_option, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1); + m_option_group.Append(&m_cleanup_option, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1); m_option_group.Finalize(); } @@ -614,90 +640,89 @@ protected: const size_t argc = args.GetArgumentCount(); std::vector<TargetSP> delete_target_list; TargetList &target_list = m_interpreter.GetDebugger().GetTargetList(); - bool success = true; TargetSP target_sp; - if (argc > 0) + + if (m_all_option.GetOptionValue()) + { + for (int i = 0; i < target_list.GetNumTargets(); ++i) + delete_target_list.push_back(target_list.GetTargetAtIndex(i)); + } + else if (argc > 0) { const uint32_t num_targets = target_list.GetNumTargets(); // Bail out if don't have any targets. if (num_targets == 0) { result.AppendError("no targets to delete"); result.SetStatus(eReturnStatusFailed); - success = false; + return false; } - for (uint32_t arg_idx = 0; success && arg_idx < argc; ++arg_idx) + for (uint32_t arg_idx = 0; arg_idx < argc; ++arg_idx) { const char *target_idx_arg = args.GetArgumentAtIndex(arg_idx); - uint32_t target_idx = Args::StringToUInt32 (target_idx_arg, UINT32_MAX, 0, &success); - if (success) + bool success = false; + uint32_t target_idx = StringConvert::ToUInt32 (target_idx_arg, UINT32_MAX, 0, &success); + if (!success) { - if (target_idx < num_targets) - { - target_sp = target_list.GetTargetAtIndex (target_idx); - if (target_sp) - { - delete_target_list.push_back (target_sp); - continue; - } - } - if (num_targets > 1) - result.AppendErrorWithFormat ("target index %u is out of range, valid target indexes are 0 - %u\n", - target_idx, - num_targets - 1); - else - result.AppendErrorWithFormat("target index %u is out of range, the only valid index is 0\n", - target_idx); - + result.AppendErrorWithFormat("invalid target index '%s'\n", target_idx_arg); result.SetStatus (eReturnStatusFailed); - success = false; + return false; } - else + if (target_idx < num_targets) { - result.AppendErrorWithFormat("invalid target index '%s'\n", target_idx_arg); - result.SetStatus (eReturnStatusFailed); - success = false; + target_sp = target_list.GetTargetAtIndex (target_idx); + if (target_sp) + { + delete_target_list.push_back (target_sp); + continue; + } } + if (num_targets > 1) + result.AppendErrorWithFormat ("target index %u is out of range, valid target indexes are 0 - %u\n", + target_idx, + num_targets - 1); + else + result.AppendErrorWithFormat("target index %u is out of range, the only valid index is 0\n", + target_idx); + + result.SetStatus (eReturnStatusFailed); + return false; } } else { target_sp = target_list.GetSelectedTarget(); - if (target_sp) - { - delete_target_list.push_back (target_sp); - } - else + if (!target_sp) { result.AppendErrorWithFormat("no target is currently selected\n"); result.SetStatus (eReturnStatusFailed); - success = false; + return false; } + delete_target_list.push_back (target_sp); } - if (success) + + const size_t num_targets_to_delete = delete_target_list.size(); + for (size_t idx = 0; idx < num_targets_to_delete; ++idx) { - const size_t num_targets_to_delete = delete_target_list.size(); - for (size_t idx = 0; idx < num_targets_to_delete; ++idx) - { - target_sp = delete_target_list[idx]; - target_list.DeleteTarget(target_sp); - target_sp->Destroy(); - } - // If "--clean" was specified, prune any orphaned shared modules from - // the global shared module list - if (m_cleanup_option.GetOptionValue ()) - { - const bool mandatory = true; - ModuleList::RemoveOrphanSharedModules(mandatory); - } - result.GetOutputStream().Printf("%u targets deleted.\n", (uint32_t)num_targets_to_delete); - result.SetStatus(eReturnStatusSuccessFinishResult); + target_sp = delete_target_list[idx]; + target_list.DeleteTarget(target_sp); + target_sp->Destroy(); + } + // If "--clean" was specified, prune any orphaned shared modules from + // the global shared module list + if (m_cleanup_option.GetOptionValue ()) + { + const bool mandatory = true; + ModuleList::RemoveOrphanSharedModules(mandatory); } + result.GetOutputStream().Printf("%u targets deleted.\n", (uint32_t)num_targets_to_delete); + result.SetStatus(eReturnStatusSuccessFinishResult); - return result.Succeeded(); + return true; } OptionGroupOptions m_option_group; + OptionGroupBoolean m_all_option; OptionGroupBoolean m_cleanup_option; }; @@ -719,7 +744,7 @@ public: "target variable", "Read global variable(s) prior to, or while running your binary.", NULL, - eFlagRequiresTarget), + eCommandRequiresTarget), m_option_group (interpreter), m_option_variable (false), // Don't include frame options m_option_format (eFormatDefault), @@ -762,6 +787,10 @@ public: { DumpValueObjectOptions options(m_varobj_options.GetAsDumpOptions()); + if (false == valobj_sp->GetTargetSP()->GetDisplayRuntimeSupportValues() && + true == valobj_sp->IsRuntimeSupportValue()) + return; + switch (var_sp->GetScope()) { case eValueTypeVariableGlobal: @@ -1260,7 +1289,7 @@ protected: { bool success = false; - uint32_t insert_idx = Args::StringToUInt32(command.GetArgumentAtIndex(0), UINT32_MAX, 0, &success); + uint32_t insert_idx = StringConvert::ToUInt32(command.GetArgumentAtIndex(0), UINT32_MAX, 0, &success); if (!success) { @@ -1711,17 +1740,16 @@ LookupSymbolInModule (CommandInterpreter &interpreter, Stream &strm, Module *mod DumpFullpath (strm, &module->GetFileSpec(), 0); strm.PutCString(":\n"); strm.IndentMore (); - //Symtab::DumpSymbolHeader (&strm); for (i=0; i < num_matches; ++i) { Symbol *symbol = symtab->SymbolAtIndex(match_indexes[i]); - DumpAddress (interpreter.GetExecutionContext().GetBestExecutionContextScope(), - symbol->GetAddress(), - verbose, - strm); - -// strm.Indent (); -// symbol->Dump (&strm, interpreter.GetExecutionContext().GetTargetPtr(), i); + if (symbol && symbol->ValueIsAddress()) + { + DumpAddress (interpreter.GetExecutionContext().GetBestExecutionContextScope(), + symbol->GetAddressRef(), + verbose, + strm); + } } strm.IndentLess (); return num_matches; @@ -2536,7 +2564,7 @@ public: "target modules dump line-table", "Dump the line table for one or more compilation units.", NULL, - eFlagRequiresTarget) + eCommandRequiresTarget) { } @@ -2963,7 +2991,7 @@ protected: { ConstString const_sect_name(sect_name); bool success = false; - addr_t load_addr = Args::StringToUInt64(load_addr_cstr, LLDB_INVALID_ADDRESS, 0, &success); + addr_t load_addr = StringConvert::ToUInt64(load_addr_cstr, LLDB_INVALID_ADDRESS, 0, &success); if (success) { SectionSP section_sp (section_list->FindSectionByName(const_sect_name)); @@ -3451,28 +3479,24 @@ protected: case 's': case 'S': { - SymbolVendor *symbol_vendor = module->GetSymbolVendor(); + const SymbolVendor *symbol_vendor = module->GetSymbolVendor(); if (symbol_vendor) { - SymbolFile *symbol_file = symbol_vendor->GetSymbolFile(); - if (symbol_file) + const FileSpec symfile_spec = symbol_vendor->GetMainFileSpec(); + if (format_char == 'S') { - if (format_char == 'S') + // Dump symbol file only if different from module file + if (!symfile_spec || symfile_spec == module->GetFileSpec()) { - FileSpec &symfile_spec = symbol_file->GetObjectFile()->GetFileSpec(); - // Dump symbol file only if different from module file - if (!symfile_spec || symfile_spec == module->GetFileSpec()) - { - print_space = false; - break; - } - // Add a newline and indent past the index - strm.Printf ("\n%*s", indent, ""); + print_space = false; + break; } - DumpFullpath (strm, &symbol_file->GetObjectFile()->GetFileSpec(), width); - dump_object_name = true; - break; + // Add a newline and indent past the index + strm.Printf ("\n%*s", indent, ""); } + DumpFullpath (strm, &symfile_spec, width); + dump_object_name = true; + break; } strm.Printf("%.*s", width, "<NONE>"); } @@ -3630,10 +3654,10 @@ public: "target modules show-unwind", "Show synthesized unwind instructions for a function.", NULL, - eFlagRequiresTarget | - eFlagRequiresProcess | - eFlagProcessMustBeLaunched | - eFlagProcessMustBePaused ), + eCommandRequiresTarget | + eCommandRequiresProcess | + eCommandProcessMustBeLaunched | + eCommandProcessMustBePaused ), m_options (interpreter) { } @@ -3756,7 +3780,7 @@ protected: { result.GetOutputStream().Printf("Synchronous (restricted to call-sites) UnwindPlan is '%s'\n", callsite_unwind_plan->GetSourceName().AsCString()); } - UnwindPlanSP fast_unwind_plan = func_unwinders_sp->GetUnwindPlanFastUnwind(*thread.get()); + UnwindPlanSP fast_unwind_plan = func_unwinders_sp->GetUnwindPlanFastUnwind(*target, *thread.get()); if (fast_unwind_plan.get()) { result.GetOutputStream().Printf("Fast UnwindPlan is '%s'\n", fast_unwind_plan->GetSourceName().AsCString()); @@ -3890,7 +3914,7 @@ public: break; case 'o': - m_offset = Args::StringToUInt64(option_arg, LLDB_INVALID_ADDRESS); + m_offset = StringConvert::ToUInt64(option_arg, LLDB_INVALID_ADDRESS); if (m_offset == LLDB_INVALID_ADDRESS) error.SetErrorStringWithFormat ("invalid offset string '%s'", option_arg); break; @@ -3910,7 +3934,7 @@ public: break; case 'l': - m_line_number = Args::StringToUInt32(option_arg, UINT32_MAX); + m_line_number = StringConvert::ToUInt32(option_arg, UINT32_MAX); if (m_line_number == UINT32_MAX) error.SetErrorStringWithFormat ("invalid line number string '%s'", option_arg); else if (m_line_number == 0) @@ -3990,7 +4014,7 @@ public: "target modules lookup", "Look up information within executable and dependent shared library images.", NULL, - eFlagRequiresTarget), + eCommandRequiresTarget), m_options (interpreter) { CommandArgumentEntry arg; @@ -4078,7 +4102,7 @@ public: if (LookupAddressInModule (m_interpreter, result.GetOutputStream(), module, - eSymbolContextEverything, + eSymbolContextEverything | (m_options.m_verbose ? eSymbolContextVariable : 0), m_options.m_addr, m_options.m_offset, m_options.m_verbose)) @@ -4370,7 +4394,7 @@ public: CommandObjectParsed (interpreter, "target symbols add", "Add a debug symbol file to one of the target's current modules by specifying a path to a debug symbols file, or using the options to specify a module to download symbols for.", - "target symbols add [<symfile>]", eFlagRequiresTarget), + "target symbols add [<symfile>]", eCommandRequiresTarget), m_option_group (interpreter), m_file_option (LLDB_OPT_SET_1, false, "shlib", 's', CommandCompletions::eModuleCompletion, eArgTypeShlibName, "Fullpath or basename for module to find debug symbols for."), m_current_frame_option (LLDB_OPT_SET_2, false, "frame", 'F', "Locate the debug symbols the currently selected frame.", false, true) @@ -4873,7 +4897,7 @@ public: break; case 'e': - m_line_end = Args::StringToUInt32 (option_arg, UINT_MAX, 0, &success); + m_line_end = StringConvert::ToUInt32 (option_arg, UINT_MAX, 0, &success); if (!success) { error.SetErrorStringWithFormat ("invalid end line number: \"%s\"", option_arg); @@ -4883,7 +4907,7 @@ public: break; case 'l': - m_line_start = Args::StringToUInt32 (option_arg, 0, 0, &success); + m_line_start = StringConvert::ToUInt32 (option_arg, 0, 0, &success); if (!success) { error.SetErrorStringWithFormat ("invalid start line number: \"%s\"", option_arg); @@ -4912,7 +4936,7 @@ public: break; case 't' : { - m_thread_id = Args::StringToUInt64(option_arg, LLDB_INVALID_THREAD_ID, 0); + m_thread_id = StringConvert::ToUInt64(option_arg, LLDB_INVALID_THREAD_ID, 0); if (m_thread_id == LLDB_INVALID_THREAD_ID) error.SetErrorStringWithFormat ("invalid thread id string '%s'", option_arg); m_thread_specified = true; @@ -4928,7 +4952,7 @@ public: break; case 'x': { - m_thread_index = Args::StringToUInt32(option_arg, UINT32_MAX, 0); + m_thread_index = StringConvert::ToUInt32(option_arg, UINT32_MAX, 0); if (m_thread_id == UINT32_MAX) error.SetErrorStringWithFormat ("invalid thread index string '%s'", option_arg); m_thread_specified = true; @@ -5233,7 +5257,7 @@ protected: bool success; for (size_t i = 0; i < num_args; i++) { - lldb::user_id_t user_id = Args::StringToUInt32 (command.GetArgumentAtIndex(i), 0, 0, &success); + lldb::user_id_t user_id = StringConvert::ToUInt32 (command.GetArgumentAtIndex(i), 0, 0, &success); if (!success) { result.AppendErrorWithFormat ("invalid stop hook id: \"%s\".\n", command.GetArgumentAtIndex(i)); @@ -5302,7 +5326,7 @@ protected: { for (size_t i = 0; i < num_args; i++) { - lldb::user_id_t user_id = Args::StringToUInt32 (command.GetArgumentAtIndex(i), 0, 0, &success); + lldb::user_id_t user_id = StringConvert::ToUInt32 (command.GetArgumentAtIndex(i), 0, 0, &success); if (!success) { result.AppendErrorWithFormat ("invalid stop hook id: \"%s\".\n", command.GetArgumentAtIndex(i)); diff --git a/contrib/llvm/tools/lldb/source/Commands/CommandObjectThread.cpp b/contrib/llvm/tools/lldb/source/Commands/CommandObjectThread.cpp index bace4e5..5f38ad4 100644 --- a/contrib/llvm/tools/lldb/source/Commands/CommandObjectThread.cpp +++ b/contrib/llvm/tools/lldb/source/Commands/CommandObjectThread.cpp @@ -7,8 +7,6 @@ // //===----------------------------------------------------------------------===// -#include "lldb/lldb-python.h" - #include "CommandObjectThread.h" // C Includes @@ -18,7 +16,9 @@ #include "lldb/lldb-private.h" #include "lldb/Core/State.h" #include "lldb/Core/SourceManager.h" +#include "lldb/Core/ValueObject.h" #include "lldb/Host/Host.h" +#include "lldb/Host/StringConvert.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" #include "lldb/Interpreter/Options.h" @@ -95,7 +95,7 @@ public: { bool success; - uint32_t thread_idx = Args::StringToUInt32(command.GetArgumentAtIndex(i), 0, 0, &success); + uint32_t thread_idx = StringConvert::ToUInt32(command.GetArgumentAtIndex(i), 0, 0, &success); if (!success) { result.AppendErrorWithFormat ("invalid thread specification: \"%s\"\n", command.GetArgumentAtIndex(i)); @@ -178,7 +178,7 @@ public: case 'c': { bool success; - int32_t input_count = Args::StringToSInt32 (option_arg, -1, 0, &success); + int32_t input_count = StringConvert::ToSInt32 (option_arg, -1, 0, &success); if (!success) error.SetErrorStringWithFormat("invalid integer value for option '%c'", short_option); if (input_count < -1) @@ -190,7 +190,7 @@ public: case 's': { bool success; - m_start = Args::StringToUInt32 (option_arg, 0, 0, &success); + m_start = StringConvert::ToUInt32 (option_arg, 0, 0, &success); if (!success) error.SetErrorStringWithFormat("invalid integer value for option '%c'", short_option); } @@ -239,11 +239,11 @@ public: "thread backtrace", "Show the stack for one or more threads. If no threads are specified, show the currently selected thread. Use the thread-index \"all\" to see all threads.", NULL, - eFlagRequiresProcess | - eFlagRequiresThread | - eFlagTryTargetAPILock | - eFlagProcessMustBeLaunched | - eFlagProcessMustBePaused ), + eCommandRequiresProcess | + eCommandRequiresThread | + eCommandTryTargetAPILock | + eCommandProcessMustBeLaunched | + eCommandProcessMustBePaused ), m_options(interpreter) { } @@ -384,7 +384,7 @@ public: case 'c': { - m_step_count = Args::StringToUInt32(option_arg, UINT32_MAX, 0); + m_step_count = StringConvert::ToUInt32(option_arg, UINT32_MAX, 0); if (m_step_count == UINT32_MAX) error.SetErrorStringWithFormat ("invalid ignore count '%s'", option_arg); break; @@ -431,6 +431,12 @@ public: m_step_in_avoid_no_debug = eLazyBoolCalculate; m_step_out_avoid_no_debug = eLazyBoolCalculate; m_run_mode = eOnlyDuringStepping; + + // Check if we are in Non-Stop mode + lldb::TargetSP target_sp = m_interpreter.GetDebugger().GetSelectedTarget(); + if (target_sp.get() != nullptr && target_sp->GetNonStopModeEnabled()) + m_run_mode = eOnlyThisThread; + m_avoid_regexp.clear(); m_step_in_target.clear(); m_class_name.clear(); @@ -464,11 +470,11 @@ public: StepType step_type, StepScope step_scope) : CommandObjectParsed (interpreter, name, help, syntax, - eFlagRequiresProcess | - eFlagRequiresThread | - eFlagTryTargetAPILock | - eFlagProcessMustBeLaunched | - eFlagProcessMustBePaused ), + eCommandRequiresProcess | + eCommandRequiresThread | + eCommandTryTargetAPILock | + eCommandProcessMustBeLaunched | + eCommandProcessMustBePaused ), m_step_type (step_type), m_step_scope (step_scope), m_options (interpreter) @@ -522,7 +528,7 @@ protected: else { const char *thread_idx_cstr = command.GetArgumentAtIndex(0); - uint32_t step_thread_idx = Args::StringToUInt32 (thread_idx_cstr, LLDB_INVALID_INDEX32); + uint32_t step_thread_idx = StringConvert::ToUInt32 (thread_idx_cstr, LLDB_INVALID_INDEX32); if (step_thread_idx == LLDB_INVALID_INDEX32) { result.AppendErrorWithFormat ("invalid thread index '%s'.\n", thread_idx_cstr); @@ -578,6 +584,7 @@ protected: if (m_step_type == eStepTypeInto) { StackFrame *frame = thread->GetStackFrameAtIndex(0).get(); + assert(frame != nullptr); if (frame->HasDebugInformation ()) { @@ -666,6 +673,8 @@ protected: process->GetThreadList().SetSelectedThreadByID (thread->GetID()); + const uint32_t iohandler_id = process->GetIOHandlerID(); + StreamString stream; Error error; if (synchronous_execution) @@ -676,7 +685,7 @@ protected: // There is a race condition where this thread will return up the call stack to the main command handler // and show an (lldb) prompt before HandlePrivateEvent (from PrivateStateThread) has // a chance to call PushProcessIOHandler(). - process->SyncIOHandler(2000); + process->SyncIOHandler(iohandler_id, 2000); if (synchronous_execution) { @@ -751,10 +760,10 @@ public: "thread continue", "Continue execution of one or more threads in an active process.", NULL, - eFlagRequiresThread | - eFlagTryTargetAPILock | - eFlagProcessMustBeLaunched | - eFlagProcessMustBePaused) + eCommandRequiresThread | + eCommandTryTargetAPILock | + eCommandProcessMustBeLaunched | + eCommandProcessMustBePaused) { CommandArgumentEntry arg; CommandArgumentData thread_idx_arg; @@ -812,7 +821,7 @@ public: { bool success; const int base = 0; - uint32_t thread_idx = Args::StringToUInt32 (command.GetArgumentAtIndex(i), LLDB_INVALID_INDEX32, base, &success); + uint32_t thread_idx = StringConvert::ToUInt32 (command.GetArgumentAtIndex(i), LLDB_INVALID_INDEX32, base, &success); if (success) { Thread *thread = process->GetThreadList().FindThreadByIndexID(thread_idx).get(); @@ -984,9 +993,17 @@ public: switch (short_option) { + case 'a': + { + ExecutionContext exe_ctx (m_interpreter.GetExecutionContext()); + lldb::addr_t tmp_addr = Args::StringToAddress(&exe_ctx, option_arg, LLDB_INVALID_ADDRESS, &error); + if (error.Success()) + m_until_addrs.push_back(tmp_addr); + } + break; case 't': { - m_thread_idx = Args::StringToUInt32 (option_arg, LLDB_INVALID_INDEX32); + m_thread_idx = StringConvert::ToUInt32 (option_arg, LLDB_INVALID_INDEX32); if (m_thread_idx == LLDB_INVALID_INDEX32) { error.SetErrorStringWithFormat ("invalid thread index '%s'", option_arg); @@ -995,7 +1012,7 @@ public: break; case 'f': { - m_frame_idx = Args::StringToUInt32 (option_arg, LLDB_INVALID_FRAME_ID); + m_frame_idx = StringConvert::ToUInt32 (option_arg, LLDB_INVALID_FRAME_ID); if (m_frame_idx == LLDB_INVALID_FRAME_ID) { error.SetErrorStringWithFormat ("invalid frame index '%s'", option_arg); @@ -1030,6 +1047,7 @@ public: m_thread_idx = LLDB_INVALID_THREAD_ID; m_frame_idx = 0; m_stop_others = false; + m_until_addrs.clear(); } const OptionDefinition* @@ -1040,6 +1058,7 @@ public: uint32_t m_step_thread_idx; bool m_stop_others; + std::vector<lldb::addr_t> m_until_addrs; // Options table: Required for subclasses of Options. @@ -1051,12 +1070,12 @@ public: CommandObjectThreadUntil (CommandInterpreter &interpreter) : CommandObjectParsed (interpreter, "thread until", - "Run the current or specified thread until it reaches a given line number or leaves the current function.", + "Run the current or specified thread until it reaches a given line number or address or leaves the current function.", NULL, - eFlagRequiresThread | - eFlagTryTargetAPILock | - eFlagProcessMustBeLaunched | - eFlagProcessMustBePaused ), + eCommandRequiresThread | + eCommandTryTargetAPILock | + eCommandProcessMustBeLaunched | + eCommandProcessMustBePaused ), m_options (interpreter) { CommandArgumentEntry arg; @@ -1110,23 +1129,33 @@ protected: else { Thread *thread = NULL; - uint32_t line_number; + std::vector<uint32_t> line_numbers; - if (command.GetArgumentCount() != 1) + if (command.GetArgumentCount() >= 1) { - result.AppendErrorWithFormat ("No line number provided:\n%s", GetSyntax()); - result.SetStatus (eReturnStatusFailed); - return false; + size_t num_args = command.GetArgumentCount(); + for (size_t i = 0; i < num_args; i++) + { + uint32_t line_number; + line_number = StringConvert::ToUInt32 (command.GetArgumentAtIndex(0), UINT32_MAX); + if (line_number == UINT32_MAX) + { + result.AppendErrorWithFormat ("invalid line number: '%s'.\n", command.GetArgumentAtIndex(0)); + result.SetStatus (eReturnStatusFailed); + return false; + } + else + line_numbers.push_back(line_number); + } } - - line_number = Args::StringToUInt32 (command.GetArgumentAtIndex(0), UINT32_MAX); - if (line_number == UINT32_MAX) + else if (m_options.m_until_addrs.empty()) { - result.AppendErrorWithFormat ("invalid line number: '%s'.\n", command.GetArgumentAtIndex(0)); + result.AppendErrorWithFormat ("No line number or address provided:\n%s", GetSyntax()); result.SetStatus (eReturnStatusFailed); return false; } + if (m_options.m_thread_idx == LLDB_INVALID_THREAD_ID) { thread = process->GetThreadList().GetSelectedThread().get(); @@ -1188,27 +1217,40 @@ protected: Address fun_end_addr(fun_start_addr.GetSection(), fun_start_addr.GetOffset() + fun_addr_range.GetByteSize()); - line_table->FindLineEntryByAddress (fun_end_addr, function_start, &end_ptr); bool all_in_function = true; - - while (index_ptr <= end_ptr) + + line_table->FindLineEntryByAddress (fun_end_addr, function_start, &end_ptr); + + for (uint32_t line_number : line_numbers) { - LineEntry line_entry; - const bool exact = false; - index_ptr = sc.comp_unit->FindLineEntry(index_ptr, line_number, sc.comp_unit, exact, &line_entry); - if (index_ptr == UINT32_MAX) - break; - - addr_t address = line_entry.range.GetBaseAddress().GetLoadAddress(target); - if (address != LLDB_INVALID_ADDRESS) + uint32_t start_idx_ptr = index_ptr; + while (start_idx_ptr <= end_ptr) { - if (fun_addr_range.ContainsLoadAddress (address, target)) - address_list.push_back (address); - else - all_in_function = false; + LineEntry line_entry; + const bool exact = false; + start_idx_ptr = sc.comp_unit->FindLineEntry(start_idx_ptr, line_number, sc.comp_unit, exact, &line_entry); + if (start_idx_ptr == UINT32_MAX) + break; + + addr_t address = line_entry.range.GetBaseAddress().GetLoadAddress(target); + if (address != LLDB_INVALID_ADDRESS) + { + if (fun_addr_range.ContainsLoadAddress (address, target)) + address_list.push_back (address); + else + all_in_function = false; + } + start_idx_ptr++; } - index_ptr++; + } + + for (lldb::addr_t address : m_options.m_until_addrs) + { + if (fun_addr_range.ContainsLoadAddress (address, target)) + address_list.push_back (address); + else + all_in_function = false; } if (address_list.size() == 0) @@ -1290,7 +1332,8 @@ CommandObjectThreadUntil::CommandOptions::g_option_table[] = { { LLDB_OPT_SET_1, false, "frame", 'f', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeFrameIndex, "Frame index for until operation - defaults to 0"}, { LLDB_OPT_SET_1, false, "thread", 't', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeThreadIndex, "Thread index for the thread for until operation"}, -{ LLDB_OPT_SET_1, false, "run-mode",'m', OptionParser::eRequiredArgument, NULL, g_duo_running_mode, 0, eArgTypeRunMode,"Determine how to run other threads while stepping this one"}, +{ LLDB_OPT_SET_1, false, "run-mode",'m', OptionParser::eRequiredArgument, NULL, g_duo_running_mode, 0, eArgTypeRunMode, "Determine how to run other threads while stepping this one"}, +{ LLDB_OPT_SET_1, false, "address", 'a', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeAddressOrExpression, "Run until we reach the specified address, or leave the function - can be specified multiple times."}, { 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL } }; @@ -1308,10 +1351,10 @@ public: "thread select", "Select a thread as the currently active thread.", NULL, - eFlagRequiresProcess | - eFlagTryTargetAPILock | - eFlagProcessMustBeLaunched | - eFlagProcessMustBePaused ) + eCommandRequiresProcess | + eCommandTryTargetAPILock | + eCommandProcessMustBeLaunched | + eCommandProcessMustBePaused ) { CommandArgumentEntry arg; CommandArgumentData thread_idx_arg; @@ -1351,7 +1394,7 @@ protected: return false; } - uint32_t index_id = Args::StringToUInt32(command.GetArgumentAtIndex(0), 0, 0); + uint32_t index_id = StringConvert::ToUInt32(command.GetArgumentAtIndex(0), 0, 0); Thread *new_thread = process->GetThreadList().FindThreadByIndexID(index_id).get(); if (new_thread == NULL) @@ -1384,10 +1427,10 @@ public: "thread list", "Show a summary of all current threads in a process.", "thread list", - eFlagRequiresProcess | - eFlagTryTargetAPILock | - eFlagProcessMustBeLaunched | - eFlagProcessMustBePaused ) + eCommandRequiresProcess | + eCommandTryTargetAPILock | + eCommandProcessMustBeLaunched | + eCommandProcessMustBePaused ) { } @@ -1429,10 +1472,10 @@ public: "thread info", "Show an extended summary of information about thread(s) in a process.", "thread info", - eFlagRequiresProcess | - eFlagTryTargetAPILock | - eFlagProcessMustBeLaunched | - eFlagProcessMustBePaused), + eCommandRequiresProcess | + eCommandTryTargetAPILock | + eCommandProcessMustBeLaunched | + eCommandProcessMustBePaused), m_options (interpreter) { m_add_return = false; @@ -1621,10 +1664,10 @@ public: "Return from the currently selected frame, short-circuiting execution of the frames below it, with an optional return value," " or with the -x option from the innermost function evaluation.", "thread return", - eFlagRequiresFrame | - eFlagTryTargetAPILock | - eFlagProcessMustBeLaunched | - eFlagProcessMustBePaused ), + eCommandRequiresFrame | + eCommandTryTargetAPILock | + eCommandProcessMustBeLaunched | + eCommandProcessMustBePaused ), m_options (interpreter) { CommandArgumentEntry arg; @@ -1796,12 +1839,12 @@ public: return Error("only one source file expected."); break; case 'l': - m_line_num = Args::StringToUInt32 (option_arg, 0, 0, &success); + m_line_num = StringConvert::ToUInt32 (option_arg, 0, 0, &success); if (!success || m_line_num == 0) return Error("invalid line number: '%s'.", option_arg); break; case 'b': - m_line_offset = Args::StringToSInt32 (option_arg, 0, 0, &success); + m_line_offset = StringConvert::ToSInt32 (option_arg, 0, 0, &success); if (!success) return Error("invalid line offset: '%s'.", option_arg); break; @@ -1849,10 +1892,10 @@ public: "thread jump", "Sets the program counter to a new address.", "thread jump", - eFlagRequiresFrame | - eFlagTryTargetAPILock | - eFlagProcessMustBeLaunched | - eFlagProcessMustBePaused ), + eCommandRequiresFrame | + eCommandTryTargetAPILock | + eCommandProcessMustBeLaunched | + eCommandProcessMustBePaused ), m_options (interpreter) { } @@ -2033,11 +2076,11 @@ public: "Show thread plans for one or more threads. If no threads are specified, show the " "currently selected thread. Use the thread-index \"all\" to see all threads.", NULL, - eFlagRequiresProcess | - eFlagRequiresThread | - eFlagTryTargetAPILock | - eFlagProcessMustBeLaunched | - eFlagProcessMustBePaused ), + eCommandRequiresProcess | + eCommandRequiresThread | + eCommandTryTargetAPILock | + eCommandProcessMustBeLaunched | + eCommandProcessMustBePaused ), m_options(interpreter) { } @@ -2085,11 +2128,11 @@ public: "Only user visible plans can be discarded, use the index from \"thread plan list\"" " without the \"-i\" argument.", NULL, - eFlagRequiresProcess | - eFlagRequiresThread | - eFlagTryTargetAPILock | - eFlagProcessMustBeLaunched | - eFlagProcessMustBePaused ) + eCommandRequiresProcess | + eCommandRequiresThread | + eCommandTryTargetAPILock | + eCommandProcessMustBeLaunched | + eCommandProcessMustBePaused ) { CommandArgumentEntry arg; CommandArgumentData plan_index_arg; @@ -2120,7 +2163,7 @@ public: } bool success; - uint32_t thread_plan_idx = Args::StringToUInt32(args.GetArgumentAtIndex(0), 0, 0, &success); + uint32_t thread_plan_idx = StringConvert::ToUInt32(args.GetArgumentAtIndex(0), 0, 0, &success); if (!success) { result.AppendErrorWithFormat("Invalid thread index: \"%s\" - should be unsigned int.", diff --git a/contrib/llvm/tools/lldb/source/Commands/CommandObjectType.cpp b/contrib/llvm/tools/lldb/source/Commands/CommandObjectType.cpp index 3a4c60c..7c8061a 100644 --- a/contrib/llvm/tools/lldb/source/Commands/CommandObjectType.cpp +++ b/contrib/llvm/tools/lldb/source/Commands/CommandObjectType.cpp @@ -7,8 +7,6 @@ // //===----------------------------------------------------------------------===// -#include "lldb/lldb-python.h" - #include "CommandObjectType.h" // C Includes @@ -4249,7 +4247,7 @@ public: nullptr, nullptr, nullptr, - eFlagRequiresFrame), + eCommandRequiresFrame), m_formatter_name(formatter_name ? formatter_name : ""), m_discovery_function(discovery_func) { diff --git a/contrib/llvm/tools/lldb/source/Commands/CommandObjectVersion.cpp b/contrib/llvm/tools/lldb/source/Commands/CommandObjectVersion.cpp index 2d950a8..70e101c 100644 --- a/contrib/llvm/tools/lldb/source/Commands/CommandObjectVersion.cpp +++ b/contrib/llvm/tools/lldb/source/Commands/CommandObjectVersion.cpp @@ -7,8 +7,6 @@ // //===----------------------------------------------------------------------===// -#include "lldb/lldb-python.h" - #include "CommandObjectVersion.h" // C Includes diff --git a/contrib/llvm/tools/lldb/source/Commands/CommandObjectWatchpoint.cpp b/contrib/llvm/tools/lldb/source/Commands/CommandObjectWatchpoint.cpp index ca5fe98..650fd25 100644 --- a/contrib/llvm/tools/lldb/source/Commands/CommandObjectWatchpoint.cpp +++ b/contrib/llvm/tools/lldb/source/Commands/CommandObjectWatchpoint.cpp @@ -7,8 +7,6 @@ // //===----------------------------------------------------------------------===// -#include "lldb/lldb-python.h" - #include "CommandObjectWatchpoint.h" #include "CommandObjectWatchpointCommand.h" @@ -21,11 +19,13 @@ #include "lldb/Core/StreamString.h" #include "lldb/Core/ValueObject.h" #include "lldb/Core/ValueObjectVariable.h" +#include "lldb/Host/StringConvert.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" #include "lldb/Interpreter/CommandCompletions.h" #include "lldb/Symbol/Variable.h" #include "lldb/Symbol/VariableList.h" +#include "lldb/Target/StackFrame.h" #include "lldb/Target/Target.h" #include "llvm/ADT/StringRef.h" @@ -639,7 +639,7 @@ public: { case 'i': { - m_ignore_count = Args::StringToUInt32(option_arg, UINT32_MAX, 0); + m_ignore_count = StringConvert::ToUInt32(option_arg, UINT32_MAX, 0); if (m_ignore_count == UINT32_MAX) error.SetErrorStringWithFormat ("invalid ignore count '%s'", option_arg); } @@ -923,10 +923,10 @@ public: "If watchpoint setting fails, consider disable/delete existing ones " "to free up resources.", NULL, - eFlagRequiresFrame | - eFlagTryTargetAPILock | - eFlagProcessMustBeLaunched | - eFlagProcessMustBePaused ), + eCommandRequiresFrame | + eCommandTryTargetAPILock | + eCommandProcessMustBeLaunched | + eCommandProcessMustBePaused ), m_option_group (interpreter), m_option_watchpoint () { @@ -1130,10 +1130,10 @@ public: "If watchpoint setting fails, consider disable/delete existing ones " "to free up resources.", NULL, - eFlagRequiresFrame | - eFlagTryTargetAPILock | - eFlagProcessMustBeLaunched | - eFlagProcessMustBePaused ), + eCommandRequiresFrame | + eCommandTryTargetAPILock | + eCommandProcessMustBeLaunched | + eCommandProcessMustBePaused ), m_option_group (interpreter), m_option_watchpoint () { @@ -1210,7 +1210,7 @@ protected: if (end_options) { - Args args (raw_command, end_options - raw_command); + Args args (llvm::StringRef(raw_command, end_options - raw_command)); if (!ParseOptions (args, result)) return false; diff --git a/contrib/llvm/tools/lldb/source/Commands/CommandObjectWatchpointCommand.cpp b/contrib/llvm/tools/lldb/source/Commands/CommandObjectWatchpointCommand.cpp index 275ee92..d7d064e 100644 --- a/contrib/llvm/tools/lldb/source/Commands/CommandObjectWatchpointCommand.cpp +++ b/contrib/llvm/tools/lldb/source/Commands/CommandObjectWatchpointCommand.cpp @@ -7,8 +7,6 @@ // //===----------------------------------------------------------------------===// -#include "lldb/lldb-python.h" - // C Includes // C++ Includes |