OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [gdb-5.3/] [gdb/] [doc/] [gdb.info-3] - Blame information for rev 1767

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1181 sfurman
This is gdb.info, produced by makeinfo version 4.1 from ./gdb.texinfo.
2
 
3
INFO-DIR-SECTION Programming & development tools.
4
START-INFO-DIR-ENTRY
5
* Gdb: (gdb).                     The GNU debugger.
6
END-INFO-DIR-ENTRY
7
 
8
   This file documents the GNU debugger GDB.
9
 
10
   This is the Ninth Edition, December 2001, of `Debugging with GDB:
11
the GNU Source-Level Debugger' for GDB Version 5.3.
12
 
13
   Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996,
14
1998,
15
1999, 2000, 2001, 2002 Free Software Foundation, Inc.
16
 
17
   Permission is granted to copy, distribute and/or modify this document
18
under the terms of the GNU Free Documentation License, Version 1.1 or
19
any later version published by the Free Software Foundation; with the
20
Invariant Sections being "Free Software" and "Free Software Needs Free
21
Documentation", with the Front-Cover Texts being "A GNU Manual," and
22
with the Back-Cover Texts as in (a) below.
23
 
24
   (a) The Free Software Foundation's Back-Cover Text is: "You have
25
freedom to copy and modify this GNU Manual, like GNU software.  Copies
26
published by the Free Software Foundation raise funds for GNU
27
development."
28
 
29

30
File: gdb.info,  Node: Disabling,  Next: Conditions,  Prev: Delete Breaks,  Up: Breakpoints
31
 
32
Disabling breakpoints
33
---------------------
34
 
35
   Rather than deleting a breakpoint, watchpoint, or catchpoint, you
36
might prefer to "disable" it.  This makes the breakpoint inoperative as
37
if it had been deleted, but remembers the information on the breakpoint
38
so that you can "enable" it again later.
39
 
40
   You disable and enable breakpoints, watchpoints, and catchpoints with
41
the `enable' and `disable' commands, optionally specifying one or more
42
breakpoint numbers as arguments.  Use `info break' or `info watch' to
43
print a list of breakpoints, watchpoints, and catchpoints if you do not
44
know which numbers to use.
45
 
46
   A breakpoint, watchpoint, or catchpoint can have any of four
47
different states of enablement:
48
 
49
   * Enabled.  The breakpoint stops your program.  A breakpoint set
50
     with the `break' command starts out in this state.
51
 
52
   * Disabled.  The breakpoint has no effect on your program.
53
 
54
   * Enabled once.  The breakpoint stops your program, but then becomes
55
     disabled.
56
 
57
   * Enabled for deletion.  The breakpoint stops your program, but
58
     immediately after it does so it is deleted permanently.  A
59
     breakpoint set with the `tbreak' command starts out in this state.
60
 
61
   You can use the following commands to enable or disable breakpoints,
62
watchpoints, and catchpoints:
63
 
64
`disable [breakpoints] [RANGE...]'
65
     Disable the specified breakpoints--or all breakpoints, if none are
66
     listed.  A disabled breakpoint has no effect but is not forgotten.
67
     All options such as ignore-counts, conditions and commands are
68
     remembered in case the breakpoint is enabled again later.  You may
69
     abbreviate `disable' as `dis'.
70
 
71
`enable [breakpoints] [RANGE...]'
72
     Enable the specified breakpoints (or all defined breakpoints).
73
     They become effective once again in stopping your program.
74
 
75
`enable [breakpoints] once RANGE...'
76
     Enable the specified breakpoints temporarily.  GDB disables any of
77
     these breakpoints immediately after stopping your program.
78
 
79
`enable [breakpoints] delete RANGE...'
80
     Enable the specified breakpoints to work once, then die.  GDB
81
     deletes any of these breakpoints as soon as your program stops
82
     there.
83
 
84
   Except for a breakpoint set with `tbreak' (*note Setting
