Annotation of cci/usr/src/bin/cdb/initsym.c, revision 1.1.1.1

1.1       root        1: static char sccsid[] = "@(#)initsym.c  2.5";
                      2: 
                      3: #include <sys/types.h>
                      4: #ifndef REGULUS
                      5: #include <sys/stat.h>
                      6: #include <core.h>
                      7: #else
                      8: #include <stat.h>
                      9: #endif
                     10: 
                     11: #ifndef BSD41
                     12: #define SYSTYPES 1     /* see basic.h */
                     13: #endif
                     14: #ifdef SUN
                     15: #define SYSTYPES 1     /* see basic.h */
                     16: #endif
                     17: #include "cdb.h"
                     18: 
                     19: #ifdef BSD41
                     20: #include <pagsiz.h>
                     21: #endif
                     22: 
                     23: export long    vmtimeSym;      /* last modification time of vsbSymfile */
                     24: export int     vmagicSym;      /* magic number of the Sym file */
                     25: export MAPR    vmapText;
                     26: 
                     27: typedef struct exec EXECR, *pEXECR;
                     28: #define cbEXECR sizeof(EXECR)
                     29: 
                     30: #define cbFileMax      1L<<24
                     31: 
                     32: 
                     33: /* C B L   F   F N */
                     34: 
                     35: export long CblFFn(fn)
                     36: int    fn;
                     37: {
                     38:        struct stat statbuf;
                     39: 
                     40:        fstat(fn, &statbuf);
                     41:        return(statbuf.st_size);
                     42: } /* CblFFn */
                     43: 
                     44: 
                     45: /* A G E   F   F N */
                     46: 
                     47: export long AgeFFn(fn)
                     48: int    fn;
                     49: {
                     50:        struct stat statbuf;
                     51: 
                     52:        fstat(fn, &statbuf);
                     53:        return(statbuf.st_mtime);
                     54: } /* AgeFFn */
                     55: 
                     56: 
                     57: /* I N I T   S Y M F I L E */
                     58: 
                     59: local void InitSymfile(sbFile)
                     60: char   *sbFile;
                     61: {
                     62:        long    cbData, cbText;
                     63:        EXECR   execSym;
                     64: 
                     65: /* printf("Opening file %s\n", sbFile); */
                     66:        vfnSym = open(sbFile, O_RDONLY);
                     67:        if (vfnSym < 0) {
                     68:                perror(sbFile);
                     69:                exit(1);
                     70:        } /* if */
                     71:        vmtimeSym = AgeFFn(vfnSym);
                     72:        vsbSymfile = sbFile;
                     73: 
                     74:        vmapText.fn = vfnSym;
                     75:        if (read(vfnSym, &execSym, cbEXECR) != cbEXECR)
                     76:                Panic("Cannot read header of %s", sbFile);
                     77:        if (FBadMagic(execSym))
                     78:                Panic("Bad Magic number in %s", sbFile);
                     79: 
                     80:        vmagicSym = execSym.a_magic;
                     81: #ifndef BSD41
                     82:        if (vmagicSym == magicReadOnly) {
                     83:                printf("WARNING: Instructions are READ ONLY!\n");
                     84:                printf("         This means you CANNOT set breakpoints!\n");
                     85:        } /* if */
                     86: #endif
                     87:        visymMax = execSym.a_syms / cbSYMR;
                     88:        cbData = execSym.a_data;
                     89:        cbText = execSym.a_text;
                     90: 
                     91: #ifndef REGULUS
                     92:        /* regulus does not do core dumps, so we will never look at symfile */
                     93: 
                     94:        vmapText.f1 = CbTextOffset(execSym);    /* standard offset */
                     95:        vmapText.b1 = 0;                /* section 1 always includes address 0 */
                     96:        vmapText.e1 = cbText;   /* section one is text */
                     97:        /* the sym file use section 1 ONLY! - data is in child or core file */
                     98:        vmapText.f2 = vmapText.b2 = vmapText.e2 = 0;
                     99: #ifdef SYSIII
                    100:        /* following is due to bug in ONYX C compiler */
                    101:        vcbSymFirst = cbText + cbData + CbTextOffset(execsym);
                    102: #endif
                    103: #ifdef BSD41
                    104:        vcbSymFirst = CbSymOffset(execSym);
                    105:        vcbSbFirst = CbStrOffset(execSym);
                    106:        vissMax = CblFFn(vfnSym) - vcbSbFirst;
                    107:        /* size of string space (is this right?) */
                    108: #endif
                    109: #endif
                    110: } /* InitSymfile */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.