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