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

Mem write odd #730

Merged
merged 9 commits into from
Aug 1, 2018
Next Next commit
Use local variable for read_result instead of *ret, and fix
calculation of *ret for EOF case.
  • Loading branch information
donmr committed Jul 26, 2018
commit c1abc8ae74ec1d2926b460fe4a58bcb0e712da0f
5 changes: 3 additions & 2 deletions src/gdbserver/semihosting.c
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ int do_semihosting (stlink_t *sl, uint32_t r0, uint32_t r1, uint32_t *ret) {
int fd;
uint32_t buffer_len;
void *buffer;
int read_result;

if (mem_read(sl, r1, args, sizeof (args)) != 0 ) {
DLOG("Semihosting SYS_READ error: "
Expand Down Expand Up @@ -337,7 +338,7 @@ int do_semihosting (stlink_t *sl, uint32_t r0, uint32_t r1, uint32_t *ret) {
DLOG("Semihosting: read(%d, target_addr:0x%08x, %zu)\n", fd,
buffer_address, buffer_len);

*ret = (uint32_t)read(fd, buffer, buffer_len);
read_result = (uint32_t)read(fd, buffer, buffer_len);
saved_errno = errno;

if (*ret == (uint32_t)-1) {
Expand All @@ -350,7 +351,7 @@ int do_semihosting (stlink_t *sl, uint32_t r0, uint32_t r1, uint32_t *ret) {
*ret = buffer_len;
return -1;
} else {
*ret -= buffer_len;
*ret = buffer_len - read_result;
}
}

Expand Down