Move other gdbtk testsuite changelog entries here
[deliverable/binutils-gdb.git] / gdb / gdbtk-hooks.c
CommitLineData
ca4e7e14
JI
1/* Startup code for gdbtk.
2 Copyright 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
3
4 Written by Stu Grossman <grossman@cygnus.com> of Cygnus Support.
5
6This file is part of GDB.
7
8This program is free software; you can redistribute it and/or modify
9it under the terms of the GNU General Public License as published by
10the Free Software Foundation; either version 2 of the License, or
11(at your option) any later version.
12
13This program is distributed in the hope that it will be useful,
14but WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16GNU General Public License for more details.
17
18You should have received a copy of the GNU General Public License
19along with this program; if not, write to the Free Software
20Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
21
22#include "defs.h"
23#include "symtab.h"
24#include "inferior.h"
25#include "command.h"
26#include "bfd.h"
27#include "symfile.h"
28#include "objfiles.h"
29#include "target.h"
30#include "gdbcore.h"
31#include "tracepoint.h"
32#include "demangle.h"
33
34#ifdef _WIN32
35#include <winuser.h>
36#endif
37
38#include <sys/stat.h>
39
40#include <tcl.h>
41#include <tk.h>
42#include <itcl.h>
43#include <tix.h>
44#include "guitcl.h"
45#include "gdbtk.h"
46
47#ifdef IDE
48/* start-sanitize-ide */
49#include "event.h"
50#include "idetcl.h"
51#include "ilutk.h"
52/* end-sanitize-ide */
53#endif
54
55#ifdef ANSI_PROTOTYPES
56#include <stdarg.h>
57#else
58#include <varargs.h>
59#endif
60#include <signal.h>
61#include <fcntl.h>
62#include <unistd.h>
63#include <setjmp.h>
64#include "top.h"
65#include <sys/ioctl.h>
66#include "gdb_string.h"
67#include "dis-asm.h"
68#include <stdio.h>
69#include "gdbcmd.h"
70
71#include "annotate.h"
72#include <sys/time.h>
73
74int in_fputs = 0;
75
3d64f1e0
KS
76extern int (*ui_load_progress_hook) PARAMS ((char *, unsigned long));
77extern void (*pre_add_symbol_hook) PARAMS ((char *));
78extern void (*post_add_symbol_hook) PARAMS ((void));
79extern void (*selected_frame_level_changed_hook) PARAMS ((int));
c98fe0c1 80#ifdef __CYGWIN32__
ca4e7e14
JI
81extern void (*ui_loop_hook) PARAMS ((int));
82#endif
3d64f1e0 83
ca4e7e14
JI
84static void gdbtk_create_tracepoint PARAMS ((struct tracepoint *));
85static void gdbtk_delete_tracepoint PARAMS ((struct tracepoint *));
86static void gdbtk_modify_tracepoint PARAMS ((struct tracepoint *));
63d138d9 87static void gdbtk_trace_find PARAMS ((char *arg, int from_tty));
2aae6397 88static void gdbtk_trace_start_stop PARAMS ((int, int));
ca4e7e14
JI
89static void gdbtk_create_breakpoint PARAMS ((struct breakpoint *));
90static void gdbtk_delete_breakpoint PARAMS ((struct breakpoint *));
91static void gdbtk_modify_breakpoint PARAMS ((struct breakpoint *));
4fb67eb5
KS
92static void gdbtk_file_changed PARAMS ((char *));
93static void gdbtk_exec_file_display PARAMS ((char *));
ca4e7e14
JI
94static void tk_command_loop PARAMS ((void));
95static void gdbtk_call_command PARAMS ((struct cmd_list_element *, char *, int));
96static int gdbtk_wait PARAMS ((int, struct target_waitstatus *));
97 void x_event PARAMS ((int));
98static int gdbtk_query PARAMS ((const char *, va_list));
99static void gdbtk_warning PARAMS ((const char *, va_list));
100void gdbtk_ignorable_warning PARAMS ((const char *));
101static char* gdbtk_readline PARAMS ((char *));
102static void
103#ifdef ANSI_PROTOTYPES
104gdbtk_readline_begin (char *format, ...);
105#else
106gdbtk_readline_begin ();
107#endif
108static void gdbtk_readline_end PARAMS ((void));
65b07ddc 109static void gdbtk_flush PARAMS ((GDB_FILE *));
ca4e7e14
JI
110static void gdbtk_pre_add_symbol PARAMS ((char *));
111static void gdbtk_print_frame_info PARAMS ((struct symtab *, int, int, int));
112static void gdbtk_post_add_symbol PARAMS ((void));
7c5c8a5e
MH
113static void gdbtk_register_changed PARAMS ((int regno));
114static void gdbtk_memory_changed PARAMS ((CORE_ADDR addr, int len));
ca4e7e14 115static void tracepoint_notify PARAMS ((struct tracepoint *, const char *));
3d64f1e0 116static void gdbtk_selected_frame_changed PARAMS ((int));
4ff5d55a 117static void gdbtk_context_change PARAMS ((int));
c98fe0c1 118static void gdbtk_error_begin PARAMS ((void));
ca4e7e14
JI
119
120/*
121 * gdbtk_fputs can't be static, because we need to call it in gdbtk.c.
122 * See note there for details.
123 */
124
65b07ddc 125void gdbtk_fputs PARAMS ((const char *, GDB_FILE *));
ca4e7e14
JI
126int gdbtk_load_hash PARAMS ((char *, unsigned long));
127static void breakpoint_notify PARAMS ((struct breakpoint *, const char *));
128
129/*
130 * gdbtk_add_hooks - add all the hooks to gdb. This will get called by the
131 * startup code to fill in the hooks needed by core gdb.
132 */
133
134void
135gdbtk_add_hooks(void)
136{
137 command_loop_hook = tk_command_loop;
138 call_command_hook = gdbtk_call_command;
139 readline_begin_hook = gdbtk_readline_begin;
140 readline_hook = gdbtk_readline;
141 readline_end_hook = gdbtk_readline_end;
142
143 print_frame_info_listing_hook = gdbtk_print_frame_info;
144 query_hook = gdbtk_query;
145 warning_hook = gdbtk_warning;
146 flush_hook = gdbtk_flush;
147
148 create_breakpoint_hook = gdbtk_create_breakpoint;
149 delete_breakpoint_hook = gdbtk_delete_breakpoint;
150 modify_breakpoint_hook = gdbtk_modify_breakpoint;
151
2c04e0d9
KS
152 interactive_hook = gdbtk_interactive;
153 target_wait_hook = gdbtk_wait;
154 ui_load_progress_hook = gdbtk_load_hash;
155
c98fe0c1 156#ifdef __CYGWIN32__
ca4e7e14
JI
157 ui_loop_hook = x_event;
158#endif
2c04e0d9
KS
159 pre_add_symbol_hook = gdbtk_pre_add_symbol;
160 post_add_symbol_hook = gdbtk_post_add_symbol;
4fb67eb5
KS
161 file_changed_hook = gdbtk_file_changed;
162 exec_file_display_hook = gdbtk_exec_file_display;
ca4e7e14
JI
163
164 create_tracepoint_hook = gdbtk_create_tracepoint;
165 delete_tracepoint_hook = gdbtk_delete_tracepoint;
166 modify_tracepoint_hook = gdbtk_modify_tracepoint;
63d138d9 167 trace_find_hook = gdbtk_trace_find;
2aae6397 168 trace_start_stop_hook = gdbtk_trace_start_stop;
c98fe0c1 169
7c5c8a5e
MH
170 register_changed_hook = gdbtk_register_changed;
171 memory_changed_hook = gdbtk_memory_changed;
3d64f1e0 172 selected_frame_level_changed_hook = gdbtk_selected_frame_changed;
4ff5d55a 173 context_hook = gdbtk_context_change;
c98fe0c1
JI
174
175 error_begin_hook = gdbtk_error_begin;
ca4e7e14
JI
176}
177
178/* These control where to put the gdb output which is created by
179 {f}printf_{un}filtered and friends. gdbtk_fputs and gdbtk_flush are the
180 lowest level of these routines and capture all output from the rest of GDB.
181
182 The reason to use the result_ptr rather than the gdbtk_interp's result
183 directly is so that a call_wrapper invoked function can preserve its result
184 across calls into Tcl which might be made in the course of the function's
185 execution.
186
187 * result_ptr->obj_ptr is where to accumulate the result.
188 * GDBTK_TO_RESULT flag means the output goes to the gdbtk_tcl_fputs proc
189 instead of to the result_ptr.
190 * GDBTK_MAKES_LIST flag means add to the result as a list element.
191
192 */
193
194gdbtk_result *result_ptr = NULL;
195\f
196
197/* This allows you to Tcl_Eval a tcl command which takes
198 a command word, and then a single argument. */
199
200int gdbtk_two_elem_cmd (cmd_name, argv1)
201 char *cmd_name;
202 char * argv1;
203{
204 char *command;
205 int result, flags_ptr, arg_len, cmd_len;
206
207 arg_len = Tcl_ScanElement (argv1, &flags_ptr);
208 cmd_len = strlen (cmd_name);
209 command = malloc(arg_len + cmd_len + 2);
210 strcpy (command, cmd_name);
211 strcat (command, " ");
212
213 Tcl_ConvertElement (argv1, command + cmd_len + 1, flags_ptr);
214
215 result = Tcl_Eval (gdbtk_interp, command);
216 free (command);
217 return result;
218
219}
220
221static void
222gdbtk_flush (stream)
65b07ddc 223 GDB_FILE *stream;
ca4e7e14
JI
224{
225#if 0
226 /* Force immediate screen update */
227
228 Tcl_VarEval (gdbtk_interp, "gdbtk_tcl_flush", NULL);
229#endif
230}
231
232/* This handles all the output from gdb. All the gdb printf_xxx functions
233 * eventually end up here. The output is either passed to the result_ptr
234 * where it will go to the result of some gdbtk command, or passed to the
235 * Tcl proc gdbtk_tcl_fputs (where it is usually just dumped to the console
236 * window.
237 *
238 * The cases are:
239 *
240 * 1) result_ptr == NULL - This happens when some output comes from gdb which
f3b86a30 241 * is not generated by a command in gdbtk-cmds, usually startup stuff.
ca4e7e14
JI
242 * In this case we just route the data to gdbtk_tcl_fputs.
243 * 2) The GDBTK_TO_RESULT flag is set - The result is supposed to go to Tcl.
244 * We place the data into the result_ptr, either as a string,
245 * or a list, depending whether the GDBTK_MAKES_LIST bit is set.
246 * 3) The GDBTK_TO_RESULT flag is unset - We route the data to gdbtk_tcl_fputs
65b07ddc 247 * UNLESS it was coming to gdb_stderr. Then we place it in the result_ptr
ca4e7e14
JI
248 * anyway, so it can be dealt with.
249 *
250 */
251
252void
253gdbtk_fputs (ptr, stream)
254 const char *ptr;
65b07ddc 255 GDB_FILE *stream;
ca4e7e14
JI
256{
257 in_fputs = 1;
258
259 if (result_ptr != NULL)
260 {
261 if (result_ptr->flags & GDBTK_TO_RESULT)
262 {
263 if (result_ptr->flags & GDBTK_MAKES_LIST)
264 Tcl_ListObjAppendElement(NULL, result_ptr->obj_ptr,
265 Tcl_NewStringObj((char *) ptr, -1));
266 else
267 Tcl_AppendToObj (result_ptr->obj_ptr, (char *) ptr, -1);
268 }
c98fe0c1 269 else if (stream == gdb_stderr || result_ptr->flags & GDBTK_ERROR_ONLY)
ca4e7e14
JI
270 {
271 if (result_ptr->flags & GDBTK_ERROR_STARTED)
272 Tcl_AppendToObj (result_ptr->obj_ptr, (char *) ptr, -1);
273 else
274 {
275 Tcl_SetStringObj (result_ptr->obj_ptr, (char *) ptr, -1);
276 result_ptr->flags |= GDBTK_ERROR_STARTED;
277 }
278 }
279 else
280 {
281 gdbtk_two_elem_cmd ("gdbtk_tcl_fputs", (char *) ptr);
282 if (result_ptr->flags & GDBTK_MAKES_LIST)
283 gdbtk_two_elem_cmd ("gdbtk_tcl_fputs", " ");
284 }
285 }
286 else
287 {
288 gdbtk_two_elem_cmd ("gdbtk_tcl_fputs", (char *) ptr);
289 }
290
291 in_fputs = 0;
292}
293
294/*
295 * This routes all warnings to the Tcl function "gdbtk_tcl_warning".
296 */
297
298static void
299gdbtk_warning (warning, args)
300 const char *warning;
301 va_list args;
302{
303 char buf[200];
304
305 vsprintf (buf, warning, args);
306 gdbtk_two_elem_cmd ("gdbtk_tcl_warning", buf);
307
308}
309
310/*
311 * This routes all ignorable warnings to the Tcl function
312 * "gdbtk_tcl_ignorable_warning".
313 */
314
315void
316gdbtk_ignorable_warning (warning)
317 const char *warning;
318{
6f5af15b 319 char buf[512];
ca4e7e14
JI
320 sprintf (buf, warning);
321 gdbtk_two_elem_cmd ("gdbtk_tcl_ignorable_warning", buf);
ca4e7e14
JI
322}
323
ca4e7e14 324static void
7c5c8a5e
MH
325gdbtk_register_changed(regno)
326 int regno;
ca4e7e14 327{
7c5c8a5e
MH
328 Tcl_Eval (gdbtk_interp, "gdbtk_register_changed");
329}
330
331static void
332gdbtk_memory_changed(addr, len)
333 CORE_ADDR addr;
334 int len;
335{
336 Tcl_Eval (gdbtk_interp, "gdbtk_memory_changed");
ca4e7e14
JI
337}
338
339\f
340/* This function is called instead of gdb's internal command loop. This is the
341 last chance to do anything before entering the main Tk event loop.
342 At the end of the command, we enter the main loop. */
343
344static void
345tk_command_loop ()
346{
65b07ddc 347 extern FILE *instream;
ca4e7e14
JI
348
349 /* We no longer want to use stdin as the command input stream */
350 instream = NULL;
351
352 if (Tcl_Eval (gdbtk_interp, "gdbtk_tcl_preloop") != TCL_OK)
353 {
354 char *msg;
355
356 /* Force errorInfo to be set up propertly. */
357 Tcl_AddErrorInfo (gdbtk_interp, "");
358
359 msg = Tcl_GetVar (gdbtk_interp, "errorInfo", TCL_GLOBAL_ONLY);
360#ifdef _WIN32
361 MessageBox (NULL, msg, NULL, MB_OK | MB_ICONERROR | MB_TASKMODAL);
362#else
363 fputs_unfiltered (msg, gdb_stderr);
364#endif
365 }
366
367#ifdef _WIN32
368 close_bfds ();
369#endif
370
371 Tk_MainLoop ();
372}
373
374/* Come here when there is activity on the X file descriptor. */
375
376void
377x_event (signo)
378 int signo;
379{
380 static int in_x_event = 0;
381 static Tcl_Obj *varname = NULL;
382 if (in_x_event || in_fputs)
383 return;
384
385 in_x_event = 1;
386
c98fe0c1 387#ifdef __CYGWIN32__
ca4e7e14
JI
388 if (signo == -2)
389 gdbtk_stop_timer ();
390#endif
391
392 /* Process pending events */
393 while (Tcl_DoOneEvent (TCL_DONT_WAIT|TCL_ALL_EVENTS) != 0)
394 ;
395
396 if (load_in_progress)
397 {
398 int val;
399 if (varname == NULL)
400 {
401 Tcl_Obj *varnamestrobj = Tcl_NewStringObj("download_cancel_ok",-1);
402 varname = Tcl_ObjGetVar2(gdbtk_interp,varnamestrobj,NULL,TCL_GLOBAL_ONLY);
403 }
404 if ((Tcl_GetIntFromObj(gdbtk_interp,varname,&val) == TCL_OK) && val)
405 {
406 quit_flag = 1;
407#ifdef REQUEST_QUIT
408 REQUEST_QUIT;
409#else
410 if (immediate_quit)
411 quit ();
412#endif
413 }
414 }
415 in_x_event = 0;
416}
417
418/* VARARGS */
419static void
420#ifdef ANSI_PROTOTYPES
421gdbtk_readline_begin (char *format, ...)
422#else
423gdbtk_readline_begin (va_alist)
424 va_dcl
425#endif
426{
427 va_list args;
6f5af15b 428 char buf[200];
ca4e7e14
JI
429
430#ifdef ANSI_PROTOTYPES
431 va_start (args, format);
432#else
433 char *format;
434 va_start (args);
435 format = va_arg (args, char *);
436#endif
437
438 vsprintf (buf, format, args);
439 gdbtk_two_elem_cmd ("gdbtk_tcl_readline_begin", buf);
440
441}
442
443static char *
444gdbtk_readline (prompt)
445 char *prompt;
446{
447 int result;
448
449#ifdef _WIN32
450 close_bfds ();
451#endif
452
453 result = gdbtk_two_elem_cmd ("gdbtk_tcl_readline", prompt);
454
455 if (result == TCL_OK)
456 {
457 return (strdup (gdbtk_interp -> result));
458 }
459 else
460 {
461 gdbtk_fputs (gdbtk_interp -> result, gdb_stdout);
462 gdbtk_fputs ("\n", gdb_stdout);
463 return (NULL);
464 }
465}
466
467static void
468gdbtk_readline_end ()
469{
470 Tcl_Eval (gdbtk_interp, "gdbtk_tcl_readline_end");
471}
472
473static void
474gdbtk_call_command (cmdblk, arg, from_tty)
475 struct cmd_list_element *cmdblk;
476 char *arg;
477 int from_tty;
478{
479 running_now = 0;
480 if (cmdblk->class == class_run || cmdblk->class == class_trace)
481 {
482
2aae6397
JI
483 running_now = 1;
484 if (!No_Update)
485 Tcl_Eval (gdbtk_interp, "gdbtk_tcl_busy");
486 (*cmdblk->function.cfunc)(arg, from_tty);
487 running_now = 0;
488 if (!No_Update)
489 Tcl_Eval (gdbtk_interp, "gdbtk_tcl_idle");
ca4e7e14
JI
490 }
491 else
492 (*cmdblk->function.cfunc)(arg, from_tty);
493}
494
495/* The next three functions use breakpoint_notify to allow the GUI
496 * to handle creating, deleting and modifying breakpoints. These three
497 * functions are put into the appropriate gdb hooks in gdbtk_init.
498 */
499
500static void
501gdbtk_create_breakpoint(b)
502 struct breakpoint *b;
503{
504 breakpoint_notify (b, "create");
505}
506
507static void
508gdbtk_delete_breakpoint(b)
509 struct breakpoint *b;
510{
511 breakpoint_notify (b, "delete");
512}
513
514static void
515gdbtk_modify_breakpoint(b)
516 struct breakpoint *b;
517{
518 breakpoint_notify (b, "modify");
519}
520
521/* This is the generic function for handling changes in
522 * a breakpoint. It routes the information to the Tcl
523 * command "gdbtk_tcl_breakpoint" in the form:
524 * gdbtk_tcl_breakpoint action b_number b_address b_line b_file
525 * On error, the error string is written to gdb_stdout.
526 */
527
528static void
529breakpoint_notify(b, action)
530 struct breakpoint *b;
531 const char *action;
532{
533 char buf[256];
534 int v;
535 struct symtab_and_line sal;
536 char *filename;
537
538 if (b->type != bp_breakpoint)
539 return;
540
541 /* We ensure that ACTION contains no special Tcl characters, so we
542 can do this. */
543 sal = find_pc_line (b->address, 0);
544 filename = symtab_to_filename (sal.symtab);
545 if (filename == NULL)
546 filename = "";
547
63d138d9
JI
548 sprintf (buf, "gdbtk_tcl_breakpoint %s %d 0x%lx %d {%s} {%s} %d %d",
549 action, b->number, (long)b->address, b->line_number, filename,
550 bpdisp[b->disposition], b->enable, b->thread);
ca4e7e14
JI
551
552 v = Tcl_Eval (gdbtk_interp, buf);
553
554 if (v != TCL_OK)
555 {
556 gdbtk_fputs (Tcl_GetStringResult (gdbtk_interp), gdb_stdout);
557 gdbtk_fputs ("\n", gdb_stdout);
558 }
559}
560
561int
562gdbtk_load_hash (section, num)
563 char *section;
564 unsigned long num;
565{
566 char buf[128];
567 sprintf (buf, "download_hash %s %ld", section, num);
568 Tcl_Eval (gdbtk_interp, buf);
569 return atoi (gdbtk_interp->result);
570}
571
572
573/* This hook is called whenever we are ready to load a symbol file so that
574 the UI can notify the user... */
575static void
576gdbtk_pre_add_symbol (name)
577 char *name;
578{
579
580 gdbtk_two_elem_cmd("gdbtk_tcl_pre_add_symbol", name);
581
582}
583
584/* This hook is called whenever we finish loading a symbol file. */
585static void
586gdbtk_post_add_symbol ()
587{
588 Tcl_Eval (gdbtk_interp, "gdbtk_tcl_post_add_symbol");
589}
590
591/* This hook function is called whenever we want to wait for the
592 target. */
593
594static int
595gdbtk_wait (pid, ourstatus)
596 int pid;
597 struct target_waitstatus *ourstatus;
598{
4ce8d0e9
KS
599 /* Don't run the timer on various targets... */
600 if (!STREQ (target_shortname, "ice"))
601 gdbtk_start_timer ();
ca4e7e14
JI
602 pid = target_wait (pid, ourstatus);
603 gdbtk_stop_timer ();
604 return pid;
605}
606
607/*
608 * This handles all queries from gdb.
609 * The first argument is a printf style format statement, the rest are its
610 * arguments. The resultant formatted string is passed to the Tcl function
611 * "gdbtk_tcl_query".
612 * It returns the users response to the query, as well as putting the value
613 * in the result field of the Tcl interpreter.
614 */
615
616static int
617gdbtk_query (query, args)
618 const char *query;
619 va_list args;
620{
621 char buf[200];
622 long val;
623
624 vsprintf (buf, query, args);
625 gdbtk_two_elem_cmd ("gdbtk_tcl_query", buf);
626
627 val = atol (gdbtk_interp->result);
628 return val;
629}
630
631
632static void
633gdbtk_print_frame_info (s, line, stopline, noerror)
634 struct symtab *s;
635 int line;
636 int stopline;
637 int noerror;
638{
639 current_source_symtab = s;
640 current_source_line = line;
641}
642
643static void
644gdbtk_create_tracepoint (tp)
645 struct tracepoint *tp;
646{
647 tracepoint_notify (tp, "create");
648}
649
650static void
651gdbtk_delete_tracepoint (tp)
652 struct tracepoint *tp;
653{
654 tracepoint_notify (tp, "delete");
655}
656
657static void
658gdbtk_modify_tracepoint (tp)
659 struct tracepoint *tp;
660{
661 tracepoint_notify (tp, "modify");
662}
663
664static void
665tracepoint_notify(tp, action)
666 struct tracepoint *tp;
667 const char *action;
668{
669 char buf[256];
670 int v;
671 struct symtab_and_line sal;
672 char *filename;
673
674 /* We ensure that ACTION contains no special Tcl characters, so we
675 can do this. */
676 sal = find_pc_line (tp->address, 0);
677
678 filename = symtab_to_filename (sal.symtab);
679 if (filename == NULL)
680 filename = "N/A";
6f5af15b 681 sprintf (buf, "gdbtk_tcl_tracepoint %s %d 0x%lx %d {%s} %d", action, tp->number,
ca4e7e14
JI
682 (long)tp->address, sal.line, filename, tp->pass_count);
683
684 v = Tcl_Eval (gdbtk_interp, buf);
685
686 if (v != TCL_OK)
687 {
688 gdbtk_fputs (gdbtk_interp->result, gdb_stdout);
689 gdbtk_fputs ("\n", gdb_stdout);
690 }
691}
692
63d138d9
JI
693/*
694 * gdbtk_trace_find
695 *
696 * This is run by the trace_find_command. arg is the argument that was passed
697 * to that command, from_tty is 1 if the command was run from a tty, 0 if it
698 * was run from a script. It runs gdbtk_tcl_tfind_hook passing on these two
699 * arguments.
700 *
701 */
702
703static void
704gdbtk_trace_find (arg, from_tty)
705 char *arg;
706 int from_tty;
707{
708 Tcl_Obj *cmdObj;
709
2aae6397
JI
710 if (from_tty) {
711 Tcl_GlobalEval (gdbtk_interp, "debug {*** In gdbtk_trace_find, from_tty is true}");
712 cmdObj = Tcl_NewListObj (0, NULL);
713 Tcl_ListObjAppendElement (gdbtk_interp, cmdObj,
714 Tcl_NewStringObj ("gdbtk_tcl_trace_find_hook", -1));
715 Tcl_ListObjAppendElement (gdbtk_interp, cmdObj, Tcl_NewStringObj (arg, -1));
716 Tcl_ListObjAppendElement (gdbtk_interp, cmdObj, Tcl_NewIntObj(from_tty));
717 Tcl_GlobalEvalObj (gdbtk_interp, cmdObj);
718 } else {
719 Tcl_GlobalEval (gdbtk_interp, "debug {*** In gdbtk_trace_find, from_tty is false}");
720 }
721}
722
723/*
724 * gdbtk_trace_start_stop
725 *
726 * This is run by the trace_start_command and trace_stop_command.
727 * The START variable determines which, 1 meaning trace_start was run,
728 * 0 meaning trace_stop was run.
729 *
730 */
731
732static void
733gdbtk_trace_start_stop (start, from_tty)
734 int start;
735 int from_tty;
736{
737 Tcl_Obj *cmdObj;
63d138d9 738
2aae6397
JI
739 if (from_tty) {
740 Tcl_GlobalEval (gdbtk_interp, "debug {*** In gdbtk_trace_start, from_tty is true}");
741 cmdObj = Tcl_NewListObj (0, NULL);
742 if (start)
743 Tcl_ListObjAppendElement (gdbtk_interp, cmdObj,
744 Tcl_NewStringObj ("gdbtk_tcl_tstart", -1));
745 else
746 Tcl_ListObjAppendElement (gdbtk_interp, cmdObj,
747 Tcl_NewStringObj ("gdbtk_tcl_tstop", -1));
748 Tcl_GlobalEvalObj (gdbtk_interp, cmdObj);
749 } else {
750 Tcl_GlobalEval (gdbtk_interp, "debug {*** In gdbtk_trace_startd, from_tty is false}");
751 }
752
63d138d9
JI
753}
754
3d64f1e0
KS
755static void
756gdbtk_selected_frame_changed (level)
757 int level;
758{
759 Tcl_UpdateLinkedVar (gdbtk_interp, "gdb_selected_frame_level");
760}
4ff5d55a
MH
761
762/* Called when the current thread changes. */
763/* gdb_context is linked to the tcl variable "gdb_context_id" */
764static void
765gdbtk_context_change (num)
766 int num;
767{
768 gdb_context = num;
769}
2c04e0d9 770
4fb67eb5
KS
771/* Called from file_command */
772static void
773gdbtk_file_changed (filename)
774 char *filename;
775{
776 gdbtk_two_elem_cmd ("gdbtk_tcl_file_changed", filename);
777}
778
2c04e0d9
KS
779/* Called from exec_file_command */
780static void
4fb67eb5 781gdbtk_exec_file_display (filename)
2c04e0d9
KS
782 char *filename;
783{
4fb67eb5 784 gdbtk_two_elem_cmd ("gdbtk_tcl_exec_file_display", filename);
2c04e0d9 785}
c98fe0c1
JI
786
787/* Called from error_begin, this hook is used to warn the gui
788 about multi-line error messages */
789static void
790gdbtk_error_begin ()
791{
792 if (result_ptr != NULL)
793 result_ptr->flags |= GDBTK_ERROR_ONLY;
794}
795\f
796/* Local variables: */
797/* change-log-default-name: "ChangeLog-gdbtk" */
798/* End: */
This page took 0.071806 seconds and 4 git commands to generate.