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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [gdb-5.3/] [gdb/] [doc/] [gdb.info-7] - Blame information for rev 1775

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: Assignment,  Next: Jumping,  Up: Altering
31
 
32
Assignment to variables
33
=======================
34
 
35
   To alter the value of a variable, evaluate an assignment expression.
36
*Note Expressions: Expressions.  For example,
37
 
38
     print x=4
39
 
40
stores the value 4 into the variable `x', and then prints the value of
41
the assignment expression (which is 4).  *Note Using GDB with Different
42
Languages: Languages, for more information on operators in supported
43
languages.
44
 
45
   If you are not interested in seeing the value of the assignment, use
46
the `set' command instead of the `print' command.  `set' is really the
47
same as `print' except that the expression's value is not printed and
48
is not put in the value history (*note Value history: Value History.).
49
The expression is evaluated only for its effects.
50
 
51
   If the beginning of the argument string of the `set' command appears
52
identical to a `set' subcommand, use the `set variable' command instead
53
of just `set'.  This command is identical to `set' except for its lack
54
of subcommands.  For example, if your program has a variable `width',
55
you get an error if you try to set a new value with just `set
56
width=13', because GDB has the command `set width':
57
 
58
     (gdb) whatis width
59
     type = double
60
     (gdb) p width
61
     $4 = 13
62
     (gdb) set width=47
63
     Invalid syntax in expression.
64
 
65
The invalid expression, of course, is `=47'.  In order to actually set
66
the program's variable `width', use
67
 
68
     (gdb) set var width=47
69
 
70
   Because the `set' command has many subcommands that can conflict
71
with the names of program variables, it is a good idea to use the `set
72
variable' command instead of just `set'.  For example, if your program
73
has a variable `g', you run into problems if you try to set a new value
74
with just `set g=4', because GDB has the command `set gnutarget',
75
abbreviated `set g':
76
 
77
     (gdb) whatis g
78
     type = double
79
     (gdb) p g
80
     $1 = 1
81
     (gdb) set g=4
82
     (gdb) p g
83
     $2 = 1
84
     (gdb) r
85
     The program being debugged has been started already.
86
     Start it from the beginning? (y or n) y
87
     Starting program: /home/smith/cc_progs/a.out
88
     "/home/smith/cc_progs/a.out": can't open to read symbols:
89
                                      Invalid bfd target.
90
     (gdb) show g
91
     The current BFD target is "=4".
92
 
93
The program variable `g' did not change, and you silently set the
94
`gnutarget' to an invalid value.  In order to set the variable `g', use
95
 
96
     (gdb) set var g=4
97
 
98
   GDB allows more implicit conversions in assignments than C; you can
99
freely store an integer value into a pointer variable or vice versa,
100
and you can convert any structure to any other structure that is the
101
same length or shorter.
102
 
103
   To store values into arbitrary places in memory, use the `{...}'
104
construct to generate a value of specified type at a specified address
105
(*note Expressions: Expressions.).  For example, `{int}0x83040' refers
106
to memory location `0x83040' as an integer (which implies a certain size
107
and representation in memory), and
108
 
109
     set {int}0x83040 = 4
110
 
111
stores the value 4 into that memory location.
112
 
113

114
File: gdb.info,  Node: Jumping,  Next: Signaling,  Prev: Assignment,  Up: Altering
115
 
116
Continuing at a different address
117
=================================
118
 
119
   Ordinarily, when you continue your program, you do so at the place
120
where it stopped, with the `continue' command.  You can instead
121
continue at an address of your own choosing, with the following
122
commands:
123
 
124
`jump LINESPEC'
125
     Resume execution at line LINESPEC.  Execution stops again
126
     immediately if there is a breakpoint there.  *Note Printing source
127
     lines: List, for a description of the different forms of LINESPEC.
128
     It is common practice to use the `tbreak' command in conjunction
129
     with `jump'.  *Note Setting breakpoints: Set Breaks.
130
 
131
     The `jump' command does not change the current stack frame, or the
132
     stack pointer, or the contents of any memory location or any
133
     register other than the program counter.  If line LINESPEC is in a
134
     different function from the one currently executing, the results
135
     may be bizarre if the two functions expect different patterns of
136
     arguments or of local variables.  For this reason, the `jump'
137
     command requests confirmation if the specified line is not in the
138
     function currently executing.  However, even bizarre results are
139
     predictable if you are well acquainted with the machine-language
140
     code of your program.
141
 
142
`jump *ADDRESS'
143
     Resume execution at the instruction at address ADDRESS.
144
 
145
   On many systems, you can get much the same effect as the `jump'
146
command by storing a new value into the register `$pc'.  The difference
147
is that this does not start your program running; it only changes the
148
address of where it _will_ run when you continue.  For example,
149
 
150
     set $pc = 0x485
151
 
152
makes the next `continue' command or stepping command execute at
153
address `0x485', rather than at the address where your program stopped.
154
*Note Continuing and stepping: Continuing and Stepping.
155
 
156
   The most common occasion to use the `jump' command is to back
157
up--perhaps with more breakpoints set--over a portion of a program that
158
has already executed, in order to examine its execution in more detail.
159
 
160

161
File: gdb.info,  Node: Signaling,  Next: Returning,  Prev: Jumping,  Up: Altering
162
 
163
Giving your program a signal
164
============================
165
 
166
`signal SIGNAL'
167
     Resume execution where your program stopped, but immediately give
168
     it the signal SIGNAL.  SIGNAL can be the name or the number of a
169
     signal.  For example, on many systems `signal 2' and `signal
170
     SIGINT' are both ways of sending an interrupt signal.
171
 
172
     Alternatively, if SIGNAL is zero, continue execution without
173
     giving a signal.  This is useful when your program stopped on
174
     account of a signal and would ordinary see the signal when resumed
175
     with the `continue' command; `signal 0' causes it to resume
176
     without a signal.
177
 
