Replacing a bogus file with a semi-bogus one (sharing through devo).
[deliverable/binutils-gdb.git] / gdb / gdbtk-hooks.c
index b76f2ff03c5467f65abf01dfedb202582b784bb1..54eacb6632621f05a8fd72b1e5e6972798fed646 100644 (file)
@@ -73,19 +73,24 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 
 int in_fputs = 0;
 
-int (*ui_load_progress_hook) PARAMS ((char *, unsigned long));
-void (*pre_add_symbol_hook) PARAMS ((char *));
-void (*post_add_symbol_hook) PARAMS ((void));
-
-#ifdef __CYGWIN32__
+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 __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 *));
@@ -107,6 +112,8 @@ static void gdbtk_print_frame_info PARAMS ((struct symtab *, int, int, int));
 static void gdbtk_post_add_symbol PARAMS ((void));
 static void pc_changed PARAMS ((void));
 static void tracepoint_notify PARAMS ((struct tracepoint *, const char *));
+static void gdbtk_selected_frame_changed PARAMS ((int));
+static void gdbtk_context_change PARAMS ((int));
 
 /*
  * gdbtk_fputs can't be static, because we need to call it in gdbtk.c.
@@ -140,20 +147,26 @@ 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;
 }
 
 /* These control where to put the gdb output which is created by
@@ -297,16 +310,11 @@ void
 gdbtk_ignorable_warning (warning)
      const char *warning;
 {
-  char buf[200], *merge[2];
-  char *command;
-
+  char buf[512];
   sprintf (buf, warning);
   gdbtk_two_elem_cmd ("gdbtk_tcl_ignorable_warning", buf);
-
 }
 
-
-
 static void
 pc_changed()
 {
@@ -361,7 +369,7 @@ x_event (signo)
 
   in_x_event = 1;
 
-#ifdef __CYGWIN32__
+#ifdef __CYGWIN__
   if (signo == -2)
     gdbtk_stop_timer ();
 #endif
@@ -402,8 +410,7 @@ gdbtk_readline_begin (va_alist)
 #endif
 {
   va_list args;
-  char buf[200], *merge[2];
-  char *command;
+  char buf[200];
 
 #ifdef ANSI_PROTOTYPES
   va_start (args, format);
@@ -458,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);
@@ -544,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);
 
@@ -594,7 +581,9 @@ gdbtk_wait (pid, ourstatus)
      int pid;
      struct target_waitstatus *ourstatus;
 {
-  gdbtk_start_timer ();
+  /* Don't run the timer on various targets... */
+  if (!STREQ (target_shortname, "ice"))
+    gdbtk_start_timer ();
   pid = target_wait (pid, ourstatus);
   gdbtk_stop_timer ();
   return pid;
@@ -674,7 +663,7 @@ tracepoint_notify(tp, action)
   filename = symtab_to_filename (sal.symtab);
   if (filename == NULL)
     filename = "N/A";
-  sprintf (buf, "gdbtk_tcl_tracepoint %s %d 0x%lx %d {%s}", action, tp->number, 
+  sprintf (buf, "gdbtk_tcl_tracepoint %s %d 0x%lx %d {%s} %d", action, tp->number, 
           (long)tp->address, sal.line, filename, tp->pass_count);
 
   v = Tcl_Eval (gdbtk_interp, buf);
@@ -686,4 +675,96 @@ 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;
+{
+  Tcl_UpdateLinkedVar (gdbtk_interp, "gdb_selected_frame_level");
+}
+
+/* Called when the current thread changes. */
+/* gdb_context is linked to the tcl variable "gdb_context_id" */
+static void
+gdbtk_context_change (num)
+     int 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.026137 seconds and 4 git commands to generate.