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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [gdb-5.0/] [gdb/] [doc/] [gdb.info-5] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 362 markom
This is ./gdb.info, produced by makeinfo version 4.0 from gdb.texinfo.
2 106 markom
 
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 Eighth Edition, March 2000, of `Debugging with GDB: the
11
GNU Source-Level Debugger' for GDB Version 5.0.
12
 
13
   Copyright (C) 1988-2000 Free Software Foundation, Inc.
14
 
15
   Permission is granted to make and distribute verbatim copies of this
16
manual provided the copyright notice and this permission notice are
17
preserved on all copies.
18
 
19
   Permission is granted to copy and distribute modified versions of
20
this manual under the conditions for verbatim copying, provided also
21
that the entire resulting derived work is distributed under the terms
22
of a permission notice identical to this one.
23
 
24
   Permission is granted to copy and distribute translations of this
25
manual into another language, under the above conditions for modified
26
versions.
27
 
28

29
File: gdb.info,  Node: Range Checking,  Prev: Type Checking,  Up: Checks
30
 
31
An overview of range checking
32
-----------------------------
33
 
34
   In some languages (such as Modula-2), it is an error to exceed the
35
bounds of a type; this is enforced with run-time checks.  Such range
36
checking is meant to ensure program correctness by making sure
37
computations do not overflow, or indices on an array element access do
38
not exceed the bounds of the array.
39
 
40
   For expressions you use in GDB commands, you can tell GDB to treat
41
range errors in one of three ways: ignore them, always treat them as
42
errors and abandon the expression, or issue warnings but evaluate the
43
expression anyway.
44
 
45
   A range error can result from numerical overflow, from exceeding an
46
array index bound, or when you type a constant that is not a member of
47
any type.  Some languages, however, do not treat overflows as an error.
48
In many implementations of C, mathematical overflow causes the result
49
to "wrap around" to lower values--for example, if M is the largest
50
integer value, and S is the smallest, then
51
 
52
     M + 1 => S
53
 
54
   This, too, is specific to individual languages, and in some cases
55
specific to individual compilers or machines.  *Note Supported
56
languages: Support, for further details on specific languages.
57
 
58
   GDB provides some additional commands for controlling the range
59
checker:
60
 
61
`set check range auto'
62
     Set range checking on or off based on the current working language.
63
     *Note Supported languages: Support, for the default settings for
64
     each language.
65
 
66
`set check range on'
67
`set check range off'
68
     Set range checking on or off, overriding the default setting for
69
     the current working language.  A warning is issued if the setting
70
     does not match the language default.  If a range error occurs and
71
     range checking is on, then a message is printed and evaluation of
72
     the expression is aborted.
73
 
74
`set check range warn'
75
     Output messages when the GDB range checker detects a range error,
76
     but attempt to evaluate the expression anyway.  Evaluating the
77
     expression may still be impossible for other reasons, such as
78
     accessing memory that the process does not own (a typical example
79
     from many Unix systems).
80
 
81
`show range'
82
     Show the current setting of the range checker, and whether or not
83
     it is being set automatically by GDB.
84
 
85

86
File: gdb.info,  Node: Support,  Prev: Checks,  Up: Languages
87
 
88
Supported languages
89
===================
90
 
91
   GDB supports C, C++, Fortran, Java, Chill, assembly, and Modula-2.
92
Some GDB features may be used in expressions regardless of the language
93
you use: the GDB `@' and `::' operators, and the `{type}addr' construct
94
(*note Expressions: Expressions.) can be used with the constructs of
95
any supported language.
96
 
97
   The following sections detail to what degree each source language is
98
supported by GDB.  These sections are not meant to be language
99
tutorials or references, but serve only as a reference guide to what the
100
GDB expression parser accepts, and what input and output formats should
101
look like for different languages.  There are many good books written
102
on each of these languages; please look to these for a language
103
reference or tutorial.
104
 
105
* Menu:
106
 
107
* C::           C and C++
108
* Modula-2::    Modula-2
109
* Chill::        Chill
110
 
111

112
File: gdb.info,  Node: C,  Next: Modula-2,  Up: Support
113
 
114
C and C++
115
---------
116
 
117
   Since C and C++ are so closely related, many features of GDB apply
118
to both languages.  Whenever this is the case, we discuss those
119
languages together.
120
 
121
   The C++ debugging facilities are jointly implemented by the C++
122
compiler and GDB.  Therefore, to debug your C++ code effectively, you
123
must compile your C++ programs with a supported C++ compiler, such as
124
GNU `g++', or the HP ANSI C++ compiler (`aCC').
125
 
126
   For best results when using GNU C++, use the stabs debugging format.
127
You can select that format explicitly with the `g++' command-line
128
options `-gstabs' or `-gstabs+'.  See *Note Options for Debugging Your
129
Program or GNU CC: (gcc.info)Debugging Options, for more information.
130
 
131
* Menu:
132
 
133
* C Operators::                 C and C++ operators
134
* C Constants::                 C and C++ constants
135
* C plus plus expressions::     C++ expressions
136
* C Defaults::                  Default settings for C and C++
137
* C Checks::                    C and C++ type and range checks
138
* Debugging C::                 GDB and C
139
* Debugging C plus plus::       GDB features for C++
140
 
141

142
File: gdb.info,  Node: C Operators,  Next: C Constants,  Up: C
143
 
144
C and C++ operators
145
...................
146
 
147
   Operators must be defined on values of specific types.  For instance,
148
`+' is defined on numbers, but not on structures.  Operators are often
149
defined on groups of types.
150
 
151
   For the purposes of C and C++, the following definitions hold:
152
 
153
   * _Integral types_ include `int' with any of its storage-class
154
     specifiers; `char'; `enum'; and, for C++, `bool'.
155
 
156
   * _Floating-point types_ include `float', `double', and `long
157
     double' (if supported by the target platform).
158
 
159
   * _Pointer types_ include all types defined as `(TYPE *)'.
160
 
161
   * _Scalar types_ include all of the above.
162
 
163
 
164
The following operators are supported.  They are listed here in order
165
of increasing precedence:
166
 
167
`,'
168
     The comma or sequencing operator.  Expressions in a