178
     `signal' does not repeat when you press  a second time after
179
     executing the command.
180
 
181
   Invoking the `signal' command is not the same as invoking the `kill'
182
utility from the shell.  Sending a signal with `kill' causes GDB to
183
decide what to do with the signal depending on the signal handling
184
tables (*note Signals::).  The `signal' command passes the signal
185
directly to your program.
186
 
187

188
File: gdb.info,  Node: Returning,  Next: Calling,  Prev: Signaling,  Up: Altering
189
 
190
Returning from a function
191
=========================
192
 
193
`return'
194
`return EXPRESSION'
195
     You can cancel execution of a function call with the `return'
196
     command.  If you give an EXPRESSION argument, its value is used as
197
     the function's return value.
198
 
199
   When you use `return', GDB discards the selected stack frame (and
200
all frames within it).  You can think of this as making the discarded
201
frame return prematurely.  If you wish to specify a value to be
202
returned, give that value as the argument to `return'.
203
 
204
   This pops the selected stack frame (*note Selecting a frame:
205
Selection.), and any other frames inside of it, leaving its caller as
206
the innermost remaining frame.  That frame becomes selected.  The
207
specified value is stored in the registers used for returning values of
208
functions.
209
 
210
   The `return' command does not resume execution; it leaves the
211
program stopped in the state that would exist if the function had just
212
returned.  In contrast, the `finish' command (*note Continuing and
213
stepping: Continuing and Stepping.) resumes execution until the
214
selected stack frame returns naturally.
215
 
216

217
File: gdb.info,  Node: Calling,  Next: Patching,  Prev: Returning,  Up: Altering
218
 
219
Calling program functions
220
=========================
221
 
222
`call EXPR'
223
     Evaluate the expression EXPR without displaying `void' returned
224
     values.
225
 
226
   You can use this variant of the `print' command if you want to
227
execute a function from your program, but without cluttering the output
228
with `void' returned values.  If the result is not void, it is printed
229
and saved in the value history.
230
 
231

232
File: gdb.info,  Node: Patching,  Prev: Calling,  Up: Altering
233
 
234
Patching programs
235
=================
236
 
237
   By default, GDB opens the file containing your program's executable
238
code (or the corefile) read-only.  This prevents accidental alterations
239
to machine code; but it also prevents you from intentionally patching
240
your program's binary.
241
 
242
   If you'd like to be able to patch the binary, you can specify that
243
explicitly with the `set write' command.  For example, you might want
244
to turn on internal debugging flags, or even to make emergency repairs.
245
 
246
`set write on'
247
`set write off'
248
     If you specify `set write on', GDB opens executable and core files
249
     for both reading and writing; if you specify `set write off' (the
250
     default), GDB opens them read-only.
251
 
