summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/Process/gdb-remote
diff options
context:
space:
mode:
authorGreg Clayton <gclayton@apple.com>2011-01-25 02:58:48 +0000
committerGreg Clayton <gclayton@apple.com>2011-01-25 02:58:48 +0000
commit414f5d3fe8c28ade7394930159e74a72aa7eba72 (patch)
treed5542c795624eb06a0eaa809603dc31f9b6be348 /lldb/source/Plugins/Process/gdb-remote
parent0c2706823e22af895844fca14dab528c4f95d044 (diff)
downloadbcm5719-llvm-414f5d3fe8c28ade7394930159e74a72aa7eba72.tar.gz
bcm5719-llvm-414f5d3fe8c28ade7394930159e74a72aa7eba72.zip
Fixed ProcessGDBRemote to kill the process correctly when it is either running
or stopped. Added support for sections to be able to state if they are encrypted or not. llvm-svn: 124171
Diffstat (limited to 'lldb/source/Plugins/Process/gdb-remote')
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp43
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp84
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h4
3 files changed, 40 insertions, 91 deletions
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
index a779db25756..aa100840936 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
@@ -151,7 +151,7 @@ GDBRemoteCommunication::SendPacketAndWaitForResponse
bool timed_out = false;
bool sent_interrupt = false;
- if (SendInterrupt(locker, 1, sent_interrupt, timed_out))
+ if (SendInterrupt(locker, 2, sent_interrupt, timed_out))
{
if (m_async_packet_predicate.WaitForValueEqualTo (false, &timeout_time, &timed_out))
{
@@ -206,7 +206,6 @@ GDBRemoteCommunication::SendContinuePacketAndWaitForResponse
)
{
LogSP log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_PROCESS));
- LogSP async_log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_ASYNC));
if (log)
log->Printf ("GDBRemoteCommunication::%s ()", __FUNCTION__);
@@ -222,21 +221,18 @@ GDBRemoteCommunication::SendContinuePacketAndWaitForResponse
while (state == eStateRunning)
{
- log = ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_PROCESS);
if (log)
log->Printf ("GDBRemoteCommunication::%s () WaitForPacket(...)", __FUNCTION__);
if (WaitForPacket (response, (TimeValue*)NULL))
{
- log = ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_PROCESS);
- async_log = ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_ASYNC);
if (response.Empty())
state = eStateInvalid;
else
{
const char stop_type = response.GetChar();
if (log)
- log->Printf ("GDBRemoteCommunication::%s () got '%c' packet", __FUNCTION__, stop_type);
+ log->Printf ("GDBRemoteCommunication::%s () got packet: %s", __FUNCTION__, response.GetStringRef().c_str());
switch (stop_type)
{
case 'T':
@@ -248,8 +244,8 @@ GDBRemoteCommunication::SendContinuePacketAndWaitForResponse
m_private_is_running.SetValue (false, eBroadcastAlways);
if (m_async_signal != -1)
{
- if (async_log)
- async_log->Printf ("async: send signo = %s", Host::GetSignalAsCString (m_async_signal));
+ if (log)
+ log->Printf ("async: send signo = %s", Host::GetSignalAsCString (m_async_signal));
// Save off the async signal we are supposed to send
const int async_signal = m_async_signal;
@@ -260,8 +256,8 @@ GDBRemoteCommunication::SendContinuePacketAndWaitForResponse
uint8_t signo = response.GetHexU8(255);
if (signo == async_signal)
{
- if (async_log)
- async_log->Printf ("async: stopped with signal %s, we are done running", Host::GetSignalAsCString (signo));
+ if (log)
+ log->Printf ("async: stopped with signal %s, we are done running", Host::GetSignalAsCString (signo));
// We already stopped with a signal that we wanted
// to stop with, so we are done
@@ -279,15 +275,15 @@ GDBRemoteCommunication::SendContinuePacketAndWaitForResponse
"C%2.2x",
async_signal);
- if (async_log)
- async_log->Printf ("async: stopped with signal %s, resume with %s",
+ if (log)
+ log->Printf ("async: stopped with signal %s, resume with %s",
Host::GetSignalAsCString (signo),
Host::GetSignalAsCString (async_signal));
if (SendPacket(signal_packet, signal_packet_len) == 0)
{
- if (async_log)
- async_log->Printf ("async: error: failed to resume with %s",
+ if (log)
+ log->Printf ("async: error: failed to resume with %s",
Host::GetSignalAsCString (async_signal));
state = eStateExited;
break;
@@ -301,9 +297,9 @@ GDBRemoteCommunication::SendContinuePacketAndWaitForResponse
}
else if (m_async_packet_predicate.GetValue())
{
- if (async_log)
- async_log->Printf ("async: send async packet: %s",
- m_async_packet.c_str());
+ if (log)
+ log->Printf ("async: send async packet: %s",
+ m_async_packet.c_str());
// We are supposed to send an asynchronous packet while
// we are running.
@@ -320,9 +316,9 @@ GDBRemoteCommunication::SendContinuePacketAndWaitForResponse
// packet know that the packet has been sent.
m_async_packet_predicate.SetValue(false, eBroadcastAlways);
- if (async_log)
- async_log->Printf ("async: resume after async response received: %s",
- m_async_response.GetStringRef().c_str());
+ if (log)
+ log->Printf ("async: resume after async response received: %s",
+ m_async_response.GetStringRef().c_str());
// Continue again
if (SendPacket("c", 1) == 0)
@@ -342,6 +338,7 @@ GDBRemoteCommunication::SendContinuePacketAndWaitForResponse
break;
case 'W':
+ case 'X':
// process exited
state = eStateExited;
break;
@@ -365,20 +362,18 @@ GDBRemoteCommunication::SendContinuePacketAndWaitForResponse
default:
if (log)
- log->Printf ("GDBRemoteCommunication::%s () got unrecognized async packet: '%s'", __FUNCTION__, stop_type);
+ log->Printf ("GDBRemoteCommunication::%s () unrecognized async packet", __FUNCTION__);
break;
}
}
}
else
{
- log = ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_PROCESS);
if (log)
log->Printf ("GDBRemoteCommunication::%s () WaitForPacket(...) => false", __FUNCTION__);
state = eStateInvalid;
}
}
- log = ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_PROCESS);
if (log)
log->Printf ("GDBRemoteCommunication::%s () => %s", __FUNCTION__, StateAsCString(state));
response.SetFilePos(0);
@@ -498,7 +493,7 @@ GDBRemoteCommunication::SendInterrupt
timeout = TimeValue::Now();
timeout.OffsetWithSeconds (seconds_to_wait_for_stop);
}
- ProcessGDBRemoteLog::LogIf (GDBR_LOG_PACKETS, "send packet: \\x03");
+ ProcessGDBRemoteLog::LogIf (GDBR_LOG_PACKETS | GDBR_LOG_PROCESS, "send packet: \\x03");
if (Write (&ctrl_c, 1, status, NULL) > 0)
{
sent_interrupt = true;
diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index 6139031cefb..b601d2c31d7 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -1175,7 +1175,6 @@ ProcessGDBRemote::InterruptIfRunning
(
bool discard_thread_plans,
bool catch_stop_event,
- bool resume_private_state_thread,
EventSP &stop_event_sp
)
{
@@ -1183,21 +1182,14 @@ ProcessGDBRemote::InterruptIfRunning
LogSP log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS));
+ bool paused_private_state_thread = false;
const bool is_running = m_gdb_comm.IsRunning();
if (log)
- log->Printf ("ProcessGDBRemote::InterruptIfRunning(discard_thread_plans=%i, catch_stop_event=%i, resume_private_state_thread=%i) is_running=%i",
+ log->Printf ("ProcessGDBRemote::InterruptIfRunning(discard_thread_plans=%i, catch_stop_event=%i) is_running=%i",
discard_thread_plans,
- catch_stop_event,
- resume_private_state_thread,
+ catch_stop_event,
is_running);
- if (catch_stop_event)
- {
- if (log)
- log->Printf ("ProcessGDBRemote::InterruptIfRunning() pausing private state thread");
- PausePrivateStateThread();
- }
-
if (discard_thread_plans)
{
if (log)
@@ -1206,6 +1198,14 @@ ProcessGDBRemote::InterruptIfRunning
}
if (is_running)
{
+ if (catch_stop_event)
+ {
+ if (log)
+ log->Printf ("ProcessGDBRemote::InterruptIfRunning() pausing private state thread");
+ PausePrivateStateThread();
+ paused_private_state_thread = true;
+ }
+
bool timed_out = false;
bool sent_interrupt = false;
Mutex::Locker locker;
@@ -1217,17 +1217,18 @@ ProcessGDBRemote::InterruptIfRunning
error.SetErrorString("timed out sending interrupt packet");
else
error.SetErrorString("unknown error sending interrupt packet");
- if (catch_stop_event)
+ if (paused_private_state_thread)
ResumePrivateStateThread();
return error;
}
if (catch_stop_event)
{
+ // LISTEN HERE
TimeValue timeout_time;
timeout_time = TimeValue::Now();
- timeout_time.OffsetWithSeconds(1);
- StateType state = WaitForProcessStopPrivate (&timeout_time, stop_event_sp);
+ timeout_time.OffsetWithSeconds(5);
+ StateType state = WaitForStateChangedEventsPrivate (&timeout_time, stop_event_sp);
const bool timed_out = state == eStateInvalid;
if (log)
@@ -1237,7 +1238,7 @@ ProcessGDBRemote::InterruptIfRunning
error.SetErrorString("unable to verify target stopped");
}
- if (catch_stop_event && resume_private_state_thread)
+ if (paused_private_state_thread)
{
if (log)
log->Printf ("ProcessGDBRemote::InterruptIfRunning() resuming private state thread");
@@ -1256,9 +1257,8 @@ ProcessGDBRemote::WillDetach ()
bool discard_thread_plans = true;
bool catch_stop_event = true;
- bool resume_private_state_thread = false; // DoDetach will resume the thread
EventSP event_sp;
- return InterruptIfRunning (discard_thread_plans, catch_stop_event, resume_private_state_thread, event_sp);
+ return InterruptIfRunning (discard_thread_plans, catch_stop_event, event_sp);
}
Error
@@ -1295,21 +1295,6 @@ ProcessGDBRemote::DoDetach()
}
Error
-ProcessGDBRemote::WillDestroy ()
-{
- LogSP log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS));
- if (log)
- log->Printf ("ProcessGDBRemote::WillDestroy()");
- bool discard_thread_plans = true;
- bool catch_stop_event = true;
- bool resume_private_state_thread = true;
- EventSP event_sp;
- return InterruptIfRunning (discard_thread_plans, catch_stop_event, resume_private_state_thread, event_sp);
-
-
-}
-
-Error
ProcessGDBRemote::DoDestroy ()
{
Error error;
@@ -1320,38 +1305,11 @@ ProcessGDBRemote::DoDestroy ()
// Interrupt if our inferior is running...
if (m_gdb_comm.IsConnected())
{
- m_continue_packet.Clear();
- m_continue_packet.Printf("k");
- Listener listener ("gdb-remote.kill-packet-sent");
- if (listener.StartListeningForEvents (&m_gdb_comm, GDBRemoteCommunication::eBroadcastBitRunPacketSent))
+ StringExtractorGDBRemote response;
+ bool send_async = true;
+ if (m_gdb_comm.SendPacketAndWaitForResponse("k", 1, response, 3, send_async) == 0)
{
- EventSP event_sp;
- TimeValue timeout;
- timeout = TimeValue::Now();
- timeout.OffsetWithSeconds (1);
- m_async_broadcaster.BroadcastEvent (eBroadcastBitAsyncContinue, new EventDataBytes (m_continue_packet.GetData(), m_continue_packet.GetSize()));
-
- // Wait for the async thread to send the "k" packet
- if (listener.WaitForEvent (&timeout, event_sp))
- {
- if (log)
- log->Printf ("ProcessGDBRemote::DoDestroy() got confirmation the \"k\" packet was sent");
- }
- else
- {
- if (log)
- log->Printf ("ProcessGDBRemote::DoDestroy() timed out waiting for \"k\" packet to be sent");
- error.SetErrorString("Resume timed out.");
- }
-
- // Wait for the async thread to exit which will indicate we stopped.
- // Hopefully the stop will be a process exited state since we are
- // asking the process to go away.
- if (!m_gdb_comm.WaitForNotRunning (&timeout))
- {
- if (log)
- log->Printf ("ProcessGDBRemote::DoDestroy() timed out waiting for \"k\" stop reply packet");
- }
+ error.SetErrorString("kill packet failed");
}
}
StopAsyncThread ();
diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
index 8c8f1a8a9af..6fa5ab7a752 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
@@ -150,9 +150,6 @@ public:
DoSignal (int signal);
virtual lldb_private::Error
- WillDestroy ();
-
- virtual lldb_private::Error
DoDestroy ();
virtual void
@@ -392,7 +389,6 @@ protected:
lldb_private::Error
InterruptIfRunning (bool discard_thread_plans,
bool catch_stop_event,
- bool resume_private_state_thread,
lldb::EventSP &stop_event_sp);
private:
OpenPOWER on IntegriCloud