Clean up ancient bad typing and malloc madness.
This commit is contained in:
parent
50b6c623d6
commit
dac1f60dc2
|
@ -73,7 +73,7 @@ void
|
||||||
gdb_main(void)
|
gdb_main(void)
|
||||||
{
|
{
|
||||||
int size;
|
int size;
|
||||||
static uint8_t single_step = 0;
|
bool single_step = false;
|
||||||
|
|
||||||
DEBUG("Entring GDB protocol main loop\n");
|
DEBUG("Entring GDB protocol main loop\n");
|
||||||
/* GDB protocol main loop */
|
/* GDB protocol main loop */
|
||||||
|
@ -91,13 +91,11 @@ gdb_main(void)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'm': { /* 'm addr,len': Read len bytes from addr */
|
case 'm': { /* 'm addr,len': Read len bytes from addr */
|
||||||
unsigned long addr, len;
|
uint32_t addr, len;
|
||||||
char *mem;
|
|
||||||
ERROR_IF_NO_TARGET();
|
ERROR_IF_NO_TARGET();
|
||||||
sscanf(pbuf, "m%08lX,%08lX", &addr, &len);
|
sscanf(pbuf, "m%08lX,%08lX", &addr, &len);
|
||||||
DEBUG("m packet: addr = %08lX, len = %08lX\n", addr, len);
|
DEBUG("m packet: addr = %08lX, len = %08lX\n", addr, len);
|
||||||
mem = malloc(len);
|
uint8_t mem[len];
|
||||||
if(!mem) break;
|
|
||||||
if(((addr & 3) == 0) && ((len & 3) == 0))
|
if(((addr & 3) == 0) && ((len & 3) == 0))
|
||||||
target_mem_read_words(cur_target, (void*)mem, addr, len);
|
target_mem_read_words(cur_target, (void*)mem, addr, len);
|
||||||
else
|
else
|
||||||
|
@ -106,7 +104,6 @@ gdb_main(void)
|
||||||
gdb_putpacket("E01", 3);
|
gdb_putpacket("E01", 3);
|
||||||
else
|
else
|
||||||
gdb_putpacket(hexify(pbuf, mem, len), len*2);
|
gdb_putpacket(hexify(pbuf, mem, len), len*2);
|
||||||
free(mem);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'G': { /* 'G XX': Write general registers */
|
case 'G': { /* 'G XX': Write general registers */
|
||||||
|
@ -118,13 +115,12 @@ gdb_main(void)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'M': { /* 'M addr,len:XX': Write len bytes to addr */
|
case 'M': { /* 'M addr,len:XX': Write len bytes to addr */
|
||||||
unsigned long addr, len;
|
uint32_t addr, len;
|
||||||
int hex;
|
int hex;
|
||||||
char *mem;
|
|
||||||
ERROR_IF_NO_TARGET();
|
ERROR_IF_NO_TARGET();
|
||||||
sscanf(pbuf, "M%08lX,%08lX:%n", &addr, &len, &hex);
|
sscanf(pbuf, "M%08lX,%08lX:%n", &addr, &len, &hex);
|
||||||
DEBUG("M packet: addr = %08lX, len = %08lX\n", addr, len);
|
DEBUG("M packet: addr = %08lX, len = %08lX\n", addr, len);
|
||||||
mem = malloc(len);
|
uint8_t mem[len];
|
||||||
unhexify(mem, pbuf + hex, len);
|
unhexify(mem, pbuf + hex, len);
|
||||||
if(((addr & 3) == 0) && ((len & 3) == 0))
|
if(((addr & 3) == 0) && ((len & 3) == 0))
|
||||||
target_mem_write_words(cur_target, addr, (void*)mem, len);
|
target_mem_write_words(cur_target, addr, (void*)mem, len);
|
||||||
|
@ -134,11 +130,10 @@ gdb_main(void)
|
||||||
gdb_putpacket("E01", 3);
|
gdb_putpacket("E01", 3);
|
||||||
else
|
else
|
||||||
gdb_putpacket("OK", 2);
|
gdb_putpacket("OK", 2);
|
||||||
free(mem);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 's': /* 's [addr]': Single step [start at addr] */
|
case 's': /* 's [addr]': Single step [start at addr] */
|
||||||
single_step = 1;
|
single_step = true;
|
||||||
// Fall through to resume target
|
// Fall through to resume target
|
||||||
case 'c': /* 'c [addr]': Continue [at addr] */
|
case 'c': /* 'c [addr]': Continue [at addr] */
|
||||||
if(!cur_target) {
|
if(!cur_target) {
|
||||||
|
@ -148,7 +143,7 @@ gdb_main(void)
|
||||||
|
|
||||||
target_halt_resume(cur_target, single_step);
|
target_halt_resume(cur_target, single_step);
|
||||||
SET_RUN_STATE(1);
|
SET_RUN_STATE(1);
|
||||||
single_step = 0;
|
single_step = false;
|
||||||
// Fall through to wait for target halt
|
// Fall through to wait for target halt
|
||||||
case '?': { /* '?': Request reason for target halt */
|
case '?': { /* '?': Request reason for target halt */
|
||||||
/* This packet isn't documented as being mandatory,
|
/* This packet isn't documented as being mandatory,
|
||||||
|
@ -219,7 +214,7 @@ gdb_main(void)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'X': { /* 'X addr,len:XX': Write binary data to addr */
|
case 'X': { /* 'X addr,len:XX': Write binary data to addr */
|
||||||
unsigned long addr, len;
|
uint32_t addr, len;
|
||||||
int bin;
|
int bin;
|
||||||
ERROR_IF_NO_TARGET();
|
ERROR_IF_NO_TARGET();
|
||||||
sscanf(pbuf, "X%08lX,%08lX:%n", &addr, &len, &bin);
|
sscanf(pbuf, "X%08lX,%08lX:%n", &addr, &len, &bin);
|
||||||
|
@ -248,7 +243,7 @@ gdb_main(void)
|
||||||
case 'z': { /* z type,addr,len: Clear breakpoint packet */
|
case 'z': { /* z type,addr,len: Clear breakpoint packet */
|
||||||
uint8_t set = (pbuf[0]=='Z')?1:0;
|
uint8_t set = (pbuf[0]=='Z')?1:0;
|
||||||
int type, len;
|
int type, len;
|
||||||
unsigned long addr;
|
uint32_t addr;
|
||||||
int ret;
|
int ret;
|
||||||
ERROR_IF_NO_TARGET();
|
ERROR_IF_NO_TARGET();
|
||||||
/* I have no idea why this doesn't work. Seems to work
|
/* I have no idea why this doesn't work. Seems to work
|
||||||
|
|
Loading…
Reference in New Issue