Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

stab.c File Reference

#include <string.h>
#include <stdlib.h>
#include "c.h"
#include "stab.h"

Include dependency graph for stab.c:

Include dependency graph

Go to the source code of this file.

Functions

void asgncode (Type, int)
void dbxout (Type)
int dbxtype (Type)
int emittype (Type, int, int)
void stabblock (int, int, Symbol *)
void stabend (Coordinate *, Symbol, Coordinate **, Symbol *, Symbol *)
void stabfend (Symbol, int)
void stabinit (char *, int, char *[])
void stabline (Coordinate *)
void stabsym (Symbol)
void stabtype (Symbol)

Variables

char * currentfile
int ntypes
Interface sparcIR
char * stabprefix = "L"


Function Documentation

void asgncode Type  ,
int 
[static]
 

Definition at line 29 of file stab.c.

References ARRAY, assert, CONST, dbxout(), ENUM, Field, fieldlist(), FLOAT, FUNCTION, INT, field::link, Xtype::marked, symbol::name, type::op, p, POINTER, STRUCT, type::sym, field::type, type::type, Type, Xtype::typeno, type::u, UNION, UNSIGNED, VOID, VOLATILE, and type::x.

Referenced by dbxtype().

00029                                        {
00030     if (ty->x.marked || ty->x.typeno)
00031         return;
00032     ty->x.marked = 1;
00033     switch (ty->op) {
00034     case VOLATILE: case CONST: case VOLATILE+CONST:
00035         asgncode(ty->type, lev);
00036         ty->x.typeno = ty->type->x.typeno;
00037         break;
00038     case POINTER: case FUNCTION: case ARRAY:
00039         asgncode(ty->type, lev + 1);
00040         /* fall thru */
00041     case VOID: case INT: case UNSIGNED: case FLOAT:
00042         break;
00043     case STRUCT: case UNION: {
00044         Field p;
00045         for (p = fieldlist(ty); p; p = p->link)
00046             asgncode(p->type, lev + 1);
00047         /* fall thru */
00048     case ENUM:
00049         if (ty->x.typeno == 0)
00050             ty->x.typeno = ++ntypes;
00051         if (lev > 0 && (*ty->u.sym->name < '0' || *ty->u.sym->name > '9'))
00052             dbxout(ty);
00053         break;
00054         }
00055     default:
00056         assert(0);
00057     }
00058 }

Here is the call graph for this function:

void dbxout Type   )  [static]
 

Definition at line 61 of file stab.c.

References col, emittype(), isarray, isenum, isfunc, isptr, isstruct, N_LSYM, symbol::name, print(), Xtype::printed, strlen(), type::sym, Type, type::u, unqual, and type::x.

Referenced by asgncode(), and dbxtype().

00061                             {
00062     ty = unqual(ty);
00063     if (!ty->x.printed) {
00064         int col = 0;
00065         print(".stabs \""), col += 8;
00066         if (ty->u.sym && !(isfunc(ty) || isarray(ty) || isptr(ty)))
00067             print("%s", ty->u.sym->name), col += strlen(ty->u.sym->name);
00068         print(":%c", isstruct(ty) || isenum(ty) ? 'T' : 't'), col += 2;
00069         emittype(ty, 0, col);
00070         print("\",%d,0,0,0\n", N_LSYM);
00071     }
00072 }

Here is the call graph for this function:

int dbxtype Type   )  [static]
 

Definition at line 75 of file stab.c.

References asgncode(), dbxout(), Type, Xtype::typeno, and type::x.

Referenced by stabinit(), stabsym(), and stabtype().

00075                             {
00076     asgncode(ty, 0);
00077     dbxout(ty);
00078     return ty->x.typeno;
00079 }

Here is the call graph for this function:

int emittype Type  ,
int  ,
int 
[static]
 

Definition at line 88 of file stab.c.

References ARRAY, assert, col, symbol::defined, ENUM, Field, fieldleft, fieldlist(), fieldright, fieldsize, FLOAT, FUNCTION, value::i, symbol::idlist, INT, IR, isconst, isvolatile, symbol::limits, field::link, interface::little_endian, field::lsb, symbol::max, symbol::min, N_LSYM, field::name, symbol::name, field::offset, type::op, p, POINTER, print(), Xtype::printed, type::size, strlen(), STRUCT, type::sym, Symbol, field::type, type::type, Type, Xtype::typeno, symbol::u, type::u, UNION, UNSIGNED, VOID, and type::x.

Referenced by dbxout().

