diff options
author | Jiri Gaisler <jiri@gaisler.se> | 2019-11-14 11:51:10 +0100 |
---|---|---|
committer | Jiri Gaisler <jiri@gaisler.se> | 2019-11-14 11:51:10 +0100 |
commit | 3475d6203ce56692cab1af0e402de286ac9bf0f8 (patch) | |
tree | 68836d196868c421e0df4aca1c3c5829b26af9d6 | |
parent | 7a6e198454d04ac6bf5f2009b4f693696c27e5c1 (diff) |
Cross-platform support for async gdb break (ctrl-c)
-rwxr-xr-x | configure | 20 | ||||
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | func.c | 62 | ||||
-rw-r--r-- | interf.c | 6 | ||||
-rw-r--r-- | remote.c | 34 | ||||
-rw-r--r-- | sis.h | 1 | ||||
-rw-r--r-- | sis.info | 6 | ||||
-rw-r--r-- | version.texi | 4 |
8 files changed, 67 insertions, 68 deletions
@@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for sis 2.19. +# Generated by GNU Autoconf 2.69 for sis 2.20. # # # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. @@ -577,8 +577,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='sis' PACKAGE_TARNAME='sis' -PACKAGE_VERSION='2.19' -PACKAGE_STRING='sis 2.19' +PACKAGE_VERSION='2.20' +PACKAGE_STRING='sis 2.20' PACKAGE_BUGREPORT='' PACKAGE_URL='' @@ -1272,7 +1272,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures sis 2.19 to adapt to many kinds of systems. +\`configure' configures sis 2.20 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1342,7 +1342,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of sis 2.19:";; + short | recursive ) echo "Configuration of sis 2.20:";; esac cat <<\_ACEOF @@ -1432,7 +1432,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -sis configure 2.19 +sis configure 2.20 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -1730,7 +1730,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by sis $as_me 2.19, which was +It was created by sis $as_me 2.20, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -2557,7 +2557,7 @@ fi # Define the identity of the package. PACKAGE='sis' - VERSION='2.19' + VERSION='2.20' cat >>confdefs.h <<_ACEOF @@ -4899,7 +4899,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by sis $as_me 2.19, which was +This file was extended by sis $as_me 2.20, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -4965,7 +4965,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -sis config.status 2.19 +sis config.status 2.20 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff --git a/configure.ac b/configure.ac index d9f2480..47a2480 100644 --- a/configure.ac +++ b/configure.ac @@ -1,4 +1,4 @@ -AC_INIT([sis], [2.19]) +AC_INIT([sis], [2.20]) AC_CONFIG_SRCDIR([sis.c]) AC_CONFIG_AUX_DIR([build-aux]) AC_CONFIG_HEADERS(config.h) @@ -786,44 +786,39 @@ init_bpt (sregs) ebase.tlimit = 0; } -/* taken from gdbserver */ -static void -check_interrup () -{ - fd_set readset; - struct timeval immediate = { 0, 0 }; - /* Protect against spurious interrupts. This has been observed to - be a problem under NetBSD 1.4 and 1.5. */ +/* support for catching ctrl-c */ - FD_ZERO (&readset); - FD_SET (new_socket, &readset); - if (select (new_socket + 1, &readset, 0, 0, &immediate) > 0) - { - int cc; - char c = 0; +#ifdef WIN32 - cc = read (new_socket, &c, 1); +BOOL WINAPI ConsoleHandler (DWORD); - if (cc == 0) - { - fprintf (stderr, "client connection closed\n"); - return; - } - else if (cc != 1 || c != '\003') - { - fprintf (stderr, "input_interrupt, count = %d c = %d ", cc, c); - if (isprint (c)) - fprintf (stderr, "('%c')\n", c); - else - fprintf (stderr, "('\\x%02x')\n", c & 0xff); - return; - } +void +init_signals () +{ + if (!SetConsoleCtrlHandler ((PHANDLER_ROUTINE) ConsoleHandler, TRUE)) + { + fprintf (stderr, "Unable to install ctrl-c handler!\n"); + } +} +BOOL WINAPI +ConsoleHandler (DWORD dwType) +{ + switch (dwType) + { + case CTRL_C_EVENT: + case CTRL_BREAK_EVENT: ctrl_c = 1; + break; + default: + break; } + return TRUE; } +#else + void int_handler (int sig) { @@ -832,14 +827,6 @@ int_handler (int sig) switch (sig) { -#ifndef WIN32 - case SIGIO: - if (sim_run) - { - check_interrup (); - } - break; -#endif case SIGINT: ctrl_c = 1; if (!sim_run) @@ -864,6 +851,7 @@ init_signals () int_tab[0] = signal (SIGTERM, int_handler); int_tab[1] = signal (SIGINT, int_handler); } +#endif void print_insn_sis (uint32 addr) @@ -126,7 +126,11 @@ sim_resume (int step) if (step) simstat = run_sim_gdb (1, 0); else - simstat = run_sim_gdb (UINT64_MAX / 2, 0); + { + socket_poll (); + simstat = run_sim_gdb (UINT64_MAX / 2, 0); + remove_event (socket_poll, -1); + } if (sis_gdb_break && (cputype != CPU_RISCV)) save_sp (&sregs[cpu]); @@ -24,12 +24,15 @@ #include <unistd.h> #include <stdio.h> #ifdef WIN32 -#include <winsock.h> +#include <winsock2.h> #else +#define WSAPOLLFD struct pollfd +#define WSAPoll poll #include <sys/socket.h> #include <netinet/in.h> #include <netinet/tcp.h> #include <netdb.h> +#include <poll.h> #endif #include <fcntl.h> #include <stdlib.h> @@ -112,12 +115,26 @@ create_socket (int port) sizeof (opt)); #ifndef WIN32 fcntl (new_socket, F_SETOWN, getpid ()); - fcntl (new_socket, F_SETFL, FASYNC); #endif return 1; } +/* poll socket periodically to detect gdb break */ +void +socket_poll () +{ + WSAPOLLFD fdarray = { 0 }; + int ret; + + fdarray.fd = new_socket; + fdarray.events = POLLRDNORM; + ret = WSAPoll (&fdarray, 1, 0); + if (ret) + ctrl_c = 1; + event (socket_poll, 0, 10000000); +} + static int hex (unsigned char ch) { @@ -435,14 +452,7 @@ gdb_remote (int port) sis_gdb_break = 1; detach = 0; -#ifndef WIN32 - signal (SIGIO, int_handler); -#endif -#ifdef __CYGWIN__ - printf ("Warning: gdb cannot interrupt a running simulator under CYGWIN\n"); - printf - (" As a workaround, use Ctrl-C in the simulator window instead\n\n"); -#endif + printf ("gdb: listening on port %d ", port); while (cont) { @@ -526,8 +536,4 @@ gdb_remote (int port) } new_socket = 0; sis_gdb_break = 0; -#ifndef WIN32 - signal (SIGIO, SIG_DFL); -#endif - } @@ -370,6 +370,7 @@ extern const struct memsys leon3; extern void gdb_remote (int port); extern int simstat; extern int new_socket; +extern void socket_poll (); /* interf.c */ @@ -1,6 +1,6 @@ -This is sis.info, produced by makeinfo version 6.6 from sis.texi. +This is sis.info, produced by makeinfo version 6.5 from sis.texi. -This manual is for SIS (version 2.19, 31 May 2019). +This manual is for SIS (version 2.20, 31 May 2019). Copyright (C) 2019 Free Software Foundation, Inc. @@ -21,7 +21,7 @@ File: sis.info, Node: Top, Next: Introduction, Up: (dir) SIS *** -This manual is for SIS (version 2.19, 31 May 2019). +This manual is for SIS (version 2.20, 31 May 2019). * Menu: diff --git a/version.texi b/version.texi index a7cb5c6..5ddeba4 100644 --- a/version.texi +++ b/version.texi @@ -1,4 +1,4 @@ @set UPDATED 31 May 2019 @set UPDATED-MONTH May 2019 -@set EDITION 2.19 -@set VERSION 2.19 +@set EDITION 2.20 +@set VERSION 2.20 |