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

Subversion Repositories or1k

[/] [or1k/] [tags/] [VER_5_3/] [gdb-5.3/] [gdb/] [doc/] [gdb.info-5] - Blame information for rev 1778

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: Macros,  Next: Tracepoints,  Prev: Data,  Up: Top
31
 
32
C Preprocessor Macros
33
*********************
34
 
35
   Some languages, such as C and C++, provide a way to define and invoke
36
"preprocessor macros" which expand into strings of tokens.  GDB can
37
evaluate expressions containing macro invocations, show the result of
38
macro expansion, and show a macro's definition, including where it was
39
defined.
40
 
41
   You may need to compile your program specially to provide GDB with
42
information about preprocessor macros.  Most compilers do not include
43
macros in their debugging information, even when you compile with the
44
`-g' flag.  *Note Compilation::.
45
 
46
   A program may define a macro at one point, remove that definition
47
later, and then provide a different definition after that.  Thus, at
48
different points in the program, a macro may have different
49
definitions, or have no definition at all.  If there is a current stack
50
frame, GDB uses the macros in scope at that frame's source code line.
51
Otherwise, GDB uses the macros in scope at the current listing location;
52
see *Note List::.
53
 
54
   At the moment, GDB does not support the `##' token-splicing
55
operator, the `#' stringification operator, or variable-arity macros.
56
 
57
   Whenever GDB evaluates an expression, it always expands any macro
58
invocations present in the expression.  GDB also provides the following
59
commands for working with macros explicitly.
60
 
61
`macro expand EXPRESSION'
62
`macro exp EXPRESSION'
63
     Show the results of expanding all preprocessor macro invocations in
64
     EXPRESSION.  Since GDB simply expands macros, but does not parse
65
     the result, EXPRESSION need not be a valid expression; it can be
66
     any string of tokens.
67
 
68
`macro expand-once EXPRESSION'
69
`macro exp1 EXPRESSION'
70
     (This command is not yet implemented.)  Show the results of
71
     expanding those preprocessor macro invocations that appear
72
     explicitly in EXPRESSION.  Macro invocations appearing in that
73
     expansion are left unchanged.  This command allows you to see the
74
     effect of a particular macro more clearly, without being confused
75
     by further expansions.  Since GDB simply expands macros, but does
76
     not parse the result, EXPRESSION need not be a valid expression; it
77
     can be any string of tokens.
78
 
79
`info macro MACRO'
80
     Show the definition of the macro named MACRO, and describe the
81
     source location where that definition was established.
82
 
83
`macro define MACRO REPLACEMENT-LIST'
84
`macro define MACRO(ARGLIST) REPLACEMENT-LIST'
85
     (This command is not yet implemented.)  Introduce a definition for
86
     a preprocessor macro named MACRO, invocations of which are replaced
87
     by the tokens given in REPLACEMENT-LIST.  The first form of this
88
     command defines an "object-like" macro, which takes no arguments;
89
     the second form defines a "function-like" macro, which takes the
90
     arguments given in ARGLIST.
91
 
92
     A definition introduced by this command is in scope in every
93
     expression evaluated in GDB, until it is removed with the `macro
94
     undef' command, described below.  The definition overrides all
95
     definitions for MACRO present in the program being debugged, as
96
     well as any previous user-supplied definition.
97
 
98
`macro undef MACRO'
99
     (This command is not yet implemented.)  Remove any user-supplied
100
     definition for the macro named MACRO.  This command only affects
101
     definitions provided with the `macro define' command, described
102
     above; it cannot remove definitions present in the program being
103
     debugged.
104
 
105
   Here is a transcript showing the above commands in action.  First, we
106
show our source files:
107
 
108
     $ cat sample.c
109
     #include 
110
     #include "sample.h"
111
 
112
     #define M 42
113
     #define ADD(x) (M + x)
114
 
115
     main ()
116
     {
117
     #define N 28
118
       printf ("Hello, world!\n");
119
     #undef N
120
       printf ("We're so creative.\n");
121
     #define N 1729
122
       printf ("Goodbye, world!\n");
123
     }
124
     $ cat sample.h
125
     #define Q <
126
     $
127
 
128
   Now, we compile the program using the GNU C compiler, GCC.  We pass
129
the `-gdwarf-2' and `-g3' flags to ensure the compiler includes
130
information about preprocessor macros in the debugging information.
131
 
132
     $ gcc -gdwarf-2 -g3 sample.c -o sample
133
     $
134
 
135
   Now, we start GDB on our sample program:
136
 
137
     $ gdb -nw sample
138
     GNU gdb 2002-05-06-cvs
139
     Copyright 2002 Free Software Foundation, Inc.
140
     GDB is free software, ...
141
     (gdb)
142
 
143
   We can expand macros and examine their definitions, even when the
144
program is not running.  GDB uses the current listing position to
145
decide which macro definitions are in scope:
146
 
147
     (gdb) list main
148
     3
149
     4       #define M 42
150
     5       #define ADD(x) (M + x)
151
     6
152
     7       main ()
