1999-01-19 Fernando Nasser <fnasser@totem.to.cygnus.com>
[deliverable/binutils-gdb.git] / gdb / gdbtk-hooks.c
index ff2e7f51d90dc85efae6d6cf939ea25be30fe361..7bccc4f25922f2a1c150caf1500cd0e86ea6a86b 100644 (file)
@@ -77,17 +77,20 @@ extern int  (*ui_load_progress_hook) PARAMS ((char *, unsigned long));
 extern void (*pre_add_symbol_hook) PARAMS ((char *));
 extern void (*post_add_symbol_hook) PARAMS ((void));
 extern void (*selected_frame_level_changed_hook) PARAMS ((int));
-
-#ifdef __CYGWIN32__
+#ifdef __CYGWIN__
 extern void (*ui_loop_hook) PARAMS ((int));
 #endif
 
 static void   gdbtk_create_tracepoint PARAMS ((struct tracepoint *));
 static void   gdbtk_delete_tracepoint PARAMS ((struct tracepoint *));
 static void   gdbtk_modify_tracepoint PARAMS ((struct tracepoint *));
+static void   gdbtk_trace_find  PARAMS ((char *arg, int from_tty));
+static void   gdbtk_trace_start_stop PARAMS ((int, int));
 static void   gdbtk_create_breakpoint PARAMS ((struct breakpoint *));
 static void   gdbtk_delete_breakpoint PARAMS ((struct breakpoint *));
 static void   gdbtk_modify_breakpoint PARAMS ((struct breakpoint *));
+static void   gdbtk_file_changed PARAMS ((char *));
+static void   gdbtk_exec_file_display PARAMS ((char *));
 static void   tk_command_loop PARAMS ((void));
 static void   gdbtk_call_command PARAMS ((struct cmd_list_element *, char *, int));
 static int    gdbtk_wait PARAMS ((int, struct target_waitstatus *));
@@ -103,7 +106,7 @@ gdbtk_readline_begin (char *format, ...);
 gdbtk_readline_begin ();
 #endif
 static void gdbtk_readline_end PARAMS ((void));
-static void   gdbtk_flush PARAMS ((FILE *));
+static void   gdbtk_flush PARAMS ((GDB_FILE *));
 static void gdbtk_pre_add_symbol PARAMS ((char *));
 static void gdbtk_print_frame_info PARAMS ((struct symtab *, int, int, int));
 static void gdbtk_post_add_symbol PARAMS ((void));
@@ -117,7 +120,7 @@ static void gdbtk_context_change PARAMS ((int));
  * See note there for details.
  */
 
-void   gdbtk_fputs PARAMS ((const char *, FILE *));
+void   gdbtk_fputs PARAMS ((const char *, GDB_FILE *));
 int           gdbtk_load_hash PARAMS ((char *, unsigned long));
 static void   breakpoint_notify PARAMS ((struct breakpoint *, const char *));
 
@@ -144,18 +147,23 @@ gdbtk_add_hooks(void)
   delete_breakpoint_hook = gdbtk_delete_breakpoint;
   modify_breakpoint_hook = gdbtk_modify_breakpoint;
 
-  interactive_hook = gdbtk_interactive;
-  target_wait_hook = gdbtk_wait;
-  ui_load_progress_hook = gdbtk_load_hash;
-#ifdef __CYGWIN32__
+  interactive_hook       = gdbtk_interactive;
+  target_wait_hook       = gdbtk_wait;
+  ui_load_progress_hook  = gdbtk_load_hash;
+
+#ifdef __CYGWIN__
   ui_loop_hook = x_event;
 #endif
-  pre_add_symbol_hook   = gdbtk_pre_add_symbol;
-  post_add_symbol_hook  = gdbtk_post_add_symbol;
+  pre_add_symbol_hook    = gdbtk_pre_add_symbol;
+  post_add_symbol_hook   = gdbtk_post_add_symbol;
+  file_changed_hook      = gdbtk_file_changed;
+  exec_file_display_hook = gdbtk_exec_file_display;
 
   create_tracepoint_hook = gdbtk_create_tracepoint;
   delete_tracepoint_hook = gdbtk_delete_tracepoint;
   modify_tracepoint_hook = gdbtk_modify_tracepoint;
