[Lldb-commits] [lldb] r186360 - <rdar://problem/13793059>
Greg Clayton
gclayton at apple.com
Mon Jul 15 15:54:21 PDT 2013
Author: gclayton
Date: Mon Jul 15 17:54:20 2013
New Revision: 186360
URL: http://llvm.org/viewvc/llvm-project?rev=186360&view=rev
Log:
<rdar://problem/13793059>
Added a setting to control timeout for kdp response packets. While I was at it, I also added a way to control the response timeout for gdb-remote packets.
KDP defaults to 5 seconds, and GDB defaults to 1 second. These were the default values that were in the code prior to adding these settings.
(lldb) settings set plugin.process.gdb-remote.packet-timeout 10
(lldb) settings set plugin.process.kdp-remote.packet-timeout 10
Modified:
lldb/trunk/include/lldb/Core/PluginManager.h
lldb/trunk/source/Core/PluginManager.cpp
lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.h
lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
Modified: lldb/trunk/include/lldb/Core/PluginManager.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/PluginManager.h?rev=186360&r1=186359&r2=186360&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/PluginManager.h (original)
+++ lldb/trunk/include/lldb/Core/PluginManager.h Mon Jul 15 17:54:20 2013
@@ -234,7 +234,8 @@ public:
static bool
RegisterPlugin (const ConstString &name,
const char *description,
- ProcessCreateInstance create_callback);
+ ProcessCreateInstance create_callback,
+ DebuggerInitializeCallback debugger_init_callback = NULL);
static bool
UnregisterPlugin (ProcessCreateInstance create_callback);
@@ -315,7 +316,7 @@ public:
static lldb::OptionValuePropertiesSP
GetSettingForDynamicLoaderPlugin (Debugger &debugger,
- const ConstString &setting_name);
+ const ConstString &setting_name);
static bool
CreateSettingForDynamicLoaderPlugin (Debugger &debugger,
@@ -332,6 +333,17 @@ public:
const lldb::OptionValuePropertiesSP &properties_sp,
const ConstString &description,
bool is_global_property);
+
+ static lldb::OptionValuePropertiesSP
+ GetSettingForProcessPlugin (Debugger &debugger,
+ const ConstString &setting_name);
+
+ static bool
+ CreateSettingForProcessPlugin (Debugger &debugger,
+ const lldb::OptionValuePropertiesSP &properties_sp,
+ const ConstString &description,
+ bool is_global_property);
+
};
Modified: lldb/trunk/source/Core/PluginManager.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/PluginManager.cpp?rev=186360&r1=186359&r2=186360&view=diff
==============================================================================
--- lldb/trunk/source/Core/PluginManager.cpp (original)
+++ lldb/trunk/source/Core/PluginManager.cpp Mon Jul 15 17:54:20 2013
@@ -1388,15 +1388,17 @@ PluginManager::AutoCompletePlatformName
struct ProcessInstance
{
ProcessInstance() :
- name(),
- description(),
- create_callback(NULL)
+ name(),
+ description(),
+ create_callback(NULL),
+ debugger_init_callback(NULL)
{
}
ConstString name;
std::string description;
ProcessCreateInstance create_callback;
+ DebuggerInitializeCallback debugger_init_callback;
};
typedef std::vector<ProcessInstance> ProcessInstances;
@@ -1417,12 +1419,10 @@ GetProcessInstances ()
bool
-PluginManager::RegisterPlugin
-(
- const ConstString &name,
- const char *description,
- ProcessCreateInstance create_callback
- )
+PluginManager::RegisterPlugin (const ConstString &name,
+ const char *description,
+ ProcessCreateInstance create_callback,
+ DebuggerInitializeCallback debugger_init_callback)
{
if (create_callback)
{
@@ -1432,6 +1432,7 @@ PluginManager::RegisterPlugin
if (description && description[0])
instance.description = description;
instance.create_callback = create_callback;
+ instance.debugger_init_callback = debugger_init_callback;
Mutex::Locker locker (GetProcessMutex ());
GetProcessInstances ().push_back (instance);
}
@@ -1851,13 +1852,26 @@ PluginManager::DebuggerInitialize (Debug
pos->debugger_init_callback (debugger);
}
}
+
+ // Initialize the Process plugins
+ {
+ Mutex::Locker locker (GetProcessMutex());
+ ProcessInstances &instances = GetProcessInstances();
+
+ ProcessInstances::iterator pos, end = instances.end();
+ for (pos = instances.begin(); pos != end; ++ pos)
+ {
+ if (pos->debugger_init_callback)
+ pos->debugger_init_callback (debugger);
+ }
+ }
+
}
-// This will put a plugin's settings under e.g. "plugin.dynamic-loader.darwin-kernel.SETTINGNAME".
-// The new preferred ordering is to put plugins under "dynamic-loader.plugin.darwin-kernel.SETTINGNAME"
-// and if there were a generic dynamic-loader setting, it would be "dynamic-loader.SETTINGNAME".
+// This is the preferred new way to register plugin specific settings. e.g.
+// This will put a plugin's settings under e.g. "plugin.<plugin_type_name>.<plugin_type_desc>.SETTINGNAME".
static lldb::OptionValuePropertiesSP
-GetDebuggerPropertyForPluginsOldStyle (Debugger &debugger,
+GetDebuggerPropertyForPlugins (Debugger &debugger,
const ConstString &plugin_type_name,
const ConstString &plugin_type_desc,
bool can_create)
@@ -1894,14 +1908,14 @@ GetDebuggerPropertyForPluginsOldStyle (D
return lldb::OptionValuePropertiesSP();
}
-// This is the preferred new way to register plugin specific settings. e.g.
-// "platform.plugin.darwin-kernel.SETTINGNAME"
+// This is deprecated way to register plugin specific settings. e.g.
+// "<plugin_type_name>.plugin.<plugin_type_desc>.SETTINGNAME"
// and Platform generic settings would be under "platform.SETTINGNAME".
static lldb::OptionValuePropertiesSP
-GetDebuggerPropertyForPlugins (Debugger &debugger,
- const ConstString &plugin_type_name,
- const ConstString &plugin_type_desc,
- bool can_create)
+GetDebuggerPropertyForPluginsOldStyle (Debugger &debugger,
+ const ConstString &plugin_type_name,
+ const ConstString &plugin_type_desc,
+ bool can_create)
{
static ConstString g_property_name("plugin");
lldb::OptionValuePropertiesSP parent_properties_sp (debugger.GetValueProperties());
@@ -1939,7 +1953,7 @@ lldb::OptionValuePropertiesSP
PluginManager::GetSettingForDynamicLoaderPlugin (Debugger &debugger, const ConstString &setting_name)
{
lldb::OptionValuePropertiesSP properties_sp;
- lldb::OptionValuePropertiesSP plugin_type_properties_sp (GetDebuggerPropertyForPluginsOldStyle (debugger,
+ lldb::OptionValuePropertiesSP plugin_type_properties_sp (GetDebuggerPropertyForPlugins (debugger,
ConstString("dynamic-loader"),
ConstString(), // not creating to so we don't need the description
false));
@@ -1956,7 +1970,7 @@ PluginManager::CreateSettingForDynamicLo
{
if (properties_sp)
{
- lldb::OptionValuePropertiesSP plugin_type_properties_sp (GetDebuggerPropertyForPluginsOldStyle (debugger,
+ lldb::OptionValuePropertiesSP plugin_type_properties_sp (GetDebuggerPropertyForPlugins (debugger,
ConstString("dynamic-loader"),
ConstString("Settings for dynamic loader plug-ins"),
true));
@@ -1977,10 +1991,10 @@ lldb::OptionValuePropertiesSP
PluginManager::GetSettingForPlatformPlugin (Debugger &debugger, const ConstString &setting_name)
{
lldb::OptionValuePropertiesSP properties_sp;
- lldb::OptionValuePropertiesSP plugin_type_properties_sp (GetDebuggerPropertyForPlugins (debugger,
- ConstString("platform"),
- ConstString(), // not creating to so we don't need the description
- false));
+ lldb::OptionValuePropertiesSP plugin_type_properties_sp (GetDebuggerPropertyForPluginsOldStyle (debugger,
+ ConstString("platform"),
+ ConstString(), // not creating to so we don't need the description
+ false));
if (plugin_type_properties_sp)
properties_sp = plugin_type_properties_sp->GetSubProperty (NULL, setting_name);
return properties_sp;
@@ -1994,9 +2008,47 @@ PluginManager::CreateSettingForPlatformP
{
if (properties_sp)
{
+ lldb::OptionValuePropertiesSP plugin_type_properties_sp (GetDebuggerPropertyForPluginsOldStyle (debugger,
+ ConstString("platform"),
+ ConstString("Settings for platform plug-ins"),
+ true));
+ if (plugin_type_properties_sp)
+ {
+ plugin_type_properties_sp->AppendProperty (properties_sp->GetName(),
+ description,
+ is_global_property,
+ properties_sp);
+ return true;
+ }
+ }
+ return false;
+}
+
+
+lldb::OptionValuePropertiesSP
+PluginManager::GetSettingForProcessPlugin (Debugger &debugger, const ConstString &setting_name)
+{
+ lldb::OptionValuePropertiesSP properties_sp;
+ lldb::OptionValuePropertiesSP plugin_type_properties_sp (GetDebuggerPropertyForPlugins (debugger,
+ ConstString("process"),
+ ConstString(), // not creating to so we don't need the description
+ false));
+ if (plugin_type_properties_sp)
+ properties_sp = plugin_type_properties_sp->GetSubProperty (NULL, setting_name);
+ return properties_sp;
+}
+
+bool
+PluginManager::CreateSettingForProcessPlugin (Debugger &debugger,
+ const lldb::OptionValuePropertiesSP &properties_sp,
+ const ConstString &description,
+ bool is_global_property)
+{
+ if (properties_sp)
+ {
lldb::OptionValuePropertiesSP plugin_type_properties_sp (GetDebuggerPropertyForPlugins (debugger,
- ConstString("platform"),
- ConstString("Settings for platform plug-ins"),
+ ConstString("process"),
+ ConstString("Settings for process plug-ins"),
true));
if (plugin_type_properties_sp)
{
Modified: lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp?rev=186360&r1=186359&r2=186360&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp (original)
+++ lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp Mon Jul 15 17:54:20 2013
@@ -44,6 +44,63 @@
using namespace lldb;
using namespace lldb_private;
+namespace {
+
+ static PropertyDefinition
+ g_properties[] =
+ {
+ { "packet-timeout" , OptionValue::eTypeUInt64 , true , 5, NULL, NULL, "Specify the default packet timeout in seconds." },
+ { NULL , OptionValue::eTypeInvalid, false, 0, NULL, NULL, NULL }
+ };
+
+ enum
+ {
+ ePropertyPacketTimeout
+ };
+
+ class PluginProperties : public Properties
+ {
+ public:
+
+ static ConstString
+ GetSettingName ()
+ {
+ return ProcessKDP::GetPluginNameStatic();
+ }
+
+ PluginProperties() :
+ Properties ()
+ {
+ m_collection_sp.reset (new OptionValueProperties(GetSettingName()));
+ m_collection_sp->Initialize(g_properties);
+ }
+
+ virtual
+ ~PluginProperties()
+ {
+ }
+
+ uint64_t
+ GetPacketTimeout()
+ {
+ const uint32_t idx = ePropertyPacketTimeout;
+ return m_collection_sp->GetPropertyAtIndexAsUInt64(NULL, idx, g_properties[idx].default_uint_value);
+ }
+ };
+
+ typedef std::shared_ptr<PluginProperties> ProcessKDPPropertiesSP;
+
+ static const ProcessKDPPropertiesSP &
+ GetGlobalPluginProperties()
+ {
+ static ProcessKDPPropertiesSP g_settings_sp;
+ if (!g_settings_sp)
+ g_settings_sp.reset (new PluginProperties ());
+ return g_settings_sp;
+ }
+
+} // anonymous namespace end
+
static const lldb::tid_t g_kernel_tid = 1;
ConstString
@@ -124,6 +181,9 @@ ProcessKDP::ProcessKDP(Target& target, L
{
m_async_broadcaster.SetEventName (eBroadcastBitAsyncThreadShouldExit, "async thread should exit");
m_async_broadcaster.SetEventName (eBroadcastBitAsyncContinue, "async thread continue");
+ const uint64_t timeout_seconds = GetGlobalPluginProperties()->GetPacketTimeout();
+ if (timeout_seconds > 0)
+ m_comm.SetPacketTimeout(timeout_seconds);
}
//----------------------------------------------------------------------
@@ -716,7 +776,8 @@ ProcessKDP::Initialize()
g_initialized = true;
PluginManager::RegisterPlugin (GetPluginNameStatic(),
GetPluginDescriptionStatic(),
- CreateInstance);
+ CreateInstance,
+ DebuggerInitialize);
Log::Callbacks log_callbacks = {
ProcessKDPLog::DisableLog,
@@ -728,6 +789,19 @@ ProcessKDP::Initialize()
}
}
+void
+ProcessKDP::DebuggerInitialize (lldb_private::Debugger &debugger)
+{
+ if (!PluginManager::GetSettingForProcessPlugin(debugger, PluginProperties::GetSettingName()))
+ {
+ const bool is_global_setting = true;
+ PluginManager::CreateSettingForProcessPlugin (debugger,
+ GetGlobalPluginProperties()->GetValueProperties(),
+ ConstString ("Properties for the kdp-remote process plug-in."),
+ is_global_setting);
+ }
+}
+
bool
ProcessKDP::StartAsyncThread ()
{
Modified: lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.h?rev=186360&r1=186359&r2=186360&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.h (original)
+++ lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.h Mon Jul 15 17:54:20 2013
@@ -48,6 +48,9 @@ public:
Initialize();
static void
+ DebuggerInitialize (lldb_private::Debugger &debugger);
+
+ static void
Terminate();
static lldb_private::ConstString
Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h?rev=186360&r1=186359&r2=186360&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h Mon Jul 15 17:54:20 2013
@@ -285,14 +285,6 @@ public:
return GetVContSupported ('a');
}
- uint32_t
- SetPacketTimeout (uint32_t packet_timeout)
- {
- const uint32_t old_packet_timeout = m_packet_timeout;
- m_packet_timeout = packet_timeout;
- return old_packet_timeout;
- }
-
bool
GetStopReply (StringExtractorGDBRemote &response);
Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp?rev=186360&r1=186359&r2=186360&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Mon Jul 15 17:54:20 2013
@@ -83,11 +83,68 @@ namespace lldb
}
}
-
#define DEBUGSERVER_BASENAME "debugserver"
using namespace lldb;
using namespace lldb_private;
+
+namespace {
+
+ static PropertyDefinition
+ g_properties[] =
+ {
+ { "packet-timeout" , OptionValue::eTypeUInt64 , true , 1, NULL, NULL, "Specify the default packet timeout in seconds." },
+ { NULL , OptionValue::eTypeInvalid, false, 0, NULL, NULL, NULL }
+ };
+
+ enum
+ {
+ ePropertyPacketTimeout
+ };
+
+ class PluginProperties : public Properties
+ {
+ public:
+
+ static ConstString
+ GetSettingName ()
+ {
+ return ProcessGDBRemote::GetPluginNameStatic();
+ }
+
+ PluginProperties() :
+ Properties ()
+ {
+ m_collection_sp.reset (new OptionValueProperties(GetSettingName()));
+ m_collection_sp->Initialize(g_properties);
+ }
+
+ virtual
+ ~PluginProperties()
+ {
+ }
+
+ uint64_t
+ GetPacketTimeout()
+ {
+ const uint32_t idx = ePropertyPacketTimeout;
+ return m_collection_sp->GetPropertyAtIndexAsUInt64(NULL, idx, g_properties[idx].default_uint_value);
+ }
+ };
+
+ typedef std::shared_ptr<PluginProperties> ProcessKDPPropertiesSP;
+
+ static const ProcessKDPPropertiesSP &
+ GetGlobalPluginProperties()
+ {
+ static ProcessKDPPropertiesSP g_settings_sp;
+ if (!g_settings_sp)
+ g_settings_sp.reset (new PluginProperties ());
+ return g_settings_sp;
+ }
+
+} // anonymous namespace end
+
static bool rand_initialized = false;
// TODO Randomly assigning a port is unsafe. We should get an unused
@@ -208,6 +265,9 @@ ProcessGDBRemote::ProcessGDBRemote(Targe
m_async_broadcaster.SetEventName (eBroadcastBitAsyncThreadShouldExit, "async thread should exit");
m_async_broadcaster.SetEventName (eBroadcastBitAsyncContinue, "async thread continue");
m_async_broadcaster.SetEventName (eBroadcastBitAsyncThreadDidExit, "async thread did exit");
+ const uint64_t timeout_seconds = GetGlobalPluginProperties()->GetPacketTimeout();
+ if (timeout_seconds > 0)
+ m_gdb_comm.SetPacketTimeout(timeout_seconds);
}
//----------------------------------------------------------------------
@@ -2642,7 +2702,8 @@ ProcessGDBRemote::Initialize()
g_initialized = true;
PluginManager::RegisterPlugin (GetPluginNameStatic(),
GetPluginDescriptionStatic(),
- CreateInstance);
+ CreateInstance,
+ DebuggerInitialize);
Log::Callbacks log_callbacks = {
ProcessGDBRemoteLog::DisableLog,
@@ -2654,6 +2715,19 @@ ProcessGDBRemote::Initialize()
}
}
+void
+ProcessGDBRemote::DebuggerInitialize (lldb_private::Debugger &debugger)
+{
+ if (!PluginManager::GetSettingForProcessPlugin(debugger, PluginProperties::GetSettingName()))
+ {
+ const bool is_global_setting = true;
+ PluginManager::CreateSettingForProcessPlugin (debugger,
+ GetGlobalPluginProperties()->GetValueProperties(),
+ ConstString ("Properties for the gdb-remote process plug-in."),
+ is_global_setting);
+ }
+}
+
bool
ProcessGDBRemote::StartAsyncThread ()
{
Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h?rev=186360&r1=186359&r2=186360&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h Mon Jul 15 17:54:20 2013
@@ -49,6 +49,9 @@ public:
Initialize();
static void
+ DebuggerInitialize (lldb_private::Debugger &debugger);
+
+ static void
Terminate();
static lldb_private::ConstString
More information about the lldb-commits
mailing list