symfile.h 4.25 KB
/*
 * Copyright (C) 1996-1998 by the Board of Trustees
 *    of Leland Stanford Junior University.
 * 
 * This file is part of the SimOS distribution. 
 * See LICENSE file for terms of the license. 
 *
 */


/*
 *  This module hides the layout of the symbol table from the user.
 *
 *  Also, for SimOS address space reasons, the data for the symbol stuff
 *  is in another process. This file hides all that too.
 *
 *  Since symfile hides all the symbol table layout and the rpc stuff
 *  don't expect the code to be pretty, its not.
 */

#ifndef _SYMFILE_H_
#define _SYMFILE_H_

#include "sym-sgi.h"

struct Execfile;


/*
 *   flags for symbol routines
 */

#define SYM_TAGS       1   /* for symlookup and symfind
                             * default is variable namespace
                             */

#define SYM_RESOLVE    2   /* for symtype, symsubtype
                             * resolve all typedefs
                             */

#define SYM_RECURSE    4   /* in symlookup, look into procs */

/*
 *   symbol types
 */

#define    tNil          0
#define    tChar         1
#define    tUChar        2
#define    tShort        3
#define    tUShort       4
#define    tInt          5
#define    tUInt         6
#define    tLong         7
#define    tULong        8
#define    tFloat        9
#define    tDouble      10
#define    tStruct      11
#define    tUnion       12
#define    tEnum        13
#define    tTypedef     14
#define    tPtr         15
#define    tArray       16
#define    tLabel       17
#define    tProc        18
#define    tStructDef   19
#define    tUnionDef    20
#define    tEnumDef     21
#define    tAddr        22
#define    tFile        23
#define    tEnd         24
#define    tBlock       25
#define    tTypedefDef  26
#define    tIndirect    27


/*
 *   opaque symb object 
 */

#define MAX_TYPES     8

typedef struct Symb {
   int      type[MAX_TYPES];
   int      nextt;
   Reg      value;
   char     *name;
   char     global;
   int      isym;
   int      filenum;
   int      index;
   RNDXR    rndx;
   int      fip;
   struct Execfile *exec;
} Symb; 

#define DWARF_INDEX 0x8f8f8f8f		/* marks sym as dwarf sym */


typedef struct SymbInfo {
   char hier;     /* can use SymIn and SymFind */
   char basic;    /* do not have subtypes */
   char vartype;  /* can be subtypes of tProc, tTypedef, tPtr, tArray */
   char mass;     /* value is an address in the object file */
} SymbInfo;

extern SymbInfo *SymInfo;


/*
 *   loading symbol tables
 */

int SymLoad(char *pathname, char *execname);


/*
 *   lookup address
 */

int SymAddr2Symbol(char *execname, int addr, Symb *sym);


/*
 *   line nuber stuff
 *
 *      SymLine2Addr to be added.
 */

int SymLine2Addr(char *execname, char *srcfile, int line, Symb *sym);


/*
 *   symbol type info
 */

#define SymIsHier(_sym) (SymInfo[(_sym)->type[(_sym)->nextt]].hier)

#define SymIsBasicType(_sym) (SymInfo[(_sym)->type[(_sym)->nextt]].basic)

#define SymIsVarType(_sym) (SymInfo[(_sym)->type[(_sym)->nextt]].vartype)

#define SymIsMassive(_sym) (SymInfo[(_sym)->type[(_sym)->nextt]].mass)


/*
 *   symbol table navigation
 */

int SymLookup(char *execname, char *srcfile, char *symname, int flags, Symb *sym);

int SymFind(Symb *sym, char *name, int flags);

int SymNext(Symb *sym);

int SymIn(Symb *sym);

int SymSubtype(Symb *sym, int flags);


/*
 *   symbol info
 */

int SymType(Symb *sym, int flags);

#define SymValue(_sym) ((_sym)->value)

#define SymName(_sym) ((_sym)->name)

Reg_s SymSize(Symb *sym);


/*
 *   symbol type manipulation
 */

int SymTypeCast(char *execname, char *srcfile, int *types, char *name, Symb *sym);

int SymMakeAddr(Symb *sym);

#ifdef DWARF2
int Dwarf_SymLoad(char *pathname, char *execname);
int Dwarf_SymAddr2Symbol(char *execname, int addr, Symb *sym);
int Dwarf_SymLine2Addr(char *execname, char *srcfile, int line, Symb *sym);
int Dwarf_SymLookup(char *execname, char *srcfile, char *symname, int flags, Symb *sym);
int Dwarf_SymFind(Symb *sym, char *name, int flags);
int Dwarf_SymNext(Symb *sym);
int Dwarf_SymIn(Symb *sym);
int Dwarf_SymSubtype(Symb *sym, int flags);
int Dwarf_SymType(Symb *sym, int flags);
Reg64 Dwarf_SymSize(Symb *sym);
int Dwarf_SymTypeCast(char *execname, char *srcfile, int *types, char *name, Symb *sym);
int Dwarf_SymMakeAddr(Symb *sym);
#endif /* DWARF2 */

#endif