Skip to content

Commit 97ea540

Browse files
authored
Merge pull request #87 from riscv/gdb_next_port
When gdb_port is 0, don't increment it.
2 parents b9822ab + b897807 commit 97ea540

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/server/gdb_server.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3113,7 +3113,13 @@ static int gdb_target_add_one(struct target *target)
31133113
if (!*end) {
31143114
if (parse_long(gdb_port_next, &portnumber) == ERROR_OK) {
31153115
free(gdb_port_next);
3116-
gdb_port_next = alloc_printf("%d", portnumber+1);
3116+
if (portnumber) {
3117+
gdb_port_next = alloc_printf("%d", portnumber+1);
3118+
} else {
3119+
/* Don't increment if gdb_port is 0, since we're just
3120+
* trying to allocate an unused port. */
3121+
gdb_port_next = alloc_printf("0");
3122+
}
31173123
}
31183124
}
31193125
}

src/server/server.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,8 @@ int add_service(char *name,
273273
c->sin.sin_port = htons(c->portnumber);
274274

275275
if (bind(c->fd, (struct sockaddr *)&c->sin, sizeof(c->sin)) == -1) {
276-
LOG_ERROR("couldn't bind %s to socket: %s", name, strerror(errno));
276+
LOG_ERROR("couldn't bind %s to socket on port %d: %s", name,
277+
c->portnumber, strerror(errno));
277278
close_socket(c->fd);
278279
free_service(c);
279280
return ERROR_FAIL;

0 commit comments

Comments
 (0)