252
     If you have already loaded a file, you must load it again (using
253
     the `exec-file' or `core-file' command) after changing `set
254
     write', for your new setting to take effect.
255
 
256
`show write'
257
     Display whether executable files and core files are opened for
258
     writing as well as reading.
259
 
260

261
File: gdb.info,  Node: GDB Files,  Next: Targets,  Prev: Altering,  Up: Top
262
 
263
GDB Files
264
*********
265
 
266
   GDB needs to know the file name of the program to be debugged, both
267
in order to read its symbol table and in order to start your program.
268
To debug a core dump of a previous run, you must also tell GDB the name
269
of the core dump file.
270
 
271
* Menu:
272
 
273
* Files::                       Commands to specify files
274
* Symbol Errors::               Errors reading symbol files
275
 
276

277
File: gdb.info,  Node: Files,  Next: Symbol Errors,  Up: GDB Files
278
 
279
Commands to specify files
280
=========================
281
 
282
   You may want to specify executable and core dump file names.  The
283
usual way to do this is at start-up time, using the arguments to GDB's
284
start-up commands (*note Getting In and Out of GDB: Invocation.).
285
 
286
   Occasionally it is necessary to change to a different file during a
287
GDB session.  Or you may run GDB and forget to specify a file you want
288
to use.  In these situations the GDB commands to specify new files are
289
useful.
290
 
291
`file FILENAME'
292
     Use FILENAME as the program to be debugged.  It is read for its
293
     symbols and for the contents of pure memory.  It is also the
294
     program executed when you use the `run' command.  If you do not
295
     specify a directory and the file is not found in the GDB working
296
     directory, GDB uses the environment variable `PATH' as a list of
297
     directories to search, just as the shell does when looking for a
298
     program to run.  You can change the value of this variable, for
299
     both GDB and your program, using the `path' command.
300
 
301
     On systems with memory-mapped files, an auxiliary file named
302
     `FILENAME.syms' may hold symbol table information for FILENAME.
303
     If so, GDB maps in the symbol table from `FILENAME.syms', starting
304
     up more quickly.  See the descriptions of the file options
305
     `-mapped' and `-readnow' (available on the command line, and with
306
     the commands `file', `symbol-file', or `add-symbol-file',
307
     described below), for more information.
308
 
309
`file'
310
     `file' with no argument makes GDB discard any information it has
311
     on both executable file and the symbol table.
312
 
313
`exec-file [ FILENAME ]'
314
     Specify that the program to be run (but not the symbol table) is
315
     found in FILENAME.  GDB searches the environment variable `PATH'
316
     if necessary to locate your program.  Omitting FILENAME means to
317
     discard information on the executable file.
318
 
319
`symbol-file [ FILENAME ]'
320
     Read symbol table information from file FILENAME.  `PATH' is
321
     searched when necessary.  Use the `file' command to get both symbol
322
     table and program to run from the same file.
323
 
324
     `symbol-file' with no argument clears out GDB information on your
325
     program's symbol table.
326
 
327
     The `symbol-file' command causes GDB to forget the contents of its
328
     convenience variables, the value history, and all breakpoints and
329
     auto-display expressions.  This is because they may contain
330
     pointers to the internal data recording symbols and data types,
331
     which are part of the old symbol table data being discarded inside
332
     GDB.
333
 
334
     `symbol-file' does not repeat if you press  again after
335
     executing it once.
336
 
337
     When GDB is configured for a particular environment, it
338
     understands debugging information in whatever format is the
339
     standard generated for that environment; you may use either a GNU
340
     compiler, or other compilers that adhere to the local conventions.
341
     Best results are usually obtained from GNU compilers; for example,
342
     using `gcc' you can generate debugging information for optimized
343
     code.
344
 
345
     For most kinds of object files, with the exception of old SVR3
346
     systems using COFF, the `symbol-file' command does not normally
347
     read the symbol table in full right away.  Instead, it scans the
348
     symbol table quickly to find which source files and which symbols
349
     are present.  The details are read later, one source file at a
350
     time, as they are needed.
351
 
352
     The purpose of this two-stage reading strategy is to make GDB
353
     start up faster.  For the most part, it is invisible except for
354
     occasional pauses while the symbol table details for a particular
355
     source file are being read.  (The `set verbose' command can turn
356
     these pauses into messages if desired.  *Note Optional warnings
357
     and messages: Messages/Warnings.)
358
 
359
     We have not implemented the two-stage strategy for COFF yet.  When
360
     the symbol table is stored in COFF format, `symbol-file' reads the
361
     symbol table data in full right away.  Note that "stabs-in-COFF"
362
     still does the two-stage strategy, since the debug info is actually
363
     in stabs format.
364
 
365
`symbol-file FILENAME [ -readnow ] [ -mapped ]'
366
`file FILENAME [ -readnow ] [ -mapped ]'
367
     You can override the GDB two-stage strategy for reading symbol
368
     tables by using the `-readnow' option with any of the commands that
369
     load symbol table information, if you want to be sure GDB has the
370
     entire symbol table available.
371
 
372
     If memory-mapped files are available on your system through the
373
     `mmap' system call, you can use another option, `-mapped', to
374
     cause GDB to write the symbols for your program into a reusable
375
     file.  Future GDB debugging sessions map in symbol information
376
     from this auxiliary symbol file (if the program has not changed),
377
     rather than spending time reading the symbol table from the
378
     executable program.  Using the `-mapped' option has the same
379
     effect as starting GDB with the `-mapped' command-line option.
380
 
381
     You can use both options together, to make sure the auxiliary
382
     symbol file has all the symbol information for your program.
383
 
384
     The auxiliary symbol file for a program called MYPROG is called
385
     `MYPROG.syms'.  Once this file exists (so long as it is newer than
386
     the corresponding executable), GDB always attempts to use it when
387
     you debug MYPROG; no special options or commands are needed.
388
 
389
     The `.syms' file is specific to the host machine where you run
390
     GDB.  It holds an exact image of the internal GDB symbol table.
391
     It cannot be shared across multiple host platforms.
392
 
393
`core-file [ FILENAME ]'
394
     Specify the whereabouts of a core dump file to be used as the
395
     "contents of memory".  Traditionally, core files contain only some
396
     parts of the address space of the process that generated them; GDB
397
     can access the executable file itself for other parts.
398
 
399
     `core-file' with no argument specifies that no core file is to be
400
     used.
401
 
402
     Note that the core file is ignored when your program is actually
403
     running under GDB.  So, if you have been running your program and
404
     you wish to debug a core file instead, you must kill the
405
     subprocess in which the program is running.  To do this, use the
406
     `kill' command (*note Killing the child process: Kill Process.).
407
 
408
`add-symbol-file FILENAME ADDRESS'
409
`add-symbol-file FILENAME ADDRESS [ -readnow ] [ -mapped ]'
410
`add-symbol-file FILENAME -sSECTION ADDRESS ...'
411
     The `add-symbol-file' command reads additional symbol table
412
     information from the file FILENAME.  You would use this command
413
     when FILENAME has been dynamically loaded (by some other means)
414
     into the program that is running.  ADDRESS should be the memory
415
     address at which the file has been loaded; GDB cannot figure this
416
     out for itself.  You can additionally specify an arbitrary number
417
     of `-sSECTION ADDRESS' pairs, to give an explicit section name and
418
     base address for that section.  You can specify any ADDRESS as an
419
     expression.
420
 
421
     The symbol table of the file FILENAME is added to the symbol table
422
     originally read with the `symbol-file' command.  You can use the
423
     `add-symbol-file' command any number of times; the new symbol data
424
     thus read keeps adding to the old.  To discard all old symbol data
425
     instead, use the `symbol-file' command without any arguments.
426
 
427
     Although FILENAME is typically a shared library file, an
428
     executable file, or some other object file which has been fully
429
     relocated for loading into a process, you can also load symbolic
430
     information from relocatable `.o' files, as long as:
431
 
432
        * the file's symbolic information refers only to linker symbols
433
          defined in that file, not to symbols defined by other object
434
          files,
435
 
436
        * every section the file's symbolic information refers to has
437
          actually been loaded into the inferior, as it appears in the
438
          file, and
439
 
440
        * you can determine the address at which every section was
441
          loaded, and provide these to the `add-symbol-file' command.
442
 
443
     Some embedded operating systems, like Sun Chorus and VxWorks, can
444
     load relocatable files into an already running program; such
445
     systems typically make the requirements above easy to meet.
446
     However, it's important to recognize that many native systems use
447
     complex link procedures (`.linkonce' section factoring and C++
448
     constructor table assembly, for example) that make the
449
     requirements difficult to meet.  In general, one cannot assume
450
     that using `add-symbol-file' to read a relocatable object file's
451
     symbolic information will have the same effect as linking the
452
     relocatable object file into the program in the normal way.
453
 
454
     `add-symbol-file' does not repeat if you press  after using
455
     it.
456
 
457
     You can use the `-mapped' and `-readnow' options just as with the
458
     `symbol-file' command, to change how GDB manages the symbol table
459
     information for FILENAME.
460
 
461
`add-shared-symbol-file'
462
     The `add-shared-symbol-file' command can be used only under
463
     Harris' CXUX operating system for the Motorola 88k.  GDB
464
     automatically looks for shared libraries, however if GDB does not
465
     find yours, you can run `add-shared-symbol-file'.  It takes no
466
     arguments.
467
 
468
`section'
469
     The `section' command changes the base address of section SECTION
470
     of the exec file to ADDR.  This can be used if the exec file does
471
     not contain section addresses, (such as in the a.out format), or
472
     when the addresses specified in the file itself are wrong.  Each
473
     section must be changed separately.  The `info files' command,
474
     described below, lists all the sections and their addresses.
475
 
476
`info files'
477
`info target'
478
     `info files' and `info target' are synonymous; both print the
479
     current target (*note Specifying a Debugging Target: Targets.),
480
     including the names of the executable and core dump files
481
     currently in use by GDB, and the files from which symbols were
482
     loaded.  The command `help target' lists all possible targets
483
     rather than current ones.
484
 
485
`maint info sections'
486
     Another command that can give you extra information about program
487
     sections is `maint info sections'.  In addition to the section
488
     information displayed by `info files', this command displays the
489
     flags and file offset of each section in the executable and core
490
     dump files.  In addition, `maint info sections' provides the
491
     following command options (which may be arbitrarily combined):
492
 
493
    `ALLOBJ'
494
          Display sections for all loaded object files, including
495
          shared libraries.
496
 
497
    `SECTIONS'
498
          Display info only for named SECTIONS.
499
 
500
    `SECTION-FLAGS'
501
          Display info only for sections for which SECTION-FLAGS are
502
          true.  The section flags that GDB currently knows about are:
503
         `ALLOC'
504
               Section will have space allocated in the process when
505
               loaded.  Set for all sections except those containing
506
               debug information.
507
 
508
         `LOAD'
509
               Section will be loaded from the file into the child
510
               process memory.  Set for pre-initialized code and data,
511
               clear for `.bss' sections.
512
 
513
         `RELOC'
514
               Section needs to be relocated before loading.
515
 
516
         `READONLY'
517
               Section cannot be modified by the child process.
518
 
519
         `CODE'
520
               Section contains executable code only.
521
 
522
         `DATA'
523
               Section contains data only (no executable code).
524
 
525
         `ROM'
526
               Section will reside in ROM.
527
 
528
         `CONSTRUCTOR'
529
               Section contains data for constructor/destructor lists.
530
 
531
         `HAS_CONTENTS'
532
               Section is not empty.
533
 
534
         `NEVER_LOAD'
535
               An instruction to the linker to not output the section.
536
 
537
         `COFF_SHARED_LIBRARY'
538
               A notification to the linker that the section contains
539
               COFF shared library information.
540
 
541
         `IS_COMMON'
542
               Section contains common symbols.
543
 
544
`set trust-readonly-sections on'
545
     Tell GDB that readonly sections in your object file really are
546
     read-only (i.e. that their contents will not change).  In that
547
     case, GDB can fetch values from these sections out of the object
548
     file, rather than from the target program.  For some targets
549
     (notably embedded ones), this can be a significant enhancement to
550
     debugging performance.
551
 
552
     The default is off.
553
 
554
`set trust-readonly-sections off'
555
     Tell GDB not to trust readonly sections.  This means that the
556
     contents of the section might change while the program is running,
557
     and must therefore be fetched from the target when needed.
558
 
559
   All file-specifying commands allow both absolute and relative file
560
names as arguments.  GDB always converts the file name to an absolute
561
file name and remembers it that way.
562
 
563
   GDB supports HP-UX, SunOS, SVr4, Irix 5, and IBM RS/6000 shared
564
libraries.
565
 
566
   GDB automatically loads symbol definitions from shared libraries
567
when you use the `run' command, or when you examine a core file.
568
(Before you issue the `run' command, GDB does not understand references
569
to a function in a shared library, however--unless you are debugging a
570
core file).
571
 
572
   On HP-UX, if the program loads a library explicitly, GDB
573
automatically loads the symbols at the time of the `shl_load' call.
574
 
575
   There are times, however, when you may wish to not automatically load
576
symbol definitions from shared libraries, such as when they are
577
particularly large or there are many of them.
578
 
579
   To control the automatic loading of shared library symbols, use the
580
commands:
581
 
582
`set auto-solib-add MODE'
583
     If MODE is `on', symbols from all shared object libraries will be
584
     loaded automatically when the inferior begins execution, you
585
     attach to an independently started inferior, or when the dynamic
586
     linker informs GDB that a new library has been loaded.  If MODE is
587
     `off', symbols must be loaded manually, using the `sharedlibrary'
588
     command.  The default value is `on'.
589
 
590
`show auto-solib-add'
591
     Display the current autoloading mode.
592
 
593
   To explicitly load shared library symbols, use the `sharedlibrary'
594
command:
595
 
596
`info share'
597
`info sharedlibrary'
598
     Print the names of the shared libraries which are currently loaded.
599
 
600
`sharedlibrary REGEX'
601
`share REGEX'
602
     Load shared object library symbols for files matching a Unix
603
     regular expression.  As with files loaded automatically, it only
604
     loads shared libraries required by your program for a core file or
605
     after typing `run'.  If REGEX is omitted all shared libraries
606
     required by your program are loaded.
607
 
608
   On some systems, such as HP-UX systems, GDB supports autoloading
609
shared library symbols until a limiting threshold size is reached.
610
This provides the benefit of allowing autoloading to remain on by
611
default, but avoids autoloading excessively large shared libraries, up
612
to a threshold that is initially set, but which you can modify if you
613
wish.
614
 
615
   Beyond that threshold, symbols from shared libraries must be
616
explicitly loaded.  To load these symbols, use the command
617
`sharedlibrary FILENAME'.  The base address of the shared library is
618
determined automatically by GDB and need not be specified.
619
 
620
   To display or set the threshold, use the commands:
621
 
622
`set auto-solib-limit THRESHOLD'
623
     Set the autoloading size threshold, in an integral number of
624
     megabytes.  If THRESHOLD is nonzero and shared library autoloading
625
     is enabled, symbols from all shared object libraries will be
626
     loaded until the total size of the loaded shared library symbols
627
     exceeds this threshold.  Otherwise, symbols must be loaded
628
     manually, using the `sharedlibrary' command.  The default
629
     threshold is 100 (i.e. 100 Mb).
630
 
631
`show auto-solib-limit'
632
     Display the current autoloading size threshold, in megabytes.
633
 
634

635
File: gdb.info,  Node: Symbol Errors,  Prev: Files,  Up: GDB Files
636
 
637
Errors reading symbol files
638
===========================
639
 
640
   While reading a symbol file, GDB occasionally encounters problems,
641
such as symbol types it does not recognize, or known bugs in compiler
642
output.  By default, GDB does not notify you of such problems, since
643
they are relatively common and primarily of interest to people
644
debugging compilers.  If you are interested in seeing information about
645
ill-constructed symbol tables, you can either ask GDB to print only one
646
message about each such type of problem, no matter how many times the
647
problem occurs; or you can ask GDB to print more messages, to see how
648
many times the problems occur, with the `set complaints' command (*note
649
Optional warnings and messages: Messages/Warnings.).
650
 
651
   The messages currently printed, and their meanings, include:
652
 
653
`inner block not inside outer block in SYMBOL'
654
     The symbol information shows where symbol scopes begin and end
655
     (such as at the start of a function or a block of statements).
656
     This error indicates that an inner scope block is not fully
657
     contained in its outer scope blocks.
658
 
659
     GDB circumvents the problem by treating the inner block as if it
660
     had the same scope as the outer block.  In the error message,
661
     SYMBOL may be shown as "`(don't know)'" if the outer block is not a
662
     function.
663
 
664
`block at ADDRESS out of order'
665
     The symbol information for symbol scope blocks should occur in
666
     order of increasing addresses.  This error indicates that it does
667
     not do so.
668
 
669
     GDB does not circumvent this problem, and has trouble locating
670
     symbols in the source file whose symbols it is reading.  (You can
671
     often determine what source file is affected by specifying `set
672
     verbose on'.  *Note Optional warnings and messages:
673
     Messages/Warnings.)
674
 
675
`bad block start address patched'
676
     The symbol information for a symbol scope block has a start address
677
     smaller than the address of the preceding source line.  This is
678
     known to occur in the SunOS 4.1.1 (and earlier) C compiler.
679
 
680
     GDB circumvents the problem by treating the symbol scope block as
681
     starting on the previous source line.
682
 
683
`bad string table offset in symbol N'
684
     Symbol number N contains a pointer into the string table which is
685
     larger than the size of the string table.
686
 
687
     GDB circumvents the problem by considering the symbol to have the
688
     name `foo', which may cause other problems if many symbols end up
689
     with this name.
690
 
691
`unknown symbol type `0xNN''
692
     The symbol information contains new data types that GDB does not
693
     yet know how to read.  `0xNN' is the symbol type of the
694
     uncomprehended information, in hexadecimal.
695
 
696
     GDB circumvents the error by ignoring this symbol information.
697
     This usually allows you to debug your program, though certain
698
     symbols are not accessible.  If you encounter such a problem and
699
     feel like debugging it, you can debug `gdb' with itself, breakpoint
700
     on `complain', then go up to the function `read_dbx_symtab' and
701
     examine `*bufp' to see the symbol.
702
 
703
`stub type has NULL name'
704
     GDB could not find the full definition for a struct or class.
705
 
706
`const/volatile indicator missing (ok if using g++ v1.x), got...'
707
     The symbol information for a C++ member function is missing some
708
     information that recent versions of the compiler should have
709
     output for it.
710
 
711
`info mismatch between compiler and debugger'
712
     GDB could not parse a type specification output by the compiler.
713
 
714

715
File: gdb.info,  Node: Targets,  Next: Remote Debugging,  Prev: GDB Files,  Up: Top
716
 
717
Specifying a Debugging Target
718
*****************************
719
 
720
   A "target" is the execution environment occupied by your program.
721
 
722
   Often, GDB runs in the same host environment as your program; in
723
that case, the debugging target is specified as a side effect when you
724
use the `file' or `core' commands.  When you need more flexibility--for
725
example, running GDB on a physically separate host, or controlling a
726
standalone system over a serial port or a realtime system over a TCP/IP
727
connection--you can use the `target' command to specify one of the
728
target types configured for GDB (*note Commands for managing targets:
729
Target Commands.).
730
 
731
* Menu:
732
 
733
* Active Targets::              Active targets
734
* Target Commands::             Commands for managing targets
735
* Byte Order::                  Choosing target byte order
736
* Remote::                      Remote debugging
737
* KOD::                         Kernel Object Display
738
 
739

740
File: gdb.info,  Node: Active Targets,  Next: Target Commands,  Up: Targets
741
 
742
Active targets
743
==============
744
 
745
   There are three classes of targets: processes, core files, and
746
executable files.  GDB can work concurrently on up to three active
747
targets, one in each class.  This allows you to (for example) start a
748
process and inspect its activity without abandoning your work on a core
749
file.
750
 
751
   For example, if you execute `gdb a.out', then the executable file
752
`a.out' is the only active target.  If you designate a core file as
753
well--presumably from a prior run that crashed and coredumped--then GDB
754
has two active targets and uses them in tandem, looking first in the
755
corefile target, then in the executable file, to satisfy requests for
756
memory addresses.  (Typically, these two classes of target are
757
complementary, since core files contain only a program's read-write
758
memory--variables and so on--plus machine status, while executable
759
files contain only the program text and initialized data.)
760
 
761
   When you type `run', your executable file becomes an active process
762
target as well.  When a process target is active, all GDB commands
763
requesting memory addresses refer to that target; addresses in an
764
active core file or executable file target are obscured while the
765
process target is active.
766
 
767
   Use the `core-file' and `exec-file' commands to select a new core
768
file or executable target (*note Commands to specify files: Files.).
769
To specify as a target a process that is already running, use the
770
`attach' command (*note Debugging an already-running process: Attach.).
771
 
772

773
File: gdb.info,  Node: Target Commands,  Next: Byte Order,  Prev: Active Targets,  Up: Targets
774
 
775
Commands for managing targets
776
=============================
777
 
778
`target TYPE PARAMETERS'
779
     Connects the GDB host environment to a target machine or process.
780
     A target is typically a protocol for talking to debugging
781
     facilities.  You use the argument TYPE to specify the type or
782
     protocol of the target machine.
783
 
784
     Further PARAMETERS are interpreted by the target protocol, but
785
     typically include things like device names or host names to connect
786
     with, process numbers, and baud rates.
787
 
788
     The `target' command does not repeat if you press  again
789
     after executing the command.
790
 
791
`help target'
792
     Displays the names of all targets available.  To display targets
793
     currently selected, use either `info target' or `info files'
794
     (*note Commands to specify files: Files.).
795
 
796
`help target NAME'
797
     Describe a particular target, including any parameters necessary to
798
     select it.
799
 
800
`set gnutarget ARGS'
801
     GDB uses its own library BFD to read your files.  GDB knows
802
     whether it is reading an "executable", a "core", or a ".o" file;
803
     however, you can specify the file format with the `set gnutarget'
804
     command.  Unlike most `target' commands, with `gnutarget' the
805
     `target' refers to a program, not a machine.
806
 
807
          _Warning:_ To specify a file format with `set gnutarget', you
808
          must know the actual BFD name.
809
 
810
     *Note Commands to specify files: Files.
811
 
812
`show gnutarget'
813
     Use the `show gnutarget' command to display what file format
814
     `gnutarget' is set to read.  If you have not set `gnutarget', GDB
815
     will determine the file format for each file automatically, and
816
     `show gnutarget' displays `The current BDF target is "auto"'.
817
 
818
   Here are some common targets (available, or not, depending on the GDB
819
configuration):
820
 
821
`target exec PROGRAM'
822
     An executable file.  `target exec PROGRAM' is the same as
823
     `exec-file PROGRAM'.
824
 
825
`target core FILENAME'
826
     A core dump file.  `target core FILENAME' is the same as
827
     `core-file FILENAME'.
828
 
829
`target remote DEV'
830
     Remote serial target in GDB-specific protocol.  The argument DEV
831
     specifies what serial device to use for the connection (e.g.
832
     `/dev/ttya'). *Note Remote debugging: Remote.  `target remote'
833
     supports the `load' command.  This is only useful if you have some
834
     other way of getting the stub to the target system, and you can put
835
     it somewhere in memory where it won't get clobbered by the
836
     download.
837
 
838
`target sim'
839
     Builtin CPU simulator.  GDB includes simulators for most
840
     architectures.  In general,
841
                  target sim
842
                  load
843
                  run
844
 
845
     works; however, you cannot assume that a specific memory map,
846
     device drivers, or even basic I/O is available, although some
847
     simulators do provide these.  For info about any
848
     processor-specific simulator details, see the appropriate section
849
     in *Note Embedded Processors: Embedded Processors.
850
 
851
   Some configurations may include these targets as well:
852
 
853
`target nrom DEV'
854
     NetROM ROM emulator.  This target only supports downloading.
855
 
856
   Different targets are available on different configurations of GDB;
857
your configuration may have more or fewer targets.
858
 
859
   Many remote targets require you to download the executable's code
860
once you've successfully established a connection.
861
 
862
`load FILENAME'
863
     Depending on what remote debugging facilities are configured into
864
     GDB, the `load' command may be available.  Where it exists, it is
865
     meant to make FILENAME (an executable) available for debugging on
866
     the remote system--by downloading, or dynamic linking, for example.
867
     `load' also records the FILENAME symbol table in GDB, like the
868
     `add-symbol-file' command.
869
 
870
     If your GDB does not have a `load' command, attempting to execute
871
     it gets the error message "`You can't do that when your target is
872
     ...'"
873
 
874
     The file is loaded at whatever address is specified in the
875
     executable.  For some object file formats, you can specify the
876
     load address when you link the program; for other formats, like
877
     a.out, the object file format specifies a fixed address.
878
 
879
     `load' does not repeat if you press  again after using it.
880
 
881

882
File: gdb.info,  Node: Byte Order,  Next: Remote,  Prev: Target Commands,  Up: Targets
883
 
884
Choosing target byte order
885
==========================
886
 
887
   Some types of processors, such as the MIPS, PowerPC, and Hitachi SH,
888
offer the ability to run either big-endian or little-endian byte
889
orders.  Usually the executable or symbol will include a bit to
890
designate the endian-ness, and you will not need to worry about which
891
to use.  However, you may still find it useful to adjust GDB's idea of
892
processor endian-ness manually.
893
 
894
`set endian big'
895
     Instruct GDB to assume the target is big-endian.
896
 
897
`set endian little'
898
     Instruct GDB to assume the target is little-endian.
899
 
900
`set endian auto'
901
     Instruct GDB to use the byte order associated with the executable.
902
 
903
`show endian'
904
     Display GDB's current idea of the target byte order.
905
 
906
   Note that these commands merely adjust interpretation of symbolic
907
data on the host, and that they have absolutely no effect on the target
908
system.
909
 
910

911
File: gdb.info,  Node: Remote,  Next: KOD,  Prev: Byte Order,  Up: Targets
912
 
913
Remote debugging
914
================
915
 
916
   If you are trying to debug a program running on a machine that
917
cannot run GDB in the usual way, it is often useful to use remote
918
debugging.  For example, you might use remote debugging on an operating
919
system kernel, or on a small system which does not have a general
920
purpose operating system powerful enough to run a full-featured
921
debugger.
922
 
923
   Some configurations of GDB have special serial or TCP/IP interfaces
924
to make this work with particular debugging targets.  In addition, GDB
925
comes with a generic serial protocol (specific to GDB, but not specific
926
to any particular target system) which you can use if you write the
927
remote stubs--the code that runs on the remote system to communicate
928
with GDB.
929
 
930
   Other remote targets may be available in your configuration of GDB;
931
use `help target' to list them.
932
 
933

934
File: gdb.info,  Node: KOD,  Prev: Remote,  Up: Targets
935
 
936
Kernel Object Display
937
=====================
938
 
939
   Some targets support kernel object display.  Using this facility,
940
GDB communicates specially with the underlying operating system and can
941
display information about operating system-level objects such as
942
mutexes and other synchronization objects.  Exactly which objects can be
943
displayed is determined on a per-OS basis.
944
 
945
   Use the `set os' command to set the operating system.  This tells
946
GDB which kernel object display module to initialize:
947
 
948
     (gdb) set os cisco
949
 
950
   If `set os' succeeds, GDB will display some information about the
951
operating system, and will create a new `info' command which can be
952
used to query the target.  The `info' command is named after the
953
operating system:
954
 
955
     (gdb) info cisco
956
     List of Cisco Kernel Objects
957
     Object     Description
958
     any        Any and all objects
959
 
960
   Further subcommands can be used to query about particular objects
961
known by the kernel.
962
 
963
   There is currently no way to determine whether a given operating
964
system is supported other than to try it.
965
 
966

967
File: gdb.info,  Node: Remote Debugging,  Next: Configurations,  Prev: Targets,  Up: Top
968
 
969
Debugging remote programs
970
*************************
971
 
972
* Menu:
973
 
974
* Server::                      Using the gdbserver program
975
* NetWare::                     Using the gdbserve.nlm program
976
* remote stub::                 Implementing a remote stub
977
 
978

979
File: gdb.info,  Node: Server,  Next: NetWare,  Up: Remote Debugging
980
 
981
Using the `gdbserver' program
982
=============================
983
 
984
   `gdbserver' is a control program for Unix-like systems, which allows
985
you to connect your program with a remote GDB via `target remote'--but
986
without linking in the usual debugging stub.
987
 
988
   `gdbserver' is not a complete replacement for the debugging stubs,
989
because it requires essentially the same operating-system facilities
990
that GDB itself does.  In fact, a system that can run `gdbserver' to
991
connect to a remote GDB could also run GDB locally!  `gdbserver' is
992
sometimes useful nevertheless, because it is a much smaller program
993
than GDB itself.  It is also easier to port than all of GDB, so you may
994
be able to get started more quickly on a new system by using
995
`gdbserver'.  Finally, if you develop code for real-time systems, you
996
may find that the tradeoffs involved in real-time operation make it
997
more convenient to do as much development work as possible on another
998
system, for example by cross-compiling.  You can use `gdbserver' to
999
make a similar choice for debugging.
1000
 
1001
   GDB and `gdbserver' communicate via either a serial line or a TCP
1002
connection, using the standard GDB remote serial protocol.
1003
 
1004
_On the target machine,_
1005
     you need to have a copy of the program you want to debug.
1006
     `gdbserver' does not need your program's symbol table, so you can
1007
     strip the program if necessary to save space.  GDB on the host
1008
     system does all the symbol handling.
1009
 
1010
     To use the server, you must tell it how to communicate with GDB;
1011
     the name of your program; and the arguments for your program.  The
1012
     usual syntax is:
1013
 
1014
          target> gdbserver COMM PROGRAM [ ARGS ... ]
1015
 
1016
     COMM is either a device name (to use a serial line) or a TCP
1017
     hostname and portnumber.  For example, to debug Emacs with the
1018
     argument `foo.txt' and communicate with GDB over the serial port
1019
     `/dev/com1':
1020
 
1021
          target> gdbserver /dev/com1 emacs foo.txt
1022
 
1023
     `gdbserver' waits passively for the host GDB to communicate with
1024
     it.
1025
 
1026
     To use a TCP connection instead of a serial line:
1027
 
1028
          target> gdbserver host:2345 emacs foo.txt
1029
 
1030
     The only difference from the previous example is the first
1031
     argument, specifying that you are communicating with the host GDB
1032
     via TCP.  The `host:2345' argument means that `gdbserver' is to
1033
     expect a TCP connection from machine `host' to local TCP port 2345.
1034
     (Currently, the `host' part is ignored.)  You can choose any number
1035
     you want for the port number as long as it does not conflict with
1036
     any TCP ports already in use on the target system (for example,
1037
     `23' is reserved for `telnet').(1)  You must use the same port
1038
     number with the host GDB `target remote' command.
1039
 
1040
     On some targets, `gdbserver' can also attach to running programs.
1041
     This is accomplished via the `--attach' argument.  The syntax is:
1042
 
1043
          target> gdbserver COMM --attach PID
1044
 
1045
     PID is the process ID of a currently running process.  It isn't
1046
     necessary to point `gdbserver' at a binary for the running process.
1047
 
1048
_On the GDB host machine,_
1049
     you need an unstripped copy of your program, since GDB needs
1050
     symbols and debugging information.  Start up GDB as usual, using
1051
     the name of the local copy of your program as the first argument.
1052
     (You may also need the `--baud' option if the serial line is
1053
     running at anything other than 9600bps.)  After that, use `target
1054
     remote' to establish communications with `gdbserver'.  Its argument
1055
     is either a device name (usually a serial device, like
1056
     `/dev/ttyb'), or a TCP port descriptor in the form `HOST:PORT'.
1057
     For example:
1058
 
1059
          (gdb) target remote /dev/ttyb
1060
 
1061
     communicates with the server via serial line `/dev/ttyb', and
1062
 
1063
          (gdb) target remote the-target:2345
1064
 
1065
     communicates via a TCP connection to port 2345 on host
1066
     `the-target'.  For TCP connections, you must start up `gdbserver'
1067
     prior to using the `target remote' command.  Otherwise you may get
1068
     an error whose text depends on the host system, but which usually
1069
     looks something like `Connection refused'.
1070
 
1071
   ---------- Footnotes ----------
1072
 
1073
   (1) If you choose a port number that conflicts with another service,
1074
`gdbserver' prints an error message and exits.
1075
 
1076

1077
File: gdb.info,  Node: NetWare,  Next: remote stub,  Prev: Server,  Up: Remote Debugging
1078
 
1079
Using the `gdbserve.nlm' program
1080
================================
1081
 
1082
   `gdbserve.nlm' is a control program for NetWare systems, which
1083
allows you to connect your program with a remote GDB via `target
1084
remote'.
1085
 
1086
   GDB and `gdbserve.nlm' communicate via a serial line, using the
1087
standard GDB remote serial protocol.
1088
 
1089
_On the target machine,_
1090
     you need to have a copy of the program you want to debug.
1091
     `gdbserve.nlm' does not need your program's symbol table, so you
1092
     can strip the program if necessary to save space.  GDB on the host
1093
     system does all the symbol handling.
1094
 
1095
     To use the server, you must tell it how to communicate with GDB;
1096
     the name of your program; and the arguments for your program.  The
1097
     syntax is:
1098
 
1099
          load gdbserve [ BOARD=BOARD ] [ PORT=PORT ]
1100
                        [ BAUD=BAUD ] PROGRAM [ ARGS ... ]
1101
 
1102
     BOARD and PORT specify the serial line; BAUD specifies the baud
1103
     rate used by the connection.  PORT and NODE default to 0, BAUD
1104
     defaults to 9600bps.
1105
 
1106
     For example, to debug Emacs with the argument `foo.txt'and
1107
     communicate with GDB over serial port number 2 or board 1 using a
1108
     19200bps connection:
1109
 
1110
          load gdbserve BOARD=1 PORT=2 BAUD=19200 emacs foo.txt
1111
 
1112
_On the GDB host machine,_
1113
     you need an unstripped copy of your program, since GDB needs
1114
     symbols and debugging information.  Start up GDB as usual, using
1115
     the name of the local copy of your program as the first argument.
1116
     (You may also need the `--baud' option if the serial line is
1117
     running at anything other than 9600bps.  After that, use `target
1118
     remote' to establish communications with `gdbserve.nlm'.  Its
1119
     argument is a device name (usually a serial device, like
1120
     `/dev/ttyb').  For example:
1121
 
1122
          (gdb) target remote /dev/ttyb
1123
 
1124
     communications with the server via serial line `/dev/ttyb'.
1125
 
1126

1127
File: gdb.info,  Node: remote stub,  Prev: NetWare,  Up: Remote Debugging
1128
 
1129
Implementing a remote stub
1130
==========================
1131
 
1132
   The stub files provided with GDB implement the target side of the
1133
communication protocol, and the GDB side is implemented in the GDB
1134
source file `remote.c'.  Normally, you can simply allow these
1135
subroutines to communicate, and ignore the details.  (If you're
1136
implementing your own stub file, you can still ignore the details: start
1137
with one of the existing stub files.  `sparc-stub.c' is the best
1138
organized, and therefore the easiest to read.)
1139
 
1140
   To debug a program running on another machine (the debugging
1141
"target" machine), you must first arrange for all the usual
1142
prerequisites for the program to run by itself.  For example, for a C
1143
program, you need:
1144
 
1145
  1. A startup routine to set up the C runtime environment; these
1146
     usually have a name like `crt0'.  The startup routine may be
1147
     supplied by your hardware supplier, or you may have to write your
1148
     own.
1149
 
1150
  2. A C subroutine library to support your program's subroutine calls,
1151
     notably managing input and output.
1152
 
1153
  3. A way of getting your program to the other machine--for example, a
1154
     download program.  These are often supplied by the hardware
1155
     manufacturer, but you may have to write your own from hardware
1156
     documentation.
1157
 
1158
   The next step is to arrange for your program to use a serial port to
1159
communicate with the machine where GDB is running (the "host" machine).
1160
In general terms, the scheme looks like this:
1161
 
1162
_On the host,_
1163
     GDB already understands how to use this protocol; when everything
1164
     else is set up, you can simply use the `target remote' command
1165
     (*note Specifying a Debugging Target: Targets.).
1166
 
1167
_On the target,_
1168
     you must link with your program a few special-purpose subroutines
1169
     that implement the GDB remote serial protocol.  The file
1170
     containing these subroutines is called  a "debugging stub".
1171
 
1172
     On certain remote targets, you can use an auxiliary program
1173
     `gdbserver' instead of linking a stub into your program.  *Note
1174
     Using the `gdbserver' program: Server, for details.
1175
 
1176
   The debugging stub is specific to the architecture of the remote
1177
machine; for example, use `sparc-stub.c' to debug programs on SPARC
1178
boards.
1179
 
1180
   These working remote stubs are distributed with GDB:
1181
 
1182
`i386-stub.c'
1183
     For Intel 386 and compatible architectures.
1184
 
1185
`m68k-stub.c'
1186
     For Motorola 680x0 architectures.
1187
 
1188
`sh-stub.c'
1189
     For Hitachi SH architectures.
1190
 
1191
`sparc-stub.c'
1192
     For SPARC architectures.
1193
 
1194
`sparcl-stub.c'
1195
     For Fujitsu SPARCLITE architectures.
1196
 
1197
   The `README' file in the GDB distribution may list other recently
1198
added stubs.
1199
 
1200
* Menu:
1201
 
1202
* Stub Contents::       What the stub can do for you
1203
* Bootstrapping::       What you must do for the stub
1204
* Debug Session::       Putting it all together
1205
 

powered by: WebSVN 2.1.0

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