SCP: Allow debugger delivery of SIGINT separate from WRU return to sim> prompt

This commit is contained in:
Mark Pizzolato 2018-12-31 09:49:06 -08:00
parent 7a1400a50c
commit 9f2d96b3e7
2 changed files with 76 additions and 12 deletions

3
scp.c
View file

@ -1143,6 +1143,9 @@ static const char simh_help[] =
"+SET CONSOLE WRU=value specify console drop to simh character\n"
"+SET CONSOLE BRK=value specify console Break character\n"
"+SET CONSOLE DEL=value specify console delete character\n"
#if (defined(__GNUC__) && !defined(__OPTIMIZE__)) /* Debug build? */
"+SET CONSOLE DEBUG=value specify SIGINT character in debugger\n"
#endif
"+SET CONSOLE PCHAR=bitmask bit mask of printable characters in\n"
"++++++++ range [31,0]\n"
"+SET CONSOLE SPEED=speed{*factor}\n"

View file

@ -168,10 +168,13 @@ static t_stat sim_set_delay (int32 flag, CONST char *cptr);
#define KMAP_WRU 0
#define KMAP_BRK 1
#define KMAP_DEL 2
#define KMAP_DBGINT 3
#define KMAP_MASK 0377
#define KMAP_NZ 0400
int32 sim_int_char = 005; /* interrupt character */
int32 sim_dbg_int_char = 0; /* SIGINT char under debugger */
static t_bool sigint_message_issued = FALSE;
int32 sim_brk_char = 000; /* break character */
int32 sim_tt_pchar = 0x00002780;
#if defined (_WIN32) || defined (__OS2__) || (defined (__MWERKS__) && defined (macintosh))
@ -303,6 +306,7 @@ static CTAB set_con_tab[] = {
{ "WRU", &sim_set_kmap, KMAP_WRU | KMAP_NZ },
{ "BRK", &sim_set_kmap, KMAP_BRK },
{ "DEL", &sim_set_kmap, KMAP_DEL | KMAP_NZ },
{ "DEBUG", &sim_set_kmap, KMAP_DBGINT | KMAP_NZ },
{ "PCHAR", &sim_set_pchar, 0 },
{ "SPEED", &sim_set_cons_speed, 0 },
{ "TELNET", &sim_set_telnet, 0 },
@ -337,6 +341,9 @@ static SHTAB show_con_tab[] = {
{ "WRU", &sim_show_kmap, KMAP_WRU },
{ "BRK", &sim_show_kmap, KMAP_BRK },
{ "DEL", &sim_show_kmap, KMAP_DEL },
#if (defined(__GNUC__) && !defined(__OPTIMIZE__)) /* Debug build? */
{ "DEBUG", &sim_show_kmap, KMAP_DBGINT },
#endif
{ "PCHAR", &sim_show_pchar, 0 },
{ "SPEED", &sim_show_cons_speed, 0 },
{ "LOG", &sim_show_cons_log, 0 },
@ -369,7 +376,8 @@ static CTAB set_con_serial_tab[] = {
static int32 *cons_kmap[] = {
&sim_int_char,
&sim_brk_char,
&sim_del_char
&sim_del_char,
&sim_dbg_int_char
};
/* Console I/O package.
@ -2075,13 +2083,16 @@ t_stat r;
if ((cptr == NULL) || (*cptr == 0))
return SCPE_2FARG;
if (dptr->dradix == 16) rdx = 16;
else rdx = 8;
if (dptr->dradix == 16)
rdx = 16;
else
rdx = 8;
val = (int32) get_uint (cptr, rdx, 0177, &r);
if ((r != SCPE_OK) ||
((val == 0) && (flag & KMAP_NZ)))
return SCPE_ARG;
*(cons_kmap[flag & KMAP_MASK]) = val;
sigint_message_issued = FALSE;
return SCPE_OK;
}
@ -2089,10 +2100,19 @@ return SCPE_OK;
t_stat sim_show_kmap (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag, CONST char *cptr)
{
int32 kmap_char = *(cons_kmap[flag & KMAP_MASK]);
if (sim_devices[0]->dradix == 16)
fprintf (st, "%s = %X\n", show_con_tab[flag].name, *(cons_kmap[flag & KMAP_MASK]));
fprintf (st, "%s = 0x%X", show_con_tab[flag].name, kmap_char);
else
fprintf (st, "%s = %o\n", show_con_tab[flag].name, *(cons_kmap[flag & KMAP_MASK]));
fprintf (st, "%s = 0%o", show_con_tab[flag].name, kmap_char);
if (isprint(kmap_char&0xFF))
fprintf (st, " = '%c'\n", kmap_char&0xFF);
else
if (kmap_char <= 26)
fprintf (st, " = ^%c\n", '@' + (kmap_char&0xFF));
else
fprintf (st, "\n");
return SCPE_OK;
}
@ -3270,7 +3290,8 @@ status = sys$qiow (EFN, tty_chan,
&iosb, 0, 0, buf, 1, 0, term, 0, 0);
if ((status != SS$_NORMAL) || (iosb.status != SS$_NORMAL))
return SCPE_OK;
if (buf[0] == sim_int_char) return SCPE_STOP;
if (buf[0] == sim_int_char)
return SCPE_STOP;
if (sim_brk_char && (buf[0] == sim_brk_char))
return SCPE_BREAK;
return (buf[0] | SCPE_KFLAG);
@ -3826,7 +3847,8 @@ if (!ps_kbhit ())
c = ps_getch();
if ((c & 0177) == sim_del_char)
c = 0177;
if ((c & 0177) == sim_int_char) return SCPE_STOP;
if ((c & 0177) == sim_int_char)
return SCPE_STOP;
if (sim_brk_char && ((c & 0177) == sim_brk_char))
return SCPE_BREAK;
return c | SCPE_KFLAG;
@ -3901,7 +3923,26 @@ static t_stat sim_os_ttrun (void)
{
sim_debug (DBG_TRC, &sim_con_telnet, "sim_os_ttrun() - BSDTTY\n");
#if (defined(__GNUC__) && !defined(__OPTIMIZE__)) /* Debug build? */
if (sim_dbg_int_char == 0)
sim_dbg_int_char = sim_int_char + 1;
runtchars.t_intrc = sim_dbg_int_char; /* let debugger get SIGINT with next highest char */
if (!sigint_message_issued) {
char sigint_name[8];
if (isprint(sim_dbg_int_char&0xFF))
sprintf(sigint_name, "'%c'", sim_dbg_int_char&0xFF);
else
if (sim_dbg_int_char <= 26)
sprintf(sigint_name, "^%c", '@' + (sim_dbg_int_char&0xFF));
else
sprintf(sigint_name, "'\\%03o'", sim_dbg_int_char&0xFF);
sigint_message_issued = TRUE;
sim_messagef (SCPE_OK, "SIGINT will be delivered to your debugger when the %s character is entered\n", sigint_name);
}
#else
runtchars.t_intrc = sim_int_char; /* in case changed */
#endif
fcntl (0, F_SETFL, runfl); /* non-block mode */
if (ioctl (0, TIOCSETP, &runtty) < 0)
return SCPE_TTIERR;
@ -3946,7 +3987,8 @@ unsigned char buf[1];
sim_debug (DBG_TRC, &sim_con_telnet, "sim_os_poll_kbd() - BSDTTY\n");
status = read (0, buf, 1);
if (status != 1) return SCPE_OK;
if (status != 1)
return SCPE_OK;
if (sim_brk_char && (buf[0] == sim_brk_char))
return SCPE_BREAK;
if (sim_int_char && (buf[0] == sim_int_char))
@ -4064,6 +4106,24 @@ runtty.c_cc[VINTR] = 0; /* OS X doesn't deliver
#else
runtty.c_cc[VINTR] = sim_int_char; /* in case changed */
#endif
#if (defined(__GNUC__) && !defined(__OPTIMIZE__)) /* Debug build? */
if (sim_dbg_int_char == 0)
sim_dbg_int_char = sim_int_char + 1;
runtty.c_cc[VINTR] = sim_dbg_int_char; /* let debugger get SIGINT with next highest char */
if (!sigint_message_issued) {
char sigint_name[8];
if (isprint(sim_dbg_int_char&0xFF))
sprintf(sigint_name, "'%c'", sim_dbg_int_char&0xFF);
else
if (sim_dbg_int_char <= 26)
sprintf(sigint_name, "^%c", '@' + (sim_dbg_int_char&0xFF));
else
sprintf(sigint_name, "'\\%03o'", sim_dbg_int_char&0xFF);
sigint_message_issued = TRUE;
sim_messagef (SCPE_OK, "SIGINT will be delivered to your debugger when the %s character is entered\n", sigint_name);
}
#endif
if (tcsetattr (fileno(stdin), TCSETATTR_ACTION, &runtty) < 0)
return SCPE_TTIERR;
sim_os_set_thread_priority (PRIORITY_BELOW_NORMAL); /* try to lower pri */
@ -4101,7 +4161,8 @@ unsigned char buf[1];
sim_debug (DBG_TRC, &sim_con_telnet, "sim_os_poll_kbd()\n");
status = read (0, buf, 1);
if (status != 1) return SCPE_OK;
if (status != 1)
return SCPE_OK;
if (sim_brk_char && (buf[0] == sim_brk_char))
return SCPE_BREAK;
if (sim_int_char && (buf[0] == sim_int_char))