File:  [Power 6/32 Unix Tahoe 4.2BSD] / cci / usr / src / bin / cdb / initsym.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Sun Jul 28 12:24:19 2019 UTC (7 years ago) by root
Branches: bsd, MAIN
CVS tags: v12b, v121, HEAD
Power 6/32 Unix version 1.2b

static char sccsid[] = "@(#)initsym.c	2.5";

#include <sys/types.h>
#ifndef REGULUS
#include <sys/stat.h>
#include <core.h>
#else
#include <stat.h>
#endif

#ifndef BSD41
#define SYSTYPES 1	/* see basic.h */
#endif
#ifdef SUN
#define SYSTYPES 1	/* see basic.h */
#endif
#include "cdb.h"

#ifdef BSD41
#include <pagsiz.h>
#endif

export long	vmtimeSym;	/* last modification time of vsbSymfile */
export int	vmagicSym;	/* magic number of the Sym file */
export MAPR	vmapText;

typedef struct exec EXECR, *pEXECR;
#define cbEXECR sizeof(EXECR)

#define cbFileMax	1L<<24


/* C B L   F   F N */

export long CblFFn(fn)
int	fn;
{
	struct stat statbuf;

	fstat(fn, &statbuf);
	return(statbuf.st_size);
} /* CblFFn */


/* A G E   F   F N */

export long AgeFFn(fn)
int	fn;
{
	struct stat statbuf;

	fstat(fn, &statbuf);
	return(statbuf.st_mtime);
} /* AgeFFn */


/* I N I T   S Y M F I L E */

local void InitSymfile(sbFile)
char	*sbFile;
{
	long	cbData, cbText;
	EXECR	execSym;

/* printf("Opening file %s\n", sbFile); */
	vfnSym = open(sbFile, O_RDONLY);
	if (vfnSym < 0) {
		perror(sbFile);
		exit(1);
	} /* if */
	vmtimeSym = AgeFFn(vfnSym);
	vsbSymfile = sbFile;

	vmapText.fn = vfnSym;
	if (read(vfnSym, &execSym, cbEXECR) != cbEXECR)
		Panic("Cannot read header of %s", sbFile);
	if (FBadMagic(execSym))
		Panic("Bad Magic number in %s", sbFile);

	vmagicSym = execSym.a_magic;
#ifndef BSD41
	if (vmagicSym == magicReadOnly) {
		printf("WARNING: Instructions are READ ONLY!\n");
		printf("         This means you CANNOT set breakpoints!\n");
	} /* if */
#endif
	visymMax = execSym.a_syms / cbSYMR;
	cbData = execSym.a_data;
	cbText = execSym.a_text;

#ifndef REGULUS
	/* regulus does not do core dumps, so we will never look at symfile */

	vmapText.f1 = CbTextOffset(execSym);	/* standard offset */
	vmapText.b1 = 0;		/* section 1 always includes address 0 */
	vmapText.e1 = cbText;	/* section one is text */
	/* the sym file use section 1 ONLY! - data is in child or core file */
	vmapText.f2 = vmapText.b2 = vmapText.e2 = 0;
#ifdef SYSIII
	/* following is due to bug in ONYX C compiler */
	vcbSymFirst = cbText + cbData + CbTextOffset(execsym);
#endif
#ifdef BSD41
	vcbSymFirst = CbSymOffset(execSym);
	vcbSbFirst = CbStrOffset(execSym);
	vissMax = CblFFn(vfnSym) - vcbSbFirst;
	/* size of string space (is this right?) */
#endif
#endif
} /* InitSymfile */

unix.superglobalmegacorp.com

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