]> git.pld-linux.org Git - packages/gdb.git/blame - gdb-ada-support.patch
- updated to 6.2.1
[packages/gdb.git] / gdb-ada-support.patch
CommitLineData
1b12d3b6
JB
1From gdb-patches-return-33877-listarch-gdb-patches=sources dot redhat dot com at sources dot redhat dot com Wed Jun 16 08:42:53 2004
2Return-Path: <gdb-patches-return-33877-listarch-gdb-patches=sources dot redhat dot com at sources dot redhat dot com>
3Delivered-To: listarch-gdb-patches at sources dot redhat dot com
4Received: (qmail 7986 invoked by alias); 16 Jun 2004 08:42:52 -0000
5Mailing-List: contact gdb-patches-help at sources dot redhat dot com; run by ezmlm
6Precedence: bulk
7List-Subscribe: <mailto:gdb-patches-subscribe at sources dot redhat dot com>
8List-Archive: <http://sources.redhat.com/ml/gdb-patches/>
9List-Post: <mailto:gdb-patches at sources dot redhat dot com>
10List-Help: <mailto:gdb-patches-help at sources dot redhat dot com>, <http://sources dot redhat dot com/ml/#faqs>
11Sender: gdb-patches-owner at sources dot redhat dot com
12Delivered-To: mailing list gdb-patches at sources dot redhat dot com
13Received: (qmail 7802 invoked from network); 16 Jun 2004 08:42:38 -0000
14Received: from unknown (HELO nile.gnat.com) (205.232.38.5)
15 by sourceware dot org with SMTP; 16 Jun 2004 08:42:38 -0000
16Received: from localhost (localhost [127.0.0.1])
17 by nile dot gnat dot com (Postfix) with ESMTP
18 id 73F11F28E9; Wed, 16 Jun 2004 04:42:38 -0400 (EDT)
19Received: from nile.gnat.com ([127.0.0.1])
20 by localhost (nile dot gnat dot com [127 dot 0 dot 0 dot 1]) (amavisd-new, port 10024) with LMTP
21 id 10906-01-2; Wed, 16 Jun 2004 04:42:38 -0400 (EDT)
22Received: by nile.gnat.com (Postfix, from userid 1345)
23 id F02D1F292A; Wed, 16 Jun 2004 04:42:37 -0400 (EDT)
24From: Paul Hilfinger <hilfingr at gnat dot com>
25To: gdb-patches at sources dot redhat dot com
26Cc: drow at false dot org, jimb at redhat dot com, eliz at gnu dot org
27In-reply-to: <20040609131240 dot GA7587 at nevyn dot them dot org> (message from Daniel
28 Jacobowitz on Wed, 9 Jun 2004 09:12:40 -0400)
29Subject: Re: [RFA]: Turn on Ada support, take 2
30References: <20040608090758.C59CAF2940@nile.gnat.com> <vt2aczd8aah.fsf@zenia.home> <20040609131240.GA7587@nevyn.them.org>
31Message-Id: <20040616084237.F02D1F292A@nile.gnat.com>
32Date: Wed, 16 Jun 2004 04:42:37 -0400 (EDT)
33X-Virus-Scanned: by amavisd-new at nile.gnat.com
34
35
36
37Here is an update to the patch I sent previously. In this version, I have
38
391. Removed the compilation of ada-tasks.o, since we have not yet turned
40 on any of it in the public version.
41
422. Responded to most of Eli's comments. I will have to consider the
43 issue of formating things like 'Address, since the standard rendering
44 in info files provided by the technically appropriate marker,
45 @code, looks rather bad (in my opinion), due to the adjacent quotes
46 at the beginning.
47
48A previous patch to the Ada sources added some conditionalization to mark code
49that is not yet used in the public version (for the benefit of reviewers).
50
51
52ChangeLogs:
53
54 2004-06-16 Paul N. Hilfinger <Hilfinger@gnat.com>
55
56 Turn on initial Ada support (mainly expression evaluation).
57
58 * Makefile.in (ada_lex_c): Define
59 (HFILES_NO_SRCDIR): Add ada-lang.h.
60 (COMMON_OBS): Add ada-lang.o, ada-typeprint.o, ada-valprint.o.
61 (YYOBJ): Add ada-exp.o.
62 (rule .l.c): Generalize to not mention ada.
63 (ada-lex.o): Remove (ada-lex.c is included by ada-exp.y).
64 (ada-lang.o): Add dependencies on completer.h, gdb_obstack.h,
65 hashtab.h.
66 (ada-tasks.o): Add dependency on gdb_string.h.
67 (ada-valprint.o): Add dependency on gdb_string.h.
68
69 * symtab.c: Add dependency on ada-lang.h.
70 (symbol_natural_name): Add Ada case.
71 (symbol_demangled_name): Add Ada case.
72 (symbol_search_name): Add Ada case.
73
74 * symfile.c (init_filename_language_table): Add extensions for
75 Ada.
76
77 * defs.h (enum language): Add language_ada.
78
79 * gdbtypes.h (TYPE_FLAG_FIXED_INSTANCE): Define.
80
812004-06-09 Paul N. Hilfinger <hilfinger@gnat.com>
82
83 * doc/gdb.texinfo (Filenames): Add Ada suffixes.
84 (Ada) New section.
85
86
87
88Index: gdb/Makefile.in
89===================================================================
90RCS file: /cvs/src/src/gdb/Makefile.in,v
91retrieving revision 1.587
92diff -u -p -r1.587 Makefile.in
93--- gdb/Makefile.in 14 Jun 2004 20:40:39 -0000 1.587
94+++ gdb/Makefile.in 16 Jun 2004 08:23:45 -0000
95@@ -616,6 +616,7 @@ nm_h = @nm_h@
96 # gdb/ headers
97 #
98
99+ada_lex_c = ada-lex.c
100 ada_lang_h = ada-lang.h $(value_h) $(gdbtypes_h)
101 alphabsd_tdep_h = alphabsd-tdep.h
102 alpha_tdep_h = alpha-tdep.h
103@@ -833,7 +834,7 @@ HFILES_NO_SRCDIR = bcache.h buildsym.h c
104 symfile.h symfile-mem.h stabsread.h target.h terminal.h typeprint.h \
105 xcoffsolib.h \
106 macrotab.h macroexp.h macroscope.h \
107- c-lang.h f-lang.h \
108+ ada-lang.h c-lang.h f-lang.h \
109 jv-lang.h \
110 m2-lang.h p-lang.h \
111 complaints.h valprint.h \
112@@ -894,7 +895,7 @@ COMMON_OBS = $(DEPFILES) $(YYOBJ) \
113 dbxread.o coffread.o coff-pe-read.o elfread.o \
114 dwarfread.o dwarf2read.o mipsread.o stabsread.o corefile.o \
115 dwarf2expr.o dwarf2loc.o dwarf2-frame.o \
116- c-lang.o f-lang.o objc-lang.o \
117+ ada-lang.o c-lang.o f-lang.o objc-lang.o \
118 ui-out.o cli-out.o \
119 varobj.o wrapper.o \
120 jv-lang.o jv-valprint.o jv-typeprint.o \
121@@ -902,8 +903,8 @@ COMMON_OBS = $(DEPFILES) $(YYOBJ) \
122 scm-exp.o scm-lang.o scm-valprint.o \
123 sentinel-frame.o \
124 complaints.o typeprint.o \
125- c-typeprint.o f-typeprint.o m2-typeprint.o \
126- c-valprint.o cp-valprint.o f-valprint.o m2-valprint.o \
127+ ada-typeprint.o c-typeprint.o f-typeprint.o m2-typeprint.o \
128+ ada-valprint.o c-valprint.o cp-valprint.o f-valprint.o m2-valprint.o \
129 nlmread.o serial.o mdebugread.o top.o utils.o \
130 ui-file.o \
131 user-regs.o \
132@@ -927,6 +928,7 @@ YYFILES = c-exp.c \
133 f-exp.c m2-exp.c p-exp.c
134 YYOBJ = c-exp.o \
135 objc-exp.o \
136+ ada-exp.o \
137 jv-exp.o \
138 f-exp.o m2-exp.o p-exp.o
139
140@@ -1495,7 +1497,7 @@ valprint.o: $(srcdir)/valprint.c
141 echo $(FLEX) -Isit $< ">" $@; \
142 $(FLEX) -Isit $< > $@; \
143 elif [ ! -f $@ -a ! -f $< ]; then \
144- echo "ada-lex.c missing and flex not available."; \
145+ echo "$< missing and flex not available."; \
146 false; \
147 elif [ ! -f $@ ]; then \
148 echo "Warning: $*.c older than $*.l and flex not available."; \
149@@ -1522,18 +1524,18 @@ ada-lang.o: ada-lang.c $(gdb_string_h) $
150 $(gdbtypes_h) $(gdbcmd_h) $(expression_h) $(parser_defs_h) \
151 $(language_h) $(c_lang_h) $(inferior_h) $(symfile_h) $(objfiles_h) \
152 $(breakpoint_h) $(gdbcore_h) $(ada_lang_h) $(ui_out_h) $(block_h) \
153- $(infcall_h) $(dictionary_h)
154-ada-lex.o: ada-lex.c
155+ $(completer_h) $(infcall_h) $(gdb_obstack_h) $(dictionary_h) \
156+ $(hashtab_h)
157 ada-tasks.o: ada-tasks.c $(defs_h) $(command_h) $(value_h) $(language_h) \
158 $(inferior_h) $(symtab_h) $(target_h) $(regcache_h) $(gdbcore_h) \
159- $(gregset_h) $(ada_lang_h)
160+ $(gregset_h) $(gdb_string_h) $(ada_lang_h)
161 ada-typeprint.o: ada-typeprint.c $(defs_h) $(gdb_obstack_h) $(bfd_h) \
162 $(symtab_h) $(gdbtypes_h) $(expression_h) $(value_h) $(gdbcore_h) \
163 $(target_h) $(command_h) $(gdbcmd_h) $(language_h) $(demangle_h) \
164 $(c_lang_h) $(typeprint_h) $(ada_lang_h) $(gdb_string_h)
165 ada-valprint.o: ada-valprint.c $(defs_h) $(symtab_h) $(gdbtypes_h) \
166 $(expression_h) $(value_h) $(demangle_h) $(valprint_h) $(language_h) \
167- $(annotate_h) $(ada_lang_h) $(c_lang_h) $(infcall_h)
168+ $(annotate_h) $(ada_lang_h) $(c_lang_h) $(gdb_string_h) $(infcall_h)
169 aix-thread.o: aix-thread.c $(defs_h) $(gdb_assert_h) $(gdbthread_h) \
170 $(target_h) $(inferior_h) $(regcache_h) $(gdbcmd_h) $(language_h) \
171 $(ppc_tdep_h) $(gdb_string_h)
172Index: gdb/defs.h
173===================================================================
174RCS file: /cvs/src/src/gdb/defs.h,v
175retrieving revision 1.147
176diff -u -p -r1.147 defs.h
177--- gdb/defs.h 10 Jun 2004 20:05:43 -0000 1.147
178+++ gdb/defs.h 16 Jun 2004 08:23:45 -0000
179@@ -220,6 +220,7 @@ enum language
180 language_asm, /* Assembly language */
181 language_scm, /* Scheme / Guile */
182 language_pascal, /* Pascal */
183+ language_ada, /* Ada */
184 language_minimal /* All other languages, minimal support only */
185 };
186
187Index: gdb/gdbtypes.h
188===================================================================
189RCS file: /cvs/src/src/gdb/gdbtypes.h,v
190retrieving revision 1.53
191diff -u -p -r1.53 gdbtypes.h
192--- gdb/gdbtypes.h 2 Jun 2004 21:01:55 -0000 1.53
193+++ gdb/gdbtypes.h 16 Jun 2004 08:23:45 -0000
194@@ -273,6 +273,17 @@ enum type_code
195 #define TYPE_ADDRESS_CLASS_ALL(t) (TYPE_INSTANCE_FLAGS(t) \
196 & TYPE_FLAG_ADDRESS_CLASS_ALL)
197
198+/* The debugging formats (especially STABS) do not contain enough information
199+ to represent all Ada types---especially those whose size depends on
200+ dynamic quantities. Therefore, the GNAT Ada compiler includes
201+ extra information in the form of additional type definitions
202+ connected by naming conventions. This flag indicates that the
203+ type is an ordinary (unencoded) GDB type that has been created from
204+ the necessary run-time information, and does not need further
205+ interpretation. Optionally marks ordinary, fixed-size GDB type. */
206+
207+#define TYPE_FLAG_FIXED_INSTANCE (1 << 15)
208+
209 /* Array bound type. */
210 enum array_bound_type
211 {
212Index: gdb/symfile.c
213===================================================================
214RCS file: /cvs/src/src/gdb/symfile.c,v
215retrieving revision 1.132
216diff -u -p -r1.132 symfile.c
217--- gdb/symfile.c 15 Jun 2004 01:04:20 -0000 1.132
218+++ gdb/symfile.c 16 Jun 2004 08:23:46 -0000
219@@ -2158,6 +2158,10 @@ init_filename_language_table (void)
220 add_filename_language (".pas", language_pascal);
221 add_filename_language (".p", language_pascal);
222 add_filename_language (".pp", language_pascal);
223+ add_filename_language (".adb", language_ada);
224+ add_filename_language (".ads", language_ada);
225+ add_filename_language (".a", language_ada);
226+ add_filename_language (".ada", language_ada);
227 }
228 }
229
230Index: gdb/symtab.c
231===================================================================
232RCS file: /cvs/src/src/gdb/symtab.c,v
233retrieving revision 1.132
234diff -u -p -r1.132 symtab.c
235--- gdb/symtab.c 10 Jun 2004 20:05:44 -0000 1.132
236+++ gdb/symtab.c 16 Jun 2004 08:23:47 -0000
237@@ -41,6 +41,7 @@
238 #include "source.h"
239 #include "filenames.h" /* for FILENAME_CMP */
240 #include "objc-lang.h"
241+#include "ada-lang.h"
242
243 #include "hashtab.h"
244
245@@ -632,17 +633,24 @@ symbol_init_demangled_name (struct gener
246 char *
247 symbol_natural_name (const struct general_symbol_info *gsymbol)
248 {
249- if ((gsymbol->language == language_cplus
250- || gsymbol->language == language_java
251- || gsymbol->language == language_objc)
252- && (gsymbol->language_specific.cplus_specific.demangled_name != NULL))
253+ switch (gsymbol->language)
254 {
255- return gsymbol->language_specific.cplus_specific.demangled_name;
256- }
257- else
258- {
259- return gsymbol->name;
260+ case language_cplus:
261+ case language_java:
262+ case language_objc:
263+ if (gsymbol->language_specific.cplus_specific.demangled_name != NULL)
264+ return gsymbol->language_specific.cplus_specific.demangled_name;
265+ break;
266+ case language_ada:
267+ if (gsymbol->language_specific.cplus_specific.demangled_name != NULL)
268+ return gsymbol->language_specific.cplus_specific.demangled_name;
269+ else
270+ return ada_decode_symbol (gsymbol);
271+ break;
272+ default:
273+ break;
274 }
275+ return gsymbol->name;
276 }
277
278 /* Return the demangled name for a symbol based on the language for
279@@ -650,13 +658,24 @@ symbol_natural_name (const struct genera
280 char *
281 symbol_demangled_name (struct general_symbol_info *gsymbol)
282 {
283- if (gsymbol->language == language_cplus
284- || gsymbol->language == language_java
285- || gsymbol->language == language_objc)
286- return gsymbol->language_specific.cplus_specific.demangled_name;
287-
288- else
289- return NULL;
290+ switch (gsymbol->language)
291+ {
292+ case language_cplus:
293+ case language_java:
294+ case language_objc:
295+ if (gsymbol->language_specific.cplus_specific.demangled_name != NULL)
296+ return gsymbol->language_specific.cplus_specific.demangled_name;
297+ break;
298+ case language_ada:
299+ if (gsymbol->language_specific.cplus_specific.demangled_name != NULL)
300+ return gsymbol->language_specific.cplus_specific.demangled_name;
301+ else
302+ return ada_decode_symbol (gsymbol);
303+ break;
304+ default:
305+ break;
306+ }
307+ return NULL;
308 }
309
310 /* Return the search name of a symbol---generally the demangled or
311#### gdb post-6.1 branch
312##@@ -664,7 +683,10 @@ symbol_demangled_name (struct general_sy
313## If there is no distinct demangled name, then returns the same value
314## (same pointer) as SYMBOL_LINKAGE_NAME. */
315## char *symbol_search_name (const struct general_symbol_info *gsymbol) {
316##- return symbol_natural_name (gsymbol);
317##+ if (gsymbol->language == language_ada)
318##+ return gsymbol->name;
319##+ else
320##+ return symbol_natural_name (gsymbol);
321## }
322##
323## /* Initialize the structure fields to zero values. */
324##
325Index: gdb/doc/gdb.texinfo
326===================================================================
327RCS file: /cvs/src/src/gdb/doc/gdb.texinfo,v
328retrieving revision 1.206
329diff -u -p -r1.206 gdb.texinfo
330--- gdb/doc/gdb.texinfo 14 Jun 2004 22:26:33 -0000 1.206
331+++ gdb/doc/gdb.texinfo 16 Jun 2004 08:23:53 -0000
332@@ -7741,6 +7741,11 @@ If a source file name ends in one of the
333 @value{GDBN} infers that its language is the one indicated.
334
335 @table @file
336+@item .ada
337+@itemx .ads
338+@itemx .adb
339+@itemx .a
340+Ada source file.
341
342 @item .c
343 C source file
344@@ -8031,7 +8036,7 @@ being set automatically by @value{GDBN}.
345 @node Support
346 @section Supported languages
347
348-@value{GDBN} supports C, C@t{++}, Objective-C, Fortran, Java, assembly, and Modula-2.
349+@value{GDBN} supports C, C@t{++}, Objective-C, Fortran, Java, assembly, Modula-2, and Ada.
350 @c This is false ...
351 Some @value{GDBN} features may be used in expressions regardless of the
352 language you use: the @value{GDBN} @code{@@} and @code{::} operators,
353@@ -8051,6 +8056,7 @@ language reference or tutorial.
354 * C:: C and C@t{++}
355 * Objective-C:: Objective-C
356 * Modula-2:: Modula-2
357+* Ada:: Ada
358 @end menu
359
360 @node C
361@@ -8666,7 +8672,7 @@ the description of an object. However,
362 with certain Objective-C libraries that have a particular hook
363 function, @code{_NSPrintForDebugger}, defined.
364
365-@node Modula-2, , Objective-C, Support
366+@node Modula-2, Ada, Objective-C, Support
367 @subsection Modula-2
368
369 @cindex Modula-2, @value{GDBN} support
370@@ -9109,6 +9115,481 @@ address can be specified by an integral
371 In @value{GDBN} scripts, the Modula-2 inequality operator @code{#} is
372 interpreted as the beginning of a comment. Use @code{<>} instead.
373
374+@node Ada
375+@subsection Ada
376+@cindex Ada
377+
378+The extensions made to @value{GDBN} for Ada only support
379+output from the @sc{gnu} Ada (GNAT) compiler.
380+Other Ada compilers are not currently supported, and
381+attempting to debug executables produced by them is most likely
382+to be difficult.
383+
384+
385+@cindex expressions in Ada
386+@menu
387+* Ada Mode Intro:: General remarks on the Ada syntax
388+ and semantics supported by Ada mode
389+ in @value{GDBN}
390+* Omissions from Ada:: Restrictions on the Ada expression syntax.
391+* Additions to Ada:: Extensions of the Ada expression syntax.
392+* Stopping Before Main Program:: Debugging the program during elaboration.
393+* Ada Exceptions:: Setting breakpoints on exception handlers.
394+* Ada Generic Units:: Dealing with generic instantiations.
395+* Ada Glitches:: Known peculiarities of Ada mode.
396+@end menu
397+
398+@node Ada Mode Intro
399+@subsubsection Introduction
400+@cindex Ada mode, general
401+
402+The Ada mode of @value{GDBN} supports a fairly large subset of Ada expression
403+syntax, with some extensions.
404+The philosophy behind the design of this subset is
405+
406+@itemize @bullet
407+@item
408+That @value{GDBN} should provide basic literals and access to operations for
409+arithmetic, dereferencing, field selection, indexing, and subprogram calls,
410+leaving more sophisticated computations to subprograms written into the
411+program (which therefore may be called from @value{GDBN}).
412+
413+@item
414+That type safety and strict adherence to Ada language restrictions
415+are not particularly important to the @value{GDBN} user.
416+
417+@item
418+That brevity is important to the @value{GDBN} user.
419+@end itemize
420+
421+Thus, for brevity, the debugger acts as if there were
422+implicit @code{with} and @code{use} clauses in effect for all user-written
423+packages, making it unnecessary to fully qualify most names with
424+their packages, regardless of context. Where this causes ambiguity,
425+@value{GDBN} asks the user's intent.
426+
427+The debugger will start in Ada mode if it detects an Ada main program.
428+As for other languages, it will enter Ada mode when stopped in a program that
429+was translated from an Ada source file.
430+
431+While in Ada mode, you may use `@t{--}' for comments. This is useful
432+mostly for documenting command files. The standard @value{GDBN} comment
433+(@samp{#}) still works at the beginning of a line in Ada mode, but not in the
434+middle (to allow based literals).
435+
436+The debugger supports limited overloading. Given a subprogram call in which
437+the function symbol has multiple definitions, it will use the number of
438+actual parameters and some information about their types to attempt to narrow
439+the set of definitions. It also makes very limited use of context, preferring
440+procedures to functions in the context of the @code{call} command, and
441+functions to procedures elsewhere.
442+
443+@node Omissions from Ada
444+@subsubsection Omissions from Ada
445+@cindex Ada, omissions from
446+
447+Here are the notable omissions from the subset:
448+
449+@itemize @bullet
450+@item
451+Only a subset of the attributes are supported:
452+
453+@itemize @minus
454+@item
455+@t{'First}, @t{'Last}, and @t{'Length}
456+ on array objects (not on types and subtypes).
457+
458+@item
459+@t{'Min} and @t{'Max}.
460+
461+@item
462+@t{'Pos} and @t{'Val}.
463+
464+@item
465+@t{'Tag}.
466+
467+@item
468+@t{'Range} on array objects (not subtypes), but only as the right
469+operand of the membership (@code{in}) operator.
470+
471+@item
472+@t{'Access}, @t{'Unchecked_Access}, and
473+@t{'Unrestricted_Access} (a GNAT extension).
474+
475+@item
476+@t{'Address}.
477+@end itemize
478+
479+@item
480+The names in
481+@code{Characters.Latin_1} are not available and
482+concatenation is not implemented. Thus, escape characters in strings are
483+not currently available.
484+
485+@item
486+Equality tests (@samp{=} and @samp{/=}) on arrays test for bitwise
487+equality of representations. They will generally work correctly
488+for strings and arrays whose elements have integer or enumeration types.
489+They may not work correctly for arrays whose element
490+types have user-defined equality, for arrays of real values
491+(in particular, IEEE-conformant floating point, because of negative
492+zeroes and NaNs), and for arrays whose elements contain unused bits with
493+indeterminate values.
494+
495+@item
496+The other component-by-component array operations (@code{and}, @code{or},
497+@code{xor}, @code{not}, and relational tests other than equality)
498+are not implemented.
499+
500+@item
501+There are no record or array aggregates.
502+
503+@item
504+Dispatching subprogram calls are not implemented.
505+
506+@item
507+The overloading algorithm is much more limited (i.e., less selective)
508+than that of real Ada. It makes only limited use of the context in which a subexpression
509+appears to resolve its meaning, and it is much looser in its rules for allowing
510+type matches. As a result, some function calls will be ambiguous, and the user
511+will be asked to choose the proper resolution.
512+
513+@item
514+The @code{new} operator is not implemented.
515+
516+@item
517+Entry calls are not implemented.
518+
519+@item
520+Aside from printing, arithmetic operations on the native VAX floating-point
521+formats are not supported.
522+
523+@item
524+It is not possible to slice a packed array.
525+@end itemize
526+
527+@node Additions to Ada
528+@subsubsection Additions to Ada
529+@cindex Ada, deviations from
530+
531+As it does for other languages, @value{GDBN} makes certain generic
532+extensions to Ada (@pxref{Expressions}):
533+
534+@itemize @bullet
535+@item
536+If the expression @var{E} is a variable residing in memory
537+(typically a local variable or array element) and @var{N} is
538+a positive integer, then @code{@var{E}@@@var{N}} displays the values of
539+@var{E} and the @var{N}-1 adjacent variables following it in memory as an array.
540+In Ada, this operator is generally not necessary, since its prime use
541+is in displaying parts of an array, and slicing will usually do this in Ada.
542+However, there are occasional uses when debugging programs
543+in which certain debugging information has been optimized away.
544+
545+@item
546+@code{@var{B}::@var{var}} means ``the variable named @var{var} that appears
547+in function or file @var{B}.'' When @var{B} is a file name, you must typically
548+surround it in single quotes.
549+
550+@item
551+The expression @code{@{@var{type}@} @var{addr}} means ``the variable of type
552+@var{type} that appears at address @var{addr}.''
553+
554+@item
555+A name starting with @samp{$} is a convenience variable
556+(@pxref{Convenience Vars}) or a machine register (@pxref{Registers}).
557+@end itemize
558+
559+In addition, @value{GDBN} provides a few other shortcuts and outright additions specific
560+to Ada:
561+
562+@itemize @bullet
563+@item
564+The assignment statement is allowed as an expression, returning
565+its right-hand operand as its value. Thus, you may enter
566+
567+@smallexample
568+set x := y + 3
569+print A(tmp := y + 1)
570+@end smallexample
571+
572+@item
573+The semicolon is allowed as an ``operator,'' returning as its value
574+the value of its right-hand operand.
575+This allows, for example,
576+complex conditional breaks:
577+
578+@smallexample
579+break f
580+condition 1 (report(i); k += 1; A(k) > 100)
581+@end smallexample
582+
583+@item
584+Rather than use catenation and symbolic character names to introduce special
585+characters into strings, one may instead use a special bracket notation,
586+which is also used to print strings. A sequence of characters of the form
587+@samp{["@var{XX}"]} within a string or character literal denotes the
588+(single) character whose numeric encoding is @var{XX} in hexadecimal. The
589+sequence of characters @samp{["""]} also denotes a single quotation mark
590+in strings. For example,
591+@smallexample
592+ "One line.["0a"]Next line.["0a"]"
593+@end smallexample
594+@noindent
595+Contains an ASCII newline character (@code{Ada.Characters.Latin_1.LF}) after each
596+period.
597+
598+@item
599+The subtype used as a prefix for the attributes @t{'Pos}, @t{'Min}, and
600+@t{'Max} is optional (and is ignored in any case). For example, it is valid
601+to write
602+
603+@smallexample
604+print 'max(x, y)
605+@end smallexample
606+
607+@item
608+When printing arrays, @value{GDBN} uses positional notation when the
609+array has a lower bound of 1, and uses a modified named notation otherwise.
610+For example, a one-dimensional array of three integers with a lower bound of 3 might print as
611+
612+@smallexample
613+(3 => 10, 17, 1)
614+@end smallexample
615+
616+@noindent
617+That is, in contrast to valid Ada, only the first component has a @code{=>}
618+clause.
619+
620+@item
621+You may abbreviate attributes in expressions with any unique,
622+multi-character subsequence of
623+their names (an exact match gets preference).
624+For example, you may use @t{a'len}, @t{a'gth}, or @t{a'lh}
625+in place of @t{a'length}.
626+
627+@item
628+@cindex quoting Ada internal identifiers
629+Since Ada is case-insensitive, the debugger normally maps identifiers you type
630+to lower case. The GNAT compiler uses upper-case characters for
631+some of its internal identifiers, which are normally of no interest to users.
632+For the rare occasions when you actually have to look at them,
633+enclose them in angle brackets to avoid the lower-case mapping.
634+For example,
635+@smallexample
636+(gdb) print <JMPBUF_SAVE>[0]
637+@end smallexample
638+
639+@item
640+Printing an object of class-wide type or dereferencing an
641+access-to-class-wide value will display all the components of the object's
642+specific type (as indicated by its run-time tag). Likewise, component
643+selection on such a value will operate on the specific type of the
644+object.
645+
646+@end itemize
647+
648+@node Stopping Before Main Program
649+@subsubsection Stopping at the Very Beginning
650+
651+@cindex breakpointing Ada elaboration code
652+It is sometimes necessary to debug the program during elaboration, and
653+before reaching the main procedure.
654+As defined in the Ada Reference
655+Manual, the elaboration code is invoked from a procedure called
656+@code{adainit}. To run your program up to the beginning of
657+elaboration, simply use the following two commands:
658+@code{tbreak adainit} and @code{run}.
659+
660+@node Ada Exceptions
661+@subsubsection Breaking on Ada Exceptions
662+@cindex Ada, exceptions
663+
664+In Ada mode, you can set breakpoints that trip when your program raises
665+selected exceptions.
666+
667+@table @code
668+@kindex break exception
669+@item break exception
670+Set a breakpoint that trips whenever (any task in the) program raises
671+any exception.
672+
673+@item break exception @var{name}
674+Set a breakpoint that trips whenever (any task in the) program raises
675+the exception @var{name}.
676+
677+When inserting a breakpoint on a specific exception for which an
678+homonym entity exists in the application, it is necessary to prefix
679+the exception name with its package name. In particular, if an entity
680+sharing the same name as one of the standard exceptions has been defined,
681+the exception name must be prefixed with package @code{Standard} when
682+setting a breakpoint on this exception.
683+
684+@smallexample
685+@iftex
686+@leftskip=0.5cm
687+@end iftex
688+(gdb) break exception Standard.Constraint_Error
689+@end smallexample
690+
691+@item break exception unhandled
692+Set a breakpoint that trips whenever (any task in the) program raises an
693+exception for which there is no handler.
694+At the moment,
695+depending on the implementation of exceptions used on your platform,
696+this may not have quite the desired effect. Other forms of
697+exception breaking stop the program at the point the exception is raised.
698+In Ada implementations that use setjmp and longjmp to implement exception
699+handling, however, unhandled exceptions are not detected until the
700+affected task's stack is completely unwound. Thus, you find out that a
701+task has terminated with an exception, but you aren't told where it was
702+raised.
703+
704+@kindex info exceptions
705+@item info exceptions
706+@itemx info exceptions @var{regexp}
707+The @code{info exceptions} command permits the user to examine all defined
708+exceptions within Ada programs. With a regular expression, @var{regexp}, as
709+argument, prints out only those exceptions whose name matches @var{regexp}.
710+@end table
711+
712+@node Ada Generic Units
713+@subsubsection Debugging Generic Units
714+@cindex Ada, generic units
715+
716+GNAT always uses code expansion for generic instantiation. This means that
717+each time an instantiation occurs, a complete copy of the original code is
718+made with appropriate substitutions.
719+
720+It is not possible to refer to the original generic entities themselves
721+in @value{GDBN} (there is no code to refer to), but it
722+is certainly possible to debug a particular instance of a generic, simply by
723+using the appropriate expanded names. For example, suppose that
724+@code{Gen} is a generic package:
725+
726+@smallexample
727+-- In file gen.ads:
728+generic package Gen is
729+ function F (v1 : Integer) return Integer;
730+end Gen;
731+
732+-- In file gen.adb:
733+package body Gen is
734+ function F (v1 : Integer) return Integer is
735+ begin
736+ return v1+1; -- Line 5
737+ end F;
738+end Gen;
739+@end smallexample
740+
741+@noindent
742+and we have the following expansions
743+
744+@smallexample
745+with Gen;
746+procedure G is
747+ package Gen1 is new Gen;
748+ package Gen2 is new Gen;
749+
750+ I : Integer := 0;
751+begin
752+ I := Gen1.F (I);
753+ I := Gen2.F (I);
754+ I := Gen1.F (I);
755+ I := Gen2.F (I);
756+end;
757+@end smallexample
758+
759+@noindent
760+Then to break on a call to procedure @code{F} in the @code{Gen2} instance, simply
761+use the command:
762+
763+@smallexample
764+break G.Gen2.F
765+@end smallexample
766+
767+When a breakpoint occurs, you can step through the code of the generic
768+instance in the normal manner. You can also examine values of data in the
769+normal manner, providing the appropriate generic package qualification to
770+refer to non-local entities.
771+
772+@node Ada Glitches
773+@subsubsection Known Peculiarities of Ada Mode
774+@cindex Ada, problems
775+
776+Besides the omissions listed previously (@pxref{Omissions from Ada}),
777+we know of several problems with and limitations of Ada mode in
778+@value{GDBN},
779+some of which will be fixed with planned future releases of the debugger
780+and the GNU Ada compiler.
781+
782+@itemize @bullet
783+@item
784+Currently, the debugger
785+has insufficient information to determine whether certain pointers represent
786+pointers to objects or the objects themselves.
787+Thus, the user may have to tack an extra @code{.all} after an expression
788+to get it printed properly.
789+
790+@item
791+Static constants that the compiler chooses not to materialize as objects in
792+storage are invisible to the debugger.
793+
794+@item
795+Named parameter associations in function argument lists are ignored (the
796+argument lists are treated as positional).
797+
798+@item
799+Many useful library packages are currently invisible to the debugger.
800+
801+@item
802+Fixed-point arithmetic, conversions, input, and output is carried out using
803+floating-point arithmetic, and may give results that only approximate those on
804+the host machine.
805+
806+@item
807+The type of the @t{'Address} attribute may not be @code{System.Address}.
808+
809+@item
810+When stopped in a particular subprogram, you can access variables defined
811+in other, lexically
812+enclosing subprograms by their simple names. At the moment, however, this
813+may not always work; it depends on whether the compiler happens to have
814+made the necessary information (the ``static link'') available
815+at execution time, which it can sometimes avoid. Of course,
816+even in those cases where
817+the compiler does not provide the information, you can still look at such
818+variables by issuing the appropriate number of @code{up} commands to get to
819+frame containing the variable you wish to see.
820+Access to non-local variables does not, at the moment, work in
821+the test expressions for conditional breakpoints
822+(@pxref{Conditions, ,Break conditions}) unless you happen to specify these
823+while stopped in the subprogram in which they are to be applied.
824+
825+@item
826+Depending on the platform, it is not always possible to set breakpoints
827+on nested functions by name (e.g., @code{break foo}). In effect, the
828+nested functions act like local variables of the enclosing function.
829+On these platforms, you must wait until @value{GDBN} is stopped in
830+the enclosing function before using this form of @code{break} command.
831+This is not much of a limitation, since you can still set a breakpoint on
832+the first line of the desired function using the usual
833+@code{break @var{file}:@var{line}} syntax.
834+
835+@item
836+The GNAT compiler never generates the prefix @code{Standard} for any of
837+the standard symbols defined by the Ada language. @value{GDBN} knows about
838+this: it will strip the prefix from names when you use it, and will never
839+look for a name you have so qualified among local symbols, nor match against
840+symbols in other packages or subprograms. If you have
841+defined entities anywhere in your program other than parameters and
842+local variables whose simple names match names in @code{Standard},
843+GNAT's lack of qualification here can cause confusion. When this happens,
844+you can usually resolve the confusion
845+by qualifying the problematic names with package
846+@code{Standard} explicitly.
847+@end itemize
848+
849 @node Unsupported languages
850 @section Unsupported languages
851
852
This page took 0.130659 seconds and 4 git commands to generate.