* gdbtk.c (running_now): New global variable.
authorStan Shebs <shebs@codesourcery.com>
Fri, 5 Apr 1996 21:52:38 +0000 (21:52 +0000)
committerStan Shebs <shebs@codesourcery.com>
Fri, 5 Apr 1996 21:52:38 +0000 (21:52 +0000)
(gdb_cmd): Test it before executing any command.
(gdbtk_call_command): Set it when inferior is running.
* gdbtk.tcl (gdbtk_tcl_busy, gdbtk_tcl_idle): Enable and
disable interaction with command window's text appropriately.

gdb/ChangeLog
gdb/gdbtk.c
gdb/gdbtk.tcl

index 35273295a29d766d35688d1d945ad9e6838a69fe..fa1942f562410d864df2996b2bd3684a5e0d0b19 100644 (file)
@@ -1,4 +1,12 @@
 start-sanitize-gdbtk
+Fri Apr  5 13:44:40 1996  Stan Shebs  <shebs@andros.cygnus.com>
+
+       * gdbtk.c (running_now): New global variable.
+       (gdb_cmd): Test it before executing any command.
+       (gdbtk_call_command): Set it when inferior is running.
+       * gdbtk.tcl (gdbtk_tcl_busy, gdbtk_tcl_idle): Enable and
+       disable interaction with command window's text appropriately.
+
 Fri Apr  5 13:25:42 1996  Michael Meissner  <meissner@tiktok.cygnus.com>
 
        * gdbtk.c (SIOCSPGRP, linux): If on Linux, undef SIOCSPGRP, since
@@ -14,11 +22,8 @@ Thu Apr  4 20:16:55 1996  Fred Fish  <fnf@cygnus.com>
        if it is actually defined.
        (gdb_setpgid): Use HAVE_SETPGID.
        * ch-exp.c: Change include of <string.h> to "gdb_string.h".
-       * c-exp.y: Ditto.
-       * f-exp.y: Ditto.
-       * m2-exp.y: Ditto.
-       * c-exp.y: Include <ctype.h>.
-       * serial.c: Ditto.
+       * c-exp.y, f-exp.y, m2-exp.y: Ditto.
+       * c-exp.y, serial.c: Include <ctype.h>.
        * config/m68k/nm-news.h: Add typedef for pid_t which is
        apparently missing from <sys/types.h>.  Enclose entire
        file in NM_NEWS_H ifndef and define when included.
@@ -106,7 +111,7 @@ Fri Mar 29 21:39:56 1996  Fred Fish  <fnf@cygnus.com>
        * values.c (unpack_field_as_long, modify_field): Ditto.
        * valops.c (value_assign, call_function_by_hand): Ditto.
        * infcmd.c (do_registers_info): Ditto.
-       * ser-tcp.c (tcp_open): Ditto
+       * ser-tcp.c (tcp_open): Ditto.
        * remote.c (putpkt): Ditto.
        * dcache.c (dcache_peek): Ditto.
        * dcache.c (dcache_poke): Ditto.
@@ -116,7 +121,7 @@ Fri Mar 29 21:39:56 1996  Fred Fish  <fnf@cygnus.com>
        out unused macro definition and variables.
        * inftarg.c (proc_wait): Move from main.c to here, and make static.
        * valprint.c (val_print_string): Change bufsize from int to unsigned.
-       * main.c (wait.h): Include
+       * main.c (wait.h): Include.
        * top.c (command_line_input): Remove unused variable "c".
        * f-typeprint.c (f_type_print_varspec_prefix): Add missing enum
        value TYPE_CODE_TYPEDEF to switch statement.
index 75108aca8eb365962d594cd4994c6e5da7414d2c..3c8cfbbc0d15c97b714f39416781caa6e46bcc6f 100644 (file)
@@ -56,21 +56,30 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 #endif
 
 /* Handle for TCL interpreter */
+
 static Tcl_Interp *interp = NULL;
 
 /* Handle for TK main window */
+
 static Tk_Window mainWindow = NULL;
 
 static int x_fd;               /* X network socket */
 
-/* This variable determines where memory used for disassembly is read from.
+/* This variable is true when the inferior is running.  Although it's
+   possible to disable most input from widgets and thus prevent
+   attempts to do anything while the inferior is running, any commands
+   that get through - even a simple memory read - are Very Bad, and
+   may cause GDB to crash or behave strangely.  So, this variable
+   provides an extra layer of defense.  */
 
