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