diff options
author | Greg Clayton <gclayton@apple.com> | 2013-07-15 22:54:20 +0000 |
---|---|---|
committer | Greg Clayton <gclayton@apple.com> | 2013-07-15 22:54:20 +0000 |
commit | 7f98240df65cfabd6d4bbf95907711f6a2734298 (patch) | |
tree | da16a1bed64b0e9ea58667b300a3ee4907e69b4f /lldb/source/Plugins/Process/gdb-remote | |
parent | 1c1d6c166627733e880546387bca5070d8aaa993 (diff) | |
download | bcm5719-llvm-7f98240df65cfabd6d4bbf95907711f6a2734298.tar.gz bcm5719-llvm-7f98240df65cfabd6d4bbf95907711f6a2734298.zip |
<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
llvm-svn: 186360
Diffstat (limited to 'lldb/source/Plugins/Process/gdb-remote')
3 files changed, 79 insertions, 10 deletions
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h index 4075eebddec..5bb8387b909 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h @@ -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); diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp index 4a2899d8f28..d27207f121d 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -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(Target& target, Listener &listener) : 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 () { diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h index ab8fef3f295..e104b7191ea 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h @@ -49,6 +49,9 @@ public: Initialize(); static void + DebuggerInitialize (lldb_private::Debugger &debugger); + + static void Terminate(); static lldb_private::ConstString |