#include <helper/binarybuffer.h>
#include <helper/log.h>
+#include <server/gdb_server.h>
#include <sys/stat.h>
/**
static int semihosting_common_fileio_end(struct target *target, int result,
int fileio_errno, bool ctrl_c);
-/* Attempts to include gdb_server.h failed. */
-extern int gdb_actual_connections;
-
/**
* Initialize common semihosting support.
*
int code = semihosting_get_field(target, 1, fields);
if (type == ADP_STOPPED_APPLICATION_EXIT) {
- if (!gdb_actual_connections)
+ if (!gdb_get_actual_connections())
exit(code);
else {
fprintf(stderr,
}
} else {
if (semihosting->param == ADP_STOPPED_APPLICATION_EXIT) {
- if (!gdb_actual_connections)
+ if (!gdb_get_actual_connections())
exit(0);
else {
fprintf(stderr,
} else if (semihosting->param == ADP_STOPPED_RUN_TIME_ERROR) {
/* Chosen more or less arbitrarily to have a nicer message,
* otherwise all other return the same exit code 1. */
- if (!gdb_actual_connections)
+ if (!gdb_get_actual_connections())
exit(1);
else {
fprintf(stderr,
"semihosting: *** application exited with error ***\n");
}
} else {
- if (!gdb_actual_connections)
+ if (!gdb_get_actual_connections())
exit(1);
else {
fprintf(stderr,
int code = semihosting_get_field(target, 1, fields);
if (type == ADP_STOPPED_APPLICATION_EXIT) {
- if (!gdb_actual_connections)
+ if (!gdb_get_actual_connections())
exit(code);
else {
fprintf(stderr,
if (retval != ERROR_OK)
return retval;
int fd = semihosting_get_field(target, 0, fields);
- semihosting->result = isatty(fd);
+ // isatty() on Windows may return any non-zero value if fd is a terminal
+ semihosting->result = isatty(fd) ? 1 : 0;
semihosting->sys_errno = errno;
LOG_DEBUG("isatty(%d)=%" PRId64, fd, semihosting->result);
}