Mercurial > repos > blastem
annotate gdb_remote.c @ 525:62860044337d
Support single stepping in gdb remote debugger
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Tue, 11 Feb 2014 22:38:47 -0800 |
parents | 1495179d6737 |
children | 6fe73296938a |
rev | line source |
---|---|
467
140af5509ce7
Added copyright notice to source files and added GPL license text in COPYING
Mike Pavone <pavone@retrodev.com>
parents:
456
diff
changeset
|
1 /* |
140af5509ce7
Added copyright notice to source files and added GPL license text in COPYING
Mike Pavone <pavone@retrodev.com>
parents:
456
diff
changeset
|
2 Copyright 2013 Michael Pavone |
505
b7b7a1cab44a
The local clone on my laptop got messed up and some changes had not been pushed. This commit represents the status of the working copy from that clone. It unfortunately contains some changes that I did not intend to commit yet, but this seems like the best option at the moment.
Michael Pavone <pavone@retrodev.com>
parents:
467
diff
changeset
|
3 This file is part of BlastEm. |
467
140af5509ce7
Added copyright notice to source files and added GPL license text in COPYING
Mike Pavone <pavone@retrodev.com>
parents:
456
diff
changeset
|
4 BlastEm is free software distributed under the terms of the GNU General Public License version 3 or greater. See COPYING for full license text. |
140af5509ce7
Added copyright notice to source files and added GPL license text in COPYING
Mike Pavone <pavone@retrodev.com>
parents:
456
diff
changeset
|
5 */ |
515
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
6 #include "gdb_remote.h" |
525
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
7 #include "68kinst.h" |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
8 #include "debug.h" |
456
249d24973682
Initial work on GDB remote debugging support
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
9 #include <unistd.h> |
249d24973682
Initial work on GDB remote debugging support
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
10 #include <fcntl.h> |
249d24973682
Initial work on GDB remote debugging support
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
11 #include <stddef.h> |
249d24973682
Initial work on GDB remote debugging support
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
12 #include <stdlib.h> |
249d24973682
Initial work on GDB remote debugging support
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
13 #include <stdio.h> |
515
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
14 #include <string.h> |
456
249d24973682
Initial work on GDB remote debugging support
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
15 |
515
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
16 #define INITIAL_BUFFER_SIZE (16*1024) |
456
249d24973682
Initial work on GDB remote debugging support
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
17 |
525
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
18 #ifdef DO_DEBUG_PRINT |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
19 #define dfprintf fprintf |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
20 #else |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
21 #define dfprintf |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
22 #endif |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
23 |
456
249d24973682
Initial work on GDB remote debugging support
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
24 char * buf = NULL; |
249d24973682
Initial work on GDB remote debugging support
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
25 char * curbuf = NULL; |
505
b7b7a1cab44a
The local clone on my laptop got messed up and some changes had not been pushed. This commit represents the status of the working copy from that clone. It unfortunately contains some changes that I did not intend to commit yet, but this seems like the best option at the moment.
Michael Pavone <pavone@retrodev.com>
parents:
467
diff
changeset
|
26 char * end = NULL; |
456
249d24973682
Initial work on GDB remote debugging support
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
27 size_t bufsize; |
249d24973682
Initial work on GDB remote debugging support
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
28 int cont = 0; |
249d24973682
Initial work on GDB remote debugging support
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
29 int expect_break_response=0; |
249d24973682
Initial work on GDB remote debugging support
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
30 uint32_t resume_pc; |
249d24973682
Initial work on GDB remote debugging support
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
31 |
515
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
32 |
525
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
33 static uint16_t branch_t; |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
34 static uint16_t branch_f; |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
35 |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
36 static bp_def * breakpoints = NULL; |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
37 static uint32_t bp_index = 0; |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
38 |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
39 |
515
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
40 void hex_32(uint32_t num, char * out) |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
41 { |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
42 for (int32_t shift = 28; shift >= 0; shift -= 4) |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
43 { |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
44 uint8_t nibble = num >> shift & 0xF; |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
45 *(out++) = nibble > 9 ? nibble - 0xA + 'A' : nibble + '0'; |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
46 } |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
47 } |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
48 |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
49 void hex_16(uint16_t num, char * out) |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
50 { |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
51 for (int16_t shift = 14; shift >= 0; shift -= 4) |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
52 { |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
53 uint8_t nibble = num >> shift & 0xF; |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
54 *(out++) = nibble > 9 ? nibble - 0xA + 'A' : nibble + '0'; |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
55 } |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
56 } |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
57 |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
58 void hex_8(uint8_t num, char * out) |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
59 { |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
60 uint8_t nibble = num >> 4; |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
61 *(out++) = nibble > 9 ? nibble - 0xA + 'A' : nibble + '0'; |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
62 nibble = num & 0xF; |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
63 *out = nibble > 9 ? nibble - 0xA + 'A' : nibble + '0'; |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
64 } |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
65 |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
66 void gdb_calc_checksum(char * command, char *out) |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
67 { |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
68 uint8_t checksum = 0; |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
69 while (*command) |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
70 { |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
71 checksum += *(command++); |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
72 } |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
73 hex_8(checksum, out); |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
74 } |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
75 |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
76 void write_or_die(int fd, const void *buf, size_t count) |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
77 { |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
78 if (write(fd, buf, count) < count) { |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
79 fputs("Error writing to stdout\n", stderr); |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
80 exit(1); |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
81 } |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
82 } |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
83 |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
84 void gdb_send_command(char * command) |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
85 { |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
86 char end[3]; |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
87 write_or_die(STDOUT_FILENO, "$", 1); |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
88 write_or_die(STDOUT_FILENO, command, strlen(command)); |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
89 end[0] = '#'; |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
90 gdb_calc_checksum(command, end+1); |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
91 write_or_die(STDOUT_FILENO, end, 3); |
525
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
92 dfprintf(stderr, "Sent $%s#%c%c\n", command, end[1], end[2]); |
515
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
93 } |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
94 |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
95 uint32_t calc_status(m68k_context * context) |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
96 { |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
97 uint32_t status = context->status << 3; |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
98 for (int i = 0; i < 5; i++) |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
99 { |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
100 status <<= 1; |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
101 status |= context->flags[i]; |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
102 } |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
103 return status; |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
104 } |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
105 |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
106 uint8_t read_byte(m68k_context * context, uint32_t address) |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
107 { |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
108 uint16_t * word; |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
109 //TODO: Use generated read/write functions so that memory map is properly respected |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
110 if (address < 0x400000) { |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
111 word = context->mem_pointers[0] + address/2; |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
112 } else if (address >= 0xE00000) { |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
113 word = context->mem_pointers[1] + (address & 0xFFFF)/2; |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
114 } else { |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
115 return 0; |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
116 } |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
117 if (address & 1) { |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
118 return *word; |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
119 } |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
120 return *word >> 8; |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
121 } |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
122 |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
123 void gdb_run_command(m68k_context * context, uint32_t pc, char * command) |
456
249d24973682
Initial work on GDB remote debugging support
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
124 { |
515
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
125 char send_buf[512]; |
525
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
126 dfprintf(stderr, "Received command %s\n", command); |
515
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
127 switch(*command) |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
128 { |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
129 |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
130 case 'c': |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
131 if (*(command+1) != 0) { |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
132 //TODO: implement resuming at an arbitrary address |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
133 goto not_impl; |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
134 } |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
135 cont = 1; |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
136 expect_break_response = 1; |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
137 break; |
525
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
138 case 's': { |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
139 if (*(command+1) != 0) { |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
140 //TODO: implement resuming at an arbitrary address |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
141 goto not_impl; |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
142 } |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
143 m68kinst inst; |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
144 uint16_t * pc_ptr; |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
145 if (pc < 0x400000) { |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
146 pc_ptr = cart + pc/2; |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
147 } else if(pc > 0xE00000) { |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
148 pc_ptr = ram + (pc & 0xFFFF)/2; |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
149 } else { |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
150 fprintf(stderr, "Entered gdb remote debugger stub at address %X\n", pc); |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
151 exit(1); |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
152 } |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
153 uint16_t * after_pc = m68k_decode(pc_ptr, &inst, pc & 0xFFFFFF); |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
154 uint32_t after = pc + (after_pc-pc_ptr)*2; |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
155 |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
156 if (inst.op == M68K_RTS) { |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
157 after = (read_dma_value(context->aregs[7]/2) << 16) | read_dma_value(context->aregs[7]/2 + 1); |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
158 } else if (inst.op == M68K_RTE || inst.op == M68K_RTR) { |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
159 after = (read_dma_value((context->aregs[7]+2)/2) << 16) | read_dma_value((context->aregs[7]+2)/2 + 1); |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
160 } else if(m68k_is_branch(&inst)) { |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
161 if (inst.op == M68K_BCC && inst.extra.cond != COND_TRUE) { |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
162 branch_f = after; |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
163 branch_t = m68k_branch_target(&inst, context->dregs, context->aregs) & 0xFFFFFF; |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
164 insert_breakpoint(context, branch_t, (uint8_t *)gdb_debug_enter); |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
165 } else if(inst.op == M68K_DBCC && inst.extra.cond != COND_FALSE) { |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
166 branch_t = after; |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
167 branch_f = m68k_branch_target(&inst, context->dregs, context->aregs) & 0xFFFFFF; |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
168 insert_breakpoint(context, branch_f, (uint8_t *)gdb_debug_enter); |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
169 } else { |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
170 after = m68k_branch_target(&inst, context->dregs, context->aregs) & 0xFFFFFF; |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
171 } |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
172 } |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
173 insert_breakpoint(context, after, (uint8_t *)gdb_debug_enter); |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
174 |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
175 cont = 1; |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
176 expect_break_response = 1; |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
177 break; |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
178 } |
515
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
179 case 'H': |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
180 if (command[1] == 'g' || command[1] == 'c') {; |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
181 //no thread suport, just acknowledge |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
182 gdb_send_command("OK"); |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
183 } else { |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
184 goto not_impl; |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
185 } |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
186 break; |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
187 case 'Z': { |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
188 uint8_t type = command[1]; |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
189 if (type < '2') { |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
190 uint32_t address = strtoul(command+3, NULL, 16); |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
191 insert_breakpoint(context, address, (uint8_t *)gdb_debug_enter); |
525
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
192 bp_def *new_bp = malloc(sizeof(bp_def)); |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
193 new_bp->next = breakpoints; |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
194 new_bp->address = address; |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
195 new_bp->index = bp_index++; |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
196 breakpoints = new_bp; |
515
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
197 gdb_send_command("OK"); |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
198 } else { |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
199 //watchpoints are not currently supported |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
200 gdb_send_command(""); |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
201 } |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
202 break; |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
203 } |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
204 case 'z': { |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
205 uint8_t type = command[1]; |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
206 if (type < '2') { |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
207 uint32_t address = strtoul(command+3, NULL, 16); |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
208 remove_breakpoint(context, address); |
525
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
209 bp_def **found = find_breakpoint(&breakpoints, address); |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
210 if (*found) |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
211 { |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
212 bp_def * to_remove = *found; |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
213 *found = to_remove->next; |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
214 free(to_remove); |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
215 } |
515
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
216 gdb_send_command("OK"); |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
217 } else { |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
218 //watchpoints are not currently supported |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
219 gdb_send_command(""); |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
220 } |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
221 break; |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
222 } |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
223 case 'g': { |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
224 char * cur = send_buf; |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
225 for (int i = 0; i < 8; i++) |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
226 { |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
227 hex_32(context->dregs[i], cur); |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
228 cur += 8; |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
229 } |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
230 for (int i = 0; i < 8; i++) |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
231 { |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
232 hex_32(context->aregs[i], cur); |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
233 cur += 8; |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
234 } |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
235 hex_32(calc_status(context), cur); |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
236 cur += 8; |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
237 hex_32(pc, cur); |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
238 cur += 8; |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
239 *cur = 0; |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
240 gdb_send_command(send_buf); |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
241 break; |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
242 } |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
243 case 'm': { |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
244 char * rest; |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
245 uint32_t address = strtoul(command+1, &rest, 16); |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
246 uint32_t size = strtoul(rest+1, NULL, 16); |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
247 if (size > sizeof(send_buf-1)/2) { |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
248 size = sizeof(send_buf-1)/2; |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
249 } |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
250 char *cur = send_buf; |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
251 while (size) |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
252 { |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
253 hex_8(read_byte(context, address), cur); |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
254 cur += 2; |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
255 address++; |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
256 size--; |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
257 } |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
258 *cur = 0; |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
259 gdb_send_command(send_buf); |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
260 break; |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
261 } |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
262 case 'p': { |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
263 unsigned long reg = strtoul(command+1, NULL, 16); |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
264 |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
265 if (reg < 8) { |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
266 hex_32(context->dregs[reg], send_buf); |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
267 } else if (reg < 16) { |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
268 hex_32(context->aregs[reg-8], send_buf); |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
269 } else if (reg == 16) { |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
270 hex_32(calc_status(context), send_buf); |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
271 } else if (reg == 17) { |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
272 hex_32(pc, send_buf); |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
273 } else { |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
274 send_buf[0] = 0; |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
275 } |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
276 send_buf[8] = 0; |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
277 gdb_send_command(send_buf); |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
278 break; |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
279 } |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
280 case 'q': |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
281 if (!memcmp("Supported", command+1, strlen("Supported"))) { |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
282 sprintf(send_buf, "PacketSize=%X", (int)bufsize); |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
283 gdb_send_command(send_buf); |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
284 } else if (!memcmp("Attached", command+1, strlen("Supported"))) { |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
285 //not really meaningful for us, but saying we spawned a new process |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
286 //is probably closest to the truth |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
287 gdb_send_command("0"); |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
288 } else if (!memcmp("Offsets", command+1, strlen("Offsets"))) { |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
289 //no relocations, so offsets are all 0 |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
290 gdb_send_command("Text=0;Data=0;Bss=0"); |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
291 } else if (!memcmp("Symbol", command+1, strlen("Symbol"))) { |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
292 gdb_send_command(""); |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
293 } else if (!memcmp("TStatus", command+1, strlen("TStatus"))) { |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
294 //TODO: actual tracepoint support |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
295 gdb_send_command("T0;tnotrun:0"); |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
296 } else if (!memcmp("TfV", command+1, strlen("TfV")) || !memcmp("TfP", command+1, strlen("TfP"))) { |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
297 //TODO: actual tracepoint support |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
298 gdb_send_command(""); |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
299 } else if (command[1] == 'C') { |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
300 //we only support a single thread currently, so send 1 |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
301 gdb_send_command("1"); |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
302 } else { |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
303 goto not_impl; |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
304 } |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
305 break; |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
306 case 'v': |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
307 if (!memcmp("Cont?", command+1, strlen("Cont?"))) { |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
308 gdb_send_command("vCont;c;C;s;S"); |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
309 } else if (!memcmp("Cont;", command+1, strlen("Cont;"))) { |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
310 switch (*(command + 1 + strlen("Cont;"))) |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
311 { |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
312 case 'c': |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
313 case 'C': |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
314 //might be interesting to have continue with signal fire a |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
315 //trap exception or something, but for no we'll treat it as |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
316 //a normal continue |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
317 cont = 1; |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
318 expect_break_response = 1; |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
319 break; |
525
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
320 case 's': |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
321 case 'S': { |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
322 m68kinst inst; |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
323 uint16_t * pc_ptr; |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
324 if (pc < 0x400000) { |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
325 pc_ptr = cart + pc/2; |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
326 } else if(pc > 0xE00000) { |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
327 pc_ptr = ram + (pc & 0xFFFF)/2; |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
328 } else { |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
329 fprintf(stderr, "Entered gdb remote debugger stub at address %X\n", pc); |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
330 exit(1); |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
331 } |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
332 uint16_t * after_pc = m68k_decode(pc_ptr, &inst, pc & 0xFFFFFF); |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
333 uint32_t after = pc + (after_pc-pc_ptr)*2; |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
334 |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
335 if (inst.op == M68K_RTS) { |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
336 after = (read_dma_value(context->aregs[7]/2) << 16) | read_dma_value(context->aregs[7]/2 + 1); |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
337 } else if (inst.op == M68K_RTE || inst.op == M68K_RTR) { |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
338 after = (read_dma_value((context->aregs[7]+2)/2) << 16) | read_dma_value((context->aregs[7]+2)/2 + 1); |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
339 } else if(m68k_is_branch(&inst)) { |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
340 if (inst.op == M68K_BCC && inst.extra.cond != COND_TRUE) { |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
341 branch_f = after; |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
342 branch_t = m68k_branch_target(&inst, context->dregs, context->aregs) & 0xFFFFFF; |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
343 insert_breakpoint(context, branch_t, (uint8_t *)gdb_debug_enter); |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
344 } else if(inst.op == M68K_DBCC && inst.extra.cond != COND_FALSE) { |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
345 branch_t = after; |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
346 branch_f = m68k_branch_target(&inst, context->dregs, context->aregs) & 0xFFFFFF; |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
347 insert_breakpoint(context, branch_f, (uint8_t *)gdb_debug_enter); |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
348 } else { |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
349 after = m68k_branch_target(&inst, context->dregs, context->aregs) & 0xFFFFFF; |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
350 } |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
351 } |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
352 insert_breakpoint(context, after, (uint8_t *)gdb_debug_enter); |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
353 |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
354 cont = 1; |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
355 expect_break_response = 1; |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
356 break; |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
357 } |
515
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
358 default: |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
359 goto not_impl; |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
360 } |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
361 } else { |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
362 goto not_impl; |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
363 } |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
364 break; |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
365 case '?': |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
366 gdb_send_command("S05"); |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
367 break; |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
368 default: |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
369 goto not_impl; |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
370 |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
371 } |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
372 return; |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
373 not_impl: |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
374 fprintf(stderr, "Command %s is not implemented, exiting...\n", command); |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
375 exit(1); |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
376 } |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
377 |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
378 m68k_context * gdb_debug_enter(m68k_context * context, uint32_t pc) |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
379 { |
525
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
380 dfprintf(stderr, "Entered debugger at address %X\n", pc); |
515
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
381 if (expect_break_response) { |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
382 gdb_send_command("S05"); |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
383 expect_break_response = 0; |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
384 } |
525
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
385 if ((pc & 0xFFFFFF) == branch_t) { |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
386 bp_def ** f_bp = find_breakpoint(&breakpoints, branch_f); |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
387 if (!*f_bp) { |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
388 remove_breakpoint(context, branch_f); |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
389 } |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
390 branch_t = branch_f = 0; |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
391 } else if((pc & 0xFFFFFF) == branch_f) { |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
392 bp_def ** t_bp = find_breakpoint(&breakpoints, branch_t); |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
393 if (!*t_bp) { |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
394 remove_breakpoint(context, branch_t); |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
395 } |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
396 branch_t = branch_f = 0; |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
397 } |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
398 //Check if this is a user set breakpoint, or just a temporary one |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
399 bp_def ** this_bp = find_breakpoint(&breakpoints, pc & 0xFFFFFF); |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
400 if (!*this_bp) { |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
401 remove_breakpoint(context, pc & 0xFFFFFF); |
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
402 } |
456
249d24973682
Initial work on GDB remote debugging support
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
403 resume_pc = pc; |
505
b7b7a1cab44a
The local clone on my laptop got messed up and some changes had not been pushed. This commit represents the status of the working copy from that clone. It unfortunately contains some changes that I did not intend to commit yet, but this seems like the best option at the moment.
Michael Pavone <pavone@retrodev.com>
parents:
467
diff
changeset
|
404 cont = 0; |
b7b7a1cab44a
The local clone on my laptop got messed up and some changes had not been pushed. This commit represents the status of the working copy from that clone. It unfortunately contains some changes that I did not intend to commit yet, but this seems like the best option at the moment.
Michael Pavone <pavone@retrodev.com>
parents:
467
diff
changeset
|
405 uint8_t partial = 0; |
456
249d24973682
Initial work on GDB remote debugging support
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
406 while(!cont) |
249d24973682
Initial work on GDB remote debugging support
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
407 { |
505
b7b7a1cab44a
The local clone on my laptop got messed up and some changes had not been pushed. This commit represents the status of the working copy from that clone. It unfortunately contains some changes that I did not intend to commit yet, but this seems like the best option at the moment.
Michael Pavone <pavone@retrodev.com>
parents:
467
diff
changeset
|
408 if (!curbuf) { |
b7b7a1cab44a
The local clone on my laptop got messed up and some changes had not been pushed. This commit represents the status of the working copy from that clone. It unfortunately contains some changes that I did not intend to commit yet, but this seems like the best option at the moment.
Michael Pavone <pavone@retrodev.com>
parents:
467
diff
changeset
|
409 int numread = read(STDIN_FILENO, buf, bufsize); |
b7b7a1cab44a
The local clone on my laptop got messed up and some changes had not been pushed. This commit represents the status of the working copy from that clone. It unfortunately contains some changes that I did not intend to commit yet, but this seems like the best option at the moment.
Michael Pavone <pavone@retrodev.com>
parents:
467
diff
changeset
|
410 curbuf = buf; |
b7b7a1cab44a
The local clone on my laptop got messed up and some changes had not been pushed. This commit represents the status of the working copy from that clone. It unfortunately contains some changes that I did not intend to commit yet, but this seems like the best option at the moment.
Michael Pavone <pavone@retrodev.com>
parents:
467
diff
changeset
|
411 end = buf + numread; |
b7b7a1cab44a
The local clone on my laptop got messed up and some changes had not been pushed. This commit represents the status of the working copy from that clone. It unfortunately contains some changes that I did not intend to commit yet, but this seems like the best option at the moment.
Michael Pavone <pavone@retrodev.com>
parents:
467
diff
changeset
|
412 } else if (partial) { |
b7b7a1cab44a
The local clone on my laptop got messed up and some changes had not been pushed. This commit represents the status of the working copy from that clone. It unfortunately contains some changes that I did not intend to commit yet, but this seems like the best option at the moment.
Michael Pavone <pavone@retrodev.com>
parents:
467
diff
changeset
|
413 if (curbuf != buf) { |
b7b7a1cab44a
The local clone on my laptop got messed up and some changes had not been pushed. This commit represents the status of the working copy from that clone. It unfortunately contains some changes that I did not intend to commit yet, but this seems like the best option at the moment.
Michael Pavone <pavone@retrodev.com>
parents:
467
diff
changeset
|
414 memmove(curbuf, buf, end-curbuf); |
515
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
415 end -= curbuf - buf; |
505
b7b7a1cab44a
The local clone on my laptop got messed up and some changes had not been pushed. This commit represents the status of the working copy from that clone. It unfortunately contains some changes that I did not intend to commit yet, but this seems like the best option at the moment.
Michael Pavone <pavone@retrodev.com>
parents:
467
diff
changeset
|
416 } |
b7b7a1cab44a
The local clone on my laptop got messed up and some changes had not been pushed. This commit represents the status of the working copy from that clone. It unfortunately contains some changes that I did not intend to commit yet, but this seems like the best option at the moment.
Michael Pavone <pavone@retrodev.com>
parents:
467
diff
changeset
|
417 int numread = read(STDIN_FILENO, end, bufsize - (end-buf)); |
b7b7a1cab44a
The local clone on my laptop got messed up and some changes had not been pushed. This commit represents the status of the working copy from that clone. It unfortunately contains some changes that I did not intend to commit yet, but this seems like the best option at the moment.
Michael Pavone <pavone@retrodev.com>
parents:
467
diff
changeset
|
418 end += numread; |
b7b7a1cab44a
The local clone on my laptop got messed up and some changes had not been pushed. This commit represents the status of the working copy from that clone. It unfortunately contains some changes that I did not intend to commit yet, but this seems like the best option at the moment.
Michael Pavone <pavone@retrodev.com>
parents:
467
diff
changeset
|
419 curbuf = buf; |
b7b7a1cab44a
The local clone on my laptop got messed up and some changes had not been pushed. This commit represents the status of the working copy from that clone. It unfortunately contains some changes that I did not intend to commit yet, but this seems like the best option at the moment.
Michael Pavone <pavone@retrodev.com>
parents:
467
diff
changeset
|
420 } |
b7b7a1cab44a
The local clone on my laptop got messed up and some changes had not been pushed. This commit represents the status of the working copy from that clone. It unfortunately contains some changes that I did not intend to commit yet, but this seems like the best option at the moment.
Michael Pavone <pavone@retrodev.com>
parents:
467
diff
changeset
|
421 for (; curbuf < end; curbuf++) |
b7b7a1cab44a
The local clone on my laptop got messed up and some changes had not been pushed. This commit represents the status of the working copy from that clone. It unfortunately contains some changes that I did not intend to commit yet, but this seems like the best option at the moment.
Michael Pavone <pavone@retrodev.com>
parents:
467
diff
changeset
|
422 { |
b7b7a1cab44a
The local clone on my laptop got messed up and some changes had not been pushed. This commit represents the status of the working copy from that clone. It unfortunately contains some changes that I did not intend to commit yet, but this seems like the best option at the moment.
Michael Pavone <pavone@retrodev.com>
parents:
467
diff
changeset
|
423 if (*curbuf == '$') |
b7b7a1cab44a
The local clone on my laptop got messed up and some changes had not been pushed. This commit represents the status of the working copy from that clone. It unfortunately contains some changes that I did not intend to commit yet, but this seems like the best option at the moment.
Michael Pavone <pavone@retrodev.com>
parents:
467
diff
changeset
|
424 { |
b7b7a1cab44a
The local clone on my laptop got messed up and some changes had not been pushed. This commit represents the status of the working copy from that clone. It unfortunately contains some changes that I did not intend to commit yet, but this seems like the best option at the moment.
Michael Pavone <pavone@retrodev.com>
parents:
467
diff
changeset
|
425 curbuf++; |
b7b7a1cab44a
The local clone on my laptop got messed up and some changes had not been pushed. This commit represents the status of the working copy from that clone. It unfortunately contains some changes that I did not intend to commit yet, but this seems like the best option at the moment.
Michael Pavone <pavone@retrodev.com>
parents:
467
diff
changeset
|
426 char * start = curbuf; |
b7b7a1cab44a
The local clone on my laptop got messed up and some changes had not been pushed. This commit represents the status of the working copy from that clone. It unfortunately contains some changes that I did not intend to commit yet, but this seems like the best option at the moment.
Michael Pavone <pavone@retrodev.com>
parents:
467
diff
changeset
|
427 while (curbuf < end && *curbuf != '#') { |
b7b7a1cab44a
The local clone on my laptop got messed up and some changes had not been pushed. This commit represents the status of the working copy from that clone. It unfortunately contains some changes that I did not intend to commit yet, but this seems like the best option at the moment.
Michael Pavone <pavone@retrodev.com>
parents:
467
diff
changeset
|
428 curbuf++; |
b7b7a1cab44a
The local clone on my laptop got messed up and some changes had not been pushed. This commit represents the status of the working copy from that clone. It unfortunately contains some changes that I did not intend to commit yet, but this seems like the best option at the moment.
Michael Pavone <pavone@retrodev.com>
parents:
467
diff
changeset
|
429 } |
b7b7a1cab44a
The local clone on my laptop got messed up and some changes had not been pushed. This commit represents the status of the working copy from that clone. It unfortunately contains some changes that I did not intend to commit yet, but this seems like the best option at the moment.
Michael Pavone <pavone@retrodev.com>
parents:
467
diff
changeset
|
430 if (*curbuf == '#') { |
b7b7a1cab44a
The local clone on my laptop got messed up and some changes had not been pushed. This commit represents the status of the working copy from that clone. It unfortunately contains some changes that I did not intend to commit yet, but this seems like the best option at the moment.
Michael Pavone <pavone@retrodev.com>
parents:
467
diff
changeset
|
431 //check to make sure we've received the checksum bytes |
b7b7a1cab44a
The local clone on my laptop got messed up and some changes had not been pushed. This commit represents the status of the working copy from that clone. It unfortunately contains some changes that I did not intend to commit yet, but this seems like the best option at the moment.
Michael Pavone <pavone@retrodev.com>
parents:
467
diff
changeset
|
432 if (end-curbuf >= 2) { |
b7b7a1cab44a
The local clone on my laptop got messed up and some changes had not been pushed. This commit represents the status of the working copy from that clone. It unfortunately contains some changes that I did not intend to commit yet, but this seems like the best option at the moment.
Michael Pavone <pavone@retrodev.com>
parents:
467
diff
changeset
|
433 //TODO: verify checksum |
b7b7a1cab44a
The local clone on my laptop got messed up and some changes had not been pushed. This commit represents the status of the working copy from that clone. It unfortunately contains some changes that I did not intend to commit yet, but this seems like the best option at the moment.
Michael Pavone <pavone@retrodev.com>
parents:
467
diff
changeset
|
434 //Null terminate payload |
515
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
435 *curbuf = 0; |
505
b7b7a1cab44a
The local clone on my laptop got messed up and some changes had not been pushed. This commit represents the status of the working copy from that clone. It unfortunately contains some changes that I did not intend to commit yet, but this seems like the best option at the moment.
Michael Pavone <pavone@retrodev.com>
parents:
467
diff
changeset
|
436 //send acknowledgement |
515
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
437 if (write(STDOUT_FILENO, "+", 1) < 1) { |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
438 fputs("Error writing to stdout\n", stderr); |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
439 exit(1); |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
440 } |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
441 gdb_run_command(context, pc, start); |
505
b7b7a1cab44a
The local clone on my laptop got messed up and some changes had not been pushed. This commit represents the status of the working copy from that clone. It unfortunately contains some changes that I did not intend to commit yet, but this seems like the best option at the moment.
Michael Pavone <pavone@retrodev.com>
parents:
467
diff
changeset
|
442 curbuf += 2; |
b7b7a1cab44a
The local clone on my laptop got messed up and some changes had not been pushed. This commit represents the status of the working copy from that clone. It unfortunately contains some changes that I did not intend to commit yet, but this seems like the best option at the moment.
Michael Pavone <pavone@retrodev.com>
parents:
467
diff
changeset
|
443 } |
b7b7a1cab44a
The local clone on my laptop got messed up and some changes had not been pushed. This commit represents the status of the working copy from that clone. It unfortunately contains some changes that I did not intend to commit yet, but this seems like the best option at the moment.
Michael Pavone <pavone@retrodev.com>
parents:
467
diff
changeset
|
444 } else { |
b7b7a1cab44a
The local clone on my laptop got messed up and some changes had not been pushed. This commit represents the status of the working copy from that clone. It unfortunately contains some changes that I did not intend to commit yet, but this seems like the best option at the moment.
Michael Pavone <pavone@retrodev.com>
parents:
467
diff
changeset
|
445 curbuf--; |
b7b7a1cab44a
The local clone on my laptop got messed up and some changes had not been pushed. This commit represents the status of the working copy from that clone. It unfortunately contains some changes that I did not intend to commit yet, but this seems like the best option at the moment.
Michael Pavone <pavone@retrodev.com>
parents:
467
diff
changeset
|
446 partial = 1; |
b7b7a1cab44a
The local clone on my laptop got messed up and some changes had not been pushed. This commit represents the status of the working copy from that clone. It unfortunately contains some changes that I did not intend to commit yet, but this seems like the best option at the moment.
Michael Pavone <pavone@retrodev.com>
parents:
467
diff
changeset
|
447 break; |
b7b7a1cab44a
The local clone on my laptop got messed up and some changes had not been pushed. This commit represents the status of the working copy from that clone. It unfortunately contains some changes that I did not intend to commit yet, but this seems like the best option at the moment.
Michael Pavone <pavone@retrodev.com>
parents:
467
diff
changeset
|
448 } |
515
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
449 } else { |
525
62860044337d
Support single stepping in gdb remote debugger
Mike Pavone <pavone@retrodev.com>
parents:
515
diff
changeset
|
450 dfprintf(stderr, "Ignoring character %c\n", *curbuf); |
505
b7b7a1cab44a
The local clone on my laptop got messed up and some changes had not been pushed. This commit represents the status of the working copy from that clone. It unfortunately contains some changes that I did not intend to commit yet, but this seems like the best option at the moment.
Michael Pavone <pavone@retrodev.com>
parents:
467
diff
changeset
|
451 } |
b7b7a1cab44a
The local clone on my laptop got messed up and some changes had not been pushed. This commit represents the status of the working copy from that clone. It unfortunately contains some changes that I did not intend to commit yet, but this seems like the best option at the moment.
Michael Pavone <pavone@retrodev.com>
parents:
467
diff
changeset
|
452 } |
515
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
453 if (curbuf == end) { |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
454 curbuf = NULL; |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
455 } |
456
249d24973682
Initial work on GDB remote debugging support
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
456 } |
515
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
457 return context; |
456
249d24973682
Initial work on GDB remote debugging support
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
458 } |
249d24973682
Initial work on GDB remote debugging support
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
459 |
515
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
460 void gdb_remote_init(void) |
456
249d24973682
Initial work on GDB remote debugging support
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
461 { |
515
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
462 buf = malloc(INITIAL_BUFFER_SIZE); |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
463 curbuf = NULL; |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
464 bufsize = INITIAL_BUFFER_SIZE; |
456
249d24973682
Initial work on GDB remote debugging support
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
465 } |