From ff6248db1e74afaf64108e9742412b775a0b1209 Mon Sep 17 00:00:00 2001 From: "Guillermo J. Rozas" Date: Tue, 4 Feb 1992 00:36:02 +0000 Subject: [PATCH] debug_back_trace now takes a FILE * object. interactive_back_trace reads a file name and uses it, the console if none provided. --- v7/src/microcode/uxsig.c | 100 +++++++++++++++++++++++++++++---------- 1 file changed, 75 insertions(+), 25 deletions(-) diff --git a/v7/src/microcode/uxsig.c b/v7/src/microcode/uxsig.c index b8df814cc..f1adc6a0f 100644 --- a/v7/src/microcode/uxsig.c +++ b/v7/src/microcode/uxsig.c @@ -1,6 +1,6 @@ /* -*-C-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/uxsig.c,v 1.18 1991/10/29 22:55:11 jinx Exp $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/uxsig.c,v 1.19 1992/02/04 00:36:02 jinx Exp $ Copyright (c) 1990-91 Massachusetts Institute of Technology @@ -699,6 +699,7 @@ static void EXFUN (print_interactive_help, (void)); static void EXFUN (print_interrupt_chars, (void)); static void EXFUN (examine_memory, (void)); static void EXFUN (reset_query, (struct FULL_SIGCONTEXT * scp)); +static void EXFUN (interactive_back_trace, (void)); #define INTERACTIVE_NEWLINE() \ { \ @@ -761,7 +762,7 @@ DEFUN (interactive_interrupt_handler, (scp), struct FULL_SIGCONTEXT * scp) case 'T': case 't': INTERACTIVE_NEWLINE (); - debug_back_trace (); + interactive_back_trace (); return; case 'Z': case 'z': @@ -1040,6 +1041,43 @@ DEFUN (reset_query, (scp), struct FULL_SIGCONTEXT * scp) if (userio_confirm ("Do you really want to reset? [Y or N] ")) hard_reset (scp); } + +#define USERIO_READ_LINE_OK 0 +#define USERIO_READ_LINE_TOO_LONG 1 +#define USERIO_READ_LINE_INPUT_FAILED 2 + +static int +DEFUN (userio_read_line, (line, size), char * line AND int size) +{ + int result = USERIO_READ_LINE_TOO_LONG; + transaction_begin (); + userio_buffered_input (); /* transaction_record_action here */ + { + char * scan = line; + char * end = (line + size); + while (scan < end) + { + char c = (userio_read_char ()); + if ((c == '\0') && (errno != 0)) + { + /* IO problems, assume everything scrod. */ + result = USERIO_READ_LINE_INPUT_FAILED; + break; + } + (*scan) = c; + if (c == '\n') + c = '\0'; + if (c == '\0') + { + result = USERIO_READ_LINE_OK; + break; + } + scan += 1; + } + } + transaction_commit (); + return (result); +} static void DEFUN_VOID (examine_memory) @@ -1047,30 +1085,11 @@ DEFUN_VOID (examine_memory) char input_string [256]; fputs ("Enter location to examine (0x prefix for hex): ", stdout); fflush (stdout); + if ((userio_read_line (&input_string[0], (sizeof (input_string)))) + == USERIO_READ_LINE_INPUT_FAILED) { - transaction_begin (); - userio_buffered_input (); - { - char * scan = input_string; - char * end = (input_string + (sizeof (input_string))); - while (scan < end) - { - char c = (userio_read_char ()); - if ((c == '\0') && (errno != 0)) - { - /* IO problems, assume everything scrod. */ - fprintf (stderr, "Problems reading keyboard input -- exiting.\n"); - termination_eof (); - } - (*scan) = c; - if (c == '\n') - c = '\0'; - if (c == '\0') - break; - scan += 1; - } - } - transaction_commit (); + fprintf (stderr, "Problems reading keyboard input -- exiting.\n"); + termination_eof (); } { long input; @@ -1084,6 +1103,37 @@ DEFUN_VOID (examine_memory) fflush (stdout); } +static void +DEFUN_VOID (interactive_back_trace) +{ + char input_string [256]; + fputs ("Enter the stack trace filename (default: terminal): ", stdout); + fflush (stdout); + if ((userio_read_line (&input_string[0], (sizeof (input_string)))) + == USERIO_READ_LINE_INPUT_FAILED) + { + fprintf (stderr, "Problems reading keyboard input -- exiting.\n"); + termination_eof (); + } + if ((strlen (&input_string[0])) == 0) + debug_back_trace (stdout); + else + { + transaction_begin (); + FILE * to_dump = (fopen (&input_string[0], "w")); + if (to_dump == ((FILE *) NULL)) + { + printf ("Error opening \"%s\".\n", (&input_string[0])); + transaction_abort (); + return; + } + transaction_record_action (tat_always, fclose, ((PTR) to_dump)); + debug_back_trace (to_dump); + transaction_commit (); + } + return; +} + #ifdef sun3 /* This code assumes that it is called very soon, before -- 2.25.1