85
breakpoints: Set Breaks.), breakpoints that you set are initially
86
enabled; subsequently, they become disabled or enabled only when you
87
use one of the commands above.  (The command `until' can set and delete
88
a breakpoint of its own, but it does not change the state of your other
89
breakpoints; see *Note Continuing and stepping: Continuing and
90
Stepping.)
91
 
92

93
File: gdb.info,  Node: Conditions,  Next: Break Commands,  Prev: Disabling,  Up: Breakpoints
94
 
95
Break conditions
96
----------------
97
 
98
   The simplest sort of breakpoint breaks every time your program
99
reaches a specified place.  You can also specify a "condition" for a
100
breakpoint.  A condition is just a Boolean expression in your
101
programming language (*note Expressions: Expressions.).  A breakpoint
102
with a condition evaluates the expression each time your program
103
reaches it, and your program stops only if the condition is _true_.
104
 
105
   This is the converse of using assertions for program validation; in
106
that situation, you want to stop when the assertion is violated--that
107
is, when the condition is false.  In C, if you want to test an
108
assertion expressed by the condition ASSERT, you should set the
109
condition `! ASSERT' on the appropriate breakpoint.
110
 
111
   Conditions are also accepted for watchpoints; you may not need them,
112
since a watchpoint is inspecting the value of an expression anyhow--but
113
it might be simpler, say, to just set a watchpoint on a variable name,
114
and specify a condition that tests whether the new value is an
115
interesting one.
116
 
117
   Break conditions can have side effects, and may even call functions
118
in your program.  This can be useful, for example, to activate functions
119
that log program progress, or to use your own print functions to format
120
special data structures. The effects are completely predictable unless
121
there is another enabled breakpoint at the same address.  (In that
122
case, GDB might see the other breakpoint first and stop your program
123
without checking the condition of this one.)  Note that breakpoint
124
commands are usually more convenient and flexible than break conditions
125
for the purpose of performing side effects when a breakpoint is reached
126
(*note Breakpoint command lists: Break Commands.).
127
 
128
   Break conditions can be specified when a breakpoint is set, by using
129
`if' in the arguments to the `break' command.  *Note Setting
130
breakpoints: Set Breaks.  They can also be changed at any time with the
131
`condition' command.
132
 
133
   You can also use the `if' keyword with the `watch' command.  The
134
`catch' command does not recognize the `if' keyword; `condition' is the
135
only way to impose a further condition on a catchpoint.
136
 
137
`condition BNUM EXPRESSION'
138
     Specify EXPRESSION as the break condition for breakpoint,
139
     watchpoint, or catchpoint number BNUM.  After you set a condition,
140
     breakpoint BNUM stops your program only if the value of EXPRESSION
141
     is true (nonzero, in C).  When you use `condition', GDB checks
142
     EXPRESSION immediately for syntactic correctness, and to determine
143
     whether symbols in it have referents in the context of your
144
     breakpoint.  If EXPRESSION uses symbols not referenced in the
145
     context of the breakpoint, GDB prints an error message:
146
 
147
          No symbol "foo" in current context.
148
 
149
     GDB does not actually evaluate EXPRESSION at the time the
150
     `condition' command (or a command that sets a breakpoint with a
151
     condition, like `break if ...') is given, however.  *Note
152
     Expressions: Expressions.
153
 
154
`condition BNUM'
155
     Remove the condition from breakpoint number BNUM.  It becomes an
156
     ordinary unconditional breakpoint.
157
 
158
   A special case of a breakpoint condition is to stop only when the
159
breakpoint has been reached a certain number of times.  This is so
160
useful that there is a special way to do it, using the "ignore count"
161
of the breakpoint.  Every breakpoint has an ignore count, which is an
162
integer.  Most of the time, the ignore count is zero, and therefore has
163
no effect.  But if your program reaches a breakpoint whose ignore count
164
is positive, then instead of stopping, it just decrements the ignore
165
count by one and continues.  As a result, if the ignore count value is
166
N, the breakpoint does not stop the next N times your program reaches
167
it.
168
 
169
`ignore BNUM COUNT'
170
     Set the ignore count of breakpoint number BNUM to COUNT.  The next
171
     COUNT times the breakpoint is reached, your program's execution
172
     does not stop; other than to decrement the ignore count, GDB takes
173
     no action.
174
 
175
     To make the breakpoint stop the next time it is reached, specify a
176
     count of zero.
177
 
178
     When you use `continue' to resume execution of your program from a
179
     breakpoint, you can specify an ignore count directly as an
180
     argument to `continue', rather than using `ignore'.  *Note
181
     Continuing and stepping: Continuing and Stepping.
182
 
183
     If a breakpoint has a positive ignore count and a condition, the
184
     condition is not checked.  Once the ignore count reaches zero, GDB
185
     resumes checking the condition.
186
 
187
     You could achieve the effect of the ignore count with a condition
188
     such as `$foo-- <= 0' using a debugger convenience variable that
189
     is decremented each time.  *Note Convenience variables:
190
     Convenience Vars.
191
 
192
   Ignore counts apply to breakpoints, watchpoints, and catchpoints.
193
 
194

195
File: gdb.info,  Node: Break Commands,  Next: Breakpoint Menus,  Prev: Conditions,  Up: Breakpoints
196
 
197
Breakpoint command lists
198
------------------------
199
 
200
   You can give any breakpoint (or watchpoint or catchpoint) a series of
201
commands to execute when your program stops due to that breakpoint.  For
202
example, you might want to print the values of certain expressions, or
203
enable other breakpoints.
204
 
205
`commands [BNUM]'
206
`... COMMAND-LIST ...'
207
`end'
208
     Specify a list of commands for breakpoint number BNUM.  The
209
     commands themselves appear on the following lines.  Type a line
210
     containing just `end' to terminate the commands.
211
 
212
     To remove all commands from a breakpoint, type `commands' and
213
     follow it immediately with `end'; that is, give no commands.
214
 
215
     With no BNUM argument, `commands' refers to the last breakpoint,
216
     watchpoint, or catchpoint set (not to the breakpoint most recently
217
     encountered).
218
 
219
   Pressing  as a means of repeating the last GDB command is
220
disabled within a COMMAND-LIST.
221
 
222
   You can use breakpoint commands to start your program up again.
223
Simply use the `continue' command, or `step', or any other command that
224
resumes execution.
225
 
226
   Any other commands in the command list, after a command that resumes
227
execution, are ignored.  This is because any time you resume execution
228
(even with a simple `next' or `step'), you may encounter another
229
breakpoint--which could have its own command list, leading to
230
ambiguities about which list to execute.
231
 
232
   If the first command you specify in a command list is `silent', the
233
usual message about stopping at a breakpoint is not printed.  This may
234
be desirable for breakpoints that are to print a specific message and
235
then continue.  If none of the remaining commands print anything, you
236
see no sign that the breakpoint was reached.  `silent' is meaningful
237
only at the beginning of a breakpoint command list.
238
 
239
   The commands `echo', `output', and `printf' allow you to print
240
precisely controlled output, and are often useful in silent
241
breakpoints.  *Note Commands for controlled output: Output.
242
 
243
   For example, here is how you could use breakpoint commands to print
244
the value of `x' at entry to `foo' whenever `x' is positive.
245
 
246
     break foo if x>0
247
     commands
248
     silent
249
     printf "x is %d\n",x
250
     cont
251
     end
252
 
253
   One application for breakpoint commands is to compensate for one bug
254
so you can test for another.  Put a breakpoint just after the erroneous
255
line of code, give it a condition to detect the case in which something
256
erroneous has been done, and give it commands to assign correct values
257
to any variables that need them.  End with the `continue' command so
258
that your program does not stop, and start with the `silent' command so
259
that no output is produced.  Here is an example:
260
 
261
     break 403
262
     commands
263
     silent
264
     set x = y + 4
265
     cont
266
     end
267
 
268

269
File: gdb.info,  Node: Breakpoint Menus,  Next: Error in Breakpoints,  Prev: Break Commands,  Up: Breakpoints
270
 
271
Breakpoint menus
272
----------------
273
 
274
   Some programming languages (notably C++) permit a single function
275
name to be defined several times, for application in different contexts.
276
This is called "overloading".  When a function name is overloaded,
277
`break FUNCTION' is not enough to tell GDB where you want a breakpoint.
278
If you realize this is a problem, you can use something like `break
279
FUNCTION(TYPES)' to specify which particular version of the function
280
you want.  Otherwise, GDB offers you a menu of numbered choices for
281
different possible breakpoints, and waits for your selection with the
282
prompt `>'.  The first two options are always `[0] cancel' and `[1]
283
all'.  Typing `1' sets a breakpoint at each definition of FUNCTION, and
284
typing `0' aborts the `break' command without setting any new
285
breakpoints.
286
 
287
   For example, the following session excerpt shows an attempt to set a
288
breakpoint at the overloaded symbol `String::after'.  We choose three
289
particular definitions of that function name:
290
 
291
     (gdb) b String::after
292
     [0] cancel
293
     [1] all
294
     [2] file:String.cc; line number:867
295
     [3] file:String.cc; line number:860
296
     [4] file:String.cc; line number:875
297
     [5] file:String.cc; line number:853
298
     [6] file:String.cc; line number:846
299
     [7] file:String.cc; line number:735
300
     > 2 4 6
301
     Breakpoint 1 at 0xb26c: file String.cc, line 867.
302
     Breakpoint 2 at 0xb344: file String.cc, line 875.
303
     Breakpoint 3 at 0xafcc: file String.cc, line 846.
304
     Multiple breakpoints were set.
305
     Use the "delete" command to delete unwanted
306
      breakpoints.
307
     (gdb)
308
 
309

310
File: gdb.info,  Node: Error in Breakpoints,  Prev: Breakpoint Menus,  Up: Breakpoints
311
 
312
"Cannot insert breakpoints"
313
---------------------------
314
 
315
   Under some operating systems, breakpoints cannot be used in a
316
program if any other process is running that program.  In this
317
situation, attempting to run or continue a program with a breakpoint
318
causes GDB to print an error message:
319
 
320
     Cannot insert breakpoints.
321
     The same program may be running in another process.
322
 
323
   When this happens, you have three ways to proceed:
324
 
325
  1. Remove or disable the breakpoints, then continue.
326
 
327
  2. Suspend GDB, and copy the file containing your program to a new
328
     name.  Resume GDB and use the `exec-file' command to specify that
329
     GDB should run your program under that name.  Then start your
330
     program again.
331
 
332
  3. Relink your program so that the text segment is nonsharable, using
333
     the linker option `-N'.  The operating system limitation may not
334
     apply to nonsharable executables.
335
 
336
   A similar message can be printed if you request too many active
337
hardware-assisted breakpoints and watchpoints:
338
 
339
     Stopped; cannot insert breakpoints.
340
     You may have requested too many hardware breakpoints and watchpoints.
341
 
342
This message is printed when you attempt to resume the program, since
343
only then GDB knows exactly how many hardware breakpoints and
344
watchpoints it needs to insert.
345
 
346
   When this message is printed, you need to disable or remove some of
347
the hardware-assisted breakpoints and watchpoints, and then continue.
348
 
349

350
File: gdb.info,  Node: Continuing and Stepping,  Next: Signals,  Prev: Breakpoints,  Up: Stopping
351
 
352
Continuing and stepping
353
=======================
354
 
355
   "Continuing" means resuming program execution until your program
356
completes normally.  In contrast, "stepping" means executing just one
357
more "step" of your program, where "step" may mean either one line of
358
source code, or one machine instruction (depending on what particular
359
command you use).  Either when continuing or when stepping, your
360
program may stop even sooner, due to a breakpoint or a signal.  (If it
361
stops due to a signal, you may want to use `handle', or use `signal 0'
362
to resume execution.  *Note Signals: Signals.)
363
 
364
`continue [IGNORE-COUNT]'
365
`c [IGNORE-COUNT]'
366
`fg [IGNORE-COUNT]'
367
     Resume program execution, at the address where your program last
368
     stopped; any breakpoints set at that address are bypassed.  The
369
     optional argument IGNORE-COUNT allows you to specify a further
370
     number of times to ignore a breakpoint at this location; its
371
     effect is like that of `ignore' (*note Break conditions:
372
     Conditions.).
