Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

return error condition if st-util's read/write memory commands fail #527

Merged
merged 1 commit into from
Dec 11, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions src/gdbserver/gdb-server.c
Original file line number Diff line number Diff line change
Expand Up @@ -1509,7 +1509,10 @@ int serve(stlink_t *sl, st_state_t *st) {
if (count_rnd < count)
count = count_rnd;

stlink_read_mem32(sl, start - adj_start, count_rnd);
if (stlink_read_mem32(sl, start - adj_start, count_rnd) != 0) {
/* read failed somehow, don't return stale buffer */
count = 0;
}

reply = calloc(count * 2 + 1, 1);
for(unsigned int i = 0; i < count; i++) {
Expand All @@ -1527,6 +1530,7 @@ int serve(stlink_t *sl, st_state_t *st) {

stm32_addr_t start = (stm32_addr_t) strtoul(s_start, NULL, 16);
unsigned count = (unsigned) strtoul(s_count, NULL, 16);
int err = 0;

if(start % 4) {
unsigned align_count = 4 - start % 4;
Expand All @@ -1536,7 +1540,7 @@ int serve(stlink_t *sl, st_state_t *st) {
uint8_t byte = strtoul(hextmp, NULL, 16);
sl->q_buf[i] = byte;
}
stlink_write_mem8(sl, start, align_count);
err |= stlink_write_mem8(sl, start, align_count);
cache_change(start, align_count);
start += align_count;
count -= align_count;
Expand All @@ -1551,7 +1555,7 @@ int serve(stlink_t *sl, st_state_t *st) {
uint8_t byte = strtoul(hextmp, NULL, 16);
sl->q_buf[i] = byte;
}
stlink_write_mem32(sl, start, aligned_count);
err |= stlink_write_mem32(sl, start, aligned_count);
cache_change(start, aligned_count);
count -= aligned_count;
start += aligned_count;
Expand All @@ -1564,10 +1568,10 @@ int serve(stlink_t *sl, st_state_t *st) {
uint8_t byte = strtoul(hextmp, NULL, 16);
sl->q_buf[i] = byte;
}
stlink_write_mem8(sl, start, count);
err |= stlink_write_mem8(sl, start, count);
cache_change(start, count);
}
reply = strdup("OK");
reply = strdup(err ? "E00" : "OK");
break;
}

Expand Down