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

📄 instrmnt.c

📁 这是一个C程序分析工具
💻 C
📖 第 1 页 / 共 2 页
字号:
	CALLS   : GetChar
             FindEndParen
                                                                           
   USED BY : InstrumentConditionals                                        
                                                                           
   HISTORY :                                                               
   VER   DATE         AUTHOR    DESCRIPTION                                
   1.00   6 Feb 93 L. McCallie  Created file.                              
   2.00  25 Feb 97 R. Jones     replaced file index with R2srcfile_ptr
  -------------------------------------------------------------------*/
void InstrumentFor(void)
   {
   char ch;
   char conditional = '\0';

   do {
      ch = GetChar();
      }while (';' != ch);
   fputc('(', gInstFILE);
	/* Examine the conditional phrase */
   vb_print(DEBUG_LEVEL,"%s","\t\t\tConditional = ");
   while (';' != gHoldChar)
        {
      ch = GetChar();
      /* test for printable characters (ignore spaces) */
		if(isgraph(ch))
         {
         conditional = ch;
         vb_print(DEBUG_LEVEL,"%c",conditional);
         }
      }
   vb_print(DEBUG_LEVEL,"%c",'\n');
   /* If empty conditional */
   if(!conditional)
      /* force the condition to TRUE */
      fputc('1', gInstFILE);
   fprintf(gInstFILE, ")?R2True(R2srcfile_ptr,%d): R2False(R2srcfile_ptr,%d)",
      gLineNumber, gLineNumber);
	FindEndParen();
	}

/*===================================================================
	FUNCTION: InstrumentSwitch
  ===================================================================
	PURPOSE : Instruments switch statements.

	CALLS   : GetChar

	USED BY : InstrumentConditionals

	HISTORY :
	VER   DATE         AUTHOR    DESCRIPTION
	1.00   6 Feb 93 L. McCallie  Created file.
	1.10  28 Feb 93 L. McCallie  Corrected multiple paren problem.
        2.00  25 Feb 97 R. Jones     replaced file index with R2srcfile_ptr
  -------------------------------------------------------------------*/
void InstrumentSwitch(void)
	{
	int ParenState = 1;

	fputs("R2Switch(", gInstFILE);
        fprintf(gInstFILE, "R2srcfile_ptr,%d,", gLineNumber);
	while (0 != ParenState)
		{
		if (')' == gHoldChar)
			{
			ParenState--;
			}
		if ('(' == gHoldChar)
			{
			ParenState++;
			}
		if (0 != ParenState)
			GetChar();
      }
   fprintf(gInstFILE, ")", gLineNumber);
   }

/*===================================================================
   FUNCTION: ConditionalType                                               
  ===================================================================
   PURPOSE : Returns an integer identifying a conditional statement.       
                                                                           
   CALLS   : None                                                          
                                                                           
   USED BY : InstrumentConditionals                                        
                                                                           
   HISTORY :                                                               
   VER   DATE         AUTHOR    DESCRIPTION                                
   1.00   6 Feb 93 L. McCallie  Created file.                              
  -------------------------------------------------------------------*/
int ConditionalType(char *Statement)
   {
	int i=-1;
   struct {
      char *mnemonic;
      short type;
      } static statement[] = {
         {"if",IFCONDITIONAL},
         {"while",WHILECONDITIONAL},
         {"for",FORCONDITIONAL},
         {"switch",SWITCHCONDITIONAL},
         {NULL,0}
         };

   while(statement[++i].mnemonic)
      if (!strcmp(statement[i].mnemonic, Statement))
         break;
   return(statement[i].type);
   }
/*===================================================================
   FUNCTION: StatementType                                                 
  ===================================================================
   PURPOSE : Returns an integer depending on the statement type.           
                                                                           
   CALLS   : None                                                          
                                                                           
	USED BY : InstrumentStatements
                                                                           
   HISTORY :                                                               
   VER   DATE         AUTHOR    DESCRIPTION                                
   1.00   6 Feb 93 L. McCallie  Created file.                              
  -------------------------------------------------------------------*/
int StatementType(char *Statement)
   {
   int i=-1;
   static struct {
      char *mnemonic;
      short type;
      } statement[] = {
         {"return",   RETURNSTATEMENT},
         {"exit",      EXITSTATEMENT},
         {"if",      CONDITIONALSTATEMENT},
         {"for",      CONDITIONALSTATEMENT},
         {"while",   CONDITIONALSTATEMENT},
         {"switch",   CONDITIONALSTATEMENT},
         {NULL,0}
         };

   while(statement[++i].mnemonic)
      if (!strcmp(statement[i].mnemonic, Statement))
			break;
   return(statement[i].type);
   }
/*===================================================================
   FUNCTION: InstrumentEntryPoint                                     
  ===================================================================
   PURPOSE : Instruments entry points in functions.                                
                                                                           
   CALLS   : None                                                  
                                                                           
   USED BY : ParseFunction                                          
                                                                           
   HISTORY :                                                               
   VER   DATE         AUTHOR    DESCRIPTION                                
   1.00   9 Mar 99 D. Fralish   Created file.                              
  -------------------------------------------------------------------*/
void InstrumentEntryPoint()
   {
	int tmpLineNumber = 0;
	tmpLineNumber = gLineNumber;
	fprintf(gInstFILE,
		"int R2InstrumentEntryPointFlag = R2Entry(R2srcfile_ptr,%d);",
		tmpLineNumber);
   }
/*===================================================================
   FUNCTION: SetEntryPointFlag                                                 
  ===================================================================
   PURPOSE : Sets the status of the entry point flag.           
                                                                           
   CALLS   : None                                                          
                                                                           
	USED BY : r2inst
                                                                           
   HISTORY :                                                               
   VER   DATE         AUTHOR    DESCRIPTION                                
   1.00   9 Mar 99 D. Fralish   Created file.                              
  -------------------------------------------------------------------*/
void SetEntryPointFlag(int state)
{
	InstrumentEntryPointFlag = state;
}
/*===================================================================
   FUNCTION: GetEntryPointFlag                                                 
  ===================================================================
   PURPOSE : Returns the status of the entry point flag.           
                                                                           
   CALLS   : None                                                          
                                                                           
	USED BY : GetFunction
                                                                           
   HISTORY :                                                               
   VER   DATE         AUTHOR    DESCRIPTION                                
   1.00   9 Mar 99 D. Fralish   Created file.                              
  -------------------------------------------------------------------*/
int GetEntryPointFlag(void)
{
	return(InstrumentEntryPointFlag);
}

⌨️ 快捷键说明

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