linux: Set SO_REUSEADDR on gdb server socket.

Renamed HOST environment variable to PROBE_HOST.

Thanks to Michael Smith for the patch.
This commit is contained in:
Gareth McMullin 2011-11-25 22:55:07 +13:00
parent d73ac40ef1
commit f06bded8dd
2 changed files with 9 additions and 5 deletions

View File

@ -1,14 +1,14 @@
ifndef HOST
HOST = stm32
ifndef PROBE_HOST
PROBE_HOST = stm32
endif
VPATH += $(HOST)
VPATH += $(PROBE_HOST)
BUILDDATE := `date +"%Y%m%d"`
CFLAGS += -Wall -Wextra -Wno-pointer-sign -Wno-char-subscripts\
-O0 -std=gnu99 -g3 -DBUILDDATE=\"$(BUILDDATE)\"\
-I. -Iinclude -I$(HOST) \
-I. -Iinclude -I$(PROBE_HOST) \
-DVERSION_SUFFIX=\"`../scripts/setlocalversion`\"
SRC = gdb_if.c \
@ -30,7 +30,7 @@ SRC = gdb_if.c \
arm7tdmi.c \
stm32f4.c \
include $(HOST)/Makefile.inc
include $(PROBE_HOST)/Makefile.inc
OBJ = $(SRC:.c=.o)

View File

@ -47,12 +47,16 @@ int gdb_if_init(void)
WSAStartup(MAKEWORD(2, 2), &wsaData);
#endif
struct sockaddr_in addr;
int opt;
addr.sin_family = AF_INET;
addr.sin_port = htons(2000);
addr.sin_addr.s_addr = htonl(INADDR_ANY);
assert((gdb_if_serv = socket(PF_INET, SOCK_STREAM, 0)) != -1);
opt = 1;
assert(setsockopt(gdb_if_serv, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)) != -1);
assert(bind(gdb_if_serv, (void*)&addr, sizeof(addr)) != -1);
assert(listen(gdb_if_serv, 1) != -1);