* gdbtk.c (gdb_get_vars_command): Return static variables and
[deliverable/binutils-gdb.git] / gdb / README.GDBTK
CommitLineData
bf4e0fe7
FF
1 README.GDBTK
2 Written by Stu Grossman
3 Updated 9/26/95 by Fred Fish for gdb 4.15 release
8a19b35a 4 Updated 4/18/97 by Martin Hunt
6fd934a6
SG
5
6This file describes how to build, install, use and hack on GDBtk, a TK based
7GUI for GDB, the GNU debugger.
8
9Introduction
10============
11
3dcd429f 12GDBtk is a version of GDB that uses Tcl/Tk to implement a graphical
8a19b35a
MH
13user inter-face. It is a fully integrated GUI, not a separate
14front-end program. The interface consists of several seperate
3dcd429f
SS
15windows, which use standard elements like buttons, scrollbars, entry
16boxes and such to create a fairly easy to use interface. Each window
17has a distinct content and purpose, and can be enabled or disabled
18individually. The windows contain things like the current source
19file, a disassembly of the current function, text commands (for things
20that aren't accessible via a button), and so forth.
6fd934a6
SG
21
22Building and installing
23=======================
24
25Building GDBtk is very straightforward. The main difference is that you will
26need to use the `--enable-gdbtk' option when you run configure in the top level
8a19b35a 27directory. You will also need to install Tcl version 7.6 and Tk version 4.2.
6fd934a6 28
8a19b35a
MH
29On Unix machines, you will also need to have X11 (R4/R5/R6) installed
30(this is a prerequisite to installing Tk).
31
32For Windows, you can obtain Tcl/Tk from ftp://ftp.smli.com:/pub/tcl/win76p2.exe.
33There is a bug in this version of Tcl/tk that requires you to set the
34environmental variable TK_LIBRARY to where the tk library directory is installed.
35There is also a problem with the colors in images on 16-bit displays under
36Windows, so some icons may look strange.
6fd934a6
SG
37
38[See the GDB README file for more details on configure options and such.]
39
40For example:
41
42 host> cd gdbtk
43 host> ./configure --enable-gdbtk
44 host> make
45 host> make install
46
47Using GDBtk
48===========
49
50Just run it like you would a normal GDB (in fact, it's actually called `gdb').
51If everything goes well, you should have several windows pop up. To get going,
52hit the start button, and go exploring.
53
54If you want to use GDB in command line mode, just use the -nw option. Or, you
55can undefine the DISPLAY environment variable.
56
57In the current version, you can have up to 6 windows active at once. They are:
58
59 1) Command
60 2) Source
bf4e0fe7 61 3) Assembly
6fd934a6
SG
62 4) Register
63 5) Auto Command
64 6) Expression
65
66Most windows have a similar layout consisting of a menubar, display area,
67scrollbar, status box and window-specific buttons.
68
69The menubar contains the following items:
70
71 File - General file control. Also has window close and quit buttons.
72 Options - Window specific options.
73 Window - A menu of other windows that can be popped up or created.
74 Help - Mostly unimplemented.
75
76The status box indicates things like the current file and function, or the
77current PC and function depending upon the window.
78
79Command window:
80
81 This can be used to type commands at GDB (useful for when there isn't a
82 button for what you want to do).
83
84Source window:
85
86 This contains the current source file. The margin displays line
87 numbers, and has an indicator for lines that actually contain code (and
88 therefore can have breakpoints as well). When a breakpoint is set at
8a19b35a 89 that line, the indicator is replaced with a stop sign icon.
6fd934a6
SG
90
91 The buttons are:
92
93 Start - Put a breakpoint at main, and then run.
94 Stop - Stop the program (only active when program is running).
95 Step, Next, Cont[inue], Finish, Up, Down - Same as the corresponding
96 GDB command. (Finish runs the current subroutine until it's done.)
97 Bottom - Does a `frame 0' to put you at the innermost call frame.
98
99 There are also accelerators for various buttons (just type the letter
100 without any control/meta/alt/shift in the text frame):
101
102 s - Step
103 n - Next
104 c - Continue
105 f - Finish
106 u - Up
107 d - Down
108
109 The mouse can also be used to set and clear breakpoints when clicked
110 in the margin (on a breakpoint indicator).
111
bf4e0fe7 112Assembly window:
6fd934a6
SG
113
114 This displays a disassembly of the current function. It's buttons are
115 similar to those of the source window, except that it uses Stepi and
116 Nexti to run one instruction at a time instead of one statement at a
117 time. The accelerators and mouse actions are also similar.
118
119 Additionally, there is an option to enable mixed source and assembly.
120
121Register window:
122
123 This displays the registers. It may have to be resized to properly
124 display all the registers. The displayed registers can be selected
125 via the Options|Config menu item.
126
127Auto Command window:
128
129 Using this window, you can specify a command to be executed frequently.
130 The output will be automatically updated. Options|Accumulate-output
131 can be used to avoid clearing the window each time so that you can
132 accumulate a history.
133
134Expressions:
135
136 The expression window can be used to just calculate an expression, or
137 to watch the value of an expression (ala the `display' command), using
138 the Update button. The expression window will also pop up
139 automatically when an expression is double-clicked in the source window.
140
141Customizing GDBtk
142=================
143
8a19b35a
MH
144There are three primary ways to customize GDBtk. One is to modifiy the
145appropriate X resources. The other is to hack a ~/.gdbtkinit file. The last
146is to change the files in gdbtcl, which defines the most basic interface
147elements.
6fd934a6
SG
148
149X resources give you control over things like the choice of fonts, color
150schemes and some geometry info.
151
8a19b35a
MH
152For more serious customizations, you will probably need to hack your
153~/.gdbtkinit or gdbtcl files.
6fd934a6
SG
154
155X Resources
156===========
157
158 The class name for GDBtk is `Gdb', and it's appname is `gdb'. The top-
159level windows have instance names of `src', 'asm', 'reg', and 'cmd'. The main
160display area in each has the class `Text'. So, to change the font in all the
161main display areas, something like the following will do:
162
163 Gdb*Text*font: fixed
164
165To change the font in only the source window:
166
167 Gdb*src*Text*font: fixed
168
169To find out the names of the widgets do the following (in the command window):
170
171 tk info comm .*
172
173To get the list of resources (and their classes) for a given widget, do some-
174thing like:
175
176 tk .asm.text config
177
178This will return a list of lists, where each sublist looks something like this:
179
180 {-height height Height 24 25}
181
182The first item is the name of the config option used when creating the widget.
183The second item is the instance name of this resource, the third is the class
184name. The fourth item is the default value, and the last item is the current
185value.
186
187To get info about a single resource, add the config option name to the end of
188the previous command. Ie:
189
190 tk .asm.text config -font
191
192will return just the info about the font.
193
194To find out the class of a window, just do:
195
196 tk winfo class .asm.text
197
198Note that some things may be explicitly overridden by gdbtk.tcl. In
199particular, the `tk colormodel . monochrome' command should probably be
200disabled if you want to use color.
201
8a19b35a 202Hacking ~/.gdbtkinit and gdbtcl
6fd934a6
SG
203==================================
204~/.gdbtkinit is sourced at the end of gdbtk.tcl. Currently there is no good
8a19b35a 205doc on this. See gdbtcl/main.tcl for see what you can change.
6fd934a6 206
8a19b35a 207The GUI is primarily implemented by Tcl/Tk code which lives in gdbtcl and a
6fd934a6
SG
208C file called gdbtk.c. The Tcl/Tk code determines the look and feel, the
209layout, and the functions associated with all of the interface elements. The C
210code is mostly just glue between GDB internals and Tclland. In essence, all of
211the policy is implemented in Tcl/Tk, and is easily changed without recompiling.
212
213To make more serious changes to the interface, such as adding a new window or
8a19b35a 214changing the framework, you will have to hack the tcl code. This directory is
6fd934a6
SG
215installed in $(libdir) (probably /usr/local/lib/). But, you will probably want
216to hack on your own private copy before putting it up for the rest of the
8a19b35a
MH
217users. To find the GDB tcl code, GDB first checks for the environment variable
218GDBTK_LIBRARY. This can be a directory name or a list of directories seperated
219by colons (semicolons on Windows). GDB will check each directory in order until
220it finds "main.tcl". If GDBTK_LIBRARY is not set, GDB will look for
221"gdbtcl/main.tcl" in the current directory, and finally, it will try to find
222the tcl directory in the sources.
223
224Note that the old GDBTK_FILENAME environment variable is no longer used.
6fd934a6
SG
225
226Internally, GDBtk is basically GDB, linked with Tcl/Tk, and some glue code that
227interfaces GDB internals to Tclland. This means that GDBtk operates as a
228single program, not a front-end to GDB. All GDB commands, and a great deal of
229the target program state are accessible to the Tcl programmer. In addition,
230there are many callbacks from GDB to notify Tclland of important events.
231
232Here is a brief rundown of the GDB<=>Tcl interfaces:
233
234Tcl->GDB calls:
235 gdb_cmd - sends a text command to gdb. Returns the result
236 gdb_loc - takes PC, and returns a list consisting of a short file name,
237 the function name, a long file name, the line number and the
238 PC (in case you didn't supply it).
239 gdb_sourcelines - Takes a filename, and returns a list of lines that
240 contain code.
241 gdb_listfiles - Returns a list of all of the source files.
242 gdb_stop - Stops the target process.
243 gdb_regnames - Returns a list of all of the register names.
244 gdb_fetch_registers - Returns the contents of the specified registers.
245 gdb_changed_register_list - Returns a list of registers that have
246 changed since the last call.
247 gdb_disassemble - Takes a function or PC. Returns the text of a dis-
248 assembly of the entire function.
249 gdb_eval - Takes an expression. Returns it's value.
250 gdb_get_breakpoint_list - Does the obvious.
251 gdb_get_breakpoint_info - Takes a breakpoint number. Returns a list of
252 info about that breakpoint.
253
254GDB->Tcl callbacks:
255 gdb_tcl_fputs - Sends output into Tcl for the command window.
256 gdb_tcl_query - Pops up a query window.
257 gdbtk_tcl_breakpoint - Notifies Tcl of changes to a breakpoint.
258 gdbtk_tcl_idle - Notifies Tcl that debugged process is now idle.
259 gdbtk_tcl_busy - Notifies Tcl that debugged process is now running.
260
261For details, see the usage in gdbtk.tcl, or the definitions in gdbtk.c.
262
263Additionally, there is a new GDB command `tk', which can be used to poke at
264Tk/Tcl from the command window.
265
266Problems
267========
268
269During building, you may run into problems with finding Tcl, Tk or X11. Look
270in gdb/Makefile, and fix TCL_CFLAGS, TCL, TK_CFLAGS, TK, and ENABLE_CLIBS as
271appropriate.
272
273If you one of the following messages when you run gdb:
274
275 Tcl_Init failed: can't find init.tcl; perhaps you need to
276 install Tcl or set your TCL_LIBRARY environment variable?
277or
278 Tk_Init failed: can't find tk.tcl; perhaps you need to
279 install Tk or set your TK_LIBRARY environment variable?
280
281then you haven't installed Tcl or TK properly. Fix the appropriate environment
282variable to point at the {tcl tk}/library directory, and restart gdb.
283
284If you get the following:
285
286 /usr/local/lib/gdbtk.tcl:1: couldn't read file "/usr/local/lib/gdbtk.tcl": No such file or directory
287 Stack trace:
288 can't unset "auto_index": no such variable
289 while executing
290 "unset auto_index"
291
292then GDBtk wasn't installed properly. You can set the GDBTK_FILENAME
293environment variable to point at the gdbtk.tcl in your source directory. Note
294that the stack trace displayed here is not valid. If you actually get an error
295in gdbtk.tcl, the stack trace is useful to pinpoint the location.
bf4e0fe7
FF
296
297Known Bugs
298==========
299
300generic problems
301
302 o If you open an Assembly window before you have run the program, gdbtk
303 pops up a dialog box titled "Error in Tcl Script" with the contents
304 "Error: No function contains the specified address". Trying to then
305 do other things brings up a dialog box with the contents "Error:
306 can't read 'current_asm_label': no such variable.
307
308 Solution: Close Assembly window when there is no program running.
309
310 o If you open Registers window before you have run the program, gdbtk
311 pops up a dialog box titled "Error in Tcl Script" with the contents
312 "Error: No registers". Trying to then do other things, like use the
313 Start button to run the program, repeatedly produce the same dialog
314 box and the action is not performed.
315
316 Solution: Close Registers window when there is no program running.
317
318 o Expressions are sometimes not displayed correctly in the Expression
319 window. I.E. "argc" works, as does "*(argv+argc)" but not "argv[argc]".
320
321 Solution: None
4e327047 322 [ I believe this problem is fixed, but I have not tested it ]
bf4e0fe7
FF
323
324 o The Breakpoint window does not get automatically updated and changes
325 made in the window are not reflected back in the results from "info br".
326 I.E. the breakpoint count in the window is not updated at each hit and
327 enabling/disabling the breakpoint from the Breakpoint window has no effect.
328
329 Solution: Use the command interface to control breakpoints and don't
330 open a Breakpoint window.
331
332 o Sometimes while an expression window is active you get a dialog box
333 that complains "Error: invalide command name ".expr.e5.expr" for
334 example. The Tcl stack trace looks something like:
335
336 invalid command name ".expr.e5.expr"
337 while executing
338 "$e.expr get 0.0 end"
339 invoked from within
340 "set expr [$e.expr get 0.0 end]..."
341 (procedure "update_expr" line 17)
342 invoked from within
343 "update_expr $expr_num"
344 invoked from within
345 "if $expr_update_list($expr_num) {
346 update_expr $expr_num
347 .
348 .
349 .
350
351 Solution: None except close expression window and reopen it.
352
353 o If you select the "Down" button in either the Source or Assembly
354 window while in the bottom (innermost) frame, the error message that
355 results goes just to the command window and may be missed if the
356 command window is not open. This may also apply to other messages
357 as well. It should probably put up a notification box instead.
358
359 Solution: Keep Command window open to see error messages.
360
361 o Not really a problem, but it would be nice to have a backtrace
362 window.
363
364 Solution: Do bt in command window?
365
366 o Also not really a problem, but it might be nice to have a frame/stack
367 window that displays the last N words on the stack, along with
368 indications about which function owns a particular frame, how the
369 frame pointers are chained, and possibly the names of variables
370 alongside their frame slots.
371
372m68k-hp-hpux9.00:
373
374 o Attempting to use a Register window results in a Tcl Script Error
375 "Error: Erroneous arithmetic operation". The Tcl stack trace is:
376
377 while executing
378 "gdb_fetch_registers $reg_format $regnum"
379 invoked from within
380 "set regval [gdb_fetch_registers $reg_format $regnum]..."
381 ("foreach" body line 2)
382 invoked from within
383 "foreach regnum $reg_display_list {
384 set regval [gdb_fetch_registers $reg_format $regnum]
385 set regval [format "%-*s" $valwidth $regval]
386 $win del ..."
387 invoked from within
388 "if {$which == "all"} {
389 set lineindex 1
390 foreach regnum $reg_display_list {
391 set regval [gdb_fetch_registers $reg_format $regnum]
392 set regval [f ..."
393 (procedure "update_registers" line 16)
394 invoked from within
395 "update_registers all"
396 .
397 .
398 .
399
This page took 0.148746 seconds and 4 git commands to generate.