[Lldb-commits] [lldb] r125815 - in /lldb/trunk: include/lldb/Core/PluginManager.h include/lldb/Target/Process.h include/lldb/Target/Target.h include/lldb/lldb-enumerations.h source/Core/PluginManager.cpp source/Core/UserSettingsController.cpp source/Interpreter/CommandInterpreter.cpp source/Target/Process.cpp source/Target/Target.cpp source/lldb.cpp
Greg Clayton
gclayton at apple.com
Thu Feb 17 17:44:25 PST 2011
Author: gclayton
Date: Thu Feb 17 19:44:25 2011
New Revision: 125815
URL: http://llvm.org/viewvc/llvm-project?rev=125815&view=rev
Log:
Added new target instance settings for execution settings:
Targets can now specify some additional parameters for when we debug
executables that can help with plug-in selection:
target.execution-level = auto | user | kernel
target.execution-mode = auto | dynamic | static
target.execution-os-type = auto | none | halted | live
On some systems, the binaries that are created are the same wether you use
them to debug a kernel, or a user space program. Many times inspecting an
object file can reveal what an executable should be. For these cases we can
now be a little more complete by specifying wether to detect all of these
things automatically (inspect the main executable file and select a plug-in
accordingly), or manually to force the selection of certain plug-ins.
To do this we now allow the specficifation of wether one is debugging a user
space program (target.execution-level = user) or a kernel program
(target.execution-level = kernel).
We can also specify if we want to debug a program where shared libraries
are dynamically loaded using a DynamicLoader plug-in
(target.execution-mode = dynamic), or wether we will treat all symbol files
as already linked at the correct address (target.execution-mode = static).
We can also specify if the inferior we are debugging is being debugged on
a bare board (target.execution-os-type = none), or debugging an OS where
we have a JTAG or other direct connection to the inferior stops the entire
OS (target.execution-os-type = halted), or if we are debugging a program on
something that has live debug services (target.execution-os-type = live).
For the "target.execution-os-type = halted" mode, we will need to create
ProcessHelper plug-ins that allow us to extract the process/thread and other
OS information by reading/writing memory.
This should allow LLDB to be used for a wide variety of debugging tasks and
handle them all correctly.
Modified:
lldb/trunk/include/lldb/Core/PluginManager.h
lldb/trunk/include/lldb/Target/Process.h
lldb/trunk/include/lldb/Target/Target.h
lldb/trunk/include/lldb/lldb-enumerations.h
lldb/trunk/source/Core/PluginManager.cpp
lldb/trunk/source/Core/UserSettingsController.cpp
lldb/trunk/source/Interpreter/CommandInterpreter.cpp
lldb/trunk/source/Target/Process.cpp
lldb/trunk/source/Target/Target.cpp
lldb/trunk/source/lldb.cpp
Modified: lldb/trunk/include/lldb/Core/PluginManager.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/PluginManager.h?rev=125815&r1=125814&r2=125815&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/PluginManager.h (original)
+++ lldb/trunk/include/lldb/Core/PluginManager.h Thu Feb 17 19:44:25 2011
@@ -185,6 +185,12 @@
static ProcessCreateInstance
GetProcessCreateCallbackForPluginName (const char *name);
+
+ static const char *
+ GetProcessPluginNameAtIndex (uint32_t idx);
+
+ static const char *
+ GetProcessPluginDescriptionAtIndex (uint32_t idx);
//------------------------------------------------------------------
// SymbolFile
Modified: lldb/trunk/include/lldb/Target/Process.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Process.h?rev=125815&r1=125814&r2=125815&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Process.h (original)
+++ lldb/trunk/include/lldb/Target/Process.h Thu Feb 17 19:44:25 2011
@@ -394,8 +394,6 @@
lldb::InstanceSettingsSP
CreateInstanceSettings (const char *instance_name);
- static lldb::OptionEnumValueElement g_plugins[];
-
private:
// Class-wide settings.
@@ -409,6 +407,9 @@
Initialize ();
static void
+ DidInitialize ();
+
+ static void
Terminate ();
static lldb::UserSettingsControllerSP &
Modified: lldb/trunk/include/lldb/Target/Target.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Target.h?rev=125815&r1=125814&r2=125815&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Target.h (original)
+++ lldb/trunk/include/lldb/Target/Target.h Thu Feb 17 19:44:25 2011
@@ -15,7 +15,7 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
+#include "lldb/lldb-include.h"
#include "lldb/Breakpoint/BreakpointList.h"
#include "lldb/Breakpoint/BreakpointLocationCollection.h"
#include "lldb/Core/Broadcaster.h"
@@ -32,6 +32,9 @@
namespace lldb_private {
+//----------------------------------------------------------------------
+// TargetInstanceSettings
+//----------------------------------------------------------------------
class TargetInstanceSettings : public InstanceSettings
{
public:
@@ -62,6 +65,43 @@
StringList &value,
Error *err);
+ lldb::ExecutionLevel
+ GetExecutionLevel () const
+ {
+ return m_execution_level;
+ }
+
+ void
+ SetExecutionLevel (lldb::ExecutionLevel execution_level)
+ {
+ m_execution_level = execution_level;
+ }
+
+ lldb::ExecutionMode
+ GetExecutionMode () const
+ {
+ return m_execution_mode;
+ }
+
+ void
+ SetExecutionMode (lldb::ExecutionMode execution_mode)
+ {
+ m_execution_mode = execution_mode;
+ }
+
+ lldb::ExecutionOSType
+ GetExecutionOSType () const
+ {
+ return m_execution_os_type;
+ }
+
+ void
+ SetExecutionOSType (lldb::ExecutionOSType execution_os_type)
+ {
+ m_execution_os_type = execution_os_type;
+ }
+
+
protected:
void
@@ -73,8 +113,15 @@
std::string m_expr_prefix_path;
std::string m_expr_prefix_contents;
+ lldb::ExecutionLevel m_execution_level;
+ lldb::ExecutionMode m_execution_mode;
+ lldb::ExecutionOSType m_execution_os_type;
+
};
+//----------------------------------------------------------------------
+// Target
+//----------------------------------------------------------------------
class Target :
public Broadcaster,
public ExecutionContextScope,
@@ -83,46 +130,16 @@
public:
friend class TargetList;
- class SettingsController : public UserSettingsController
+ //------------------------------------------------------------------
+ /// Broadcaster event bits definitions.
+ //------------------------------------------------------------------
+ enum
{
- public:
- SettingsController ();
-
- virtual
- ~SettingsController ();
-
- bool
- SetGlobalVariable (const ConstString &var_name,
- const char *index_value,
- const char *value,
- const SettingEntry &entry,
- const lldb::VarSetOperationType op,
- Error&err);
-
- bool
- GetGlobalVariable (const ConstString &var_name,
- StringList &value,
- Error &err);
-
- static SettingEntry global_settings_table[];
- static SettingEntry instance_settings_table[];
-
- protected:
-
- lldb::InstanceSettingsSP
- CreateInstanceSettings (const char *instance_name);
-
- static const ConstString &
- DefArchVarName ();
-
- private:
-
- // Class-wide settings.
- ArchSpec m_default_architecture;
-
- DISALLOW_COPY_AND_ASSIGN (SettingsController);
+ eBroadcastBitBreakpointChanged = (1 << 0),
+ eBroadcastBitModulesLoaded = (1 << 1),
+ eBroadcastBitModulesUnloaded = (1 << 2)
};
-
+
static void
Initialize ();
@@ -141,16 +158,6 @@
void
UpdateInstanceName ();
- //------------------------------------------------------------------
- /// Broadcaster event bits definitions.
- //------------------------------------------------------------------
- enum
- {
- eBroadcastBitBreakpointChanged = (1 << 0),
- eBroadcastBitModulesLoaded = (1 << 1),
- eBroadcastBitModulesUnloaded = (1 << 2)
- };
-
lldb::ModuleSP
GetSharedModule (const FileSpec& file_spec,
const ArchSpec& arch,
@@ -206,7 +213,6 @@
lldb::TargetSP
GetSP();
-
//------------------------------------------------------------------
// This part handles the breakpoints.
//------------------------------------------------------------------
@@ -501,6 +507,46 @@
}
+ //------------------------------------------------------------------
+ // Target::SettingsController
+ //------------------------------------------------------------------
+ class SettingsController : public UserSettingsController
+ {
+ public:
+ SettingsController ();
+
+ virtual
+ ~SettingsController ();
+
+ bool
+ SetGlobalVariable (const ConstString &var_name,
+ const char *index_value,
+ const char *value,
+ const SettingEntry &entry,
+ const lldb::VarSetOperationType op,
+ Error&err);
+
+ bool
+ GetGlobalVariable (const ConstString &var_name,
+ StringList &value,
+ Error &err);
+
+ static SettingEntry global_settings_table[];
+ static SettingEntry instance_settings_table[];
+
+ protected:
+
+ lldb::InstanceSettingsSP
+ CreateInstanceSettings (const char *instance_name);
+
+ private:
+
+ // Class-wide settings.
+ ArchSpec m_default_architecture;
+
+ DISALLOW_COPY_AND_ASSIGN (SettingsController);
+ };
+
protected:
friend class lldb::SBTarget;
Modified: lldb/trunk/include/lldb/lldb-enumerations.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-enumerations.h?rev=125815&r1=125814&r2=125815&view=diff
==============================================================================
--- lldb/trunk/include/lldb/lldb-enumerations.h (original)
+++ lldb/trunk/include/lldb/lldb-enumerations.h Thu Feb 17 19:44:25 2011
@@ -618,6 +618,60 @@
eLazyBoolYes = 1
} LazyBool;
+//------------------------------------------------------------------
+/// Execution Level
+//------------------------------------------------------------------
+typedef enum ExecutionLevel
+{
+ eExecutionLevelAuto, // Automatically detect how to run an executable
+ eExecutionLevelKernel, // Execute a program as a kernel executable
+ eExecutionLevelUser // Execute a program as a user space executable
+} ExecutionLevel;
+
+
+//------------------------------------------------------------------
+/// Execution mode
+//------------------------------------------------------------------
+typedef enum ExecutionMode
+{
+ // Automatically detect the execution mode
+ eExecutionModeAuto,
+
+ // Execute with no shared libraries, everything is where the executable
+ // files say they are (file addresses == load addresses)
+ eExecutionModeStatic,
+
+ // Execute with shared libraries using a dynamic loader plug-in to
+ // detect when shared libraries are loaded/unloaded.
+ eExecutionModeDynamic
+
+} ExecutionMode;
+
+//------------------------------------------------------------------
+/// Execution OS
+//------------------------------------------------------------------
+typedef enum ExecutionOSType
+{
+ // Automatically detect the execution operating system
+ eExecutionOSTypeAuto,
+
+ // There is no operating system (no processes or threads).
+ eExecutionOSTypeNone,
+
+ // There is an OS, but when we execution stops, the entire OS is halted
+ // (common when debugging in eExecutionLevelKernel modes). Processes and
+ // threads can be queried, selected and switched between using memory
+ // reads/writes using a ProcessHelper plug-in (which has yet to be
+ // designed).
+ eExecutionOSTypeHalted,
+
+ // There is live OS with debug services that we can talk to for process,
+ // thread, and other OS queries.
+ eExecutionOSTypeLive
+
+} ExecutionOSType;
+
+
} // namespace lldb
Modified: lldb/trunk/source/Core/PluginManager.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/PluginManager.cpp?rev=125815&r1=125814&r2=125815&view=diff
==============================================================================
--- lldb/trunk/source/Core/PluginManager.cpp (original)
+++ lldb/trunk/source/Core/PluginManager.cpp Thu Feb 17 19:44:25 2011
@@ -1278,6 +1278,24 @@
return false;
}
+const char *
+PluginManager::GetProcessPluginNameAtIndex (uint32_t idx)
+{
+ ProcessInstance instance;
+ if (AccessProcessInstances (ePluginGetInstanceAtIndex, instance, idx))
+ return instance.name.c_str();
+ return NULL;
+}
+
+const char *
+PluginManager::GetProcessPluginDescriptionAtIndex (uint32_t idx)
+{
+ ProcessInstance instance;
+ if (AccessProcessInstances (ePluginGetInstanceAtIndex, instance, idx))
+ return instance.description.c_str();
+ return NULL;
+}
+
bool
PluginManager::UnregisterPlugin (ProcessCreateInstance create_callback)
{
Modified: lldb/trunk/source/Core/UserSettingsController.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/UserSettingsController.cpp?rev=125815&r1=125814&r2=125815&view=diff
==============================================================================
--- lldb/trunk/source/Core/UserSettingsController.cpp (original)
+++ lldb/trunk/source/Core/UserSettingsController.cpp Thu Feb 17 19:44:25 2011
@@ -17,10 +17,56 @@
#include "lldb/Core/StreamString.h"
#include "lldb/Interpreter/CommandInterpreter.h"
+using namespace lldb;
using namespace lldb_private;
+static void
+DumpSettingEntry (CommandInterpreter &interpreter,
+ StreamString &result_stream,
+ const uint32_t max_len,
+ const SettingEntry &entry)
+{
+ StreamString description;
+
+ if (entry.description)
+ description.Printf ("%s", entry.description);
+
+ if (entry.default_value && entry.default_value[0])
+ description.Printf (" (default: %s)", entry.default_value);
+
+ interpreter.OutputFormattedHelpText (result_stream,
+ entry.var_name,
+ "--",
+ description.GetData(),
+ max_len);
+
+ if (entry.enum_values && entry.enum_values[0].string_value)
+ {
+ interpreter.OutputFormattedHelpText (result_stream,
+ "",
+ " ",
+ "Enumeration values:",
+ max_len);
+ for (uint32_t enum_idx=0; entry.enum_values[enum_idx].string_value != NULL; ++enum_idx)
+ {
+ description.Clear();
+ if (entry.enum_values[enum_idx].usage)
+ description.Printf ("%s = %s",
+ entry.enum_values[enum_idx].string_value,
+ entry.enum_values[enum_idx].usage);
+ else
+ description.Printf ("%s", entry.enum_values[enum_idx].string_value);
+ interpreter.OutputFormattedHelpText (result_stream,
+ "",
+ " ",
+ description.GetData(),
+ max_len);
+ }
+ }
+}
+
UserSettingsController::UserSettingsController (const char *level_name,
- const lldb::UserSettingsControllerSP &parent) :
+ const UserSettingsControllerSP &parent) :
m_default_settings (),
m_settings (),
m_children (),
@@ -46,7 +92,7 @@
const char *index_value,
const char *value,
const SettingEntry &entry,
- const lldb::VarSetOperationType op,
+ const VarSetOperationType op,
Error &err
)
{
@@ -66,11 +112,11 @@
}
bool
-UserSettingsController::InitializeSettingsController (lldb::UserSettingsControllerSP &controller_sp,
+UserSettingsController::InitializeSettingsController (UserSettingsControllerSP &controller_sp,
SettingEntry *global_settings,
SettingEntry *instance_settings)
{
- const lldb::UserSettingsControllerSP &parent = controller_sp->GetParent ();
+ const UserSettingsControllerSP &parent = controller_sp->GetParent ();
if (parent)
parent->RegisterChild (controller_sp);
@@ -84,9 +130,9 @@
}
void
-UserSettingsController::FinalizeSettingsController (lldb::UserSettingsControllerSP &controller_sp)
+UserSettingsController::FinalizeSettingsController (UserSettingsControllerSP &controller_sp)
{
- const lldb::UserSettingsControllerSP &parent = controller_sp->GetParent ();
+ const UserSettingsControllerSP &parent = controller_sp->GetParent ();
if (parent)
parent->RemoveChild (controller_sp);
}
@@ -100,7 +146,7 @@
num_entries = m_settings.global_settings.size();
for (int i = 0; i < num_entries; ++i)
{
- SettingEntry &entry = m_settings.global_settings[i];
+ const SettingEntry &entry = m_settings.global_settings[i];
if (entry.default_value != NULL)
{
StreamString full_name;
@@ -108,30 +154,19 @@
full_name.Printf ("%s.%s", prefix, entry.var_name);
else
full_name.Printf ("%s", entry.var_name);
- SetVariable (full_name.GetData(), entry.default_value, lldb::eVarSetOperationAssign, false, "");
- }
- else if ((entry.var_type == lldb::eSetVarTypeEnum)
- && (entry.enum_values != NULL))
- {
- StreamString full_name;
- if (prefix[0] != '\0')
- full_name.Printf ("%s.%s", prefix, entry.var_name);
- else
- full_name.Printf ("%s", entry.var_name);
- SetVariable (full_name.GetData(), entry.enum_values[0].string_value, lldb::eVarSetOperationAssign,
- false, "");
+ SetVariable (full_name.GetData(), entry.default_value, eVarSetOperationAssign, false, "");
}
}
}
-const lldb::UserSettingsControllerSP &
+const UserSettingsControllerSP &
UserSettingsController::GetParent ()
{
return m_settings.parent;
}
void
-UserSettingsController::RegisterChild (const lldb::UserSettingsControllerSP &child)
+UserSettingsController::RegisterChild (const UserSettingsControllerSP &child)
{
Mutex::Locker locker (m_children_mutex);
@@ -161,13 +196,13 @@
return m_children.size();
}
-const lldb::UserSettingsControllerSP
+const UserSettingsControllerSP
UserSettingsController::GetChildAtIndex (size_t index)
{
if (index < m_children.size())
return m_children[index];
- lldb::UserSettingsControllerSP dummy_value;
+ UserSettingsControllerSP dummy_value;
return dummy_value;
}
@@ -178,7 +213,7 @@
for (int i = 0; i < m_settings.global_settings.size(); ++i)
{
- SettingEntry &entry = m_settings.global_settings[i];
+ const SettingEntry &entry = m_settings.global_settings[i];
ConstString entry_name (entry.var_name);
if (entry_name == var_name)
return &entry;
@@ -205,7 +240,7 @@
void
UserSettingsController::BuildParentPrefix (std::string &parent_prefix)
{
- lldb::UserSettingsControllerSP parent = GetParent();
+ UserSettingsControllerSP parent = GetParent();
if (parent.get() != NULL)
{
parent->BuildParentPrefix (parent_prefix);
@@ -216,14 +251,14 @@
}
void
-UserSettingsController::RemoveChild (const lldb::UserSettingsControllerSP &child)
+UserSettingsController::RemoveChild (const UserSettingsControllerSP &child)
{
Mutex::Locker locker (m_children_mutex);
- std::vector<lldb::UserSettingsControllerSP>::iterator pos, end = m_children.end();
+ std::vector<UserSettingsControllerSP>::iterator pos, end = m_children.end();
for (pos = m_children.begin(); pos != end; ++pos)
{
- lldb::UserSettingsControllerSP entry = *pos;
+ UserSettingsControllerSP entry = *pos;
if (entry == child)
{
m_children.erase (pos);
@@ -235,7 +270,7 @@
Error
UserSettingsController::SetVariable (const char *full_dot_name,
const char *value,
- const lldb::VarSetOperationType op,
+ const VarSetOperationType op,
const bool override,
const char *debugger_instance_name,
const char *index_value)
@@ -285,9 +320,9 @@
return err;
if ((value == NULL || value[0] == '\0')
- && (op == lldb::eVarSetOperationAssign))
+ && (op == eVarSetOperationAssign))
{
- if (entry->var_type != lldb::eSetVarTypeEnum)
+ if (entry->var_type != eSetVarTypeEnum)
value = entry->default_value;
else
value = entry->enum_values[0].string_value;
@@ -313,9 +348,9 @@
return err;
if ((value == NULL || value[0] == '\0')
- && (op == lldb::eVarSetOperationAssign))
+ && (op == eVarSetOperationAssign))
{
- if (entry->var_type != lldb::eSetVarTypeEnum)
+ if (entry->var_type != eSetVarTypeEnum)
value = entry->default_value;
else
value = entry->enum_values[0].string_value;
@@ -348,11 +383,11 @@
OverrideAllInstances (const_var_name, value, op, index_value, err);
// Update all pending records as well.
-// std::map<std::string, lldb::InstanceSettingsSP>::iterator pos, end = m_pending_settings.end();
+// std::map<std::string, InstanceSettingsSP>::iterator pos, end = m_pending_settings.end();
// for (pos = m_pending_settings.begin(); pos != end; end++)
// {
// const ConstString instance_name (pos->first.c_str());
-// lldb::InstanceSettingsSP setting_sp = pos->second;
+// InstanceSettingsSP setting_sp = pos->second;
// setting_sp->UpdateInstanceSettingsVariable (const_var_name, index_value, value,
// instance_name, *entry, op, err, true);
// }
@@ -399,9 +434,9 @@
return err;
if ((value == NULL || value[0] == '\0')
- && (op == lldb::eVarSetOperationAssign))
+ && (op == eVarSetOperationAssign))
{
- if (entry->var_type != lldb::eSetVarTypeEnum)
+ if (entry->var_type != eSetVarTypeEnum)
value = entry->default_value;
else
value = entry->enum_values[0].string_value;
@@ -421,7 +456,7 @@
else
{
// Instance does not currently exist; make or update a pending setting for it.
- lldb::InstanceSettingsSP current_settings_sp = PendingSettingsForInstance (instance_name);
+ InstanceSettingsSP current_settings_sp = PendingSettingsForInstance (instance_name);
// Now we have a settings record, update it appropriately.
@@ -438,12 +473,12 @@
OverrideAllInstances (const_var_name, value, op, index_value, err);
// Update all pending records as well.
- std::map<std::string, lldb::InstanceSettingsSP>::iterator pos;
- std::map<std::string, lldb::InstanceSettingsSP>::iterator end = m_pending_settings.end();
+ std::map<std::string, InstanceSettingsSP>::iterator pos;
+ std::map<std::string, InstanceSettingsSP>::iterator end = m_pending_settings.end();
for (pos = m_pending_settings.begin(); pos != end; end++)
{
const ConstString tmp_inst_name (pos->first.c_str());
- lldb::InstanceSettingsSP setting_sp = pos->second;
+ InstanceSettingsSP setting_sp = pos->second;
setting_sp->UpdateInstanceSettingsVariable (const_var_name, index_value, value,
tmp_inst_name, *entry, op, err, true);
}
@@ -453,7 +488,7 @@
else
{
// A child setting.
- lldb::UserSettingsControllerSP child;
+ UserSettingsControllerSP child;
ConstString child_prefix (names.GetArgumentAtIndex (0));
int num_children = GetNumChildren();
bool found = false;
@@ -497,7 +532,7 @@
UserSettingsController::GetVariable
(
const char *full_dot_name,
- lldb::SettableVariableType &var_type,
+ SettableVariableType &var_type,
const char *debugger_instance_name,
Error &err
)
@@ -528,7 +563,7 @@
// Should we pass this off to a child? If there is more than one name piece left, and the next name piece
// matches a child prefix, then yes.
- lldb::UserSettingsControllerSP child;
+ UserSettingsControllerSP child;
if (names.GetArgumentCount() > 1)
{
ConstString child_prefix (names.GetArgumentAtIndex (0));
@@ -570,12 +605,12 @@
// Look for instance name setting in pending settings.
std::string inst_name_str = instance_name.AsCString();
- std::map<std::string, lldb::InstanceSettingsSP>::iterator pos;
+ std::map<std::string, InstanceSettingsSP>::iterator pos;
pos = m_pending_settings.find (inst_name_str);
if (pos != m_pending_settings.end())
{
- lldb::InstanceSettingsSP settings_sp = pos->second;
+ InstanceSettingsSP settings_sp = pos->second;
settings_sp->GetInstanceSettingsValue (*instance_entry, const_var_name, value, &err);
}
else
@@ -655,16 +690,16 @@
tmp_name.Printf ("%s", instance_name.AsCString());
std::string instance_name_str (tmp_name.GetData());
- std::map<std::string, lldb::InstanceSettingsSP>::iterator pos;
+ std::map<std::string, InstanceSettingsSP>::iterator pos;
Mutex::Locker locker (m_pending_settings_mutex);
m_pending_settings.erase (instance_name_str);
}
-const lldb::InstanceSettingsSP &
+const InstanceSettingsSP &
UserSettingsController::FindPendingSettings (const ConstString &instance_name)
{
- std::map<std::string, lldb::InstanceSettingsSP>::iterator pos;
+ std::map<std::string, InstanceSettingsSP>::iterator pos;
StreamString tmp_name;
// Add surrounding brackets to instance name if not already present.
@@ -698,16 +733,16 @@
ConstString var_name (entry.var_name);
const char *value = entry.default_value;
- if (entry.var_type == lldb::eSetVarTypeEnum)
+ if (entry.var_type == eSetVarTypeEnum)
value = entry.enum_values[0].string_value;
m_default_settings->UpdateInstanceSettingsVariable (var_name, NULL, value, default_name, entry,
- lldb::eVarSetOperationAssign, err, true);
+ eVarSetOperationAssign, err, true);
}
}
void
-UserSettingsController::CopyDefaultSettings (const lldb::InstanceSettingsSP &actual_settings,
+UserSettingsController::CopyDefaultSettings (const InstanceSettingsSP &actual_settings,
const ConstString &instance_name,
bool pending)
{
@@ -733,27 +768,27 @@
}
actual_settings->UpdateInstanceSettingsVariable (var_name, NULL, value_str.c_str(), instance_name, entry,
- lldb::eVarSetOperationAssign, err, pending);
+ eVarSetOperationAssign, err, pending);
}
}
-lldb::InstanceSettingsSP
+InstanceSettingsSP
UserSettingsController::PendingSettingsForInstance (const ConstString &instance_name)
{
std::string name_str (instance_name.AsCString());
- std::map<std::string, lldb::InstanceSettingsSP>::iterator pos;
+ std::map<std::string, InstanceSettingsSP>::iterator pos;
Mutex::Locker locker (m_pending_settings_mutex);
pos = m_pending_settings.find (name_str);
if (pos != m_pending_settings.end())
{
- lldb::InstanceSettingsSP settings_sp = pos->second;
+ InstanceSettingsSP settings_sp = pos->second;
return settings_sp;
}
else
{
- lldb::InstanceSettingsSP new_settings_sp = CreateInstanceSettings (instance_name.AsCString());
+ InstanceSettingsSP new_settings_sp = CreateInstanceSettings (instance_name.AsCString());
CopyDefaultSettings (new_settings_sp, instance_name, true);
m_pending_settings[name_str] = new_settings_sp;
return new_settings_sp;
@@ -761,7 +796,7 @@
// Should never reach this line.
- lldb::InstanceSettingsSP dummy;
+ InstanceSettingsSP dummy;
return dummy;
}
@@ -789,9 +824,9 @@
{
for (int j = 0; j < tmp_value.GetSize(); ++j)
{
- if (entry.var_type == lldb::eSetVarTypeArray)
+ if (entry.var_type == eSetVarTypeArray)
value_string.Printf ("\n [%d]: '%s'", j, tmp_value.GetStringAtIndex (j));
- else if (entry.var_type == lldb::eSetVarTypeDictionary)
+ else if (entry.var_type == eSetVarTypeDictionary)
value_string.Printf ("\n '%s'", tmp_value.GetStringAtIndex (j));
}
multi_value = true;
@@ -812,7 +847,7 @@
void
UserSettingsController::GetAllPendingSettingValues (StreamString &result_stream)
{
- std::map<std::string, lldb::InstanceSettingsSP>::iterator pos;
+ std::map<std::string, InstanceSettingsSP>::iterator pos;
std::string parent_prefix;
BuildParentPrefix (parent_prefix);
@@ -821,7 +856,7 @@
for (pos = m_pending_settings.begin(); pos != m_pending_settings.end(); ++pos)
{
std::string tmp_name = pos->first;
- lldb::InstanceSettingsSP settings_sp = pos->second;
+ InstanceSettingsSP settings_sp = pos->second;
const ConstString instance_name (tmp_name.c_str());
@@ -929,7 +964,7 @@
void
UserSettingsController::OverrideAllInstances (const ConstString &var_name,
const char *value,
- lldb::VarSetOperationType op,
+ VarSetOperationType op,
const char *index_value,
Error &err)
{
@@ -1018,23 +1053,23 @@
}
const char *
-UserSettingsController::GetTypeString (lldb::SettableVariableType var_type)
+UserSettingsController::GetTypeString (SettableVariableType var_type)
{
switch (var_type)
{
- case lldb::eSetVarTypeInt:
+ case eSetVarTypeInt:
return "int";
- case lldb::eSetVarTypeBoolean:
+ case eSetVarTypeBoolean:
return "boolean";
- case lldb::eSetVarTypeString:
+ case eSetVarTypeString:
return "string";
- case lldb::eSetVarTypeArray:
+ case eSetVarTypeArray:
return "array";
- case lldb::eSetVarTypeDictionary:
+ case eSetVarTypeDictionary:
return "dictionary";
- case lldb::eSetVarTypeEnum:
+ case eSetVarTypeEnum:
return "enum";
- case lldb::eSetVarTypeNone:
+ case eSetVarTypeNone:
return "no type";
}
@@ -1042,7 +1077,7 @@
}
void
-UserSettingsController::PrintEnumValues (const lldb::OptionEnumValueElement *enum_values, Stream &str)
+UserSettingsController::PrintEnumValues (const OptionEnumValueElement *enum_values, Stream &str)
{
int i = 0;
while (enum_values[i].string_value != NULL)
@@ -1055,7 +1090,7 @@
void
UserSettingsController::FindAllSettingsDescriptions (CommandInterpreter &interpreter,
- lldb::UserSettingsControllerSP root,
+ UserSettingsControllerSP root,
std::string ¤t_prefix,
StreamString &result_stream,
Error &err)
@@ -1063,11 +1098,9 @@
// Write out current prefix line.
StreamString prefix_line;
StreamString description;
- uint32_t max_len;
+ uint32_t max_len = FindMaxNameLength (root->m_settings.global_settings);
int num_entries = root->m_settings.global_settings.size();
- max_len = FindMaxNameLength (root->m_settings.global_settings);
-
if (! current_prefix.empty())
result_stream.Printf ("\n'%s' variables:\n\n", current_prefix.c_str());
else
@@ -1078,24 +1111,7 @@
// Write out all "global" variables.
for (int i = 0; i < num_entries; ++i)
{
- SettingEntry entry = root->m_settings.global_settings[i];
- description.Clear();
- if (entry.var_type == lldb::eSetVarTypeEnum)
- {
- StreamString enum_values_str;
- UserSettingsController::PrintEnumValues (entry.enum_values, enum_values_str);
- description.Printf ("[static, enum] %s. Valid values: {%s} (default: '%s')", entry.description,
- enum_values_str.GetData(), entry.enum_values[0].string_value);
- }
- else if (entry.default_value != NULL)
- description.Printf ("[static, %s] %s (default: '%s')", GetTypeString (entry.var_type),
- entry.description, entry.default_value);
-
- else
- description.Printf ("[static, %s] %s (default: '')", GetTypeString (entry.var_type),
- entry.description);
- interpreter.OutputFormattedHelpText (result_stream, entry.var_name, "--", description.GetData(),
- max_len);
+ DumpSettingEntry (interpreter, result_stream, max_len, root->m_settings.global_settings[i]);
}
}
@@ -1107,32 +1123,15 @@
// Write out all instance variables.
for (int i = 0; i < num_entries; ++i)
{
- SettingEntry entry = root->m_settings.instance_settings[i];
- description.Clear();
- if (entry.var_type == lldb::eSetVarTypeEnum)
- {
- StreamString enum_values_str;
- UserSettingsController::PrintEnumValues (entry.enum_values, enum_values_str);
- description.Printf ("[instance, enum] %s. Valid values: {%s} (default: '%s')", entry.description,
- enum_values_str.GetData(), entry.enum_values[0].string_value);
- }
- else if (entry.default_value != NULL)
- description.Printf ("[instance, %s] %s (default: '%s')", GetTypeString (entry.var_type),
- entry.description, entry.default_value);
- else
- description.Printf ("[instance, %s] %s (default: '')", GetTypeString (entry.var_type),
- entry.description);
- interpreter.OutputFormattedHelpText (result_stream, entry.var_name, "--", description.GetData(),
- max_len);
+ DumpSettingEntry (interpreter, result_stream, max_len, root->m_settings.instance_settings[i]);
}
-
}
// Now, recurse across all children.
int num_children = root->GetNumChildren();
for (int i = 0; i < num_children; ++i)
{
- lldb::UserSettingsControllerSP child = root->GetChildAtIndex (i);
+ UserSettingsControllerSP child = root->GetChildAtIndex (i);
if (child)
{
@@ -1143,7 +1142,10 @@
else
new_prefix.Printf ("%s", child_prefix.AsCString());
std::string new_prefix_str = new_prefix.GetData();
- UserSettingsController::FindAllSettingsDescriptions (interpreter, child, new_prefix_str, result_stream,
+ UserSettingsController::FindAllSettingsDescriptions (interpreter,
+ child,
+ new_prefix_str,
+ result_stream,
err);
}
}
@@ -1151,7 +1153,7 @@
void
UserSettingsController::FindSettingsDescriptions (CommandInterpreter &interpreter,
- lldb::UserSettingsControllerSP root,
+ UserSettingsControllerSP root,
std::string ¤t_prefix,
const char *search_name,
StreamString &result_stream,
@@ -1198,23 +1200,7 @@
// Write out all "global" variables.
for (int i = 0; i < num_entries; ++i)
{
- SettingEntry entry = root->m_settings.global_settings[i];
- description.Clear();
- if (entry.var_type == lldb::eSetVarTypeEnum)
- {
- StreamString enum_values_str;
- UserSettingsController::PrintEnumValues (entry.enum_values, enum_values_str);
- description.Printf ("[static, enum] %s. Valid values: {%s} (default: '%s')", entry.description,
- enum_values_str.GetData(), entry.enum_values[0].string_value);
- }
- else if (entry.default_value != NULL)
- description.Printf ("[static, %s] %s (default: '%s')", GetTypeString (entry.var_type),
- entry.description, entry.default_value);
- else
- description.Printf ("[static, %s] %s (default: '')", GetTypeString (entry.var_type),
- entry.description);
- interpreter.OutputFormattedHelpText (result_stream, entry.var_name, "--", description.GetData(),
- max_len);
+ DumpSettingEntry (interpreter, result_stream, max_len, root->m_settings.global_settings[i]);
}
}
@@ -1226,23 +1212,7 @@
// Write out all instance variables.
for (int i = 0; i < num_entries; ++i)
{
- SettingEntry entry = root->m_settings.instance_settings[i];
- description.Clear();
- if (entry.var_type == lldb::eSetVarTypeEnum)
- {
- StreamString enum_values_str;
- UserSettingsController::PrintEnumValues (entry.enum_values, enum_values_str);
- description.Printf ("[instance, enum] %s. Valid values: {%s} (default: '%s')", entry.description,
- enum_values_str.GetData(), entry.enum_values[0].string_value);
- }
- else if (entry.default_value != NULL)
- description.Printf ("[instance, %s] %s (default: '%s')", GetTypeString (entry.var_type),
- entry.description, entry.default_value);
- else
- description.Printf ("[instance, %s] %s (default: '')", GetTypeString (entry.var_type),
- entry.description);
- interpreter.OutputFormattedHelpText (result_stream, entry.var_name, "--", description.GetData(),
- max_len);
+ DumpSettingEntry (interpreter, result_stream, max_len, root->m_settings.instance_settings[i]);
}
}
}
@@ -1261,28 +1231,7 @@
// Check to see if it is a global or instance variable name.
if (setting_entry != NULL)
{
- StreamString description;
- if (setting_entry->var_type == lldb::eSetVarTypeEnum)
- {
- StreamString enum_values_str;
- UserSettingsController::PrintEnumValues (setting_entry->enum_values, enum_values_str);
- description.Printf ("[%s, enum] %s. Valid values: {%s} (default: '%s')",
- (is_global ? "static" : "instance"),
- setting_entry->description,
- enum_values_str.GetData(), setting_entry->enum_values[0].string_value);
- }
- else if (setting_entry->default_value != NULL)
- description.Printf ("[%s, %s] %s (default: '%s')",
- (is_global ? "static" : "instance"),
- GetTypeString (setting_entry->var_type),
- setting_entry->description, setting_entry->default_value);
- else
- description.Printf ("[%s, %s] %s (default: '')",
- (is_global ? "static" : "instance"),
- GetTypeString (setting_entry->var_type),
- setting_entry->description);
- interpreter.OutputFormattedHelpText (result_stream, setting_entry->var_name, "--", description.GetData(),
- var_name.GetLength());
+ DumpSettingEntry (interpreter, result_stream, var_name.GetLength(), *setting_entry);
}
else
{
@@ -1291,15 +1240,19 @@
bool found = false;
for (int i = 0; i < num_children && !found; ++i)
{
- lldb::UserSettingsControllerSP child = root->GetChildAtIndex (i);
+ UserSettingsControllerSP child = root->GetChildAtIndex (i);
if (child)
{
ConstString child_prefix = child->GetLevelName();
if (child_prefix == var_name)
{
found = true;
- UserSettingsController::FindSettingsDescriptions (interpreter, child, current_prefix,
- var_name.AsCString(), result_stream, err);
+ UserSettingsController::FindSettingsDescriptions (interpreter,
+ child,
+ current_prefix,
+ var_name.AsCString(),
+ result_stream,
+ err);
}
}
}
@@ -1329,7 +1282,7 @@
bool found = false;
for (int i = 0; i < num_children && !found; ++i)
{
- lldb::UserSettingsControllerSP child = root->GetChildAtIndex (i);
+ UserSettingsControllerSP child = root->GetChildAtIndex (i);
if (child)
{
ConstString child_prefix = child->GetLevelName();
@@ -1354,7 +1307,7 @@
void
UserSettingsController::SearchAllSettingsDescriptions (CommandInterpreter &interpreter,
- lldb::UserSettingsControllerSP root,
+ UserSettingsControllerSP root,
std::string ¤t_prefix,
const char *search_word,
StreamString &result_stream)
@@ -1368,7 +1321,7 @@
{
for (int i = 0; i < num_entries; ++i)
{
- SettingEntry &entry = root->m_settings.global_settings[i];
+ const SettingEntry &entry = root->m_settings.global_settings[i];
if (strcasestr (entry.description, search_word) != NULL)
{
StreamString var_name;
@@ -1404,7 +1357,7 @@
int num_children = root->GetNumChildren ();
for (int i = 0; i < num_children; ++i)
{
- lldb::UserSettingsControllerSP child = root->GetChildAtIndex (i);
+ UserSettingsControllerSP child = root->GetChildAtIndex (i);
if (child)
{
@@ -1423,20 +1376,20 @@
void
UserSettingsController::GetAllVariableValues (CommandInterpreter &interpreter,
- lldb::UserSettingsControllerSP root,
+ UserSettingsControllerSP root,
std::string ¤t_prefix,
StreamString &result_stream,
Error &err)
{
StreamString description;
int num_entries = root->m_settings.global_settings.size();
- lldb::SettableVariableType var_type;
+ SettableVariableType var_type;
for (int i = 0; i < num_entries; ++i)
{
StreamString full_var_name;
- SettingEntry entry = root->m_settings.global_settings[i];
+ const SettingEntry &entry = root->m_settings.global_settings[i];
if (! current_prefix.empty())
full_var_name.Printf ("%s.%s", current_prefix.c_str(), entry.var_name);
else
@@ -1451,9 +1404,9 @@
{
description.Printf ("%s (%s):\n", full_var_name.GetData(), GetTypeString (entry.var_type));
for (int j = 0; j < value.GetSize(); ++j)
- if (entry.var_type == lldb::eSetVarTypeArray)
+ if (entry.var_type == eSetVarTypeArray)
description.Printf (" [%d]: '%s'\n", j, value.GetStringAtIndex (j));
- else if (entry.var_type == lldb::eSetVarTypeDictionary)
+ else if (entry.var_type == eSetVarTypeDictionary)
description.Printf (" '%s'\n", value.GetStringAtIndex (j));
}
@@ -1470,7 +1423,7 @@
int num_children = root->GetNumChildren();
for (int i = 0; i < num_children; ++i)
{
- lldb::UserSettingsControllerSP child = root->GetChildAtIndex (i);
+ UserSettingsControllerSP child = root->GetChildAtIndex (i);
if (child)
{
@@ -1525,7 +1478,7 @@
}
int
-UserSettingsController::CompleteSettingsValue (lldb::UserSettingsControllerSP root_settings,
+UserSettingsController::CompleteSettingsValue (UserSettingsControllerSP root_settings,
const char *full_dot_name,
const char *partial_value,
bool &word_complete,
@@ -1605,9 +1558,9 @@
if (entry == NULL)
return 0;
- if (entry->var_type == lldb::eSetVarTypeBoolean)
+ if (entry->var_type == eSetVarTypeBoolean)
return UserSettingsController::BooleanMatches (partial_value, word_complete, matches);
- else if (entry->var_type == lldb::eSetVarTypeEnum)
+ else if (entry->var_type == eSetVarTypeEnum)
return UserSettingsController::EnumMatches (partial_value, entry->enum_values, word_complete, matches);
else
return 0;
@@ -1647,7 +1600,7 @@
int
UserSettingsController::EnumMatches (const char *partial_value,
- lldb::OptionEnumValueElement *enum_values,
+ OptionEnumValueElement *enum_values,
bool &word_complete,
StringList &matches)
{
@@ -1676,7 +1629,7 @@
}
int
-UserSettingsController::CompleteSettingsNames (lldb::UserSettingsControllerSP root_settings,
+UserSettingsController::CompleteSettingsNames (UserSettingsControllerSP root_settings,
Args &partial_setting_name_pieces,
bool &word_complete,
StringList &matches)
@@ -1835,7 +1788,7 @@
for (size_t i = 0; i < m_settings.global_settings.size(); ++i)
{
- SettingEntry &entry = m_settings.global_settings[i];
+ const SettingEntry &entry = m_settings.global_settings[i];
std::string var_name (entry.var_name);
if ((partial_len == 0)
|| ((partial_len <= var_name.length())
@@ -1964,16 +1917,16 @@
}
void
-UserSettingsController::VerifyOperationForType (lldb::SettableVariableType var_type,
- lldb::VarSetOperationType op,
+UserSettingsController::VerifyOperationForType (SettableVariableType var_type,
+ VarSetOperationType op,
const ConstString &var_name,
Error &err)
{
- if (op == lldb::eVarSetOperationAssign)
+ if (op == eVarSetOperationAssign)
return;
- if (op == lldb::eVarSetOperationInvalid)
+ if (op == eVarSetOperationInvalid)
{
err.SetErrorString ("Invalid 'settings ' subcommand operation.\n");
return;
@@ -1981,23 +1934,23 @@
switch (op)
{
- case lldb::eVarSetOperationInsertBefore:
- case lldb::eVarSetOperationInsertAfter:
- if (var_type != lldb::eSetVarTypeArray)
+ case eVarSetOperationInsertBefore:
+ case eVarSetOperationInsertAfter:
+ if (var_type != eSetVarTypeArray)
err.SetErrorString ("Invalid operation: This operation can only be performed on array variables.\n");
break;
- case lldb::eVarSetOperationReplace:
- case lldb::eVarSetOperationRemove:
- if ((var_type != lldb::eSetVarTypeArray)
- && (var_type != lldb::eSetVarTypeDictionary))
+ case eVarSetOperationReplace:
+ case eVarSetOperationRemove:
+ if ((var_type != eSetVarTypeArray)
+ && (var_type != eSetVarTypeDictionary))
err.SetErrorString ("Invalid operation: This operation can only be performed on array or dictionary"
" variables.\n");
break;
- case lldb::eVarSetOperationAppend:
- case lldb::eVarSetOperationClear:
- if ((var_type != lldb::eSetVarTypeArray)
- && (var_type != lldb::eSetVarTypeDictionary)
- && (var_type != lldb::eSetVarTypeString))
+ case eVarSetOperationAppend:
+ case eVarSetOperationClear:
+ if ((var_type != eSetVarTypeArray)
+ && (var_type != eSetVarTypeDictionary)
+ && (var_type != eSetVarTypeString))
err.SetErrorString ("Invalid operation: This operation can only be performed on array, dictionary "
"or string variables.\n");
break;
@@ -2009,36 +1962,36 @@
}
void
-UserSettingsController::UpdateStringVariable (lldb::VarSetOperationType op,
+UserSettingsController::UpdateStringVariable (VarSetOperationType op,
std::string &string_var,
const char *new_value,
Error &err)
{
- if (op == lldb::eVarSetOperationAssign)
+ if (op == eVarSetOperationAssign)
{
if (new_value && new_value[0])
string_var.assign (new_value);
else
string_var.clear();
}
- else if (op == lldb::eVarSetOperationAppend)
+ else if (op == eVarSetOperationAppend)
{
if (new_value && new_value[0])
string_var.append (new_value);
}
- else if (op == lldb::eVarSetOperationClear)
+ else if (op == eVarSetOperationClear)
string_var.clear();
else
err.SetErrorString ("Unrecognized operation. Cannot update value.\n");
}
void
-UserSettingsController::UpdateBooleanVariable (lldb::VarSetOperationType op,
+UserSettingsController::UpdateBooleanVariable (VarSetOperationType op,
bool &bool_var,
const char *new_value,
Error &err)
{
- if (op != lldb::eVarSetOperationAssign)
+ if (op != eVarSetOperationAssign)
err.SetErrorString ("Invalid operation for Boolean variable. Cannot update value.\n");
if (new_value && new_value[0])
@@ -2063,7 +2016,7 @@
}
void
-UserSettingsController::UpdateStringArrayVariable (lldb::VarSetOperationType op,
+UserSettingsController::UpdateStringArrayVariable (VarSetOperationType op,
const char *index_value,
Args &array_var,
const char *new_value,
@@ -2096,41 +2049,41 @@
switch (op)
{
- case lldb::eVarSetOperationAssign:
+ case eVarSetOperationAssign:
array_var.SetCommandString (new_value);
break;
- case lldb::eVarSetOperationReplace:
+ case eVarSetOperationReplace:
{
if (valid_index)
array_var.ReplaceArgumentAtIndex (index, new_value);
break;
}
- case lldb::eVarSetOperationInsertBefore:
- case lldb::eVarSetOperationInsertAfter:
+ case eVarSetOperationInsertBefore:
+ case eVarSetOperationInsertAfter:
{
if (valid_index)
{
Args new_array (new_value);
- if (op == lldb::eVarSetOperationInsertAfter)
+ if (op == eVarSetOperationInsertAfter)
++index;
for (int i = 0; i < new_array.GetArgumentCount(); ++i)
array_var.InsertArgumentAtIndex (index, new_array.GetArgumentAtIndex (i));
}
break;
}
- case lldb::eVarSetOperationRemove:
+ case eVarSetOperationRemove:
{
if (valid_index)
array_var.DeleteArgumentAtIndex (index);
break;
}
- case lldb::eVarSetOperationAppend:
+ case eVarSetOperationAppend:
{
Args new_array (new_value);
array_var.AppendArguments (new_array);
break;
}
- case lldb::eVarSetOperationClear:
+ case eVarSetOperationClear:
array_var.Clear();
break;
default:
@@ -2140,7 +2093,7 @@
}
void
-UserSettingsController::UpdateDictionaryVariable (lldb::VarSetOperationType op,
+UserSettingsController::UpdateDictionaryVariable (VarSetOperationType op,
const char *index_value,
std::map<std::string, std::string> &dictionary,
const char *new_value,
@@ -2148,7 +2101,7 @@
{
switch (op)
{
- case lldb::eVarSetOperationReplace:
+ case eVarSetOperationReplace:
if (index_value != NULL)
{
std::string key (index_value);
@@ -2163,7 +2116,7 @@
else
err.SetErrorString ("'settings replace' requires a key for dictionary variables. No key supplied.\n");
break;
- case lldb::eVarSetOperationRemove:
+ case eVarSetOperationRemove:
if (index_value != NULL)
{
std::string key (index_value);
@@ -2172,14 +2125,14 @@
else
err.SetErrorString ("'settings remove' requires a key for dictionary variables. No key supplied.\n");
break;
- case lldb::eVarSetOperationClear:
+ case eVarSetOperationClear:
dictionary.clear ();
break;
- case lldb::eVarSetOperationAppend:
- case lldb::eVarSetOperationAssign:
+ case eVarSetOperationAppend:
+ case eVarSetOperationAssign:
{
// Clear the dictionary if it's an assign with new_value as NULL.
- if (new_value == NULL && op == lldb::eVarSetOperationAssign)
+ if (new_value == NULL && op == eVarSetOperationAssign)
{
dictionary.clear ();
break;
@@ -2215,8 +2168,8 @@
}
}
break;
- case lldb::eVarSetOperationInsertBefore:
- case lldb::eVarSetOperationInsertAfter:
+ case eVarSetOperationInsertBefore:
+ case eVarSetOperationInsertAfter:
err.SetErrorString ("Specified operation cannot be performed on dictionary variables.\n");
break;
default:
@@ -2226,7 +2179,7 @@
}
const char *
-UserSettingsController::EnumToString (const lldb::OptionEnumValueElement *enum_values,
+UserSettingsController::EnumToString (const OptionEnumValueElement *enum_values,
int value)
{
int i = 0;
@@ -2237,12 +2190,12 @@
++i;
}
- return "Invalid enumeration value";
+ return "";
}
void
-UserSettingsController::UpdateEnumVariable (lldb::OptionEnumValueElement *enum_values,
+UserSettingsController::UpdateEnumVariable (OptionEnumValueElement *enum_values,
int *enum_var,
const char *new_value,
Error &err)
@@ -2297,11 +2250,11 @@
live_settings->ChangeInstanceName (stripped_new_name);
// Now see if there are any pending settings for the new name; if so, copy them into live_settings.
- std::map<std::string, lldb::InstanceSettingsSP>::iterator pending_pos;
+ std::map<std::string, InstanceSettingsSP>::iterator pending_pos;
pending_pos = m_pending_settings.find (new_name_key);
if (pending_pos != m_pending_settings.end())
{
- lldb::InstanceSettingsSP pending_settings_sp = pending_pos->second;
+ InstanceSettingsSP pending_settings_sp = pending_pos->second;
live_settings->CopyInstanceSettings (pending_settings_sp, false);
}
Modified: lldb/trunk/source/Interpreter/CommandInterpreter.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandInterpreter.cpp?rev=125815&r1=125814&r2=125815&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/CommandInterpreter.cpp (original)
+++ lldb/trunk/source/Interpreter/CommandInterpreter.cpp Thu Feb 17 19:44:25 2011
@@ -1687,12 +1687,17 @@
int indent_size = max_word_len + strlen (separator) + 2;
strm.IndentMore (indent_size);
-
- int len = indent_size + strlen (help_text) + 1;
- char *text = (char *) malloc (len);
- sprintf (text, "%-*s %s %s", max_word_len, word_text, separator, help_text);
+
+ StreamString text_strm;
+ text_strm.Printf ("%-*s %s %s", max_word_len, word_text, separator, help_text);
+
+ size_t len = text_strm.GetSize();
+ const char *text = text_strm.GetData();
if (text[len - 1] == '\n')
- text[--len] = '\0';
+ {
+ text_strm.EOL();
+ len = text_strm.GetSize();
+ }
if (len < max_columns)
{
@@ -1750,7 +1755,6 @@
}
strm.EOL();
strm.IndentLess(indent_size);
- free (text);
}
void
Modified: lldb/trunk/source/Target/Process.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=125815&r1=125814&r2=125815&view=diff
==============================================================================
--- lldb/trunk/source/Target/Process.cpp (original)
+++ lldb/trunk/source/Target/Process.cpp Thu Feb 17 19:44:25 2011
@@ -2644,10 +2644,39 @@
m_target.GetDebugger().PopInputReader (m_process_input_reader);
}
-
+// The process needs to know about installed plug-ins
void
-Process::Initialize ()
+Process::DidInitialize ()
{
+ static std::vector<lldb::OptionEnumValueElement> g_plugins;
+
+ int i=0;
+ const char *name;
+ OptionEnumValueElement option_enum;
+ while ((name = PluginManager::GetProcessPluginNameAtIndex (i)) != NULL)
+ {
+ if (name)
+ {
+ option_enum.value = i;
+ option_enum.string_value = name;
+ option_enum.usage = PluginManager::GetProcessPluginDescriptionAtIndex (i);
+ g_plugins.push_back (option_enum);
+ }
+ ++i;
+ }
+ option_enum.value = 0;
+ option_enum.string_value = NULL;
+ option_enum.usage = NULL;
+ g_plugins.push_back (option_enum);
+
+ for (i=0; (name = SettingsController::instance_settings_table[i].var_name); ++i)
+ {
+ if (::strcmp (name, "plugin") == 0)
+ {
+ SettingsController::instance_settings_table[i].enum_values = &g_plugins[0];
+ break;
+ }
+ }
UserSettingsControllerSP &usc = GetSettingsController();
usc.reset (new SettingsController);
UserSettingsController::InitializeSettingsController (usc,
@@ -2656,6 +2685,11 @@
}
void
+Process::Initialize ()
+{
+}
+
+void
Process::Terminate ()
{
UserSettingsControllerSP &usc = GetSettingsController();
@@ -3550,14 +3584,6 @@
};
-lldb::OptionEnumValueElement
-Process::SettingsController::g_plugins[] =
-{
- { eMacosx, "process.macosx", "Use the native MacOSX debugger plugin" },
- { eRemoteDebugger, "process.gdb-remote" , "Use the GDB Remote protocol based debugger plugin" },
- { 0, NULL, NULL }
-};
-
SettingEntry
Process::SettingsController::instance_settings_table[] =
{
@@ -3568,7 +3594,7 @@
{ "input-path", eSetVarTypeString, NULL, NULL, false, false, "The file/path to be used by the executable program for reading its input." },
{ "output-path", eSetVarTypeString, NULL, NULL, false, false, "The file/path to be used by the executable program for writing its output." },
{ "error-path", eSetVarTypeString, NULL, NULL, false, false, "The file/path to be used by the executable program for writings its error messages." },
- { "plugin", eSetVarTypeEnum, NULL, g_plugins, false, false, "The plugin to be used to run the process." },
+ { "plugin", eSetVarTypeEnum, NULL, NULL, false, false, "The plugin to be used to run the process." },
{ "disable-aslr", eSetVarTypeBoolean, "true", NULL, false, false, "Disable Address Space Layout Randomization (ASLR)" },
{ "disable-stdio", eSetVarTypeBoolean, "false", NULL, false, false, "Disable stdin/stdout for process (e.g. for a GUI application)" },
{ NULL, eSetVarTypeNone, NULL, NULL, false, false, NULL }
Modified: lldb/trunk/source/Target/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=125815&r1=125814&r2=125815&view=diff
==============================================================================
--- lldb/trunk/source/Target/Target.cpp (original)
+++ lldb/trunk/source/Target/Target.cpp Thu Feb 17 19:44:25 2011
@@ -998,14 +998,51 @@
return new_settings_sp;
}
-const ConstString &
-Target::SettingsController::DefArchVarName ()
+
+#define TSC_DEFAULT_ARCH "default-arch"
+#define TSC_EXPR_PREFIX "expr-prefix"
+#define TSC_EXEC_LEVEL "execution-level"
+#define TSC_EXEC_MODE "execution-mode"
+#define TSC_EXEC_OS_TYPE "execution-os-type"
+
+
+static const ConstString &
+GetSettingNameForDefaultArch ()
{
- static ConstString def_arch_var_name ("default-arch");
+ static ConstString g_const_string (TSC_DEFAULT_ARCH);
- return def_arch_var_name;
+ return g_const_string;
+}
+
+static const ConstString &
+GetSettingNameForExpressionPrefix ()
+{
+ static ConstString g_const_string (TSC_EXPR_PREFIX);
+ return g_const_string;
}
+static const ConstString &
+GetSettingNameForExecutionLevel ()
+{
+ static ConstString g_const_string (TSC_EXEC_LEVEL);
+ return g_const_string;
+}
+
+static const ConstString &
+GetSettingNameForExecutionMode ()
+{
+ static ConstString g_const_string (TSC_EXEC_MODE);
+ return g_const_string;
+}
+
+static const ConstString &
+GetSettingNameForExecutionOSType ()
+{
+ static ConstString g_const_string (TSC_EXEC_OS_TYPE);
+ return g_const_string;
+}
+
+
bool
Target::SettingsController::SetGlobalVariable (const ConstString &var_name,
const char *index_value,
@@ -1014,7 +1051,7 @@
const lldb::VarSetOperationType op,
Error&err)
{
- if (var_name == DefArchVarName())
+ if (var_name == GetSettingNameForDefaultArch())
{
ArchSpec tmp_spec (value);
if (tmp_spec.IsValid())
@@ -1031,7 +1068,7 @@
StringList &value,
Error &err)
{
- if (var_name == DefArchVarName())
+ if (var_name == GetSettingNameForDefaultArch())
{
// If the arch is invalid (the default), don't show a string for it
if (m_default_architecture.IsValid())
@@ -1054,7 +1091,12 @@
bool live_instance,
const char *name
) :
- InstanceSettings (owner, name ? name : InstanceSettings::InvalidName().AsCString(), live_instance)
+ InstanceSettings (owner, name ? name : InstanceSettings::InvalidName().AsCString(), live_instance),
+ m_expr_prefix_path (),
+ m_expr_prefix_contents (),
+ m_execution_level (eExecutionLevelAuto),
+ m_execution_mode (eExecutionModeAuto),
+ m_execution_os_type (eExecutionOSTypeAuto)
{
// CopyInstanceSettings is a pure virtual function in InstanceSettings; it therefore cannot be called
// until the vtables for TargetInstanceSettings are properly set up, i.e. AFTER all the initializers.
@@ -1100,8 +1142,6 @@
return *this;
}
-#define EXPR_PREFIX_STRING "expr-prefix"
-
void
TargetInstanceSettings::UpdateInstanceSettingsVariable (const ConstString &var_name,
const char *index_value,
@@ -1112,9 +1152,9 @@
Error &err,
bool pending)
{
- static ConstString expr_prefix_str (EXPR_PREFIX_STRING);
-
- if (var_name == expr_prefix_str)
+ int new_enum = -1;
+
+ if (var_name == GetSettingNameForExpressionPrefix ())
{
switch (op)
{
@@ -1156,19 +1196,39 @@
return;
}
}
+ else if (var_name == GetSettingNameForExecutionLevel ())
+ {
+ UserSettingsController::UpdateEnumVariable (entry.enum_values, &new_enum, value, err);
+ if (err.Success())
+ m_execution_level = (ExecutionLevel)new_enum;
+ }
+ else if (var_name == GetSettingNameForExecutionMode ())
+ {
+ UserSettingsController::UpdateEnumVariable (entry.enum_values, &new_enum, value, err);
+ if (err.Success())
+ m_execution_mode = (ExecutionMode)new_enum;
+ }
+ else if (var_name == GetSettingNameForExecutionOSType ())
+ {
+ UserSettingsController::UpdateEnumVariable (entry.enum_values, &new_enum, value, err);
+ if (err.Success())
+ m_execution_os_type = (ExecutionOSType)new_enum;
+ }
}
void
-TargetInstanceSettings::CopyInstanceSettings (const lldb::InstanceSettingsSP &new_settings,
- bool pending)
+TargetInstanceSettings::CopyInstanceSettings (const lldb::InstanceSettingsSP &new_settings, bool pending)
{
TargetInstanceSettings *new_settings_ptr = static_cast <TargetInstanceSettings *> (new_settings.get());
if (!new_settings_ptr)
return;
- m_expr_prefix_path = new_settings_ptr->m_expr_prefix_path;
- m_expr_prefix_contents = new_settings_ptr->m_expr_prefix_contents;
+ m_expr_prefix_path = new_settings_ptr->m_expr_prefix_path;
+ m_expr_prefix_contents = new_settings_ptr->m_expr_prefix_contents;
+ m_execution_level = new_settings_ptr->m_execution_level;
+ m_execution_mode = new_settings_ptr->m_execution_mode;
+ m_execution_os_type = new_settings_ptr->m_execution_os_type;
}
bool
@@ -1177,12 +1237,22 @@
StringList &value,
Error *err)
{
- static ConstString expr_prefix_str (EXPR_PREFIX_STRING);
-
- if (var_name == expr_prefix_str)
+ if (var_name == GetSettingNameForExpressionPrefix ())
{
value.AppendString (m_expr_prefix_path.c_str(), m_expr_prefix_path.size());
}
+ else if (var_name == GetSettingNameForExecutionLevel ())
+ {
+ value.AppendString (UserSettingsController::EnumToString (entry.enum_values, m_execution_level));
+ }
+ else if (var_name == GetSettingNameForExecutionMode ())
+ {
+ value.AppendString (UserSettingsController::EnumToString (entry.enum_values, m_execution_mode));
+ }
+ else if (var_name == GetSettingNameForExecutionOSType ())
+ {
+ value.AppendString (UserSettingsController::EnumToString (entry.enum_values, m_execution_os_type));
+ }
else
{
if (err)
@@ -1213,15 +1283,51 @@
SettingEntry
Target::SettingsController::global_settings_table[] =
{
- //{ "var-name", var-type, "default", enum-table, init'd, hidden, "help-text"},
- { "default-arch", eSetVarTypeString, NULL, NULL, false, false, "Default architecture to choose, when there's a choice." },
- { NULL, eSetVarTypeNone, NULL, NULL, 0, 0, NULL }
+ // var-name var-type default enum init'd hidden help-text
+ // ================= ================== =========== ==== ====== ====== =========================================================================
+ { TSC_DEFAULT_ARCH , eSetVarTypeString , NULL , NULL, false, false, "Default architecture to choose, when there's a choice." },
+ { NULL , eSetVarTypeNone , NULL , NULL, false, false, NULL }
+};
+
+static lldb::OptionEnumValueElement
+g_execution_level_enums[] =
+{
+ { eExecutionLevelAuto , "auto" , "Automatically detect the execution level (user/kernel)." },
+ { eExecutionLevelKernel , "kernel" , "Treat executables as kernel executables." },
+ { eExecutionLevelUser , "user" , "Treat executables as user space executables." },
+ { 0 , NULL , NULL }
+};
+
+static lldb::OptionEnumValueElement
+g_execution_mode_enums[] =
+{
+ { eExecutionModeAuto , "auto" , "Automatically detect the execution mode (static/dynamic)." },
+ { eExecutionModeStatic , "static" , "All executables are static and addresses at the virtual addresses in the object files." },
+ { eExecutionModeDynamic , "dynamic" , "Executables and shared libraries are dynamically loaded.." },
+ { 0 , NULL , NULL }
+};
+
+static lldb::OptionEnumValueElement
+g_execution_os_enums[] =
+{
+ { eExecutionOSTypeAuto , "auto" , "Automatically detect the execution OS (none/halted/live)." },
+ { eExecutionOSTypeNone , "none" , "There is no operating system available (no processes or threads)." },
+ { eExecutionOSTypeHalted, "halted" , "There is an operating system, but it is halted when the debugger is halted. "
+ "Processes and threads must be discovered by accessing symbols and reading "
+ "memory." },
+ { eExecutionOSTypeLive , "live" , "There is a live operating system with debug services that can be used to "
+ "get processes, threads and theirs states." },
+ { 0, NULL, NULL }
};
SettingEntry
Target::SettingsController::instance_settings_table[] =
{
- //{ "var-name", var-type, "default", enum-table, init'd, hidden, "help-text"},
- { EXPR_PREFIX_STRING, eSetVarTypeString, NULL, NULL, false, false, "Path to a file containing expressions to be prepended to all expressions." },
- { NULL, eSetVarTypeNone, NULL, NULL, 0, 0, NULL }
+ // var-name var-type default enum-table init'd hidden help-text
+ // ================= ================== =========== ========================= ====== ====== =========================================================================
+ { TSC_EXPR_PREFIX , eSetVarTypeString , NULL , NULL , false, false, "Path to a file containing expressions to be prepended to all expressions." },
+ { TSC_EXEC_LEVEL , eSetVarTypeEnum , "auto" , g_execution_level_enums , false, false, "Sets the execution level for a target." },
+ { TSC_EXEC_MODE , eSetVarTypeEnum , "auto" , g_execution_mode_enums , false, false, "Sets the execution mode for a target." },
+ { TSC_EXEC_OS_TYPE , eSetVarTypeEnum , "auto" , g_execution_os_enums , false, false, "Sets the execution OS for a target." },
+ { NULL , eSetVarTypeNone , NULL , NULL , false, false, NULL }
};
Modified: lldb/trunk/source/lldb.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/lldb.cpp?rev=125815&r1=125814&r2=125815&view=diff
==============================================================================
--- lldb/trunk/source/lldb.cpp (original)
+++ lldb/trunk/source/lldb.cpp Thu Feb 17 19:44:25 2011
@@ -101,6 +101,10 @@
#endif
// Scan for any system or user LLDB plug-ins
PluginManager::Initialize();
+
+ // The process needs to know about installed plug-ins
+ Process::DidInitialize ();
+
}
}
More information about the lldb-commits
mailing list