-   If > 0, then disassembly comes from the exec file rather than the target
-   (which might be at the other end of a slow serial link).  If == 0 then
-   disassembly comes from target.  If < 0 disassembly is automatically switched
-   to the target if it's an inferior process, otherwise the exec file is
-   used.
- */
+static int running_now;
+
+/* This variable determines where memory used for disassembly is read from.
+   If > 0, then disassembly comes from the exec file rather than the
+   target (which might be at the other end of a slow serial link).  If
+   == 0 then disassembly comes from target.  If < 0 disassembly is
+   automatically switched to the target if it's an inferior process,
+   otherwise the exec file is used.  */
 
 static int disassemble_from_exec = -1;
 
@@ -138,6 +147,7 @@ gdbtk_fputs (ptr, stream)
      const char *ptr;
      FILE *stream;
 {
+
   if (result_ptr)
     Tcl_DStringAppend (result_ptr, (char *)ptr, -1);
   else
@@ -610,7 +620,7 @@ register_changed_p (regnum, argp)
              REGISTER_RAW_SIZE (regnum)) == 0)
     return;
 
-  /* Found a changed register.  Save new value and return it's number. */
+  /* Found a changed register.  Save new value and return its number. */
 
   memcpy (&old_regs[REGISTER_BYTE (regnum)], raw_buffer,
          REGISTER_RAW_SIZE (regnum));
@@ -631,7 +641,7 @@ gdb_changed_register_list (clientData, interp, argc, argv)
   return map_arg_registers (argc, argv, register_changed_p, NULL);
 }
 \f
-/* This implements the TCL command `gdb_cmd', which sends it's argument into
+/* This implements the TCL command `gdb_cmd', which sends its argument into
    the GDB command scanner.  */
 
 static int
@@ -644,6 +654,9 @@ gdb_cmd (clientData, interp, argc, argv)
   if (argc != 2)
     error ("wrong # args");
 
+  if (running_now)
+    return TCL_OK;
+
   execute_command (argv[1], 1);
 
   bpstat_do_actions (&stop_bpstat);
@@ -690,8 +703,9 @@ call_wrapper (clientData, interp, argc, argv)
 
       gdb_flush (gdb_stdout);  /* Sometimes error output comes here as well */
 
-/* In case of an error, we may need to force the GUI into idle mode because
-   gdbtk_call_command may have bombed out while in the command routine.  */
+      /* In case of an error, we may need to force the GUI into idle
+        mode because gdbtk_call_command may have bombed out while in
+        the command routine.  */
 
       Tcl_Eval (interp, "gdbtk_tcl_idle");
     }
@@ -843,7 +857,7 @@ gdb_disassemble (clientData, interp, argc, argv)
      correctly.
 
      Else, we're debugging a remote process, and should disassemble from the
-     exec file for speed.  However, this is no good if the target modifies it's
+     exec file for speed.  However, this is no good if the target modifies its
      code (for relocation, or whatever).
    */
 
@@ -1080,11 +1094,14 @@ gdbtk_call_command (cmdblk, arg, from_tty)
      char *arg;
      int from_tty;
 {
+  running_now = 0;
   if (cmdblk->class == class_run)
     {
+      running_now = 1;
       Tcl_Eval (interp, "gdbtk_tcl_busy");
       (*cmdblk->function.cfunc)(arg, from_tty);
       Tcl_Eval (interp, "gdbtk_tcl_idle");
+      running_now = 0;
     }
   else
     (*cmdblk->function.cfunc)(arg, from_tty);
index 148517f4f6e142e2bc27e316c5a080ec70e4a375..60e1628f6c759c48a5160e18448d9dda07569267 100644 (file)
@@ -668,6 +668,9 @@ proc delete_breakpoint_tag {win line} {
 }
 
 proc gdbtk_tcl_busy {} {
+       if {[winfo exists .cmd]} {
+               .cmd.text configure -state disabled
+       }
        if {[winfo exists .src]} {
                .src.start configure -state disabled
                .src.stop configure -state normal
@@ -692,6 +695,9 @@ proc gdbtk_tcl_busy {} {
 }
 
 proc gdbtk_tcl_idle {} {
+       if {[winfo exists .cmd]} {
+               .cmd.text configure -state normal
+       }
        if {[winfo exists .src]} {
                .src.start configure -state normal
                .src.stop configure -state disabled
@@ -703,7 +709,6 @@ proc gdbtk_tcl_idle {} {
                .src.down configure -state normal
                .src.bottom configure -state normal
        }
-
        if {[winfo exists .asm]} {
                .asm.stepi configure -state normal
                .asm.nexti configure -state normal