Daily bump.
[official-gcc.git] / gcc / ada / exp_dbug.ads
blob3415e7db55f0e3774a0c47357eb4654142405268
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- E X P _ D B U G --
6 -- --
7 -- S p e c --
8 -- --
9 -- $Revision: 1.1 $
10 -- --
11 -- Copyright (C) 1996-2001 Free Software Foundation, Inc. --
12 -- --
13 -- GNAT is free software; you can redistribute it and/or modify it under --
14 -- terms of the GNU General Public License as published by the Free Soft- --
15 -- ware Foundation; either version 2, or (at your option) any later ver- --
16 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
17 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
18 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
19 -- for more details. You should have received a copy of the GNU General --
20 -- Public License distributed with GNAT; see file COPYING. If not, write --
21 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
22 -- MA 02111-1307, USA. --
23 -- --
24 -- GNAT was originally developed by the GNAT team at New York University. --
25 -- Extensive contributions were provided by Ada Core Technologies Inc. --
26 -- --
27 ------------------------------------------------------------------------------
29 -- Expand routines for generation of special declarations used by the
30 -- debugger. In accordance with the Dwarf 2.2 specification, certain
31 -- type names are encoded to provide information to the debugger.
33 with Sinfo; use Sinfo;
34 with Types; use Types;
35 with Uintp; use Uintp;
36 with Get_Targ; use Get_Targ;
38 package Exp_Dbug is
40 -----------------------------------------------------
41 -- Encoding and Qualification of Names of Entities --
42 -----------------------------------------------------
44 -- This section describes how the names of entities are encoded in
45 -- the generated debugging information.
47 -- An entity in Ada has a name of the form X.Y.Z ... E where X,Y,Z
48 -- are the enclosing scopes (not including Standard at the start).
50 -- The encoding of the name follows this basic qualified naming scheme,
51 -- where the encoding of individual entity names is as described in
52 -- Namet (i.e. in particular names present in the original source are
53 -- folded to all lower case, with upper half and wide characters encoded
54 -- as described in Namet). Upper case letters are used only for entities
55 -- generated by the compiler.
57 -- There are two cases, global entities, and local entities. In more
58 -- formal terms, local entities are those which have a dynamic enclosing
59 -- scope, and global entities are at the library level, except that we
60 -- always consider procedures to be global entities, even if they are
61 -- nested (that's because at the debugger level a procedure name refers
62 -- to the code, and the code is indeed a global entity, including the
63 -- case of nested procedures.) In addition, we also consider all types
64 -- to be global entities, even if they are defined within a procedure.
66 -- The reason for full treating all type names as global entities is
67 -- that a number of our type encodings work by having related type
68 -- names, and we need the full qualification to keep this unique.
70 -- For global entities, the encoded name includes all components of the
71 -- fully expanded name (but omitting Standard at the start). For example,
72 -- if a library level child package P.Q has an embedded package R, and
73 -- there is an entity in this embdded package whose name is S, the encoded
74 -- name will include the components p.q.r.s.
76 -- For local entities, the encoded name only includes the components
77 -- up to the enclosing dynamic scope (other than a block). At run time,
78 -- such a dynamic scope is a subprogram, and the debugging formats know
79 -- about local variables of procedures, so it is not necessary to have
80 -- full qualification for such entities. In particular this means that
81 -- direct local variables of a procedure are not qualified.
83 -- As an example of the local name convention, consider a procedure V.W
84 -- with a local variable X, and a nested block Y containing an entity
85 -- Z. The fully qualified names of the entities X and Z are:
87 -- V.W.X
88 -- V.W.Y.Z
90 -- but since V.W is a subprogram, the encoded names will end up
91 -- encoding only
93 -- x
94 -- y.z
96 -- The separating dots are translated into double underscores.
98 -- Note: there is one exception, which is that on IRIX, for workshop
99 -- back compatibility, dots are retained as dots. In the rest of this
100 -- document we assume the double underscore encoding.
102 -----------------------------
103 -- Handling of Overloading --
104 -----------------------------
106 -- The above scheme is incomplete with respect to overloaded
107 -- subprograms, since overloading can legitimately result in a
108 -- case of two entities with exactly the same fully qualified names.
109 -- To distinguish between entries in a set of overloaded subprograms,
110 -- the encoded names are serialized by adding one of the two suffixes:
112 -- $n (dollar sign)
113 -- __nn (two underscores)
115 -- where nn is a serial number (1 for the first overloaded function,
116 -- 2 for the second, etc.). The former suffix is used when a dollar
117 -- sign is a valid symbol on the target machine and the latter is
118 -- used when it is not. No suffix need appear on the encoding of
119 -- the first overloading of a subprogram.
121 -- These names are prefixed by the normal full qualification. So
122 -- for example, the third instance of the subprogram qrs in package
123 -- yz would have one of the two names:
125 -- yz__qrs$3
126 -- yz__qrs__3
128 -- The serial number always appears at the end as shown, even in the
129 -- case of subprograms nested inside overloaded subprograms, and only
130 -- when the named subprogram is overloaded. For example, consider
131 -- the following situation:
133 -- package body Yz is
134 -- procedure Qrs is -- Encoded name is yz__qrs
135 -- procedure Tuv is ... end; -- Encoded name is yz__qrs__tuv
136 -- begin ... end Qrs;
138 -- procedure Qrs (X: Integer) is -- Encoded name is yz__qrs__2
139 -- procedure Tuv is ... end; -- Encoded name is yz__qrs__tuv
140 -- -- (not yz__qrs__2__tuv).
141 -- procedure Tuv (X: INTEGER) -- Encoded name is yz__qrs__tuv__2
142 -- begin ... end Tuv;
144 -- procedure Tuv (X: INTEGER) -- Encoded name is yz__qrs__tuv__3
145 -- begin ... end Tuv;
146 -- begin ... end Qrs;
147 -- end Yz;
149 -- This example also serves to illustrate, a case in which the
150 -- debugging data are currently ambiguous. The two parameterless
151 -- versions of Yz.Qrs.Tuv have the same encoded names in the
152 -- debugging data. However, the actual external symbols (which
153 -- linkers use to resolve references) will be modified with an
154 -- an additional suffix so that they do not clash. Thus, there will
155 -- be cases in which the name of a function shown in the debugging
156 -- data differs from that function's "official" external name, and
157 -- in which several different functions have exactly the same name
158 -- as far as the debugger is concerned. We don't consider this too
159 -- much of a problem, since the only way the user has of referring
160 -- to these functions by name is, in fact, Yz.Qrs.Tuv, so that the
161 -- reference is inherently ambiguous from the user's perspective,
162 -- regardless of internal encodings (in these cases, the debugger
163 -- can provide a menu of options to allow the user to disambiguate).
165 --------------------
166 -- Operator Names --
167 --------------------
169 -- The above rules applied to operator names would result in names
170 -- with quotation marks, which are not typically allowed by assemblers
171 -- and linkers, and even if allowed would be odd and hard to deal with.
172 -- To avoid this problem, operator names are encoded as follows:
174 -- Oabs abs
175 -- Oand and
176 -- Omod mod
177 -- Onot not
178 -- Oor or
179 -- Orem rem
180 -- Oxor xor
181 -- Oeq =
182 -- One /=
183 -- Olt <
184 -- Ole <=
185 -- Ogt >
186 -- Oge >=
187 -- Oadd +
188 -- Osubtract -
189 -- Oconcat &
190 -- Omultiply *
191 -- Odivide /
192 -- Oexpon **
194 -- These names are prefixed by the normal full qualification, and
195 -- suffixed by the overloading identification. So for example, the
196 -- second operator "=" defined in package Extra.Messages would
197 -- have the name:
199 -- extra__messages__Oeq__2
201 ----------------------------------
202 -- Resolving Other Name Clashes --
203 ----------------------------------
205 -- It might be thought that the above scheme is complete, but in Ada 95,
206 -- full qualification is insufficient to uniquely identify an entity
207 -- in the program, even if it is not an overloaded subprogram. There
208 -- are two possible confusions:
210 -- a.b
212 -- interpretation 1: entity b in body of package a
213 -- interpretation 2: child procedure b of package a
215 -- a.b.c
217 -- interpretation 1: entity c in child package a.b
218 -- interpretation 2: entity c in nested package b in body of a
220 -- It is perfectly valid in both cases for both interpretations to
221 -- be valid within a single program. This is a bit of a surprise since
222 -- certainly in Ada 83, full qualification was sufficient, but not in
223 -- Ada 95. The result is that the above scheme can result in duplicate
224 -- names. This would not be so bad if the effect were just restricted
225 -- to debugging information, but in fact in both the above cases, it
226 -- is possible for both symbols to be external names, and so we have
227 -- a real problem of name clashes.
229 -- To deal with this situation, we provide two additional encoding
230 -- rules for names
232 -- First: all library subprogram names are preceded by the string
233 -- _ada_ (which causes no duplications, since normal Ada names can
234 -- never start with an underscore. This not only solves the first
235 -- case of duplication, but also solves another pragmatic problem
236 -- which is that otherwise Ada procedures can generate names that
237 -- clash with existing system function names. Most notably, we can
238 -- have clashes in the case of procedure Main with the C main that
239 -- in some systems is always present.
241 -- Second, for the case where nested packages declared in package
242 -- bodies can cause trouble, we add a suffix which shows which
243 -- entities in the list are body-nested packages, i.e. packages
244 -- whose spec is within a package body. The rules are as follows,
245 -- given a list of names in a qualified name name1.name2....
247 -- If none are body-nested package entities, then there is no suffix
249 -- If at least one is a body-nested package entity, then the suffix
250 -- is X followed by a string of b's and n's (b = body-nested package
251 -- entity, n = not a body-nested package).
253 -- There is one element in this string for each entity in the encoded
254 -- expanded name except the first (the rules are such that the first
255 -- entity of the encoded expanded name can never be a body-nested'
256 -- package. Trailing n's are omitted, as is the last b (there must
257 -- be at least one b, or we would not be generating a suffix at all).
259 -- For example, suppose we have
261 -- package x is
262 -- pragma Elaborate_Body;
263 -- m1 : integer; -- #1
264 -- end x;
266 -- package body x is
267 -- package y is m2 : integer; end y; -- #2
268 -- package body y is
269 -- package z is r : integer; end z; -- #3
270 -- end;
271 -- m3 : integer; -- #4
272 -- end x;
274 -- package x.y is
275 -- pragma Elaborate_Body;
276 -- m2 : integer; -- #5
277 -- end x.y;
279 -- package body x.y is
280 -- m3 : integer; -- #6
281 -- procedure j is -- #7
282 -- package k is
283 -- z : integer; -- #8
284 -- end k;
285 -- begin
286 -- null;
287 -- end j;
288 -- end x.y;
290 -- procedure x.m3 is begin null; end; -- #9
292 -- Then the encodings would be:
294 -- #1. x__m1 (no BNPE's in sight)
295 -- #2. x__y__m2X (y is a BNPE)
296 -- #3. x__y__z__rXb (y is a BNPE, so is z)
297 -- #4. x__m3 (no BNPE's in sight)
298 -- #5. x__y__m2 (no BNPE's in sight)
299 -- #6. x__y__m3 (no BNPE's in signt)
300 -- #7. x__y__j (no BNPE's in sight)
301 -- #8. k__z (no BNPE's, only up to procedure)
302 -- #9 _ada_x__m3 (library level subprogram)
304 -- Note that we have instances here of both kind of potential name
305 -- clashes, and the above examples show how the encodings avoid the
306 -- clash as follows:
308 -- Lines #4 and #9 both refer to the entity x.m3, but #9 is a library
309 -- level subprogram, so it is preceded by the string _ada_ which acts
310 -- to distinguish it from the package body entity.
312 -- Lines #2 and #5 both refer to the entity x.y.m2, but the first
313 -- instance is inside the body-nested package y, so there is an X
314 -- suffix to distinguish it from the child library entity.
316 -- Note that enumeration literals never need Xb type suffixes, since
317 -- they are never referenced using global external names.
319 ---------------------
320 -- Interface Names --
321 ---------------------
323 -- Note: if an interface name is present, then the external name
324 -- is taken from the specified interface name. Given the current
325 -- limitations of the gcc backend, this means that the debugging
326 -- name is also set to the interface name, but conceptually, it
327 -- would be possible (and indeed desirable) to have the debugging
328 -- information still use the Ada name as qualified above, so we
329 -- still fully qualify the name in the front end.
331 -------------------------------------
332 -- Encodings Related to Task Types --
333 -------------------------------------
335 -- Each task object defined by a single task declaration is associated
336 -- with a prefix that is used to qualify procedures defined in that
337 -- task. Given
339 -- package body P is
340 -- task body TaskObj is
341 -- procedure F1 is ... end;
342 -- begin
343 -- B;
344 -- end TaskObj;
345 -- end P;
347 -- The name of subprogram TaskObj.F1 is encoded as p__taskobjTK__f1,
348 -- The body, B, is contained in a subprogram whose name is
349 -- p__taskobjTKB.
351 ------------------------------------------
352 -- Encodings Related to Protected Types --
353 ------------------------------------------
355 -- Each protected type has an associated record type, that describes
356 -- the actual layout of the private data. In addition to the private
357 -- components of the type, the Corresponding_Record_Type includes one
358 -- component of type Protection, which is the actual lock structure.
359 -- The run-time size of the protected type is the size of the corres-
360 -- ponding record.
362 -- For a protected type prot, the Corresponding_Record_Type is encoded
363 -- as protV.
365 -- The operations of a protected type are encoded as follows: each
366 -- operation results in two subprograms, a locking one that is called
367 -- from outside of the object, and a non-locking one that is used for
368 -- calls from other operations on the same object. The locking operation
369 -- simply acquires the lock, and then calls the non-locking version.
370 -- The names of all of these have a prefix constructed from the name
371 -- of the name of the type, the string "PT", and a suffix which is P
372 -- or N, depending on whether this is the protected or non-locking
373 -- version of the operation.
375 -- Given the declaration:
377 -- protected type lock is
378 -- function get return integer;
379 -- procedure set (x: integer);
380 -- private
381 -- value : integer := 0;
382 -- end lock;
384 -- the following operations are created:
386 -- lockPT_getN
387 -- lockPT_getP,
388 -- lockPT_setN
389 -- lockPT_setP
391 ----------------------------------------------------
392 -- Conversion between Entities and External Names --
393 ----------------------------------------------------
395 No_Dollar_In_Label : constant Boolean := Get_No_Dollar_In_Label;
396 -- True iff the target allows dollar signs ("$") in external names
398 procedure Get_External_Name
399 (Entity : Entity_Id;
400 Has_Suffix : Boolean);
401 -- Set Name_Buffer and Name_Len to the external name of entity E.
402 -- The external name is the Interface_Name, if specified, unless
403 -- the entity has an address clause or a suffix.
405 -- If the Interface is not present, or not used, the external name
406 -- is the concatenation of:
408 -- - the string "_ada_", if the entity is a library subprogram,
409 -- - the names of any enclosing scopes, each followed by "__",
410 -- or "X_" if the next entity is a subunit)
411 -- - the name of the entity
412 -- - the string "$" (or "__" if target does not allow "$"), followed
413 -- by homonym number, if the entity is an overloaded subprogram
415 procedure Get_External_Name_With_Suffix
416 (Entity : Entity_Id;
417 Suffix : String);
418 -- Set Name_Buffer and Name_Len to the external name of entity E.
419 -- If Suffix is the empty string the external name is as above,
420 -- otherwise the external name is the concatenation of:
422 -- - the string "_ada_", if the entity is a library subprogram,
423 -- - the names of any enclosing scopes, each followed by "__",
424 -- or "X_" if the next entity is a subunit)
425 -- - the name of the entity
426 -- - the string "$" (or "__" if target does not allow "$"), followed
427 -- by homonym number, if the entity is an overloaded subprogram
428 -- - the string "___" followed by Suffix
430 function Get_Entity_Id (External_Name : String) return Entity_Id;
431 -- Find entity in current compilation unit, which has the given
432 -- External_Name.
434 ----------------------------
435 -- Debug Name Compression --
436 ----------------------------
438 -- The full qualification of names can lead to long names, and this
439 -- section describes the method used to compress these names. Such
440 -- compression is attempted if one of the following holds:
442 -- The length exceeds a maximum set in hostparm, currently set
443 -- to 128, but can be changed as needed.
445 -- The compiler switch -gnatC is set, setting the Compress_Debug_Names
446 -- switch in Opt to True.
448 -- If either of these conditions holds, name compression is attempted
449 -- by replacing the qualifying section as follows.
451 -- Given a name of the form
453 -- a__b__c__d
455 -- where a,b,c,d are arbitrary strings not containing a sequence
456 -- of exactly two underscores, the name is rewritten as:
458 -- XC????????_d
460 -- where ???????? are 8 hex digits representing a 32-bit checksum
461 -- value that identifies the sequence of compressed names. In
462 -- addition a dummy type declaration is generated as shown by
463 -- the following example. Supposed we have three compression
464 -- sequences
466 -- XC1234abcd corresponding to a__b__c__ prefix
467 -- XCabcd1234 corresponding to a__b__ prefix
468 -- XCab1234cd corresponding to a__ prefix
470 -- then an enumeration type declaration is generated:
472 -- type XC is
473 -- (XC1234abcdXnn, aXnn, bXnn, cXnn,
474 -- XCabcd1234Xnn, aXnn, bXnn,
475 -- XCab1234cdXnn, aXnn);
477 -- showing the meaning of each compressed prefix, so the debugger
478 -- can interpret the exact sequence of names that correspond to the
479 -- compressed sequence. The Xnn suffixes in the above are simply
480 -- serial numbers that are guaranteed to be different to ensure
481 -- that all names are unique, and are otherwise ignored.
483 --------------------------------------------
484 -- Subprograms for Handling Qualification --
485 --------------------------------------------
487 procedure Qualify_Entity_Names (N : Node_Id);
488 -- Given a node N, that represents a block, subprogram body, or package
489 -- body or spec, or protected or task type, sets a fully qualified name
490 -- for the defining entity of given construct, and also sets fully
491 -- qualified names for all enclosed entities of the construct (using
492 -- First_Entity/Next_Entity). Note that the actual modifications of the
493 -- names is postponed till a subsequent call to Qualify_All_Entity_Names.
494 -- Note: this routine does not deal with prepending _ada_ to library
495 -- subprogram names. The reason for this is that we only prepend _ada_
496 -- to the library entity itself, and not to names built from this name.
498 procedure Qualify_All_Entity_Names;
499 -- When Qualify_Entity_Names is called, no actual name changes are made,
500 -- i.e. the actual calls to Qualify_Entity_Name are deferred until a call
501 -- is made to this procedure. The reason for this deferral is that when
502 -- names are changed semantic processing may be affected. By deferring
503 -- the changes till just before gigi is called, we avoid any concerns
504 -- about such effects. Gigi itself does not use the names except for
505 -- output of names for debugging purposes (which is why we are doing
506 -- the name changes in the first place.
508 -- Note: the routines Get_Unqualified_[Decoded]_Name_String in Namet
509 -- are useful to remove qualification from a name qualified by the
510 -- call to Qualify_All_Entity_Names.
512 procedure Generate_Auxiliary_Types;
513 -- The process of qualifying names may result in name compression which
514 -- requires dummy enumeration types to be generated. This subprogram
515 -- ensures that these types are appropriately included in the tree.
517 --------------------------------
518 -- Handling of Numeric Values --
519 --------------------------------
521 -- All numeric values here are encoded as strings of decimal digits.
522 -- Only integer values need to be encoded. A negative value is encoded
523 -- as the corresponding positive value followed by a lower case m for
524 -- minus to indicate that the value is negative (e.g. 2m for -2).
526 -------------------------
527 -- Type Name Encodings --
528 -------------------------
530 -- In the following typ is the name of the type as normally encoded by
531 -- the debugger rules, i.e. a non-qualified name, all in lower case,
532 -- with standard encoding of upper half and wide characters
534 ------------------------
535 -- Encapsulated Types --
536 ------------------------
538 -- In some cases, the compiler encapsulates a type by wrapping it in
539 -- a structure. For example, this is used when a size or alignment
540 -- specification requires a larger type. Consider:
542 -- type y is mod 2 ** 64;
543 -- for y'size use 256;
545 -- In this case the compile generates a structure type y___PAD, which
546 -- has a single field whose name is F. This single field is 64 bits
547 -- long and contains the actual value.
549 -- A similar encapsulation is done for some packed array types,
550 -- in which case the structure type is y___LJM and the field name
551 -- is OBJECT.
553 -- When the debugger sees an object of a type whose name has a
554 -- suffix not otherwise mentioned in this specification, the type
555 -- is a record containing a single field, and the name of that field
556 -- is all upper-case letters, it should look inside to get the value
557 -- of the field, and neither the outer structure name, nor the
558 -- field name should appear when the value is printed.
560 -----------------------
561 -- Fixed-Point Types --
562 -----------------------
564 -- Fixed-point types are encoded using a suffix that indicates the
565 -- delta and small values. The actual type itself is a normal
566 -- integer type.
568 -- typ___XF_nn_dd
569 -- typ___XF_nn_dd_nn_dd
571 -- The first form is used when small = delta. The value of delta (and
572 -- small) is given by the rational nn/dd, where nn and dd are decimal
573 -- integers.
575 -- The second form is used if the small value is different from the
576 -- delta. In this case, the first nn/dd rational value is for delta,
577 -- and the second value is for small.
579 ------------------------------
580 -- VAX Floating-Point Types --
581 ------------------------------
583 -- Vax floating-point types are represented at run time as integer
584 -- types, which are treated specially by the code generator. Their
585 -- type names are encoded with the following suffix:
587 -- typ___XFF
588 -- typ___XFD
589 -- typ___XFG
591 -- representing the Vax F Float, D Float, and G Float types. The
592 -- debugger must treat these specially. In particular, printing
593 -- these values can be achieved using the debug procedures that
594 -- are provided in package System.Vax_Float_Operations:
596 -- procedure Debug_Output_D (Arg : D);
597 -- procedure Debug_Output_F (Arg : F);
598 -- procedure Debug_Output_G (Arg : G);
600 -- These three procedures take a Vax floating-point argument, and
601 -- output a corresponding decimal representation to standard output
602 -- with no terminating line return.
604 --------------------
605 -- Discrete Types --
606 --------------------
608 -- Discrete types are coded with a suffix indicating the range in
609 -- the case where one or both of the bounds are discriminants or
610 -- variable.
612 -- Note: at the current time, we also encode static bounds if they
613 -- do not match the natural machine type bounds, but this may be
614 -- removed in the future, since it is redundant for most debugging
615 -- formats. However, we do not ever need XD encoding for enumeration
616 -- base types, since here it is always clear what the bounds are
617 -- from the number of enumeration literals, and of course we do
618 -- not need to encode the dummy XR types generated for renamings.
620 -- typ___XD
621 -- typ___XDL_lowerbound
622 -- typ___XDU_upperbound
623 -- typ___XDLU_lowerbound__upperbound
625 -- If a discrete type is a natural machine type (i.e. its bounds
626 -- correspond in a natural manner to its size), then it is left
627 -- unencoded. The above encoding forms are used when there is a
628 -- constrained range that does not correspond to the size or that
629 -- has discriminant references or other non-static bounds.
631 -- The first form is used if both bounds are dynamic, in which case
632 -- two constant objects are present whose names are typ___L and
633 -- typ___U in the same scope as typ, and the values of these constants
634 -- indicate the bounds. As far as the debugger is concerned, these
635 -- are simply variables that can be accessed like any other variables.
636 -- In the enumeration case, these values correspond to the Enum_Rep
637 -- values for the lower and upper bounds.
639 -- The second form is used if the upper bound is dynamic, but the
640 -- lower bound is either constant or depends on a discriminant of
641 -- the record with which the type is associated. The upper bound
642 -- is stored in a constant object of name typ___U as previously
643 -- described, but the lower bound is encoded directly into the
644 -- name as either a decimal integer, or as the discriminant name.
646 -- The third form is similarly used if the lower bound is dynamic,
647 -- but the upper bound is static or a discriminant reference, in
648 -- which case the lower bound is stored in a constant object of
649 -- name typ___L, and the upper bound is encoded directly into the
650 -- name as either a decimal integer, or as the discriminant name.
652 -- The fourth form is used if both bounds are discriminant references
653 -- or static values, with the encoding first for the lower bound,
654 -- then for the upper bound, as previously described.
656 ------------------
657 -- Biased Types --
658 ------------------
660 -- Only discrete types can be biased, and the fact that they are
661 -- biased is indicated by a suffix of the form:
663 -- typ___XB_lowerbound__upperbound
665 -- Here lowerbound and upperbound are decimal integers, with the
666 -- usual (postfix "m") encoding for negative numbers. Biased
667 -- types are only possible where the bounds are static, and the
668 -- values are represented as unsigned offsets from the lower
669 -- bound given. For example:
671 -- type Q is range 10 .. 15;
672 -- for Q'size use 3;
674 -- The size clause will force values of type Q in memory to be
675 -- stored in biased form (e.g. 11 will be represented by the
676 -- bit pattern 001).
678 ----------------------------------------------
679 -- Record Types with Variable-Length Fields --
680 ----------------------------------------------
682 -- The debugging formats do not fully support these types, and indeed
683 -- some formats simply generate no useful information at all for such
684 -- types. In order to provide information for the debugger, gigi creates
685 -- a parallel type in the same scope with one of the names
687 -- type___XVE
688 -- type___XVU
690 -- The former name is used for a record and the latter for the union
691 -- that is made for a variant record (see below) if that union has
692 -- variable size. These encodings suffix any other encodings that
693 -- might be suffixed to the type name.
695 -- The idea here is to provide all the needed information to interpret
696 -- objects of the original type in the form of a "fixed up" type, which
697 -- is representable using the normal debugging information.
699 -- There are three cases to be dealt with. First, some fields may have
700 -- variable positions because they appear after variable-length fields.
701 -- To deal with this, we encode *all* the field bit positions of the
702 -- special ___XV type in a non-standard manner.
704 -- The idea is to encode not the position, but rather information
705 -- that allows computing the position of a field from the position
706 -- of the previous field. The algorithm for computing the actual
707 -- positions of all fields and the length of the record is as
708 -- follows. In this description, let P represent the current
709 -- bit position in the record.
711 -- 1. Initialize P to 0.
713 -- 2. For each field in the record,
715 -- 2a. If an alignment is given (see below), then round P
716 -- up, if needed, to the next multiple of that alignment.
718 -- 2b. If a bit position is given, then increment P by that
719 -- amount (that is, treat it as an offset from the end of the
720 -- preceding record).
722 -- 2c. Assign P as the actual position of the field.
724 -- 2d. Compute the length, L, of the represented field (see below)
725 -- and compute P'=P+L. Unless the field represents a variant part
726 -- (see below and also Variant Record Encoding), set P to P'.
728 -- The alignment, if present, is encoded in the field name of the
729 -- record, which has a suffix:
731 -- fieldname___XVAnn
733 -- where the nn after the XVA indicates the alignment value in storage
734 -- units. This encoding is present only if an alignment is present.
736 -- The size of the record described by an XVE-encoded type (in bits)
737 -- is generally the maximum value attained by P' in step 2d above,
738 -- rounded up according to the record's alignment.
740 -- Second, the variable-length fields themselves are represented by
741 -- replacing the type by a special access type. The designated type
742 -- of this access type is the original variable-length type, and the
743 -- fact that this field has been transformed in this way is signalled
744 -- by encoding the field name as:
746 -- field___XVL
748 -- where field is the original field name. If a field is both
749 -- variable-length and also needs an alignment encoding, then the
750 -- encodings are combined using:
752 -- field___XVLnn
754 -- Note: the reason that we change the type is so that the resulting
755 -- type has no variable-length fields. At least some of the formats
756 -- used for debugging information simply cannot tolerate variable-
757 -- length fields, so the encoded information would get lost.
759 -- Third, in the case of a variant record, the special union
760 -- that contains the variants is replaced by a normal C union.
761 -- In this case, the positions are all zero.
763 -- As an example of this encoding, consider the declarations:
765 -- type Q is array (1 .. V1) of Float; -- alignment 4
766 -- type R is array (1 .. V2) of Long_Float; -- alignment 8
768 -- type X is record
769 -- A : Character;
770 -- B : Float;
771 -- C : String (1 .. V3);
772 -- D : Float;
773 -- E : Q;
774 -- F : R;
775 -- G : Float;
776 -- end record;
778 -- The encoded type looks like:
780 -- type anonymousQ is access Q;
781 -- type anonymousR is access R;
783 -- type X___XVE is record
784 -- A : Character; -- position contains 0
785 -- B : Float; -- position contains 24
786 -- C___XVL : access String (1 .. V3); -- position contains 0
787 -- D___XVA4 : Float; -- position contains 0
788 -- E___XVL4 : anonymousQ; -- position contains 0
789 -- F___XVL8 : anonymousR; -- position contains 0
790 -- G : Float; -- position contains 0
791 -- end record;
793 -- Any bit sizes recorded for fields other than dynamic fields and
794 -- variants are honored as for ordinary records.
796 -- Notes:
798 -- 1) The B field could also have been encoded by using a position
799 -- of zero, and an alignment of 4, but in such a case, the coding by
800 -- position is preferred (since it takes up less space). We have used
801 -- the (illegal) notation access xxx as field types in the example
802 -- above.
804 -- 2) The E field does not actually need the alignment indication
805 -- but this may not be detected in this case by the conversion
806 -- routines.
808 -- All discriminants always appear before any variable-length
809 -- fields that depend on them. So they can be located independent
810 -- of the variable-length field, using the standard procedure for
811 -- computing positions described above.
813 -- The size of the ___XVE or ___XVU record or union is set to the
814 -- alignment (in bytes) of the original object so that the debugger
815 -- can calculate the size of the original type.
817 -- 3) Our conventions do not cover all XVE-encoded records in which
818 -- some, but not all, fields have representation clauses. Such
819 -- records may, therefore, be displayed incorrectly by debuggers.
820 -- This situation is not common.
822 -----------------------
823 -- Base Record Types --
824 -----------------------
826 -- Under certain circumstances, debuggers need two descriptions
827 -- of a record type, one that gives the actual details of the
828 -- base type's structure (as described elsewhere in these
829 -- comments) and one that may be used to obtain information
830 -- about the particular subtype and the size of the objects
831 -- being typed. In such cases the compiler will substitute a
832 -- type whose name is typically compiler-generated and
833 -- irrelevant except as a key for obtaining the actual type.
834 -- Specifically, if this name is x, then we produce a record
835 -- type named x___XVS consisting of one field. The name of
836 -- this field is that of the actual type being encoded, which
837 -- we'll call y (the type of this single field is arbitrary).
838 -- Both x and y may have corresponding ___XVE types.
840 -- The size of the objects typed as x should be obtained from
841 -- the structure of x (and x___XVE, if applicable) as for
842 -- ordinary types unless there is a variable named x___XVZ, which,
843 -- if present, will hold the the size (in bits) of x.
845 -- The type x will either be a subtype of y (see also Subtypes
846 -- of Variant Records, below) or will contain no fields at
847 -- all. The layout, types, and positions of these fields will
848 -- be accurate, if present. (Currently, however, the GDB
849 -- debugger makes no use of x except to determine its size).
851 -- Among other uses, XVS types are sometimes used to encode
852 -- unconstrained types. For example, given
854 -- subtype Int is INTEGER range 0..10;
855 -- type T1 (N: Int := 0) is record
856 -- F1: String (1 .. N);
857 -- end record;
858 -- type AT1 is array (INTEGER range <>) of T1;
860 -- the element type for AT1 might have a type defined as if it had
861 -- been written:
863 -- type at1___C_PAD is record null; end record;
864 -- for at1___C_PAD'Size use 16 * 8;
866 -- and there would also be
868 -- type at1___C_PAD___XVS is record t1: Integer; end record;
869 -- type t1 is ...
871 -- Had the subtype Int been dynamic:
873 -- subtype Int is INTEGER range 0 .. M; -- M a variable
875 -- Then the compiler would also generate a declaration whose effect
876 -- would be
878 -- at1___C_PAD___XVZ: constant Integer := 32 + M * 8 + padding term;
880 -- Not all unconstrained types are so encoded; the XVS
881 -- convention may be unnecessary for unconstrained types of
882 -- fixed size. However, this encoding is always necessary when
883 -- a subcomponent type (array element's type or record field's
884 -- type) is an unconstrained record type some of whose
885 -- components depend on discriminant values.
887 -----------------
888 -- Array Types --
889 -----------------
891 -- Since there is no way for the debugger to obtain the index subtypes
892 -- for an array type, we produce a type that has the name of the
893 -- array type followed by "___XA" and is a record whose field names
894 -- are the names of the types for the bounds. The types of these
895 -- fields is an integer type which is meaningless.
897 -- To conserve space, we do not produce this type unless one of
898 -- the index types is either an enumeration type, has a variable
899 -- upper bound, has a lower bound different from the constant 1,
900 -- is a biased type, or is wider than "sizetype".
902 -- Given the full encoding of these types (see above description for
903 -- the encoding of discrete types), this means that all necessary
904 -- information for addressing arrays is available. In some
905 -- debugging formats, some or all of the bounds information may
906 -- be available redundantly, particularly in the fixed-point case,
907 -- but this information can in any case be ignored by the debugger.
909 ----------------------------
910 -- Note on Implicit Types --
911 ----------------------------
913 -- The compiler creates implicit type names in many situations where
914 -- a type is present semantically, but no specific name is present.
915 -- For example:
917 -- S : Integer range M .. N;
919 -- Here the subtype of S is not integer, but rather an anonymous
920 -- subtype of Integer. Where possible, the compiler generates names
921 -- for such anonymous types that are related to the type from which
922 -- the subtype is obtained as follows:
924 -- T name suffix
926 -- where name is the name from which the subtype is obtained, using
927 -- lower case letters and underscores, and suffix starts with an upper
928 -- case letter. For example, the name for the above declaration of S
929 -- might be:
931 -- TintegerS4b
933 -- If the debugger is asked to give the type of an entity and the type
934 -- has the form T name suffix, it is probably appropriate to just use
935 -- "name" in the response since this is what is meaningful to the
936 -- programmer.
938 -------------------------------------------------
939 -- Subprograms for Handling Encoded Type Names --
940 -------------------------------------------------
942 procedure Get_Encoded_Name (E : Entity_Id);
943 -- If the entity is a typename, store the external name of
944 -- the entity as in Get_External_Name, followed by three underscores
945 -- plus the type encoding in Name_Buffer with the length in Name_Len,
946 -- and an ASCII.NUL character stored following the name.
947 -- Otherwise set Name_Buffer and Name_Len to hold the entity name.
949 --------------
950 -- Renaming --
951 --------------
953 -- Debugging information is generated for exception, object, package,
954 -- and subprogram renaming (generic renamings are not significant, since
955 -- generic templates are not relevant at debugging time).
957 -- Consider a renaming declaration of the form
959 -- x typ renames y;
961 -- There is one case in which no special debugging information is required,
962 -- namely the case of an object renaming where the backend allocates a
963 -- reference for the renamed variable, and the entity x is this reference.
964 -- The debugger can handle this case without any special processing or
965 -- encoding (it won't know it was a renaming, but that does not matter).
967 -- All other cases of renaming generate a dummy type definition for
968 -- an entity whose name is:
970 -- x___XR for an object renaming
971 -- x___XRE for an exception renaming
972 -- x___XRP for a package renaming
974 -- The name is fully qualified in the usual manner, i.e. qualified in
975 -- the same manner as the entity x would be.
977 -- Note: subprogram renamings are not encoded at the present time.
979 -- The type is an enumeration type with a single enumeration literal
980 -- that is an identifier which describes the renamed variable.
982 -- For the simple entity case, where y is an entity name,
983 -- the enumeration is of the form:
985 -- (y___XE)
987 -- i.e. the enumeration type has a single field, whose name
988 -- matches the name y, with the XE suffix. The entity for this
989 -- enumeration literal is fully qualified in the usual manner.
990 -- All subprogram, exception, and package renamings fall into
991 -- this category, as well as simple object renamings.
993 -- For the object renaming case where y is a selected component or an
994 -- indexed component, the literal name is suffixed by additional fields
995 -- that give details of the components. The name starts as above with
996 -- a y___XE entity indicating the outer level variable. Then a series
997 -- of selections and indexing operations can be specified as follows:
999 -- Indexed component
1001 -- A series of subscript values appear in sequence, the number
1002 -- corresponds to the number of dimensions of the array. The
1003 -- subscripts have one of the following two forms:
1005 -- XSnnn
1007 -- Here nnn is a constant value, encoded as a decimal
1008 -- integer (pos value for enumeration type case). Negative
1009 -- values have a trailing 'm' as usual.
1011 -- XSe
1013 -- Here e is the (unqualified) name of a constant entity in
1014 -- the same scope as the renaming which contains the subscript
1015 -- value.
1017 -- Slice
1019 -- For the slice case, we have two entries. The first is for
1020 -- the lower bound of the slice, and has the form
1022 -- XLnnn
1023 -- XLe
1025 -- Specifies the lower bound, using exactly the same encoding
1026 -- as for an XS subscript as described above.
1028 -- Then the upper bound appears in the usual XSnnn/XSe form
1030 -- Selected component
1032 -- For a selected component, we have a single entry
1034 -- XRf
1036 -- Here f is the field name for the selection
1038 -- For an explicit deference (.all), we have a single entry
1040 -- XA
1042 -- As an example, consider the declarations:
1044 -- package p is
1045 -- type q is record
1046 -- m : string (2 .. 5);
1047 -- end record;
1049 -- type r is array (1 .. 10, 1 .. 20) of q;
1051 -- g : r;
1053 -- z : string renames g (1,5).m(2 ..3)
1054 -- end p;
1056 -- The generated type definition would appear as
1058 -- type p__z___XR is
1059 -- (p__g___XEXS1XS5XRmXL2XS3);
1060 -- p__q___XE--------------------outer entity is g
1061 -- XS1-----------------first subscript for g
1062 -- XS5--------------second subscript for g
1063 -- XRm-----------select field m
1064 -- XL2--------lower bound of slice
1065 -- XS3-----upper bound of slice
1067 function Debug_Renaming_Declaration (N : Node_Id) return Node_Id;
1068 -- The argument N is a renaming declaration. The result is a type
1069 -- declaration as described in the above paragraphs. If not special
1070 -- debug declaration, than Empty is returned.
1072 ---------------------------
1073 -- Packed Array Encoding --
1074 ---------------------------
1076 -- For every packed array, two types are created, and both appear in
1077 -- the debugging output.
1079 -- The original declared array type is a perfectly normal array type,
1080 -- and its index bounds indicate the original bounds of the array.
1082 -- The corresponding packed array type, which may be a modular type, or
1083 -- may be an array of bytes type (see Exp_Pakd for full details). This
1084 -- is the type that is actually used in the generated code and for
1085 -- debugging information for all objects of the packed type.
1087 -- The name of the corresponding packed array type is:
1089 -- ttt___XPnnn
1091 -- where
1092 -- ttt is the name of the original declared array
1093 -- nnn is the component size in bits (1-31)
1095 -- When the debugger sees that an object is of a type that is encoded
1096 -- in this manner, it can use the original type to determine the bounds,
1097 -- and the component size to determine the packing details.
1099 -- Packed arrays are represented in tightly packed form, with no extra
1100 -- bits between components. This is true even when the component size
1101 -- is not a factor of the storage unit size, so that as a result it is
1102 -- possible for components to cross storage unit boundaries.
1104 -- The layout in storage is identical, regardless of whether the
1105 -- implementation type is a modular type or an array-of-bytes type.
1106 -- See Exp_Pakd for details of how these implementation types are used,
1107 -- but for the purpose of the debugger, only the starting address of
1108 -- the object in memory is significant.
1110 -- The following example should show clearly how the packing works in
1111 -- the little-endian and big-endian cases:
1113 -- type B is range 0 .. 7;
1114 -- for B'Size use 3;
1116 -- type BA is array (0 .. 5) of B;
1117 -- pragma Pack (BA);
1119 -- BV : constant BA := (1,2,3,4,5,6);
1121 -- Little endian case
1123 -- BV'Address + 2 BV'Address + 1 BV'Address + 0
1124 -- +-----------------+-----------------+-----------------+
1125 -- | 0 0 0 0 0 0 1 1 | 0 1 0 1 1 0 0 0 | 1 1 0 1 0 0 0 1 |
1126 -- +-----------------+-----------------+-----------------+
1127 -- <---------> <-----> <---> <---> <-----> <---> <--->
1128 -- unused bits BV(5) BV(4) BV(3) BV(2) BV(1) BV(0)
1130 -- Big endian case
1132 -- BV'Address + 0 BV'Address + 1 BV'Address + 2
1133 -- +-----------------+-----------------+-----------------+
1134 -- | 0 0 1 0 1 0 0 1 | 1 1 0 0 1 0 1 1 | 1 0 0 0 0 0 0 0 |
1135 -- +-----------------+-----------------+-----------------+
1136 -- <---> <---> <-----> <---> <---> <-----> <--------->
1137 -- BV(0) BV(1) BV(2) BV(3) BV(4) BV(5) unused bits
1139 ------------------------------------------------------
1140 -- Subprograms for Handling Packed Array Type Names --
1141 ------------------------------------------------------
1143 function Make_Packed_Array_Type_Name
1144 (Typ : Entity_Id;
1145 Csize : Uint)
1146 return Name_Id;
1147 -- This function is used in Exp_Pakd to create the name that is encoded
1148 -- as described above. The entity Typ provides the name ttt, and the
1149 -- value Csize is the component size that provides the nnn value.
1151 --------------------------------------
1152 -- Pointers to Unconstrained Arrays --
1153 --------------------------------------
1155 -- There are two kinds of pointers to arrays. The debugger can tell
1156 -- which format is in use by the form of the type of the pointer.
1158 -- Fat Pointers
1160 -- Fat pointers are represented as a struct with two fields. This
1161 -- struct has two distinguished field names:
1163 -- P_ARRAY is a pointer to the array type. The name of this
1164 -- type is the unconstrained type followed by "___XUA". This
1165 -- array will have bounds which are the discriminants, and
1166 -- hence are unparsable, but will give the number of
1167 -- subscripts and the component type.
1169 -- P_BOUNDS is a pointer to a struct, the name of whose type is the
1170 -- unconstrained array name followed by "___XUB" and which has
1171 -- fields of the form
1173 -- LBn (n a decimal integer) lower bound of n'th dimension
1174 -- UBn (n a decimal integer) upper bound of n'th dimension
1176 -- The bounds may be any integral type. In the case of an
1177 -- enumeration type, Enum_Rep values are used.
1179 -- The debugging information will sometimes reference an anonymous
1180 -- fat pointer type. Such types are given the name xxx___XUP, where
1181 -- xxx is the name of the designated type. If the debugger is asked
1182 -- to output such a type name, the appropriate form is "access xxx".
1184 -- Thin Pointers
1186 -- Thin pointers are represented as a pointer to the ARRAY field of
1187 -- a structure with two fields. The name of the structure type is
1188 -- that of the unconstrained array followed by "___XUT".
1190 -- The field ARRAY contains the array value. This array field is
1191 -- typically a variable-length array, and consequently the entire
1192 -- record structure will be encoded as previously described,
1193 -- resulting in a type with suffix "___XUT___XVE".
1195 -- The field BOUNDS is a struct containing the bounds as above.
1197 --------------------------------------
1198 -- Tagged Types and Type Extensions --
1199 --------------------------------------
1201 -- A type C derived from a tagged type P has a field named "_parent"
1202 -- of type P that contains its inherited fields. The type of this
1203 -- field is usually P (encoded as usual if it has a dynamic size),
1204 -- but may be a more distant ancestor, if P is a null extension of
1205 -- that type.
1207 -- The type tag of a tagged type is a field named _tag, of type void*.
1208 -- If the type is derived from another tagged type, its _tag field is
1209 -- found in its _parent field.
1211 -----------------------------
1212 -- Variant Record Encoding --
1213 -----------------------------
1215 -- The variant part of a variant record is encoded as a single field
1216 -- in the enclosing record, whose name is:
1218 -- discrim___XVN
1220 -- where discrim is the unqualified name of the variant. This field name
1221 -- is built by gigi (not by code in this unit). In the case of an
1222 -- Unchecked_Union record, this discriminant will not appear in the
1223 -- record, and the debugger must proceed accordingly (basically it
1224 -- can treat this case as it would a C union).
1226 -- The type corresponding to this field has a name that is obtained
1227 -- by concatenating the type name with the above string and is similar
1228 -- to a C union, in which each member of the union corresponds to one
1229 -- variant. However, unlike a C union, the size of the type may be
1230 -- variable even if each of the components are fixed size, since it
1231 -- includes a computation of which variant is present. In that case,
1232 -- it will be encoded as above and a type with the suffix "___XVN___XVU"
1233 -- will be present.
1235 -- The name of the union member is encoded to indicate the choices, and
1236 -- is a string given by the following grammar:
1238 -- union_name ::= {choice} | others_choice
1239 -- choice ::= simple_choice | range_choice
1240 -- simple_choice ::= S number
1241 -- range_choice ::= R number T number
1242 -- number ::= {decimal_digit} [m]
1243 -- others_choice ::= O (upper case letter O)
1245 -- The m in a number indicates a negative value. As an example of this
1246 -- encoding scheme, the choice 1 .. 4 | 7 | -10 would be represented by
1248 -- R1T4S7S10m
1250 -- In the case of enumeration values, the values used are the
1251 -- actual representation values in the case where an enumeration type
1252 -- has an enumeration representation spec (i.e. they are values that
1253 -- correspond to the use of the Enum_Rep attribute).
1255 -- The type of the inner record is given by the name of the union
1256 -- type (as above) concatenated with the above string. Since that
1257 -- type may itself be variable-sized, it may also be encoded as above
1258 -- with a new type with a further suffix of "___XVU".
1260 -- As an example, consider:
1262 -- type Var (Disc : Boolean := True) is record
1263 -- M : Integer;
1265 -- case Disc is
1266 -- when True =>
1267 -- R : Integer;
1268 -- S : Integer;
1270 -- when False =>
1271 -- T : Integer;
1272 -- end case;
1273 -- end record;
1275 -- V1 : Var;
1277 -- In this case, the type var is represented as a struct with three
1278 -- fields, the first two are "disc" and "m", representing the values
1279 -- of these record components.
1281 -- The third field is a union of two types, with field names S1 and O.
1282 -- S1 is a struct with fields "r" and "s", and O is a struct with
1283 -- fields "t".
1285 ------------------------------------------------
1286 -- Subprograms for Handling Variant Encodings --
1287 ------------------------------------------------
1289 procedure Get_Variant_Encoding (V : Node_Id);
1290 -- This procedure is called by Gigi with V being the variant node.
1291 -- The corresponding encoding string is returned in Name_Buffer with
1292 -- the length of the string in Name_Len, and an ASCII.NUL character
1293 -- stored following the name.
1295 ---------------------------------
1296 -- Subtypes of Variant Records --
1297 ---------------------------------
1299 -- A subtype of a variant record is represented by a type in which the
1300 -- union field from the base type is replaced by one of the possible
1301 -- values. For example, if we have:
1303 -- type Var (Disc : Boolean := True) is record
1304 -- M : Integer;
1306 -- case Disc is
1307 -- when True =>
1308 -- R : Integer;
1309 -- S : Integer;
1311 -- when False =>
1312 -- T : Integer;
1313 -- end case;
1315 -- end record;
1316 -- V1 : Var;
1317 -- V2 : Var (True);
1318 -- V3 : Var (False);
1320 -- Here V2 for example is represented with a subtype whose name is
1321 -- something like TvarS3b, which is a struct with three fields. The
1322 -- first two fields are "disc" and "m" as for the base type, and
1323 -- the third field is S1, which contains the fields "r" and "s".
1325 -- The debugger should simply ignore structs with names of the form
1326 -- corresponding to variants, and consider the fields inside as
1327 -- belonging to the containing record.
1329 -------------------------------------------
1330 -- Character literals in Character Types --
1331 -------------------------------------------
1333 -- Character types are enumeration types at least one of whose
1334 -- enumeration literals is a character literal. Enumeration literals
1335 -- are usually simply represented using their identifier names. In
1336 -- the case where an enumeration literal is a character literal, the
1337 -- name aencoded as described in the following paragraph.
1339 -- A name QUhh, where each 'h' is a lower-case hexadecimal digit,
1340 -- stands for a character whose Unicode encoding is hh, and
1341 -- QWhhhh likewise stands for a wide character whose encoding
1342 -- is hhhh. The representation values are encoded as for ordinary
1343 -- enumeration literals (and have no necessary relationship to the
1344 -- values encoded in the names).
1346 -- For example, given the type declaration
1348 -- type x is (A, 'C', B);
1350 -- the second enumeration literal would be named QU43 and the
1351 -- value assigned to it would be 1.
1353 -------------------
1354 -- Modular Types --
1355 -------------------
1357 -- A type declared
1359 -- type x is mod N;
1361 -- Is encoded as a subrange of an unsigned base type with lower bound
1362 -- 0 and upper bound N. That is, there is no name encoding; we only use
1363 -- the standard encodings provided by the debugging format. Thus,
1364 -- we give these types a non-standard interpretation: the standard
1365 -- interpretation of our encoding would not, in general, imply that
1366 -- arithmetic on type x was to be performed modulo N (especially not
1367 -- when N is not a power of 2).
1369 ---------------------
1370 -- Context Clauses --
1371 ---------------------
1373 -- The SGI Workshop debugger requires a very peculiar and nonstandard
1374 -- symbol name containing $ signs to be generated that records the
1375 -- use clauses that are used in a unit. GDB does not use this name,
1376 -- since it takes a different philsophy of universal use visibility,
1377 -- with manual resolution of any ambiguities.
1379 -- The routines and data in this section are used to prepare this
1380 -- specialized name, whose exact contents are described below. Gigi
1381 -- will output this encoded name only in the SGI case (indeed, not
1382 -- only is it useless on other targets, but hazardous, given the use
1383 -- of the non-standard character $ rejected by many assemblers.)
1385 -- "Use" clauses are encoded as follows:
1387 -- _LSS__ prefix for clauses in a subprogram spec
1388 -- _LSB__ prefix for clauses in a subprogram body
1389 -- _LPS__ prefix for clauses in a package spec
1390 -- _LPB__ prefix for clauses in a package body
1392 -- Following the prefix is the fully qualified filename, followed by
1393 -- '$' separated names of fully qualified units in the "use" clause.
1394 -- If a unit appears in both the spec and the body "use" clause, it
1395 -- will appear once in the _L[SP]S__ encoding and twice in the _L[SP]B__
1396 -- encoding. The encoding appears as a global symbol in the object file.
1398 ------------------------------------------------------------------------
1399 -- Subprograms and Declarations for Handling Context Clause Encodings --
1400 ------------------------------------------------------------------------
1402 procedure Save_Unitname_And_Use_List
1403 (Main_Unit_Node : Node_Id;
1404 Main_Kind : Node_Kind);
1405 -- Creates a string containing the current compilation unit name
1406 -- and a dollar sign delimited list of packages named in a Use_Package
1407 -- clause for the compilation unit. Needed for the SGI debugger. The
1408 -- procedure is called unconditionally to set the variables declared
1409 -- below, then gigi decides whether or not to use the values.
1411 -- The following variables are used for communication between the front
1412 -- end and the debugging output routines in Gigi.
1414 type Char_Ptr is access all Character;
1415 pragma Convention (C, Char_Ptr);
1416 -- Character pointers accessed from C
1418 Spec_Context_List, Body_Context_List : Char_Ptr;
1419 -- List of use package clauses for spec and body, respectively, as
1420 -- built by the call to Save_Unitname_And_Use_List. Used by gigi if
1421 -- these strings are to be output.
1423 Spec_Filename, Body_Filename : Char_Ptr;
1424 -- Filenames for the spec and body, respectively, as built by the
1425 -- call to Save_Unitname_And_Use_List. Used by gigi if these strings
1426 -- are to be output.
1428 end Exp_Dbug;