373
 
374
     The argument IGNORE-COUNT is meaningful only when your program
375
     stopped due to a breakpoint.  At other times, the argument to
376
     `continue' is ignored.
377
 
378
     The synonyms `c' and `fg' (for "foreground", as the debugged
379
     program is deemed to be the foreground program) are provided
380
     purely for convenience, and have exactly the same behavior as
381
     `continue'.
382
 
383
   To resume execution at a different place, you can use `return'
384
(*note Returning from a function: Returning.) to go back to the calling
385
function; or `jump' (*note Continuing at a different address: Jumping.)
386
to go to an arbitrary location in your program.
387
 
388
   A typical technique for using stepping is to set a breakpoint (*note
389
Breakpoints; watchpoints; and catchpoints: Breakpoints.) at the
390
beginning of the function or the section of your program where a problem
391
is believed to lie, run your program until it stops at that breakpoint,
392
and then step through the suspect area, examining the variables that are
393
interesting, until you see the problem happen.
394
 
395
`step'
396
     Continue running your program until control reaches a different
397
     source line, then stop it and return control to GDB.  This command
398
     is abbreviated `s'.
399
 
400
          _Warning:_ If you use the `step' command while control is
401
          within a function that was compiled without debugging
402
          information, execution proceeds until control reaches a
403
          function that does have debugging information.  Likewise, it
404
          will not step into a function which is compiled without
405
          debugging information.  To step through functions without
406
          debugging information, use the `stepi' command, described
407
          below.
408
 
409
     The `step' command only stops at the first instruction of a source
410
     line.  This prevents the multiple stops that could otherwise occur
411
     in `switch' statements, `for' loops, etc.  `step' continues to
412
     stop if a function that has debugging information is called within
413
     the line.  In other words, `step' _steps inside_ any functions
414
     called within the line.
415
 
416
     Also, the `step' command only enters a function if there is line
417
     number information for the function.  Otherwise it acts like the
418
     `next' command.  This avoids problems when using `cc -gl' on MIPS