169
     comma-separated list are evaluated from left to right, with the
170
     result of the entire expression being the last expression
171
     evaluated.
172
 
173
`='
174
     Assignment.  The value of an assignment expression is the value
175
     assigned.  Defined on scalar types.
176
 
177
`OP='
178
     Used in an expression of the form `A OP= B', and translated to
179
     `A = A OP B'.  `OP=' and `=' have the same precedence.  OP is any
180
     one of the operators `|', `^', `&', `<<', `>>', `+', `-', `*',
181
     `/', `%'.
182
 
183
`?:'
184
     The ternary operator.  `A ? B : C' can be thought of as:  if A
185
     then B else C.  A should be of an integral type.
186
 
187
`||'
188
     Logical OR.  Defined on integral types.
189
 
190
`&&'
191
     Logical AND.  Defined on integral types.
192
 
193
`|'
194
     Bitwise OR.  Defined on integral types.
195
 
196
`^'
197
     Bitwise exclusive-OR.  Defined on integral types.
198
 
199
`&'
200
     Bitwise AND.  Defined on integral types.
201
 
202
`==, !='
203
     Equality and inequality.  Defined on scalar types.  The value of
204
     these expressions is 0 for false and non-zero for true.
205
 
206
`<, >, <=, >='
207
     Less than, greater than, less than or equal, greater than or equal.
208
     Defined on scalar types.  The value of these expressions is 0 for
209
     false and non-zero for true.
210
 
211
`<<, >>'
212
     left shift, and right shift.  Defined on integral types.
213
 
214
`@'
215
     The GDB "artificial array" operator (*note Expressions:
216
     Expressions.).
217
 
218
`+, -'
219
     Addition and subtraction.  Defined on integral types,
220
     floating-point types and pointer types.
221
 
222
`*, /, %'
223
     Multiplication, division, and modulus.  Multiplication and
224
     division are defined on integral and floating-point types.
225
     Modulus is defined on integral types.
226
 
227
`++, --'
228
     Increment and decrement.  When appearing before a variable, the
229
     operation is performed before the variable is used in an
230
     expression; when appearing after it, the variable's value is used
231
     before the operation takes place.
232
 
233
`*'
234
     Pointer dereferencing.  Defined on pointer types.  Same precedence
235
     as `++'.
236
 
237
`&'
238
     Address operator.  Defined on variables.  Same precedence as `++'.
239
 
240
     For debugging C++, GDB implements a use of `&' beyond what is
241
     allowed in the C++ language itself: you can use `&(&REF)' (or, if
242
     you prefer, simply `&&REF') to examine the address where a C++
243
     reference variable (declared with `&REF') is stored.
244
 
245
`-'
246
     Negative.  Defined on integral and floating-point types.  Same
247
     precedence as `++'.
248
 
249
`!'
250
     Logical negation.  Defined on integral types.  Same precedence as
251
     `++'.
252
 
253
`~'
254
     Bitwise complement operator.  Defined on integral types.  Same
255
     precedence as `++'.
256
 
257
`., ->'
258
     Structure member, and pointer-to-structure member.  For
259
     convenience, GDB regards the two as equivalent, choosing whether
260
     to dereference a pointer based on the stored type information.
261
     Defined on `struct' and `union' data.
262
 
263
`.*, ->*'
264
     Dereferences of pointers to members.
265
 
266
`[]'
267
     Array indexing.  `A[I]' is defined as `*(A+I)'.  Same precedence
268
     as `->'.
269
 
270
`()'
271
     Function parameter list.  Same precedence as `->'.
272
 
273
`::'
274
     C++ scope resolution operator.  Defined on `struct', `union', and
275
     `class' types.
276
 
277
`::'
278
     Doubled colons also represent the GDB scope operator (*note
279
     Expressions: Expressions.).  Same precedence as `::', above.
280
 
281
   If an operator is redefined in the user code, GDB usually attempts
282
to invoke the redefined version instead of using the operator's
283
predefined meaning.
284
 
285
* Menu:
286
 
287
* C Constants::
288
 
289

290
File: gdb.info,  Node: C Constants,  Next: C plus plus expressions,  Prev: C Operators,  Up: C
291
 
292
C and C++ constants
293
...................
294
 
295
   GDB allows you to express the constants of C and C++ in the
296
following ways:
297
 
298
   * Integer constants are a sequence of digits.  Octal constants are
299
     specified by a leading `0' (i.e. zero), and hexadecimal constants
300
     by a leading `0x' or `0X'.  Constants may also end with a letter
301
     `l', specifying that the constant should be treated as a `long'
302
     value.
303
 
304
   * Floating point constants are a sequence of digits, followed by a
305
     decimal point, followed by a sequence of digits, and optionally
306
     followed by an exponent.  An exponent is of the form:
307
     `e[[+]|-]NNN', where NNN is another sequence of digits.  The `+'
308
     is optional for positive exponents.  A floating-point constant may
309
     also end with a letter `f' or `F', specifying that the constant
310
     should be treated as being of the `float' (as opposed to the
311
     default `double') type; or with a letter `l' or `L', which
312
     specifies a `long double' constant.
313
 
314
   * Enumerated constants consist of enumerated identifiers, or their
315
     integral equivalents.
316
 
317
   * Character constants are a single character surrounded by single
