2 Written by Stu Grossman
3 Updated 9/26/95 by Fred Fish for gdb 4.15 release
4 Updated 4/18/97 by Martin Hunt
5 Updated 8/15/02 by Keith Seitz
7 This file describes how to build, install, use and hack on Insight (formerly
8 GDBtk), a TK-based GUI for GDB, the GNU debugger.
13 Insight is a version of GDB that uses Tcl/Tk to implement a graphical
14 user inter-face. It is a fully integrated GUI, not a separate
15 front-end program. The interface consists of several separate
16 windows, which use standard elements like buttons, scrollbars, entry
17 boxes and such to create a fairly easy to use interface. Each window
18 has a distinct content and purpose, and can be enabled or disabled
19 individually. The windows contain things like the current source
20 file, a disassembly of the current function, text commands (for things
21 that aren't accessible via a button), and so forth.
23 Building and Installing
24 =======================
26 Building Insight is very straightforward. It is configured/built by
27 default when you checkout or download Insight. Right now, Insight MUST
28 be built using the versions of Tcl, Tk, and Itcl that come with
29 the sources. We're working to fix that, but it is going to take a lot
30 of time. (Want to help?)
32 On Unix machines, you will also need to have X11 (R4/R5/R6) installed
33 (this is a prerequisite to installing Tk).
35 Insight inherits much of GDB's configuration options (like where it is
36 to be installed). See the GDB README file for more details on configure
37 options and such for GDB.
39 It is recommended that Insight, like GDB, be built outside of the source
40 directory in order to preserve the integrity of the source directory. This
41 is very useful, for example, when building GDB/Insight for multiple hosts
48 host> mkdir insight; cd insight
49 host> ../src/configure
56 Insight and all of its support infrastructure read various environment variables
57 for optional startup information. All of these environment variables are
58 optional: Insight and its packages know how to find their files in both the
59 install and the source trees.
63 TCL_LIBRARY The location of the Tcl library files
64 TK_LIBRARY The location of the Tk library files
65 REDHAT_GUI_LIBRARY The location of the libgui library files
66 GDBTK_LIBRARY The location of the Insight library files
67 INSIGHT_PLUGINS A colon-separated list of directories
68 to search for plugins (see gdb/gdbtk/plugins/HOW-TO)
69 GDBTK_DEBUG Controls runtime loading of the Debug Window.
70 (This is the most useful debug option.)
71 GDBTK_TRACE Controls runtime tracing of the tcl code
72 GDBTK_DEBUGFILE Filename to send debug output
73 GDBTK_TEST_RUNNING Testsuite variable. See gdb/testsuite/gdb.gdbtk/README
75 INSIGHT_FORCE_READ_PREFERENCES
76 If set, read .gdbtkinit (or gdb.ini on windows)
77 even when -nx is passed to GDB.
78 DISPLAY The display to use on unix/X platforms.
79 Not used on Windows platforms.
81 All of the environment variables for controlling Insight are well documented
82 in gdb/gdbtk/library/main.tcl. Search for "env" to find them all.
87 You can start Insight by running the `insight' executable (for cross-platform
88 targets, include the build triple, i.e., `powerpc-elf-insight'). Alternatively start
89 Insight by telling GDB to start it with `gdb -w' or `gdb -i=insight'. If
90 everything goes well, you should have several windows pop up. To get going,
91 hit the Run button, and go exploring.
93 If you want to use GDB in command line mode, just use the -nw option or the
94 console interpreter (`insight -i=console').
96 Insight comes with all your standard debugger windows, including:
105 o Thread/Process Window
106 o Function Browser Window
107 o Debug Window (for developers)
109 Insight also has an extensive (if outdated) online help system which describes
110 all the windows and explains how to use them. Users are urged to browse this
111 help system for information on using Insight.
116 The GUI is primarily implemented by Tcl/Tk code which lives in gdb/gdbtk/library
117 and bunch of C files in gdb/gdbtk/generic. The Tcl/Tk code determines the look
118 and feel, the layout, and the functions associated with all of the interface
119 elements. The C code is mostly just glue between GDB internals and Tcl-land.
120 In essence, all of the policy is implemented in Tcl/Tk, and is easily changed
123 To make more serious changes to the interface, such as adding a new window or
124 changing the framework, you will have to hack the tcl code (and probably the C
125 code as well). The tcl library install directory is $(libdir) (probably
126 /usr/local/lib/insight1.0). But, you will probably want to hack on your own
127 private copy before putting it up for the rest of the users. To find the GDB tcl
128 code, GDB first checks for the environment variable GDBTK_LIBRARY. GDB will check
129 this directory for the file "main.tcl". If GDBTK_LIBRARY is not set, GDB will
130 look for main.tcl in the install directory, and finally it will try to find
131 the tcl directory in the sources.
133 A word about the different files in Insight is in order. Insight is a hybrid of
134 C code and "Tcl" code (actually Incr Tcl code). We use the following conventions
135 for naming our tcl files (most of the time!). Any file with a ".tcl" extension
136 is simply vanilla tcl code. Any file ending with ".itcl" is an Itcl file,
137 class definition and implementation all in one. So far so good. Now comes the
138 toughy: Files ending in ".ith" are Itcl class definition files, and they all
139 must have a corresponding implementation file, ending in ".itb". Why do we do
140 this? Simple. With Itcl, one can reread class implementations at runtime, but
141 one cannot change the class definition. So all those ".itcl" files can only
142 be reread be restarting Insight. The same is not true, though, of the ".itb"
143 files. Those files can be changed and immediately reread and used in Insight
144 without having to restart (as long as the class definition doesn't change). This
145 is a nifty Itcl feature which is fully exploited by the Debug Window, which
146 has a "ReSource" menu on it to reread the Tcl files. (To get to the Debug Window,
147 hit Ctrl-Alt-F11 in the Source Window or type "tk ManagedWin::open DebugWin" in
150 Internally, Insight is basically GDB, linked with Tcl/Tk, some Tcl/Tk extensions,
151 and some glue code that interfaces GDB internals to Tcl-land. This means that
152 Insight operates as a single program, not a front-end to GDB. All GDB commands,
153 and a great deal of the target program state are accessible to the Tcl programmer.
154 In addition, there are many callbacks from GDB to notify Tcl-land of important
155 events. Many of these are accomplished via "hooks" in GDB, and others are
156 accomplished using event notifications. GDB is slowly deprecating the use of
157 "hooks" in favor of its new event mechanism.
159 All of the below commands have lots of nice comments before them explaining what
160 they all do, how they are to be used, etc. The source code is the definitive
161 authority (other than a maintainer) for the definition/usage of a command in
162 Insight. Hackers are urged to read through the source code for any commands
163 which may need explaining.
167 Here is a brief, if incomplete, summary of the Tcl commands that are created
168 by Insight. These are installed into the Tcl interpreter in the C files.
172 gdb_cmd Sends a text command to gdb. Returns the result.
173 DEPRECATED: Do not use any more.
174 gdb_loc Returns a list of useful tidbits about the specified
176 gdb_sourcelines Returns a list of executable lines for a source file
177 gdb_listfiles Returns a list of all of the source files
178 gdb_stop Stops the target process (or at least tries to)
179 gdb_reginfo Returns information about registers (names, numbers,
181 gdb_disassemble Returns the text of a disassembly of the entire
182 function. No longer used.
183 gdb_load_disassembly Loads the disassembly of a location into a
184 source window's textbox
185 gdb_eval Returns the value of a given expression
186 gdb_get_breakpoint_list Returns a list of all breakpoints
187 gdb_get_breakpoint_info Returns a list of info about a breakpoint
189 Tcl procedures that are hooked into GDB:
191 This is a list, albeit incomplete, of the "hook" functions that are installed
192 into GDB. The actual "hooks" are installed/initialized in
193 gdb/gdbtk/generic/gdbtk-hooks.c (and maybe one or two in gdbtk.c). The list
194 below is the Tcl side of the hook.
198 gdb_tcl_fputs Sends output into Tcl for the command window
199 gdb_tcl_query Pops up a query window
200 gdbtk_tcl_breakpoint Notifies Tcl of changes to a breakpoint
201 gdbtk_tcl_idle Notifies Tcl that debugged process is now idle
202 gdbtk_tcl_busy Notifies Tcl that debugged process is now running
206 Starting with GDB 5.0, GDB has had an event loop. Although largely unused right
207 now, with it came some useful "baggage", especially event notifications, even
208 though they, too, were largely incomplete. The list of events continues to grow,
209 and Insight and GDB often "share" overlapping events, but the list below is
210 complete (since there are only a few defined events). The source for these
211 events can be found in gdb/gdbtk/library/gdbevents.it[hb].
215 BreakpointEvent A breakpoint has been created/modified/deleted
216 TracepointEvent A tracepoint has been created/modified/deleted
217 SetVariableEvent User has issued a "set" command in Console
218 BusyEvent The debugger is "busy"
219 IdleEvent The debugger is "idle"
220 UpdateEvent The state of the target has changed (or the
221 GDB's view of the target has changed)
222 ArchChangedEvent The architecture of the system has changed
223 (this can happen when GDB defaults to using
224 some basic CPU and detects that a more elaborate
225 CPU is actually being used, e.g., SH5)
229 Insight installs a few GDB commands, which are available with the Console Window.
233 tk Executes the arguments in the Insight Tcl
235 view Displays the given linespec in the Source Window
240 During building, you may run into problems with finding Tcl, Tk or X11. Look
241 in gdb/Makefile, and fix TCL_CFLAGS, TCL, TK_CFLAGS, TK, and ENABLE_CLIBS as
244 If you one of the following messages when you run gdb:
246 Tcl_Init failed: can't find init.tcl; perhaps you need to
247 install Tcl or set your TCL_LIBRARY environment variable?
249 Tk_Init failed: can't find tk.tcl; perhaps you need to
250 install Tk or set your TK_LIBRARY environment variable?
252 then you haven't installed Tcl or TK properly. Fix the appropriate environment
253 variable to point at the {tcl tk}/library directory, and restart gdb.
260 o Using the GDB commands "up"/"down"/"frame" in Console Window
261 can cause GDB and Insight to get out of sync. If this happens,
262 simply use the Stack Window or the frame navigation buttons on
263 the Source Window's toolbar to resync the two.
265 o Not really a problem, but it might be nice to have a frame/stack
266 window that displays the last N words on the stack, along with
267 indications about which function owns a particular frame, how the
268 frame pointers are chained, and possibly the names of variables
269 alongside their frame slots.
271 host- or target-specific problems
273 o Windows is hosed. Tk8.3 in sources.redhat.com is not stable
274 on windows. Wanna help?
279 The first place to turn for help is the online help system. It may be old, but
280 it is still largely correct: it explains what everything does. If that fails,
281 search the mailing list archives for other users who may have had similar problems
282 or questions. The archives are online at
284 http://sources.redhat.com/insight/mailinglist.htm .
286 If all else fails, send a note to the mailing list, insight@sources.redhat.com,
287 where users and maintainers lurk. This is a very low traffic list, so don't
288 be afraid to join the list. Instructions for joining are on our homepage,
289 http://sources.redhat.com/insight .