419
     machines.  Previously, `step' entered subroutines if there was any
420
     debugging information about the routine.
421
 
422
`step COUNT'
423
     Continue running as in `step', but do so COUNT times.  If a
424
     breakpoint is reached, or a signal not related to stepping occurs
425
     before COUNT steps, stepping stops right away.
426
 
427
`next [COUNT]'
428
     Continue to the next source line in the current (innermost) stack
429
     frame.  This is similar to `step', but function calls that appear
430
     within the line of code are executed without stopping.  Execution
431
     stops when control reaches a different line of code at the
432
     original stack level that was executing when you gave the `next'
433
     command.  This command is abbreviated `n'.
434
 
435
     An argument COUNT is a repeat count, as for `step'.
436
 
437
     The `next' command only stops at the first instruction of a source
438
     line.  This prevents multiple stops that could otherwise occur in
439
     `switch' statements, `for' loops, etc.
440
 
441
`set step-mode'
442
`set step-mode on'
443
     The `set step-mode on' command causes the `step' command to stop
444
     at the first instruction of a function which contains no debug line
445
     information rather than stepping over it.
446
 
447
     This is useful in cases where you may be interested in inspecting
448
     the machine instructions of a function which has no symbolic info
449
     and do not want GDB to automatically skip over this function.
450
 
451
`set step-mode off'
452
     Causes the `step' command to step over any functions which
453
     contains no debug information.  This is the default.
454
 
455
`finish'
456
     Continue running until just after function in the selected stack
457
     frame returns.  Print the returned value (if any).
458
 
459
     Contrast this with the `return' command (*note Returning from a
460
     function: Returning.).
461
 
462
`until'
463
`u'
464
     Continue running until a source line past the current line, in the
465
     current stack frame, is reached.  This command is used to avoid
466
     single stepping through a loop more than once.  It is like the
467
     `next' command, except that when `until' encounters a jump, it
468
     automatically continues execution until the program counter is
469
     greater than the address of the jump.
470
 
471
     This means that when you reach the end of a loop after single
472
     stepping though it, `until' makes your program continue execution
473
     until it exits the loop.  In contrast, a `next' command at the end
474
     of a loop simply steps back to the beginning of the loop, which
475
     forces you to step through the next iteration.
476
 
477
     `until' always stops your program if it attempts to exit the
478
     current stack frame.
479
 
480
     `until' may produce somewhat counterintuitive results if the order
481
     of machine code does not match the order of the source lines.  For
482
     example, in the following excerpt from a debugging session, the `f'
483
     (`frame') command shows that execution is stopped at line `206';
484
     yet when we use `until', we get to line `195':
485
 
486
          (gdb) f
487
          #0  main (argc=4, argv=0xf7fffae8) at m4.c:206
488
          206                 expand_input();
489
          (gdb) until