318
     quotes (`''), or a number--the ordinal value of the corresponding
319
     character (usually its ASCII value).  Within quotes, the single
320
     character may be represented by a letter or by "escape sequences",
321
     which are of the form `\NNN', where NNN is the octal representation
322
     of the character's ordinal value; or of the form `\X', where `X'
323
     is a predefined special character--for example, `\n' for newline.
324
 
325
   * String constants are a sequence of character constants surrounded
326
     by double quotes (`"').  Any valid character constant (as described
327
     above) may appear.  Double quotes within the string must be
328
     preceded by a backslash, so for instance `"a\"b'c"' is a string of
329
     five characters.
330
 
331
   * Pointer constants are an integral value.  You can also write
332
     pointers to constants using the C operator `&'.
333
 
334
   * Array constants are comma-separated lists surrounded by braces `{'
335
     and `}'; for example, `{1,2,3}' is a three-element array of
336
     integers, `{{1,2}, {3,4}, {5,6}}' is a three-by-two array, and
337
     `{&"hi", &"there", &"fred"}' is a three-element array of pointers.
338
 
339
* Menu:
340
 
341
* C plus plus expressions::
342
* C Defaults::
343
* C Checks::
344
 
345
* Debugging C::
346
 
347

348
File: gdb.info,  Node: C plus plus expressions,  Next: C Defaults,  Prev: C Constants,  Up: C
349
 
350
C++ expressions
351
...............
352
 
353
   GDB expression handling can interpret most C++ expressions.
354
 
355
     _Warning:_ GDB can only debug C++ code if you use the proper
356
     compiler.  Typically, C++ debugging depends on the use of
357
     additional debugging information in the symbol table, and thus
358
     requires special support.  In particular, if your compiler
359
     generates a.out, MIPS ECOFF, RS/6000 XCOFF, or ELF with stabs
360
     extensions to the symbol table, these facilities are all
361
     available.  (With GNU CC, you can use the `-gstabs' option to
362
     request stabs debugging extensions explicitly.)  Where the object
363
     code format is standard COFF or DWARF in ELF, on the other hand,
364
     most of the C++ support in GDB does _not_ work.
365
 
366
  1. Member function calls are allowed; you can use expressions like
367
 
368
          count = aml->GetOriginal(x, y)
369
 
370
  2. While a member function is active (in the selected stack frame),
371
     your expressions have the same namespace available as the member
372
     function; that is, GDB allows implicit references to the class
373
     instance pointer `this' following the same rules as C++.
374
 
375
  3. You can call overloaded functions; GDB resolves the function call
376
     to the right definition, with some restrictions.  GDB does not
377
     perform overload resolution involving user-defined type
378
     conversions, calls to constructors, or instantiations of templates
379
     that do not exist in the program.  It also cannot handle ellipsis
380
     argument lists or default arguments.
381
 
382
     It does perform integral conversions and promotions, floating-point
383
     promotions, arithmetic conversions, pointer conversions,
384
     conversions of class objects to base classes, and standard
385
     conversions such as those of functions or arrays to pointers; it
386
     requires an exact match on the number of function arguments.
387
 
388
     Overload resolution is always performed, unless you have specified
389
     `set overload-resolution off'.  *Note GDB features for C++:
390
     Debugging C plus plus.
391
 
392
     You must specify `set overload-resolution off' in order to use an
393
     explicit function signature to call an overloaded function, as in
394
          p 'foo(char,int)'('x', 13)
395
 
396
     The GDB command-completion facility can simplify this; see *Note
397
     Command completion: Completion.
398
 
399
  4. GDB understands variables declared as C++ references; you can use
400
     them in expressions just as you do in C++ source--they are
401
     automatically dereferenced.
402
 
403
     In the parameter list shown when GDB displays a frame, the values
404
     of reference variables are not displayed (unlike other variables);
405
     this avoids clutter, since references are often used for large
406
     structures.  The _address_ of a reference variable is always
407
     shown, unless you have specified `set print address off'.
408
 
409
  5. GDB supports the C++ name resolution operator `::'--your
410
     expressions can use it just as expressions in your program do.
411
     Since one scope may be defined in another, you can use `::'
412
     repeatedly if necessary, for example in an expression like
413
     `SCOPE1::SCOPE2::NAME'.  GDB also allows resolving name scope by
414
     reference to source files, in both C and C++ debugging (*note
415
     Program variables: Variables.).
416
 
417
   In addition, when used with HP's C++ compiler, GDB supports calling
418
virtual functions correctly, printing out virtual bases of objects,
419
calling functions in a base subobject, casting objects, and invoking
420
user-defined operators.
421
 
422

423
File: gdb.info,  Node: C Defaults,  Next: C Checks,  Prev: C plus plus expressions,  Up: C
424
 
425
C and C++ defaults
426
..................
427
 
428
   If you allow GDB to set type and range checking automatically, they
429
both default to `off' whenever the working language changes to C or
430
C++.  This happens regardless of whether you or GDB selects the working
431
language.
432
 
433
   If you allow GDB to set the language automatically, it recognizes
434
source files whose names end with `.c', `.C', or `.cc', etc, and when
435
GDB enters code compiled from one of these files, it sets the working
436
language to C or C++.  *Note Having GDB infer the source language:
437
Automatically, for further details.
438
 
439

440
File: gdb.info,  Node: C Checks,  Next: Debugging C,  Prev: C Defaults,  Up: C
441
 
442
C and C++ type and range checks
443
...............................
444
 
445
   By default, when GDB parses C or C++ expressions, type checking is
446
not used.  However, if you turn type checking on, GDB considers two
447
variables type equivalent if:
448
 
449
   * The two variables are structured and have the same structure,
450
     union, or enumerated tag.
451
 
452
   * The two variables have the same type name, or types that have been
453
     declared equivalent through `typedef'.
454
 
455
 
456
   Range checking, if turned on, is done on mathematical operations.
457
Array indices are not checked, since they are often used to index a
458
pointer that is not itself an array.
459
 
460

461
File: gdb.info,  Node: Debugging C,  Next: Debugging C plus plus,  Prev: C Checks,  Up: C
462
 
463
GDB and C
464
.........
465
 
466
   The `set print union' and `show print union' commands apply to the
467
`union' type.  When set to `on', any `union' that is inside a `struct'
468
or `class' is also printed.  Otherwise, it appears as `{...}'.
469
 
470
   The `@' operator aids in the debugging of dynamic arrays, formed
471
with pointers and a memory allocation function.  *Note Expressions:
472
Expressions.
473
 
474
* Menu:
475
 
476
* Debugging C plus plus::
477
 
478

479
File: gdb.info,  Node: Debugging C plus plus,  Prev: Debugging C,  Up: C
480
 
481
GDB features for C++
482
....................
483
 
484
   Some GDB commands are particularly useful with C++, and some are
485
designed specifically for use with C++.  Here is a summary:
486
 
487
`breakpoint menus'
488
     When you want a breakpoint in a function whose name is overloaded,
489
     GDB breakpoint menus help you specify which function definition
490
     you want.  *Note Breakpoint menus: Breakpoint Menus.
491
 
492
`rbreak REGEX'
493
     Setting breakpoints using regular expressions is helpful for
494
     setting breakpoints on overloaded functions that are not members
495
     of any special classes.  *Note Setting breakpoints: Set Breaks.
496
 
497
`catch throw'
498
`catch catch'
499
     Debug C++ exception handling using these commands.  *Note Setting
500
     catchpoints: Set Catchpoints.
501
 
502
`ptype TYPENAME'
503
     Print inheritance relationships as well as other information for
504
     type TYPENAME.  *Note Examining the Symbol Table: Symbols.
505
 
506
`set print demangle'
507
`show print demangle'
508
`set print asm-demangle'
509
`show print asm-demangle'
510
     Control whether C++ symbols display in their source form, both when
511
     displaying code as C++ source and when displaying disassemblies.
512
     *Note Print settings: Print Settings.
513
 
514
`set print object'
515
`show print object'
516
     Choose whether to print derived (actual) or declared types of
517
     objects.  *Note Print settings: Print Settings.
518
 
519
`set print vtbl'
520
`show print vtbl'
521
     Control the format for printing virtual function tables.  *Note
522
     Print settings: Print Settings.  (The `vtbl' commands do not work
523
     on programs compiled with the HP ANSI C++ compiler (`aCC').)
524
 
525
`set overload-resolution on'
526
     Enable overload resolution for C++ expression evaluation.  The
527
     default is on.  For overloaded functions, GDB evaluates the
528
     arguments and searches for a function whose signature matches the
529
     argument types, using the standard C++ conversion rules (see *Note
530
     C++ expressions: C plus plus expressions, for details).  If it
531
     cannot find a match, it emits a message.
532
 
533
`set overload-resolution off'
534
     Disable overload resolution for C++ expression evaluation.  For
535
     overloaded functions that are not class member functions, GDB
536
     chooses the first function of the specified name that it finds in
537
     the symbol table, whether or not its arguments are of the correct
538
     type.  For overloaded functions that are class member functions,
539
     GDB searches for a function whose signature _exactly_ matches the
540
     argument types.
541
 
542
`Overloaded symbol names'
543
     You can specify a particular definition of an overloaded symbol,
544
     using the same notation that is used to declare such symbols in
545
     C++: type `SYMBOL(TYPES)' rather than just SYMBOL.  You can also
546
     use the GDB command-line word completion facilities to list the
547
     available choices, or to finish the type list for you.  *Note
548
     Command completion: Completion, for details on how to do this.
549
 
550

551
File: gdb.info,  Node: Modula-2,  Next: Chill,  Prev: C,  Up: Support
552
 
553
Modula-2
554
--------
555
 
556
   The extensions made to GDB to support Modula-2 only support output
557
from the GNU Modula-2 compiler (which is currently being developed).
558
Other Modula-2 compilers are not currently supported, and attempting to
559
debug executables produced by them is most likely to give an error as
560
GDB reads in the executable's symbol table.
561
 
562
* Menu:
563
 
564
* M2 Operators::                Built-in operators
565
* Built-In Func/Proc::          Built-in functions and procedures
566
* M2 Constants::                Modula-2 constants
567
* M2 Defaults::                 Default settings for Modula-2
568
* Deviations::                  Deviations from standard Modula-2
569
* M2 Checks::                   Modula-2 type and range checks
570
* M2 Scope::                    The scope operators `::' and `.'
571
* GDB/M2::                      GDB and Modula-2
572
 
573

574
File: gdb.info,  Node: M2 Operators,  Next: Built-In Func/Proc,  Up: Modula-2
575
 
576
Operators
577
.........
578
 
579
   Operators must be defined on values of specific types.  For instance,
580
`+' is defined on numbers, but not on structures.  Operators are often
581
defined on groups of types.  For the purposes of Modula-2, the
582
following definitions hold:
583
 
584
   * _Integral types_ consist of `INTEGER', `CARDINAL', and their
585
     subranges.
586
 
587
   * _Character types_ consist of `CHAR' and its subranges.
588
 
589
   * _Floating-point types_ consist of `REAL'.
590
 
591
   * _Pointer types_ consist of anything declared as `POINTER TO TYPE'.
592
 
593
   * _Scalar types_ consist of all of the above.
594
 
595
   * _Set types_ consist of `SET' and `BITSET' types.
596
 
597
   * _Boolean types_ consist of `BOOLEAN'.
598
 
599
The following operators are supported, and appear in order of
600
increasing precedence:
601
 
602
`,'
603
     Function argument or array index separator.
604
 
605
`:='
606
     Assignment.  The value of VAR `:=' VALUE is VALUE.
607
 
608
`<, >'
609
     Less than, greater than on integral, floating-point, or enumerated
610
     types.
611
 
612
`<=, >='
613
     Less than or equal to, greater than or equal to on integral,
614
     floating-point and enumerated types, or set inclusion on set
615
     types.  Same precedence as `<'.
616
 
617
`=, <>, #'
618
     Equality and two ways of expressing inequality, valid on scalar
619
     types.  Same precedence as `<'.  In GDB scripts, only `<>' is
620
     available for inequality, since `#' conflicts with the script
621
     comment character.
622
 
623
`IN'
624
     Set membership.  Defined on set types and the types of their
625
     members.  Same precedence as `<'.
626
 
627
`OR'
628
     Boolean disjunction.  Defined on boolean types.
629
 
630
`AND, &'
631
     Boolean conjunction.  Defined on boolean types.
632
 
633
`@'
634
     The GDB "artificial array" operator (*note Expressions:
635
     Expressions.).
636
 
637
`+, -'
638
     Addition and subtraction on integral and floating-point types, or
639
     union and difference on set types.
640
 
641
`*'
642
     Multiplication on integral and floating-point types, or set
643
     intersection on set types.
644
 
645
`/'
646
     Division on floating-point types, or symmetric set difference on
647
     set types.  Same precedence as `*'.
648
 
649
`DIV, MOD'
650
     Integer division and remainder.  Defined on integral types.  Same
651
     precedence as `*'.
652
 
653
`-'
654
     Negative. Defined on `INTEGER' and `REAL' data.
655
 
656
`^'
657
     Pointer dereferencing.  Defined on pointer types.
658
 
659
`NOT'
660
     Boolean negation.  Defined on boolean types.  Same precedence as
661
     `^'.
662
 
663
`.'
664
     `RECORD' field selector.  Defined on `RECORD' data.  Same
665
     precedence as `^'.
666
 
667
`[]'
668
     Array indexing.  Defined on `ARRAY' data.  Same precedence as `^'.
669
 
670
`()'
671
     Procedure argument list.  Defined on `PROCEDURE' objects.  Same
672
     precedence as `^'.
673
 
674
`::, .'
675
     GDB and Modula-2 scope operators.
676
 
677
     _Warning:_ Sets and their operations are not yet supported, so GDB
678
     treats the use of the operator `IN', or the use of operators `+',
679
     `-', `*', `/', `=', , `<>', `#', `<=', and `>=' on sets as an
680
     error.
681
 
682

683
File: gdb.info,  Node: Built-In Func/Proc,  Next: M2 Constants,  Prev: M2 Operators,  Up: Modula-2
684
 
685
Built-in functions and procedures
686
.................................
687
 
688
   Modula-2 also makes available several built-in procedures and
689
functions.  In describing these, the following metavariables are used:
690
 
691
A
692
     represents an `ARRAY' variable.
693
 
694
C
695
     represents a `CHAR' constant or variable.
696
 
697
I
698
     represents a variable or constant of integral type.
699
 
700
M
701
     represents an identifier that belongs to a set.  Generally used in
702
     the same function with the metavariable S.  The type of S should
703
     be `SET OF MTYPE' (where MTYPE is the type of M).
704
 
705
N
706
     represents a variable or constant of integral or floating-point
707
     type.
708
 
709
R
710
     represents a variable or constant of floating-point type.
711
 
712
T
713
     represents a type.
714
 
715
V
716
     represents a variable.
717
 
718
X
719
     represents a variable or constant of one of many types.  See the
720
     explanation of the function for details.
721
 
722
   All Modula-2 built-in procedures also return a result, described
723
below.
724
 
725
`ABS(N)'
726
     Returns the absolute value of N.
727
 
728
`CAP(C)'
729
     If C is a lower case letter, it returns its upper case equivalent,
730
     otherwise it returns its argument.
731
 
732
`CHR(I)'
733
     Returns the character whose ordinal value is I.
734
 
735
`DEC(V)'
736
     Decrements the value in the variable V by one.  Returns the new
737
     value.
738
 
739
`DEC(V,I)'
740
     Decrements the value in the variable V by I.  Returns the new
741
     value.
742
 
743
`EXCL(M,S)'
744
     Removes the element M from the set S.  Returns the new set.
745
 
746
`FLOAT(I)'
747
     Returns the floating point equivalent of the integer I.
748
 
749
`HIGH(A)'
750
     Returns the index of the last member of A.
751
 
752
`INC(V)'
753
     Increments the value in the variable V by one.  Returns the new
754
     value.
755
 
756
`INC(V,I)'
757
     Increments the value in the variable V by I.  Returns the new
758
     value.
759
 
760
`INCL(M,S)'
761
     Adds the element M to the set S if it is not already there.
762
     Returns the new set.
763
 
764
`MAX(T)'
765
     Returns the maximum value of the type T.
766
 
767
`MIN(T)'
768
     Returns the minimum value of the type T.
769
 
770
`ODD(I)'
771
     Returns boolean TRUE if I is an odd number.
772
 
773
`ORD(X)'
774
     Returns the ordinal value of its argument.  For example, the
775
     ordinal value of a character is its ASCII value (on machines
776
     supporting the ASCII character set).  X must be of an ordered
777
     type, which include integral, character and enumerated types.
778
 
779
`SIZE(X)'
780
     Returns the size of its argument.  X can be a variable or a type.
781
 
782
`TRUNC(R)'
783
     Returns the integral part of R.
784
 
785
`VAL(T,I)'
786
     Returns the member of the type T whose ordinal value is I.
787
 
788
     _Warning:_  Sets and their operations are not yet supported, so
789
     GDB treats the use of procedures `INCL' and `EXCL' as an error.
790
 
791

792
File: gdb.info,  Node: M2 Constants,  Next: M2 Defaults,  Prev: Built-In Func/Proc,  Up: Modula-2
793
 
794
Constants
795
.........
796
 
797
   GDB allows you to express the constants of Modula-2 in the following
798
ways:
799
 
800
   * Integer constants are simply a sequence of digits.  When used in an
801
     expression, a constant is interpreted to be type-compatible with
802
     the rest of the expression.  Hexadecimal integers are specified by
803
     a trailing `H', and octal integers by a trailing `B'.
804
 
805
   * Floating point constants appear as a sequence of digits, followed
806
     by a decimal point and another sequence of digits.  An optional
807
     exponent can then be specified, in the form `E[+|-]NNN', where
808
     `[+|-]NNN' is the desired exponent.  All of the digits of the
809
     floating point constant must be valid decimal (base 10) digits.
810
 
811
   * Character constants consist of a single character enclosed by a
812
     pair of like quotes, either single (`'') or double (`"').  They may
813
     also be expressed by their ordinal value (their ASCII value,
814
     usually) followed by a `C'.
815
 
816
   * String constants consist of a sequence of characters enclosed by a
817
     pair of like quotes, either single (`'') or double (`"').  Escape
818
     sequences in the style of C are also allowed.  *Note C and C++
819
     constants: C Constants, for a brief explanation of escape
820
     sequences.
821
 
822
   * Enumerated constants consist of an enumerated identifier.
823
 
824
   * Boolean constants consist of the identifiers `TRUE' and `FALSE'.
825
 
826
   * Pointer constants consist of integral values only.
827
 
828
   * Set constants are not yet supported.
829
 
830

831
File: gdb.info,  Node: M2 Defaults,  Next: Deviations,  Prev: M2 Constants,  Up: Modula-2
832
 
833
Modula-2 defaults
834
.................
835
 
836
   If type and range checking are set automatically by GDB, they both
837
default to `on' whenever the working language changes to Modula-2.
838
This happens regardless of whether you or GDB selected the working
839
language.
840
 
841
   If you allow GDB to set the language automatically, then entering
842
code compiled from a file whose name ends with `.mod' sets the working
843
language to Modula-2.  *Note Having GDB set the language automatically:
844
Automatically, for further details.
845
 
846

847
File: gdb.info,  Node: Deviations,  Next: M2 Checks,  Prev: M2 Defaults,  Up: Modula-2
848
 
849
Deviations from standard Modula-2
850
.................................
851
 
852
   A few changes have been made to make Modula-2 programs easier to
853
debug.  This is done primarily via loosening its type strictness:
854
 
855
   * Unlike in standard Modula-2, pointer constants can be formed by
856
     integers.  This allows you to modify pointer variables during
857
     debugging.  (In standard Modula-2, the actual address contained in
858
     a pointer variable is hidden from you; it can only be modified
859
     through direct assignment to another pointer variable or
860
     expression that returned a pointer.)
861
 
862
   * C escape sequences can be used in strings and characters to
863
     represent non-printable characters.  GDB prints out strings with
864
     these escape sequences embedded.  Single non-printable characters
865
     are printed using the `CHR(NNN)' format.
866
 
867
   * The assignment operator (`:=') returns the value of its right-hand
868
     argument.
869
 
870
   * All built-in procedures both modify _and_ return their argument.
871
 
872

873
File: gdb.info,  Node: M2 Checks,  Next: M2 Scope,  Prev: Deviations,  Up: Modula-2
874
 
875
Modula-2 type and range checks
876
..............................
877
 
878
     _Warning:_ in this release, GDB does not yet perform type or range
879
     checking.
880
 
881
   GDB considers two Modula-2 variables type equivalent if:
882
 
883
   * They are of types that have been declared equivalent via a `TYPE
884
     T1 = T2' statement
885
 
886
   * They have been declared on the same line.  (Note:  This is true of
887
     the GNU Modula-2 compiler, but it may not be true of other
888
     compilers.)
889
 
890
   As long as type checking is enabled, any attempt to combine variables
891
whose types are not equivalent is an error.
892
 
893
   Range checking is done on all mathematical operations, assignment,
894
array index bounds, and all built-in functions and procedures.
895
 
896

897
File: gdb.info,  Node: M2 Scope,  Next: GDB/M2,  Prev: M2 Checks,  Up: Modula-2
898
 
899
The scope operators `::' and `.'
900
................................
901
 
902
   There are a few subtle differences between the Modula-2 scope
903
operator (`.') and the GDB scope operator (`::').  The two have similar
904
syntax:
905
 
906
 
907
     MODULE . ID
908
     SCOPE :: ID
909
 
910
where SCOPE is the name of a module or a procedure, MODULE the name of
911
a module, and ID is any declared identifier within your program, except
912
another module.
913
 
914
   Using the `::' operator makes GDB search the scope specified by
915
SCOPE for the identifier ID.  If it is not found in the specified
916
scope, then GDB searches all scopes enclosing the one specified by
917
SCOPE.
918
 
919
   Using the `.' operator makes GDB search the current scope for the
920
identifier specified by ID that was imported from the definition module
921
specified by MODULE.  With this operator, it is an error if the
922
identifier ID was not imported from definition module MODULE, or if ID
923
is not an identifier in MODULE.
924
 
925

926
File: gdb.info,  Node: GDB/M2,  Prev: M2 Scope,  Up: Modula-2
927
 
928
GDB and Modula-2
929
................
930
 
931
   Some GDB commands have little use when debugging Modula-2 programs.
932
Five subcommands of `set print' and `show print' apply specifically to
933
C and C++: `vtbl', `demangle', `asm-demangle', `object', and `union'.
934
The first four apply to C++, and the last to the C `union' type, which
935
has no direct analogue in Modula-2.
936
 
937
   The `@' operator (*note Expressions: Expressions.), while available
938
with any language, is not useful with Modula-2.  Its intent is to aid
939
the debugging of "dynamic arrays", which cannot be created in Modula-2
940
as they can in C or C++.  However, because an address can be specified
941
by an integral constant, the construct `{TYPE}ADREXP' is still useful.
942
 
943
   In GDB scripts, the Modula-2 inequality operator `#' is interpreted
944
as the beginning of a comment.  Use `<>' instead.
945
 
946

947
File: gdb.info,  Node: Chill,  Prev: Modula-2,  Up: Support
948
 
949
Chill
950
-----
951
 
952
   The extensions made to GDB to support Chill only support output from
953
the GNU Chill compiler.  Other Chill compilers are not currently
954
supported, and attempting to debug executables produced by them is most
955
likely to give an error as GDB reads in the executable's symbol table.
956
 
957
   This section covers the Chill related topics and the features of GDB
958
which support these topics.
959
 
960
* Menu:
961
 
962
* How modes are displayed::        How modes are displayed
963
* Locations::                        Locations and their accesses
964
* Values and their Operations:: Values and their Operations
965
* Chill type and range checks::
966
* Chill defaults::
967
 
968

969
File: gdb.info,  Node: How modes are displayed,  Next: Locations,  Up: Chill
970
 
971
How modes are displayed
972
.......................
973
 
974
   The Chill Datatype- (Mode) support of GDB is directly related with
975
the functionality of the GNU Chill compiler, and therefore deviates
976
slightly from the standard specification of the Chill language. The
977
provided modes are:
978
 
979
`_Discrete modes:_'
980
        * _Integer Modes_ which are predefined by `BYTE, UBYTE, INT,
981
          UINT, LONG, ULONG',
982
 
983
        * _Boolean Mode_ which is predefined by `BOOL',
984
 
985
        * _Character Mode_ which is predefined by `CHAR',
986
 
987
        * _Set Mode_ which is displayed by the keyword `SET'.
988
               (gdb) ptype x
989
               type = SET (karli = 10, susi = 20, fritzi = 100)
990
          If the type is an unnumbered set the set element values are
991
          omitted.
992
 
993
        * _Range Mode_ which is displayed by
994
               `type = ( : )'
995
          where `, ' can be of any discrete
996
          literal expression (e.g. set element names).
997
 
998
`_Powerset Mode:_'
999
     A Powerset Mode is displayed by the keyword `POWERSET' followed by
1000
     the member mode of the powerset.  The member mode can be any
1001
     discrete mode.
1002
          (gdb) ptype x
1003
          type = POWERSET SET (egon, hugo, otto)
1004
 
1005
`_Reference Modes:_'
1006
        * _Bound Reference Mode_ which is displayed by the keyword `REF'
1007
          followed by the mode name to which the reference is bound.
1008
 
1009
        * _Free Reference Mode_ which is displayed by the keyword `PTR'.
1010
 
1011
`_Procedure mode_'
1012
     The procedure mode is displayed by `type = PROC()
1013
      EXCEPTIONS ()'. The `
1014
     list>' is a list of the parameter modes.  `' indicates
1015
     the mode of the result of the procedure if any.  The exceptionlist
1016
     lists all possible exceptions which can be raised by the procedure.
1017
 
1018
`_Synchronization Modes:_'
1019
        * _Event Mode_ which is displayed by
1020
               `EVENT ()'
1021
          where `()' is optional.
1022
 
1023
        * _Buffer Mode_ which is displayed by
1024
               `BUFFER ()'
1025
          where `()' is optional.
1026
 
1027
`_Timing Modes:_'
1028
        * _Duration Mode_ which is predefined by `DURATION'
1029
 
1030
        * _Absolute Time Mode_ which is predefined by `TIME'
1031
 
1032
`_Real Modes:_'
1033
     Real Modes are predefined with `REAL' and `LONG_REAL'.
1034
 
1035
`_String Modes:_'
1036
        * _Character String Mode_ which is displayed by
1037
               `CHARS()'
1038
          followed by the keyword `VARYING' if the String Mode is a
1039
          varying mode
1040
 
1041
        * _Bit String Mode_ which is displayed by
1042
               `BOOLS(
1043
               length>)'
1044
 
1045
`_Array Mode:_'
1046
     The Array Mode is displayed by the keyword `ARRAY()'
1047
     followed by the element mode (which may in turn be an array mode).
1048
          (gdb) ptype x
1049
          type = ARRAY (1:42)
1050
                    ARRAY (1:20)
1051
                       SET (karli = 10, susi = 20, fritzi = 100)
1052
 
1053
`_Structure Mode_'
1054
     The Structure mode is displayed by the keyword `STRUCT(
1055
     list>)'.  The `' consists of names and modes of fields
1056
     of the structure.  Variant structures have the keyword `CASE
1057
      OF  ESAC' in their field list.  Since the
1058
     current version of the GNU Chill compiler doesn't implement tag
1059
     processing (no runtime checks of variant fields, and therefore no
1060
     debugging info), the output always displays all variant fields.
1061
          (gdb) ptype str
1062
          type = STRUCT (
1063
              as x,
1064
              bs x,
1065
              CASE bs OF
1066
              (karli):
1067
                  cs a
1068
              (ott):
1069
                  ds x
1070
              ESAC
1071
          )
1072
 
1073

1074
File: gdb.info,  Node: Locations,  Next: Values and their Operations,  Prev: How modes are displayed,  Up: Chill
1075
 
1076
Locations and their accesses
1077
............................
1078
 
1079
   A location in Chill is an object which can contain values.
1080
 
1081
   A value of a location is generally accessed by the (declared) name of
1082
the location.  The output conforms to the specification of values in
1083
Chill programs.  How values are specified is the topic of the next
1084
section, *Note Values and their Operations::.
1085
 
1086
   The pseudo-location `RESULT' (or `result') can be used to display or
1087
change the result of a currently-active procedure:
1088
 
1089
     set result := EXPR
1090
 
1091
This does the same as the Chill action `RESULT EXPR' (which is not
1092
available in GDB).
1093
 
1094
   Values of reference mode locations are printed by `PTR()'
1095
in case of a free reference mode, and by `(REF )
1096
()' in case of a bound reference.  `' represents
1097
the address where the reference points to.  To access the value of the
1098
location referenced by the pointer, use the dereference operator `->'.
1099
 
1100
   Values of procedure mode locations are displayed by
1101
     `{ PROC
1102
     ( )  } 
1103
     location>'
1104
   `' is a list of modes according to the parameter
1105
specification of the procedure and `
' shows the address of the
1106
entry point.
1107
 
1108
   Substructures of string mode-, array mode- or structure mode-values
1109
(e.g. array slices, fields of structure locations) are accessed using
1110
certain operations which are described in the next section, *Note
1111
Values and their Operations::.
1112
 
1113
   A location value may be interpreted as having a different mode using
1114
the location conversion.  This mode conversion is written as `
1115
name>()'.  The user has to consider that the sizes of the
1116
modes have to be equal otherwise an error occurs.  Furthermore, no range
1117
checking of the location against the destination mode is performed, and
1118
therefore the result can be quite confusing.
1119
 
1120
     (gdb) print int (s(3 up 4)) XXX TO be filled in !! XXX
1121
 
1122

1123
File: gdb.info,  Node: Values and their Operations,  Next: Chill type and range checks,  Prev: Locations,  Up: Chill
1124
 
1125
Values and their Operations
1126
...........................
1127
 
1128
   Values are used to alter locations, to investigate complex
1129
structures in more detail or to filter relevant information out of a
1130
large amount of data.  There are several (mode dependent) operations
1131
defined which enable such investigations.  These operations are not
1132
only applicable to constant values but also to locations, which can
1133
become quite useful when debugging complex structures.  During parsing
1134
the command line (e.g. evaluating an expression) GDB treats location
1135
names as the values behind these locations.
1136
 
1137
   This section describes how values have to be specified and which
1138
operations are legal to be used with such values.
1139
 
1140
`Literal Values'
1141
     Literal values are specified in the same manner as in GNU Chill
1142
     programs.  For detailed specification refer to the GNU Chill
1143
     implementation Manual chapter 1.5.
1144
 
1145
`Tuple Values'
1146
     A tuple is specified by `[]', where `
1147
     name>' can be omitted if the mode of the tuple is unambiguous.
1148
     This unambiguity is derived from the context of a evaluated
1149
     expression.  `' can be one of the following:
1150
 
1151
        * _Powerset Tuple_
1152
 
1153
        * _Array Tuple_
1154
 
1155
        * _Structure Tuple_ Powerset tuples, array tuples and structure
1156
          tuples are specified in the same manner as in Chill programs
1157
          refer to z200/88 chpt 5.2.5.
1158
 
1159
`String Element Value'
1160
     A string element value is specified by
1161
          `()'
1162
     where `' is a integer expression.  It delivers a character
1163
     value which is equivalent to the character indexed by `' in
1164
     the string.
1165
 
1166
`String Slice Value'
1167
     A string slice value is specified by `(
1168
     spec>)', where `' can be either a range of integer
1169
     expressions or specified by ` up '.  `'
1170
     denotes the number of elements which the slice contains.  The
1171
     delivered value is a string value, which is part of the specified
1172
     string.
1173
 
1174
`Array Element Values'
1175
     An array element value is specified by `()' and
1176
     delivers a array element value of the mode of the specified array.
1177
 
1178
`Array Slice Values'
1179
     An array slice is specified by `()', where
1180
     `' can be either a range specified by expressions or by
1181
     ` up '.  `' denotes the number of
1182
     arrayelements the slice contains.  The delivered value is an array
1183
     value which is part of the specified array.
1184
 
1185
`Structure Field Values'
1186
     A structure field value is derived by `.
1187
     name>', where `' indicates the name of a field
1188
     specified in the mode definition of the structure.  The mode of
1189
     the delivered value corresponds to this mode definition in the
1190
     structure definition.
1191
 
1192
`Procedure Call Value'
1193
     The procedure call value is derived from the return value of the
1194
     procedure(1).
1195
 
1196
     Values of duration mode locations are represented by `ULONG'
1197
     literals.
1198
 
1199
     Values of time mode locations appear as
1200
          `TIME(:)'
1201
 
1202
`Zero-adic Operator Value'
1203
     The zero-adic operator value is derived from the instance value
1204
     for the current active process.
1205
 
1206
`Expression Values'
1207
     The value delivered by an expression is the result of the
1208
     evaluation of the specified expression.  If there are error
1209
     conditions (mode incompatibility, etc.) the evaluation of
1210
     expressions is aborted with a corresponding error message.
1211
     Expressions may be parenthesised which causes the evaluation of
1212
     this expression before any other expression which uses the result
1213
     of the parenthesised expression.  The following operators are
1214
     supported by GDB:
1215
 
1216
    ``OR, ORIF, XOR''
1217
    ``AND, ANDIF''
1218
    ``NOT''
1219
          Logical operators defined over operands of boolean mode.
1220
 
1221
    ``=, /=''
1222
          Equality and inequality operators defined over all modes.
1223
 
1224
    ``>, >=''
1225
    ``<, <=''
1226
          Relational operators defined over predefined modes.
1227
 
1228
    ``+, -''
1229
    ``*, /, MOD, REM''
1230
          Arithmetic operators defined over predefined modes.
1231
 
1232
    ``-''
1233
          Change sign operator.
1234
 
1235
    ``//''
1236
          String concatenation operator.
1237
 
1238
    ``()''
1239
          String repetition operator.
1240
 
1241
    ``->''
1242
          Referenced location operator which can be used either to take
1243
          the address of a location (`->loc'), or to dereference a
1244
          reference location (`loc->').
1245
 
1246
    ``OR, XOR''
1247
    ``AND''
1248
    ``NOT''
1249
          Powerset and bitstring operators.
1250
 
1251
    ``>, >=''
1252
    ``<, <=''
1253
          Powerset inclusion operators.
1254
 
1255
    ``IN''
1256
          Membership operator.
1257
 
1258
   ---------- Footnotes ----------
1259
 
1260
   (1) If a procedure call is used for instance in an expression, then
1261
this procedure is called with all its side effects.  This can lead to
1262
confusing results if used carelessly.
1263
 
1264

1265
File: gdb.info,  Node: Chill type and range checks,  Next: Chill defaults,  Prev: Values and their Operations,  Up: Chill
1266
 
1267
Chill type and range checks
1268
...........................
1269
 
1270
   GDB considers two Chill variables mode equivalent if the sizes of
1271
the two modes are equal.  This rule applies recursively to more complex
1272
datatypes which means that complex modes are treated equivalent if all
1273
element modes (which also can be complex modes like structures, arrays,
1274
etc.) have the same size.
1275
 
1276
   Range checking is done on all mathematical operations, assignment,
1277
array index bounds and all built in procedures.
1278
 
1279
   Strong type checks are forced using the GDB command `set check
1280
strong'.  This enforces strong type and range checks on all operations
1281
where Chill constructs are used (expressions, built in functions, etc.)
1282
in respect to the semantics as defined in the z.200 language
1283
specification.
1284
 
1285
   All checks can be disabled by the GDB command `set check off'.
1286
 
1287

1288
File: gdb.info,  Node: Chill defaults,  Prev: Chill type and range checks,  Up: Chill
1289
 
1290
Chill defaults
1291
..............
1292
 
1293
   If type and range checking are set automatically by GDB, they both
1294
default to `on' whenever the working language changes to Chill.  This
1295
happens regardless of whether you or GDB selected the working language.
1296
 
1297
   If you allow GDB to set the language automatically, then entering
1298
code compiled from a file whose name ends with `.ch' sets the working
1299
language to Chill.  *Note Having GDB set the language automatically:
1300
Automatically, for further details.
1301
 

powered by: WebSVN 2.1.0

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