1 |
578 |
markom |
# GDBtk (Insight) entry point
|
2 |
|
|
# Copyright 1997, 1998, 1999 Cygnus Solutions
|
3 |
|
|
#
|
4 |
|
|
# This program is free software; you can redistribute it and/or modify it
|
5 |
|
|
# under the terms of the GNU General Public License (GPL) as published by
|
6 |
|
|
# the Free Software Foundation; either version 2 of the License, or (at
|
7 |
|
|
# your option) any later version.
|
8 |
|
|
#
|
9 |
|
|
# This program is distributed in the hope that it will be useful,
|
10 |
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11 |
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12 |
|
|
# GNU General Public License for more details.
|
13 |
|
|
|
14 |
|
|
|
15 |
|
|
# State is controlled by 5 global boolean variables.
|
16 |
|
|
#
|
17 |
|
|
# gdb_target_changed
|
18 |
|
|
# gdb_exe_changed
|
19 |
|
|
# gdb_running
|
20 |
|
|
# gdb_downloading
|
21 |
|
|
# gdb_loaded
|
22 |
|
|
|
23 |
|
|
################### Initialization code #########################
|
24 |
|
|
|
25 |
|
|
# If GDBtk fails to start at all, you might want to uncomment one or
|
26 |
|
|
# both of these.
|
27 |
|
|
#set tcl_traceExec 2
|
28 |
|
|
#set tcl_traceCompile 1
|
29 |
|
|
|
30 |
|
|
# Add gdb's Tcl library directory to the end of the auto-load search path, if
|
31 |
|
|
# it isn't already on the path.
|
32 |
|
|
# Also, add the plugins directory if it exists.
|
33 |
|
|
# Note: GDBTK_LIBRARY will be set in tcl_findLibrary before main.tcl is called.
|
34 |
|
|
|
35 |
|
|
set gdb_plugins ""
|
36 |
|
|
|
37 |
|
|
if {[info exists auto_path]} {
|
38 |
|
|
if {[lsearch -exact $auto_path $GDBTK_LIBRARY] < 0} {
|
39 |
|
|
lappend auto_path $GDBTK_LIBRARY
|
40 |
|
|
}
|
41 |
|
|
# In any case, add the plugins directory if it exists
|
42 |
|
|
if {[file exists [file join $GDBTK_LIBRARY plugins]]} {
|
43 |
|
|
set gdb_plugins [file join $GDBTK_LIBRARY plugins]
|
44 |
|
|
lappend auto_path $gdb_plugins
|
45 |
|
|
}
|
46 |
|
|
}
|
47 |
|
|
|
48 |
|
|
# Require the packages we need. Most are loaded already, but this will catch
|
49 |
|
|
# any odd errors... :
|
50 |
|
|
package require Tcl 8.0
|
51 |
|
|
package require Tk 8.0
|
52 |
|
|
package require Itcl 3.0
|
53 |
|
|
package require Itk 3.0
|
54 |
|
|
package require Gdbtk 1.0
|
55 |
|
|
package require combobox 1.0
|
56 |
|
|
|
57 |
|
|
namespace import itcl::*
|
58 |
|
|
|
59 |
|
|
namespace import debug::*
|
60 |
|
|
|
61 |
|
|
if {![find_iwidgets_library]} {
|
62 |
|
|
set msg "Could not find the Iwidgets libraries.\n\nGot nameofexec: [info nameofexecutable]\nError(s) were: \n$errMsg"
|
63 |
|
|
|
64 |
|
|
if {![info exists ::env(GDBTK_TEST_RUNNING)] || $::env(GDBTK_TEST_RUNNING) == 0} {
|
65 |
|
|
puts stderr $msg
|
66 |
|
|
} else {
|
67 |
|
|
tk_messageBox -title Error -message $msg -icon error -type ok
|
68 |
|
|
}
|
69 |
|
|
exit
|
70 |
|
|
}
|
71 |
|
|
|
72 |
|
|
# Environment variables controlling debugging:
|
73 |
|
|
# GDBTK_TRACE
|
74 |
|
|
# unset or 0 no tracing
|
75 |
|
|
# 1 tracing initialized but not started
|
76 |
|
|
# 2 tracing initialized and started
|
77 |
|
|
#
|
78 |
|
|
# GDBTK_DEBUGFILE - filename to write debugging messages and
|
79 |
|
|
# trace information (if tracing is enabled).
|
80 |
|
|
#
|
81 |
|
|
if {[info exists env(GDBTK_TRACE)] && $env(GDBTK_TRACE) != 0} {
|
82 |
|
|
# WARNING: the tracing code must not trace into itself or
|
83 |
|
|
# infinite recursion will result. As currently configured
|
84 |
|
|
# the tracing code will not trace basic tcl functions or anything defined
|
85 |
|
|
# before debug::init. For this reason we must source the DebugWin
|
86 |
|
|
# code before debug::init is called.
|
87 |
|
|
source [file join $GDBTK_LIBRARY debugwin.ith]
|
88 |
|
|
source [file join $GDBTK_LIBRARY debugwin.itb]
|
89 |
|
|
|
90 |
|
|
# Calling this installs our hooks for tracing and profiling.
|
91 |
|
|
# This WILL slow things down.
|
92 |
|
|
::debug::init
|
93 |
|
|
|
94 |
|
|
if {$env(GDBTK_TRACE) == 2} {
|
95 |
|
|
::debug::trace_start
|
96 |
|
|
}
|
97 |
|
|
}
|
98 |
|
|
|
99 |
|
|
if {[info exists env(GDBTK_DEBUGFILE)]} {
|
100 |
|
|
::debug::logfile $env(GDBTK_DEBUGFILE)
|
101 |
|
|
}
|
102 |
|
|
|
103 |
|
|
if {$tcl_platform(platform) == "unix"} {
|
104 |
|
|
# tix resetoptions TK TK
|
105 |
|
|
# tk_setPalette tan
|
106 |
|
|
tix resetoptions TixGray [tix cget -fontset]
|
107 |
|
|
}
|
108 |
|
|
|
109 |
|
|
# For testing
|
110 |
|
|
set _test(interactive) 0
|
111 |
|
|
|
112 |
|
|
# initialize state variables
|
113 |
|
|
initialize_gdbtk
|
114 |
|
|
|
115 |
|
|
# set traces on state variables
|
116 |
|
|
trace variable gdb_running w do_state_hook
|
117 |
|
|
trace variable gdb_downloading w do_state_hook
|
118 |
|
|
trace variable gdb_loaded w do_state_hook
|
119 |
|
|
define_hook state_hook
|
120 |
|
|
|
121 |
|
|
# set up preferences
|
122 |
|
|
pref init
|
123 |
|
|
|
124 |
|
|
# let libgui tell us how to feel
|
125 |
|
|
standard_look_and_feel
|
126 |
|
|
|
127 |
|
|
# now let GDB set its default preferences
|
128 |
|
|
pref_set_defaults
|
129 |
|
|
|
130 |
|
|
# read in preferences
|
131 |
|
|
pref_read
|
132 |
|
|
|
133 |
|
|
init_disassembly_flavor
|
134 |
|
|
|
135 |
|
|
ManagedWin::init
|
136 |
|
|
|
137 |
|
|
# This stuff will help us play nice with WindowMaker's AppIcons.
|
138 |
|
|
# Can't do the first bit yet, since we don't get this from gdb...
|
139 |
|
|
# wm command . [concat $argv0 $argv]
|
140 |
|
|
wm group . .
|
141 |
|
|
|
142 |
|
|
# Open debug window if testsuite is not running and GDBTK_DEBUG is set
|
143 |
|
|
if {![info exists env(GDBTK_TEST_RUNNING)] || !$env(GDBTK_TEST_RUNNING)} {
|
144 |
|
|
if {[info exists env(GDBTK_DEBUG)] && $env(GDBTK_DEBUG) > 1} {
|
145 |
|
|
ManagedWin::open DebugWin
|
146 |
|
|
}
|
147 |
|
|
}
|
148 |
|
|
|
149 |
|
|
# some initial commands to get gdb in the right mode
|
150 |
|
|
gdb_cmd {set height 0}
|
151 |
|
|
gdb_cmd {set width 0}
|
152 |
|
|
|
153 |
|
|
if {[info exists env(GDBTK_TEST_RUNNING)] && $env(GDBTK_TEST_RUNNING)} {
|
154 |
|
|
set gdb_target_name "exec"
|
155 |
|
|
} else {
|
156 |
|
|
# gdb_target_name is the name of the GDB target; that is, the argument
|
157 |
|
|
# to the GDB target command.
|
158 |
|
|
set gdb_target_name ""
|
159 |
|
|
# By setting gdb_target_changed, we force a target dialog
|
160 |
|
|
# to be displayed on the first "run"
|
161 |
|
|
set gdb_target_changed 1
|
162 |
|
|
}
|
163 |
|
|
|
164 |
|
|
update
|
165 |
|
|
|
166 |
|
|
# Uncomment the next line if you want a splash screen at startup...
|
167 |
|
|
# ManagedWin::open About -transient -expire 5000
|
168 |
|
|
|
169 |
|
|
gdbtk_idle
|
170 |
|
|
|