+  trace_find_hook        = gdbtk_trace_find;
+  trace_start_stop_hook  = gdbtk_trace_start_stop;
   pc_changed_hook = pc_changed;
   selected_frame_level_changed_hook = gdbtk_selected_frame_changed;
   context_hook = gdbtk_context_change;
@@ -206,7 +214,7 @@ int gdbtk_two_elem_cmd (cmd_name, argv1)
 
 static void
 gdbtk_flush (stream)
-     FILE *stream;
+     GDB_FILE *stream;
 {
 #if 0
   /* Force immediate screen update */
@@ -230,7 +238,7 @@ gdbtk_flush (stream)
  *    We place the data into the result_ptr, either as a string,
  *    or a list, depending whether the GDBTK_MAKES_LIST bit is set.
  * 3) The GDBTK_TO_RESULT flag is unset - We route the data to gdbtk_tcl_fputs
- *    UNLESS it was coming to stderr.  Then we place it in the result_ptr
+ *    UNLESS it was coming to gdb_stderr.  Then we place it in the result_ptr
  *    anyway, so it can be dealt with.
  *
  */
@@ -238,7 +246,7 @@ gdbtk_flush (stream)
 void
 gdbtk_fputs (ptr, stream)
      const char *ptr;
-     FILE *stream;
+     GDB_FILE *stream;
 {
   in_fputs = 1;
 
@@ -321,7 +329,7 @@ pc_changed()
 static void
 tk_command_loop ()
 {
-  extern GDB_FILE *instream;
+  extern FILE *instream;
 
   /* We no longer want to use stdin as the command input stream */
   instream = NULL;
@@ -361,7 +369,7 @@ x_event (signo)
 
   in_x_event = 1;
 
-#ifdef __CYGWIN32__
+#ifdef __CYGWIN__
   if (signo == -2)
     gdbtk_stop_timer ();
 #endif
@@ -457,34 +465,13 @@ gdbtk_call_command (cmdblk, arg, from_tty)
   if (cmdblk->class == class_run || cmdblk->class == class_trace)
     {
 
-      /* HACK! HACK! This is to get the gui to update the tstart/tstop
-         button only incase of tstart/tstop commands issued from the console
-         We don't want to update the src window, so we need to have specific
-         procedures to do tstart and tstop
-         Unfortunately this will not display errors from tstart or tstop in the 
-         console window itself, but as dialogs.*/
-
-      if (!strcmp(cmdblk->name, "tstart") && !No_Update)
-        {
-          Tcl_Eval (gdbtk_interp, "gdbtk_tcl_tstart"); 
-          (*cmdblk->function.cfunc)(arg, from_tty);
-        }
-      else if (!strcmp(cmdblk->name, "tstop") && !No_Update) 
-        {
-          Tcl_Eval (gdbtk_interp, "gdbtk_tcl_tstop"); 
-          (*cmdblk->function.cfunc)(arg, from_tty);
-        }
-      /* end of hack */
-      else 
-        {
-          running_now = 1;
-          if (!No_Update)
-            Tcl_Eval (gdbtk_interp, "gdbtk_tcl_busy");
-          (*cmdblk->function.cfunc)(arg, from_tty);
-          running_now = 0;
-          if (!No_Update)
-            Tcl_Eval (gdbtk_interp, "gdbtk_tcl_idle");
-        }
+      running_now = 1;
+      if (!No_Update)
+       Tcl_Eval (gdbtk_interp, "gdbtk_tcl_busy");
+      (*cmdblk->function.cfunc)(arg, from_tty);
+      running_now = 0;
+      if (!No_Update)
+       Tcl_Eval (gdbtk_interp, "gdbtk_tcl_idle");
     }
   else
     (*cmdblk->function.cfunc)(arg, from_tty);
@@ -543,8 +530,9 @@ breakpoint_notify(b, action)
   if (filename == NULL)
     filename = "";
 
-  sprintf (buf, "gdbtk_tcl_breakpoint %s %d 0x%lx %d {%s}", action, b->number, 
-          (long)b->address, b->line_number, filename);
+  sprintf (buf, "gdbtk_tcl_breakpoint %s %d 0x%lx %d {%s} {%s} %d %d",
+          action, b->number, (long)b->address, b->line_number, filename,
+          bpdisp[b->disposition], b->enable,  b->thread);
 
   v = Tcl_Eval (gdbtk_interp, buf);
 
@@ -687,6 +675,68 @@ tracepoint_notify(tp, action)
     }
 }
 
