⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dbgdata.h

📁 < 虚拟机设计与实现> 的source code, linux版本
💻 H
字号:
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+                                                                   +
+ dbgdata   reads executable, populates debug data structures       +
+                                                                   +
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
#ifndef _DBGDATA_H
#define _DBGDATA_H

#include "init.h"
#include "common.h"

#ifdef OS_WIN
#include "win32.h"
#else
#include "linux.h"
#endif

#define SIZE_GLOBREC	37		/* byte size of global record */
#define SIZE_PROCREC	25		/* byte size of procedure record */
#define SIZE_RETREC		16		/* byte size of return value record */
#define SIZE_ARGREC		16		/* byte size of argument record */
#define SIZE_LOCREC		16		/* byte size of local variable record */
#define SIZE_LBLREC		20		/* byte size of label record */

#define MAX_RECSIZE		SIZE_GLOBREC

#define	SZ_BYTE		1	/*used to indicate GlobVar type*/
#define SZ_WORD		2
#define SZ_DWORD	4
#define SZ_QWORD	8

struct Contents
{
	U4 nGlobVarRec;		/*number of global variable records in symbol table*/
	U4 nProcRec;		/*number of procedure records in symbol table*/
};

struct GlobVarRec
{
	U8 text;		/*index into StrTbl of where identifier begins*/
	U1 dType;		/* SZ_BYTE, SZ_WORD, SZ_DWORD, SZ_QWORD */
	U8 len;			/* # elements if array */
	U8 size;		/* total byte size */
	S8 offset;      /* offset below $TOP, address(g) = $TOP - offset*/
	U4 line;		/* source code line containing declaration */
};

struct StackFrameRec
{
	U8 text;		/* index into StrTbl of where identifier begins */
	S4 fpOffset;	/* +n or -n from $FP */
	U4 line;		/* source code line containing declaration */
};

struct LabelRec
{
	U8 text;		/* index into StrTbl of where identifier begins */
	U8 address;		/* address of label*/
	U4 line;		/* source code line containing declaration */
};

struct ProcRec
{
	U8 text;		/* index into StrTbl of where identifier begins */
	U8 address;		/* address of procedure */
	U4 line;		/* source code line containing declaration */
	struct StackFrameRec ret;
	U1 nRet;		/* 0 = void return, 1 = returns a value*/
	struct StackFrameRec *arg;
	U1 nArg;
	struct StackFrameRec *local;
	U1 nLocal;
	struct LabelRec *label;
	U2 nLabel;
};

struct DebugData
{
	struct Contents contents;
	struct GlobVarRec * gvRec;
	struct ProcRec * pRec;
	U1 * strTbl;
};

extern U1 debug;
extern struct DebugData debugData;
extern char * globSz[];

void DebugData_init();
void DebugData_free();
void populateDebugData(struct HeaderRec hr, struct DebugData * ptr, FILE *fptr);
void printDebugData(struct DebugData *ptr);

#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -