|
|
1.1 root 1: .ds + \v'-0.06i'+\v'0.06i'
2: .de PR
3: .sp 1
4: .in +1.5i
5: .ti -0.8i
6: .nh
7: \s-2\fL\\$1 \s+2\(->\s-2 \\$2\fR\s+2
8: .hy
9: .in -1.5i
10: ..
11: .de PC
12: .in +1.5i
13: .ti -0.8i
14: .nh
15: .sp 0.05i
16: \s-2\fL\\$1 \s+2\(->\s-2 \\$2\fR\s+2
17: .hy
18: .in -1.5i
19: ..
20: .OF 'Sun Microsystems'8 Apr 86'Programming Languages Group'
21: .EF 'Sun Microsystems'8 Apr 86'Programming Languages Group'
22: .ps 12
23: .nr PS 12
24: .vs 14p
25: .nr VS 14p
26: .ce
27: \fB\s20Dbx and Dbxtool Interfaces\s0\fR
28: .sp 1
29: .ce
30: Steven S. Muchnick
31: .sp 1
32: .ce
33: \fI8 April 1986\fR
34: .sp 2
35: .NH 1
36: Introduction and Assumptions
37: .PP
38: This document specifies two interfaces, one between Sun's compilers and
39: the \fIdbx\fR and \fIdbxtool\fR debuggers and the other between the two
40: processes which make up \fIdbxtool\fR.
41: The information is current as of the 3.0 Sun Software Release and the
42: 1.0 release of Sun Modula-2 and is intended for compiler implementors.
43: .PP
44: The interface languages are expected to grow and evolve over time.
45: While they may be extended at arbitrary times and bugs fixed in them as needed,
46: major changes which introduce incompatibilities with previous versions
47: will generally be synchronized with major system releases.
48: .PP
49: This document assumes the reader is familiar with the Sun assembler and linker,
50: and with \fIdbx\fR and \fIdbxtool\fR.
51: .PP
52: .sp 1
53: .NH 1
54: \fIDbx\fB and \fIDbxtool\fR
55: .PP
56: \fIDbxtool\fR consists of two processes, the debugger process (DP), which is
57: identical to \fIdbx\fR, and the user interface process (UIP).
58: When the UIP starts the DP it passes a flag to it telling it that it was
59: started by the UIP, rather than directly by the user.
60: Commands are communicated from the UIP to the DP in the same form that they
61: are typed by the user to \fIdbx\fR, as character strings consisting of the
62: command name followed by the arguments, and are presented to it via its
63: standard input.
64: Commands entered via the mouse are translated by the UIP into the standard
65: form: the command button provides the command name to be placed at the
66: beginning of the string and the selected argument is translated according
67: to the selection interpretation associated with the command button.
68: The DP communicates to the UIP in the DP-UIP interface language,
69: instead of the usual tty-oriented responses used by the DP when it is
70: invoked directly as \fIdbx\fR.
71: .PP
72: The next section presents the syntax and semantics of the language which
73: compilers use to convey information about data types, variables and the
74: relationship between source statements and machine instructions to the DP
75: (or, equivalently, to \fIdbx\fR).
76: The following section presents the syntax and semantics of the interface
77: between the DP and the UIP.
78: Appendix A lists the standard types defined for Sun's supported languages.
79: Appendix B gives an example of the compiler-debugger interface.
80: .PP
81: .sp 1
82: .NH 1
83: Overview of the Compiler-Debugger Interface Language
84: .PP
85: All information about a compiled module needed by \fIdbx\fR and \fIdbxtool\fR
86: is contained in the symbol table part of the \fIa.out\fR file.
87: Some of this information is derived from ordinary linker and assembler
88: symbols; the rest is passed by the compilers to the assembler via \fL.stab\fR
89: ("symbol table") directives.
90: The debuggers distinguish the two types of symbols by whether or not any of
91: the \fLN_STAB\fR* bits are set in the type field of the symbol entry, as
92: described below in Section 3.31.
93: .FS
94: *Symbols beginning with \fLN_\fR are defined in the files
95: \fL/usr/include/a.out.h\fR and \fL/usr/include/stab.h\fR.
96: .FE
97: .PP
98: The \fL.stab\fR directives have the following forms:
99: .sp 1
100: .in +1.0i
101: \fL .stabs "\fIname\fR",\fItype\fR,0,\fIdesc\fR,\fIvalue\fR
102: .sp 1
103: \fL .stabn \fItype\fR,0,\fIdesc\fR,\fIvalue\fR
104: .in -1.0i
105: .sp 0.6
106: or
107: .sp 0.6
108: .in +1.0i
109: \fL .stabd \fItype\fR,0,\fIdesc\fR
110: .in -1.0i
111: .sp 1
112: .LP
113: The \fL.stabs\fR directives are used to describe types, variables,
114: procedures, and so on, while the \fL.stabn\fR directives convey
115: information about scopes and the mapping from source statements to
116: object code.
117: A \fL.stabd\fR directive is identical in meaning to a
118: corresponding \fL.stabn\fR directive with the value field set to "." (dot),
119: which the assembler uses to mean the current location.
120: Most of the needed information, for example symbol name and type structure,
121: is contained in the \fIname\fR field.
122: The \fItype\fR field identifies the type of symbolic information, for
123: example source file, global symbol, or source line.
124: The \fIdesc\fR field specifies the number of bytes occupied by a variable or
125: type or the nesting level for a scope symbol.
126: The \fIvalue\fR field specifies an address or an offset.
127: .PP
128: The following classes of \fL.stab\fR information are needed to describe
129: a compiled module or file, with of course considerable variations
130: depending on the source language:
131: .IP -
132: file and module identification and (for Modula-2) the list of imported
133: separate units
134: .IP -
135: program structure information and descriptions of types, variables and scopes
136: .IP -
137: code address information for statements
138: .PP
139: The \fL.stab\fR directives may be interspersed in the generated assembly
140: language with relatively few constraints on their ordering.
141: In particular, the \fLN_SLINE .stabd\fR or \fL.stabn\fR directives which
142: describe the relationship between the source and object code need to
143: appear in the same order as the corresponding source lines and
144: the \fL.stabs\fR directives which describe variables need to be ordered
145: to correspond to the scope structure of the program.
146: .PP
147: The name field in a \fL.stabs\fR entry for a symbol contains the
148: symbol's name, followed by a colon, a one-character symbol
149: descriptor, and descriptor-specific information, i.e.
150: .sp 1
151: .in +1.0i
152: \fLsymbol : descriptor debuginfo\fR
153: .in -1.0i
154: .sp 0.5
155: .PP
156: The linker and assembler symbols and \fL.stab\fR directives expected by
157: the debuggers and their meanings are described below.
158: .PP
159: .sp 1
160: .NH 2
161: Syntax Notation
162: .PP
163: In the syntax notation used below nonterminal symbols are those in
164: \fLtypewriter font\fR which are more than one character long and begin with
165: a capital letter.
166: The left and right sides of a production are separated by an arrow
167: "\fL\(->\fR".
168: Braces "\fL{\fR" and "\fL}\fR" are used to indicate grouping, brackets
169: "\fL[\fR" and "\fL]\fR" to indicate optionality, vertical bar "\fL|\fR" for
170: alternation, asterisk "\fL*\fR" for zero or more repetitions, and plus
171: "\fL\*+\fR" for one or more repetitions.
172: All other symbols in \fLtypewriter font\fR which are not part of the notation
173: denote terminals.
174: .PP
175: .sp 1
176: .NH 2
177: Lexical Rules
178: .PP
179: Lexically \fL.stab\fR directives follow the conventions of ordinary
180: assembly language lines.
181: The string in a \fL.stabs\fR directive may be continued from one line to the
182: next by terminating it with a backslash '\\', completing the other fields
183: of the directive, and continuing the string in another \fL.stabs\fR
184: directive on the next line with the same non-string fileds.
185: Thus, for example,
186: .in +1.0i
187: .nf
188: \fL\s-2.stabs "int:t(0,1)=r(0,1);-2147483648;\\",0x80,0,0,0
189: .stabs "2147483647;",0x80,0,0,0\s+2\fR
190: .fi
191: .in -1.0i
192: .LP
193: and
194: .in +1.0i
195: .nf
196: \fL\s-2.stabs "int:t(0,1)=r(0,1);-2147483648;2147483647;",0x80,0,0,0\s+2\fR
197: .fi
198: .in -1.0i
199: .LP
200: are equivalent.
201: There may be any number of such continuation lines.
202: .PP
203: .sp 1
204: .NH 2
205: Linker and Assembler Symbols
206: .PP
207: The linker and assembler symbols used by the debuggers are those which
208: identify object files, procedures, and variables.
209: These symbols are generated either by the linker (object filenames) or by
210: the assembler (procedure names and variables) without the compiler having
211: to supply \fL.stab\fR directives for them.
212: .PP
213: Symbols in text space whose names end in "\fL.o\fR" are taken as object
214: filenames.
215: The debugger strips off the "\fL.o\fR" and any leading directory names.
216: The resulting filename becomes associated with following symbols as the
217: file which contains them, until another object filename or the end of file
218: is seen.
219: Text-space symbols other than object filenames are taken by the debugger
220: as names of procedures.
221: If the symbol has a leading underscore, it is removed.
222: If a debugger symbol entry is later encountered for the same symbol, the
223: assembler symbol is discarded in its favor.
224: .PP
225: Data- and bss-space symbols are taken by the debugger as representing
226: global variables in the corresponding spaces.
227: Leading underscores are stripped off and the scope information is preserved.
228: A debugger symbol is also required for such symbols to provide full information
229: for them (see Section 3.13).
230: .PP
231: .sp 1
232: .NH 2
233: Top-Level Structure of Debugger Symbols
234: .PP
235: .PR DebuggerStabs "{CodeStabs | SourceFileStabs | UnitStab | ProcStab | ScopeBgnStab StructureStabs* ScopeEndStab | TypeStab | GlblVarStab | StaticVarStab | LclVarStab | ParamStab | CommonStabs | ImpExpStab}*"
236: .PP
237: .NH 2
238: Source-to-Object Code Mapping
239: .PP
240: .PR CodeStabs "{BlockBgnStab LineStab* BlockEndStab}*"
241: .PC BlockBgnStab ".stabn N_LBRAC , 0 , Level , CodeAddr"
242: .PC N_LBRAC 0xc0
243: .PC LineStab ".stabn N_SLINE , 0 , Line , CodeAddr"
244: .PC N_SLINE 0x44
245: .PC BlockEndStab ".stabn N_RBRAC , 0 , Level , CodeAddr"
246: .PC N_RBRAC 0xe0
247: .PP
248: \fLCodeStabs\fR define the relationship between the source code and the
249: object code.
250: The object code generated for each block (e.g. a group of statements
251: delimited by curly braces in C or by \fLbegin\fR and \fLend\fR in Pascal)
252: is enclosed in \fLBlockBgnStab\fR and \fLBlockEndStab\fR directives.
253: A \fLLineStab\fR is given for the first instruction generated for
254: each statement.
255: \fLLevel\fR identifies the static nesting level of a block, \fLLine\fR
256: gives the source line number for a statement and \fLCodeAddr\fR
257: gives the relocatable address of the corresponding object code.
258: .PP
259: .NH 2
260: Source File Identification
261: .PP
262: .PR SourceFileStab ".stabs "" SourceFileString "" , N_SO , 0 , 0 , CodeAddr"
263: .PC SourceFileString String
264: .PC N_SO 0x64
265: .PP
266: A \fLSourceFileStab\fR identifies the source file which was compiled to
267: produce this object code.
268: The \fLSourceFileString\fR is the name of the source file in the form it was
269: given to the compiler.
270: The \fLCodeAddr\fR gives the relocatable address of the beginning of the
271: generated object code.
272: .PP
273: .NH 2
274: Unit Identification (Modula-2 only)
275: .PP
276: .PR UnitStab ".stabs "" UnitString "" , N_M2C , 0 , UnitNumber , UnitFlag"
277: .PC UnitString "Name , UnitTimeStamp [, CodeTimeStamp]"
278: .PC N_M2C 0x42
279: .PC UnitNumber Number
280: .PC UnitTimeStamp String
281: .PC CodeTimeStamp String
282: .PC UnitFlag "0 | 1"
283: .PP
284: A \fLUnitStab\fR provides some debugging information, in addition to
285: identifying a Modula-2 separate compilation unit for version consistency
286: checking in the Modula-2 linker \fIm2l\fR .
287: The \fLName\fR field defines the the name of the module to the
288: debugger.
289: The \fLUnitNumber\fR field is used to identify the modules of imported
290: and exported identifiers (see Section 3.12).
291: The \fLUnitTimeStamp\fR is used internally in the debugger to provide
292: unique entries in its module table.
293: The \fLUnitFlag\fR field is used only to identify the main module
294: (its \fLUnitFlag\fR is \fL0\fR).
295: The \fLCodeTimeStamp\fR field is used only for consistency checking.
296: .PP
297: .NH 2
298: Functions and Procedures (C, FORTRAN and Pascal)
299: .PP
300: .PR ProcStab ".stabs "" ProcName : ProcClass ProcRtnType "" , N_FUN , 0 , RtnSize , CodeAddr"
301: .PC ProcClass "F | f"
302: .PC ProcRtnType TypeRef
303: .PC N_FUN 0x24
304: .PP
305: A \fLProcStab\fR defines the beginning of a C, FORTRAN or Pascal function or
306: procedure.
307: It gives the routine's name and storage class, the type and size of the value
308: it returns, and the address of the beginning of its code.
309: The class is \fLF\fR for globally defined routines and \fLf\fR for local ones.
310: For procedures, the return type is \fLvoid\fR.
311: .PP
312: .NH 2
313: Module, Function and Procedure Scopes (Modula-2 only)
314: .PP
315: .PR ScopeBgnStab ".stabs "" ScopeBgnString "" , N_SCOPE , 0 , Level , CodeAddr"
316: .PC ScopeEndStab ".stabs "" ScopeEndString "" , N_SCOPE , 0 , Level , 0"
317: .PC ScopeBgnString "Name : ScopeId"
318: .PC ScopeId "M ScopeNumber | Q ScopeNumber ResultType"
319: .PC ResultType TypeRef
320: .PC ScopeEndString "Name : E ScopeNumber"
321: .PC N_SCOPE 0xc4
322: .PC ScopeNumber Number
323: .PP
324: A \fLScopeBgnStab\fR - \fLScopeEndStab\fR pair delimits a module, procedure or
325: function scope in Modula-2.
326: The \fLScopeBgnString\fR gives the name of the scope and a \fLScopeId\fR
327: which identifies it as a module (\fLM\fR) or a function or procedure
328: (\fLQ\fR) and gives the sequence number (\fLScopeNumber\fR) assigned to it
329: and, for functions and procedures, the type of its return value; for
330: procedures the return type is \fLvoid\fR.
331: The \fLLevel\fR field gives the static nesting level of the scope.
332: The \fLScopeEndString\fR gives the name of the scope and the assigned sequence
333: number.
334: .PP
335: .NH 2
336: Type Identifiers
337: .PP
338: .PR TypeStab ".stabs "" TypeString "" , TypeScope , 0 , Size , 0"
339: .PC TypeScope "N_LSYM | N_GSYM"
340: .PC N_GSYM 0x20
341: .PC N_LSYM 0x80
342: .PC TypeString "[Name] : t Type"
343: .PP
344: A \fLTypeStab\fR describes a data type, giving its name,
345: a description of the range of values it comprises and (for Modula-2) the size
346: in bytes of the storage it occupies.
347: The \fLSize\fR field is ignored by \fIdbx\fR for languages other than
348: Modula-2 and the size of a type is determined by its range of values.
349: The \fLTypeScope\fR indicates whether the type is locally or globally
350: defined.
351: See Section 3.20 below for a description of \fLType\fR.
352: .PP
353: .NH 2
354: Local Variables
355: .PP
356: .PR LclVarStab ".stabs "" Name : Type "" , N_LSYM , 0 , 0 , DataOffset"
357: .PP
358: A \fLLclVarStab\fR describes a local variable, giving its name, kind and type
359: and the offset from the stack pointer to the local.
360: .PP
361: .NH 2
362: Modula-2 Imports and Exports
363: .PP
364: .PR ImpExpStab ".stabs "" ImpExpString "" , N_LSYM , 0 , 0 , 0"
365: .PC ImpExpString "Name : ImpExpId"
366: .PC ImpExpId "U UnitNumber | u UnitNumber | d ScopeNumber"
367: .PP
368: An \fLImpExpStab\fR is used by Modula-2 to describe a separately compiled
369: module and the symbols it defines.
370: See Table 2 (Section 3.30) below for a description of the letters occurring in
371: the \fLImpExpId\fR field.
372: .PP
373: .NH 2
374: Global Variables
375: .PP
376: .PR GlblVarStab ".stabs "" Name : G Type "" , N_GSYM , 0 , 0 , 0"
377: .PC N_GSYM 0x20
378: .PP
379: A \fLGlblVarStab\fR identifies a global variable.
380: The address of the variable is gotten from the corresponding assembler symbol.
381: .PP
382: .NH 2
383: Static Variables
384: .PP
385: .PR StaticVarStab ".stabs "" Name : StaticKind Type "" , StaticSym , 0 , 0 , DataAddr"
386: .PC StaticKind "S | V"
387: .PC StaticSym "N_STSYM | N_LCSYM"
388: .PC N_STSYM 0x26
389: .PC N_LCSYM 0x28
390: .PP
391: A \fLStaticVarStab\fR identifies a static variable, which may be either
392: uninitialized or initialized and either global or local.
393: Global statics are identified by \fLStaticKind\fR \fLS\fR and local ones
394: by \fLV\fR.
395: Uninitialized statics are identified by \fLStaticSym\fR \fLN_LCSYM\fR and
396: initialized ones by \fLN_STSYM\fR.
397: The \fLDataAddr\fR is the relocatable address assigned to the static
398: variable.
399: .PP
400: .NH 2
401: Parameters
402: .PP
403: .PR ParamStab ".stabs "" Name : ParamKind Type "" , N_PSYM , 0 , 0 , DataOffset"
404: .PC ParamKind "p | i | v | C | x | pP | pF | X"
405: .PC N_PSYM 0xa0
406: .PP
407: A \fLParamStab\fR describes a procedure or function parameter, giving its
408: name, kind, type and stack offset.
409: The kind is as described in Table 2 (Section 3.30) below, except that \fLpP\fR
410: and \fLpF\fR are used for Pascal procedure and function parameters,
411: respectively.
412: For register parameters a \fLRegStab\fR is also generated.
413: .PP
414: .NH 2
415: Register Variables
416: .PP
417: .PR RegStab ".stabs "" Name : Type "" , N_RSYM , 0 , RegSize , RegNumber"
418: .PC RegSize Number
419: .PC RegNumber Number
420: .PC N_RSYM 0x40
421: .PP
422: A \fLRegStab\fR describes a register variable or parameter, giving its
423: name, size in bytes, type and register number.
424: The register numbers are assigned as shown in Table 1.
425: .KF
426: .TS
427: box center;
428: l | l
429: l | l.
430: Register class Numbers
431: _ _
432: Data registers d0 - d7 0 - 7
433: Address registers a0 - a7 8 - 15
434: MC68881 registers fp0 - fp7 18 - 25
435: FPA registers fpa0 - fpa31 31 - 62
436: .TE
437: .ce
438: Table 1. Register Numbers
439: .sp 1
440: .KE
441: .LP
442: For register parameters a \fLParamStab\fR is also generated.
443: .PP
444: .NH 2
445: Common Blocks
446: .PP
447: .PR CommonStabs "BgnCommonStab GlblVarStab* EndCommonStab"
448: .PC BgnCommonStab ".stabs ""BlockName"" , N_BCOMM , 0 , 0 , 0"
449: .PC EndCommonStab ".stabs ""BlockName"" , N_ECOMM , 0 , 0 , 0"
450: .PC BlockName Name
451: .PC N_BCOMM 0xe2
452: .PC N_ECOMM 0xe4
453: .PP
454: A \fLBgnCommonStab\fR introduces the symbol list for a common block and the
455: corresponding \fLEndCommonStab\fR ends it.
456: .PP
457: .NH 2
458: Other Terms
459: .PP
460: .PR Level Number
461: .PC Size Number
462: .PC Line Number
463: .PC CodeAddr AddrExpr
464: .PC DataAddr AddrExpr
465: .PC DataOffset Number
466: .PR Number "[-] {DIGIT}\*+ | 0x {HEXDIGIT}\*+"
467: .PC Name " LETTER {LETTER | DIGIT}*"
468: .PC String "{CHARACTER}*"
469: .PP
470: An \fLAddrExpr\fR is an assembler address expression (see the assembly language
471: manual).
472: A \fLDIGIT\fR may be any decimal digit.
473: A \fLHEXDIGIT\fR may be a decimal digit or an upper or lower case letter in
474: the range \fLA\fR through \fLF\fR.
475: A \fLCHARACTER\fR may be any character accepted by the assembler in a string
476: (see the assembly language manual).
477: .PP
478: .sp 1
479: .NH 2
480: Specification of Types
481: .PP
482: Type information starts with a type descriptor, followed by type-specific
483: information, which is a sequence of information blocks separated by semicolons.
484: .sp 1
485: .in +1.0i
486: \fLtypedescriptor typeinfoblock ; ... ; typeinfoblock\fR
487: .in -1.0i
488: .sp 0.5
489: .LP
490: Upon definition of a type, a type number or type number pair is assigned
491: to it which can be used in later type specifications to refer to the
492: type definition.
493: .NH 2
494: Types, Type Definitions, Type References and Standard Types
495: .PP
496: .PR Type "TypeRef | TypeDef | Enumeration | RangeOrFloat | Array | DynArray | ConfArray | Record | Set | Pointer | ProcType | FuncType | FileType | SeparateType"
497: .PC TypeRef "Number | ( Number , Number )"
498: .PC TypeDef "TypeRef = Type"
499: .PP
500: A type may be any of those allowed by the C, FORTRAN 77, Modula-2 and
501: Pascal languages.
502: A \fLTypeRef\fR is the number or pair of numbers assigned to a type.
503: Whether numbers or pairs are used depends on the compiler.
504: Currently, C uses pairs and FORTRAN 77, Pascal and Modula-2 use
505: single numbers.
506: .PP
507: In the single number form, the numbers are assigned sequentially by the
508: compiler as it encounters type definitions during processing a source file and
509: the files included into it.
510: In the pair form, the first element identifies the file (the source file is
511: number 0 and successive include files are given successive numbers) and the
512: second element identifies successive types defined within each file.
513: .PP
514: A \fLTypeDef\fR associates a type number with a type definition.
515: .PP
516: Each language defines some standard types by a series of \fL.stabs\fR
517: lines, as shown in Appendix A.
518: .PP
519: .NH 2
520: Enumeration Types
521: .PP
522: .PR Enumeration "e {EnumName : OrdinalValue ,}\*+"
523: .PC EnumName Name
524: .PC OrdinalValue Number
525: .PP
526: An \fLEnumeration\fR defines an enumeration type by giving the names and values
527: of its elements.
528: .PP
529: .NH 2
530: Range, Floating-Point and Complex Types
531: .PP
532: .PR RangeOrFloat "r Type ; MinValue ; MaxValue"
533: .PC MinValue RangeValue
534: .PC MaxValue RangeValue
535: .PC RangeValue "[ A | J] Number"
536: .PP
537: A \fLRangeOrFloat\fR defines a range, floating-point or complex type.
538: It describes a range type if the number in the \fLMaxValue\fR field is
539: nonzero and the \fLMinValue\fR number is less than or equal to the
540: \fLMaxValue\fR number.
541: In this case, it gives the minimal and maximal values of the range and the
542: type it is a subrange of.
543: The letters \fLA\fR or \fLJ\fR occur only for ranges.
544: An \fLA\fR indicates that the following number, instead of being the range
545: value is the run-time offset from the frame pointer of the range.
546: A \fLT\fR indicates that the bound is adjustable at runtime and not
547: determinable, as may be the case for FORTRAN array arguments.
548: .PP
549: It describes a floating-point or complex type if the \fLMaxValue\fR field is
550: zero and the \fLMinValue\fR is greater than the \fLMaxValue\fR.
551: In this case, the \fLMinValue\fR field gives the number of bytes occupied by
552: values of the floating-point or complex type.
553: The type is interpreted as complex if the name in the \fL.stabs\fR line is
554: \fLcomplex\fR or \fLdouble complex\fR.
555: .PP
556: .NH 2
557: Array Types
558: .PP
559: .PR Array "a IndexType ; ElementType"
560: .PC IndexType Type
561: .PC ElementType Type
562: .PC DynArray "a r IndexType ; 0 ; A HighBound ; ElementType"
563: .PC ConfArray "a C LowBound , HighBound , IndexType ; ElementType"
564: .PC LowBound Number
565: .PC HighBound Number
566: .PP
567: An \fLArray\fR defines an array type by giving the types of the indexes and
568: elements.
569: Multidimensional arrays are treated as if they were one-dimensional arrays
570: of arrays.**
571: .FS
572: **See Appendix B, line 36 for an example.
573: .FE
574: .PP
575: A \fLDynArray\fR defines a Modula-2 dynamic array type by giving the types
576: of the indexes and elements and the high bound.
577: Note that \fLDynArray\fR is identical to an ordinary array whose index is
578: a range type (see Section 3.22).
579: .PP
580: A \fLConfArray\fR defines a Pascal conformant array type by giving the types
581: of the indexes and elements and the low and high bounds.
582: .PP
583: .NH 2
584: Record Types
585: .PP
586: .PR Record "s ByteSize FieldList"
587: .PC FieldList "{FieldName : {Type | Variant} , BitOffset , BitSize ;}\*+"
588: .PC Variant "Selector ; { Case ; }\*+"
589: .PC Selector "v Flag : Type"
590: .PC Case "{CaseValue ,}\*+ : FieldList"
591: .PC FieldName Name
592: .PC ByteSize Number
593: .PC BitOffset Number
594: .PC BitSize Number
595: .PC CaseValue Number
596: .PC Flag "0 | 1"
597: .PP
598: A \fLRecord\fR defines a record type, giving the size in bytes of an instance
599: of the type and a description of each field.
600: A field description includes its name, either a type or a variant description,
601: bit offset within the record type and length in bits.
602: A variant consists of the selector name and a series of cases.
603: The flag in a selector indicates whether a variant record has a discriminant
604: (\fL1\fR) or not (\fL0\fR).
605: .PP
606: .NH 2
607: Set Types
608: .PP
609: .PR Set "S Type"
610: .PP
611: A \fLSet\fR defines a set type and specifies its base type.
612: .PP
613: .NH 2
614: Pointer Types
615: .PP
616: .PR Pointer "* Type"
617: .PP
618: A \fLPointer\fR defines a pointer type and specifies its base type.
619: .PP
620: .NH 2
621: Function and Procedure Types
622: .PP
623: .PR FuncType "Q ResultType , ParamNumber {; FormalType}*"
624: .PC ParamNumber Number
625: .PC FormalType "DataKind Type"
626: .PP
627: A \fLFuncType\fR defines a function or procedure type, giving its result type,
628: the number of parameters expected and descriptions of the parameters.
629: The \fLDataKind\fR field may be any of the type descriptors listed in
630: Table 2 (Section 3.31) below.
631: .PP
632: .NH 2
633: File Types (Pascal only)
634: .PP
635: .PR FileType "L Type"
636: .PP
637: A \fLFileType\fR describes a Pascal file type by giving its base type.
638: .PP
639: .NH 2
640: Types Defined in Separate Units (Modula-2)
641: .PP
642: .PR SeparateType "I UnitNumber , Name"
643: .PP
644: A \fLSeparateType\fR describes a type defined in a different compiled unit in
645: a Modula-2 program, giving its unit number and name.
646: .PP
647: .NH 2
648: Summary of Symbol Descriptors
649: .PP
650: Table 2 lists the symbol descriptors currently in use, along with their
651: meanings and the languages which generate them (C = C, F = FORTRAN 77,
652: M = Modula-2, P = Pascal).
653: .KF
654: .sp 1
655: .TS
656: center box;
657: c | c | c
658: cfL | l | c.
659: descriptor meaning languages
660: _
661: (empty) local variable C F M P
662: d symbol defined in other scope M
663: f local (function) procedure C P
664: i value parameter by reference (indirect access) M
665: p value parameter C F M P
666: r register variable C
667: t type name C F M P
668: u symbol defined in a separate unit (module) M
669: v variable parameter by reference F M P
670: x conformant array value parameter P
671: A bound value in parameter with specified offset F M
672: C read-only parameter (conformant array bound) P
673: E end of scope M
674: F global (function) procedure C F P
675: G global variable C F P
676: M module M
677: Q procedure or function M
678: S static global variable C M
679: T enumeration or structure type tag C
680: U separate unit (module) M
681: V common / static local variable F / C
682: X function result variable F P
683: .TE
684: .ce
685: Table 2. Symbol Descriptors
686: .sp 1
687: .KE
688: .NH 2
689: Summary of Type Descriptors
690: .PP
691: Table 3 lists the type descriptors which are currently in use,
692: along with their meanings and the languages which generate them (C = C,
693: F = FORTRAN 77, M = Modula-2, P = Pascal).
694: .KF
695: .sp 1
696: .TS
697: center box;
698: c | c | c
699: cfL | l | c.
700: descriptor meaning languages
701: _
702: (empty) type reference C F M P
703: a array type C F M P
704: c conformant array P
705: e enumeration type C M P
706: f function type C
707: r range type C F M P
708: s record / structure type C M P
709: u union specification C
710: v variant specification P
711: C lower and upper bound of a conformant array P
712: F function parameter type P
713: I separate type M
714: L file type P
715: P procedure parameter type P
716: Q function or procedure type M
717: S set type M P
718: * pointer type C F M P
719: .TE
720: .ce
721: Table 3. Type Descriptors
722: .sp 1
723: .KE
724: .PP
725: .NH 2
726: Generating Object Code Instead of Assembly Language
727: .PP
728: Some compilers prefer to generate object code directly, rather than Sun
729: assembly language.
730: This section explains how to generate the appropriate code for the assembler
731: symbols and \fL.stab\fR directives described above (linker symbols are
732: generated automatically by the system linker).
733: .PP
734: In the Sun-2 and Sun-3 assemblers, the three types of directives
735: .sp 1
736: .in +1.0i
737: \fL .stabs "\fIname\fL",\fItype\fL,0,\fIdesc\fL,\fIvalue\fR
738: .sp 1
739: \fL .stabn \fItype\fL,0,\fIdesc\fL,\fIvalue\fR
740: .in -1.0i
741: .sp 0.6
742: and
743: .sp 0.6
744: .in +1.0i
745: \fL .stabd \fItype\fL,0,\fIdesc\fR
746: .in -1.0i
747: .sp 1
748: .LP
749: generate records in the \fIa.out\fR symbol table which are described by
750: variations of the C structure
751: .ne 7
752: .TS
753: center;
754: l l lw(1.5i) lw(1.0i) l lw(2.7i) l.
755: \s-2\fLstruct nlist
756: { long n_strx; /* \fRstring table index\fL */
757: unsigned char n_type; /* \fRtype field\fL */
758: char n_other; /* \fRunused\fL */
759: short n_desc; /* \fRdesc field\fL */
760: unsigned long n_value; /* \fRsymbol value or offset\fL */
761: };\fR\s+2
762: .TE
763: with the variations as given by the field names, i.e. a \fL.stabs\fR directive
764: fills all five fields, a \fL.stabn\fR directive defaults the \fLn_strx\fR
765: field to zero, and a \fL.stabd\fR directive, in addition to defaulting
766: \fLn_strx\fR, sets the \fLn_value\fR field to the current value of the
767: assembler location counter.
768: .PP
769: Symbols generated by \fL.stab\fR directives are distinguished from assembler
770: symbols by whether any of the bits in the mask \fLN_STAB\fR (with value
771: \fL0xe0\fR) are set.
772: .PP
773: The \fLn_strx\fR field contains an index into the \fIa.out\fR string table for
774: the string occurring in a \fL.stabs\fR directive.
775: The string table consists of a 32-bit word containing the length of the table
776: in bytes (including the length word) followed by a series of
777: null-terminated strings.
778: The index is the offset of the first character of a string from the first
779: byte of the length word.
780: .PP
781: If the value field given in a \fL.stabd\fR directive is a symbol, the offset of
782: the symbol from the beginning of the appropriate control section (text, data
783: or bss) is placed in the \fLn_value\fR field.
784: The current location is handled similarly for the \fL.stabd\fR directive.
785: .PP
786: Assembler symbols can be described in terms of the \fL.stabs\fR directives
787: which would generate the same information.
788: Their syntax is as follows:
789: .PP
790: .PR AssemblerSymbol ".stabs "" SymbolName "" , SymbolType , 0 , 0 , SymbolOffset
791: .PC SymbolName Name
792: .PC SymbolType "N_TEXT | TextExternal | N_DATA | DataExternal | N_BSS | BssExternal"
793: .PC N_TEXT 0x04
794: .PC TextExternal 0x05
795: .PC N_DATA 0x06
796: .PC DataExternal 0x07
797: .PC N_BSS 0x08
798: .PC BssExternal 0x09
799: .PP
800: The \fLSymbolName\fR and \fLSymbolOffset\fR are simply the text of the symbol
801: and its offset within the text, data or bss space.
802: The \fLSymbolType\fR indicates the address space and whether the symbol is
803: external.
804: External symbols are indicated by or'ing the value of \fLN_EXT\fR, which is
805: \fL0x01\fR, with the type for the corresponding space.
806: .PP
807: .sp 1
808: .NH 2
809: Other Issues
810: .PP
811: There are several other things one needs to know to interface to the debuggers:
812: .sp 0.5
813: .IP 1.
814: The debuggers require that a program include a routine named \fL_main\fR.
815: If none is found, an internal error results.
816: .IP 2.
817: The debuggers assume the Sun standard format for the run-time stack.
818: If yours differs, it may still be possible to interface to them.
819: Contact us for more information.
820: .PP
821: .sp 1
822: .NH 1
823: The DP-UIP Interface Language
824: .PP
825: As mentioned above in Section 2, \fIdbxtool\fR consists of two processes, the
826: DP (debugger process) and the UIP (user interface process).
827: Commands passed from the DP to the UIP pass through a pipe which is created
828: by the UIP when it starts the DP.
829: The commands are expressed in the DP-UIP interface language, whose
830: syntax and semantics appear below.
831: .NH 2
832: What the UIP and DP Know About Each Other
833: .PP
834: In the current version of \fIdbxtool\fR there are several assumptions which
835: the UIP makes about the DP and vice versa, as follows:
836: .IP 1.
837: The name of the program which the UIP starts is \fLdbx\fR.
838: To do so, it calls \fLttysw_fork(\ )\fR with its second argument set to a
839: pointer to an array \fLnargv[ ]\fR of character strings of the form
840: .TS
841: center;
842: lfL l.
843: nargv[0] \fLdbx\fR
844: nargv[1] \fL-P\fR
845: nargv[2] \fIpipenumber\fR
846: nargv[3] \v'0.02i'\(rt\v'-0.02i'
847: ... \(rk \fIarguments\fR
848: nargv[\fIn\fR] \v'-0.02i'\(rb\v'0.02i'
849: .TE
850: where \fIpipenumber\fR is the number of the pipe which the DP uses in writing
851: to the UIP and \fIarguments\fR are the arguments with which \fIdbxtool\fR
852: was invoked.
853: .IP 2.
854: The sequence of directories to search for source files (provided by
855: the \fIuse\fR command in \fIdbx\fR and \fIdbxtool\fR) is passed by the
856: DP to the UIP (via the \fLI_USE\fR command described below) and used by it
857: to display source in the source window.
858: .IP 3.
859: The lineno selection interpretation is expanded into the form
860: "\fIfilename\fR":\fIlineno\fR before it is passed to the DP.
861: .IP 4.
862: The UIP's command button mechanism assumes that the DP expects commands in
863: prefix form, i.e. with the command name first, and with a blank separating
864: the name from the following argument (if any).
865: Further, for the command buttons to be really useful it must be the case that
866: the DP's most used commands take either zero or one argument, since the
867: argument selection mechanism cannot accomodate more than one selection per
868: command.
869: .PP
870: .NH 2
871: Commands and Type Identifiers
872: .PP
873: .PR Command "VersionCheck | InitDone | Stopped | Quit | PrintLines | BreakSet | BreakDel | Resume | Use | Reinit | Kill | Chdir | Emphasize | Trace | Display | ToolEnv | Width | SourceLines | CommandLines | DisplayLines | Font | TopMargin | BotMargin | Un
874:
875:
876:
877:
878:
879: button | Button"
880: .PP
881: Each command and argument begins with a type identifier which indicates the
882: command or the type of the argument.
883: The mapping between integers and type identifiers is given in Table 4.
884: .KF
885: .sp 1
886: .TS
887: center box;
888: n | lfL.
889: 0 I_BADTYPE
890: 1 I_INITDONE
891: 2 I_STOPPED
892: 3 I_STRING
893: 4 I_INT
894: 5 I_QUIT
895: 6 I_PRINTLINES
896: 7 I_BRKSET
897: 8 I_BRKDEL
898: 9 I_RESUME
899: 10 I_USE
900: 11 I_REINIT
901: 12 I_KILL
902: 13 I_CHDIR
903: 14 I_EMPHASIZE
904: 15 I_TRACE
905: 16 I_DISPLAY
906: 17 I_VERSION
907: 18 I_TOOLENV
908: 19 I_WIDTH
909: 20 I_SRCLINES
910: 21 I_CMDLINES
911: 22 I_DISPLINES
912: 23 I_FONT
913: 24 I_TOPMARGIN
914: 25 I_BOTMARGIN
915: 26 I_UNBUTTON
916: 27 I_BUTTON
917: .TE
918: .ce
919: Table 4. Command and Type Identifiers
920: .sp 1
921: .KE
922: .PP
923: .NH 2
924: Version Consistency Checking
925: .PP
926: .PR VersionCheck "I_VERSION VersionNumber"
927: .PP
928: The DP issues this command during initialization to insure that the versions
929: of the DP and UIP being run are consistent with each other.
930: It tells the UIP the version number of the DP, which must match that of the
931: UIP.
932: It must be the first command issued.
933: .PP
934: .NH 2
935: Initialization Finished
936: .PP
937: .PR InitDone "I_INITDONE FileName LineNumber"
938: .PP
939: The DP issues this command to inform the UIP that it has completed initializing
940: itself.
941: It tells the UIP the name of the source file to display and the line number of
942: the line to appear at the top of the source window.
943: .PP
944: .NH 2
945: Breakpoint Reached
946: .PP
947: .PR Stopped "I_STOPPED FileName FuncName LineNumber BreakFile BreakFunc BreakLine"
948: .PP
949: This command indicates that a breakpoint has been reached and tells the
950: UIP the filename, function name and line number of the point currently
951: being displayed and the same information concerning the breakpoint.
952: .PP
953: .NH 2
954: Terminate \fIDbxtool\fR
955: .PP
956: .PR Quit "I_QUIT ExitStatus"
957: .PP
958: This command tells the UIP to terminate execution of \fIdbxtool\fR and return
959: the given exit status to the shell which invoked it.
960: .PP
961: .NH 2
962: Print Source Lines
963: .PP
964: .PR PrintLines "I_PRINTLINES FileName LineNumber LineNumber"
965: .PP
966: This command specifies a filename and two line numbers, the second of which
967: is ignored by the UIP.
968: It causes the UIP to display lines from the given file in the source window.
969: .PP
970: .NH 2
971: Set a Breakpoint
972: .PP
973: .PR BreakSet "I_BRKSET FileName LineNumber"
974: .PP
975: This command tells the UIP to display a stop sign on the given line
976: of the given file.
977: .PP
978: .NH 2
979: Delete a Breakpoint
980: .PP
981: .PR BreakDel "I_BRKDEL FileName LineNumber"
982: .PP
983: This command tells the UIP to remove a stop sign from the given line
984: of the given file.
985: .PP
986: .NH 2
987: Ready to Resume Execution
988: .PP
989: .PR Resume "I_RESUME"
990: .PP
991: This command tells the UIP that the DP is ready to resume execution of the
992: process being debugged.
993: .PP
994: .NH 2
995: Specify Directory Search Path
996: .PP
997: .PR Use "I_USE DirNumber Directory*"
998: .PP
999: This command specifies to the UIP the search path to be used in locating
1000: source files.
1001: It specifies the number of directories followed by their names.
1002: .PP
1003: .NH 2
1004: Reinitialize the Debugger
1005: .PP
1006: .PR Reinit "I_REINIT"
1007: .PP
1008: This command indicates that the debugger is being reinitialized to debug
1009: another process.
1010: .PP
1011: .NH 2
1012: Kill the Process Being Debugged
1013: .PP
1014: .PR Kill "I_KILL"
1015: .PP
1016: This command informs the UIP that the process being debugged has been
1017: discarded by the DP.
1018: .PP
1019: .NH 2
1020: Change Directory
1021: .PP
1022: .PR Chdir "I_CHDIR Directory"
1023: .PP
1024: This command tells the UIP to change its notion of the current directory
1025: to the one specified.
1026: .PP
1027: .NH 2
1028: Display and Highlight Source Lines
1029: .PP
1030: .PR Emphasize "I_EMPHASIZE FileName LineNumber"
1031: .PP
1032: This command tells the UIP to highlight the given source line (and to display
1033: it if it is not already displayed).
1034: .PP
1035: .NH 2
1036: Display and Highlight Traced Lines
1037: .PP
1038: .PR Trace "I_TRACE BreakFile BreakFunc BreakLine"
1039: .PP
1040: This command tells the UIP to highlight the given source line and display the
1041: arrow indicating the execution focus next to it (and to display it if it
1042: is not already displayed).
1043: .PP
1044: .NH 2
1045: Update Variable Display
1046: .PP
1047: .PR Display "I_DISPLAY DisplayFile"
1048: .PP
1049: This command tells the UIP to update the variable display window by
1050: showing the contents of the given file.
1051: .PP
1052: .NH 2
1053: Print the Tool Environment
1054: .PP
1055: .PR ToolEnv "I_TOOLENV"
1056: .PP
1057: This command causes the UIP to print the current tool environment parameters.
1058: .PP
1059: .NH 2
1060: Specify Width of Window
1061: .PP
1062: .PR Width "I_WIDTH Number"
1063: .PP
1064: This command causes the UIP to change the width of the window to the
1065: given number of characters.
1066: .PP
1067: .NH 2
1068: Specify Number of Lines in Source Window
1069: .PP
1070: .PR SourceLines "I_SRCLINES NumberLines"
1071: .PP
1072: This command causes the UIP to set the vertical size of the source window to
1073: the given number of lines.
1074: .PP
1075: .NH 2
1076: Specify Number of Lines in Command Window
1077: .PP
1078: .PR CommandLines "I_CMDLINES NumberLines"
1079: .PP
1080: This command causes the UIP to set the vertical size of the command window to
1081: the given number of lines.
1082: .PP
1083: .NH 2
1084: Specify Number of Lines in Display Window
1085: .PP
1086: .PR DisplayLines "I_DISPLINES NumberLines"
1087: .PP
1088: This command causes the UIP to set the vertical size of the display window to
1089: the given number of lines.
1090: .PP
1091: .NH 2
1092: Change Font
1093: .PP
1094: .PR Font "I_FONT FontFile"
1095: .PP
1096: This command causes the UIP to using the font given in the specified font file.
1097: .PP
1098: .NH 2
1099: Change Top Margin of Source Window
1100: .PP
1101: .PR TopMargin "I_TOPMARGIN NumberLines"
1102: .PP
1103: This command causes the UIP to set the number of lines between the top of the
1104: source window and the first line containing a breakpoint or the current
1105: execution focus.
1106: .PP
1107: .NH 2
1108: Change Bottom Margin of Source Window
1109: .PP
1110: .PR BotMargin "I_BOTMARGIN NumberLines"
1111: .PP
1112: This command causes the UIP to set the number of lines between the bottom
1113: of the source window and the last line containing a breakpoint or the current
1114: execution focus.
1115: .PP
1116: .NH 2
1117: Remove a Button from the Buttons Window
1118: .PP
1119: .PR Unbutton "I_UNBUTTON ButtonName"
1120: .PP
1121: This command causes the UIP to remove from the buttons window the first button
1122: with the given name.
1123: .PP
1124: .NH 2
1125: Add a Button to the Buttons Window
1126: .PP
1127: .PR Button "I_BUTTON SelectionType ButtonName"
1128: .PP
1129: This command causes the UIP to add to the buttons window a button with the
1130: indicated selection interpretation and name.
1131: The mapping between selection type numbers and selection interpretations
1132: and their meanings is given in Table 5.
1133: .KF
1134: .sp 1
1135: .TS
1136: center box;
1137: c | c | cw(3.5i)
1138: n | l | lw(3.5i).
1139: type name meaning
1140: _
1141: 1 command T{
1142: the selection, which must be in the command window, is expanded to produce
1143: the command which contains it
1144: T}
1145: _
1146: 2 expand T{
1147: the selection produces exactly the selected text, except that if either
1148: its first or last character is an alphanumeric or an underscore it is
1149: expanded to produce the longest enclosing sequence of alphanumerics and
1150: underscores
1151: T}
1152: _
1153: 3 ignore T{
1154: the selection is ignored, producing the null string
1155: T}
1156: _
1157: 4 lineno T{
1158: the selection, which must be in the source window, produces a string of the
1159: form "\fIfilename\fR":\fIlineno\fR, where \fIfilename\fR is the name of the
1160: file displayed in the source window and \fIlineno\fR is the line number of
1161: the selected line
1162: T}
1163: _
1164: 5 literal T{
1165: the selection produces exactly the selected text
1166: T}
1167: .TE
1168: .ce
1169: Table 5. Selection Interpretations
1170: .sp 1
1171: .KE
1172: .PP
1173: .NH 2
1174: Other Items
1175: .PP
1176: .PR SelectionType Number
1177: .PC FileName String
1178: .PC LineNumber Number
1179: .PC FuncName String
1180: .PC BreakFile String
1181: .PC BreakFunc String
1182: .PC BreakLine Number
1183: .PC ExitStatus Number
1184: .PC DirNumber Number
1185: .PC Directory String
1186: .PC DisplayFile String
1187: .PC NumberLines Number
1188: .PC FontFile String
1189: .PC ButtonName String
1190: .PP
1191: .NH 2
1192: Numbers and Strings
1193: .PP
1194: .PR Number "I_INT Integer"
1195: .PC String "I_STRING StringLen Character*"
1196: .PC StringLen Integer
1197: .PP
1198: A number is a 32-bit integer.
1199: A string consists of a 32-bit integer followed by a sequence of that many
1200: characters.
1201: .PP
1202: .bp
1203: .ce
1204: \s+2\fBAppendix A. Standard Types for Sun C, FORTRAN 77, Pascal
1205: .ce
1206: and Modula-2\fR\s-2
1207: .sp 1
1208: .PP
1209: Each language defines some standard types by a series of \fL.stabs\fR
1210: lines, as follows.
1211: For C***, they are
1212: .FS
1213: ***The "\fL???\fR" entry at the end is a debugging artifact.
1214: It serves no purpose in ordinary usage of \fIdbx\fR.
1215: .FE
1216: .sp 1
1217: .in +0.75i
1218: .nf
1219: \fL\s-2
1220: .stabs "int:t(0,1)=r(0,1);-2147483648;2147483647;",0x80,0,0,0
1221: .stabs "char:t(0,2)=r(0,2);0;127;",0x80,0,0,0
1222: .stabs "long:t(0,3)=r(0,1);-2147483648;2147483647;",0x80,0,0,0
1223: .stabs "short:t(0,4)=r(0,1);-32768;32767;",0x80,0,0,0
1224: .stabs "unsigned char:t(0,5)=r(0,1);0;255;",0x80,0,0,0
1225: .stabs "unsigned short:t(0,6)=r(0,1);0;65535;",0x80,0,0,0
1226: .stabs "unsigned long:t(0,7)=r(0,1);0;-1;",0x80,0,0,0
1227: .stabs "unsigned int:t(0,8)=r(0,1);0;-1;",0x80,0,0,0
1228: .stabs "float:t(0,9)=r(0,1);4;0;",0x80,0,0,0
1229: .stabs "double:t(0,10)=r(0,1);8;0;",0x80,0,0,0
1230: .stabs "void:t(0,11)=(0,11)",0x80,0,0,0
1231: .stabs "???:t(0,12)=(0,1)",0x80,0,0,0
1232: \fR\s+2
1233: .fi
1234: .in -0.75i
1235: .sp 1
1236: For FORTRAN 77, they are
1237: .sp 1
1238: .in +0.75i
1239: .nf
1240: \fL\s-2
1241: .stabs "integer*2:t2=r2;-32768;32767;",0x20,0,0,0
1242: .stabs "integer*4:t3=r3;-2147483648;2147483647;",0x20,0,0,0
1243: .stabs "real:t5=r5;4;0;",0x20,0,0,0
1244: .stabs "double precision:t6=r6;8;0;",0x20,0,0,0
1245: .stabs "complex:t7=r7;8;0;",0x20,0,0,0
1246: .stabs "double complex:t8=r8;16;0;",0x20,0,0,0
1247: .stabs "logical:t9=3;",0x20,0,0,0
1248: .stabs "char:t10=r10;0;127;",0x20,0,0,0
1249: .stabs "void:t11=r11;0;0;",0x20,0,0,0
1250: \fR\s+2
1251: .fi
1252: .in -0.75i
1253: .sp 1
1254: For Pascal, they are
1255: .sp 1
1256: .in +0.75i
1257: .nf
1258: \fL\s-2
1259: .stabs "boolean:t1=efalse:0,true:1,",0x20,0x0,0x0,0x0
1260: .stabs "char:t2=r2;0;127",0x20,0x0,0x0,0x0
1261: .stabs "integer:t3=r3;-2147483648;2147483647",0x20,0x0,0x0,0x0
1262: .stabs "shortreal:t4=r4;4;0",0x20,0x0,0x0,0x0
1263: .stabs "real:t5=r5;8;0",0x20,0x0,0x0,0x0
1264: .stabs "(void):t6=6",0x20,0x0,0x0,0x0
1265: .stabs "Boolean:t1",0x20,0x0,0x0,0x0
1266: .stabs "intset:t7=Sr3;0;127",0x20,0x0,0x0,0x0
1267: .stabs "alfa:t8=ar3;1;10;2",0x20,0x0,0x0,0x0
1268: .stabs "text:t9=L2",0x20,0x0,0x0,0x0
1269: .stabs "longreal:t5",0x20,0x0,0x0,0x0
1270: \fR\s+2
1271: .fi
1272: .in -0.75i
1273: .sp 1
1274: .ne 10
1275: For Modula-2, they are
1276: .sp 1
1277: .in +0.75i
1278: .nf
1279: \fL\s-2
1280: .stabs "INTEGER:t1=r1;-2147483648;2147483647", 0x80, 0, 4, 0
1281: .stabs "SHORTINT:t2=r1;-32768;32767", 0x80, 0, 2, 0
1282: .stabs "CARDINAL:t3=r3;0;-1", 0x80, 0, 4, 0
1283: .stabs "SHORTCARD:t4=r3;0;65535", 0x80, 0, 2, 0
1284: .stabs "CHAR:t5=r5;0;255", 0x80, 0, 1, 0
1285: .stabs "BOOLEAN:t6=eFALSE:0,TRUE:1,", 0x80, 0, 1, 0
1286: .stabs "REAL:t7=r7;4;0", 0x80, 0, 4, 0
1287: .stabs "(void):t8=8", 0x80, 0, 4, 0
1288: .stabs "PROC:t9=Q8,0", 0x80, 0, 4, 0
1289: .stabs "BITSET:t10=Sr3;0;31", 0x80, 0, 4, 0
1290: .stabs "BYTE:t11=r11;0;255", 0x80, 0, 1, 0
1291: .stabs "WORD:t12=r12;0;-1", 0x80, 0, 4, 0
1292: .stabs "ADDRESS:t13=r3;0;-1", 0x80, 0, 4, 0
1293: .stabs "PROCESS:t14=*12", 0x80, 0, 4, 0
1294: \fR\s+2
1295: .fi
1296: .in -0.75i
1297: .sp 1
1298: .bp
1299: .ce
1300: \s+2\fBAppendix B. An Example of the Compiler-Debugger Interface\fR\s-2
1301: .sp 1
1302: .PP
1303: This appendix gives an example of the code generated by the Sun C compiler
1304: to interface to the \fIdbx\fR and \fIdbxtool\fR debuggers.
1305: We take as our example the (nonsense) C program
1306: .sp 1
1307: .in +1.0i
1308: .nf
1309: \fL
1310: int a;
1311: static int b;
1312:
1313: static void l( );
1314:
1315: main (d)
1316: register short int d;
1317: { int e[10][20];
1318: static int g = 3;
1319: register int h;
1320: struct i {
1321: int j;
1322: float k;
1323: } i;
1324:
1325: a = 2;
1326: i.j = b;
1327: l( );
1328: }
1329:
1330: static void l()
1331: {
1332: b = 3;
1333: }
1334: \fR
1335: .fi
1336: .in -1.0i
1337: .LP
1338: Compiling this program with \fLcc -g -S example.c\fR results in the following
1339: assembly code in \fLexample.s\fR (with line numbers supplied at the left):
1340: .TS
1341: nw(0.4i) lw(0.7i)fL lw(0.9i)fL lfL.
1342: \s-2
1343: 1 .stabs "example.c",0x64,0,0,LL0
1344: 2 LL0:
1345: 3 .data
1346: 4 .stabs "int:t(0,1)=r(0,1);-2147483648;2147483647;",
1347: 0x80,0,0,0
1348: 5 .stabs "char:t(0,2)=r(0,2);0;127;",0x80,0,0,0
1349: 6 .stabs "long:t(0,3)=r(0,1);-2147483648;2147483647;",
1350: 0x80,0,0,0
1351: 7 .stabs "short:t(0,4)=r(0,1);-32768;32767;",0x80,0,0,0
1352: 8 .stabs "unsigned char:t(0,5)=r(0,1);0;255;",
1353: 0x80,0,0,0
1354: 9 .stabs "unsigned short:t(0,6)=r(0,1);0;65535;",
1355: 0x80,0,0,0
1356: 10 .stabs "unsigned long:t(0,7)=r(0,1);0;-1;",0x80,0,0,0
1357: 11 .stabs "unsigned int:t(0,8)=r(0,1);0;-1;",0x80,0,0,0
1358: 12 .stabs "float:t(0,9)=r(0,1);4;0;",0x80,0,0,0
1359: 13 .stabs "double:t(0,10)=r(0,1);8;0;",0x80,0,0,0
1360: 14 .stabs "void:t(0,11)=(0,11)",0x80,0,0,0
1361: 15 .stabs "???:t(0,12)=(0,1)",0x80,0,0,0
1362: 16 .stabs "a:G(0,1)",0x20,0,4,0
1363: 17 .comm _a,0x4
1364: 18 .stabs "b:S(0,1)",0x28,0,4,_b
1365: 19 .lcomm _b,4
1366: 20 ||| no info for l (18)
1367: 21 .stabs "main:F(0,1)",0x24,0,4,_main
1368: 22 .stabs "d:r(0,4)",0x40,0,2,7
1369: 23 .stabs "d:p(0,4)",0xa0,0,2,8
1370: 24 .text
1371: 25 .stabn 0x44,0,8,LL1
1372: 26 LL1:
1373: 27 | #PROC# 04
1374: 28 .globl _main
1375: 29 _main:
1376: 30 link a6,#0
1377: 31 addl #-LF14,sp
1378: 32 moveml #LS14,sp@
1379: 33 movw a6@(10),d7
1380: 34 .stabn 0x44,0,8,LL2
1381: 35 LL2:
1382: 36 .stabs "e:(0,13)=ar(0,1);0;9;(0,14)=ar(0,1);0;19;(0,1)",
1383: 0x80,0,4,-800
1384: 37 .stabs "g:V(0,1)",0x26,0,4,L16
1385: 38 .data
1386: 39 .even
1387: 40 L16:
1388: 41 .text
1389: 42 .data
1390: 43 .long 0x3
1391: 44 .stabs "h:r(0,1)",0x40,0,4,6
1392: 45 .stabs "i:T(0,15)=s8j:(0,1),0,32;k:(0,9),32,32;;",
1393: 0x80,0,8,-1275
1394: 46 .stabs "i:(0,15)",0x80,0,8,-808
1395: 47 .stabn 0xc0,0,2,LL3
1396: 48 LL3:
1397: 49 .text
1398: 50 .stabn 0x44,0,16,LL4
1399: 51 LL4:
1400: 52 movl #0x2,_a
1401: 53 .stabn 0x44,0,17,LL5
1402: 54 LL5:
1403: 55 movl _b,a6@(-0x328)
1404: 56 .stabn 0x44,0,18,LL6
1405: 57 LL6:
1406: 58 jbsr _l
1407: 59 .stabn 0xe0,0,2,LL7
1408: 60 LL7:
1409: 61 .stabn 0x44,0,19,LL8
1410: 62 LL8:
1411: 63 LE14:
1412: 64 moveml a6@(-0x32c),#0x80
1413: 65 unlk a6
1414: 66 rts
1415: 67 LF14 = 812
1416: 68 LS14 = 0x80
1417: 69 LFF14 = 808
1418: 70 LSS14 = 0x0
1419: 71 LP14 = 0x8
1420: 72 .data
1421: 73 .stabs "l:f(0,11)",0x24,0,0,_l
1422: 74 .text
1423: 75 .stabn 0x44,0,22,LL9
1424: 76 LL9:
1425: 77 | #PROC# 0
1426: 78 _l:
1427: 79 link a6,#0
1428: 80 addl #-LF17,sp
1429: 81 moveml #LS17,sp@
1430: 82 .stabn 0x44,0,22,LL10
1431: 83 LL10:
1432: 84 .stabn 0x44,0,23,LL11
1433: 85 LL11:
1434: 86 movl #0x3,_b
1435: 87 .stabn 0x44,0,24,LL12
1436: 88 LL12:
1437: 89 LE17:
1438: 90 unlk a6
1439: 91 rts
1440: 92 LF17 = 0
1441: 93 LS17 = 0x0
1442: 94 LFF17 = 0
1443: 95 LSS17 = 0x0
1444: 96 LP17 = 0x8
1445: 97 .data
1446: \s+2
1447: .TE
1448: .LP
1449: The following commentary is keyed to the line numbers appearing at the left.
1450: .IP 1: 0.75i
1451: Identifies the source file from which the program was compiled.
1452: .IP "4 - 15:" 0.75i
1453: The C standard types, generated automatically by the compiler.
1454: Line 4, for example, defines \fLint\fR to be type number \fL(0,1)\fR, to be
1455: a subrange of itself with values extending from \fL-2147483648\fR through
1456: \fL2147483647\fR and to be local.
1457: .IP "16 - 17:" 0.75i
1458: The variable \fLa\fR is identified as being a global \fLint\fR
1459: ("\fLG(0,1)\fR") and as occupying 4 bytes of storage.
1460: Its address is given by the assembler symbol \fL_a\fR.
1461: .IP "18 - 19:" 0.75i
1462: The variable \fLb\fR is identified as being a static global \fLint\fR
1463: ("\fLS(0,1)\fR") occupying 4 bytes of storage an with address \fL_b\fR.
1464: .IP 20: 0.75i
1465: The information about \fLl\fR will come later when it is declared (see
1466: line 73).
1467: .IP 21: 0.75i
1468: The symbol \fLmain\fR is identified as a function returning an \fLint\fR
1469: ("\fLF(0,1)\fR") and as beginning at the assembler symbol \fL_main\fR.
1470: .IP "22 - 23:" 0.75i
1471: The symbol \fLd\fR is a \fLshort int\fR parameter ("\fLp(0,4)\fR") and a
1472: register variable ("\fLr(0,4)\fR") occupying in register d7.
1473: .IP 25: 0.75i
1474: This entry represents a bug discovered in the C compiler discovered during
1475: preparation of this document.
1476: The entry on line 34 is the correct one (\fIq.v.\fR)
1477: The bug causes no errors in the debugger since the second (correct) entry for
1478: line 8 simply supplants this one.
1479: .IP 34: 0.75i
1480: Identifies the first line of \fLexample.c\fR for which any executable code is
1481: generated as line 8 and as corresponding to assembly label \fLLL2\fR.
1482: Line 8 is the entry point of \fLmain\fR.
1483: .IP 36: 0.75i
1484: Identifies the symbol \fLe\fR as an array of arrays with anonymous type
1485: \fL(0,13)\fR.
1486: Its subscript is a subrange of \fLint\fR with range \fL0\fR through \fL9\fR
1487: and its elements are arrays with anonymous type \fL(0,14)\fR, which in turn
1488: is an array whose subscript is a subrange of \fLint\fR with range \fL0\fR
1489: through \fL19\fR and element type \fLint\fR.
1490: Its stack offset is -800.
1491: .IP 37: 0.75i
1492: Identifies the symbol \fLg\fR as a static local variable of type \fLint\fR
1493: ("\fLV(0,1)\fR") located at label \fLL16\fR.
1494: .IP 44: 0.75i
1495: The variable \fLh\fR is identified as being a \fLregister int\fR
1496: ("\fLr(0,1)\fR") occupying register d6.
1497: .IP 45: 0.75i
1498: Identifies the symbol \fLi\fR as a structure tag of anonymous type
1499: \fL(0,15)\fR.
1500: Type \fL(0,15)\fR is defined as a structure type occupying 8 bytes with fields
1501: named \fLj\fR and \fLk\fR.
1502: Field \fLj\fR is of type \fLint\fR, begins at bit offset zero and runs for
1503: 32 bits; field \fLk\fR is of type \fLfloat\fR, begins at bit offset 32 and
1504: runs for 32 bits.
1505: .IP 46: 0.75i
1506: Identifies the symbol \fLi\fR as a local variable of type \fL(0,15)\fR
1507: occupying eight bytes and located at stack offset -808.
1508: .IP 47: 0.75i
1509: Identifies a level 2 scope beginning at label \fLLL3\fR.
1510: .IP 59: 0.75i
1511: Identifies a level 2 scope ending at label \fLLL7\fR.
1512: .IP 73: 0.75i
1513: Identifies \fLl\fR as a local function returning \fLvoid\fR and beginning at
1514: symbol \fL_l\fR.
1515: .IP "75 & 82:" 0.75i
1516: These two lines represent the same harmless C compiler bug as do lines 25 and
1517: 34.
1518:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.