490
          195             for ( ; argc > 0; NEXTARG) {
491
 
492
     This happened because, for execution efficiency, the compiler had
493
     generated code for the loop closure test at the end, rather than
494
     the start, of the loop--even though the test in a C `for'-loop is
495
     written before the body of the loop.  The `until' command appeared
496
     to step back to the beginning of the loop when it advanced to this
497
     expression; however, it has not really gone to an earlier
498
     statement--not in terms of the actual machine code.
499
 
500
     `until' with no argument works by means of single instruction
501
     stepping, and hence is slower than `until' with an argument.
502
 
503
`until LOCATION'
504
`u LOCATION'
505
     Continue running your program until either the specified location
506
     is reached, or the current stack frame returns.  LOCATION is any of
507
     the forms of argument acceptable to `break' (*note Setting
508
     breakpoints: Set Breaks.).  This form of the command uses
509
     breakpoints, and hence is quicker than `until' without an argument.
510
 
511
`stepi'
512
`stepi ARG'
513
`si'
514
     Execute one machine instruction, then stop and return to the
515
     debugger.
516
 
517
     It is often useful to do `display/i $pc' when stepping by machine
518
     instructions.  This makes GDB automatically display the next
519
     instruction to be executed, each time your program stops.  *Note
520
     Automatic display: Auto Display.
521
 
522
     An argument is a repeat count, as in `step'.
523
 
524
`nexti'
525
`nexti ARG'
526
`ni'
527
     Execute one machine instruction, but if it is a function call,
528
     proceed until the function returns.
529
 
530
     An argument is a repeat count, as in `next'.
531
 
532

533
File: gdb.info,  Node: Signals,  Next: Thread Stops,  Prev: Continuing and Stepping,  Up: Stopping
534
 
535
Signals
536
=======
537
 
538
   A signal is an asynchronous event that can happen in a program.  The
539
operating system defines the possible kinds of signals, and gives each
540
kind a name and a number.  For example, in Unix `SIGINT' is the signal
541
a program gets when you type an interrupt character (often `C-c');
542
`SIGSEGV' is the signal a program gets from referencing a place in
543
memory far away from all the areas in use; `SIGALRM' occurs when the
544
alarm clock timer goes off (which happens only if your program has
545
requested an alarm).
546
 
547
   Some signals, including `SIGALRM', are a normal part of the
548
functioning of your program.  Others, such as `SIGSEGV', indicate
549
errors; these signals are "fatal" (they kill your program immediately)
550
if the program has not specified in advance some other way to handle
551
the signal.  `SIGINT' does not indicate an error in your program, but
552
it is normally fatal so it can carry out the purpose of the interrupt:
553
to kill the program.
554
 
555
   GDB has the ability to detect any occurrence of a signal in your
556
program.  You can tell GDB in advance what to do for each kind of
557
signal.
558
 
559
   Normally, GDB is set up to let the non-erroneous signals like
560
`SIGALRM' be silently passed to your program (so as not to interfere
561
with their role in the program's functioning) but to stop your program
562
immediately whenever an error signal happens.  You can change these
563
settings with the `handle' command.
564
 
565
`info signals'
566
`info handle'
567
     Print a table of all the kinds of signals and how GDB has been
568
     told to handle each one.  You can use this to see the signal
569
     numbers of all the defined types of signals.
570
 
571
     `info handle' is an alias for `info signals'.
572
 
573
`handle SIGNAL KEYWORDS...'
574
     Change the way GDB handles signal SIGNAL.  SIGNAL can be the
575
     number of a signal or its name (with or without the `SIG' at the
576
     beginning); a list of signal numbers of the form `LOW-HIGH'; or
577
     the word `all', meaning all the known signals.  The KEYWORDS say
578
     what change to make.
579
 
580
   The keywords allowed by the `handle' command can be abbreviated.
581
Their full names are:
582
 
583
`nostop'
584
     GDB should not stop your program when this signal happens.  It may
585
     still print a message telling you that the signal has come in.
586
 
587
`stop'
588
     GDB should stop your program when this signal happens.  This
589
     implies the `print' keyword as well.
590
 
591
`print'
592
     GDB should print a message when this signal happens.
593
 
594
`noprint'
595
     GDB should not mention the occurrence of the signal at all.  This
596
     implies the `nostop' keyword as well.
597
 
598
`pass'
599
`noignore'
600
     GDB should allow your program to see this signal; your program can
601
     handle the signal, or else it may terminate if the signal is fatal
602
     and not handled.  `pass' and `noignore' are synonyms.
603
 
604
`nopass'
605
`ignore'
606
     GDB should not allow your program to see this signal.  `nopass'
607
     and `ignore' are synonyms.
608
 
609
   When a signal stops your program, the signal is not visible to the
610
program until you continue.  Your program sees the signal then, if
611
`pass' is in effect for the signal in question _at that time_.  In
612
other words, after GDB reports a signal, you can use the `handle'
613
command with `pass' or `nopass' to control whether your program sees
614
that signal when you continue.
615
 
616
   The default is set to `nostop', `noprint', `pass' for non-erroneous
617
signals such as `SIGALRM', `SIGWINCH' and `SIGCHLD', and to `stop',
618
`print', `pass' for the erroneous signals.
619
 
620
   You can also use the `signal' command to prevent your program from
621
seeing a signal, or cause it to see a signal it normally would not see,
622
or to give it any signal at any time.  For example, if your program
623
stopped due to some sort of memory reference error, you might store
624
correct values into the erroneous variables and continue, hoping to see
625
more execution; but your program would probably terminate immediately as
626
a result of the fatal signal once it saw the signal.  To prevent this,
627
you can continue with `signal 0'.  *Note Giving your program a signal:
628
Signaling.
629
 
630

631
File: gdb.info,  Node: Thread Stops,  Prev: Signals,  Up: Stopping
632
 
633
Stopping and starting multi-thread programs
634
===========================================
635
 
636
   When your program has multiple threads (*note Debugging programs
637
with multiple threads: Threads.), you can choose whether to set
638
breakpoints on all threads, or on a particular thread.
639
 
640
`break LINESPEC thread THREADNO'
641
`break LINESPEC thread THREADNO if ...'
642
     LINESPEC specifies source lines; there are several ways of writing
643
     them, but the effect is always to specify some source line.
644
 
645
     Use the qualifier `thread THREADNO' with a breakpoint command to
646
     specify that you only want GDB to stop the program when a
647
     particular thread reaches this breakpoint.  THREADNO is one of the
648
     numeric thread identifiers assigned by GDB, shown in the first
649
     column of the `info threads' display.
650
 
651
     If you do not specify `thread THREADNO' when you set a breakpoint,
652
     the breakpoint applies to _all_ threads of your program.
653
 
654
     You can use the `thread' qualifier on conditional breakpoints as
655
     well; in this case, place `thread THREADNO' before the breakpoint
656
     condition, like this:
657
 
658
          (gdb) break frik.c:13 thread 28 if bartab > lim
659
 
660
   Whenever your program stops under GDB for any reason, _all_ threads
661
of execution stop, not just the current thread.  This allows you to
662
examine the overall state of the program, including switching between
663
threads, without worrying that things may change underfoot.
664
 
665
   Conversely, whenever you restart the program, _all_ threads start
666
executing.  _This is true even when single-stepping_ with commands like
667
`step' or `next'.
668
 
669
   In particular, GDB cannot single-step all threads in lockstep.
670
Since thread scheduling is up to your debugging target's operating
671
system (not controlled by GDB), other threads may execute more than one
672
statement while the current thread completes a single step.  Moreover,
673
in general other threads stop in the middle of a statement, rather than
674
at a clean statement boundary, when the program stops.
675
 
676
   You might even find your program stopped in another thread after
677
continuing or even single-stepping.  This happens whenever some other
678
thread runs into a breakpoint, a signal, or an exception before the
679
first thread completes whatever you requested.
680
 
681
   On some OSes, you can lock the OS scheduler and thus allow only a
682
single thread to run.
683
 
684
`set scheduler-locking MODE'
685
     Set the scheduler locking mode.  If it is `off', then there is no
686
     locking and any thread may run at any time.  If `on', then only the
687
     current thread may run when the inferior is resumed.  The `step'
688
     mode optimizes for single-stepping.  It stops other threads from
689
     "seizing the prompt" by preempting the current thread while you are
690
     stepping.  Other threads will only rarely (or never) get a chance
691
     to run when you step.  They are more likely to run when you `next'
692
     over a function call, and they are completely free to run when you
693
     use commands like `continue', `until', or `finish'.  However,
694
     unless another thread hits a breakpoint during its timeslice, they
695
     will never steal the GDB prompt away from the thread that you are
696
     debugging.
697
 
698
`show scheduler-locking'
699
     Display the current scheduler locking mode.
700
 
701

702
File: gdb.info,  Node: Stack,  Next: Source,  Prev: Stopping,  Up: Top
703
 
704
Examining the Stack
705
*******************
706
 
707
   When your program has stopped, the first thing you need to know is
708
where it stopped and how it got there.
709
 
710
   Each time your program performs a function call, information about
711
the call is generated.  That information includes the location of the
712
call in your program, the arguments of the call, and the local
713
variables of the function being called.  The information is saved in a
714
block of data called a "stack frame".  The stack frames are allocated
715
in a region of memory called the "call stack".
716
 
717
   When your program stops, the GDB commands for examining the stack
718
allow you to see all of this information.
719
 
720
   One of the stack frames is "selected" by GDB and many GDB commands
721
refer implicitly to the selected frame.  In particular, whenever you
722
ask GDB for the value of a variable in your program, the value is found
723
in the selected frame.  There are special GDB commands to select
724
whichever frame you are interested in. *Note Selecting a frame:
725
Selection.
726
 
727
   When your program stops, GDB automatically selects the currently
728
executing frame and describes it briefly, similar to the `frame'
729
command (*note Information about a frame: Frame Info.).
730
 
731
* Menu:
732
 
733
* Frames::                      Stack frames
734
* Backtrace::                   Backtraces
735
* Selection::                   Selecting a frame
736
* Frame Info::                  Information on a frame
737
 
738

739
File: gdb.info,  Node: Frames,  Next: Backtrace,  Up: Stack
740
 
741
Stack frames
742
============
743
 
744
   The call stack is divided up into contiguous pieces called "stack
745
frames", or "frames" for short; each frame is the data associated with
746
one call to one function.  The frame contains the arguments given to
747
the function, the function's local variables, and the address at which
748
the function is executing.
749
 
750
   When your program is started, the stack has only one frame, that of
751
the function `main'.  This is called the "initial" frame or the
752
"outermost" frame.  Each time a function is called, a new frame is
753
made.  Each time a function returns, the frame for that function
754
invocation is eliminated.  If a function is recursive, there can be
755
many frames for the same function.  The frame for the function in which
756
execution is actually occurring is called the "innermost" frame.  This
757
is the most recently created of all the stack frames that still exist.
758
 
759
   Inside your program, stack frames are identified by their addresses.
760
A stack frame consists of many bytes, each of which has its own
761
address; each kind of computer has a convention for choosing one byte
762
whose address serves as the address of the frame.  Usually this address
763
is kept in a register called the "frame pointer register" while
764
execution is going on in that frame.
765
 
766
   GDB assigns numbers to all existing stack frames, starting with zero
767
for the innermost frame, one for the frame that called it, and so on
768
upward.  These numbers do not really exist in your program; they are
769
assigned by GDB to give you a way of designating stack frames in GDB
770
commands.
771
 
772
   Some compilers provide a way to compile functions so that they
773
operate without stack frames.  (For example, the gcc option
774
     `-fomit-frame-pointer'
775
   generates functions without a frame.)  This is occasionally done
776
with heavily used library functions to save the frame setup time.  GDB
777
has limited facilities for dealing with these function invocations.  If
778
the innermost function invocation has no stack frame, GDB nevertheless
779
regards it as though it had a separate frame, which is numbered zero as
780
usual, allowing correct tracing of the function call chain.  However,
781
GDB has no provision for frameless functions elsewhere in the stack.
782
 
783
`frame ARGS'
784
     The `frame' command allows you to move from one stack frame to
785
     another, and to print the stack frame you select.  ARGS may be
786
     either the address of the frame or the stack frame number.
787
     Without an argument, `frame' prints the current stack frame.
788
 
789
`select-frame'
790
     The `select-frame' command allows you to move from one stack frame
791
     to another without printing the frame.  This is the silent version
792
     of `frame'.
793
 
794

795
File: gdb.info,  Node: Backtrace,  Next: Selection,  Prev: Frames,  Up: Stack
796
 
797
Backtraces
798
==========
799
 
800
   A backtrace is a summary of how your program got where it is.  It
801
shows one line per frame, for many frames, starting with the currently
802
executing frame (frame zero), followed by its caller (frame one), and
803
on up the stack.
804
 
805
`backtrace'
806
`bt'
807
     Print a backtrace of the entire stack: one line per frame for all
808
     frames in the stack.
809
 
810
     You can stop the backtrace at any time by typing the system
811
     interrupt character, normally `C-c'.
812
 
813
`backtrace N'
814
`bt N'
815
     Similar, but print only the innermost N frames.
816
 
817
`backtrace -N'
818
`bt -N'
819
     Similar, but print only the outermost N frames.
820
 
821
   The names `where' and `info stack' (abbreviated `info s') are
822
additional aliases for `backtrace'.
823
 
824
   Each line in the backtrace shows the frame number and the function
825
name.  The program counter value is also shown--unless you use `set
826
print address off'.  The backtrace also shows the source file name and
827
line number, as well as the arguments to the function.  The program
828
counter value is omitted if it is at the beginning of the code for that
829
line number.
830
 
831
   Here is an example of a backtrace.  It was made with the command `bt
832
3', so it shows the innermost three frames.
833
 
834
     #0  m4_traceon (obs=0x24eb0, argc=1, argv=0x2b8c8)
835
         at builtin.c:993
836
     #1  0x6e38 in expand_macro (sym=0x2b600) at macro.c:242
837
     #2  0x6840 in expand_token (obs=0x0, t=177664, td=0xf7fffb08)
838
         at macro.c:71
839
     (More stack frames follow...)
840
 
841
The display for frame zero does not begin with a program counter value,
842
indicating that your program has stopped at the beginning of the code
843
for line `993' of `builtin.c'.
844
 
845

846
File: gdb.info,  Node: Selection,  Next: Frame Info,  Prev: Backtrace,  Up: Stack
847
 
848
Selecting a frame
849
=================
850
 
851
   Most commands for examining the stack and other data in your program
852
work on whichever stack frame is selected at the moment.  Here are the
853
commands for selecting a stack frame; all of them finish by printing a
854
brief description of the stack frame just selected.
855
 
856
`frame N'
857
`f N'
858
     Select frame number N.  Recall that frame zero is the innermost
859
     (currently executing) frame, frame one is the frame that called the
860
     innermost one, and so on.  The highest-numbered frame is the one
861
     for `main'.
862
 
863
`frame ADDR'
864
`f ADDR'
865
     Select the frame at address ADDR.  This is useful mainly if the
866
     chaining of stack frames has been damaged by a bug, making it
867
     impossible for GDB to assign numbers properly to all frames.  In
868
     addition, this can be useful when your program has multiple stacks
869
     and switches between them.
870
 
871
     On the SPARC architecture, `frame' needs two addresses to select
872
     an arbitrary frame: a frame pointer and a stack pointer.
873
 
874
     On the MIPS and Alpha architecture, it needs two addresses: a stack
875
     pointer and a program counter.
876
 
877
     On the 29k architecture, it needs three addresses: a register stack
878
     pointer, a program counter, and a memory stack pointer.
879
 
880
`up N'
881
     Move N frames up the stack.  For positive numbers N, this advances
882
     toward the outermost frame, to higher frame numbers, to frames
883
     that have existed longer.  N defaults to one.
884
 
885
`down N'
886
     Move N frames down the stack.  For positive numbers N, this
887
     advances toward the innermost frame, to lower frame numbers, to
888
     frames that were created more recently.  N defaults to one.  You
889
     may abbreviate `down' as `do'.
890
 
891
   All of these commands end by printing two lines of output describing
892
the frame.  The first line shows the frame number, the function name,
893
the arguments, and the source file and line number of execution in that
894
frame.  The second line shows the text of that source line.
895
 
896
   For example:
897
 
898
     (gdb) up
899
     #1  0x22f0 in main (argc=1, argv=0xf7fffbf4, env=0xf7fffbfc)
900
         at env.c:10
901
     10              read_input_file (argv[i]);
902
 
903
   After such a printout, the `list' command with no arguments prints
904
ten lines centered on the point of execution in the frame.  *Note
905
Printing source lines: List.
906
 
907
`up-silently N'
908
`down-silently N'
909
     These two commands are variants of `up' and `down', respectively;
910
     they differ in that they do their work silently, without causing
911
     display of the new frame.  They are intended primarily for use in
912
     GDB command scripts, where the output might be unnecessary and
913
     distracting.
914
 
915

916
File: gdb.info,  Node: Frame Info,  Prev: Selection,  Up: Stack
917
 
918
Information about a frame
919
=========================
920
 
921
   There are several other commands to print information about the
922
selected stack frame.
923
 
924
`frame'
925
`f'
926
     When used without any argument, this command does not change which
927
     frame is selected, but prints a brief description of the currently
928
     selected stack frame.  It can be abbreviated `f'.  With an
929
     argument, this command is used to select a stack frame.  *Note
930
     Selecting a frame: Selection.
931
 
932
`info frame'
933
`info f'
934
     This command prints a verbose description of the selected stack
935
     frame, including:
936
 
937
        * the address of the frame
938
 
939
        * the address of the next frame down (called by this frame)
940
 
941
        * the address of the next frame up (caller of this frame)
942
 
943
        * the language in which the source code corresponding to this
944
          frame is written
945
 
946
        * the address of the frame's arguments
947
 
948
        * the address of the frame's local variables
949
 
950
        * the program counter saved in it (the address of execution in
951
          the caller frame)
952
 
953
        * which registers were saved in the frame
954
 
955
     The verbose description is useful when something has gone wrong
956
     that has made the stack format fail to fit the usual conventions.
957
 
958
`info frame ADDR'
959
`info f ADDR'
960
     Print a verbose description of the frame at address ADDR, without
961
     selecting that frame.  The selected frame remains unchanged by this
962
     command.  This requires the same kind of address (more than one
963
     for some architectures) that you specify in the `frame' command.
964
     *Note Selecting a frame: Selection.
965
 
966
`info args'
967
     Print the arguments of the selected frame, each on a separate line.
968
 
969
`info locals'
970
     Print the local variables of the selected frame, each on a separate
971
     line.  These are all variables (declared either static or
972
     automatic) accessible at the point of execution of the selected
973
     frame.
974
 
975
`info catch'
976
     Print a list of all the exception handlers that are active in the
977
     current stack frame at the current point of execution.  To see
978
     other exception handlers, visit the associated frame (using the
979
     `up', `down', or `frame' commands); then type `info catch'.  *Note
980
     Setting catchpoints: Set Catchpoints.
981
 
982

983
File: gdb.info,  Node: Source,  Next: Data,  Prev: Stack,  Up: Top
984
 
985
Examining Source Files
986
**********************
987
 
988
   GDB can print parts of your program's source, since the debugging
989
information recorded in the program tells GDB what source files were
990
used to build it.  When your program stops, GDB spontaneously prints
991
the line where it stopped.  Likewise, when you select a stack frame
992
(*note Selecting a frame: Selection.), GDB prints the line where
993
execution in that frame has stopped.  You can print other portions of
994
source files by explicit command.
995
 
996
   If you use GDB through its GNU Emacs interface, you may prefer to
997
use Emacs facilities to view source; see *Note Using GDB under GNU
998
Emacs: Emacs.
999
 
1000
* Menu:
1001
 
1002
* List::                        Printing source lines
1003
* Search::                      Searching source files
1004
* Source Path::                 Specifying source directories
1005
* Machine Code::                Source and machine code
1006
 
1007

1008
File: gdb.info,  Node: List,  Next: Search,  Up: Source
1009
 
1010
Printing source lines
1011
=====================
1012
 
1013
   To print lines from a source file, use the `list' command
1014
(abbreviated `l').  By default, ten lines are printed.  There are
1015
several ways to specify what part of the file you want to print.
1016
 
1017
   Here are the forms of the `list' command most commonly used:
1018
 
1019
`list LINENUM'
1020
     Print lines centered around line number LINENUM in the current
1021
     source file.
1022
 
1023
`list FUNCTION'
1024
     Print lines centered around the beginning of function FUNCTION.
1025
 
1026
`list'
1027
     Print more lines.  If the last lines printed were printed with a
1028
     `list' command, this prints lines following the last lines
1029
     printed; however, if the last line printed was a solitary line
1030
     printed as part of displaying a stack frame (*note Examining the
1031
     Stack: Stack.), this prints lines centered around that line.
1032
 
1033
`list -'
1034
     Print lines just before the lines last printed.
1035
 
1036
   By default, GDB prints ten source lines with any of these forms of
1037
the `list' command.  You can change this using `set listsize':
1038
 
1039
`set listsize COUNT'
1040
     Make the `list' command display COUNT source lines (unless the
1041
     `list' argument explicitly specifies some other number).
1042
 
1043
`show listsize'
1044
     Display the number of lines that `list' prints.
1045
 
1046
   Repeating a `list' command with  discards the argument, so it
1047
is equivalent to typing just `list'.  This is more useful than listing
1048
the same lines again.  An exception is made for an argument of `-';
1049
that argument is preserved in repetition so that each repetition moves
1050
up in the source file.
1051
 
1052
   In general, the `list' command expects you to supply zero, one or two
1053
"linespecs".  Linespecs specify source lines; there are several ways of
1054
writing them, but the effect is always to specify some source line.
1055
Here is a complete description of the possible arguments for `list':
1056
 
1057
`list LINESPEC'
1058
     Print lines centered around the line specified by LINESPEC.
1059
 
1060
`list FIRST,LAST'
1061
     Print lines from FIRST to LAST.  Both arguments are linespecs.
1062
 
1063
`list ,LAST'
1064
     Print lines ending with LAST.
1065
 
1066
`list FIRST,'
1067
     Print lines starting with FIRST.
1068
 
1069
`list +'
1070
     Print lines just after the lines last printed.
1071
 
1072
`list -'
1073
     Print lines just before the lines last printed.
1074
 
1075
`list'
1076
     As described in the preceding table.
1077
 
1078
   Here are the ways of specifying a single source line--all the kinds
1079
of linespec.
1080
 
1081
`NUMBER'
1082
     Specifies line NUMBER of the current source file.  When a `list'
1083
     command has two linespecs, this refers to the same source file as
1084
     the first linespec.
1085
 
1086
`+OFFSET'
1087
     Specifies the line OFFSET lines after the last line printed.  When
1088
     used as the second linespec in a `list' command that has two, this
1089
     specifies the line OFFSET lines down from the first linespec.
1090
 
1091
`-OFFSET'
1092
     Specifies the line OFFSET lines before the last line printed.
1093
 
1094
`FILENAME:NUMBER'
1095
     Specifies line NUMBER in the source file FILENAME.
1096
 
1097
`FUNCTION'
1098
     Specifies the line that begins the body of the function FUNCTION.
1099
     For example: in C, this is the line with the open brace.
1100
 
1101
`FILENAME:FUNCTION'
1102
     Specifies the line of the open-brace that begins the body of the
1103
     function FUNCTION in the file FILENAME.  You only need the file
1104
     name with a function name to avoid ambiguity when there are
1105
     identically named functions in different source files.
1106
 
1107
`*ADDRESS'
1108
     Specifies the line containing the program address ADDRESS.
1109
     ADDRESS may be any expression.
1110
 
1111

1112
File: gdb.info,  Node: Search,  Next: Source Path,  Prev: List,  Up: Source
1113
 
1114
Searching source files
1115
======================
1116
 
1117
   There are two commands for searching through the current source file
1118
for a regular expression.
1119
 
1120
`forward-search REGEXP'
1121
`search REGEXP'
1122
     The command `forward-search REGEXP' checks each line, starting
1123
     with the one following the last line listed, for a match for
1124
     REGEXP.  It lists the line that is found.  You can use the synonym
1125
     `search REGEXP' or abbreviate the command name as `fo'.
1126
 
1127
`reverse-search REGEXP'
1128
     The command `reverse-search REGEXP' checks each line, starting
1129
     with the one before the last line listed and going backward, for a
1130
     match for REGEXP.  It lists the line that is found.  You can
1131
     abbreviate this command as `rev'.
1132
 
1133

1134
File: gdb.info,  Node: Source Path,  Next: Machine Code,  Prev: Search,  Up: Source
1135
 
1136
Specifying source directories
1137
=============================
1138
 
1139
   Executable programs sometimes do not record the directories of the
1140
source files from which they were compiled, just the names.  Even when
1141
they do, the directories could be moved between the compilation and
1142
your debugging session.  GDB has a list of directories to search for
1143
source files; this is called the "source path".  Each time GDB wants a
1144
source file, it tries all the directories in the list, in the order
1145
they are present in the list, until it finds a file with the desired
1146
name.  Note that the executable search path is _not_ used for this
1147
purpose.  Neither is the current working directory, unless it happens
1148
to be in the source path.
1149
 
1150
   If GDB cannot find a source file in the source path, and the object
1151
program records a directory, GDB tries that directory too.  If the
1152
source path is empty, and there is no record of the compilation
1153
directory, GDB looks in the current directory as a last resort.
1154
 
1155
   Whenever you reset or rearrange the source path, GDB clears out any
1156
information it has cached about where source files are found and where
1157
each line is in the file.
1158
 
1159
   When you start GDB, its source path includes only `cdir' and `cwd',
1160
in that order.  To add other directories, use the `directory' command.
1161
 
1162
`directory DIRNAME ...'
1163
 
1164
`dir DIRNAME ...'
1165
     Add directory DIRNAME to the front of the source path.  Several
1166
     directory names may be given to this command, separated by `:'
1167
     (`;' on MS-DOS and MS-Windows, where `:' usually appears as part
1168
     of absolute file names) or whitespace.  You may specify a
1169
     directory that is already in the source path; this moves it
1170
     forward, so GDB searches it sooner.
1171
 
1172
     You can use the string `$cdir' to refer to the compilation
1173
     directory (if one is recorded), and `$cwd' to refer to the current
1174
     working directory.  `$cwd' is not the same as `.'--the former
1175
     tracks the current working directory as it changes during your GDB
1176
     session, while the latter is immediately expanded to the current
1177
     directory at the time you add an entry to the source path.
1178
 
1179
`directory'
1180
     Reset the source path to empty again.  This requires confirmation.
1181
 
1182
`show directories'
1183
     Print the source path: show which directories it contains.
1184
 
1185
   If your source path is cluttered with directories that are no longer
1186
of interest, GDB may sometimes cause confusion by finding the wrong
1187
versions of source.  You can correct the situation as follows:
1188
 
1189
  1. Use `directory' with no argument to reset the source path to empty.
1190
 
1191
  2. Use `directory' with suitable arguments to reinstall the
1192
     directories you want in the source path.  You can add all the
1193
     directories in one command.
1194
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.