00088                                                {
00089     int tc = ty->x.typeno;
00090 
00091     if (isconst(ty) || isvolatile(ty)) {
00092         col = emittype(ty->type, lev, col);
00093         ty->x.typeno = ty->type->x.typeno;
00094         ty->x.printed = 1;
00095         return col;
00096     }
00097     if (tc == 0) {
00098         ty->x.typeno = tc = ++ntypes;
00099 /*              fprint(2,"`%t'=%d\n", ty, tc); */
00100     }
00101     print("%d", tc), col += 3;
00102     if (ty->x.printed)
00103         return col;
00104     ty->x.printed = 1;
00105     switch (ty->op) {
00106     case VOID:  /* void is defined as itself */
00107         print("=%d", tc), col += 1+3;
00108         break;
00109     case INT:
00110         if (ty == chartype) /* plain char is a subrange of itself */
00111             print("=r%d;%d;%d;", tc, ty->u.sym->u.limits.min.i, ty->u.sym->u.limits.max.i),
00112                 col += 2+3+2*2.408*ty->size+2;
00113         else            /* other signed ints are subranges of int */
00114             print("=r1;%D;%D;", ty->u.sym->u.limits.min.i, ty->u.sym->u.limits.max.i),
00115                 col += 4+2*2.408*ty->size+2;
00116         break;
00117     case UNSIGNED:
00118         if (ty == chartype) /* plain char is a subrange of itself */
00119             print("=r%d;0;%u;", tc, ty->u.sym->u.limits.max.i),
00120                 col += 2+3+2+2.408*ty->size+1;
00121         else            /* other signed ints are subranges of int */
00122             print("=r1;0;%U;", ty->u.sym->u.limits.max.i),
00123                 col += 4+2.408*ty->size+1;
00124         break;
00125     case FLOAT: /* float, double, long double get sizes, not ranges */
00126         print("=r1;%d;0;", ty->size), col += 4+1+3;
00127         break;
00128     case POINTER:
00129         print("=*"), col += 2;
00130         col = emittype(ty->type, lev + 1, col);
00131         break;
00132     case FUNCTION:
00133         print("=f"), col += 2;
00134         col = emittype(ty->type, lev + 1, col);
00135         break;
00136     case ARRAY: /* array includes subscript as an int range */
00137         if (ty->size && ty->type->size)
00138             print("=ar1;0;%d;", ty->size/ty->type->size - 1), col += 7+3+1;
00139         else
00140             print("=ar1;0;-1;"), col += 10;
00141         col = emittype(ty->type, lev + 1, col);
00142         break;
00143     case STRUCT: case UNION: {
00144         Field p;
00145         if (!ty->u.sym->defined) {
00146             print("=x%c%s:", ty->op == STRUCT ? 's' : 'u', ty->u.sym->name);
00147             col += 2+1+strlen(ty->u.sym->name)+1;
00148             break;
00149         }
00150         if (lev > 0 && (*ty->u.sym->name < '0' || *ty->u.sym->name > '9')) {
00151             ty->x.printed = 0;
00152             break;
00153         }
00154         print("=%c%d", ty->op == STRUCT ? 's' : 'u', ty->size), col += 1+1+3;
00155         for (p = fieldlist(ty); p; p = p->link) {
00156             if (p->name)
00157                 print("%s:", p->name), col += strlen(p->name)+1;
00158             else
00159                 print(":"), col += 1;
00160             col = emittype(p->type, lev + 1, col);
00161             if (p->lsb)
00162                 print(",%d,%d;", 8*p->offset +
00163                     (IR->little_endian ? fieldright(p) : fieldleft(p)),
00164                     fieldsize(p));
00165             else
00166                 print(",%d,%d;", 8*p->offset, 8*p->type->size);
00167             col += 1+3+1+3+1;   /* accounts for ,%d,%d; */
00168             if (col >= 80 && p->link) {
00169                 print("\\\\\",%d,0,0,0\n.stabs \"", N_LSYM);
00170                 col = 8;
00171             }
00172         }
00173         print(";"), col += 1;
00174         break;
00175         }
00176     case ENUM: {
00177         Symbol *p;
00178         if (lev > 0 && (*ty->u.sym->name < '0' || *ty->u.sym->name > '9')) {
00179             ty->x.printed = 0;
00180             break;
00181         }
00182         print("=e"), col += 2;
00183         for (p = ty->u.sym->u.idlist; *p; p++) {
00184             print("%s:%d,", (*p)->name, (*p)->u.value), col += strlen((*p)->name)+3;
00185             if (col >= 80 && p[1]) {
00186                 print("\\\\\",%d,0,0,0\n.stabs \"", N_LSYM);
00187                 col = 8;
00188             }
00189         }
00190         print(";"), col += 1;
00191         break;
00192         }
00193     default:
00194         assert(0);
00195     }
00196     return col;
00197 }

Here is the call graph for this function:

void stabblock int  ,
int  ,
Symbol
 

Definition at line 200 of file stab.c.

References cfunc, genlabel(), IR, N_LBRAC, N_RBRAC, Xsymbol::name, p, print(), stabprefix, stabsym(), Symbol, and symbol::x.

Referenced by asdl_init().

00200                                               {
00201     if (brace == '{')
00202         while (*p)
00203             stabsym(*p++);
00204     if (IR == &sparcIR)
00205         print(".stabd 0x%x,0,%d\n", brace == '{' ? N_LBRAC : N_RBRAC, lev);
00206     else {
00207         int lab = genlabel(1);
00208         print(".stabn 0x%x,0,%d,%s%d-%s\n", brace == '{' ? N_LBRAC : N_RBRAC, lev,
00209             stabprefix, lab, cfunc->x.name);
00210         print("%s%d:\n", stabprefix, lab);
00211     }
00212 }

Here is the call graph for this function:

void stabend Coordinate ,
Symbol  ,
Coordinate **  ,
Symbol ,
Symbol
 

Definition at line 326 of file stab.c.

References Coordinate, IR, N_SO, print(), interface::segment, stabprefix, and Symbol.

Referenced by asdl_init().

00326                                                                                    {
00327     (*IR->segment)(CODE);
00328     print(".stabs \"\", %d, 0, 0,%setext\n", N_SO, stabprefix);
00329     print("%setext:\n", stabprefix);
00330 }

Here is the call graph for this function:

void stabfend Symbol  ,
int 
 

Definition at line 323 of file stab.c.

References Symbol.

Referenced by asdl_init().

00323 {}

void stabinit char *  ,
int  ,
char *  []
 

Definition at line 215 of file stab.c.

References chartype, currentfile, dbxtype(), doubletype, file, floattype, foreach(), GLOBAL, inttype, IR, longdouble, longlong, longtype, N_OPT, N_SO, NULL, print(), interface::segment, shorttype, signedchar, size_t, stabprefix, stabtype(), Symbol, types, unsignedchar, unsignedlong, unsignedlonglong, unsignedshort, unsignedtype, void(), and voidtype.

Referenced by asdl_init().

00215                                                   {
00216     typedef void (*Closure)(Symbol, void *);
00217     extern char *getcwd(char *, size_t);
00218 
00219     print(".stabs \"lcc4_compiled.\",0x%x,0,0,0\n", N_OPT);
00220     if (file && *file) {
00221         char buf[1024], *cwd = getcwd(buf, sizeof buf);
00222         if (cwd)
00223             print(".stabs \"%s/\",0x%x,0,3,%stext0\n", cwd, N_SO, stabprefix);
00224         print(".stabs \"%s\",0x%x,0,3,%stext0\n", file, N_SO, stabprefix);
00225         (*IR->segment)(CODE);
00226         print("%stext0:\n", stabprefix, N_SO);
00227         currentfile = file;
00228     }
00229     dbxtype(inttype);
00230     dbxtype(chartype);
00231     dbxtype(doubletype);
00232     dbxtype(floattype);
00233     dbxtype(longdouble);
00234     dbxtype(longtype);
00235     dbxtype(longlong);
00236     dbxtype(shorttype);
00237     dbxtype(signedchar);
00238     dbxtype(unsignedchar);
00239     dbxtype(unsignedlong);
00240     dbxtype(unsignedlonglong);
00241     dbxtype(unsignedshort);
00242     dbxtype(unsignedtype);
00243     dbxtype(voidtype);
00244     foreach(types, GLOBAL, (Closure)stabtype, NULL);
00245 }

Here is the call graph for this function:

void stabline Coordinate  ) 
 

Definition at line 248 of file stab.c.

References cfunc, Coordinate, cp, currentfile, coord::file, genlabel(), IR, N_SLINE, N_SOL, Xsymbol::name, print(), stabprefix, symbol::x, and coord::y.

Referenced by asdl_init().

00248                               {
00249     if (cp->file && cp->file != currentfile) {
00250         int lab = genlabel(1);
00251         print(".stabs \"%s\",0x%x,0,0,%s%d\n", cp->file, N_SOL, stabprefix, lab);
00252         print("%s%d:\n", stabprefix, lab);
00253         currentfile = cp->file;
00254     }
00255     if (IR == &sparcIR)
00256         print(".stabd 0x%x,0,%d\n", N_SLINE, cp->y);
00257     else {
00258         int lab = genlabel(1);
00259         print(".stabn 0x%x,0,%d,%s%d-%s\n", N_SLINE, cp->y,
00260             stabprefix, lab, cfunc->x.name);
00261         print("%s%d:\n", stabprefix, lab);
00262     }
00263 }

Here is the call graph for this function:

void stabsym Symbol   ) 
 

Definition at line 266 of file stab.c.

References assert, BSS, code, symbol::computed, dbxtype(), EXTERN, freturn(), symbol::generated, GLOBAL, IR, isfunc, isptr, isstruct, N_FUN, N_LCSYM, N_RSYM, N_STSYM, Xsymbol::name, symbol::name, Regnode::number, p, PARAM, print(), r, Xsymbol::regnode, symbol::sclass, symbol::scope, symbol::seg, Regnode::set, type::size, symbol::structarg, Symbol, type::type, symbol::type, symbol::u, interface::wants_argb, and symbol::x.

Referenced by asdl_init(), and stabblock().

00266                        {
00267     int code, tc, sz = p->type->size;
00268 
00269     if (p->generated || p->computed)
00270         return;
00271     if (isfunc(p->type)) {
00272         print(".stabs \"%s:%c%d\",%d,0,0,%s\n", p->name,
00273             p->sclass == STATIC ? 'f' : 'F', dbxtype(freturn(p->type)),
00274             N_FUN, p->x.name);
00275         return;
00276     }
00277     if (!IR->wants_argb && p->scope == PARAM && p->structarg) {
00278         assert(isptr(p->type) && isstruct(p->type->type));
00279         tc = dbxtype(p->type->type);
00280         sz = p->type->type->size;
00281     } else
00282         tc = dbxtype(p->type);
00283     if (p->sclass == AUTO && p->scope == GLOBAL || p->sclass == EXTERN) {
00284         print(".stabs \"%s:G", p->name);
00285         code = N_GSYM;
00286     } else if (p->sclass == STATIC) {
00287         print(".stabs \"%s:%c%d\",%d,0,0,%s\n", p->name, p->scope == GLOBAL ? 'S' : 'V',
00288             tc, p->u.seg == BSS ? N_LCSYM : N_STSYM, p->x.name);
00289         return;
00290     } else if (p->sclass == REGISTER) {
00291         if (p->x.regnode) {
00292             int r = p->x.regnode->number;
00293             if (p->x.regnode->set == FREG)
00294                 r += 32;    /* floating point */
00295                 print(".stabs \"%s:%c%d\",%d,0,", p->name,
00296                     p->scope == PARAM ? 'P' : 'r', tc, N_RSYM);
00297             print("%d,%d\n", sz, r);
00298         }
00299         return;
00300     } else if (p->scope == PARAM) {
00301         print(".stabs \"%s:p", p->name);
00302         code = N_PSYM;
00303     } else if (p->scope >= LOCAL) {
00304         print(".stabs \"%s:", p->name);
00305         code = N_LSYM;
00306     } else
00307         assert(0);
00308     print("%d\",%d,0,0,%s\n", tc, code,
00309         p->scope >= PARAM && p->sclass != EXTERN ? p->x.name : "0");
00310 }

Here is the call graph for this function:

void stabtype Symbol   ) 
 

Definition at line 313 of file stab.c.

References dbxtype(), N_LSYM, symbol::name, p, print(), symbol::sclass, Symbol, and symbol::type.

Referenced by asdl_init(), and stabinit().

00313                         {
00314     if (p->type) {
00315         if (p->sclass == 0)
00316             dbxtype(p->type);
00317         else if (p->sclass == TYPEDEF)
00318             print(".stabs \"%s:t%d\",%d,0,0,0\n", p->name, dbxtype(p->type), N_LSYM);
00319     }
00320 }

Here is the call graph for this function:


Variable Documentation

char* currentfile [static]
 

Definition at line 7 of file stab.c.

Referenced by stabinit(), and stabline().

int ntypes [static]
 

Definition at line 8 of file stab.c.

Interface sparcIR
 

char * stabprefix = "L"
 

Definition at line 12 of file stab.c.

Referenced by stabblock(), stabend(), stabinit(), and stabline().


Generated on Thu Aug 25 15:55:31 2005 for Quake III Arena by  doxygen 1.3.9.1