Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vathpela/3dc00c7327a6ef5ef8e058825bfdb0e9 to your computer and use it in GitHub Desktop.
Save vathpela/3dc00c7327a6ef5ef8e058825bfdb0e9 to your computer and use it in GitHub Desktop.
From cd506e1b189f48eb068bddcc4c0e0fe2011e38c9 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Tue, 31 May 2016 13:47:06 -0400
Subject: [PATCH] remote: try x86_64 when 'g' packet size is wrong.
Signed-off-by: Peter Jones <pjones@redhat.com>
---
gdb/remote.c | 24 +++++++++++++++++++++++-
1 file changed, 23 insertions(+), 1 deletion(-)
diff --git a/gdb/remote.c b/gdb/remote.c
index ec41a12..f9b840b 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -7297,9 +7297,31 @@ process_g_packet (struct regcache *regcache)
buf_len = strlen (rs->buf);
+ if (buf_len > 2 * rsa->sizeof_g_packet)
+ {
+ execute_command ("set architecture i386:x86-64:intel", 0);
+ gdbarch = get_regcache_arch (regcache);
+ rs = get_remote_state ();
+ rsa = get_remote_arch_state ();
+ }
+
/* Further sanity checks, with knowledge of the architecture. */
if (buf_len > 2 * rsa->sizeof_g_packet)
- error (_("Remote 'g' packet reply is too long: %s"), rs->buf);
+ {
+ rsa->sizeof_g_packet = buf_len;
+ for (i = 0; i < gdbarch_num_regs (gdbarch); i++)
+ {
+ if (rsa->regs->pnum == -1)
+ continue;
+ if (rsa->regs->offset >= rsa->sizeof_g_packet)
+ rsa->regs->in_g_packet = 0;
+ else
+ rsa->regs->in_g_packet = 1;
+ }
+
+ if (rsa->regs->in_g_packet && buf_len > 2 * rsa->sizeof_g_packet)
+ error (_("Remote 'g' packet reply is too long: %s"), rs->buf);
+ }
/* Save the size of the packet sent to us by the target. It is used
as a heuristic when determining the max size of packets that the
--
2.7.4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment