
1: /* Definitions and structures for reading debug symbols from the 2: native HP C compiler. 3: 4: Written by the Center for Software Science at the University of Utah 5: and by Cygnus Support. 6: 7: Copyright 1994, 1995, 1998, 1999, 2003 Free Software Foundation, Inc. 8: 9: This program is free software; you can redistribute it and/or modify 10: it under the terms of the GNU General Public License as published by 11: the Free Software Foundation; either version 2 of the License, or 12: (at your option) any later version. 13: 14: This program is distributed in the hope that it will be useful, 15: but WITHOUT ANY WARRANTY; without even the implied warranty of 16: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17: GNU General Public License for more details. 18: 19: You should have received a copy of the GNU General Public License 20: along with this program; if not, write to the Free Software 21: Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ 22: 23: #ifndef HP_SYMTAB_INCLUDED 24: #define HP_SYMTAB_INCLUDED 25: 26: /* General information: 27: 28: This header file defines and describes only the data structures 29: necessary to read debug symbols produced by the HP C compiler, 30: HP ANSI C++ compiler, and HP FORTRAN 90 compiler using the 31: SOM object file format. 32: (For a full description of the debug format, ftp hpux-symtab.h from 33: jaguar.cs.utah.edu:/dist). 34: 35: Additional notes (Rich Title) 36: This file is a reverse-engineered version of a file called 37: "symtab.h" which exists internal to HP's Computer Languages Organization 38: in /CLO/Components/DDE/obj/som/symtab.h. Because HP's version of 39: the file is copyrighted and not distributed, it is necessary for 40: GDB to use the reverse-engineered version that follows. 41: Work was done by Cygnus to reverse-engineer the C subset of symtab.h. 42: The WDB project has extended this to also contain the C++ 43: symbol definitions, the F90 symbol definitions, 44: and the DOC (debugging-optimized-code) symbol definitions. 45: In some cases (the C++ symbol definitions) 46: I have added internal documentation here that 47: goes beyond what is supplied in HP's symtab.h. If we someday 48: unify these files again, the extra comments should be merged back 49: into HP's symtab.h. 50: 51: ------------------------------------------------------------------- 52: 53: Debug symbols are contained entirely within an unloadable space called 54: $DEBUG$. $DEBUG$ contains several subspaces which group related 55: debug symbols. 56: 57: $GNTT$ contains information for global variables, types and contants. 58: 59: $LNTT$ contains information for procedures (including nesting), scoping 60: information, local variables, types, and constants. 61: 62: $SLT$ contains source line information so that code addresses may be 63: mapped to source lines. 64: 65: $VT$ contains various strings and constants for named objects (variables, 66: typedefs, functions, etc). Strings are stored as null-terminated character 67: lists. Constants always begin on word boundaries. The first byte of 68: the VT must be zero (a null string). 69: 70: $XT$ is not currently used by GDB. 71: 72: Many structures within the subspaces point to other structures within 73: the same subspace, or to structures within a different subspace. These 74: pointers are represented as a structure index from the beginning of 75: the appropriate subspace. */ 76: 77: /* Used to describe where a constant is stored. */ 78: enum location_type 79: { 80: LOCATION_IMMEDIATE, 81: LOCATION_PTR, 82: LOCATION_VT, 83: }; 84: 85: /* Languages supported by this debug format. Within the data structures 86: this type is limited to 4 bits for a maximum of 16 languages. */ 87: enum hp_language 88: { 89: HP_LANGUAGE_UNKNOWN, 90: HP_LANGUAGE_C, 91: HP_LANGUAGE_FORTRAN, 92: HP_LANGUAGE_F77 = HP_LANGUAGE_FORTRAN, 93: HP_LANGUAGE_PASCAL, 94: HP_LANGUAGE_MODCAL, 95: HP_LANGUAGE_COBOL, 96: HP_LANGUAGE_BASIC, 97: HP_LANGUAGE_ADA, 98: HP_LANGUAGE_CPLUSPLUS, 99: HP_LANGUAGE_DMPASCAL 100: }; 101: 102: 103: /* Basic data types available in this debug format. Within the data 104: structures this type is limited to 5 bits for a maximum of 32 basic 105: data types. */ 106: enum hp_type 107: { 108: HP_TYPE_UNDEFINED, /* 0 */ 109: HP_TYPE_BOOLEAN, /* 1 */ 110: HP_TYPE_CHAR, /* 2 */ 111: HP_TYPE_INT, /* 3 */ 112: HP_TYPE_UNSIGNED_INT, /* 4 */ 113: HP_TYPE_REAL, /* 5 */ 114: HP_TYPE_COMPLEX, /* 6 */ 115: HP_TYPE_STRING200, /* 7 */ 116: HP_TYPE_LONGSTRING200, /* 8 */ 117: HP_TYPE_TEXT, /* 9 */ 118: HP_TYPE_FLABEL, /* 10 */ 119: HP_TYPE_FTN_STRING_SPEC, /* 11 */ 120: HP_TYPE_MOD_STRING_SPEC, /* 12 */ 121: HP_TYPE_PACKED_DECIMAL, /* 13 */ 122: HP_TYPE_REAL_3000, /* 14 */ 123: HP_TYPE_MOD_STRING_3000, /* 15 */ 124: HP_TYPE_ANYPOINTER, /* 16 */ 125: HP_TYPE_GLOBAL_ANYPOINTER, /* 17 */ 126: HP_TYPE_LOCAL_ANYPOINTER, /* 18 */ 127: HP_TYPE_COMPLEXS3000, /* 19 */ 128: HP_TYPE_FTN_STRING_S300_COMPAT, /* 20 */ 129: HP_TYPE_FTN_STRING_VAX_COMPAT, /* 21 */ 130: HP_TYPE_BOOLEAN_S300_COMPAT, /* 22 */ 131: HP_TYPE_BOOLEAN_VAX_COMPAT, /* 23 */ 132: HP_TYPE_WIDE_CHAR, /* 24 */ 133: HP_TYPE_LONG, /* 25 */ 134: HP_TYPE_UNSIGNED_LONG, /* 26 */ 135: HP_TYPE_DOUBLE, /* 27 */ 136: HP_TYPE_TEMPLATE_ARG, /* 28 */ 137: HP_TYPE_VOID /* 29 */ 138: }; 139: 140: /* An immediate name and type table entry. 141: 142: extension and immediate will always be one. 143: global will always be zero. 144: hp_type is the basic type this entry describes. 145: bitlength is the length in bits for the basic type. */ 146: struct dnttp_immediate 147: { 148: unsigned int extension: 1; 149: unsigned int immediate: 1; 150: unsigned int global: 1; 151: unsigned int type: 5; 152: unsigned int bitlength: 24; 153: }; 154: 155: /* A nonimmediate name and type table entry. 156: 157: extension will always be one. 158: immediate will always be zero. 159: if global is zero, this entry points into the LNTT 160: if global is one, this entry points into the GNTT 161: index is the index within the GNTT or LNTT for this entry. */ 162: struct dnttp_nonimmediate 163: { 164: unsigned int extension: 1; 165: unsigned int immediate: 1; 166: unsigned int global: 1; 167: unsigned int index: 29; 168: }; 169: 170: /* A pointer to an entry in the GNTT and LNTT tables. It has two 171: forms depending on the type being described. 172: 173: The immediate form is used for simple entries and is one 174: word. 175: 176: The nonimmediate form is used for complex entries and contains 177: an index into the LNTT or GNTT which describes the entire type. 178: 179: If a dnttpointer is -1, then it is a NIL entry. */ 180: 181: #define DNTTNIL (-1) 182: typedef union dnttpointer 183: { 184: struct dnttp_immediate dntti; 185: struct dnttp_nonimmediate dnttp; 186: int word; 187: } dnttpointer; 188: 189: /* An index into the source line table. As with dnttpointers, a sltpointer 190: of -1 indicates a NIL entry. */ 191: #define SLTNIL (-1) 192: typedef int sltpointer; 193: 194: /* Index into DOC (= "Debugging Optimized Code") line table. */ 195: #define LTNIL (-1) 196: typedef int ltpointer; 197: 198: /* Index into context table. */ 199: #define CTXTNIL (-1) 200: typedef int ctxtpointer; 201: 202: /* Unsigned byte offset into the VT. */ 203: typedef unsigned int vtpointer; 204: 205: /* A DNTT entry (used within the GNTT and LNTT). 206: 207: DNTT entries are variable sized objects, but are always a multiple 208: of 3 words (we call each group of 3 words a "block"). 209: 210: The first bit in each block is an extension bit. This bit is zero 211: for the first block of a DNTT entry. If the entry requires more 212: than one block, then this bit is set to one in all blocks after 213: the first one. */ 214: 215: /* Each DNTT entry describes a particular debug symbol (beginning of 216: a source file, a function, variables, structures, etc. 217: 218: The type of the DNTT entry is stored in the "kind" field within the 219: DNTT entry itself. */ 220: 221: enum dntt_entry_type 222: { 223: DNTT_TYPE_NIL = -1, 224: DNTT_TYPE_SRCFILE, 225: DNTT_TYPE_MODULE, 226: DNTT_TYPE_FUNCTION, 227: DNTT_TYPE_ENTRY, 228: DNTT_TYPE_BEGIN, 229: DNTT_TYPE_END, 230: DNTT_TYPE_IMPORT, 231: DNTT_TYPE_LABEL, 232: DNTT_TYPE_FPARAM, 233: DNTT_TYPE_SVAR, 234: DNTT_TYPE_DVAR, 235: DNTT_TYPE_HOLE1, 236: DNTT_TYPE_CONST, 237: DNTT_TYPE_TYPEDEF, 238: DNTT_TYPE_TAGDEF, 239: DNTT_TYPE_POINTER, 240: DNTT_TYPE_ENUM, 241: DNTT_TYPE_MEMENUM, 242: DNTT_TYPE_SET, 243: DNTT_TYPE_SUBRANGE, 244: DNTT_TYPE_ARRAY, 245: DNTT_TYPE_STRUCT, 246: DNTT_TYPE_UNION, 247: DNTT_TYPE_FIELD, 248: DNTT_TYPE_VARIANT, 249: DNTT_TYPE_FILE, 250: DNTT_TYPE_FUNCTYPE, 251: DNTT_TYPE_WITH, 252: DNTT_TYPE_COMMON, 253: DNTT_TYPE_COBSTRUCT, 254: DNTT_TYPE_XREF, 255: DNTT_TYPE_SA, 256: DNTT_TYPE_MACRO, 257: DNTT_TYPE_BLOCKDATA, 258: DNTT_TYPE_CLASS_SCOPE, 259: DNTT_TYPE_REFERENCE, 260: DNTT_TYPE_PTRMEM, 261: DNTT_TYPE_PTRMEMFUNC, 262: DNTT_TYPE_CLASS, 263: DNTT_TYPE_GENFIELD, 264: DNTT_TYPE_VFUNC, 265: DNTT_TYPE_MEMACCESS, 266: DNTT_TYPE_INHERITANCE, 267: DNTT_TYPE_FRIEND_CLASS, 268: DNTT_TYPE_FRIEND_FUNC, 269: DNTT_TYPE_MODIFIER, 270: DNTT_TYPE_OBJECT_ID, 271: DNTT_TYPE_MEMFUNC, 272: DNTT_TYPE_TEMPLATE, 273: DNTT_TYPE_TEMPLATE_ARG, 274: DNTT_TYPE_FUNC_TEMPLATE, 275: DNTT_TYPE_LINK, 276: DNTT_TYPE_DYN_ARRAY_DESC, 277: DNTT_TYPE_DESC_SUBRANGE, 278: DNTT_TYPE_BEGIN_EXT, 279: DNTT_TYPE_INLN, 280: DNTT_TYPE_INLN_LIST, 281: DNTT_TYPE_ALIAS, 282: DNTT_TYPE_DOC_FUNCTION, 283: DNTT_TYPE_DOC_MEMFUNC, 284: DNTT_TYPE_MAX 285: }; 286: 287: /* DNTT_TYPE_SRCFILE: 288: 289: One DNTT_TYPE_SRCFILE symbol is output for the start of each source 290: file and at the begin and end of an included file. A DNTT_TYPE_SRCFILE 291: entry is also output before each DNTT_TYPE_FUNC symbol so that debuggers 292: can determine what file a function was defined in. 293: 294: LANGUAGE describes the source file's language. 295: 296: NAME points to an VT entry providing the source file's name. 297: 298: Note the name used for DNTT_TYPE_SRCFILE entries are exactly as seen 299: by the compiler (ie they may be relative or absolute). C include files 300: via <> inclusion must use absolute paths. 301: 302: ADDRESS points to an SLT entry from which line number and code locations 303: may be determined. */ 304: 305: struct dntt_type_srcfile 306: { 307: unsigned int extension: 1; 308: unsigned int kind: 10; /* DNTT_TYPE_SRCFILE */ 309: unsigned int language: 4; 310: unsigned int unused: 17; 311: vtpointer name; 312: sltpointer address; 313: }; 314: 315: /* DNTT_TYPE_MODULE: 316: 317: A DNTT_TYPE_MODULE symbol is emitted for the start of a pascal 318: module or C source file. A module indicates a compilation unit 319: for name-scoping purposes; in that regard there should be 320: a 1-1 correspondence between GDB "symtab"'s and MODULE symbol records. 321: 322: Each DNTT_TYPE_MODULE must have an associated DNTT_TYPE_END symbol. 323: 324: NAME points to a VT entry providing the module's name. Note C 325: source files are considered nameless modules. 326: 327: ALIAS point to a VT entry providing a secondary name. 328: 329: ADDRESS points to an SLT entry from which line number and code locations 330: may be determined. */ 331: 332: struct dntt_type_module 333: { 334: unsigned int extension: 1; 335: unsigned int kind: 10; /* DNTT_TYPE_MODULE */ 336: unsigned int unused: 21; 337: vtpointer name; 338: vtpointer alias; 339: dnttpointer unused2; 340: sltpointer address; 341: }; 342: 343: /* DNTT_TYPE_FUNCTION, 344: DNTT_TYPE_ENTRY, 345: DNTT_TYPE_BLOCKDATA, 346: DNTT_TYPE_MEMFUNC: 347: 348: A DNTT_TYPE_FUNCTION symbol is emitted for each function definition; 349: a DNTT_TYPE_ENTRY symbols is used for secondary entry points. Both 350: symbols used the dntt_type_function structure. 351: A DNTT_TYPE_BLOCKDATA symbol is emitted ...? 352: A DNTT_TYPE_MEMFUNC symbol is emitted for inlined member functions (C++). 353: 354: Each of DNTT_TYPE_FUNCTION must have a matching DNTT_TYPE_END. 355: 356: GLOBAL is nonzero if the function has global scope. 357: 358: LANGUAGE describes the function's source language. 359: 360: OPT_LEVEL describes the optimization level the function was compiled 361: with. 362: 363: VARARGS is nonzero if the function uses varargs. 364: 365: NAME points to a VT entry providing the function's name. 366: 367: ALIAS points to a VT entry providing a secondary name for the function. 368: 369: FIRSTPARAM points to a LNTT entry which describes the parameter list. 370: 371: ADDRESS points to an SLT entry from which line number and code locations 372: may be determined. 373: 374: ENTRYADDR is the memory address corresponding the function's entry point 375: 376: RETVAL points to a LNTT entry describing the function's return value. 377: 378: LOWADDR is the lowest memory address associated with this function. 379: 380: HIADDR is the highest memory address associated with this function. */ 381: 382: struct dntt_type_function 383: { 384: unsigned int extension: 1; 385: unsigned int kind: 10; /* DNTT_TYPE_FUNCTION, 386: DNTT_TYPE_ENTRY, 387: DNTT_TYPE_BLOCKDATA 388: or DNTT_TYPE_MEMFUNC */ 389: unsigned int global: 1; 390: unsigned int language: 4; 391: unsigned int nest_level: 5; 392: unsigned int opt_level: 2; 393: unsigned int varargs: 1; 394: unsigned int lang_info: 4; 395: unsigned int inlined: 1; 396: unsigned int localalloc: 1; 397: unsigned int expansion: 1; 398: unsigned int unused: 1; 399: vtpointer name; 400: vtpointer alias; 401: dnttpointer firstparam; 402: sltpointer address; 403: CORE_ADDR entryaddr; 404: dnttpointer retval; 405: CORE_ADDR lowaddr; 406: CORE_ADDR hiaddr; 407: }; 408: 409: /* DNTT_TYPE_BEGIN: 410: 411: A DNTT_TYPE_BEGIN symbol is emitted to begin a new nested scope. 412: Every DNTT_TYPE_BEGIN symbol must have a matching DNTT_TYPE_END symbol. 413: 414: CLASSFLAG is nonzero if this is the beginning of a c++ class definition. 415: 416: ADDRESS points to an SLT entry from which line number and code locations 417: may be determined. */ 418: 419: struct dntt_type_begin 420: { 421: unsigned int extension: 1; 422: unsigned int kind: 10; 423: unsigned int classflag: 1; 424: unsigned int unused: 20; 425: sltpointer address; 426: }; 427: 428: /* DNTT_TYPE_END: 429: 430: A DNTT_TYPE_END symbol is emitted when closing a scope started by 431: a DNTT_TYPE_MODULE, DNTT_TYPE_FUNCTION, DNTT_TYPE_WITH, 432: DNTT_TYPE_COMMON, DNTT_TYPE_BEGIN, and DNTT_TYPE_CLASS_SCOPE symbols. 433: 434: ENDKIND describes what type of scope the DNTT_TYPE_END is closing 435: (one of the above 6 kinds). 436: 437: CLASSFLAG is nonzero if this is the end of a c++ class definition. 438: 439: ADDRESS points to an SLT entry from which line number and code locations 440: may be determined. 441: 442: BEGINSCOPE points to the LNTT entry which opened the scope. */ 443: 444: struct dntt_type_end 445: { 446: unsigned int extension: 1; 447: unsigned int kind: 10; 448: unsigned int endkind: 10; 449: unsigned int classflag: 1; 450: unsigned int unused: 10; 451: sltpointer address; 452: dnttpointer beginscope; 453: }; 454: 455: /* DNTT_TYPE_IMPORT is unused by GDB. */ 456: /* DNTT_TYPE_LABEL is unused by GDB. */ 457: 458: /* DNTT_TYPE_FPARAM: 459: 460: A DNTT_TYPE_FPARAM symbol is emitted for a function argument. When 461: chained together the symbols represent an argument list for a function. 462: 463: REGPARAM is nonzero if this parameter was passed in a register. 464: 465: INDIRECT is nonzero if this parameter is a pointer to the parameter 466: (pass by reference or pass by value for large items). 467: 468: LONGADDR is nonzero if the parameter is a 64bit pointer. 469: 470: NAME is a pointer into the VT for the parameter's name. 471: 472: LOCATION describes where the parameter is stored. Depending on the 473: parameter type LOCATION could be a register number, or an offset 474: from the stack pointer. 475: 476: TYPE points to a NTT entry describing the type of this parameter. 477: 478: NEXTPARAM points to the LNTT entry describing the next parameter. */ 479: 480: struct dntt_type_fparam 481: { 482: unsigned int extension: 1; 483: unsigned int kind: 10; 484: unsigned int regparam: 1; 485: unsigned int indirect: 1; 486: unsigned int longaddr: 1; 487: unsigned int copyparam: 1; 488: unsigned int dflt: 1; 489: unsigned int doc_ranges: 1; 490: unsigned int misc_kind: 1; 491: unsigned int unused: 14; 492: vtpointer name; 493: CORE_ADDR location; 494: dnttpointer type; 495: dnttpointer nextparam; 496: int misc; 497: }; 498: 499: /* DNTT_TYPE_SVAR: 500: 501: A DNTT_TYPE_SVAR is emitted to describe a variable in static storage. 502: 503: GLOBAL is nonzero if the variable has global scope. 504: 505: INDIRECT is nonzero if the variable is a pointer to an object. 506: 507: LONGADDR is nonzero if the variable is in long pointer space. 508: 509: STATICMEM is nonzero if the variable is a member of a class. 510: 511: A_UNION is nonzero if the variable is an anonymous union member. 512: 513: NAME is a pointer into the VT for the variable's name. 514: 515: LOCATION provides the memory address for the variable. 516: 517: TYPE is a pointer into either the GNTT or LNTT which describes 518: the type of this variable. */ 519: 520: struct dntt_type_svar 521: { 522: unsigned int extension: 1; 523: unsigned int kind: 10; 524: unsigned int global: 1; 525: unsigned int indirect: 1; 526: unsigned int longaddr: 1; 527: unsigned int staticmem: 1; 528: unsigned int a_union: 1; 529: unsigned int unused1: 1; 530: unsigned int thread_specific: 1; 531: unsigned int unused2: 14; 532: vtpointer name; 533: CORE_ADDR location; 534: dnttpointer type; 535: unsigned int offset; 536: unsigned int displacement; 537: }; 538: 539: /* DNTT_TYPE_DVAR: 540: 541: A DNTT_TYPE_DVAR is emitted to describe automatic variables and variables 542: held in registers. 543: 544: GLOBAL is nonzero if the variable has global scope. 545: 546: INDIRECT is nonzero if the variable is a pointer to an object. 547: 548: REGVAR is nonzero if the variable is in a register. 549: 550: A_UNION is nonzero if the variable is an anonymous union member. 551: 552: NAME is a pointer into the VT for the variable's name. 553: 554: LOCATION provides the memory address or register number for the variable. 555: 556: TYPE is a pointer into either the GNTT or LNTT which describes 557: the type of this variable. */ 558: 559: struct dntt_type_dvar 560: { 561: unsigned int extension: 1; 562: unsigned int kind: 10; 563: unsigned int global: 1; 564: unsigned int indirect: 1; 565: unsigned int regvar: 1; 566: unsigned int a_union: 1; 567: unsigned int unused: 17; 568: vtpointer name; 569: int location; 570: dnttpointer type; 571: unsigned int offset; 572: }; 573: 574: /* DNTT_TYPE_CONST: 575: 576: A DNTT_TYPE_CONST symbol is emitted for program constants. 577: 578: GLOBAL is nonzero if the constant has global scope. 579: 580: INDIRECT is nonzero if the constant is a pointer to an object. 581: 582: LOCATION_TYPE describes where to find the constant's value 583: (in the VT, memory, or embedded in an instruction). 584: 585: CLASSMEM is nonzero if the constant is a member of a class. 586: 587: NAME is a pointer into the VT for the constant's name. 588: 589: LOCATION provides the memory address, register number or pointer 590: into the VT for the constant's value. 591: 592: TYPE is a pointer into either the GNTT or LNTT which describes 593: the type of this variable. */ 594: 595: struct dntt_type_const 596: { 597: unsigned int extension: 1; 598: unsigned int kind: 10; 599: unsigned int global: 1; 600: unsigned int indirect: 1; 601: unsigned int location_type: 3; 602: unsigned int classmem: 1; 603: unsigned int unused: 15; 604: vtpointer name; 605: CORE_ADDR location; 606: dnttpointer type; 607: unsigned int offset; 608: unsigned int displacement; 609: }; 610: 611: /* DNTT_TYPE_TYPEDEF and DNTT_TYPE_TAGDEF: 612: 613: The same structure is used to describe typedefs and tagdefs. 614: 615: DNTT_TYPE_TYPEDEFS are associated with C "typedefs". 616: 617: DNTT_TYPE_TAGDEFs are associated with C "struct", "union", and "enum" 618: tags, which may have the same name as a typedef in the same sc