diff options
56 files changed, 1156 insertions, 924 deletions
diff --git a/lldb/include/lldb/Interpreter/OptionGroupArchitecture.h b/lldb/include/lldb/Interpreter/OptionGroupArchitecture.h new file mode 100644 index 00000000000..7cd1ca3d710 --- /dev/null +++ b/lldb/include/lldb/Interpreter/OptionGroupArchitecture.h @@ -0,0 +1,73 @@ +//===-- OptionGroupArchitecture.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_OptionGroupArchitecture_h_ +#define liblldb_OptionGroupArchitecture_h_ + +// C Includes +// C++ Includes +// Other libraries and framework includes +// Project includes +#include "lldb/Interpreter/Options.h" +#include "lldb/Core/ArchSpec.h" + +namespace lldb_private { + +//------------------------------------------------------------------------- +// OptionGroupArchitecture +//------------------------------------------------------------------------- + +class OptionGroupArchitecture : public OptionGroup +{ +public: + + OptionGroupArchitecture (); + + virtual + ~OptionGroupArchitecture (); + + + virtual uint32_t + GetNumDefinitions (); + + virtual const OptionDefinition* + GetDefinitions (); + + virtual Error + SetOptionValue (CommandInterpreter &interpreter, + uint32_t option_idx, + const char *option_value); + + virtual void + OptionParsingStarting (CommandInterpreter &interpreter); + + bool + GetArchitecture (Platform *platform, ArchSpec &arch); + + bool + ArchitectureWasSpecified () const + { + return !m_arch_str.empty(); + } + const char * + GetArchitectureName () + { + if (m_arch_str.empty()) + return NULL; + return m_arch_str.c_str(); + } + +protected: + + std::string m_arch_str; // Save the arch triple in case a platform is specified after the architecture +}; + +} // namespace lldb_private + +#endif // liblldb_OptionGroupArchitecture_h_ diff --git a/lldb/include/lldb/Interpreter/OptionGroupPlatform.h b/lldb/include/lldb/Interpreter/OptionGroupPlatform.h new file mode 100644 index 00000000000..08306158e24 --- /dev/null +++ b/lldb/include/lldb/Interpreter/OptionGroupPlatform.h @@ -0,0 +1,89 @@ +//===-- OptionGroupPlatform.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_OptionGroupPlatform_h_ +#define liblldb_OptionGroupPlatform_h_ + +// C Includes +// C++ Includes +// Other libraries and framework includes +// Project includes +#include "lldb/Interpreter/Options.h" + +namespace lldb_private { + +//------------------------------------------------------------------------- +// PlatformOptionGroup +// +// Make platform options available to any commands that need the settings. +//------------------------------------------------------------------------- +class OptionGroupPlatform : public OptionGroup +{ +public: + + OptionGroupPlatform (bool include_platform_option) : + OptionGroup(), + m_platform_name (), + m_os_version_major (UINT32_MAX), + m_os_version_minor (UINT32_MAX), + m_os_version_update (UINT32_MAX), + m_include_platform_option (include_platform_option) + { + } + + virtual + ~OptionGroupPlatform () + { + } + + virtual uint32_t + GetNumDefinitions (); + + virtual const OptionDefinition* + GetDefinitions (); + + virtual Error + SetOptionValue (CommandInterpreter &interpreter, + uint32_t option_idx, + const char *option_value); + + virtual void + OptionParsingStarting (CommandInterpreter &interpreter); + + lldb::PlatformSP + CreatePlatformWithOptions (CommandInterpreter &interpreter, + bool make_selected, + Error& error); + + bool + PlatformWasSpecified () const + { + return !m_platform_name.empty(); + } + + void + SetPlatformName (const char *platform_name) + { + if (platform_name && platform_name[0]) + m_platform_name.assign (platform_name); + else + m_platform_name.clear(); + } + +protected: + std::string m_platform_name; + uint32_t m_os_version_major; + uint32_t m_os_version_minor; + uint32_t m_os_version_update; + bool m_include_platform_option; +}; + +} // namespace lldb_private + +#endif // liblldb_OptionGroupPlatform_h_ diff --git a/lldb/include/lldb/Target/Process.h b/lldb/include/lldb/Target/Process.h index add53cc61e3..ca2cabe6032 100644 --- a/lldb/include/lldb/Target/Process.h +++ b/lldb/include/lldb/Target/Process.h @@ -1896,6 +1896,16 @@ public: static const char * ExecutionResultAsCString (ExecutionResults result); + void + GetStatus (Stream &ostrm); + + size_t + GetThreadStatus (Stream &ostrm, + bool only_threads_with_stop_reason, + uint32_t start_frame, + uint32_t num_frames, + uint32_t num_frames_with_source); + protected: friend class CommandObjectProcessLaunch; friend class ProcessEventData; diff --git a/lldb/include/lldb/Target/StackFrame.h b/lldb/include/lldb/Target/StackFrame.h index af8b317dc6e..b1df63073ae 100644 --- a/lldb/include/lldb/Target/StackFrame.h +++ b/lldb/include/lldb/Target/StackFrame.h @@ -160,6 +160,13 @@ public: lldb::StackFrameSP GetSP (); + bool + GetStatus (Stream &strm, + bool show_frame_info, + bool show_source, + uint32_t source_lines_before, + uint32_t source_lines_after); + protected: friend class StackFrameList; diff --git a/lldb/include/lldb/Target/StackFrameList.h b/lldb/include/lldb/Target/StackFrameList.h index df1512aea2c..90c98d91189 100644 --- a/lldb/include/lldb/Target/StackFrameList.h +++ b/lldb/include/lldb/Target/StackFrameList.h @@ -68,6 +68,15 @@ public: lldb::StackFrameSP GetStackFrameSPForStackFramePtr (StackFrame *stack_frame_ptr); + size_t + GetStatus (Stream &strm, + uint32_t first_frame, + uint32_t num_frames, + bool show_frame_info, + uint32_t num_frames_with_source, + uint32_t source_lines_before, + uint32_t source_lines_after); + protected: friend class Thread; diff --git a/lldb/include/lldb/Target/TargetList.h b/lldb/include/lldb/Target/TargetList.h index 6c21177ab8b..975684e0ea8 100644 --- a/lldb/include/lldb/Target/TargetList.h +++ b/lldb/include/lldb/Target/TargetList.h @@ -182,9 +182,6 @@ public: uint32_t SetSelectedTarget (Target *target); - void - SetSelectedTargetWithIndex (uint32_t idx); - lldb::TargetSP GetSelectedTarget (); diff --git a/lldb/include/lldb/Target/Thread.h b/lldb/include/lldb/Target/Thread.h index 4830f621664..03fb414534d 100644 --- a/lldb/include/lldb/Target/Thread.h +++ b/lldb/include/lldb/Target/Thread.h @@ -703,6 +703,21 @@ public: lldb::StackFrameSP GetStackFrameSPForStackFramePtr (StackFrame *stack_frame_ptr); + + size_t + GetStatus (Stream &strm, + uint32_t start_frame, + uint32_t num_frames, + uint32_t num_frames_with_source); + + size_t + GetStackFrameStatus (Stream& strm, + uint32_t first_frame, + uint32_t num_frames, + bool show_frame_info, + uint32_t num_frames_with_source, + uint32_t source_lines_before, + uint32_t source_lines_after); protected: diff --git a/lldb/lldb.xcodeproj/project.pbxproj b/lldb/lldb.xcodeproj/project.pbxproj index 66a68401082..4b90ecfd653 100644 --- a/lldb/lldb.xcodeproj/project.pbxproj +++ b/lldb/lldb.xcodeproj/project.pbxproj @@ -94,7 +94,6 @@ 2689001613353DDE00698AC0 /* CommandObjectCommands.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C5DBBC611E3FEC60035160F /* CommandObjectCommands.cpp */; }; 2689001713353DDE00698AC0 /* CommandObjectDisassemble.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E3010F1B84700F91463 /* CommandObjectDisassemble.cpp */; }; 2689001813353DDE00698AC0 /* CommandObjectExpression.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E3110F1B84700F91463 /* CommandObjectExpression.cpp */; }; - 2689001913353DDE00698AC0 /* CommandObjectFile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E3210F1B84700F91463 /* CommandObjectFile.cpp */; }; 2689001A13353DDE00698AC0 /* CommandObjectFrame.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2672D8461189055500FF4019 /* CommandObjectFrame.cpp */; }; 2689001B13353DDE00698AC0 /* CommandObjectHelp.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E3310F1B84700F91463 /* CommandObjectHelp.cpp */; }; 2689001C13353DDE00698AC0 /* CommandObjectImage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E3410F1B84700F91463 /* CommandObjectImage.cpp */; }; @@ -380,6 +379,8 @@ 26B42C4D1187ABA50079C8C8 /* LLDB.h in Headers */ = {isa = PBXBuildFile; fileRef = 26B42C4C1187ABA50079C8C8 /* LLDB.h */; settings = {ATTRIBUTES = (Public, ); }; }; 26C72C94124322890068DC16 /* SBStream.h in Headers */ = {isa = PBXBuildFile; fileRef = 26C72C93124322890068DC16 /* SBStream.h */; settings = {ATTRIBUTES = (Public, ); }; }; 26C72C961243229A0068DC16 /* SBStream.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26C72C951243229A0068DC16 /* SBStream.cpp */; }; + 26D5E15F135BAEA2006EA0A7 /* OptionGroupArchitecture.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26D5E15E135BAEA2006EA0A7 /* OptionGroupArchitecture.cpp */; }; + 26D5E163135BB054006EA0A7 /* OptionGroupPlatform.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26D5E162135BB054006EA0A7 /* OptionGroupPlatform.cpp */; }; 26DC6A171337FE8000FF7998 /* liblldb-core.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 2689FFCA13353D7A00698AC0 /* liblldb-core.a */; }; 26DC6A1D1337FECA00FF7998 /* lldb-platform.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26DC6A1C1337FECA00FF7998 /* lldb-platform.cpp */; }; 26DE1E6B11616C2E00A093E2 /* lldb-forward-rtti.h in Headers */ = {isa = PBXBuildFile; fileRef = 26DE1E6911616C2E00A093E2 /* lldb-forward-rtti.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -756,7 +757,6 @@ 26BC7D1410F1B76300F91463 /* CommandObjectBreakpoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectBreakpoint.h; path = source/Commands/CommandObjectBreakpoint.h; sourceTree = "<group>"; }; 26BC7D1710F1B76300F91463 /* CommandObjectDisassemble.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectDisassemble.h; path = source/Commands/CommandObjectDisassemble.h; sourceTree = "<group>"; }; 26BC7D1810F1B76300F91463 /* CommandObjectExpression.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectExpression.h; path = source/Commands/CommandObjectExpression.h; sourceTree = "<group>"; }; - 26BC7D1910F1B76300F91463 /* CommandObjectFile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectFile.h; path = source/Commands/CommandObjectFile.h; sourceTree = "<group>"; }; 26BC7D1A10F1B76300F91463 /* CommandObjectHelp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectHelp.h; path = source/Commands/CommandObjectHelp.h; sourceTree = "<group>"; }; 26BC7D1B10F1B76300F91463 /* CommandObjectImage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectImage.h; path = source/Commands/CommandObjectImage.h; sourceTree = "<group>"; }; 26BC7D1D10F1B76300F91463 /* CommandObjectMemory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectMemory.h; path = source/Commands/CommandObjectMemory.h; sourceTree = "<group>"; }; @@ -861,7 +861,6 @@ 26BC7E2D10F1B84700F91463 /* CommandObjectBreakpoint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectBreakpoint.cpp; path = source/Commands/CommandObjectBreakpoint.cpp; sourceTree = "<group>"; }; 26BC7E3010F1B84700F91463 /* CommandObjectDisassemble.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectDisassemble.cpp; path = source/Commands/CommandObjectDisassemble.cpp; sourceTree = "<group>"; }; 26BC7E3110F1B84700F91463 /* CommandObjectExpression.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectExpression.cpp; path = source/Commands/CommandObjectExpression.cpp; sourceTree = "<group>"; }; - 26BC7E3210F1B84700F91463 /* CommandObjectFile.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectFile.cpp; path = source/Commands/CommandObjectFile.cpp; sourceTree = "<group>"; }; 26BC7E3310F1B84700F91463 /* CommandObjectHelp.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectHelp.cpp; path = source/Commands/CommandObjectHelp.cpp; sourceTree = "<group>"; }; 26BC7E3410F1B84700F91463 /* CommandObjectImage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectImage.cpp; path = source/Commands/CommandObjectImage.cpp; sourceTree = "<group>"; }; 26BC7E3610F1B84700F91463 /* CommandObjectMemory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectMemory.cpp; path = source/Commands/CommandObjectMemory.cpp; sourceTree = "<group>"; }; @@ -980,6 +979,10 @@ 26D0DD5510FE555900271C65 /* BreakpointResolverName.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = BreakpointResolverName.cpp; path = source/Breakpoint/BreakpointResolverName.cpp; sourceTree = "<group>"; }; 26D27C9D11ED3A4E0024D721 /* ELFHeader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ELFHeader.cpp; sourceTree = "<group>"; }; 26D27C9E11ED3A4E0024D721 /* ELFHeader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ELFHeader.h; sourceTree = "<group>"; }; + 26D5E15E135BAEA2006EA0A7 /* OptionGroupArchitecture.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = OptionGroupArchitecture.cpp; path = source/Interpreter/OptionGroupArchitecture.cpp; sourceTree = "<group>"; }; + 26D5E160135BAEB0006EA0A7 /* OptionGroupArchitecture.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = OptionGroupArchitecture.h; path = include/lldb/Interpreter/OptionGroupArchitecture.h; sourceTree = "<group>"; }; + 26D5E161135BB040006EA0A7 /* OptionGroupPlatform.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = OptionGroupPlatform.h; path = include/lldb/Interpreter/OptionGroupPlatform.h; sourceTree = "<group>"; }; + 26D5E162135BB054006EA0A7 /* OptionGroupPlatform.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = OptionGroupPlatform.cpp; path = source/Interpreter/OptionGroupPlatform.cpp; sourceTree = "<group>"; }; 26D9FDC612F784E60003F2EE /* EmulateInstruction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = EmulateInstruction.h; path = include/lldb/Core/EmulateInstruction.h; sourceTree = "<group>"; }; 26D9FDC812F784FD0003F2EE /* EmulateInstruction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = EmulateInstruction.cpp; path = source/Core/EmulateInstruction.cpp; sourceTree = "<group>"; }; 26D9FDCC12F7853F0003F2EE /* EmulateInstructionARM.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = EmulateInstructionARM.cpp; path = Instruction/ARM/EmulateInstructionARM.cpp; sourceTree = "<group>"; }; @@ -2044,8 +2047,6 @@ 26BC7E3010F1B84700F91463 /* CommandObjectDisassemble.cpp */, 26BC7D1810F1B76300F91463 /* CommandObjectExpression.h */, 26BC7E3110F1B84700F91463 /* CommandObjectExpression.cpp */, - 26BC7D1910F1B76300F91463 /* CommandObjectFile.h */, - 26BC7E3210F1B84700F91463 /* CommandObjectFile.cpp */, 2672D8471189055500FF4019 /* CommandObjectFrame.h */, 2672D8461189055500FF4019 /* CommandObjectFrame.cpp */, 26BC7D1A10F1B76300F91463 /* CommandObjectHelp.h */, @@ -2164,6 +2165,10 @@ 26BC7F0A10F1B8DD00F91463 /* CommandReturnObject.cpp */, 26BC7D6D10F1B77400F91463 /* Options.h */, 26BC7E8610F1B85900F91463 /* Options.cpp */, + 26D5E160135BAEB0006EA0A7 /* OptionGroupArchitecture.h */, + 26D5E15E135BAEA2006EA0A7 /* OptionGroupArchitecture.cpp */, + 26D5E161135BB040006EA0A7 /* OptionGroupPlatform.h */, + 26D5E162135BB054006EA0A7 /* OptionGroupPlatform.cpp */, 26BC7DE510F1B7F900F91463 /* ScriptInterpreter.h */, 9A82010B10FFB49800182560 /* ScriptInterpreter.cpp */, 9A2771FB1135A35C00E6ADB6 /* ScriptInterpreterNone.h */, @@ -2870,7 +2875,6 @@ 2689001613353DDE00698AC0 /* CommandObjectCommands.cpp in Sources */, 2689001713353DDE00698AC0 /* CommandObjectDisassemble.cpp in Sources */, 2689001813353DDE00698AC0 /* CommandObjectExpression.cpp in Sources */, - 2689001913353DDE00698AC0 /* CommandObjectFile.cpp in Sources */, 2689001A13353DDE00698AC0 /* CommandObjectFrame.cpp in Sources */, 2689001B13353DDE00698AC0 /* CommandObjectHelp.cpp in Sources */, 2689001C13353DDE00698AC0 /* CommandObjectImage.cpp in Sources */, @@ -3130,6 +3134,8 @@ 2671A0D013482601003A87BB /* ConnectionMachPort.cpp in Sources */, 4CABA9E0134A8BCD00539BDD /* ValueObjectMemory.cpp in Sources */, 4CD0BD0F134BFADF00CB44D4 /* ValueObjectDynamicValue.cpp in Sources */, + 26D5E15F135BAEA2006EA0A7 /* OptionGroupArchitecture.cpp in Sources */, + 26D5E163135BB054006EA0A7 /* OptionGroupPlatform.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/lldb/source/Commands/CommandObjectExpression.cpp b/lldb/source/Commands/CommandObjectExpression.cpp index 82d2197e7cc..ee14839372b 100644 --- a/lldb/source/Commands/CommandObjectExpression.cpp +++ b/lldb/source/Commands/CommandObjectExpression.cpp @@ -13,7 +13,6 @@ // C++ Includes // Other libraries and framework includes // Project includes -#include "CommandObjectThread.h" // For DisplayThreadInfo. #include "lldb/Interpreter/Args.h" #include "lldb/Core/Value.h" #include "lldb/Core/InputReader.h" @@ -32,6 +31,7 @@ #include "lldb/Target/Process.h" #include "lldb/Target/StackFrame.h" #include "lldb/Target/Target.h" +#include "lldb/Target/Thread.h" #include "llvm/ADT/StringRef.h" using namespace lldb; @@ -281,10 +281,25 @@ CommandObjectExpression::EvaluateExpression if (exe_results == eExecutionInterrupted && !m_options.unwind_on_error) { + uint32_t start_frame = 0; + uint32_t num_frames = 1; + uint32_t num_frames_with_source = 0; if (m_exe_ctx.thread) - lldb_private::DisplayThreadInfo (m_interpreter, result->GetOutputStream(), m_exe_ctx.thread, false, true); - else - lldb_private::DisplayThreadsInfo (m_interpreter, &m_exe_ctx, *result, true, true); + { + m_exe_ctx.thread->GetStatus (result->GetOutputStream(), + start_frame, + num_frames, + num_frames_with_source); + } + else if (m_exe_ctx.process) + { + bool only_threads_with_stop_reason = true; + m_exe_ctx.process->GetThreadStatus (result->GetOutputStream(), + only_threads_with_stop_reason, + start_frame, + num_frames, + num_frames_with_source); + } } if (result_valobj_sp) diff --git a/lldb/source/Commands/CommandObjectFile.cpp b/lldb/source/Commands/CommandObjectFile.cpp deleted file mode 100644 index 563cbe298dc..00000000000 --- a/lldb/source/Commands/CommandObjectFile.cpp +++ /dev/null @@ -1,235 +0,0 @@ -//===-- CommandObjectFile.cpp -----------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#include "CommandObjectFile.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/Timer.h" -#include "lldb/Core/Debugger.h" -#include "lldb/Interpreter/CommandInterpreter.h" -#include "lldb/Interpreter/CommandReturnObject.h" -#include "lldb/Interpreter/CommandCompletions.h" -#include "lldb/Target/Process.h" - -using namespace lldb; -using namespace lldb_private; - -FileOptionGroup::FileOptionGroup() : - m_arch_str () -{ -} - -FileOptionGroup::~FileOptionGroup () -{ -} - -OptionDefinition g_file_option_table[] = -{ - { LLDB_OPT_SET_1 , false, "arch" , 'a', required_argument, NULL, 0, eArgTypeArchitecture , "Specify the architecture for the target."}, -}; -const uint32_t k_num_file_options = sizeof(g_file_option_table)/sizeof(OptionDefinition); - -uint32_t -FileOptionGroup::GetNumDefinitions () -{ - return k_num_file_options; -} - -const OptionDefinition * -FileOptionGroup::GetDefinitions () -{ - return g_file_option_table; -} - -bool -FileOptionGroup::GetArchitecture (Platform *platform, ArchSpec &arch) -{ - if (m_arch_str.empty()) - arch.Clear(); - else - arch.SetTriple(m_arch_str.c_str(), platform); - return arch.IsValid(); -} - - -Error -FileOptionGroup::SetOptionValue (CommandInterpreter &interpreter, - uint32_t option_idx, - const char *option_arg) -{ - Error error; - char short_option = (char) g_file_option_table[option_idx].short_option; - - switch (short_option) - { - case 'a': - m_arch_str.assign (option_arg); - break; - - default: - error.SetErrorStringWithFormat ("Unrecognized option '%c'.\n", short_option); - break; - } - - return error; -} - -void -FileOptionGroup::OptionParsingStarting (CommandInterpreter &interpreter) -{ - m_arch_str.clear(); -} - -//------------------------------------------------------------------------- -// CommandObjectFile -//------------------------------------------------------------------------- - -CommandObjectFile::CommandObjectFile(CommandInterpreter &interpreter) : - CommandObject (interpreter, - "file", - "Set the file to be used as the main executable by the debugger.", - NULL), - m_option_group (interpreter), - m_file_options (), - m_platform_options(true) // Do include the "--platform" option in the platform settings by passing true -{ - CommandArgumentEntry arg; - CommandArgumentData file_arg; - - // Define the first (and only) variant of this arg. - file_arg.arg_type = eArgTypeFilename; - file_arg.arg_repetition = eArgRepeatPlain; - - // There is only one variant this argument could be; put it into the argument entry. - arg.push_back (file_arg); - - // Push the data for the first argument into the m_arguments vector. - m_arguments.push_back (arg); - - m_option_group.Append (&m_file_options, 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.Finalize(); -} - -CommandObjectFile::~CommandObjectFile () -{ -} - -Options * -CommandObjectFile::GetOptions () -{ - return &m_option_group; -} - -bool -CommandObjectFile::Execute -( - Args& command, - CommandReturnObject &result -) -{ - const char *file_path = command.GetArgumentAtIndex(0); - Timer scoped_timer(__PRETTY_FUNCTION__, "(lldb) file '%s'", file_path); - const int argc = command.GetArgumentCount(); - if (argc == 1) - { - FileSpec file_spec (file_path, true); - - bool select = true; - PlatformSP platform_sp; - - Error error; - - if (!m_platform_options.platform_name.empty()) - { - platform_sp = m_platform_options.CreatePlatformWithOptions(m_interpreter, select, error); - if (!platform_sp) - { - result.AppendError(error.AsCString()); - result.SetStatus (eReturnStatusFailed); - return false; - } - } - ArchSpec file_arch; - - if (!m_file_options.m_arch_str.empty()) - { - if (!platform_sp) - platform_sp = m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform(); - if (!m_file_options.GetArchitecture(platform_sp.get(), file_arch)) - { - result.AppendErrorWithFormat("invalid architecture '%s'", m_file_options.m_arch_str.c_str()); - result.SetStatus (eReturnStatusFailed); - return false; - } - } - - if (! file_spec.Exists() && !file_spec.ResolveExecutableLocation()) - { - result.AppendErrorWithFormat ("File '%s' does not exist.\n", file_path); - result.SetStatus (eReturnStatusFailed); - return false; - } - - TargetSP target_sp; - Debugger &debugger = m_interpreter.GetDebugger(); - error = debugger.GetTargetList().CreateTarget (debugger, file_spec, file_arch, true, target_sp); - - if (target_sp) - { - debugger.GetTargetList().SetSelectedTarget(target_sp.get()); - result.AppendMessageWithFormat ("Current executable set to '%s' (%s).\n", file_path, target_sp->GetArchitecture().GetArchitectureName()); - result.SetStatus (eReturnStatusSuccessFinishNoResult); - } - else - { - result.AppendError(error.AsCString()); - result.SetStatus (eReturnStatusFailed); - } - } - else - { - result.AppendErrorWithFormat("'%s' takes exactly one executable path argument.\n", m_cmd_name.c_str()); - result.SetStatus (eReturnStatusFailed); - } - return result.Succeeded(); - -} - -int -CommandObjectFile::HandleArgumentCompletion -( - Args &input, - int &cursor_index, - int &cursor_char_position, - OptionElementVector &opt_element_vector, - int match_start_point, - int max_return_elements, - bool &word_complete, - StringList &matches -) -{ - std::string completion_str (input.GetArgumentAtIndex(cursor_index)); - completion_str.erase (cursor_char_position); - - CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter, - CommandCompletions::eDiskFileCompletion, - completion_str.c_str(), - match_start_point, - max_return_elements, - NULL, - word_complete, - matches); - return matches.GetSize(); -} diff --git a/lldb/source/Commands/CommandObjectFile.h b/lldb/source/Commands/CommandObjectFile.h deleted file mode 100644 index f3ef2d94a15..00000000000 --- a/lldb/source/Commands/CommandObjectFile.h +++ /dev/null @@ -1,95 +0,0 @@ -//===-- CommandObjectFile.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_CommandObjectFile_h_ -#define liblldb_CommandObjectFile_h_ - -// C Includes -// C++ Includes -#include <vector> -// Other libraries and framework includes -// Project includes -#include "lldb/Interpreter/Options.h" -#include "lldb/Core/ArchSpec.h" -#include "lldb/Interpreter/CommandObject.h" -#include "CommandObjectPlatform.h" - -namespace lldb_private { - -//------------------------------------------------------------------------- -// CommandObjectFile -//------------------------------------------------------------------------- - -class FileOptionGroup : public OptionGroup -{ -public: - - FileOptionGroup (); - - virtual - ~FileOptionGroup (); - - - virtual uint32_t - GetNumDefinitions (); - - virtual const OptionDefinition* - GetDefinitions (); - - virtual Error - SetOptionValue (CommandInterpreter &interpreter, - uint32_t option_idx, - const char *option_value); - - virtual void - OptionParsingStarting (CommandInterpreter &interpreter); - - bool - GetArchitecture (Platform *platform, ArchSpec &arch); - - std::string m_arch_str; // Save the arch triple in case a platform is specified after the architecture -}; - -class CommandObjectFile : public CommandObject -{ -public: - - CommandObjectFile (CommandInterpreter &interpreter); - - virtual - ~CommandObjectFile (); - - virtual bool - Execute (Args& command, - CommandReturnObject &result); - - virtual Options * - GetOptions (); - - - virtual int - HandleArgumentCompletion (Args &input, - int &cursor_index, - int &cursor_char_position, - OptionElementVector &opt_element_vector, - int match_start_point, - int max_return_elements, - bool &word_complete, - StringList &matches); - - -private: - OptionGroupOptions m_option_group; - FileOptionGroup m_file_options; - PlatformOptionGroup m_platform_options; -}; - -} // namespace lldb_private - -#endif // liblldb_CommandObjectFile_h_ diff --git a/lldb/source/Commands/CommandObjectFrame.cpp b/lldb/source/Commands/CommandObjectFrame.cpp index bdcd7039b99..97dbdf30e17 100644 --- a/lldb/source/Commands/CommandObjectFrame.cpp +++ b/lldb/source/Commands/CommandObjectFrame.cpp @@ -37,8 +37,6 @@ #include "lldb/Target/Thread.h" #include "lldb/Target/Target.h" -#include "CommandObjectThread.h" - using namespace lldb; using namespace lldb_private; @@ -243,14 +241,15 @@ public: already_shown = Host::OpenFileInExternalEditor (frame_sc.line_entry.file, frame_sc.line_entry.line); } - if (DisplayFrameForExecutionContext (exe_ctx.thread, - exe_ctx.frame, - m_interpreter, - result.GetOutputStream(), - true, - !already_shown, - 3, - 3)) + bool show_frame_info = true; + bool show_source = !already_shown; + uint32_t source_lines_before = 3; + uint32_t source_lines_after = 3; + if (exe_ctx.frame->GetStatus(result.GetOutputStream(), + show_frame_info, + show_source, + source_lines_before, + source_lines_after)) { result.SetStatus (eReturnStatusSuccessFinishResult); return result.Succeeded(); diff --git a/lldb/source/Commands/CommandObjectPlatform.cpp b/lldb/source/Commands/CommandObjectPlatform.cpp index 252865162a0..f9462f62421 100644 --- a/lldb/source/Commands/CommandObjectPlatform.cpp +++ b/lldb/source/Commands/CommandObjectPlatform.cpp @@ -19,7 +19,7 @@ #include "lldb/Interpreter/Args.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" -#include "lldb/Interpreter/Options.h" +#include "lldb/Interpreter/OptionGroupPlatform.h" #include "lldb/Target/ExecutionContext.h" #include "lldb/Target/Platform.h" #include "lldb/Target/Process.h" @@ -28,94 +28,8 @@ using namespace lldb; using namespace lldb_private; -PlatformSP -PlatformOptionGroup::CreatePlatformWithOptions (CommandInterpreter &interpreter, bool select, Error& error) -{ - PlatformSP platform_sp; - if (!platform_name.empty()) - { - platform_sp = Platform::Create (platform_name.c_str(), error); - - if (platform_sp) - { - interpreter.GetDebugger().GetPlatformList().Append (platform_sp, select); - if (os_version_major != UINT32_MAX) - { - platform_sp->SetOSVersion (os_version_major, - os_version_minor, - os_version_update); - } - } - } - return platform_sp; -} - -void -PlatformOptionGroup::OptionParsingStarting (CommandInterpreter &interpreter) -{ - platform_name.clear(); - os_version_major = UINT32_MAX; - os_version_minor = UINT32_MAX; - os_version_update = UINT32_MAX; -} - -static OptionDefinition -g_option_table[] = -{ - { LLDB_OPT_SET_ALL, false, "platform" , 'p', required_argument, NULL, 0, eArgTypePlatform, "Specify name of the platform to use for this target, creating the platform if necessary."}, - { LLDB_OPT_SET_ALL, false, "sdk-version", 'v', required_argument, NULL, 0, eArgTypeNone, "Specify the initial SDK version to use prior to connecting." } -}; - -static const uint32_t k_option_table_size = sizeof(g_option_table)/sizeof (OptionDefinition); - -const OptionDefinition* -PlatformOptionGroup::GetDefinitions () -{ - if (m_include_platform_option) - return g_option_table; - return g_option_table + 1; -} - -uint32_t -PlatformOptionGroup::GetNumDefinitions () -{ - if (m_include_platform_option) - return k_option_table_size; - return k_option_table_size - 1; -} - - -Error -PlatformOptionGroup::SetOptionValue (CommandInterpreter &interpreter, - uint32_t option_idx, - const char *option_arg) -{ - Error error; - if (!m_include_platform_option) - --option_idx; - - char short_option = (char) g_option_table[option_idx].short_option; - - switch (short_option) - { - case 'p': - platform_name.assign (option_arg); - break; - - case 'v': - if (Args::StringToVersion (option_arg, os_version_major, os_version_minor, os_version_update) == option_arg) - error.SetErrorStringWithFormat ("invalid version string '%s'", option_arg); - break; - - default: - error.SetErrorStringWithFormat ("Unrecognized option '%c'.\n", short_option); - break; - } - return error; -} - //---------------------------------------------------------------------- -// "platform create <platform-name>" +// "platform select <platform-name>" //---------------------------------------------------------------------- class CommandObjectPlatformSelect : public CommandObject { @@ -147,7 +61,7 @@ public: if (platform_name && platform_name[0]) { const bool select = true; - m_platform_options.platform_name.assign (platform_name); + m_platform_options.SetPlatformName (platform_name); Error error; PlatformSP platform_sp (m_platform_options.CreatePlatformWithOptions (m_interpreter, select, error)); if (platform_sp) @@ -175,6 +89,29 @@ public: return result.Succeeded(); } + + virtual int + HandleCompletion (Args &input, + int &cursor_index, + int &cursor_char_position, + int match_start_point, + int max_return_elements, + bool &word_complete, + StringList &matches) + { + std::string completion_str (input.GetArgumentAtIndex(cursor_index)); + completion_str.erase (cursor_char_position); + + CommandCompletions::PlatformPluginNames (m_interpreter, + completion_str.c_str(), + match_start_point, + max_return_elements, + NULL, + word_complete, + matches); + return matches.GetSize(); + } + virtual Options * GetOptions () { @@ -183,7 +120,7 @@ public: protected: OptionGroupOptions m_option_group; - PlatformOptionGroup m_platform_options; + OptionGroupPlatform m_platform_options; }; //---------------------------------------------------------------------- diff --git a/lldb/source/Commands/CommandObjectPlatform.h b/lldb/source/Commands/CommandObjectPlatform.h index 00199158666..f3bd7584864 100644 --- a/lldb/source/Commands/CommandObjectPlatform.h +++ b/lldb/source/Commands/CommandObjectPlatform.h @@ -35,64 +35,6 @@ public: DISALLOW_COPY_AND_ASSIGN (CommandObjectPlatform); }; - -//------------------------------------------------------------------------- -// PlatformOptionGroup -// -// Make platform options available to to any other command in case they -// need them. The "file" command needs them, and by exposing them we can -// reuse the platform command options for any command, we can keep things -// consistent. -//------------------------------------------------------------------------- -class PlatformOptionGroup : public OptionGroup -{ -public: - - PlatformOptionGroup (bool include_platform_option) : - platform_name (), - os_version_major (UINT32_MAX), - os_version_minor (UINT32_MAX), - os_version_update (UINT32_MAX), - m_include_platform_option (include_platform_option) - { - } - - virtual - ~PlatformOptionGroup () - { - } - - virtual uint32_t - GetNumDefinitions (); - - virtual const OptionDefinition* - GetDefinitions (); - - virtual Error - SetOptionValue (CommandInterpreter &interpreter, - uint32_t option_idx, - const char *option_value); - - lldb::PlatformSP - CreatePlatformWithOptions (CommandInterpreter &interpreter, - bool select, - Error &error); - - virtual void - OptionParsingStarting (CommandInterpreter &interpreter); - - // Instance variables to hold the values for command options. - - std::string platform_name; - uint32_t os_version_major; - uint32_t os_version_minor; - uint32_t os_version_update; -protected: - bool m_include_platform_option; -}; - - - } // namespace lldb_private #endif // liblldb_CommandObjectPlatform_h_ diff --git a/lldb/source/Commands/CommandObjectProcess.cpp b/lldb/source/Commands/CommandObjectProcess.cpp index aed04bd6a81..5446cc66f96 100644 --- a/lldb/source/Commands/CommandObjectProcess.cpp +++ b/lldb/source/Commands/CommandObjectProcess.cpp @@ -16,10 +16,9 @@ #include "lldb/Interpreter/Args.h" #include "lldb/Interpreter/Options.h" #include "lldb/Core/State.h" +#include "lldb/Host/Host.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" -#include "CommandObjectThread.h" -#include "lldb/Host/Host.h" #include "lldb/Target/Platform.h" #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" @@ -1491,52 +1490,26 @@ public: CommandReturnObject &result ) { - Stream &output_stream = result.GetOutputStream(); + Stream &strm = result.GetOutputStream(); result.SetStatus (eReturnStatusSuccessFinishNoResult); ExecutionContext exe_ctx(m_interpreter.GetExecutionContext()); if (exe_ctx.process) { - const StateType state = exe_ctx.process->GetState(); - if (StateIsStoppedState(state)) - { - if (state == eStateExited) - { - int exit_status = exe_ctx.process->GetExitStatus(); - const char *exit_description = exe_ctx.process->GetExitDescription(); - output_stream.Printf ("Process %d exited with status = %i (0x%8.8x) %s\n", - exe_ctx.process->GetID(), - exit_status, - exit_status, - exit_description ? exit_description : ""); - } - else - { - if (state == eStateConnected) - output_stream.Printf ("Connected to remote target.\n"); - else - output_stream.Printf ("Process %d %s\n", exe_ctx.process->GetID(), StateAsCString (state)); - if (exe_ctx.thread == NULL) - exe_ctx.thread = exe_ctx.process->GetThreadList().GetThreadAtIndex(0).get(); - if (exe_ctx.thread != NULL) - { - DisplayThreadsInfo (m_interpreter, &exe_ctx, result, true, true); - } - else - { - result.AppendError ("No valid thread found in current process."); - result.SetStatus (eReturnStatusFailed); - } - } - } - else - { - output_stream.Printf ("Process %d is running.\n", - exe_ctx.process->GetID()); - } + const bool only_threads_with_stop_reason = true; + const uint32_t start_frame = 0; + const uint32_t num_frames = 1; + const uint32_t num_frames_with_source = 1; + exe_ctx.process->GetStatus(strm); + exe_ctx.process->GetThreadStatus (strm, + only_threads_with_stop_reason, + start_frame, + num_frames, + num_frames_with_source); + } else { - result.AppendError ("No current location or status available."); + result.AppendError ("No process."); result.SetStatus (eReturnStatusFailed); } return result.Succeeded(); diff --git a/lldb/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp index 5a90bfb1288..6332976a875 100644 --- a/lldb/source/Commands/CommandObjectTarget.cpp +++ b/lldb/source/Commands/CommandObjectTarget.cpp @@ -18,9 +18,12 @@ #include "lldb/Interpreter/Args.h" #include "lldb/Core/Debugger.h" #include "lldb/Core/InputReader.h" +#include "lldb/Core/State.h" #include "lldb/Core/Timer.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" +#include "lldb/Interpreter/OptionGroupArchitecture.h" +#include "lldb/Interpreter/OptionGroupPlatform.h" #include "lldb/Target/Process.h" #include "lldb/Target/StackFrame.h" #include "lldb/Target/Thread.h" @@ -29,6 +32,360 @@ using namespace lldb; using namespace lldb_private; + + +static void +DumpTargetInfo (uint32_t target_idx, Target *target, const char *prefix_cstr, bool show_stopped_process_status, Stream &strm) +{ + ArchSpec &target_arch = target->GetArchitecture(); + + ModuleSP exe_module_sp (target->GetExecutableModule ()); + char exe_path[PATH_MAX]; + bool exe_valid = false; + if (exe_module_sp) + exe_valid = exe_module_sp->GetFileSpec().GetPath (exe_path, sizeof(exe_path)); + + if (!exe_valid) + ::strcpy (exe_path, "<none>"); + + strm.Printf ("%starget #%u: %s", prefix_cstr ? prefix_cstr : "", target_idx, exe_path); + + uint32_t properties = 0; + if (target_arch.IsValid()) + { + strm.Printf ("%sarch=%s", properties++ > 0 ? ", " : " ( ", target_arch.GetTriple().str().c_str()); + properties++; + } + PlatformSP platform_sp (target->GetPlatform()); + if (platform_sp) + strm.Printf ("%splatform=%s", properties++ > 0 ? ", " : " ( ", platform_sp->GetName()); + + ProcessSP process_sp (target->GetProcessSP()); + bool show_process_status = false; + if (process_sp) + { + lldb::pid_t pid = process_sp->GetID(); + StateType state = process_sp->GetState(); + if (show_stopped_process_status) + show_process_status = StateIsStoppedState(state); + const char *state_cstr = StateAsCString (state); + if (pid != LLDB_INVALID_PROCESS_ID) + strm.Printf ("%spid=%i", properties++ > 0 ? ", " : " ( ", pid); + strm.Printf ("%sstate=%s", properties++ > 0 ? ", " : " ( ", state_cstr); + } + if (properties > 0) + strm.PutCString (" )\n"); + else + strm.EOL(); + if (show_process_status) + { + const bool only_threads_with_stop_reason = true; + const uint32_t start_frame = 0; + const uint32_t num_frames = 1; + const uint32_t num_frames_with_source = 1; + process_sp->GetStatus (strm); + process_sp->GetThreadStatus (strm, + only_threads_with_stop_reason, + start_frame, + num_frames, + num_frames_with_source); + + } +} + +static uint32_t +DumpTargetList (TargetList &target_list, bool show_stopped_process_status, Stream &strm) +{ + const uint32_t num_targets = target_list.GetNumTargets(); + if (num_targets) + { + TargetSP selected_target_sp (target_list.GetSelectedTarget()); + strm.PutCString ("Current targets:\n"); + for (uint32_t i=0; i<num_targets; ++i) + { + TargetSP target_sp (target_list.GetTargetAtIndex (i)); + if (target_sp) + { + bool is_selected = target_sp.get() == selected_target_sp.get(); + DumpTargetInfo (i, + target_sp.get(), + is_selected ? "* " : " ", + show_stopped_process_status, + strm); + } + } + } + return num_targets; +} +#pragma mark CommandObjectTargetCreate + +//------------------------------------------------------------------------- +// "target create" +//------------------------------------------------------------------------- + +class CommandObjectTargetCreate : public CommandObject +{ +public: + CommandObjectTargetCreate(CommandInterpreter &interpreter) : + CommandObject (interpreter, + "target create", + "Create a target using the argument as the main executable.", + NULL), + m_option_group (interpreter), + m_file_options (), + m_platform_options(true) // Do include the "--platform" option in the platform settings by passing true + { + CommandArgumentEntry arg; + CommandArgumentData file_arg; + + // Define the first (and only) variant of this arg. + file_arg.arg_type = eArgTypeFilename; + file_arg.arg_repetition = eArgRepeatPlain; + + // There is only one variant this argument could be; put it into the argument entry. + arg.push_back (file_arg); + + // Push the data for the first argument into the m_arguments vector. + m_arguments.push_back (arg); + + m_option_group.Append (&m_file_options, 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.Finalize(); + } + + ~CommandObjectTargetCreate () + { + } + + Options * + GetOptions () + { + return &m_option_group; + } + + bool + Execute (Args& command, CommandReturnObject &result) + { + const int argc = command.GetArgumentCount(); + if (argc == 1) + { + const char *file_path = command.GetArgumentAtIndex(0); + Timer scoped_timer(__PRETTY_FUNCTION__, "(lldb) target create '%s'", file_path); + FileSpec file_spec (file_path, true); + + bool select = true; + PlatformSP platform_sp; + + Error error; + + if (m_platform_options.PlatformWasSpecified ()) + { + platform_sp = m_platform_options.CreatePlatformWithOptions(m_interpreter, select, error); + if (!platform_sp) + { + result.AppendError(error.AsCString()); + result.SetStatus (eReturnStatusFailed); + return false; + } + } + ArchSpec file_arch; + + const char *arch_cstr = m_file_options.GetArchitectureName(); + if (arch_cstr) + { + if (!platform_sp) + platform_sp = m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform(); + if (!m_file_options.GetArchitecture(platform_sp.get(), file_arch)) + { + result.AppendErrorWithFormat("invalid architecture '%s'\n", arch_cstr); + result.SetStatus (eReturnStatusFailed); + return false; + } + } + + if (! file_spec.Exists() && !file_spec.ResolveExecutableLocation()) + { + result.AppendErrorWithFormat ("File '%s' does not exist.\n", file_path); + result.SetStatus (eReturnStatusFailed); + return false; + } + + TargetSP target_sp; + Debugger &debugger = m_interpreter.GetDebugger(); + error = debugger.GetTargetList().CreateTarget (debugger, file_spec, file_arch, true, target_sp); + + if (target_sp) + { + debugger.GetTargetList().SetSelectedTarget(target_sp.get()); + result.AppendMessageWithFormat ("Current executable set to '%s' (%s).\n", file_path, target_sp->GetArchitecture().GetArchitectureName()); + result.SetStatus (eReturnStatusSuccessFinishNoResult); + } + else + { + result.AppendError(error.AsCString()); + result.SetStatus (eReturnStatusFailed); + } + } + else + { + result.AppendErrorWithFormat("'%s' takes exactly one executable path argument.\n", m_cmd_name.c_str()); + result.SetStatus (eReturnStatusFailed); + } + return result.Succeeded(); + + } + + int + HandleArgumentCompletion (Args &input, + int &cursor_index, + int &cursor_char_position, + OptionElementVector &opt_element_vector, + int match_start_point, + int max_return_elements, + bool &word_complete, + StringList &matches) + { + std::string completion_str (input.GetArgumentAtIndex(cursor_index)); + completion_str.erase (cursor_char_position); + + CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter, + CommandCompletions::eDiskFileCompletion, + completion_str.c_str(), + match_start_point, + max_return_elements, + NULL, + word_complete, + matches); + return matches.GetSize(); + } +private: + OptionGroupOptions m_option_group; + OptionGroupArchitecture m_file_options; + OptionGroupPlatform m_platform_options; + +}; + +#pragma mark CommandObjectTargetList + +//---------------------------------------------------------------------- +// "target list" +//---------------------------------------------------------------------- + +class CommandObjectTargetList : public CommandObject +{ +public: + CommandObjectTargetList (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "target list", + "List all current targets in the current debug session.", + NULL, + 0) + { + } + + virtual + ~CommandObjectTargetList () + { + } + + virtual bool + Execute (Args& args, CommandReturnObject &result) + { + if (args.GetArgumentCount() == 0) + { + Stream &strm = result.GetOutputStream(); + + bool show_stopped_process_status = false; + if (DumpTargetList (m_interpreter.GetDebugger().GetTargetList(), show_stopped_process_status, strm) == 0) + { + strm.PutCString ("No targets.\n"); + } + } + else + { + result.AppendError ("the 'target list' command takes no arguments\n"); + result.SetStatus (eReturnStatusFailed); + } + return result.Succeeded(); + } +}; + + +#pragma mark CommandObjectTargetSelect + +//---------------------------------------------------------------------- +// "target select" +//---------------------------------------------------------------------- + +class CommandObjectTargetSelect : public CommandObject +{ +public: + CommandObjectTargetSelect (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "target select", + "Select a target as the current target by target index.", + NULL, + 0) + { + } + + virtual + ~CommandObjectTargetSelect () + { + } + + virtual bool + Execute (Args& args, CommandReturnObject &result) + { + if (args.GetArgumentCount() == 1) + { + bool success = false; + const char *target_idx_arg = args.GetArgumentAtIndex(0); + uint32_t target_idx = Args::StringToUInt32 (target_idx_arg, UINT32_MAX, 0, &success); + if (success) + { + TargetList &target_list = m_interpreter.GetDebugger().GetTargetList(); + const uint32_t num_targets = target_list.GetNumTargets(); + if (target_idx < num_targets) + { + TargetSP target_sp (target_list.GetTargetAtIndex (target_idx)); + if (target_sp) + { + Stream &strm = result.GetOutputStream(); + target_list.SetSelectedTarget (target_sp.get()); + bool show_stopped_process_status = false; + DumpTargetList (target_list, show_stopped_process_status, strm); + } + else + { + result.AppendErrorWithFormat ("target #%u is NULL in target list\n", target_idx); + result.SetStatus (eReturnStatusFailed); + } + } + else + { + result.AppendErrorWithFormat ("index %u is out of range, valid target indexes are 0 - %u\n", + target_idx, + num_targets - 1); + result.SetStatus (eReturnStatusFailed); + } + } + else + { + result.AppendErrorWithFormat("invalid index string value '%s'\n", target_idx_arg); + result.SetStatus (eReturnStatusFailed); + } + } + else + { + result.AppendError ("'target select' takes a single argument: a target index\n"); + result.SetStatus (eReturnStatusFailed); + } + return result.Succeeded(); + } +}; + + #pragma mark CommandObjectTargetImageSearchPaths class CommandObjectTargetImageSearchPathsAdd : public CommandObject @@ -77,7 +434,7 @@ public: uint32_t argc = command.GetArgumentCount(); if (argc & 1) { - result.AppendError ("add requires an even number of arguments"); + result.AppendError ("add requires an even number of arguments\n"); result.SetStatus (eReturnStatusFailed); } else @@ -98,9 +455,9 @@ public: else { if (from[0]) - result.AppendError ("<path-prefix> can't be empty"); + result.AppendError ("<path-prefix> can't be empty\n"); else - result.AppendError ("<new-path-prefix> can't be empty"); + result.AppendError ("<new-path-prefix> can't be empty\n"); result.SetStatus (eReturnStatusFailed); } } @@ -108,7 +465,7 @@ public: } else { - result.AppendError ("invalid target"); + result.AppendError ("invalid target\n"); result.SetStatus (eReturnStatusFailed); } return result.Succeeded(); @@ -144,7 +501,7 @@ public: } else { - result.AppendError ("invalid target"); + result.AppendError ("invalid target\n"); result.SetStatus (eReturnStatusFailed); } return result.Succeeded(); @@ -241,9 +598,9 @@ public: else { if (from[0]) - result.AppendError ("<path-prefix> can't be empty"); + result.AppendError ("<path-prefix> can't be empty\n"); else - result.AppendError ("<new-path-prefix> can't be empty"); + result.AppendError ("<new-path-prefix> can't be empty\n"); result.SetStatus (eReturnStatusFailed); return false; } @@ -251,7 +608,7 @@ public: } else { - result.AppendError ("insert requires at least three arguments"); + result.AppendError ("insert requires at least three arguments\n"); result.SetStatus (eReturnStatusFailed); return result.Succeeded(); } @@ -259,7 +616,7 @@ public: } else { - result.AppendError ("invalid target"); + result.AppendError ("invalid target\n"); result.SetStatus (eReturnStatusFailed); } return result.Succeeded(); @@ -291,7 +648,7 @@ public: { if (command.GetArgumentCount() != 0) { - result.AppendError ("list takes no arguments"); + result.AppendError ("list takes no arguments\n"); result.SetStatus (eReturnStatusFailed); return result.Succeeded(); } @@ -301,7 +658,7 @@ public: } else { - result.AppendError ("invalid target"); + result.AppendError ("invalid target\n"); result.SetStatus (eReturnStatusFailed); } return result.Succeeded(); @@ -345,7 +702,7 @@ public: { if (command.GetArgumentCount() != 1) { - result.AppendError ("query requires one argument"); + result.AppendError ("query requires one argument\n"); result.SetStatus (eReturnStatusFailed); return result.Succeeded(); } @@ -361,7 +718,7 @@ public: } else { - result.AppendError ("invalid target"); + result.AppendError ("invalid target\n"); result.SetStatus (eReturnStatusFailed); } return result.Succeeded(); @@ -790,7 +1147,7 @@ public: InputReaderSP reader_sp (new InputReader(m_interpreter.GetDebugger())); if (!reader_sp) { - result.AppendError("out of memory"); + result.AppendError("out of memory\n"); result.SetStatus (eReturnStatusFailed); target->RemoveStopHookByID (new_hook_sp->GetID()); return false; @@ -815,7 +1172,7 @@ public: } else { - result.AppendError ("invalid target"); + result.AppendError ("invalid target\n"); result.SetStatus (eReturnStatusFailed); } @@ -902,14 +1259,14 @@ public: lldb::user_id_t user_id = Args::StringToUInt32 (command.GetArgumentAtIndex(i), 0, 0, &success); if (!success) { - result.AppendErrorWithFormat ("invalid stop hook id: \"%s\".", command.GetArgumentAtIndex(i)); + result.AppendErrorWithFormat ("invalid stop hook id: \"%s\".\n", command.GetArgumentAtIndex(i)); result.SetStatus(eReturnStatusFailed); return false; } success = target->RemoveStopHookByID (user_id); if (!success) { - result.AppendErrorWithFormat ("unknown stop hook id: \"%s\".", command.GetArgumentAtIndex(i)); + result.AppendErrorWithFormat ("unknown stop hook id: \"%s\".\n", command.GetArgumentAtIndex(i)); result.SetStatus(eReturnStatusFailed); return false; } @@ -919,7 +1276,7 @@ public: } else { - result.AppendError ("invalid target"); + result.AppendError ("invalid target\n"); result.SetStatus (eReturnStatusFailed); } @@ -971,14 +1328,14 @@ public: lldb::user_id_t user_id = Args::StringToUInt32 (command.GetArgumentAtIndex(i), 0, 0, &success); if (!success) { - result.AppendErrorWithFormat ("invalid stop hook id: \"%s\".", command.GetArgumentAtIndex(i)); + result.AppendErrorWithFormat ("invalid stop hook id: \"%s\".\n", command.GetArgumentAtIndex(i)); result.SetStatus(eReturnStatusFailed); return false; } success = target->SetStopHookActiveStateByID (user_id, m_enable); if (!success) { - result.AppendErrorWithFormat ("unknown stop hook id: \"%s\".", command.GetArgumentAtIndex(i)); + result.AppendErrorWithFormat ("unknown stop hook id: \"%s\".\n", command.GetArgumentAtIndex(i)); result.SetStatus(eReturnStatusFailed); return false; } @@ -988,7 +1345,7 @@ public: } else { - result.AppendError ("invalid target"); + result.AppendError ("invalid target\n"); result.SetStatus (eReturnStatusFailed); } return result.Succeeded(); @@ -1032,7 +1389,7 @@ public: } else { - result.AppendError ("invalid target"); + result.AppendError ("invalid target\n"); result.SetStatus (eReturnStatusFailed); } @@ -1104,11 +1461,16 @@ CommandObjectMultiwordTarget::CommandObjectMultiwordTarget (CommandInterpreter & "A set of commands for operating on debugger targets.", "target <subcommand> [<subcommand-options>]") { - LoadSubCommand ("image-search-paths", CommandObjectSP (new CommandObjectMultiwordImageSearchPaths (interpreter))); + + LoadSubCommand ("create", CommandObjectSP (new CommandObjectTargetCreate (interpreter))); + LoadSubCommand ("list", CommandObjectSP (new CommandObjectTargetList (interpreter))); + LoadSubCommand ("select", CommandObjectSP (new CommandObjectTargetSelect (interpreter))); LoadSubCommand ("stop-hook", CommandObjectSP (new CommandObjectMultiwordTargetStopHooks (interpreter))); + LoadSubCommand ("image-search-paths", CommandObjectSP (new CommandObjectMultiwordImageSearchPaths (interpreter))); } CommandObjectMultiwordTarget::~CommandObjectMultiwordTarget () { } + diff --git a/lldb/source/Commands/CommandObjectThread.cpp b/lldb/source/Commands/CommandObjectThread.cpp index fd90720b1e8..9f25b49e8e1 100644 --- a/lldb/source/Commands/CommandObjectThread.cpp +++ b/lldb/source/Commands/CommandObjectThread.cpp @@ -38,205 +38,6 @@ using namespace lldb; using namespace lldb_private; -bool -lldb_private::DisplayThreadInfo -( - CommandInterpreter &interpreter, - Stream &strm, - Thread *thread, - bool only_threads_with_stop_reason, - bool show_source -) -{ - if (thread) - { - if (only_threads_with_stop_reason) - { - if (thread->GetStopInfo() == NULL) - return false; - } - - strm.Indent(); - strm.Printf("%c ", thread->GetProcess().GetThreadList().GetSelectedThread().get() == thread ? '*' : ' '); - - // Show one frame with only the first showing source - if (show_source) - { - bool already_shown = false; - StackFrameSP frame_sp = thread->GetStackFrameAtIndex(0); - SymbolContext frame_sc(frame_sp->GetSymbolContext (eSymbolContextLineEntry)); - if (interpreter.GetDebugger().GetUseExternalEditor() && frame_sc.line_entry.file && frame_sc.line_entry.line != 0) - { - already_shown = Host::OpenFileInExternalEditor (frame_sc.line_entry.file, frame_sc.line_entry.line); - } - - DisplayFramesForExecutionContext (thread, - interpreter, - strm, - 0, // Start at first frame - 1, // Number of frames to show - false,// Don't show the frame info since we already displayed most of it above... - !already_shown, // Show source for the first frame - 3, // lines of source context before - 3); // lines of source context after - } - else - { - thread->DumpUsingSettingsFormat (strm, 0); - } - - return true; - } - return false; -} - -size_t -lldb_private::DisplayThreadsInfo -( - CommandInterpreter &interpreter, - ExecutionContext *exe_ctx, - CommandReturnObject &result, - bool only_threads_with_stop_reason, - bool show_source -) -{ - StreamString strm; - - size_t num_thread_infos_dumped = 0; - - if (!exe_ctx->process) - return 0; - - const size_t num_threads = exe_ctx->process->GetThreadList().GetSize(); - if (num_threads > 0) - { - - for (uint32_t i = 0; i < num_threads; i++) - { - Thread *thread = exe_ctx->process->GetThreadList().GetThreadAtIndex(i).get(); - if (thread) - { - if (DisplayThreadInfo (interpreter, - strm, - thread, - only_threads_with_stop_reason, - show_source)) - ++num_thread_infos_dumped; - } - } - } - - if (num_thread_infos_dumped > 0) - { - if (num_thread_infos_dumped < num_threads) - result.GetOutputStream().Printf("%u of %u threads stopped with reasons:\n", num_thread_infos_dumped, num_threads); - - result.AppendMessage (strm.GetString().c_str()); - result.SetStatus (eReturnStatusSuccessFinishNoResult); - } - return num_thread_infos_dumped; -} - - -size_t -lldb_private::DisplayFramesForExecutionContext -( - Thread *thread, - CommandInterpreter &interpreter, - Stream& strm, - uint32_t first_frame, - uint32_t num_frames, - bool show_frame_info, - uint32_t num_frames_with_source, - uint32_t source_lines_before, - uint32_t source_lines_after -) -{ - if (thread == NULL) - return 0; - - size_t num_frames_displayed = 0; - - if (num_frames == 0) - return 0; - - thread->DumpUsingSettingsFormat (strm, num_frames > 1 ? UINT32_MAX : first_frame); - strm.IndentMore(); - - StackFrameSP frame_sp; - uint32_t frame_idx = 0; - uint32_t last_frame; - - // Don't let the last frame wrap around... - if (num_frames == UINT32_MAX) - last_frame = UINT32_MAX; - else - last_frame = first_frame + num_frames; - - for (frame_idx = first_frame; frame_idx < last_frame; ++frame_idx) - { - frame_sp = thread->GetStackFrameAtIndex (frame_idx); - if (frame_sp.get() == NULL) - break; - - if (DisplayFrameForExecutionContext (thread, - frame_sp.get(), - interpreter, - strm, - show_frame_info, - num_frames_with_source > first_frame - frame_idx, - source_lines_before, - source_lines_after) == false) - break; - - ++num_frames_displayed; - } - - strm.IndentLess(); - return num_frames_displayed; -} - -bool -lldb_private::DisplayFrameForExecutionContext -( - Thread *thread, - StackFrame *frame, - CommandInterpreter &interpreter, - Stream& strm, - bool show_frame_info, - bool show_source, - uint32_t source_lines_before, - uint32_t source_lines_after -) -{ - // thread and frame must be filled in prior to calling this function - if (thread && frame) - { - if (show_frame_info) - { - strm.Indent(); - frame->DumpUsingSettingsFormat (&strm); - } - - SymbolContext sc (frame->GetSymbolContext(eSymbolContextCompUnit | eSymbolContextLineEntry)); - - if (show_source && sc.comp_unit && sc.line_entry.IsValid()) - { - interpreter.GetDebugger().GetSourceManager().DisplaySourceLinesWithLineNumbers ( - sc.line_entry.file, - sc.line_entry.line, - 3, - 3, - "->", - &strm); - - } - return true; - } - return false; -} - - //------------------------------------------------------------------------- // CommandObjectThreadBacktrace //------------------------------------------------------------------------- @@ -300,7 +101,7 @@ public: void OptionParsingStarting () { - m_count = -1; + m_count = UINT32_MAX; m_start = 0; } @@ -353,27 +154,21 @@ public: virtual bool Execute (Args& command, CommandReturnObject &result) - { - - bool show_frame_info = true; - uint32_t num_frames_with_source = 0; // Don't show any frames with source when backtracing - + { result.SetStatus (eReturnStatusSuccessFinishResult); - + Stream &strm = result.GetOutputStream(); + + // Don't show source context when doing backtraces. + const uint32_t num_frames_with_source = 0; if (command.GetArgumentCount() == 0) { ExecutionContext exe_ctx(m_interpreter.GetExecutionContext()); if (exe_ctx.thread) { - if (DisplayFramesForExecutionContext (exe_ctx.thread, - m_interpreter, - result.GetOutputStream(), - m_options.m_start, - m_options.m_count, - show_frame_info, - num_frames_with_source, - 3, - 3)) + if (exe_ctx.thread->GetStatus (strm, + m_options.m_start, + m_options.m_count, + num_frames_with_source)) { result.SetStatus (eReturnStatusSuccessFinishResult); } @@ -391,22 +186,15 @@ public: for (uint32_t i = 0; i < num_threads; i++) { ThreadSP thread_sp = process->GetThreadList().GetThreadAtIndex(i); - if (!DisplayFramesForExecutionContext (thread_sp.get(), - m_interpreter, - result.GetOutputStream(), - m_options.m_start, - m_options.m_count, - show_frame_info, - num_frames_with_source, - 3, - 3)) + if (thread_sp->GetStatus (strm, + m_options.m_start, + m_options.m_count, + num_frames_with_source)) { result.AppendErrorWithFormat ("error displaying backtrace for thread: \"0x%4.4x\"\n", i); result.SetStatus (eReturnStatusFailed); return false; } - if (i < num_threads - 1) - result.AppendMessage(""); } } else @@ -440,15 +228,10 @@ public: for (uint32_t i = 0; i < num_args; i++) { - if (!DisplayFramesForExecutionContext (thread_sps[i].get(), - m_interpreter, - result.GetOutputStream(), - m_options.m_start, - m_options.m_count, - show_frame_info, - num_frames_with_source, - 3, - 3)) + if (!thread_sps[i]->GetStatus (strm, + m_options.m_start, + m_options.m_count, + num_frames_with_source)) { result.AppendErrorWithFormat ("error displaying backtrace for thread: \"%s\"\n", command.GetArgumentAtIndex(i)); result.SetStatus (eReturnStatusFailed); @@ -1335,11 +1118,13 @@ public: process->GetThreadList().SetSelectedThreadByID(new_thread->GetID()); result.SetStatus (eReturnStatusSuccessFinishNoResult); - DisplayThreadInfo (m_interpreter, - result.GetOutputStream(), - new_thread, - false, - true); + const uint32_t start_frame = 0; + const uint32_t num_frames = 1; + const uint32_t num_frames_with_source = 1; + new_thread->GetStatus (result.GetOutputStream(), + start_frame, + num_frames, + num_frames_with_source); return result.Succeeded(); } @@ -1381,41 +1166,16 @@ public: ExecutionContext exe_ctx(m_interpreter.GetExecutionContext()); if (exe_ctx.process) { - const StateType state = exe_ctx.process->GetState(); - - if (StateIsStoppedState(state)) - { - if (state == eStateExited) - { - int exit_status = exe_ctx.process->GetExitStatus(); - const char *exit_description = exe_ctx.process->GetExitDescription(); - strm.Printf ("Process %d exited with status = %i (0x%8.8x) %s\n", - exe_ctx.process->GetID(), - exit_status, - exit_status, - exit_description ? exit_description : ""); - } - else - { - strm.Printf ("Process %d state is %s\n", exe_ctx.process->GetID(), StateAsCString (state)); - if (exe_ctx.thread == NULL) - exe_ctx.thread = exe_ctx.process->GetThreadList().GetThreadAtIndex(0).get(); - if (exe_ctx.thread != NULL) - { - DisplayThreadsInfo (m_interpreter, &exe_ctx, result, false, false); - } - else - { - result.AppendError ("no valid thread found in current process"); - result.SetStatus (eReturnStatusFailed); - } - } - } - else - { - result.AppendError ("process is currently running"); - result.SetStatus (eReturnStatusFailed); - } + const bool only_threads_with_stop_reason = false; + const uint32_t start_frame = 0; + const uint32_t num_frames = 0; + const uint32_t num_frames_with_source = 0; + exe_ctx.process->GetStatus(strm); + exe_ctx.process->GetThreadStatus (strm, + only_threads_with_stop_reason, + start_frame, + num_frames, + num_frames_with_source); } else { diff --git a/lldb/source/Commands/CommandObjectThread.h b/lldb/source/Commands/CommandObjectThread.h index 7fc58261ed0..52902ee36c7 100644 --- a/lldb/source/Commands/CommandObjectThread.h +++ b/lldb/source/Commands/CommandObjectThread.h @@ -29,42 +29,6 @@ public: }; - -bool -DisplayThreadInfo (CommandInterpreter &interpreter, - Stream &strm, - Thread *thread, - bool only_threads_with_stop_reason, - bool show_source); - -size_t -DisplayThreadsInfo (CommandInterpreter &interpreter, - ExecutionContext *exe_ctx, - CommandReturnObject &result, - bool only_threads_with_stop_reason, - bool show_source); - -size_t -DisplayFramesForExecutionContext (Thread *thread, - CommandInterpreter &interpreter, - Stream& strm, - uint32_t first_frame, - uint32_t num_frames, - bool show_frame_info, - uint32_t num_frames_with_source, - uint32_t source_lines_before, - uint32_t source_lines_after); - -bool -DisplayFrameForExecutionContext (Thread *thread, - StackFrame *frame, - CommandInterpreter &interpreter, - Stream& strm, - bool show_frame_info, - bool show_source, - uint32_t source_lines_before, - uint32_t source_lines_after); - } // namespace lldb_private #endif // liblldb_CommandObjectThread_h_ diff --git a/lldb/source/Core/PluginManager.cpp b/lldb/source/Core/PluginManager.cpp index aff9b2b1973..8efeedce52b 100644 --- a/lldb/source/Core/PluginManager.cpp +++ b/lldb/source/Core/PluginManager.cpp @@ -1192,7 +1192,7 @@ PluginManager::GetPlatformCreateCallbackForPluginName (const char *name) PlatformInstances::iterator pos, end = instances.end(); for (pos = instances.begin(); pos != end; ++ pos) { - if (name_sref.equals (name)) + if (name_sref.equals (pos->name)) return pos->create_callback; } } @@ -1211,9 +1211,9 @@ PluginManager::AutoCompletePlatformName (const char *name, StringList &matches) PlatformInstances::iterator pos, end = instances.end(); for (pos = instances.begin(); pos != end; ++ pos) { - const char *plugin_name = pos->name.c_str(); - if (name_sref.startswith(plugin_name)) - matches.AppendString (plugin_name); + llvm::StringRef plugin_name (pos->name); + if (plugin_name.startswith(name_sref)) + matches.AppendString (plugin_name.data()); } } return matches.GetSize(); diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp index 6dcc4a1eea5..95061523bf4 100644 --- a/lldb/source/Interpreter/CommandInterpreter.cpp +++ b/lldb/source/Interpreter/CommandInterpreter.cpp @@ -19,7 +19,7 @@ //#include "../Commands/CommandObjectCall.h" #include "../Commands/CommandObjectDisassemble.h" #include "../Commands/CommandObjectExpression.h" -#include "../Commands/CommandObjectFile.h" +//#include "../Commands/CommandObjectFile.h" #include "../Commands/CommandObjectFrame.h" #include "../Commands/CommandObjectHelp.h" #include "../Commands/CommandObjectImage.h" @@ -117,6 +117,7 @@ CommandInterpreter::Initialize () HandleCommand ("command alias po expression -o --", false, result); HandleCommand ("command alias up _regexp-up", false, result); HandleCommand ("command alias down _regexp-down", false, result); + HandleCommand ("command alias file target create", false, result); } @@ -165,7 +166,7 @@ CommandInterpreter::LoadCommandDictionary () m_command_dict["commands"] = CommandObjectSP (new CommandObjectMultiwordCommands (*this)); m_command_dict["disassemble"] = CommandObjectSP (new CommandObjectDisassemble (*this)); m_command_dict["expression"]= CommandObjectSP (new CommandObjectExpression (*this)); - m_command_dict["file"] = CommandObjectSP (new CommandObjectFile (*this)); +// m_command_dict["file"] = CommandObjectSP (new CommandObjectFile (*this)); m_command_dict["frame"] = CommandObjectSP (new CommandObjectMultiwordFrame (*this)); m_command_dict["help"] = CommandObjectSP (new CommandObjectHelp (*this)); m_command_dict["image"] = CommandObjectSP (new CommandObjectImage (*this)); diff --git a/lldb/source/Interpreter/OptionGroupArchitecture.cpp b/lldb/source/Interpreter/OptionGroupArchitecture.cpp new file mode 100644 index 00000000000..f96d704e3f1 --- /dev/null +++ b/lldb/source/Interpreter/OptionGroupArchitecture.cpp @@ -0,0 +1,85 @@ +//===-- OptionGroupArchitecture.cpp -----------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "OptionGroupArchitecture.h" + +// C Includes +// C++ Includes +// Other libraries and framework includes +// Project includes + +using namespace lldb; +using namespace lldb_private; + +OptionGroupArchitecture::OptionGroupArchitecture() : + m_arch_str () +{ +} + +OptionGroupArchitecture::~OptionGroupArchitecture () +{ +} + +OptionDefinition g_file_option_table[] = +{ + { LLDB_OPT_SET_1 , false, "arch" , 'a', required_argument, NULL, 0, eArgTypeArchitecture , "Specify the architecture for the target."}, +}; +const uint32_t k_num_file_options = sizeof(g_file_option_table)/sizeof(OptionDefinition); + +uint32_t +OptionGroupArchitecture::GetNumDefinitions () +{ + return k_num_file_options; +} + +const OptionDefinition * +OptionGroupArchitecture::GetDefinitions () +{ + return g_file_option_table; +} + +bool +OptionGroupArchitecture::GetArchitecture (Platform *platform, ArchSpec &arch) +{ + if (m_arch_str.empty()) + arch.Clear(); + else + arch.SetTriple(m_arch_str.c_str(), platform); + return arch.IsValid(); +} + + +Error +OptionGroupArchitecture::SetOptionValue (CommandInterpreter &interpreter, + uint32_t option_idx, + const char *option_arg) +{ + Error error; + char short_option = (char) g_file_option_table[option_idx].short_option; + + switch (short_option) + { + case 'a': + m_arch_str.assign (option_arg); + break; + + default: + error.SetErrorStringWithFormat ("Unrecognized option '%c'.\n", short_option); + break; + } + + return error; +} + +void +OptionGroupArchitecture::OptionParsingStarting (CommandInterpreter &interpreter) +{ + m_arch_str.clear(); +} + diff --git a/lldb/source/Interpreter/OptionGroupPlatform.cpp b/lldb/source/Interpreter/OptionGroupPlatform.cpp new file mode 100644 index 00000000000..59dbceb7626 --- /dev/null +++ b/lldb/source/Interpreter/OptionGroupPlatform.cpp @@ -0,0 +1,109 @@ +//===-- OptionGroupPlatform.cpp ---------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "lldb/Interpreter/OptionGroupPlatform.h" + +// C Includes +// C++ Includes +// Other libraries and framework includes +// Project includes +#include "lldb/Interpreter/CommandInterpreter.h" +#include "lldb/Target/Platform.h" + +using namespace lldb; +using namespace lldb_private; + +PlatformSP +OptionGroupPlatform::CreatePlatformWithOptions (CommandInterpreter &interpreter, bool make_selected, Error& error) +{ + PlatformSP platform_sp; + if (!m_platform_name.empty()) + { + platform_sp = Platform::Create (m_platform_name.c_str(), error); + + if (platform_sp) + { + interpreter.GetDebugger().GetPlatformList().Append (platform_sp, make_selected); + if (m_os_version_major != UINT32_MAX) + { + platform_sp->SetOSVersion (m_os_version_major, + m_os_version_minor, + m_os_version_update); + } + } + } + return platform_sp; +} + +void +OptionGroupPlatform::OptionParsingStarting (CommandInterpreter &interpreter) +{ + m_platform_name.clear(); + m_os_version_major = UINT32_MAX; + m_os_version_minor = UINT32_MAX; + m_os_version_update = UINT32_MAX; +} + +static OptionDefinition +g_option_table[] = +{ + { LLDB_OPT_SET_ALL, false, "platform" , 'p', required_argument, NULL, 0, eArgTypePlatform, "Specify name of the platform to use for this target, creating the platform if necessary."}, + { LLDB_OPT_SET_ALL, false, "sdk-version", 'v', required_argument, NULL, 0, eArgTypeNone, "Specify the initial SDK version to use prior to connecting." } +}; + +static const uint32_t k_option_table_size = sizeof(g_option_table)/sizeof (OptionDefinition); + +const OptionDefinition* +OptionGroupPlatform::GetDefinitions () +{ + if (m_include_platform_option) + return g_option_table; + return g_option_table + 1; +} + +uint32_t +OptionGroupPlatform::GetNumDefinitions () +{ + if (m_include_platform_option) + return k_option_table_size; + return k_option_table_size - 1; +} + + +Error +OptionGroupPlatform::SetOptionValue (CommandInterpreter &interpreter, + uint32_t option_idx, + const char *option_arg) +{ + Error error; + if (!m_include_platform_option) + --option_idx; + + char short_option = (char) g_option_table[option_idx].short_option; + + switch (short_option) + { + case 'p': + m_platform_name.assign (option_arg); + break; + + case 'v': + if (Args::StringToVersion (option_arg, + m_os_version_major, + m_os_version_minor, + m_os_version_update) == option_arg) + error.SetErrorStringWithFormat ("invalid version string '%s'", option_arg); + break; + + default: + error.SetErrorStringWithFormat ("Unrecognized option '%c'.\n", short_option); + break; + } + return error; +} diff --git a/lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp b/lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp index 4f71a1b339f..5ddcd727bc0 100644 --- a/lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp +++ b/lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp @@ -76,9 +76,11 @@ static int IPRegisterReader(uint64_t *value, unsigned regID, void* arg) InstructionLLVM::InstructionLLVM (const Address &addr, AddressClass addr_class, - EDDisassemblerRef disassembler) : + EDDisassemblerRef disassembler, + bool force_raw) : Instruction (addr, addr_class), - m_disassembler (disassembler) + m_disassembler (disassembler), + m_force_raw (force_raw) { } @@ -153,6 +155,9 @@ InstructionLLVM::Dump int numTokens = -1; if (!raw) + raw = m_force_raw; + + if (!raw) numTokens = EDNumTokens(m_inst); int currentOpIndex = -1; @@ -471,9 +476,20 @@ DisassemblerLLVM::DecodeInstructions if (inst_address_class == eAddressClassCodeAlternateISA) use_thumb = true; } + bool force_raw = false; + switch (m_arch.GetMachine()) + { + case llvm::Triple::arm: + case llvm::Triple::thumb: + force_raw = true; + break; + default: + break; + } InstructionSP inst_sp (new InstructionLLVM (inst_addr, inst_address_class, - use_thumb ? m_disassembler_thumb : m_disassembler)); + use_thumb ? m_disassembler_thumb : m_disassembler, + force_raw)); size_t inst_byte_size = inst_sp->Decode (*this, data, data_offset); diff --git a/lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVM.h b/lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVM.h index 69998d91cb9..953f5f492b1 100644 --- a/lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVM.h +++ b/lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVM.h @@ -21,7 +21,8 @@ class InstructionLLVM : public lldb_private::Instruction public: InstructionLLVM (const lldb_private::Address &addr, lldb_private::AddressClass addr_class, - EDDisassemblerRef disassembler); + EDDisassemblerRef disassembler, + bool force_raw); virtual ~InstructionLLVM(); @@ -45,6 +46,7 @@ public: protected: EDDisassemblerRef m_disassembler; EDInstRef m_inst; + bool m_force_raw; }; diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp index d3a11e43e84..4998426d7d8 100644 --- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp @@ -156,13 +156,6 @@ PlatformDarwin::ResolveExecutable (const FileSpec &exe_file, } } } - else - { - error.SetErrorStringWithFormat ("'%s%s%s' does not exist", - exe_file.GetDirectory().AsCString(""), - exe_file.GetDirectory() ? "/" : "", - exe_file.GetFilename().AsCString("")); - } return error; } diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp index 3e0b2b14906..881b15bc451 100644 --- a/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp @@ -112,9 +112,9 @@ PlatformRemoteiOS::GetStatus (Stream &strm) Platform::GetStatus (strm); const char *sdk_directory = GetDeviceSupportDirectoryForOSVersion(); if (sdk_directory) - strm.Printf ("SDKROOT: \"%s\"\n", sdk_directory); + strm.Printf (" SDK Path: \"%s\"\n", sdk_directory); else - strm.PutCString ("SDKROOT: error: unable to locate SDK\n"); + strm.PutCString (" SDK Path: error: unable to locate SDK\n"); } diff --git a/lldb/source/Symbol/ClangASTContext.cpp b/lldb/source/Symbol/ClangASTContext.cpp index 57d25b9c94e..40f0124acbe 100644 --- a/lldb/source/Symbol/ClangASTContext.cpp +++ b/lldb/source/Symbol/ClangASTContext.cpp @@ -2318,6 +2318,7 @@ ClangASTContext::GetNumPointeeChildren (clang_type_t clang_type) case clang::Type::Builtin: switch (cast<clang::BuiltinType>(qual_type)->getKind()) { + case clang::BuiltinType::UnknownAny: case clang::BuiltinType::Void: case clang::BuiltinType::NullPtr: return 0; diff --git a/lldb/source/Symbol/ClangASTType.cpp b/lldb/source/Symbol/ClangASTType.cpp index 1d3b02fe5db..ad14fd6eac1 100644 --- a/lldb/source/Symbol/ClangASTType.cpp +++ b/lldb/source/Symbol/ClangASTType.cpp @@ -260,6 +260,7 @@ ClangASTType::GetFormat (clang_type_t clang_type) switch (cast<clang::BuiltinType>(qual_type)->getKind()) { //default: assert(0 && "Unknown builtin type!"); + case clang::BuiltinType::UnknownAny: case clang::BuiltinType::Void: break; diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp index a492e47642d..b0037bf0ef9 100644 --- a/lldb/source/Target/Process.cpp +++ b/lldb/source/Target/Process.cpp @@ -3867,6 +3867,66 @@ Process::ExecutionResultAsCString (ExecutionResults result) return result_name; } +void +Process::GetStatus (Stream &strm) +{ + const StateType state = GetState(); + if (StateIsStoppedState(state)) + { + if (state == eStateExited) + { + int exit_status = GetExitStatus(); + const char *exit_description = GetExitDescription(); + strm.Printf ("Process %d exited with status = %i (0x%8.8x) %s\n", + GetID(), + exit_status, + exit_status, + exit_description ? exit_description : ""); + } + else + { + if (state == eStateConnected) + strm.Printf ("Connected to remote target.\n"); + else + strm.Printf ("Process %d %s\n", GetID(), StateAsCString (state)); + } + } + else + { + strm.Printf ("Process %d is running.\n", GetID()); + } +} + +size_t +Process::GetThreadStatus (Stream &strm, + bool only_threads_with_stop_reason, + uint32_t start_frame, + uint32_t num_frames, + uint32_t num_frames_with_source) +{ + size_t num_thread_infos_dumped = 0; + + const size_t num_threads = GetThreadList().GetSize(); + for (uint32_t i = 0; i < num_threads; i++) + { + Thread *thread = GetThreadList().GetThreadAtIndex(i).get(); + if (thread) + { + if (only_threads_with_stop_reason) + { + if (thread->GetStopInfo().get() == NULL) + continue; + } + thread->GetStatus (strm, + start_frame, + num_frames, + num_frames_with_source); + ++num_thread_infos_dumped; + } + } + return num_thread_infos_dumped; +} + //-------------------------------------------------------------- // class Process::SettingsController //-------------------------------------------------------------- diff --git a/lldb/source/Target/StackFrame.cpp b/lldb/source/Target/StackFrame.cpp index a5df9284b55..ec3376d522b 100644 --- a/lldb/source/Target/StackFrame.cpp +++ b/lldb/source/Target/StackFrame.cpp @@ -991,3 +991,38 @@ StackFrame::GetSP () { return m_thread.GetStackFrameSPForStackFramePtr (this); } + + + +bool +StackFrame::GetStatus (Stream& strm, + bool show_frame_info, + bool show_source, + uint32_t source_lines_before, + uint32_t source_lines_after) +{ + if (show_frame_info) + { + strm.Indent(); + DumpUsingSettingsFormat (&strm); + } + + if (show_source) + { + GetSymbolContext(eSymbolContextCompUnit | eSymbolContextLineEntry); + + if (m_sc.comp_unit && m_sc.line_entry.IsValid()) + { + GetThread().GetProcess().GetTarget().GetDebugger().GetSourceManager().DisplaySourceLinesWithLineNumbers ( + m_sc.line_entry.file, + m_sc.line_entry.line, + 3, + 3, + "->", + &strm); + + } + } + return true; +} + diff --git a/lldb/source/Target/StackFrameList.cpp b/lldb/source/Target/StackFrameList.cpp index aef35a8d140..21f8a505f3f 100644 --- a/lldb/source/Target/StackFrameList.cpp +++ b/lldb/source/Target/StackFrameList.cpp @@ -569,3 +569,46 @@ StackFrameList::GetStackFrameSPForStackFramePtr (StackFrame *stack_frame_ptr) return ret_sp; } +size_t +StackFrameList::GetStatus (Stream& strm, + uint32_t first_frame, + uint32_t num_frames, + bool show_frame_info, + uint32_t num_frames_with_source, + uint32_t source_lines_before, + uint32_t source_lines_after) +{ + size_t num_frames_displayed = 0; + + if (num_frames == 0) + return 0; + + StackFrameSP frame_sp; + uint32_t frame_idx = 0; + uint32_t last_frame; + + // Don't let the last frame wrap around... + if (num_frames == UINT32_MAX) + last_frame = UINT32_MAX; + else + last_frame = first_frame + num_frames; + + for (frame_idx = first_frame; frame_idx < last_frame; ++frame_idx) + { + frame_sp = GetFrameAtIndex(frame_idx); + if (frame_sp.get() == NULL) + break; + + if (!frame_sp->GetStatus (strm, + show_frame_info, + num_frames_with_source > first_frame - frame_idx, + source_lines_before, + source_lines_after)) + break; + ++num_frames_displayed; + } + + strm.IndentLess(); + return num_frames_displayed; +} + diff --git a/lldb/source/Target/Thread.cpp b/lldb/source/Target/Thread.cpp index 384d03f5e47..9f77e61dfb8 100644 --- a/lldb/source/Target/Thread.cpp +++ b/lldb/source/Target/Thread.cpp @@ -14,6 +14,7 @@ #include "lldb/Core/Stream.h" #include "lldb/Core/StreamString.h" #include "lldb/Core/RegularExpression.h" +#include "lldb/Host/Host.h" #include "lldb/Target/DynamicLoader.h" #include "lldb/Target/ExecutionContext.h" #include "lldb/Target/ObjCLanguageRuntime.h" @@ -1100,6 +1101,63 @@ Thread::RunModeAsCString (lldb::RunMode mode) return unknown_state_string; } +size_t +Thread::GetStatus (Stream &strm, uint32_t start_frame, uint32_t num_frames, uint32_t num_frames_with_source) +{ + size_t num_frames_shown = 0; + strm.Indent(); + strm.Printf("%c ", GetProcess().GetThreadList().GetSelectedThread().get() == this ? '*' : ' '); + + StackFrameSP frame_sp = GetStackFrameAtIndex(start_frame); + SymbolContext frame_sc(frame_sp->GetSymbolContext (eSymbolContextLineEntry)); + if (frame_sc.line_entry.line != 0 && + frame_sc.line_entry.file && + GetProcess().GetTarget().GetDebugger().GetUseExternalEditor()) + { + Host::OpenFileInExternalEditor (frame_sc.line_entry.file, frame_sc.line_entry.line); + } + + DumpUsingSettingsFormat (strm, start_frame); + + if (num_frames > 0) + { + strm.IndentMore(); + + const bool show_frame_info = true; + const uint32_t source_lines_before = 3; + const uint32_t source_lines_after = 3; + num_frames_shown = GetStackFrameList ().GetStatus (strm, + start_frame, + num_frames, + show_frame_info, + num_frames_with_source, + source_lines_before, + source_lines_after); + strm.IndentLess(); + } + return num_frames_shown; +} + +size_t +Thread::GetStackFrameStatus (Stream& strm, + uint32_t first_frame, + uint32_t num_frames, + bool show_frame_info, + uint32_t num_frames_with_source, + uint32_t source_lines_before, + uint32_t source_lines_after) +{ + return GetStackFrameList().GetStatus (strm, + first_frame, + num_frames, + show_frame_info, + num_frames_with_source, + source_lines_before, + source_lines_after); +} + + + #pragma mark "Thread::SettingsController" //-------------------------------------------------------------- // class Thread::SettingsController diff --git a/lldb/test/abbreviation_tests/TestAbbreviations.py b/lldb/test/abbreviation_tests/TestAbbreviations.py index 6f46346c54d..0105ef6489b 100644 --- a/lldb/test/abbreviation_tests/TestAbbreviations.py +++ b/lldb/test/abbreviation_tests/TestAbbreviations.py @@ -23,8 +23,8 @@ class AbbreviationsTestCase(TestBase): self.runCmd("com a alias com al") self.runCmd("alias gurp help") - self.expect("gurp file", - substrs = ['Syntax: file <cmd-options> <filename>']) + self.expect("gurp target create", + substrs = ['Syntax: target create <cmd-options> <filename>']) self.runCmd("com u gurp") self.expect("gurp", COMMAND_FAILED_AS_EXPECTED, error = True, diff --git a/lldb/test/array_types/TestArrayTypes.py b/lldb/test/array_types/TestArrayTypes.py index 905319ebae0..129cef8d2c2 100644 --- a/lldb/test/array_types/TestArrayTypes.py +++ b/lldb/test/array_types/TestArrayTypes.py @@ -60,7 +60,7 @@ class ArrayTypesTestCase(TestBase): # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['state is stopped', + substrs = ['stopped', 'stop reason = breakpoint']) # The breakpoint should have a hit count of 1. diff --git a/lldb/test/bitfields/TestBitfields.py b/lldb/test/bitfields/TestBitfields.py index d5c95f2c14b..8299cf560c9 100644 --- a/lldb/test/bitfields/TestBitfields.py +++ b/lldb/test/bitfields/TestBitfields.py @@ -54,7 +54,7 @@ class BitfieldsTestCase(TestBase): # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['state is stopped', + substrs = ['stopped', 'stop reason = breakpoint']) # The breakpoint should have a hit count of 1. diff --git a/lldb/test/breakpoint_command/TestBreakpointCommand.py b/lldb/test/breakpoint_command/TestBreakpointCommand.py index 850aff5c42a..30a38428686 100644 --- a/lldb/test/breakpoint_command/TestBreakpointCommand.py +++ b/lldb/test/breakpoint_command/TestBreakpointCommand.py @@ -126,7 +126,7 @@ class BreakpointCommandTestCase(TestBase): # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['state is stopped', + substrs = ['stopped', 'stop reason = breakpoint']) # The breakpoint should have a hit count of 2. diff --git a/lldb/test/class_static/TestStaticVariables.py b/lldb/test/class_static/TestStaticVariables.py index 4e412ec4cbb..10308f9df84 100644 --- a/lldb/test/class_static/TestStaticVariables.py +++ b/lldb/test/class_static/TestStaticVariables.py @@ -54,7 +54,7 @@ class StaticVariableTestCase(TestBase): # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['state is stopped', + substrs = ['stopped', 'stop reason = breakpoint']) # On Mac OS X, gcc 4.2 emits the wrong debug info for A::g_points. diff --git a/lldb/test/class_types/TestClassTypes.py b/lldb/test/class_types/TestClassTypes.py index 6ff53726243..dd916c9d8ba 100644 --- a/lldb/test/class_types/TestClassTypes.py +++ b/lldb/test/class_types/TestClassTypes.py @@ -80,7 +80,7 @@ class ClassTypesTestCase(TestBase): # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['state is stopped', + substrs = ['stopped', 'stop reason = breakpoint']) # The breakpoint should have a hit count of 1. @@ -168,7 +168,7 @@ class ClassTypesTestCase(TestBase): # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['state is stopped', + substrs = ['stopped', 'stop reason = breakpoint']) # The breakpoint should have a hit count of 1. diff --git a/lldb/test/class_types/TestClassTypesDisassembly.py b/lldb/test/class_types/TestClassTypesDisassembly.py index 1791f16417e..67d9b53c6a4 100644 --- a/lldb/test/class_types/TestClassTypesDisassembly.py +++ b/lldb/test/class_types/TestClassTypesDisassembly.py @@ -56,7 +56,7 @@ class IterateFrameAndDisassembleTestCase(TestBase): # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['state is stopped', + substrs = ['stopped', 'stop reason = breakpoint']) # We should be stopped on the ctor function of class C. diff --git a/lldb/test/conditional_break/TestConditionalBreak.py b/lldb/test/conditional_break/TestConditionalBreak.py index 67ded569ab7..04a58412679 100644 --- a/lldb/test/conditional_break/TestConditionalBreak.py +++ b/lldb/test/conditional_break/TestConditionalBreak.py @@ -109,7 +109,7 @@ class ConditionalBreakTestCase(TestBase): # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['state is stopped', 'stop reason = breakpoint']) + substrs = ['stopped', 'stop reason = breakpoint']) # The frame info for frame #0 points to a.out`c and its immediate caller # (frame #1) points to a.out`a. diff --git a/lldb/test/dead-strip/TestDeadStrip.py b/lldb/test/dead-strip/TestDeadStrip.py index 1372c7165d5..de984d11a5c 100644 --- a/lldb/test/dead-strip/TestDeadStrip.py +++ b/lldb/test/dead-strip/TestDeadStrip.py @@ -43,7 +43,7 @@ class DeadStripTestCase(TestBase): # The stop reason of the thread should be breakpoint (breakpoint #1). self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['state is stopped', + substrs = ['stopped', 'a.out`f1', 'stop reason = breakpoint']) @@ -55,7 +55,7 @@ class DeadStripTestCase(TestBase): # The stop reason of the thread should be breakpoint (breakpoint #3). self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['state is stopped', + substrs = ['stopped', 'a.out`f3', 'stop reason = breakpoint']) diff --git a/lldb/test/enum_types/TestEnumTypes.py b/lldb/test/enum_types/TestEnumTypes.py index f5baeac75c9..d062ae15347 100644 --- a/lldb/test/enum_types/TestEnumTypes.py +++ b/lldb/test/enum_types/TestEnumTypes.py @@ -43,7 +43,7 @@ class EnumTypesTestCase(TestBase): # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['state is stopped', + substrs = ['stopped', 'stop reason = breakpoint']) # The breakpoint should have a hit count of 1. diff --git a/lldb/test/forward/TestForwardDeclaration.py b/lldb/test/forward/TestForwardDeclaration.py index 639c9bc8fbe..6f324fa86f0 100644 --- a/lldb/test/forward/TestForwardDeclaration.py +++ b/lldb/test/forward/TestForwardDeclaration.py @@ -37,7 +37,7 @@ class ForwardDeclarationTestCase(TestBase): # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['state is stopped', + substrs = ['stopped', 'stop reason = breakpoint']) # The breakpoint should have a hit count of 1. diff --git a/lldb/test/function_types/TestFunctionTypes.py b/lldb/test/function_types/TestFunctionTypes.py index b0fbd5b3f94..eb696ec2f13 100644 --- a/lldb/test/function_types/TestFunctionTypes.py +++ b/lldb/test/function_types/TestFunctionTypes.py @@ -41,7 +41,7 @@ class FunctionTypesTestCase(TestBase): # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['state is stopped', + substrs = ['stopped', 'stop reason = breakpoint']) # The breakpoint should have a hit count of 1. diff --git a/lldb/test/global_variables/TestGlobalVariables.py b/lldb/test/global_variables/TestGlobalVariables.py index b927bcb932b..4faab4001e9 100644 --- a/lldb/test/global_variables/TestGlobalVariables.py +++ b/lldb/test/global_variables/TestGlobalVariables.py @@ -41,7 +41,7 @@ class GlobalVariablesTestCase(TestBase): # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['state is stopped', + substrs = ['stopped', 'stop reason = breakpoint']) # The breakpoint should have a hit count of 1. diff --git a/lldb/test/inferior-crashing/TestInferiorCrashing.py b/lldb/test/inferior-crashing/TestInferiorCrashing.py index 9dc0e19d39b..0658023893b 100644 --- a/lldb/test/inferior-crashing/TestInferiorCrashing.py +++ b/lldb/test/inferior-crashing/TestInferiorCrashing.py @@ -41,7 +41,7 @@ class CrashingInferiorTestCase(TestBase): # The stop reason of the thread should be a bad access exception. self.expect("thread list", STOPPED_DUE_TO_EXC_BAD_ACCESS, - substrs = ['state is stopped', + substrs = ['stopped', 'stop reason = EXC_BAD_ACCESS']) # And it should report the correct line number. diff --git a/lldb/test/inlined_breakpoints/TestInlinedBreakpoints.py b/lldb/test/inlined_breakpoints/TestInlinedBreakpoints.py index 63b396da0c4..be512844a43 100644 --- a/lldb/test/inlined_breakpoints/TestInlinedBreakpoints.py +++ b/lldb/test/inlined_breakpoints/TestInlinedBreakpoints.py @@ -45,7 +45,7 @@ class InlinedBreakpointsTestCase(TestBase): # The stop reason of the thread should be breakpoint. # And it should break at basic_type.cpp:176. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['state is stopped', + substrs = ['stopped', 'stop reason = breakpoint', 'basic_type.cpp:%d' % self.line]) diff --git a/lldb/test/load_unload/TestLoadUnload.py b/lldb/test/load_unload/TestLoadUnload.py index 8dff34df47b..94fef31e4d9 100644 --- a/lldb/test/load_unload/TestLoadUnload.py +++ b/lldb/test/load_unload/TestLoadUnload.py @@ -179,7 +179,7 @@ class LoadUnloadTestCase(TestBase): # The stop reason of the thread should be breakpoint and at a_function. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['state is stopped', + substrs = ['stopped', 'a_function', 'stop reason = breakpoint']) @@ -194,7 +194,7 @@ class LoadUnloadTestCase(TestBase): # rdar://problem/8508987 # The a_function breakpoint should be encountered twice. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['state is stopped', + substrs = ['stopped', 'a_function', 'stop reason = breakpoint']) diff --git a/lldb/test/namespace/TestNamespace.py b/lldb/test/namespace/TestNamespace.py index d099a32a642..033d8400729 100644 --- a/lldb/test/namespace/TestNamespace.py +++ b/lldb/test/namespace/TestNamespace.py @@ -51,7 +51,7 @@ class NamespaceTestCase(TestBase): # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['state is stopped', + substrs = ['stopped', 'stop reason = breakpoint']) # On Mac OS X, gcc 4.2 emits the wrong debug info with respect to types. diff --git a/lldb/test/set_values/TestSetValues.py b/lldb/test/set_values/TestSetValues.py index aab09a9f617..e17eb714329 100644 --- a/lldb/test/set_values/TestSetValues.py +++ b/lldb/test/set_values/TestSetValues.py @@ -65,7 +65,7 @@ class SetValuesTestCase(TestBase): # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['state is stopped', + substrs = ['stopped', 'stop reason = breakpoint']) # The breakpoint should have a hit count of 1. diff --git a/lldb/test/signal/TestSendSignal.py b/lldb/test/signal/TestSendSignal.py index 8748de0b2ab..afd0247ec00 100644 --- a/lldb/test/signal/TestSendSignal.py +++ b/lldb/test/signal/TestSendSignal.py @@ -43,7 +43,7 @@ class SendSignalTestCase(TestBase): # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['state is stopped', + substrs = ['stopped', 'stop reason = breakpoint']) # The breakpoint should have a hit count of 1. diff --git a/lldb/test/signed_types/TestSignedTypes.py b/lldb/test/signed_types/TestSignedTypes.py index 9d045c87235..6dde6906f66 100644 --- a/lldb/test/signed_types/TestSignedTypes.py +++ b/lldb/test/signed_types/TestSignedTypes.py @@ -44,7 +44,7 @@ class UnsignedTypesTestCase(TestBase): # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['state is stopped', 'stop reason = breakpoint']) + substrs = ['stopped', 'stop reason = breakpoint']) # The breakpoint should have a hit count of 1. self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE, diff --git a/lldb/test/source-manager/TestSourceManager.py b/lldb/test/source-manager/TestSourceManager.py index dd4361d0608..7b8f3fd2fc6 100644 --- a/lldb/test/source-manager/TestSourceManager.py +++ b/lldb/test/source-manager/TestSourceManager.py @@ -85,7 +85,7 @@ class SourceManagerTestCase(TestBase): # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['state is stopped', + substrs = ['stopped', 'main.c', 'stop reason = breakpoint']) diff --git a/lldb/test/unique-types/TestUniqueTypes.py b/lldb/test/unique-types/TestUniqueTypes.py index 78646447273..7562e33263e 100644 --- a/lldb/test/unique-types/TestUniqueTypes.py +++ b/lldb/test/unique-types/TestUniqueTypes.py @@ -43,7 +43,7 @@ class UniqueTypesTestCase(TestBase): # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['state is stopped', + substrs = ['stopped', 'stop reason = breakpoint']) if self.getCompiler().endswith('clang'): diff --git a/lldb/test/unsigned_types/TestUnsignedTypes.py b/lldb/test/unsigned_types/TestUnsignedTypes.py index 185fac31d6a..9b47b66cd31 100644 --- a/lldb/test/unsigned_types/TestUnsignedTypes.py +++ b/lldb/test/unsigned_types/TestUnsignedTypes.py @@ -44,7 +44,7 @@ class UnsignedTypesTestCase(TestBase): # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['state is stopped', 'stop reason = breakpoint']) + substrs = ['stopped', 'stop reason = breakpoint']) # The breakpoint should have a hit count of 1. self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE, diff --git a/lldb/tools/driver/Driver.cpp b/lldb/tools/driver/Driver.cpp index a6a40426f93..83e42fe2e0c 100644 --- a/lldb/tools/driver/Driver.cpp +++ b/lldb/tools/driver/Driver.cpp @@ -1121,13 +1121,13 @@ Driver::MainLoop () if (m_debugger.GetDefaultArchitecture (arch_name, sizeof (arch_name))) ::snprintf (command_string, sizeof (command_string), - "file --arch=%s '%s'", + "target create --arch=%s '%s'", arch_name, m_option_data.m_args[0].c_str()); else ::snprintf (command_string, sizeof(command_string), - "file '%s'", + "target create '%s'", m_option_data.m_args[0].c_str()); m_debugger.HandleCommand (command_string); |