summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Clayton <gclayton@apple.com>2011-05-20 03:15:54 +0000
committerGreg Clayton <gclayton@apple.com>2011-05-20 03:15:54 +0000
commit5fe15d2d52fa34f7ba12f3320dc6420148a13d3e (patch)
tree0bcbaa126d452b9c5a99387048490d01189766e8
parentfe4f9d5977f58f25a2df0515e796e71686701b2f (diff)
downloadbcm5719-llvm-5fe15d2d52fa34f7ba12f3320dc6420148a13d3e.tar.gz
bcm5719-llvm-5fe15d2d52fa34f7ba12f3320dc6420148a13d3e.zip
Fixed an issue in GDBRemoteCommunicationClient where we weren't listening to
the "payload_length" argument for the "payload" packet data. This meant we could end up sending random extra data with a packet depending on how the packet was constructed. Fixed GDBRemoteRegisterContext to properly save and restore all registers. Previous fixes had been added to work around the "payload_length" issues fixed above and aren't needed anymore. Fix logging in GDBRemoteCommunication to make sure we log the correct packet data being sent by using the packet length when dumping the packet contents. Added register definitions for 'arm-lldb' in the "disasm-gdb-remote.pl" script so if you have a register dump from the GDB remote that doesn't include the qRegisterInfo packets, you can manually tell the script which registers are which. llvm-svn: 131715
-rwxr-xr-xlldb/scripts/disasm-gdb-remote.pl89
-rw-r--r--lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp2
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp19
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp6
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp21
5 files changed, 114 insertions, 23 deletions
diff --git a/lldb/scripts/disasm-gdb-remote.pl b/lldb/scripts/disasm-gdb-remote.pl
index 84788de49a1..3a12f4d4d65 100755
--- a/lldb/scripts/disasm-gdb-remote.pl
+++ b/lldb/scripts/disasm-gdb-remote.pl
@@ -204,6 +204,95 @@ our %reg_map = (
{ name => 'd31' , info => $float64_href },
],
+
+ 'arm-lldb' => [
+ { name => 'r0' , info => $reg32_href },
+ { name => 'r1' , info => $reg32_href },
+ { name => 'r2' , info => $reg32_href },
+ { name => 'r3' , info => $reg32_href },
+ { name => 'r4' , info => $reg32_href },
+ { name => 'r5' , info => $reg32_href },
+ { name => 'r6' , info => $reg32_href },
+ { name => 'r7' , info => $reg32_href },
+ { name => 'r8' , info => $reg32_href },
+ { name => 'r9' , info => $reg32_href },
+ { name => 'r10' , info => $reg32_href },
+ { name => 'r11' , info => $reg32_href },
+ { name => 'r12' , info => $reg32_href },
+ { name => 'sp' , info => $reg32_href },
+ { name => 'lr' , info => $reg32_href },
+ { name => 'pc' , info => $reg32_href },
+ { name => 'cpsr' , info => $reg32_href },
+ { name => 's0' , info => $float32_href },
+ { name => 's1' , info => $float32_href },
+ { name => 's2' , info => $float32_href },
+ { name => 's3' , info => $float32_href },
+ { name => 's4' , info => $float32_href },
+ { name => 's5' , info => $float32_href },
+ { name => 's6' , info => $float32_href },
+ { name => 's7' , info => $float32_href },
+ { name => 's8' , info => $float32_href },
+ { name => 's9' , info => $float32_href },
+ { name => 's10' , info => $float32_href },
+ { name => 's11' , info => $float32_href },
+ { name => 's12' , info => $float32_href },
+ { name => 's13' , info => $float32_href },
+ { name => 's14' , info => $float32_href },
+ { name => 's15' , info => $float32_href },
+ { name => 's16' , info => $float32_href },
+ { name => 's17' , info => $float32_href },
+ { name => 's18' , info => $float32_href },
+ { name => 's19' , info => $float32_href },
+ { name => 's20' , info => $float32_href },
+ { name => 's21' , info => $float32_href },
+ { name => 's22' , info => $float32_href },
+ { name => 's23' , info => $float32_href },
+ { name => 's24' , info => $float32_href },
+ { name => 's25' , info => $float32_href },
+ { name => 's26' , info => $float32_href },
+ { name => 's27' , info => $float32_href },
+ { name => 's28' , info => $float32_href },
+ { name => 's29' , info => $float32_href },
+ { name => 's30' , info => $float32_href },
+ { name => 's31' , info => $float32_href },
+ { name => 'd0' , info => $float64_href },
+ { name => 'd1' , info => $float64_href },
+ { name => 'd2' , info => $float64_href },
+ { name => 'd3' , info => $float64_href },
+ { name => 'd4' , info => $float64_href },
+ { name => 'd5' , info => $float64_href },
+ { name => 'd6' , info => $float64_href },
+ { name => 'd7' , info => $float64_href },
+ { name => 'd8' , info => $float64_href },
+ { name => 'd9' , info => $float64_href },
+ { name => 'd10' , info => $float64_href },
+ { name => 'd11' , info => $float64_href },
+ { name => 'd12' , info => $float64_href },
+ { name => 'd13' , info => $float64_href },
+ { name => 'd14' , info => $float64_href },
+ { name => 'd15' , info => $float64_href },
+ { name => 'd16' , info => $float64_href },
+ { name => 'd17' , info => $float64_href },
+ { name => 'd18' , info => $float64_href },
+ { name => 'd19' , info => $float64_href },
+ { name => 'd20' , info => $float64_href },
+ { name => 'd21' , info => $float64_href },
+ { name => 'd22' , info => $float64_href },
+ { name => 'd23' , info => $float64_href },
+ { name => 'd24' , info => $float64_href },
+ { name => 'd25' , info => $float64_href },
+ { name => 'd26' , info => $float64_href },
+ { name => 'd27' , info => $float64_href },
+ { name => 'd28' , info => $float64_href },
+ { name => 'd29' , info => $float64_href },
+ { name => 'd30' , info => $float64_href },
+ { name => 'd31' , info => $float64_href },
+ { name => 'fpscr' , info => $reg32_href },
+ { name => 'exc' , info => $reg32_href },
+ { name => 'fsr' , info => $reg32_href },
+ { name => 'far' , info => $reg32_href },
+ ],
+
'x86_64-gdb' => [
{ name => 'rax' , info => $reg64_href },
{ name => 'rbx' , info => $reg64_href },
diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp
index a30e8e3fd80..5098e99c4fc 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp
@@ -147,7 +147,7 @@ AppleObjCRuntimeV1::CreateObjectChecker(const char *name)
"%s(void *$__lldb_arg_obj) \n"
"{ \n"
" struct __objc_object *obj = (struct __objc_object*)$__lldb_arg_obj; \n"
- " strlen(obj->isa->name); \n"
+ " (int)strlen(obj->isa->name); \n"
"} \n",
name) < sizeof(buf->contents));
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
index ac9985548f4..c5e11ef33de 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
@@ -138,7 +138,7 @@ GDBRemoteCommunication::SendPacketNoLock (const char *payload, size_t payload_le
LogSP log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_PACKETS));
if (log)
- log->Printf ("send packet: %s", packet.GetData());
+ log->Printf ("send packet: %.*s", (int)packet.GetSize(), packet.GetData());
ConnectionStatus status = eConnectionStatusSuccess;
size_t bytes_written = Write (packet.GetData(), packet.GetSize(), status, NULL);
if (bytes_written == packet.GetSize())
@@ -156,7 +156,7 @@ GDBRemoteCommunication::SendPacketNoLock (const char *payload, size_t payload_le
{
LogSP log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_PACKETS));
if (log)
- log->Printf ("error: failed to send packet: %s", packet.GetData());
+ log->Printf ("error: failed to send packet: %.*s", (int)packet.GetSize(), packet.GetData());
}
return bytes_written;
}
@@ -218,11 +218,11 @@ GDBRemoteCommunication::WaitForPacketNoLock (StringExtractorGDBRemote &packet, c
const EventDataBytes *event_bytes = EventDataBytes::GetEventDataFromEvent(event_sp.get());
if (event_bytes)
{
- const char * packet_data = (const char *)event_bytes->GetBytes();
+ const char *packet_data = (const char *)event_bytes->GetBytes();
+ const uint32_t packet_size = event_bytes->GetByteSize();
LogSP log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_PACKETS));
if (log)
- log->Printf ("read packet: %s", packet_data);
- const size_t packet_size = event_bytes->GetByteSize();
+ log->Printf ("read packet: %.*s", packet_size, packet_data);
if (packet_data && packet_size > 0)
{
std::string &packet_str = packet.GetStringRef();
@@ -242,9 +242,12 @@ GDBRemoteCommunication::WaitForPacketNoLock (StringExtractorGDBRemote &packet, c
packet_str.assign (packet_data + 1, packet_size - 4);
if (GetSendAcks ())
{
- char packet_checksum = strtol (&packet_data[packet_size-2], NULL, 16);
- char actual_checksum = CalculcateChecksum (&packet_str[0], packet_str.size());
- checksum_error = packet_checksum != actual_checksum;
+ if (success)
+ {
+ char packet_checksum = strtol (&packet_data[packet_size-2], NULL, 16);
+ char actual_checksum = CalculcateChecksum (&packet_str[0], packet_str.size());
+ checksum_error = packet_checksum != actual_checksum;
+ }
// Send the ack or nack if needed
if (checksum_error || !success)
SendNack();
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
index bfb4755931b..314d51f55aa 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
@@ -252,7 +252,7 @@ GDBRemoteCommunicationClient::SendPacketAndWaitForResponse
if (GetSequenceMutex (locker))
{
- if (SendPacketNoLock (payload, strlen(payload)))
+ if (SendPacketNoLock (payload, payload_length))
return WaitForPacketNoLock (response, &timeout_time);
}
else
@@ -1597,8 +1597,8 @@ GDBRemoteCommunicationClient::GetThreadStopInfo (uint32_t tid, StringExtractorGD
m_supports_qThreadStopInfo = false;
}
}
- if (SetCurrentThread (tid))
- return GetStopReply (response);
+// if (SetCurrentThread (tid))
+// return GetStopReply (response);
return false;
}
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
index 7c4c39d2f45..62472732d17 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
@@ -356,18 +356,17 @@ GDBRemoteRegisterContext::ReadAllRegisterValues (lldb::DataBufferSP &data_sp)
if (response.IsErrorResponse())
return false;
- response.GetStringRef().insert(0, 1, 'G');
- if (thread_suffix_supported)
+ std::string &response_str = response.GetStringRef();
+ if (isxdigit(response_str[0]))
{
- char thread_id_cstr[64];
- ::snprintf (thread_id_cstr, sizeof(thread_id_cstr), ";thread:%4.4x;", m_thread.GetID());
- response.GetStringRef().append (thread_id_cstr);
- }
- const char *g_data = response.GetStringRef().c_str();
- size_t g_data_len = strspn(g_data + 1, "0123456789abcdefABCDEF");
- if (g_data_len > 0)
- {
- data_sp.reset (new DataBufferHeap (g_data, g_data_len));
+ response_str.insert(0, 1, 'G');
+ if (thread_suffix_supported)
+ {
+ char thread_id_cstr[64];
+ ::snprintf (thread_id_cstr, sizeof(thread_id_cstr), ";thread:%4.4x;", m_thread.GetID());
+ response_str.append (thread_id_cstr);
+ }
+ data_sp.reset (new DataBufferHeap (response_str.c_str(), response_str.size()));
return true;
}
}
OpenPOWER on IntegriCloud