-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathremote-packet-patch.diff
More file actions
52 lines (47 loc) · 1.88 KB
/
Copy pathremote-packet-patch.diff
File metadata and controls
52 lines (47 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
From 404d815ed23fe1a627eff04975bec27b3fc8bd35 Mon Sep 17 00:00:00 2001
From: 8dcc <8dcc.git@gmail.com>
Date: Fri, 6 Jan 2023 15:50:27 +0100
Subject: [PATCH] Patch g remote packet error
---
gdb/remote.c | 29 ++++++++++++++++++++++++-----
1 file changed, 24 insertions(+), 5 deletions(-)
diff --git a/gdb/remote.c b/gdb/remote.c
index 1a34812..aaec4dd 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -8463,11 +8463,30 @@ remote_target::process_g_packet (struct regcache *regcache)
buf_len = strlen (rs->buf.data ());
/* Further sanity checks, with knowledge of the architecture. */
- if (buf_len > 2 * rsa->sizeof_g_packet)
- error (_("Remote 'g' packet reply is too long (expected %ld bytes, got %d "
- "bytes): %s"),
- rsa->sizeof_g_packet, buf_len / 2,
- rs->buf.data ());
+ /* HACKFIX for changing architectures for qemu. It's ugly. Don't use, unless
+ you have to. Just a tiny modification of the patch of Matias Vara
+ (http://forum.osdev.org/viewtopic.php?f=13&p=177644) */
+ if (buf_len > 2 * rsa->sizeof_g_packet) {
+ warning(_("Assuming long-mode change. [Remote 'g' packet reply is too long "
+ "(expected %ld bytes, got %d bytes): %s"),
+ rsa->sizeof_g_packet, buf_len / 2, rs->buf.data());
+
+ rsa->sizeof_g_packet = buf_len;
+
+ for (i = 0; i < gdbarch_num_regs(gdbarch); i++) {
+ if (rsa->regs[i].pnum == -1)
+ continue;
+
+ if (rsa->regs[i].offset >= rsa->sizeof_g_packet)
+ rsa->regs[i].in_g_packet = 0;
+ else
+ rsa->regs[i].in_g_packet = 1;
+ }
+
+ /* HACKFIX: Make sure at least the lower half of EIP is set correctly, so
+ the proper breakpoint is recognized (and triggered). */
+ rsa->regs[8].offset = 16 * 8;
+ }
/* 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.38.2