153
     8       {
154
     9       #define N 28
155
     10        printf ("Hello, world!\n");
156
     11      #undef N
157
     12        printf ("We're so creative.\n");
158
     (gdb) info macro ADD
159
     Defined at /home/jimb/gdb/macros/play/sample.c:5
160
     #define ADD(x) (M + x)
161
     (gdb) info macro Q
162
     Defined at /home/jimb/gdb/macros/play/sample.h:1
163
       included at /home/jimb/gdb/macros/play/sample.c:2
164
     #define Q <
165
     (gdb) macro expand ADD(1)
166
     expands to: (42 + 1)
167
     (gdb) macro expand-once ADD(1)
168
     expands to: once (M + 1)
169
     (gdb)
170
 
171
   In the example above, note that `macro expand-once' expands only the
172
macro invocation explicit in the original text -- the invocation of
173
`ADD' -- but does not expand the invocation of the macro `M', which was
174
introduced by `ADD'.
175
 
176
   Once the program is running, GDB uses the macro definitions in force
177
at the source line of the current stack frame:
178
 
179
     (gdb) break main
180
     Breakpoint 1 at 0x8048370: file sample.c, line 10.
181
     (gdb) run
182
     Starting program: /home/jimb/gdb/macros/play/sample
183
 
184
     Breakpoint 1, main () at sample.c:10
185
     10        printf ("Hello, world!\n");
186
     (gdb)
187
 
188
   At line 10, the definition of the macro `N' at line 9 is in force:
189
 
190
     (gdb) info macro N
191
     Defined at /home/jimb/gdb/macros/play/sample.c:9
192
     #define N 28
193
     (gdb) macro expand N Q M
194
     expands to: 28 < 42
195
     (gdb) print N Q M
196
     $1 = 1
197
     (gdb)
198
 
199
   As we step over directives that remove `N''s definition, and then
200
give it a new definition, GDB finds the definition (or lack thereof) in
201
force at each point:
202
 
203
     (gdb) next
204
     Hello, world!
205
     12        printf ("We're so creative.\n");
206
     (gdb) info macro N
207
     The symbol `N' has no definition as a C/C++ preprocessor macro
208
     at /home/jimb/gdb/macros/play/sample.c:12
209
     (gdb) next
210
     We're so creative.
211
     14        printf ("Goodbye, world!\n");
212
     (gdb) info macro N
213
     Defined at /home/jimb/gdb/macros/play/sample.c:13
214
     #define N 1729
215
     (gdb) macro expand N Q M
216
     expands to: 1729 < 42
217
     (gdb) print N Q M
218
     $2 = 0
219
     (gdb)
220
 
221

222
File: gdb.info,  Node: Tracepoints,  Next: Overlays,  Prev: Macros,  Up: Top
223
 
224
Tracepoints
225
***********
226
 
227
   In some applications, it is not feasible for the debugger to
228
interrupt the program's execution long enough for the developer to learn
229
anything helpful about its behavior.  If the program's correctness
230
depends on its real-time behavior, delays introduced by a debugger
231
might cause the program to change its behavior drastically, or perhaps
232
fail, even when the code itself is correct.  It is useful to be able to
233
observe the program's behavior without interrupting it.
234
 
235
   Using GDB's `trace' and `collect' commands, you can specify
236
locations in the program, called "tracepoints", and arbitrary
237
expressions to evaluate when those tracepoints are reached.  Later,
238
using the `tfind' command, you can examine the values those expressions
239
had when the program hit the tracepoints.  The expressions may also
240
denote objects in memory--structures or arrays, for example--whose
241
values GDB should record; while visiting a particular tracepoint, you
242
may inspect those objects as if they were in memory at that moment.
243
However, because GDB records these values without interacting with you,
244
it can do so quickly and unobtrusively, hopefully not disturbing the
245
program's behavior.
246
 
247
   The tracepoint facility is currently available only for remote
248
targets.  *Note Targets::.  In addition, your remote target must know
249
how to collect trace data.  This functionality is implemented in the
250
remote stub; however, none of the stubs distributed with GDB support
251
tracepoints as of this writing.
252
 
253
   This chapter describes the tracepoint commands and features.
254
 
255
* Menu:
256
 
257
* Set Tracepoints::
258
* Analyze Collected Data::
259
* Tracepoint Variables::
260
 
261

262
File: gdb.info,  Node: Set Tracepoints,  Next: Analyze Collected Data,  Up: Tracepoints
263
 
264
Commands to Set Tracepoints
265
===========================
266
 
267
   Before running such a "trace experiment", an arbitrary number of
268
tracepoints can be set.  Like a breakpoint (*note Set Breaks::), a
269
tracepoint has a number assigned to it by GDB.  Like with breakpoints,
270
tracepoint numbers are successive integers starting from one.  Many of
271
the commands associated with tracepoints take the tracepoint number as
272
their argument, to identify which tracepoint to work on.
273
 
274
   For each tracepoint, you can specify, in advance, some arbitrary set
275
of data that you want the target to collect in the trace buffer when it
276
hits that tracepoint.  The collected data can include registers, local
277
variables, or global data.  Later, you can use GDB commands to examine
278
the values these data had at the time the tracepoint was hit.
279
 
280
   This section describes commands to set tracepoints and associated
281
conditions and actions.
282
 
283
* Menu:
284
 
285
* Create and Delete Tracepoints::
286
* Enable and Disable Tracepoints::
287
* Tracepoint Passcounts::
288
* Tracepoint Actions::
289
* Listing Tracepoints::
290
* Starting and Stopping Trace Experiment::
291
 
292

293
File: gdb.info,  Node: Create and Delete Tracepoints,  Next: Enable and Disable Tracepoints,  Up: Set Tracepoints
294
 
295
Create and Delete Tracepoints
296
-----------------------------
297
 
298
`trace'
299
     The `trace' command is very similar to the `break' command.  Its
300
     argument can be a source line, a function name, or an address in
301
     the target program.  *Note Set Breaks::.  The `trace' command
302
     defines a tracepoint, which is a point in the target program where
303
     the debugger will briefly stop, collect some data, and then allow
304
     the program to continue.  Setting a tracepoint or changing its
305
     commands doesn't take effect until the next `tstart' command;
306
     thus, you cannot change the tracepoint attributes once a trace
307
     experiment is running.
308
 
309
     Here are some examples of using the `trace' command:
310
 
311
          (gdb) trace foo.c:121    // a source file and line number
312
 
313
          (gdb) trace +2           // 2 lines forward
314
 
315
          (gdb) trace my_function  // first source line of function
316
 
317
          (gdb) trace *my_function // EXACT start address of function
318
 
319
          (gdb) trace *0x2117c4    // an address
320
 
321
     You can abbreviate `trace' as `tr'.
322
 
323
     The convenience variable `$tpnum' records the tracepoint number of
324
     the most recently set tracepoint.
325
 
326
`delete tracepoint [NUM]'
327
     Permanently delete one or more tracepoints.  With no argument, the
328
     default is to delete all tracepoints.
329
 
330
     Examples:
331
 
332
          (gdb) delete trace 1 2 3 // remove three tracepoints
333
 
334
          (gdb) delete trace       // remove all tracepoints
335
 
336
     You can abbreviate this command as `del tr'.
337
 
338

339
File: gdb.info,  Node: Enable and Disable Tracepoints,  Next: Tracepoint Passcounts,  Prev: Create and Delete Tracepoints,  Up: Set Tracepoints
340
 
341
Enable and Disable Tracepoints
342
------------------------------
343
 
344
`disable tracepoint [NUM]'
345
     Disable tracepoint NUM, or all tracepoints if no argument NUM is
346
     given.  A disabled tracepoint will have no effect during the next
347
     trace experiment, but it is not forgotten.  You can re-enable a
348
     disabled tracepoint using the `enable tracepoint' command.
349
 
350
`enable tracepoint [NUM]'
351
     Enable tracepoint NUM, or all tracepoints.  The enabled
352
     tracepoints will become effective the next time a trace experiment
353
     is run.
354
 
355

356
File: gdb.info,  Node: Tracepoint Passcounts,  Next: Tracepoint Actions,  Prev: Enable and Disable Tracepoints,  Up: Set Tracepoints
357
 
358
Tracepoint Passcounts
359
---------------------
360
 
361
`passcount [N [NUM]]'
362
     Set the "passcount" of a tracepoint.  The passcount is a way to
363
     automatically stop a trace experiment.  If a tracepoint's
364
     passcount is N, then the trace experiment will be automatically
365
     stopped on the N'th time that tracepoint is hit.  If the
366
     tracepoint number NUM is not specified, the `passcount' command
367
     sets the passcount of the most recently defined tracepoint.  If no
368
     passcount is given, the trace experiment will run until stopped
369
     explicitly by the user.
370
 
371
     Examples:
372
 
373
          (gdb) passcount 5 2 // Stop on the 5th execution of
374
                                        `// tracepoint 2'
375
 
376
          (gdb) passcount 12  // Stop on the 12th execution of the
377
                                        `// most recently defined tracepoint.'
378
          (gdb) trace foo
379
          (gdb) pass 3
380
          (gdb) trace bar
381
          (gdb) pass 2
382
          (gdb) trace baz
383
          (gdb) pass 1        // Stop tracing when foo has been
384
                                         `// executed 3 times OR when bar has'
385
     `// been executed 2 times'
386
     `// OR when baz has been executed 1 time.'
387
 
388

389
File: gdb.info,  Node: Tracepoint Actions,  Next: Listing Tracepoints,  Prev: Tracepoint Passcounts,  Up: Set Tracepoints
390
 
391
Tracepoint Action Lists
392
-----------------------
393
 
394
`actions [NUM]'
395
     This command will prompt for a list of actions to be taken when the
396
     tracepoint is hit.  If the tracepoint number NUM is not specified,
397
     this command sets the actions for the one that was most recently
398
     defined (so that you can define a tracepoint and then say
399
     `actions' without bothering about its number).  You specify the
400
     actions themselves on the following lines, one action at a time,
401
     and terminate the actions list with a line containing just `end'.
402
     So far, the only defined actions are `collect' and
403
     `while-stepping'.
404
 
405
     To remove all actions from a tracepoint, type `actions NUM' and
406
     follow it immediately with `end'.
407
 
408
          (gdb) collect DATA // collect some data
409
 
410
          (gdb) while-stepping 5 // single-step 5 times, collect data
411
 
412
          (gdb) end              // signals the end of actions.
413
 
414
     In the following example, the action list begins with `collect'
415
     commands indicating the things to be collected when the tracepoint
416
     is hit.  Then, in order to single-step and collect additional data
417
     following the tracepoint, a `while-stepping' command is used,
418
     followed by the list of things to be collected while stepping.  The
419
     `while-stepping' command is terminated by its own separate `end'
420
     command.  Lastly, the action list is terminated by an `end'
421
     command.
422
 
423
          (gdb) trace foo
424
          (gdb) actions
425
          Enter actions for tracepoint 1, one per line:
426
          > collect bar,baz
427
          > collect $regs
428
          > while-stepping 12
429
            > collect $fp, $sp
430
            > end
431
          end
432
 
433
`collect EXPR1, EXPR2, ...'
434
     Collect values of the given expressions when the tracepoint is hit.
435
     This command accepts a comma-separated list of any valid
436
     expressions.  In addition to global, static, or local variables,
437
     the following special arguments are supported:
438
 
439
    `$regs'
440
          collect all registers
441
 
442
    `$args'
443
          collect all function arguments
444
 
445
    `$locals'
446
          collect all local variables.
447
 
448
     You can give several consecutive `collect' commands, each one with
449
     a single argument, or one `collect' command with several arguments
450
     separated by commas: the effect is the same.
451
 
452
     The command `info scope' (*note info scope: Symbols.) is
453
     particularly useful for figuring out what data to collect.
454
 
455
`while-stepping N'
456
     Perform N single-step traces after the tracepoint, collecting new
457
     data at each step.  The `while-stepping' command is followed by
458
     the list of what to collect while stepping (followed by its own
459
     `end' command):
460
 
461
          > while-stepping 12
462
            > collect $regs, myglobal
463
            > end
464
          >
465
 
466
     You may abbreviate `while-stepping' as `ws' or `stepping'.
467
 
468

469
File: gdb.info,  Node: Listing Tracepoints,  Next: Starting and Stopping Trace Experiment,  Prev: Tracepoint Actions,  Up: Set Tracepoints
470
 
471
Listing Tracepoints
472
-------------------
473
 
474
`info tracepoints [NUM]'
475
     Display information about the tracepoint NUM.  If you don't specify
476
     a tracepoint number, displays information about all the tracepoints
477
     defined so far.  For each tracepoint, the following information is
478
     shown:
479
 
480
        * its number
481
 
482
        * whether it is enabled or disabled
483
 
484
        * its address
485
 
486
        * its passcount as given by the `passcount N' command
487
 
488
        * its step count as given by the `while-stepping N' command
489
 
490
        * where in the source files is the tracepoint set
491
 
492
        * its action list as given by the `actions' command
493
 
494
          (gdb) info trace
495
          Num Enb Address    PassC StepC What
496
          1   y   0x002117c4 0     0     
497
          2   y   0x0020dc64 0     0     in g_test at g_test.c:1375
498
          3   y   0x0020b1f4 0     0     in get_data at ../foo.c:41
499
          (gdb)
500
 
501
     This command can be abbreviated `info tp'.
502
 
503

504
File: gdb.info,  Node: Starting and Stopping Trace Experiment,  Prev: Listing Tracepoints,  Up: Set Tracepoints
505
 
506
Starting and Stopping Trace Experiment
507
--------------------------------------
508
 
509
`tstart'
510
     This command takes no arguments.  It starts the trace experiment,
511
     and begins collecting data.  This has the side effect of
512
     discarding all the data collected in the trace buffer during the
513
     previous trace experiment.
514
 
515
`tstop'
516
     This command takes no arguments.  It ends the trace experiment, and
517
     stops collecting data.
518
 
519
     *Note:* a trace experiment and data collection may stop
520
     automatically if any tracepoint's passcount is reached (*note
521
     Tracepoint Passcounts::), or if the trace buffer becomes full.
522
 
523
`tstatus'
524
     This command displays the status of the current trace data
525
     collection.
526
 
527
   Here is an example of the commands we described so far:
528
 
529
     (gdb) trace gdb_c_test
530
     (gdb) actions
531
     Enter actions for tracepoint #1, one per line.
532
     > collect $regs,$locals,$args
533
     > while-stepping 11
534
       > collect $regs
535
       > end
536
     > end
537
     (gdb) tstart
538
        [time passes ...]
539
     (gdb) tstop
540
 
541

542
File: gdb.info,  Node: Analyze Collected Data,  Next: Tracepoint Variables,  Prev: Set Tracepoints,  Up: Tracepoints
543
 
544
Using the collected data
545
========================
546
 
547
   After the tracepoint experiment ends, you use GDB commands for
548
examining the trace data.  The basic idea is that each tracepoint
549
collects a trace "snapshot" every time it is hit and another snapshot
550
every time it single-steps.  All these snapshots are consecutively
551
numbered from zero and go into a buffer, and you can examine them
552
later.  The way you examine them is to "focus" on a specific trace
553
snapshot.  When the remote stub is focused on a trace snapshot, it will
554
respond to all GDB requests for memory and registers by reading from
555
the buffer which belongs to that snapshot, rather than from _real_
556
memory or registers of the program being debugged.  This means that
557
*all* GDB commands (`print', `info registers', `backtrace', etc.) will
558
behave as if we were currently debugging the program state as it was
559
when the tracepoint occurred.  Any requests for data that are not in
560
the buffer will fail.
561
 
562
* Menu:
563
 
564
* tfind::                       How to select a trace snapshot
565
* tdump::                       How to display all data for a snapshot
566
* save-tracepoints::            How to save tracepoints for a future run
567
 
568

569
File: gdb.info,  Node: tfind,  Next: tdump,  Up: Analyze Collected Data
570
 
571
`tfind N'
572
---------
573
 
574
   The basic command for selecting a trace snapshot from the buffer is
575
`tfind N', which finds trace snapshot number N, counting from zero.  If
576
no argument N is given, the next snapshot is selected.
577
 
578
   Here are the various forms of using the `tfind' command.
579
 
580
`tfind start'
581
     Find the first snapshot in the buffer.  This is a synonym for
582
     `tfind 0' (since 0 is the number of the first snapshot).
583
 
584
`tfind none'
585
     Stop debugging trace snapshots, resume _live_ debugging.
586
 
587
`tfind end'
588
     Same as `tfind none'.
589
 
590
`tfind'
591
     No argument means find the next trace snapshot.
592
 
593
`tfind -'
594
     Find the previous trace snapshot before the current one.  This
595
     permits retracing earlier steps.
596
 
597
`tfind tracepoint NUM'
598
     Find the next snapshot associated with tracepoint NUM.  Search
599
     proceeds forward from the last examined trace snapshot.  If no
600
     argument NUM is given, it means find the next snapshot collected
601
     for the same tracepoint as the current snapshot.
602
 
603
`tfind pc ADDR'
604
     Find the next snapshot associated with the value ADDR of the
605
     program counter.  Search proceeds forward from the last examined
606
     trace snapshot.  If no argument ADDR is given, it means find the
607
     next snapshot with the same value of PC as the current snapshot.
608
 
609
`tfind outside ADDR1, ADDR2'
610
     Find the next snapshot whose PC is outside the given range of
611
     addresses.
612
 
613
`tfind range ADDR1, ADDR2'
614
     Find the next snapshot whose PC is between ADDR1 and ADDR2.
615
 
616
`tfind line [FILE:]N'
617
     Find the next snapshot associated with the source line N.  If the
618
     optional argument FILE is given, refer to line N in that source
619
     file.  Search proceeds forward from the last examined trace
620
     snapshot.  If no argument N is given, it means find the next line
621
     other than the one currently being examined; thus saying `tfind
622
     line' repeatedly can appear to have the same effect as stepping
623
     from line to line in a _live_ debugging session.
624
 
625
   The default arguments for the `tfind' commands are specifically
626
designed to make it easy to scan through the trace buffer.  For
627
instance, `tfind' with no argument selects the next trace snapshot, and
628
`tfind -' with no argument selects the previous trace snapshot.  So, by
629
giving one `tfind' command, and then simply hitting  repeatedly
630
you can examine all the trace snapshots in order.  Or, by saying `tfind
631
-' and then hitting  repeatedly you can examine the snapshots in
632
reverse order.  The `tfind line' command with no argument selects the
633
snapshot for the next source line executed.  The `tfind pc' command with
634
no argument selects the next snapshot with the same program counter
635
(PC) as the current frame.  The `tfind tracepoint' command with no
636
argument selects the next trace snapshot collected by the same
637
tracepoint as the current one.
638
 
639
   In addition to letting you scan through the trace buffer manually,
640
these commands make it easy to construct GDB scripts that scan through
641
the trace buffer and print out whatever collected data you are
642
interested in.  Thus, if we want to examine the PC, FP, and SP
643
registers from each trace frame in the buffer, we can say this:
644
 
645
     (gdb) tfind start
646
     (gdb) while ($trace_frame != -1)
647
     > printf "Frame %d, PC = %08X, SP = %08X, FP = %08X\n", \
648
               $trace_frame, $pc, $sp, $fp
649
     > tfind
650
     > end
651
 
652
     Frame 0, PC = 0020DC64, SP = 0030BF3C, FP = 0030BF44
653
     Frame 1, PC = 0020DC6C, SP = 0030BF38, FP = 0030BF44
654
     Frame 2, PC = 0020DC70, SP = 0030BF34, FP = 0030BF44
655
     Frame 3, PC = 0020DC74, SP = 0030BF30, FP = 0030BF44
656
     Frame 4, PC = 0020DC78, SP = 0030BF2C, FP = 0030BF44
657
     Frame 5, PC = 0020DC7C, SP = 0030BF28, FP = 0030BF44
658
     Frame 6, PC = 0020DC80, SP = 0030BF24, FP = 0030BF44
659
     Frame 7, PC = 0020DC84, SP = 0030BF20, FP = 0030BF44
660
     Frame 8, PC = 0020DC88, SP = 0030BF1C, FP = 0030BF44
661
     Frame 9, PC = 0020DC8E, SP = 0030BF18, FP = 0030BF44
662
     Frame 10, PC = 00203F6C, SP = 0030BE3C, FP = 0030BF14
663
 
664
   Or, if we want to examine the variable `X' at each source line in
665
the buffer:
666
 
667
     (gdb) tfind start
668
     (gdb) while ($trace_frame != -1)
669
     > printf "Frame %d, X == %d\n", $trace_frame, X
670
     > tfind line
671
     > end
672
 
673
     Frame 0, X = 1
674
     Frame 7, X = 2
675
     Frame 13, X = 255
676
 
677

678
File: gdb.info,  Node: tdump,  Next: save-tracepoints,  Prev: tfind,  Up: Analyze Collected Data
679
 
680
`tdump'
681
-------
682
 
683
   This command takes no arguments.  It prints all the data collected at
684
the current trace snapshot.
685
 
686
     (gdb) trace 444
687
     (gdb) actions
688
     Enter actions for tracepoint #2, one per line:
689
     > collect $regs, $locals, $args, gdb_long_test
690
     > end
691
 
692
     (gdb) tstart
693
 
694
     (gdb) tfind line 444
695
     #0  gdb_test (p1=0x11, p2=0x22, p3=0x33, p4=0x44, p5=0x55, p6=0x66)
696
     at gdb_test.c:444
697
     444        printp( "%s: arguments = 0x%X 0x%X 0x%X 0x%X 0x%X 0x%X\n", )
698
 
699
     (gdb) tdump
700
     Data collected at tracepoint 2, trace frame 1:
701
     d0             0xc4aa0085       -995491707
702
     d1             0x18     24
703
     d2             0x80     128
704
     d3             0x33     51
705
     d4             0x71aea3d        119204413
706
     d5             0x22     34
707
     d6             0xe0     224
708
     d7             0x380035 3670069
709
     a0             0x19e24a 1696330
710
     a1             0x3000668        50333288
711
     a2             0x100    256
712
     a3             0x322000 3284992
713
     a4             0x3000698        50333336
714
     a5             0x1ad3cc 1758156
715
     fp             0x30bf3c 0x30bf3c
716
     sp             0x30bf34 0x30bf34
717
     ps             0x0      0
718
     pc             0x20b2c8 0x20b2c8
719
     fpcontrol      0x0      0
720
     fpstatus       0x0      0
721
     fpiaddr        0x0      0
722
     p = 0x20e5b4 "gdb-test"
723
     p1 = (void *) 0x11
724
     p2 = (void *) 0x22
725
     p3 = (void *) 0x33
726
     p4 = (void *) 0x44
727
     p5 = (void *) 0x55
728
     p6 = (void *) 0x66
729
     gdb_long_test = 17 '\021'
730
 
731
     (gdb)
732
 
733

734
File: gdb.info,  Node: save-tracepoints,  Prev: tdump,  Up: Analyze Collected Data
735
 
736
`save-tracepoints FILENAME'
737
---------------------------
738
 
739
   This command saves all current tracepoint definitions together with
740
their actions and passcounts, into a file `FILENAME' suitable for use
741
in a later debugging session.  To read the saved tracepoint
742
definitions, use the `source' command (*note Command Files::).
743
 
744

745
File: gdb.info,  Node: Tracepoint Variables,  Prev: Analyze Collected Data,  Up: Tracepoints
746
 
747
Convenience Variables for Tracepoints
748
=====================================
749
 
750
`(int) $trace_frame'
751
     The current trace snapshot (a.k.a. "frame") number, or -1 if no
752
     snapshot is selected.
753
 
754
`(int) $tracepoint'
755
     The tracepoint for the current trace snapshot.
756
 
757
`(int) $trace_line'
758
     The line number for the current trace snapshot.
759
 
760
`(char []) $trace_file'
761
     The source file for the current trace snapshot.
762
 
763
`(char []) $trace_func'
764
     The name of the function containing `$tracepoint'.
765
 
766
   Note: `$trace_file' is not suitable for use in `printf', use
767
`output' instead.
768
 
769
   Here's a simple example of using these convenience variables for
770
stepping through all the trace snapshots and printing some of their
771
data.
772
 
773
     (gdb) tfind start
774
 
775
     (gdb) while $trace_frame != -1
776
     > output $trace_file
777
     > printf ", line %d (tracepoint #%d)\n", $trace_line, $tracepoint
778
     > tfind
779
     > end
780
 
781

782
File: gdb.info,  Node: Overlays,  Next: Languages,  Prev: Tracepoints,  Up: Top
783
 
784
Debugging Programs That Use Overlays
785
************************************
786
 
787
   If your program is too large to fit completely in your target
788
system's memory, you can sometimes use "overlays" to work around this
789
problem.  GDB provides some support for debugging programs that use
790
overlays.
791
 
792
* Menu:
793
 
794
* How Overlays Work::              A general explanation of overlays.
795
* Overlay Commands::               Managing overlays in GDB.
796
* Automatic Overlay Debugging::    GDB can find out which overlays are
797
                                   mapped by asking the inferior.
798
* Overlay Sample Program::         A sample program using overlays.
799
 
800

801
File: gdb.info,  Node: How Overlays Work,  Next: Overlay Commands,  Up: Overlays
802
 
803
How Overlays Work
804
=================
805
 
806
   Suppose you have a computer whose instruction address space is only
807
64 kilobytes long, but which has much more memory which can be accessed
808
by other means: special instructions, segment registers, or memory
809
management hardware, for example.  Suppose further that you want to
810
adapt a program which is larger than 64 kilobytes to run on this system.
811
 
812
   One solution is to identify modules of your program which are
813
relatively independent, and need not call each other directly; call
814
these modules "overlays".  Separate the overlays from the main program,
815
and place their machine code in the larger memory.  Place your main
816
program in instruction memory, but leave at least enough space there to
817
hold the largest overlay as well.
818
 
819
   Now, to call a function located in an overlay, you must first copy
820
that overlay's machine code from the large memory into the space set
821
aside for it in the instruction memory, and then jump to its entry point
822
there.
823
 
824
         Data             Instruction            Larger
825
     Address Space       Address Space        Address Space
826
     +-----------+       +-----------+        +-----------+
827
     |           |       |           |        |           |
828
     +-----------+       +-----------+        +-----------+<-- overlay 1
829
     | program   |       |   main    |   .----| overlay 1 | load address
830
     | variables |       |  program  |   |    +-----------+
831
     | and heap  |       |           |   |    |           |
832
     +-----------+       |           |   |    +-----------+<-- overlay 2
833
     |           |       +-----------+   |    |           | load address
834
     +-----------+       |           |   |  .-| overlay 2 |
835
                         |           |   |  | |           |
836
              mapped --->+-----------+   |  | +-----------+
837
              address    |           |   |  | |           |
838
                         |  overlay  | <-'  | |           |
839
                         |   area    |  <---' +-----------+<-- overlay 3
840
                         |           | <---.  |           | load address
841
                         +-----------+     `--| overlay 3 |
842
                         |           |        |           |
843
                         +-----------+        |           |
844
                                              +-----------+
845
                                              |           |
846
                                              +-----------+
847
 
848
                         A code overlay
849
 
850
   The diagram (*note A code overlay::) shows a system with separate
851
data and instruction address spaces.  To map an overlay, the program
852
copies its code from the larger address space to the instruction
853
address space.  Since the overlays shown here all use the same mapped
854
address, only one may be mapped at a time.  For a system with a single
855
address space for data and instructions, the diagram would be similar,
856
except that the program variables and heap would share an address space
857
with the main program and the overlay area.
858
 
859
   An overlay loaded into instruction memory and ready for use is
860
called a "mapped" overlay; its "mapped address" is its address in the
861
instruction memory.  An overlay not present (or only partially present)
862
in instruction memory is called "unmapped"; its "load address" is its
863
address in the larger memory.  The mapped address is also called the
864
"virtual memory address", or "VMA"; the load address is also called the
865
"load memory address", or "LMA".
866
 
867
   Unfortunately, overlays are not a completely transparent way to
868
adapt a program to limited instruction memory.  They introduce a new
869
set of global constraints you must keep in mind as you design your
870
program:
871
 
872
   * Before calling or returning to a function in an overlay, your
873
     program must make sure that overlay is actually mapped.
874
     Otherwise, the call or return will transfer control to the right
875
     address, but in the wrong overlay, and your program will probably
876
     crash.
877
 
878
   * If the process of mapping an overlay is expensive on your system,
879
     you will need to choose your overlays carefully to minimize their
880
     effect on your program's performance.
881
 
882
   * The executable file you load onto your system must contain each
883
     overlay's instructions, appearing at the overlay's load address,
884
     not its mapped address.  However, each overlay's instructions must
885
     be relocated and its symbols defined as if the overlay were at its
886
     mapped address.  You can use GNU linker scripts to specify
887
     different load and relocation addresses for pieces of your
888
     program; see *Note Overlay Description: (ld.info)Overlay
889
     Description.
890
 
891
   * The procedure for loading executable files onto your system must
892
     be able to load their contents into the larger address space as
893
     well as the instruction and data spaces.
894
 
895
 
896
   The overlay system described above is rather simple, and could be
897
improved in many ways:
898
 
899
   * If your system has suitable bank switch registers or memory
900
     management hardware, you could use those facilities to make an
901
     overlay's load area contents simply appear at their mapped address
902
     in instruction space.  This would probably be faster than copying
903
     the overlay to its mapped area in the usual way.
904
 
905
   * If your overlays are small enough, you could set aside more than
906
     one overlay area, and have more than one overlay mapped at a time.
907
 
908
   * You can use overlays to manage data, as well as instructions.  In
909
     general, data overlays are even less transparent to your design
910
     than code overlays: whereas code overlays only require care when
911
     you call or return to functions, data overlays require care every
912
     time you access the data.  Also, if you change the contents of a
913
     data overlay, you must copy its contents back out to its load
914
     address before you can copy a different data overlay into the same
915
     mapped area.
916
 
917
 
918

919
File: gdb.info,  Node: Overlay Commands,  Next: Automatic Overlay Debugging,  Prev: How Overlays Work,  Up: Overlays
920
 
921
Overlay Commands
922
================
923
 
924
   To use GDB's overlay support, each overlay in your program must
925
correspond to a separate section of the executable file.  The section's
926
virtual memory address and load memory address must be the overlay's
927
mapped and load addresses.  Identifying overlays with sections allows
928
GDB to determine the appropriate address of a function or variable,
929
depending on whether the overlay is mapped or not.
930
 
931
   GDB's overlay commands all start with the word `overlay'; you can
932
abbreviate this as `ov' or `ovly'.  The commands are:
933
 
934
`overlay off'
935
     Disable GDB's overlay support.  When overlay support is disabled,
936
     GDB assumes that all functions and variables are always present at
937
     their mapped addresses.  By default, GDB's overlay support is
938
     disabled.
939
 
940
`overlay manual'
941
     Enable "manual" overlay debugging.  In this mode, GDB relies on
942
     you to tell it which overlays are mapped, and which are not, using
943
     the `overlay map-overlay' and `overlay unmap-overlay' commands
944
     described below.
945
 
946
`overlay map-overlay OVERLAY'
947
`overlay map OVERLAY'
948
     Tell GDB that OVERLAY is now mapped; OVERLAY must be the name of
949
     the object file section containing the overlay.  When an overlay
950
     is mapped, GDB assumes it can find the overlay's functions and
951
     variables at their mapped addresses.  GDB assumes that any other
952
     overlays whose mapped ranges overlap that of OVERLAY are now
953
     unmapped.
954
 
955
`overlay unmap-overlay OVERLAY'
956
`overlay unmap OVERLAY'
957
     Tell GDB that OVERLAY is no longer mapped; OVERLAY must be the
958
     name of the object file section containing the overlay.  When an
959
     overlay is unmapped, GDB assumes it can find the overlay's
960
     functions and variables at their load addresses.
961
 
962
`overlay auto'
963
     Enable "automatic" overlay debugging.  In this mode, GDB consults
964
     a data structure the overlay manager maintains in the inferior to
965
     see which overlays are mapped.  For details, see *Note Automatic
966
     Overlay Debugging::.
967
 
968
`overlay load-target'
969
`overlay load'
970
     Re-read the overlay table from the inferior.  Normally, GDB
971
     re-reads the table GDB automatically each time the inferior stops,
972
     so this command should only be necessary if you have changed the
973
     overlay mapping yourself using GDB.  This command is only useful
974
     when using automatic overlay debugging.
975
 
976
`overlay list-overlays'
977
`overlay list'
978
     Display a list of the overlays currently mapped, along with their
979
     mapped addresses, load addresses, and sizes.
980
 
981
   Normally, when GDB prints a code address, it includes the name of
982
the function the address falls in:
983
 
984
     (gdb) print main
985
     $3 = {int ()} 0x11a0 
986
 
987
When overlay debugging is enabled, GDB recognizes code in unmapped
988
overlays, and prints the names of unmapped functions with asterisks
989
around them.  For example, if `foo' is a function in an unmapped
990
overlay, GDB prints it this way:
991
 
992
     (gdb) overlay list
993
     No sections are mapped.
994
     (gdb) print foo
995
     $5 = {int (int)} 0x100000 <*foo*>
996
 
997
When `foo''s overlay is mapped, GDB prints the function's name normally:
998
 
999
     (gdb) overlay list
1000
     Section .ov.foo.text, loaded at 0x100000 - 0x100034,
1001
             mapped at 0x1016 - 0x104a
1002
     (gdb) print foo
1003
     $6 = {int (int)} 0x1016 
1004
 
1005
   When overlay debugging is enabled, GDB can find the correct address
1006
for functions and variables in an overlay, whether or not the overlay
1007
is mapped.  This allows most GDB commands, like `break' and
1008
`disassemble', to work normally, even on unmapped code.  However, GDB's
1009
breakpoint support has some limitations:
1010
 
1011
   * You can set breakpoints in functions in unmapped overlays, as long
1012
     as GDB can write to the overlay at its load address.
1013
 
1014
   * GDB can not set hardware or simulator-based breakpoints in
1015
     unmapped overlays.  However, if you set a breakpoint at the end of
1016
     your overlay manager (and tell GDB which overlays are now mapped,
1017
     if you are using manual overlay management), GDB will re-set its
1018
     breakpoints properly.
1019
 
1020

1021
File: gdb.info,  Node: Automatic Overlay Debugging,  Next: Overlay Sample Program,  Prev: Overlay Commands,  Up: Overlays
1022
 
1023
Automatic Overlay Debugging
1024
===========================
1025
 
1026
   GDB can automatically track which overlays are mapped and which are
1027
not, given some simple co-operation from the overlay manager in the
1028
inferior.  If you enable automatic overlay debugging with the `overlay
1029
auto' command (*note Overlay Commands::), GDB looks in the inferior's
1030
memory for certain variables describing the current state of the
1031
overlays.
1032
 
1033
   Here are the variables your overlay manager must define to support
1034
GDB's automatic overlay debugging:
1035
 
1036
`_ovly_table':
1037
     This variable must be an array of the following structures:
1038
 
1039
          struct
1040
          {
1041
            /* The overlay's mapped address.  */
1042
            unsigned long vma;
1043
 
1044
            /* The size of the overlay, in bytes.  */
1045
            unsigned long size;
1046
 
1047
            /* The overlay's load address.  */
1048
            unsigned long lma;
1049
 
1050
            /* Non-zero if the overlay is currently mapped;
1051
               zero otherwise.  */
1052
            unsigned long mapped;
1053
          }
1054
 
1055
`_novlys':
1056
     This variable must be a four-byte signed integer, holding the total
1057
     number of elements in `_ovly_table'.
1058
 
1059
   To decide whether a particular overlay is mapped or not, GDB looks
1060
for an entry in `_ovly_table' whose `vma' and `lma' members equal the
1061
VMA and LMA of the overlay's section in the executable file.  When GDB
1062
finds a matching entry, it consults the entry's `mapped' member to
1063
determine whether the overlay is currently mapped.
1064
 
1065
   In addition, your overlay manager may define a function called
1066
`_ovly_debug_event'.  If this function is defined, GDB will silently
1067
set a breakpoint there.  If the overlay manager then calls this
1068
function whenever it has changed the overlay table, this will enable
1069
GDB to accurately keep track of which overlays are in program memory,
1070
and update any breakpoints that may be set in overlays.  This will
1071
allow breakpoints to work even if the overlays are kept in ROM or other
1072
non-writable memory while they are not being executed.
1073
 
1074

1075
File: gdb.info,  Node: Overlay Sample Program,  Prev: Automatic Overlay Debugging,  Up: Overlays
1076
 
1077
Overlay Sample Program
1078
======================
1079
 
1080
   When linking a program which uses overlays, you must place the
1081
overlays at their load addresses, while relocating them to run at their
1082
mapped addresses.  To do this, you must write a linker script (*note
1083
Overlay Description: (ld.info)Overlay Description.).  Unfortunately,
1084
since linker scripts are specific to a particular host system, target
1085
architecture, and target memory layout, this manual cannot provide
1086
portable sample code demonstrating GDB's overlay support.
1087
 
1088
   However, the GDB source distribution does contain an overlaid
1089
program, with linker scripts for a few systems, as part of its test
1090
suite.  The program consists of the following files from
1091
`gdb/testsuite/gdb.base':
1092
 
1093
`overlays.c'
1094
     The main program file.
1095
 
1096
`ovlymgr.c'
1097
     A simple overlay manager, used by `overlays.c'.
1098
 
1099
`foo.c'
1100
`bar.c'
1101
`baz.c'
1102
`grbx.c'
1103
     Overlay modules, loaded and used by `overlays.c'.
1104
 
1105
`d10v.ld'
1106
`m32r.ld'
1107
     Linker scripts for linking the test program on the `d10v-elf' and
1108
     `m32r-elf' targets.
1109
 
1110
   You can build the test program using the `d10v-elf' GCC
1111
cross-compiler like this:
1112
 
1113
     $ d10v-elf-gcc -g -c overlays.c
1114
     $ d10v-elf-gcc -g -c ovlymgr.c
1115
     $ d10v-elf-gcc -g -c foo.c
1116
     $ d10v-elf-gcc -g -c bar.c
1117
     $ d10v-elf-gcc -g -c baz.c
1118
     $ d10v-elf-gcc -g -c grbx.c
1119
     $ d10v-elf-gcc -g overlays.o ovlymgr.o foo.o bar.o \
1120
                       baz.o grbx.o -Wl,-Td10v.ld -o overlays
1121
 
1122
   The build process is identical for any other architecture, except
1123
that you must substitute the appropriate compiler and linker script for
1124
the target system for `d10v-elf-gcc' and `d10v.ld'.
1125
 
1126

1127
File: gdb.info,  Node: Languages,  Next: Symbols,  Prev: Overlays,  Up: Top
1128
 
1129
Using GDB with Different Languages
1130
**********************************
1131
 
1132
   Although programming languages generally have common aspects, they
1133
are rarely expressed in the same manner.  For instance, in ANSI C,
1134
dereferencing a pointer `p' is accomplished by `*p', but in Modula-2,
1135
it is accomplished by `p^'.  Values can also be represented (and
1136
displayed) differently.  Hex numbers in C appear as `0x1ae', while in
1137
Modula-2 they appear as `1AEH'.
1138
 
1139
   Language-specific information is built into GDB for some languages,
1140
allowing you to express operations like the above in your program's
1141
native language, and allowing GDB to output values in a manner
1142
consistent with the syntax of your program's native language.  The
1143
language you use to build expressions is called the "working language".
1144
 
1145
* Menu:
1146
 
1147
* Setting::                     Switching between source languages
1148
* Show::                        Displaying the language
1149
* Checks::                      Type and range checks
1150
* Support::                     Supported languages
1151
 
1152

1153
File: gdb.info,  Node: Setting,  Next: Show,  Up: Languages
1154
 
1155
Switching between source languages
1156
==================================
1157
 
1158
   There are two ways to control the working language--either have GDB
1159
set it automatically, or select it manually yourself.  You can use the
1160
`set language' command for either purpose.  On startup, GDB defaults to
1161
setting the language automatically.  The working language is used to
1162
determine how expressions you type are interpreted, how values are
1163
printed, etc.
1164
 
1165
   In addition to the working language, every source file that GDB
1166
knows about has its own working language.  For some object file
1167
formats, the compiler might indicate which language a particular source
1168
file is in.  However, most of the time GDB infers the language from the
1169
name of the file.  The language of a source file controls whether C++
1170
names are demangled--this way `backtrace' can show each frame
1171
appropriately for its own language.  There is no way to set the
1172
language of a source file from within GDB, but you can set the language
1173
associated with a filename extension.  *Note Displaying the language:
1174
Show.
1175
 
1176
   This is most commonly a problem when you use a program, such as
1177
`cfront' or `f2c', that generates C but is written in another language.
1178
In that case, make the program use `#line' directives in its C output;
1179
that way GDB will know the correct language of the source code of the
1180
original program, and will display that source code, not the generated
1181
C code.
1182
 
1183
* Menu:
1184
 
1185
* Filenames::                   Filename extensions and languages.
1186
* Manually::                    Setting the working language manually
1187
* Automatically::               Having GDB infer the source language
1188
 
1189

1190
File: gdb.info,  Node: Filenames,  Next: Manually,  Up: Setting
1191
 
1192
List of filename extensions and languages
1193
-----------------------------------------
1194
 
1195
   If a source file name ends in one of the following extensions, then
1196
GDB infers that its language is the one indicated.
1197
 
1198
`.c'
1199
     C source file
1200
 
1201
`.C'
1202
`.cc'
1203
`.cp'
1204
`.cpp'
1205
`.cxx'
1206
`.c++'
1207
     C++ source file
1208
 
1209
`.f'
1210
`.F'
1211
     Fortran source file
1212
 
1213
`.mod'
1214
     Modula-2 source file
1215
 
1216
`.s'
1217
`.S'
1218
     Assembler source file.  This actually behaves almost like C, but
1219
     GDB does not skip over function prologues when stepping.
1220
 
1221
   In addition, you may set the language associated with a filename
1222
extension.  *Note Displaying the language: Show.
1223
 
1224

1225
File: gdb.info,  Node: Manually,  Next: Automatically,  Prev: Filenames,  Up: Setting
1226
 
1227
Setting the working language
1228
----------------------------
1229
 
1230
   If you allow GDB to set the language automatically, expressions are
1231
interpreted the same way in your debugging session and your program.
1232
 
1233
   If you wish, you may set the language manually.  To do this, issue
1234
the command `set language LANG', where LANG is the name of a language,
1235
such as `c' or `modula-2'.  For a list of the supported languages, type
1236
`set language'.
1237
 
1238
   Setting the language manually prevents GDB from updating the working
1239
language automatically.  This can lead to confusion if you try to debug
1240
a program when the working language is not the same as the source
1241
language, when an expression is acceptable to both languages--but means
1242
different things.  For instance, if the current source file were
1243
written in C, and GDB was parsing Modula-2, a command such as:
1244
 
1245
     print a = b + c
1246
 
1247
might not have the effect you intended.  In C, this means to add `b'
1248
and `c' and place the result in `a'.  The result printed would be the
1249
value of `a'.  In Modula-2, this means to compare `a' to the result of
1250
`b+c', yielding a `BOOLEAN' value.
1251
 
1252

1253
File: gdb.info,  Node: Automatically,  Prev: Manually,  Up: Setting
1254
 
1255
Having GDB infer the source language
1256
------------------------------------
1257
 
1258
   To have GDB set the working language automatically, use `set
1259
language local' or `set language auto'.  GDB then infers the working
1260
language.  That is, when your program stops in a frame (usually by
1261
encountering a breakpoint), GDB sets the working language to the
1262
language recorded for the function in that frame.  If the language for
1263
a frame is unknown (that is, if the function or block corresponding to
1264
the frame was defined in a source file that does not have a recognized
1265
extension), the current working language is not changed, and GDB issues
1266
a warning.
1267
 
1268
   This may not seem necessary for most programs, which are written
1269
entirely in one source language.  However, program modules and libraries
1270
written in one source language can be used by a main program written in
1271
a different source language.  Using `set language auto' in this case
1272
frees you from having to set the working language manually.
1273
 
1274

1275
File: gdb.info,  Node: Show,  Next: Checks,  Prev: Setting,  Up: Languages
1276
 
1277
Displaying the language
1278
=======================
1279
 
1280
   The following commands help you find out which language is the
1281
working language, and also what language source files were written in.
1282
 
1283
`show language'
1284
     Display the current working language.  This is the language you
1285
     can use with commands such as `print' to build and compute
1286
     expressions that may involve variables in your program.
1287
 
1288
`info frame'
1289
     Display the source language for this frame.  This language becomes
1290
     the working language if you use an identifier from this frame.
1291
     *Note Information about a frame: Frame Info, to identify the other
1292
     information listed here.
1293
 
1294
`info source'
1295
     Display the source language of this source file.  *Note Examining
1296
     the Symbol Table: Symbols, to identify the other information
1297
     listed here.
1298
 
1299
   In unusual circumstances, you may have source files with extensions
1300
not in the standard list.  You can then set the extension associated
1301
with a language explicitly:
1302
 
1303
`set extension-language .EXT LANGUAGE'
1304
     Set source files with extension .EXT to be assumed to be in the
1305
     source language LANGUAGE.
1306
 
1307
`info extensions'
1308
     List all the filename extensions and the associated languages.
1309
 

powered by: WebSVN 2.1.0

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