Added more platform support. There are now some new commands:
platform status -- gets status information for the selected platform
platform create <platform-name> -- creates a new instance of a remote platform
platform list -- list all available platforms
platform select -- select a platform instance as the current platform (not working yet)
When using "platform create" it will create a remote platform and make it the
selected platform. For instances for iPhone OS debugging on Mac OS X one can
do:
(lldb) platform create remote-ios --sdk-version=4.0
Remote platform: iOS platform
SDK version: 4.0
SDK path: "/Developer/Platforms/iPhoneOS.platform/DeviceSupport/4.0"
Not connected to a remote device.
(lldb) file ~/Documents/a.out
Current executable set to '~/Documents/a.out' (armv6).
(lldb) image list
[ 0] /Volumes/work/gclayton/Documents/devb/attach/a.out
[ 1] /Developer/Platforms/iPhoneOS.platform/DeviceSupport/4.0/Symbols/usr/lib/dyld
[ 2] /Developer/Platforms/iPhoneOS.platform/DeviceSupport/4.0/Symbols/usr/lib/libSystem.B.dylib
Note that this is all happening prior to running _or_ connecting to a remote
platform. Once connected to a remote platform the OS version might change which
means we will need to update our dependecies. Also once we run, we will need
to match up the actualy binaries with the actualy UUID's to files in the
SDK, or download and cache them locally.
This is just the start of the remote platforms, but this modification is the
first iteration in getting the platforms really doing something.
git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@127934 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Commands/CommandObjectFrame.cpp b/source/Commands/CommandObjectFrame.cpp
index 1616ecc..0bc30f4 100644
--- a/source/Commands/CommandObjectFrame.cpp
+++ b/source/Commands/CommandObjectFrame.cpp
@@ -319,7 +319,8 @@
case 'L': show_location= true; break;
case 'c': show_decl = true; break;
case 'D': debug = true; break;
- case 'f': flat_output = true; break;
+ case 'f': error = Args::StringToFormat(option_arg, format); break;
+ case 'F': flat_output = true; break;
case 'd':
max_depth = Args::StringToUInt32 (option_arg, UINT32_MAX, 0, &success);
if (!success)
@@ -367,6 +368,7 @@
flat_output = false;
max_depth = UINT32_MAX;
ptr_depth = 0;
+ format = eFormatDefault;
globals.clear();
}
@@ -393,6 +395,7 @@
flat_output:1;
uint32_t max_depth; // The depth to print when dumping concrete (not pointers) aggreate values
uint32_t ptr_depth; // The default depth that is dumped when we find pointers
+ lldb::Format format; // The format to use when dumping variables or children of variables
std::vector<ConstString> globals;
// Instance variables to hold the values for command options.
};
@@ -491,6 +494,9 @@
if (valobj_sp)
{
+ if (m_options.format != eFormatDefault)
+ valobj_sp->SetFormat (m_options.format);
+
if (m_options.show_decl && var_sp->GetDeclaration ().GetFile())
{
var_sp->GetDeclaration ().DumpStopContext (&s, false);
@@ -550,6 +556,9 @@
valobj_sp = exe_ctx.frame->GetValueObjectForFrameVariable (var_sp);
if (valobj_sp)
{
+ if (m_options.format != eFormatDefault)
+ valobj_sp->SetFormat (m_options.format);
+
if (m_options.show_decl && var_sp->GetDeclaration ().GetFile())
{
var_sp->GetDeclaration ().DumpStopContext (&s, false);
@@ -593,6 +602,9 @@
valobj_sp = exe_ctx.frame->GetValueForVariableExpressionPath (name_cstr, expr_path_options, error);
if (valobj_sp)
{
+ if (m_options.format != eFormatDefault)
+ valobj_sp->SetFormat (m_options.format);
+
if (m_options.show_decl && var_sp->GetDeclaration ().GetFile())
{
var_sp->GetDeclaration ().DumpStopContext (&s, false);
@@ -672,6 +684,9 @@
valobj_sp = exe_ctx.frame->GetValueObjectForFrameVariable (var_sp);
if (valobj_sp)
{
+ if (m_options.format != eFormatDefault)
+ valobj_sp->SetFormat (m_options.format);
+
// When dumping all variables, don't print any variables
// that are not in scope to avoid extra unneeded output
if (valobj_sp->IsInScope (exe_ctx.frame))
@@ -726,7 +741,8 @@
{ LLDB_OPT_SET_1, false, "objc", 'o', no_argument, NULL, 0, eArgTypeNone, "When looking up a variable by name, print as an Objective-C object."},
{ LLDB_OPT_SET_1, false, "ptr-depth", 'p', required_argument, NULL, 0, eArgTypeCount, "The number of pointers to be traversed when dumping values (default is zero)."},
{ LLDB_OPT_SET_1, false, "regex", 'r', no_argument, NULL, 0, eArgTypeRegularExpression, "The <variable-name> argument for name lookups are regular expressions."},
-{ LLDB_OPT_SET_1, false, "flat", 'f', no_argument, NULL, 0, eArgTypeNone, "Display results in a flat format that uses expression paths for each variable or member."},
+{ LLDB_OPT_SET_1, false, "flat", 'F', no_argument, NULL, 0, eArgTypeNone, "Display results in a flat format that uses expression paths for each variable or member."},
+{ LLDB_OPT_SET_1, false, "format", 'f', required_argument, NULL, 0, eArgTypeExprFormat, "Specify the format that the variable output should use."},
{ 0, false, NULL, 0, 0, NULL, NULL, eArgTypeNone, NULL }
};
#pragma mark CommandObjectMultiwordFrame
diff --git a/source/Commands/CommandObjectPlatform.cpp b/source/Commands/CommandObjectPlatform.cpp
new file mode 100644
index 0000000..97eb0a4
--- /dev/null
+++ b/source/Commands/CommandObjectPlatform.cpp
@@ -0,0 +1,306 @@
+//===-- CommandObjectPlatform.cpp -------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "CommandObjectPlatform.h"
+
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
+#include "lldb/Core/DataExtractor.h"
+#include "lldb/Core/Debugger.h"
+#include "lldb/Core/PluginManager.h"
+#include "lldb/Interpreter/Args.h"
+#include "lldb/Interpreter/CommandInterpreter.h"
+#include "lldb/Interpreter/CommandReturnObject.h"
+#include "lldb/Target/ExecutionContext.h"
+#include "lldb/Target/Platform.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+//----------------------------------------------------------------------
+// "platform create <platform-name>"
+//----------------------------------------------------------------------
+class CommandObjectPlatformCreate : public CommandObject
+{
+public:
+ CommandObjectPlatformCreate (CommandInterpreter &interpreter) :
+ CommandObject (interpreter,
+ "platform create",
+ "Create a platform instance by name and select it as the current platform.",
+ "platform create <platform-name>",
+ 0)
+ {
+ }
+
+ virtual
+ ~CommandObjectPlatformCreate ()
+ {
+ }
+
+ virtual bool
+ Execute (Args& args, CommandReturnObject &result)
+ {
+ Error error;
+ if (args.GetArgumentCount() == 1)
+ {
+ PlatformSP platform_sp (Platform::Create (args.GetArgumentAtIndex (0), error));
+
+ if (platform_sp)
+ {
+ m_interpreter.GetDebugger().GetPlatformList().Append (platform_sp, true);
+ if (m_options.os_version_major != UINT32_MAX)
+ {
+ platform_sp->SetOSVersion (m_options.os_version_major,
+ m_options.os_version_minor,
+ m_options.os_version_update);
+ }
+
+ platform_sp->GetStatus (result.GetOutputStream());
+ }
+ }
+ else
+ {
+ result.AppendError ("command not implemented");
+ result.SetStatus (eReturnStatusFailed);
+ }
+ return result.Succeeded();
+ }
+
+ virtual Options *
+ GetOptions ()
+ {
+ return &m_options;
+ }
+
+protected:
+
+ class CommandOptions : public Options
+ {
+ public:
+
+ CommandOptions () :
+ os_version_major (UINT32_MAX),
+ os_version_minor (UINT32_MAX),
+ os_version_update (UINT32_MAX)
+ {
+ }
+
+ virtual
+ ~CommandOptions ()
+ {
+ }
+
+ virtual Error
+ SetOptionValue (int option_idx, const char *option_arg)
+ {
+ Error error;
+ char short_option = (char) m_getopt_table[option_idx].val;
+
+ switch (short_option)
+ {
+ 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;
+ }
+
+ void
+ ResetOptionValues ()
+ {
+ os_version_major = UINT32_MAX;
+ os_version_minor = UINT32_MAX;
+ os_version_update = UINT32_MAX;
+ }
+
+ const lldb::OptionDefinition*
+ GetDefinitions ()
+ {
+ return g_option_table;
+ }
+
+ // Options table: Required for subclasses of Options.
+
+ static lldb::OptionDefinition g_option_table[];
+
+ // Instance variables to hold the values for command options.
+
+ uint32_t os_version_major;
+ uint32_t os_version_minor;
+ uint32_t os_version_update;
+ };
+ CommandOptions m_options;
+};
+
+lldb::OptionDefinition
+CommandObjectPlatformCreate::CommandOptions::g_option_table[] =
+{
+ { LLDB_OPT_SET_ALL, false, "sdk-version", 'v', required_argument, NULL, 0, eArgTypeNone, "Specify the initial SDK version to use prior to connecting." },
+ { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL }
+};
+
+//----------------------------------------------------------------------
+// "platform list"
+//----------------------------------------------------------------------
+class CommandObjectPlatformList : public CommandObject
+{
+public:
+ CommandObjectPlatformList (CommandInterpreter &interpreter) :
+ CommandObject (interpreter,
+ "platform list",
+ "List all platforms that are available.",
+ NULL,
+ 0)
+ {
+ }
+
+ virtual
+ ~CommandObjectPlatformList ()
+ {
+ }
+
+ virtual bool
+ Execute (Args& args, CommandReturnObject &result)
+ {
+ Stream &ostrm = result.GetOutputStream();
+ ostrm.Printf("Available platforms:\n");
+
+ PlatformSP host_platform_sp (Platform::GetDefaultPlatform());
+ ostrm.Printf ("%s: %s\n",
+ host_platform_sp->GetShortPluginName(),
+ host_platform_sp->GetDescription());
+
+ uint32_t idx;
+ for (idx = 0; 1; ++idx)
+ {
+ const char *plugin_name = PluginManager::GetPlatformPluginNameAtIndex (idx);
+ if (plugin_name == NULL)
+ break;
+ const char *plugin_desc = PluginManager::GetPlatformPluginDescriptionAtIndex (idx);
+ if (plugin_desc == NULL)
+ break;
+ ostrm.Printf("%s: %s\n", plugin_name, plugin_desc);
+ }
+
+ if (idx == 0)
+ {
+ result.AppendError ("no platforms are available");
+ result.SetStatus (eReturnStatusFailed);
+ }
+ return result.Succeeded();
+ }
+};
+
+//----------------------------------------------------------------------
+// "platform status"
+//----------------------------------------------------------------------
+class CommandObjectPlatformStatus : public CommandObject
+{
+public:
+ CommandObjectPlatformStatus (CommandInterpreter &interpreter) :
+ CommandObject (interpreter,
+ "platform status",
+ "Display status for the currently selected platform.",
+ NULL,
+ 0)
+ {
+ }
+
+ virtual
+ ~CommandObjectPlatformStatus ()
+ {
+ }
+
+ virtual bool
+ Execute (Args& args, CommandReturnObject &result)
+ {
+ Stream &ostrm = result.GetOutputStream();
+
+ PlatformSP selected_platform_sp (m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform());
+ if (selected_platform_sp)
+ {
+ selected_platform_sp->GetStatus (ostrm);
+ result.SetStatus (eReturnStatusSuccessFinishResult);
+ }
+ else
+ {
+ result.AppendError ("no platform us currently selected");
+ result.SetStatus (eReturnStatusFailed);
+ }
+ return result.Succeeded();
+ }
+};
+
+
+//----------------------------------------------------------------------
+// "platform select <platform-name>"
+//----------------------------------------------------------------------
+class CommandObjectPlatformSelect : public CommandObject
+{
+public:
+ CommandObjectPlatformSelect (CommandInterpreter &interpreter) :
+ CommandObject (interpreter,
+ "platform select",
+ "Select a platform by name to be the currently selected platform.",
+ "platform select <platform-name>",
+ 0)
+ {
+ }
+
+ virtual
+ ~CommandObjectPlatformSelect ()
+ {
+ }
+
+ virtual bool
+ Execute (Args& args, CommandReturnObject &result)
+ {
+ result.AppendError ("command not implemented");
+ result.SetStatus (eReturnStatusFailed);
+ return result.Succeeded();
+ }
+};
+
+
+
+//----------------------------------------------------------------------
+// CommandObjectPlatform constructor
+//----------------------------------------------------------------------
+CommandObjectPlatform::CommandObjectPlatform(CommandInterpreter &interpreter) :
+ CommandObjectMultiword (interpreter,
+ "platform",
+ "A set of commands to manage and create platforms.",
+ "platform [create|list|status|select] ...")
+{
+ LoadSubCommand ("create", CommandObjectSP (new CommandObjectPlatformCreate (interpreter)));
+ LoadSubCommand ("list" , CommandObjectSP (new CommandObjectPlatformList (interpreter)));
+ LoadSubCommand ("select", CommandObjectSP (new CommandObjectPlatformSelect (interpreter)));
+ LoadSubCommand ("status", CommandObjectSP (new CommandObjectPlatformStatus (interpreter)));
+}
+
+
+//----------------------------------------------------------------------
+// Destructor
+//----------------------------------------------------------------------
+CommandObjectPlatform::~CommandObjectPlatform()
+{
+}
diff --git a/source/Commands/CommandObjectPlatform.h b/source/Commands/CommandObjectPlatform.h
new file mode 100644
index 0000000..994052e
--- /dev/null
+++ b/source/Commands/CommandObjectPlatform.h
@@ -0,0 +1,45 @@
+//===-- CommandObjectPlatform.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_CommandObjectPlatform_h_
+#define liblldb_CommandObjectPlatform_h_
+
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
+#include "lldb/Interpreter/CommandObjectMultiword.h"
+
+namespace lldb_private {
+
+//-------------------------------------------------------------------------
+// CommandObjectPlatform
+//-------------------------------------------------------------------------
+
+class CommandObjectPlatform : public CommandObjectMultiword
+{
+public:
+ //------------------------------------------------------------------
+ // Constructors and Destructors
+ //------------------------------------------------------------------
+ CommandObjectPlatform(CommandInterpreter &interpreter);
+
+ virtual
+ ~CommandObjectPlatform();
+
+private:
+ //------------------------------------------------------------------
+ // For CommandObjectPlatform only
+ //------------------------------------------------------------------
+ DISALLOW_COPY_AND_ASSIGN (CommandObjectPlatform);
+};
+
+} // namespace lldb_private
+
+#endif // liblldb_CommandObjectPlatform_h_
diff --git a/source/Commands/CommandObjectProcess.cpp b/source/Commands/CommandObjectProcess.cpp
index 0dbc9b8..ece8fe1 100644
--- a/source/Commands/CommandObjectProcess.cpp
+++ b/source/Commands/CommandObjectProcess.cpp
@@ -523,7 +523,7 @@
const char *partial_name = NULL;
partial_name = input.GetArgumentAtIndex(opt_arg_pos);
- PlatformSP platform_sp (Platform::GetSelectedPlatform ());
+ PlatformSP platform_sp (interpeter.GetDebugger().GetPlatformList().GetSelectedPlatform ());
if (platform_sp)
{
ProcessInfoList process_infos;
@@ -703,7 +703,7 @@
if (attach_pid == LLDB_INVALID_PROCESS_ID && wait_name != NULL)
{
ProcessInfoList process_infos;
- PlatformSP platform_sp (Platform::GetSelectedPlatform ());
+ PlatformSP platform_sp (m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform ());
if (platform_sp)
{
platform_sp->FindProcessesByName (wait_name, eNameMatchEquals, process_infos);