|
|
1.1 ! root 1: /* Copyright (c) 1980 Regents of the University of California */ ! 2: ! 3: static char sccsid[] = "@(#)stab.c 1.3 9/4/80"; ! 4: ! 5: /* ! 6: * procedures to put out sdb symbol table information. ! 7: * and stabs for separate compilation type checking. ! 8: * these use the new .stabs, .stabn, and .stabd directives ! 9: */ ! 10: ! 11: #include "whoami.h" ! 12: #ifdef PC ! 13: /* and the rest of the file */ ! 14: # include "0.h" ! 15: # include <stab.h> ! 16: ! 17: /* ! 18: * additional symbol definition for <stab.h> ! 19: * that is used by the separate compilation facility -- ! 20: * eventually, <stab.h> should be updated to include this ! 21: */ ! 22: ! 23: # include "pstab.h" ! 24: # include "pc.h" ! 25: ! 26: /* ! 27: * absolute value: line numbers are negative if error recovery. ! 28: */ ! 29: #define ABS( x ) ( x < 0 ? -x : x ) ! 30: ! 31: /* ! 32: * variables ! 33: */ ! 34: stabvar( name , type , level , offset , length , line ) ! 35: char *name; ! 36: int type; ! 37: int level; ! 38: int offset; ! 39: int length; ! 40: int line; ! 41: { ! 42: ! 43: /* ! 44: * for separate compilation ! 45: */ ! 46: if ( level == 1 ) { ! 47: putprintf( " .stabs \"%s\",0x%x,0,0x%x,0x%x" , 0 ! 48: , name , N_PC , N_PGVAR , ABS( line ) ); ! 49: } ! 50: /* ! 51: * for sdb ! 52: */ ! 53: if ( ! opt('g') ) { ! 54: return; ! 55: } ! 56: putprintf( " .stabs \"" , 1 ); ! 57: putprintf( NAMEFORMAT , 1 , name ); ! 58: if ( level == 1 ) { ! 59: putprintf( "\",0x%x,0,0x%x,0" , 0 , N_GSYM , type ); ! 60: } else { ! 61: putprintf( "\",0x%x,0,0x%x,0x%x" , 0 , N_LSYM , type , offset ); ! 62: } ! 63: putprintf( " .stabs \"" , 1 ); ! 64: putprintf( NAMEFORMAT , 1 , name ); ! 65: putprintf( "\",0x%x,0,0,0x%x" , 0 , N_LENG , length ); ! 66: ! 67: } ! 68: ! 69: ! 70: /* ! 71: * parameters ! 72: */ ! 73: stabparam( name , type , offset , length ) ! 74: char *name; ! 75: int type; ! 76: int offset; ! 77: int length; ! 78: { ! 79: ! 80: if ( ! opt('g') ) { ! 81: return; ! 82: } ! 83: putprintf( " .stabs \"" , 1 ); ! 84: putprintf( NAMEFORMAT , 1 , name ); ! 85: putprintf( "\",0x%x,0,0x%x,0x%x" , 0 , N_PSYM , type , offset ); ! 86: putprintf( " .stabs \"" , 1 ); ! 87: putprintf( NAMEFORMAT , 1 , name ); ! 88: putprintf( "\",0x%x,0,0,0x%x" , 0 , N_LENG , length ); ! 89: } ! 90: ! 91: /* ! 92: * fields ! 93: */ ! 94: stabfield( name , type , offset , length ) ! 95: char *name; ! 96: int type; ! 97: int offset; ! 98: int length; ! 99: { ! 100: ! 101: if ( ! opt('g') ) { ! 102: return; ! 103: } ! 104: putprintf( " .stabs \"" , 1 ); ! 105: putprintf( NAMEFORMAT , 1 , name ); ! 106: putprintf( "\",0x%x,0,0x%x,0x%x" , 0 , N_SSYM , type , offset ); ! 107: putprintf( " .stabs \"" , 1 ); ! 108: putprintf( NAMEFORMAT , 1 , name ); ! 109: putprintf( "\",0x%x,0,0,0x%x" , 0 , N_LENG , length ); ! 110: } ! 111: ! 112: /* ! 113: * left brackets ! 114: */ ! 115: stablbrac( level ) ! 116: int level; ! 117: { ! 118: ! 119: if ( ! opt('g') ) { ! 120: return; ! 121: } ! 122: putprintf( " .stabd 0x%x,0,0x%x" , 0 , N_LBRAC , level ); ! 123: } ! 124: ! 125: /* ! 126: * right brackets ! 127: */ ! 128: stabrbrac( level ) ! 129: int level; ! 130: { ! 131: ! 132: if ( ! opt('g') ) { ! 133: return; ! 134: } ! 135: putprintf( " .stabd 0x%x,0,0x%x" , 0 , N_RBRAC , level ); ! 136: } ! 137: ! 138: /* ! 139: * functions ! 140: */ ! 141: stabfunc( name , class , line , level ) ! 142: char *name; ! 143: int class; ! 144: int line; ! 145: long level; ! 146: { ! 147: int type; ! 148: long i; ! 149: ! 150: /* ! 151: * for separate compilation ! 152: */ ! 153: if ( level == 1 ) { ! 154: if ( class == FUNC ) { ! 155: putprintf( " .stabs \"%s\",0x%x,0,0x%x,0x%x" , 0 ! 156: , name , N_PC , N_PGFUNC , ABS( line ) ); ! 157: } else if ( class == PROC ) { ! 158: putprintf( " .stabs \"%s\",0x%x,0,0x%x,0x%x" , 0 ! 159: , name , N_PC , N_PGPROC , ABS( line ) ); ! 160: } ! 161: } ! 162: /* ! 163: * for sdb ! 164: */ ! 165: if ( ! opt('g') ) { ! 166: return; ! 167: } ! 168: putprintf( " .stabs \"" , 1 ); ! 169: putprintf( NAMEFORMAT , 1 , name ); ! 170: putprintf( "\",0x%x,0,0x%x," , 1 , N_FUN , line ); ! 171: for ( i = 1 ; i < level ; i++ ) { ! 172: putprintf( EXTFORMAT , 1 , enclosing[ i ] ); ! 173: } ! 174: putprintf( EXTFORMAT , 0 , name ); ! 175: } ! 176: ! 177: /* ! 178: * source line numbers ! 179: */ ! 180: stabline( line ) ! 181: int line; ! 182: { ! 183: if ( ! opt('g') ) { ! 184: return; ! 185: } ! 186: putprintf( " .stabd 0x%x,0,0x%x" , 0 , N_SLINE , ABS( line ) ); ! 187: } ! 188: ! 189: /* ! 190: * source files ! 191: */ ! 192: stabsource( filename ) ! 193: char *filename; ! 194: { ! 195: int label; ! 196: ! 197: /* ! 198: * for separate compilation ! 199: */ ! 200: putprintf( " .stabs \"%s\",0x%x,0,0x%x,0" , 0 ! 201: , filename , N_PC , N_PSO ); ! 202: /* ! 203: * for sdb ! 204: */ ! 205: if ( ! opt('g') ) { ! 206: return; ! 207: } ! 208: label = getlab(); ! 209: putprintf( " .stabs \"" , 1 ); ! 210: putprintf( NAMEFORMAT , 1 , filename ); ! 211: putprintf( "\",0x%x,0,0," , 1 , N_SO ); ! 212: putprintf( PREFIXFORMAT , 0 , LLABELPREFIX , label ); ! 213: putprintf( PREFIXFORMAT , 1 , LLABELPREFIX , label ); ! 214: putprintf( ":" , 0 ); ! 215: } ! 216: ! 217: /* ! 218: * included files get one or more of these: ! 219: * one as they are entered by a #include, ! 220: * and one every time they are returned to by nested #includes ! 221: */ ! 222: stabinclude( filename ) ! 223: char *filename; ! 224: { ! 225: int label; ! 226: ! 227: /* ! 228: * for separate compilation ! 229: */ ! 230: putprintf( " .stabs \"%s\",0x%x,0,0x%x,0" , 0 ! 231: , filename , N_PC , N_PSOL ); ! 232: /* ! 233: * for sdb ! 234: */ ! 235: if ( ! opt('g') ) { ! 236: return; ! 237: } ! 238: label = getlab(); ! 239: putprintf( " .stabs \"" , 1 ); ! 240: putprintf( NAMEFORMAT , 1 , filename ); ! 241: putprintf( "\",0x%x,0,0," , 1 , N_SOL ); ! 242: putprintf( PREFIXFORMAT , 0 , LLABELPREFIX , label ); ! 243: putprintf( PREFIXFORMAT , 1 , LLABELPREFIX , label ); ! 244: putprintf( ":" , 0 ); ! 245: } ! 246: ! 247: ! 248: /* ! 249: * global Pascal symbols : ! 250: * labels, types, constants, and external procedure and function names: ! 251: * These are used by the separate compilation facility ! 252: * to be able to check for disjoint header files. ! 253: */ ! 254: ! 255: /* ! 256: * global labels ! 257: */ ! 258: stabglabel( label , line ) ! 259: char *label; ! 260: int line; ! 261: { ! 262: ! 263: putprintf( " .stabs \"%s\",0x%x,0,0x%x,0x%x" , 0 ! 264: , label , N_PC , N_PGLABEL , ABS( line ) ); ! 265: } ! 266: ! 267: /* ! 268: * global constants ! 269: */ ! 270: stabgconst( const , line ) ! 271: char *const; ! 272: int line; ! 273: { ! 274: ! 275: putprintf( " .stabs \"%s\",0x%x,0,0x%x,0x%x" , 0 ! 276: , const , N_PC , N_PGCONST , ABS( line ) ); ! 277: } ! 278: ! 279: /* ! 280: * global types ! 281: */ ! 282: stabgtype( type , line ) ! 283: char *type; ! 284: int line; ! 285: { ! 286: ! 287: putprintf( " .stabs \"%s\",0x%x,0,0x%x,0x%x" , 0 ! 288: , type , N_PC , N_PGTYPE , ABS( line ) ); ! 289: } ! 290: ! 291: ! 292: /* ! 293: * external functions and procedures ! 294: */ ! 295: stabefunc( name , class , line ) ! 296: char *name; ! 297: int class; ! 298: int line; ! 299: { ! 300: int type; ! 301: ! 302: if ( class == FUNC ) { ! 303: type = N_PEFUNC; ! 304: } else if ( class == PROC ) { ! 305: type = N_PEPROC; ! 306: } else { ! 307: return; ! 308: } ! 309: putprintf( " .stabs \"%s\",0x%x,0,0x%x,0x%x" , 0 ! 310: , name , N_PC , type , ABS( line ) ); ! 311: } ! 312: ! 313: #endif PC
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.