/* Copyright (c) 1980 Regents of the University of California */
static char sccsid
[] = "@(#)stab.c 1.8.1.1 %G%";
* procedures to put out sdb symbol table information.
* and stabs for separate compilation type checking.
* these use the new .stabs, .stabn, and .stabd directives
/* and the rest of the file */
* additional symbol definition for <stab.h>
* that is used by the separate compilation facility --
* eventually, <stab.h> should be updated to include this
* absolute value: line numbers are negative if error recovery.
#define ABS( x ) ( x < 0 ? -x : x )
stabgvar( name
, type
, offset
, length
, line
)
* for separate compilation
putprintf( " .stabs \"%s\",0x%x,0,0x%x,0x%x" , 0
, (int) name
, N_PC
, N_PGVAR
, ABS( line
) );
putprintf( " .stabs \"" , 1 );
putprintf( NAMEFORMAT
, 1 , (int) name
);
putprintf( "\",0x%x,0,0x%x,0" , 0 , N_GSYM
, type
);
putprintf( " .stabs \"" , 1 );
putprintf( NAMEFORMAT
, 1 , (int) name
);
putprintf( "\",0x%x,0,0,0x%x" , 0 , N_LENG
, length
);
stablvar( name
, type
, level
, offset
, length
)
putprintf( " .stabs \"" , 1 );
putprintf( NAMEFORMAT
, 1 , (int) name
);
putprintf( "\",0x%x,0,0x%x,0x%x" , 0 , N_LSYM
, type
, -offset
);
putprintf( " .stabs \"" , 1 );
putprintf( NAMEFORMAT
, 1 , (int) name
);
putprintf( "\",0x%x,0,0,0x%x" , 0 , N_LENG
, length
);
stabparam( name
, type
, offset
, length
)
putprintf( " .stabs \"" , 1 );
putprintf( NAMEFORMAT
, 1 , (int) name
);
putprintf( "\",0x%x,0,0x%x,0x%x" , 0 , N_PSYM
, type
, offset
);
putprintf( " .stabs \"" , 1 );
putprintf( NAMEFORMAT
, 1 , (int) name
);
putprintf( "\",0x%x,0,0,0x%x" , 0 , N_LENG
, length
);
putprintf( " .stabd 0x%x,0,0x%x" , 0 , N_LBRAC
, level
);
putprintf( " .stabd 0x%x,0,0x%x" , 0 , N_RBRAC
, level
);
stabfunc( name
, typeclass
, line
, level
)
* for separate compilation
if ( typeclass
== FUNC
) {
putprintf( " .stabs \"%s\",0x%x,0,0x%x,0x%x" , 0
, (int) name
, N_PC
, N_PGFUNC
, ABS( line
) );
} else if ( typeclass
== PROC
) {
putprintf( " .stabs \"%s\",0x%x,0,0x%x,0x%x" , 0
, (int) name
, N_PC
, N_PGPROC
, ABS( line
) );
putprintf( " .stabs \"" , 1 );
putprintf( NAMEFORMAT
, 1 , (int) name
);
sextname( extname
, name
, (int) level
);
putprintf( "\",0x%x,0,0x%x,%s" , 0 , N_FUN
, line
, (int) extname
);
putprintf( " .stabd 0x%x,0,0x%x" , 0 , N_SLINE
, ABS( line
) );
* for separate compilation
putprintf(" .stabs \"%s\",0x%x,0,0x%x,0x%x", 0,
filename
, N_PC
, N_PSO
, N_FLAGCHECKSUM
);
putprintf( " .stabs \"" , 1 );
putprintf( NAMEFORMAT
, 1 , filename
);
putprintf( "\",0x%x,0,0," , 1 , N_SO
);
putprintf( PREFIXFORMAT
, 0 , LLABELPREFIX
, label
);
putprintf( PREFIXFORMAT
, 1 , LLABELPREFIX
, label
);
* included files get one or more of these:
* one as they are entered by a #include,
* and one every time they are returned to from nested #includes.
stabinclude(filename
, firsttime
)
* for separate compilation
check
= checksum(filename
);
putprintf(" .stabs \"%s\",0x%x,0,0x%x,0x%x", 0,
filename
, N_PC
, N_PSOL
, check
);
putprintf( " .stabs \"" , 1 );
putprintf( NAMEFORMAT
, 1 , filename
);
putprintf( "\",0x%x,0,0," , 1 , N_SOL
);
putprintf( PREFIXFORMAT
, 0 , LLABELPREFIX
, label
);
putprintf( PREFIXFORMAT
, 1 , LLABELPREFIX
, label
);
* anyone know a good checksum for ascii files?
* this does a rotate-left and then exclusive-or's in the character.
* also, it avoids returning checksums of 0.
* The rotate is implemented by shifting and adding back the
* sign bit when negative.
filep
= fopen(filename
, "r");
while ((input
= getc(filep
)) != EOF
) {
if ((unsigned) check
<= N_FLAGCHECKSUM
) {
return N_FLAGCHECKSUM
+ 1;
* global Pascal symbols :
* labels, types, constants, and external procedure and function names:
* These are used by the separate compilation facility
* to be able to check for disjoint header files.
stabglabel( label
, line
)
putprintf( " .stabs \"%s\",0x%x,0,0x%x,0x%x" , 0
, (int) label
, N_PC
, N_PGLABEL
, ABS( line
) );
stabgconst( const , line
)
putprintf( " .stabs \"%s\",0x%x,0,0x%x,0x%x" , 0
, (int) const , N_PC
, N_PGCONST
, ABS( line
) );
putprintf( " .stabs \"%s\",0x%x,0,0x%x,0x%x" , 0
, (int) type
, N_PC
, N_PGTYPE
, ABS( line
) );
* external functions and procedures
stabefunc( name
, typeclass
, line
)
if ( typeclass
== FUNC
) {
} else if ( typeclass
== PROC
) {
putprintf( " .stabs \"%s\",0x%x,0,0x%x,0x%x" , 0
, (int) name
, N_PC
, type
, ABS( line
) );