Commits

RomanGol committed 8cc875d

DIAOS parser 0.03

remove redundant variable

  • Participants
  • Parent commits dad0bc2

Comments (0)

Files changed (3)

File parser/Readtrace.cpp

 	fprintf( fpw, "method : %s\n", lo.methodName);
 	//fprintf( fpw, "logcontent:%s\n", lo.logcontent);
 
-	for( size_t i = 0; i < 16; i++ )
+	fprintf( fpw, "Reg\n" );
+	for( size_t i = 0; i < RegMaxNum; i++ )
 	{
-		fprintf( fpw, "Reg[%lu] = [%04x],",i,lo.reg[i]);
+		fprintf( fpw, "%08x\t", lo.reg[i] );
 	}
 
 	fprintf( fpw, "\n" );
 
+
 	// using handler function to deal with opcode's details
 	uint16_t inst = lo.inst[0];
 	Handler deal_opcode = (Handler) opcodeHandlers[inst & 0xff];

File parser/method.cpp

 
 #define PRINT_REG void()
 
-u4 getReg(const Loccs_opcode lo, u2 offset){
-	u4 ret;
-	if(offset > 16){
+u4 getReg(const Loccs_opcode lo, u2 offset) {
+	u4 ret = 0;
+	if ( offset > 16 ) {
 		ret = 0xFFFFFFFF;
 		printf("reg overflow\n");
 		printf("pc = %08x\n", lo.pc);
 		printf("class : %s\n",lo.methodDescriptor);
 		printf("method : %s\n",lo.methodName);
 	}
-	else ret = lo.reg[offset];
+	else
+		ret = lo.reg[offset];
+	
 	return ret;
 }
 
 	fprintf(fpw, "inst = %04x\n",lo.inst[0]);
 	fprintf(fpw,"Inst_Parse:|invoke-static/jumbo args=%d @0x%08x {regs=v%d-v%d}", vsrc1, ref, vdst, vdst+vsrc1-1);
 }
+
 void ldvm_OP_INVOKE_INTERFACE_JUMBO(const Loccs_opcode lo, FILE* fpw){
 	u4 ref;
 	u2 vsrc1, vsrc2, vdst;

File parser/trace.h

 #ifndef _TRACE_H_
 #define _TRACE_H_
 
-#include <stdint.h>
+#include <cstdint>
 #include <cstdio>
 #include <iostream>
 #include <iomanip>
 typedef int64_t s8;
 
 
-const static uint32_t InstNum = 5;//shujunliang
-const static uint32_t LogContentLen = 128;
-const static uint32_t RegNum = 16;
-const static uint32_t MethDescLen = 128;
-const static uint32_t MethNameLen = 64;
-const static uint32_t ClassListLen = 8;
-const static uint32_t FileNameLen = 64;
-const static uint32_t BufSize=16;
-
-const static uint32_t instNumInLo = 5; // add according to shujunliang
-const static uint32_t logContentLen = 128;
-const static uint32_t regNum = 16;
-const static uint32_t methDescLen = 128;
-const static uint32_t methNameLen = 64;
-const static uint32_t classListLen = 8;
-const static uint32_t fileNameLen = 64;
-const static uint32_t Buf_size=16;
-
-
-					  
-const static uint32_t ProcessNameLen = 128;
-const static uint32_t ProcessFileNameLen = 64;
-const static uint32_t ProcessListLen = 8;
+const static uint32_t InstMaxNum = 5; // add by shujunliang
+const static uint32_t RegMaxNum = 16;
+const static uint32_t ClassNameMaxLen = 128;
+const static uint32_t MethodNameMaxLen = 64;
+const static uint32_t LogContentMaxLen = 256;
 
 struct Loccs_opcode
 {
-	uint32_t threadId;
-	uint32_t pc;
-	uint16_t inst[InstNum];
-	uint32_t reg[RegNum];
-	unsigned char methodDescriptor[MethDescLen];
-	unsigned char methodName[MethNameLen];
-	//char logcontent[LogContentLen];
+	uint32_t threadId; // 4 bytes
+	uint32_t pc; // 4 bytes
+	uint16_t inst[InstMaxNum]; // may be this should be 2 * 4 or 2 * 8 bytes
+	uint32_t reg[RegMaxNum]; // 64 bytes
+	char methodDescriptor[ClassNameMaxLen]; // 128 bytes
+	char methodName[MethodNameMaxLen]; // 64 bytes
 };
 
 //����Ϊ�ݶ��Ľ���������ݽṹ����δͶ��ʹ��
 	int32_t category;//����
 	uint16_t length;//����,1~5	 
 	uint16_t inst[5];
-	unsigned char method_name[MethNameLen];
-	unsigned char class_name[MethDescLen];
+	unsigned char method_name[MethodNameMaxLen];
+	unsigned char class_name[ClassNameMaxLen];
 };
 
 struct Argtype
 };
 struct Opcode_parsed{
 	uint32_t pc;
-	char description[LogContentLen];
+	char description[LogContentMaxLen];
 	Instrtype Instruction;
 	Argtype vdst;
 	Argtype vscr1;