Skip to content

Commit 3a6e6a2

Browse files
borneoaerhankur
authored andcommitted
mem_ap: fix GDB connections
After commit d9b2607 ("gdb_server: support sparse register maps"), GDB crashes while requesting the value of 'cpsr' because the fake register is tagged as not existing. Change the logic and set all register as existing, while still limiting the list for the initial GDB request at connect. Change-Id: I1c4e274c06147683db2a59a8920ae5ccd863e15c Signed-off-by: Antonio Borneo <[email protected]> Reviewed-on: https://review.openocd.org/c/openocd/+/8163 Tested-by: jenkins
1 parent 99f2ea1 commit 3a6e6a2

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/target/mem_ap.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,11 +194,11 @@ static const char *mem_ap_get_gdb_arch(const struct target *target)
194194
* reg[24]: 32 bits, fps
195195
* reg[25]: 32 bits, cpsr
196196
*
197-
* Set 'exist' only to reg[0..15], so initial response to GDB is correct
197+
* GDB requires only reg[0..15]
198198
*/
199199
#define NUM_REGS 26
200+
#define NUM_GDB_REGS 16
200201
#define MAX_REG_SIZE 96
201-
#define REG_EXIST(n) ((n) < 16)
202202
#define REG_SIZE(n) ((((n) >= 16) && ((n) < 24)) ? 96 : 32)
203203

204204
struct mem_ap_alloc_reg_list {
@@ -218,14 +218,14 @@ static int mem_ap_get_gdb_reg_list(struct target *target, struct reg **reg_list[
218218
}
219219

220220
*reg_list = mem_ap_alloc->reg_list;
221-
*reg_list_size = NUM_REGS;
221+
*reg_list_size = (reg_class == REG_CLASS_ALL) ? NUM_REGS : NUM_GDB_REGS;
222222
struct reg *regs = mem_ap_alloc->regs;
223223

224224
for (int i = 0; i < NUM_REGS; i++) {
225225
regs[i].number = i;
226226
regs[i].value = mem_ap_alloc->regs_value;
227227
regs[i].size = REG_SIZE(i);
228-
regs[i].exist = REG_EXIST(i);
228+
regs[i].exist = true;
229229
regs[i].type = &mem_ap_reg_arch_type;
230230
(*reg_list)[i] = &regs[i];
231231
}

0 commit comments

Comments
 (0)