[Lldb-commits] [lldb] r123903 - in /lldb/trunk/source/Plugins/Process/gdb-remote: GDBRemoteCommunication.cpp GDBRemoteCommunication.h
Greg Clayton
gclayton at apple.com
Wed Jan 19 23:53:46 PST 2011
Author: gclayton
Date: Thu Jan 20 01:53:45 2011
New Revision: 123903
URL: http://llvm.org/viewvc/llvm-project?rev=123903&view=rev
Log:
Fixed the async packets (packets that need to be sent to the GDB server
while the inferior is running) to be fast. The previous code would always
cause the sender to timeout, yet still return success due to the way we
were waiting for a value (incorrect value) to change. Now the ProcessGDBRemote
plug-in has a public and private "is running" predicate. This allows things
that need to send async packets to interrupt and wait for the private "is running"
state to be flipped to false, and then resume quickly with no timeout.
Modified:
lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h
Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp?rev=123903&r1=123902&r2=123903&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp Thu Jan 20 01:53:45 2011
@@ -37,7 +37,8 @@
m_thread_suffix_supported (false),
m_rx_packet_listener ("gdbremote.rx_packet"),
m_sequence_mutex (Mutex::eMutexTypeRecursive),
- m_is_running (false),
+ m_public_is_running (false),
+ m_private_is_running (false),
m_async_mutex (Mutex::eMutexTypeRecursive),
m_async_packet_predicate (false),
m_async_packet (),
@@ -206,7 +207,8 @@
state = eStateInvalid;
BroadcastEvent(eBroadcastBitRunPacketSent, NULL);
- m_is_running.SetValue (true, eBroadcastNever);
+ m_public_is_running.SetValue (true, eBroadcastNever);
+ m_private_is_running.SetValue (true, eBroadcastNever);
while (state == eStateRunning)
{
@@ -229,6 +231,11 @@
{
case 'T':
case 'S':
+ // Privately notify any internal threads that we have stopped
+ // in case we wanted to interrupt our process, yet we might
+ // send a packet and continue without returning control to the
+ // user.
+ m_private_is_running.SetValue (false, eBroadcastAlways);
if (m_async_signal != -1)
{
if (async_log)
@@ -272,11 +279,14 @@
if (async_log)
async_log->Printf ("async: error: failed to resume with %s",
Host::GetSignalAsCString (async_signal));
- state = eStateInvalid;
+ state = eStateExited;
break;
}
else
+ {
+ m_private_is_running.SetValue (true, eBroadcastNever);
continue;
+ }
}
}
else if (m_async_packet_predicate.GetValue())
@@ -307,11 +317,15 @@
// Continue again
if (SendPacket("c", 1) == 0)
{
- state = eStateInvalid;
+ // Failed to send the continue packet
+ state = eStateExited;
break;
}
else
+ {
+ m_private_is_running.SetValue (true, eBroadcastNever);
continue;
+ }
}
// Stop with signal and thread info
state = eStateStopped;
@@ -358,7 +372,8 @@
if (log)
log->Printf ("GDBRemoteCommunication::%s () => %s", __FUNCTION__, StateAsCString(state));
response.SetFilePos(0);
- m_is_running.SetValue (false, eBroadcastAlways);
+ m_private_is_running.SetValue (false, eBroadcastAlways);
+ m_public_is_running.SetValue (false, eBroadcastAlways);
return state;
}
@@ -470,7 +485,7 @@
if (Write (&ctrl_c, 1, status, NULL) > 0)
{
if (seconds_to_wait_for_stop)
- m_is_running.WaitForValueEqualTo (false, &timeout, timed_out);
+ m_private_is_running.WaitForValueEqualTo (false, &timeout, timed_out);
return true;
}
}
@@ -481,6 +496,7 @@
size_t
GDBRemoteCommunication::WaitForPacket (StringExtractorGDBRemote &response, uint32_t timeout_seconds)
{
+ Mutex::Locker locker(m_sequence_mutex);
TimeValue timeout_time;
timeout_time = TimeValue::Now();
timeout_time.OffsetWithSeconds (timeout_seconds);
Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h?rev=123903&r1=123902&r2=123903&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h Thu Jan 20 01:53:45 2011
@@ -215,7 +215,7 @@
bool
IsRunning() const
{
- return m_is_running.GetValue();
+ return m_public_is_running.GetValue();
}
bool
@@ -260,7 +260,8 @@
m_thread_suffix_supported:1;
lldb_private::Listener m_rx_packet_listener;
lldb_private::Mutex m_sequence_mutex; // Restrict access to sending/receiving packets to a single thread at a time
- lldb_private::Predicate<bool> m_is_running;
+ lldb_private::Predicate<bool> m_public_is_running;
+ lldb_private::Predicate<bool> m_private_is_running;
// If we need to send a packet while the target is running, the m_async_XXX
// member variables take care of making this happen.
More information about the lldb-commits
mailing list