gdb_server: fix double free
[openocd.git] / src / server / server.c
1 /***************************************************************************
2 * Copyright (C) 2005 by Dominic Rath *
3 * Dominic.Rath@gmx.de *
4 * *
5 * Copyright (C) 2007-2010 Øyvind Harboe *
6 * oyvind.harboe@zylin.com *
7 * *
8 * Copyright (C) 2008 by Spencer Oliver *
9 * spen@spen-soft.co.uk *
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 * This program is distributed in the hope that it will be useful, *
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
19 * GNU General Public License for more details. *
20 * *
21 * You should have received a copy of the GNU General Public License *
22 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
23 ***************************************************************************/
24
25 #ifdef HAVE_CONFIG_H
26 #include "config.h"
27 #endif
28
29 #include "server.h"
30 #include <helper/time_support.h>
31 #include <target/target.h>
32 #include <target/target_request.h>
33 #include <target/openrisc/jsp_server.h>
34 #include "openocd.h"
35 #include "tcl_server.h"
36 #include "telnet_server.h"
37
38 #include <signal.h>
39
40 #ifdef HAVE_NETDB_H
41 #include <netdb.h>
42 #endif
43
44 #ifndef _WIN32
45 #include <netinet/tcp.h>
46 #endif
47
48 static struct service *services;
49
50 enum shutdown_reason {
51 CONTINUE_MAIN_LOOP, /* stay in main event loop */
52 SHUTDOWN_REQUESTED, /* set by shutdown command; exit the event loop and quit the debugger */
53 SHUTDOWN_WITH_ERROR_CODE, /* set by shutdown command; quit with non-zero return code */
54 SHUTDOWN_WITH_SIGNAL_CODE /* set by sig_handler; exec shutdown then exit with signal as return code */
55 };
56 static enum shutdown_reason shutdown_openocd = CONTINUE_MAIN_LOOP;
57
58 /* store received signal to exit application by killing ourselves */
59 static int last_signal;
60
61 /* set the polling period to 100ms */
62 static int polling_period = 100;
63
64 /* address by name on which to listen for incoming TCP/IP connections */
65 static char *bindto_name;
66
67 static int add_connection(struct service *service, struct command_context *cmd_ctx)
68 {
69 socklen_t address_size;
70 struct connection *c, **p;
71 int retval;
72 int flag = 1;
73
74 c = malloc(sizeof(struct connection));
75 c->fd = -1;
76 c->fd_out = -1;
77 memset(&c->sin, 0, sizeof(c->sin));
78 c->cmd_ctx = copy_command_context(cmd_ctx);
79 c->service = service;
80 c->input_pending = false;
81 c->priv = NULL;
82 c->next = NULL;
83
84 if (service->type == CONNECTION_TCP) {
85 address_size = sizeof(c->sin);
86
87 c->fd = accept(service->fd, (struct sockaddr *)&service->sin, &address_size);
88 c->fd_out = c->fd;
89
90 /* This increases performance dramatically for e.g. GDB load which
91 * does not have a sliding window protocol.
92 *
93 * Ignore errors from this fn as it probably just means less performance
94 */
95 setsockopt(c->fd, /* socket affected */
96 IPPROTO_TCP, /* set option at TCP level */
97 TCP_NODELAY, /* name of option */
98 (char *)&flag, /* the cast is historical cruft */
99 sizeof(int)); /* length of option value */
100
101 LOG_INFO("accepting '%s' connection on tcp/%s", service->name, service->port);
102 retval = service->new_connection(c);
103 if (retval != ERROR_OK) {
104 close_socket(c->fd);
105 LOG_ERROR("attempted '%s' connection rejected", service->name);
106 command_done(c->cmd_ctx);
107 free(c);
108 return retval;
109 }
110 } else if (service->type == CONNECTION_STDINOUT) {
111 c->fd = service->fd;
112 c->fd_out = fileno(stdout);
113
114 #ifdef _WIN32
115 /* we are using stdin/out so ignore ctrl-c under windoze */
116 SetConsoleCtrlHandler(NULL, TRUE);
117 #endif
118
119 /* do not check for new connections again on stdin */
120 service->fd = -1;
121
122 LOG_INFO("accepting '%s' connection from pipe", service->name);
123 retval = service->new_connection(c);
124 if (retval != ERROR_OK) {
125 LOG_ERROR("attempted '%s' connection rejected", service->name);
126 command_done(c->cmd_ctx);
127 free(c);
128 return retval;
129 }
130 } else if (service->type == CONNECTION_PIPE) {
131 c->fd = service->fd;
132 /* do not check for new connections again on stdin */
133 service->fd = -1;
134
135 char *out_file = alloc_printf("%so", service->port);
136 c->fd_out = open(out_file, O_WRONLY);
137 free(out_file);
138 if (c->fd_out == -1) {
139 LOG_ERROR("could not open %s", service->port);
140 command_done(c->cmd_ctx);
141 free(c);
142 return ERROR_FAIL;
143 }
144
145 LOG_INFO("accepting '%s' connection from pipe %s", service->name, service->port);
146 retval = service->new_connection(c);
147 if (retval != ERROR_OK) {
148 LOG_ERROR("attempted '%s' connection rejected", service->name);
149 command_done(c->cmd_ctx);
150 free(c);
151 return retval;
152 }
153 }
154
155 /* add to the end of linked list */
156 for (p = &service->connections; *p; p = &(*p)->next)
157 ;
158 *p = c;
159
160 if (service->max_connections != CONNECTION_LIMIT_UNLIMITED)
161 service->max_connections--;
162
163 return ERROR_OK;
164 }
165
166 static int remove_connection(struct service *service, struct connection *connection)
167 {
168 struct connection **p = &service->connections;
169 struct connection *c;
170
171 /* find connection */
172 while ((c = *p)) {
173 if (c->fd == connection->fd) {
174 service->connection_closed(c);
175 if (service->type == CONNECTION_TCP)
176 close_socket(c->fd);
177 else if (service->type == CONNECTION_PIPE) {
178 /* The service will listen to the pipe again */
179 c->service->fd = c->fd;
180 }
181
182 command_done(c->cmd_ctx);
183
184 /* delete connection */
185 *p = c->next;
186 free(c);
187
188 if (service->max_connections != CONNECTION_LIMIT_UNLIMITED)
189 service->max_connections++;
190
191 break;
192 }
193
194 /* redirect p to next list pointer */
195 p = &(*p)->next;
196 }
197
198 return ERROR_OK;
199 }
200
201 static void free_service(struct service *c)
202 {
203 free(c->name);
204 free(c->port);
205 free(c);
206 }
207
208 int add_service(char *name,
209 const char *port,
210 int max_connections,
211 new_connection_handler_t new_connection_handler,
212 input_handler_t input_handler,
213 connection_closed_handler_t connection_closed_handler,
214 void *priv)
215 {
216 struct service *c, **p;
217 struct hostent *hp;
218 int so_reuseaddr_option = 1;
219
220 c = malloc(sizeof(struct service));
221
222 c->name = strdup(name);
223 c->port = strdup(port);
224 c->max_connections = 1; /* Only TCP/IP ports can support more than one connection */
225 c->fd = -1;
226 c->connections = NULL;
227 c->new_connection = new_connection_handler;
228 c->input = input_handler;
229 c->connection_closed = connection_closed_handler;
230 c->priv = priv;
231 c->next = NULL;
232 long portnumber;
233 if (strcmp(c->port, "pipe") == 0)
234 c->type = CONNECTION_STDINOUT;
235 else {
236 char *end;
237 portnumber = strtol(c->port, &end, 0);
238 if (!*end && (parse_long(c->port, &portnumber) == ERROR_OK)) {
239 c->portnumber = portnumber;
240 c->type = CONNECTION_TCP;
241 } else
242 c->type = CONNECTION_PIPE;
243 }
244
245 if (c->type == CONNECTION_TCP) {
246 c->max_connections = max_connections;
247
248 c->fd = socket(AF_INET, SOCK_STREAM, 0);
249 if (c->fd == -1) {
250 LOG_ERROR("error creating socket: %s", strerror(errno));
251 free_service(c);
252 return ERROR_FAIL;
253 }
254
255 setsockopt(c->fd,
256 SOL_SOCKET,
257 SO_REUSEADDR,
258 (void *)&so_reuseaddr_option,
259 sizeof(int));
260
261 socket_nonblock(c->fd);
262
263 memset(&c->sin, 0, sizeof(c->sin));
264 c->sin.sin_family = AF_INET;
265
266 if (!bindto_name)
267 c->sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
268 else {
269 hp = gethostbyname(bindto_name);
270 if (!hp) {
271 LOG_ERROR("couldn't resolve bindto address: %s", bindto_name);
272 close_socket(c->fd);
273 free_service(c);
274 return ERROR_FAIL;
275 }
276 memcpy(&c->sin.sin_addr, hp->h_addr_list[0], hp->h_length);
277 }
278 c->sin.sin_port = htons(c->portnumber);
279
280 if (bind(c->fd, (struct sockaddr *)&c->sin, sizeof(c->sin)) == -1) {
281 LOG_ERROR("couldn't bind %s to socket on port %d: %s", name, c->portnumber, strerror(errno));
282 close_socket(c->fd);
283 free_service(c);
284 return ERROR_FAIL;
285 }
286
287 #ifndef _WIN32
288 int segsize = 65536;
289 setsockopt(c->fd, IPPROTO_TCP, TCP_MAXSEG, &segsize, sizeof(int));
290 #endif
291 int window_size = 128 * 1024;
292
293 /* These setsockopt()s must happen before the listen() */
294
295 setsockopt(c->fd, SOL_SOCKET, SO_SNDBUF,
296 (char *)&window_size, sizeof(window_size));
297 setsockopt(c->fd, SOL_SOCKET, SO_RCVBUF,
298 (char *)&window_size, sizeof(window_size));
299
300 if (listen(c->fd, 1) == -1) {
301 LOG_ERROR("couldn't listen on socket: %s", strerror(errno));
302 close_socket(c->fd);
303 free_service(c);
304 return ERROR_FAIL;
305 }
306
307 struct sockaddr_in addr_in;
308 addr_in.sin_port = 0;
309 socklen_t addr_in_size = sizeof(addr_in);
310 if (getsockname(c->fd, (struct sockaddr *)&addr_in, &addr_in_size) == 0)
311 LOG_INFO("Listening on port %hu for %s connections",
312 ntohs(addr_in.sin_port), name);
313 } else if (c->type == CONNECTION_STDINOUT) {
314 c->fd = fileno(stdin);
315
316 #ifdef _WIN32
317 /* for win32 set stdin/stdout to binary mode */
318 if (_setmode(_fileno(stdout), _O_BINARY) < 0)
319 LOG_WARNING("cannot change stdout mode to binary");
320 if (_setmode(_fileno(stdin), _O_BINARY) < 0)
321 LOG_WARNING("cannot change stdin mode to binary");
322 if (_setmode(_fileno(stderr), _O_BINARY) < 0)
323 LOG_WARNING("cannot change stderr mode to binary");
324 #else
325 socket_nonblock(c->fd);
326 #endif
327 } else if (c->type == CONNECTION_PIPE) {
328 #ifdef _WIN32
329 /* we currently do not support named pipes under win32
330 * so exit openocd for now */
331 LOG_ERROR("Named pipes currently not supported under this os");
332 free_service(c);
333 return ERROR_FAIL;
334 #else
335 /* Pipe we're reading from */
336 c->fd = open(c->port, O_RDONLY | O_NONBLOCK);
337 if (c->fd == -1) {
338 LOG_ERROR("could not open %s", c->port);
339 free_service(c);
340 return ERROR_FAIL;
341 }
342 #endif
343 }
344
345 /* add to the end of linked list */
346 for (p = &services; *p; p = &(*p)->next)
347 ;
348 *p = c;
349
350 return ERROR_OK;
351 }
352
353 static void remove_connections(struct service *service)
354 {
355 struct connection *connection;
356
357 connection = service->connections;
358
359 while (connection) {
360 struct connection *tmp;
361
362 tmp = connection->next;
363 remove_connection(service, connection);
364 connection = tmp;
365 }
366 }
367
368 int remove_service(const char *name, const char *port)
369 {
370 struct service *tmp;
371 struct service *prev;
372
373 prev = services;
374
375 for (tmp = services; tmp; prev = tmp, tmp = tmp->next) {
376 if (!strcmp(tmp->name, name) && !strcmp(tmp->port, port)) {
377 remove_connections(tmp);
378
379 if (tmp == services)
380 services = tmp->next;
381 else
382 prev->next = tmp->next;
383
384 if (tmp->type != CONNECTION_STDINOUT)
385 close_socket(tmp->fd);
386
387 free(tmp->priv);
388 free_service(tmp);
389
390 return ERROR_OK;
391 }
392 }
393
394 return ERROR_OK;
395 }
396
397 static int remove_services(void)
398 {
399 struct service *c = services;
400
401 /* loop service */
402 while (c) {
403 struct service *next = c->next;
404
405 remove_connections(c);
406
407 free(c->name);
408
409 if (c->type == CONNECTION_PIPE) {
410 if (c->fd != -1)
411 close(c->fd);
412 }
413 free(c->port);
414 free(c->priv);
415 /* delete service */
416 free(c);
417
418 /* remember the last service for unlinking */
419 c = next;
420 }
421
422 services = NULL;
423
424 return ERROR_OK;
425 }
426
427 int server_loop(struct command_context *command_context)
428 {
429 struct service *service;
430
431 bool poll_ok = true;
432
433 /* used in select() */
434 fd_set read_fds;
435 int fd_max;
436
437 /* used in accept() */
438 int retval;
439
440 int64_t next_event = timeval_ms() + polling_period;
441
442 #ifndef _WIN32
443 if (signal(SIGPIPE, SIG_IGN) == SIG_ERR)
444 LOG_ERROR("couldn't set SIGPIPE to SIG_IGN");
445 #endif
446
447 while (shutdown_openocd == CONTINUE_MAIN_LOOP) {
448 /* monitor sockets for activity */
449 fd_max = 0;
450 FD_ZERO(&read_fds);
451
452 /* add service and connection fds to read_fds */
453 for (service = services; service; service = service->next) {
454 if (service->fd != -1) {
455 /* listen for new connections */
456 FD_SET(service->fd, &read_fds);
457
458 if (service->fd > fd_max)
459 fd_max = service->fd;
460 }
461
462 if (service->connections) {
463 struct connection *c;
464
465 for (c = service->connections; c; c = c->next) {
466 /* check for activity on the connection */
467 FD_SET(c->fd, &read_fds);
468 if (c->fd > fd_max)
469 fd_max = c->fd;
470 }
471 }
472 }
473
474 struct timeval tv;
475 tv.tv_sec = 0;
476 if (poll_ok) {
477 /* we're just polling this iteration, this is faster on embedded
478 * hosts */
479 tv.tv_usec = 0;
480 retval = socket_select(fd_max + 1, &read_fds, NULL, NULL, &tv);
481 } else {
482 /* Every 100ms, can be changed with "poll_period" command */
483 int timeout_ms = next_event - timeval_ms();
484 if (timeout_ms < 0)
485 timeout_ms = 0;
486 else if (timeout_ms > polling_period)
487 timeout_ms = polling_period;
488 tv.tv_usec = timeout_ms * 1000;
489 /* Only while we're sleeping we'll let others run */
490 kept_alive();
491 retval = socket_select(fd_max + 1, &read_fds, NULL, NULL, &tv);
492 }
493
494 if (retval == -1) {
495 #ifdef _WIN32
496
497 errno = WSAGetLastError();
498
499 if (errno == WSAEINTR)
500 FD_ZERO(&read_fds);
501 else {
502 LOG_ERROR("error during select: %s", strerror(errno));
503 return ERROR_FAIL;
504 }
505 #else
506
507 if (errno == EINTR)
508 FD_ZERO(&read_fds);
509 else {
510 LOG_ERROR("error during select: %s", strerror(errno));
511 return ERROR_FAIL;
512 }
513 #endif
514 }
515
516 if (retval == 0) {
517 /* We only execute these callbacks when there was nothing to do or we timed
518 *out */
519 target_call_timer_callbacks_now();
520 next_event = target_timer_next_event();
521 process_jim_events(command_context);
522
523 FD_ZERO(&read_fds); /* eCos leaves read_fds unchanged in this case! */
524
525 /* We timed out/there was nothing to do, timeout rather than poll next time
526 **/
527 poll_ok = false;
528 } else {
529 /* There was something to do, next time we'll just poll */
530 poll_ok = true;
531 }
532
533 /* This is a simple back-off algorithm where we immediately
534 * re-poll if we did something this time around.
535 *
536 * This greatly improves performance of DCC.
537 */
538 poll_ok = poll_ok || target_got_message();
539
540 for (service = services; service; service = service->next) {
541 /* handle new connections on listeners */
542 if ((service->fd != -1)
543 && (FD_ISSET(service->fd, &read_fds))) {
544 if (service->max_connections != 0)
545 add_connection(service, command_context);
546 else {
547 if (service->type == CONNECTION_TCP) {
548 struct sockaddr_in sin;
549 socklen_t address_size = sizeof(sin);
550 int tmp_fd;
551 tmp_fd = accept(service->fd,
552 (struct sockaddr *)&service->sin,
553 &address_size);
554 close_socket(tmp_fd);
555 }
556 LOG_INFO(
557 "rejected '%s' connection, no more connections allowed",
558 service->name);
559 }
560 }
561
562 /* handle activity on connections */
563 if (service->connections) {
564 struct connection *c;
565
566 for (c = service->connections; c; ) {
567 if ((c->fd >= 0 && FD_ISSET(c->fd, &read_fds)) || c->input_pending) {
568 retval = service->input(c);
569 if (retval != ERROR_OK) {
570 struct connection *next = c->next;
571 if (service->type == CONNECTION_PIPE ||
572 service->type == CONNECTION_STDINOUT) {
573 /* if connection uses a pipe then
574 * shutdown openocd on error */
575 shutdown_openocd = SHUTDOWN_REQUESTED;
576 }
577 remove_connection(service, c);
578 LOG_INFO("dropped '%s' connection",
579 service->name);
580 c = next;
581 continue;
582 }
583 }
584 c = c->next;
585 }
586 }
587 }
588
589 #ifdef _WIN32
590 MSG msg;
591 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
592 if (msg.message == WM_QUIT)
593 shutdown_openocd = SHUTDOWN_WITH_SIGNAL_CODE;
594 }
595 #endif
596 }
597
598 /* when quit for signal or CTRL-C, run (eventually user implemented) "shutdown" */
599 if (shutdown_openocd == SHUTDOWN_WITH_SIGNAL_CODE)
600 command_run_line(command_context, "shutdown");
601
602 return shutdown_openocd == SHUTDOWN_WITH_ERROR_CODE ? ERROR_FAIL : ERROR_OK;
603 }
604
605 static void sig_handler(int sig)
606 {
607 /* store only first signal that hits us */
608 if (shutdown_openocd == CONTINUE_MAIN_LOOP) {
609 shutdown_openocd = SHUTDOWN_WITH_SIGNAL_CODE;
610 last_signal = sig;
611 LOG_DEBUG("Terminating on Signal %d", sig);
612 } else
613 LOG_DEBUG("Ignored extra Signal %d", sig);
614 }
615
616
617 #ifdef _WIN32
618 BOOL WINAPI control_handler(DWORD ctrl_type)
619 {
620 shutdown_openocd = SHUTDOWN_WITH_SIGNAL_CODE;
621 return TRUE;
622 }
623 #else
624 static void sigkey_handler(int sig)
625 {
626 /* ignore keystroke generated signals if not in foreground process group */
627
628 if (tcgetpgrp(STDIN_FILENO) > 0)
629 sig_handler(sig);
630 else
631 LOG_DEBUG("Ignored Signal %d", sig);
632 }
633 #endif
634
635
636 int server_host_os_entry(void)
637 {
638 /* this currently only calls WSAStartup on native win32 systems
639 * before any socket operations are performed.
640 * This is an issue if you call init in your config script */
641
642 #ifdef _WIN32
643 WORD version_requested;
644 WSADATA wsadata;
645
646 version_requested = MAKEWORD(2, 2);
647
648 if (WSAStartup(version_requested, &wsadata) != 0) {
649 LOG_ERROR("Failed to Open Winsock");
650 return ERROR_FAIL;
651 }
652 #endif
653 return ERROR_OK;
654 }
655
656 int server_host_os_close(void)
657 {
658 #ifdef _WIN32
659 WSACleanup();
660 #endif
661 return ERROR_OK;
662 }
663
664 int server_preinit(void)
665 {
666 #ifdef _WIN32
667 /* register ctrl-c handler */
668 SetConsoleCtrlHandler(control_handler, TRUE);
669
670 signal(SIGBREAK, sig_handler);
671 signal(SIGINT, sig_handler);
672 #else
673 signal(SIGHUP, sig_handler);
674 signal(SIGPIPE, sig_handler);
675 signal(SIGQUIT, sigkey_handler);
676 signal(SIGINT, sigkey_handler);
677 #endif
678 signal(SIGTERM, sig_handler);
679 signal(SIGABRT, sig_handler);
680
681 return ERROR_OK;
682 }
683
684 int server_init(struct command_context *cmd_ctx)
685 {
686 int ret = tcl_init();
687
688 if (ret != ERROR_OK)
689 return ret;
690
691 ret = telnet_init("Open On-Chip Debugger");
692
693 if (ret != ERROR_OK) {
694 remove_services();
695 return ret;
696 }
697
698 return ERROR_OK;
699 }
700
701 int server_quit(void)
702 {
703 remove_services();
704 target_quit();
705
706 #ifdef _WIN32
707 SetConsoleCtrlHandler(control_handler, FALSE);
708
709 return ERROR_OK;
710 #endif
711
712 /* return signal number so we can kill ourselves */
713 return last_signal;
714 }
715
716 void server_free(void)
717 {
718 tcl_service_free();
719 telnet_service_free();
720 jsp_service_free();
721
722 free(bindto_name);
723 }
724
725 void exit_on_signal(int sig)
726 {
727 #ifndef _WIN32
728 /* bring back default system handler and kill yourself */
729 signal(sig, SIG_DFL);
730 kill(getpid(), sig);
731 #endif
732 }
733
734 int connection_write(struct connection *connection, const void *data, int len)
735 {
736 if (len == 0) {
737 /* successful no-op. Sockets and pipes behave differently here... */
738 return 0;
739 }
740 if (connection->service->type == CONNECTION_TCP)
741 return write_socket(connection->fd_out, data, len);
742 else
743 return write(connection->fd_out, data, len);
744 }
745
746 int connection_read(struct connection *connection, void *data, int len)
747 {
748 if (connection->service->type == CONNECTION_TCP)
749 return read_socket(connection->fd, data, len);
750 else
751 return read(connection->fd, data, len);
752 }
753
754 /* tell the server we want to shut down */
755 COMMAND_HANDLER(handle_shutdown_command)
756 {
757 LOG_USER("shutdown command invoked");
758
759 shutdown_openocd = SHUTDOWN_REQUESTED;
760
761 if (CMD_ARGC == 1) {
762 if (!strcmp(CMD_ARGV[0], "error")) {
763 shutdown_openocd = SHUTDOWN_WITH_ERROR_CODE;
764 return ERROR_FAIL;
765 }
766 }
767
768 return ERROR_COMMAND_CLOSE_CONNECTION;
769 }
770
771 COMMAND_HANDLER(handle_poll_period_command)
772 {
773 if (CMD_ARGC == 0)
774 LOG_WARNING("You need to set a period value");
775 else
776 COMMAND_PARSE_NUMBER(int, CMD_ARGV[0], polling_period);
777
778 LOG_INFO("set servers polling period to %ums", polling_period);
779
780 return ERROR_OK;
781 }
782
783 COMMAND_HANDLER(handle_bindto_command)
784 {
785 switch (CMD_ARGC) {
786 case 0:
787 command_print(CMD, "bindto name: %s", bindto_name);
788 break;
789 case 1:
790 free(bindto_name);
791 bindto_name = strdup(CMD_ARGV[0]);
792 break;
793 default:
794 return ERROR_COMMAND_SYNTAX_ERROR;
795 }
796 return ERROR_OK;
797 }
798
799 static const struct command_registration server_command_handlers[] = {
800 {
801 .name = "shutdown",
802 .handler = &handle_shutdown_command,
803 .mode = COMMAND_ANY,
804 .usage = "",
805 .help = "shut the server down",
806 },
807 {
808 .name = "poll_period",
809 .handler = &handle_poll_period_command,
810 .mode = COMMAND_ANY,
811 .usage = "",
812 .help = "set the servers polling period",
813 },
814 {
815 .name = "bindto",
816 .handler = &handle_bindto_command,
817 .mode = COMMAND_CONFIG,
818 .usage = "[name]",
819 .help = "Specify address by name on which to listen for "
820 "incoming TCP/IP connections",
821 },
822 COMMAND_REGISTRATION_DONE
823 };
824
825 int server_register_commands(struct command_context *cmd_ctx)
826 {
827 int retval = telnet_register_commands(cmd_ctx);
828 if (retval != ERROR_OK)
829 return retval;
830
831 retval = tcl_register_commands(cmd_ctx);
832 if (retval != ERROR_OK)
833 return retval;
834
835 retval = jsp_register_commands(cmd_ctx);
836 if (retval != ERROR_OK)
837 return retval;
838
839 return register_commands(cmd_ctx, NULL, server_command_handlers);
840 }
841
842 COMMAND_HELPER(server_port_command, unsigned short *out)
843 {
844 switch (CMD_ARGC) {
845 case 0:
846 command_print(CMD, "%d", *out);
847 break;
848 case 1:
849 {
850 uint16_t port;
851 COMMAND_PARSE_NUMBER(u16, CMD_ARGV[0], port);
852 *out = port;
853 break;
854 }
855 default:
856 return ERROR_COMMAND_SYNTAX_ERROR;
857 }
858 return ERROR_OK;
859 }
860
861 COMMAND_HELPER(server_pipe_command, char **out)
862 {
863 switch (CMD_ARGC) {
864 case 0:
865 command_print(CMD, "%s", *out);
866 break;
867 case 1:
868 {
869 if (CMD_CTX->mode == COMMAND_EXEC) {
870 LOG_WARNING("unable to change server port after init");
871 return ERROR_COMMAND_ARGUMENT_INVALID;
872 }
873 free(*out);
874 *out = strdup(CMD_ARGV[0]);
875 break;
876 }
877 default:
878 return ERROR_COMMAND_SYNTAX_ERROR;
879 }
880 return ERROR_OK;
881 }

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)