+/*
+ * gdbtk_trace_find
+ *
+ * This is run by the trace_find_command.  arg is the argument that was passed
+ * to that command, from_tty is 1 if the command was run from a tty, 0 if it
+ * was run from a script.  It runs gdbtk_tcl_tfind_hook passing on these two
+ * arguments.
+ *
+ */
+
+static void
+gdbtk_trace_find (arg, from_tty)
+     char *arg;
+     int from_tty;
+{
+  Tcl_Obj *cmdObj;
+  
+  if (from_tty) {
+    Tcl_GlobalEval (gdbtk_interp, "debug {*** In gdbtk_trace_find, from_tty is true}");
+    cmdObj = Tcl_NewListObj (0, NULL);
+    Tcl_ListObjAppendElement (gdbtk_interp, cmdObj,
+                             Tcl_NewStringObj ("gdbtk_tcl_trace_find_hook", -1));
+    Tcl_ListObjAppendElement (gdbtk_interp, cmdObj, Tcl_NewStringObj (arg, -1));
+    Tcl_ListObjAppendElement (gdbtk_interp, cmdObj, Tcl_NewIntObj(from_tty));
+    Tcl_GlobalEvalObj (gdbtk_interp, cmdObj);
+  } else {
+    Tcl_GlobalEval (gdbtk_interp, "debug {*** In gdbtk_trace_find, from_tty is false}");
+  }
+}
+
+/*
+ * gdbtk_trace_start_stop
+ *
+ * This is run by the trace_start_command and trace_stop_command.
+ * The START variable determines which, 1 meaning trace_start was run,
+ * 0 meaning trace_stop was run.
+ *
+ */
+
+static void
+gdbtk_trace_start_stop (start, from_tty)
+     int start;
+     int from_tty;
+{
+  Tcl_Obj *cmdObj;
+  
+  if (from_tty) {
+    Tcl_GlobalEval (gdbtk_interp, "debug {*** In gdbtk_trace_start, from_tty is true}");
+    cmdObj = Tcl_NewListObj (0, NULL);
+    if (start)
+      Tcl_ListObjAppendElement (gdbtk_interp, cmdObj,
+                               Tcl_NewStringObj ("gdbtk_tcl_tstart", -1));
+    else
+      Tcl_ListObjAppendElement (gdbtk_interp, cmdObj,
+                               Tcl_NewStringObj ("gdbtk_tcl_tstop", -1));
+    Tcl_GlobalEvalObj (gdbtk_interp, cmdObj);
+  } else {
+    Tcl_GlobalEval (gdbtk_interp, "debug {*** In gdbtk_trace_startd, from_tty is false}");
+  }
+
+}
+
 static void
 gdbtk_selected_frame_changed (level)
      int level;
@@ -702,3 +752,19 @@ gdbtk_context_change (num)
 {
   gdb_context = num;
 }
+
+/* Called from file_command */
+static void
+gdbtk_file_changed (filename)
+     char *filename;
+{
+  gdbtk_two_elem_cmd ("gdbtk_tcl_file_changed", filename);
+}
+
+/* Called from exec_file_command */
+static void
+gdbtk_exec_file_display (filename)
+     char *filename;
+{
+  gdbtk_two_elem_cmd ("gdbtk_tcl_exec_file_display", filename);
+}
This page took 0.025921 seconds and 4 git commands to generate.