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

📄 r2protos.c

📁 这是一个C程序分析工具
💻 C
📖 第 1 页 / 共 5 页
字号:
/* Check if the global current trace exists.  If not, create one and       */
/* open the corresponding trace file.                                      */
/*-------------------------------------------------------------------------*/
  if( gCurrentTrace == NULL )
  {
      gCurrentTrace = (R2TRACE *) malloc(sizeof(R2TRACE));
#ifdef MESSAGE_Q
      gCurrentTrace = r2OpenDefaultMessageQ();
#else
      gCurrentTrace = r2OpenDefaultFile();
#endif
  }

/*-------------------------------------------------------------------------*/
/*  If tracing is suspended, return.                                       */
/*-------------------------------------------------------------------------*/
  if(R2SUSPENDED == gCurrentTrace->r2status)
     return 1;

/*-------------------------------------------------------------------------*/
/*  Check the input.                                                       */
/*-------------------------------------------------------------------------*/
  ValidateInput(R2srcfile_ptr, line, 1);

/*-------------------------------------------------------------------------*/
/*  Call the lower case function to actually write/save the trace info     */
/*-------------------------------------------------------------------------*/
  return r2true(gCurrentTrace, R2srcfile_ptr, line);
}

int r2true(R2TRACE_PTR theTrace, char *R2srcfile_ptr, int line)
{
char TraceData[MAX_CHARS];
int err, index;

   switch (theTrace->r2status) {
/*-------------------------------------------------------------------------*/
/*  If the trace is open, either set the correspondig bit (MIN_TRACE) or   */
/*  write the line to the trace file.                                      */
/*-------------------------------------------------------------------------*/
      case R2OPEN:
#ifdef MIN_TRACE
            index = R2PathToIndex(R2srcfile_ptr);
            gCurrentTrace->TrueList = 
                        TFListBitSet(theTrace->TrueList, index, line,
                                              &(theTrace->TrueListEntries));
#else
            sprintf(TraceData, "T %d %d %s\n", line, strlen(R2srcfile_ptr),
                                               R2srcfile_ptr);
            err = WriteTrace(TraceData);
            if (err == FILE_ERR)
            R2Err(R2srcfile_ptr, line, "Error writing trace file.");
            if (err == QUEUE_ERR)
               R2Err(R2srcfile_ptr, line, "Error writing to message buffer");
#endif
         break;

/*-------------------------------------------------------------------------*/
/*  If the trace is suspended, return without writing or saving anything   */
/*-------------------------------------------------------------------------*/
      case R2SUSPENDED:
         break;

/*-------------------------------------------------------------------------*/
/*  If the trace is closed, issue an error message.                        */
/*-------------------------------------------------------------------------*/
      case R2CLOSED:
         R2Err(R2srcfile_ptr,line, "Attempt to write to a closed trace");
         break;
   }
   return 1;
}

/*=========================================================================*/
/* FUNCTION: R2False                                                       */
/*=========================================================================*/
/* PURPOSE : If MIN_TRACE is not defined, writes the 'F' character, line   */
/*           number, number of characters in the source file name, and     */
/*           the source file name to the trace file.  If MIN_TRACE is      */
/*           defined, R2False sets the bit in TrueList corresponding to    */
/*           the file index and line number.                               */
/*                                                                         */
/*           Function is entered when an instrumented 'if', 'for', or      */
/*           'while' statement is encountered.  Example statements are as  */
/*           follows:                                                      */
/*                    Before:                                              */
/*                       if (exp)                                          */
/*                       for (exp;exp;exp)                                 */
/*                       while (exp)                                       */
/*                    After:                                               */
/*                       if ((exp)?R2True:R2False)                         */
/*                       for (exp;(exp)?R2True:R2False;exp)                */
/*                       while ((exp)?R2True:R2False)                      */
/*                                                                         */
/* SYSTEM  : RECON II                                                      */
/*                                                                         */
/* CALLS   : R2OpenDefaultFile, R2OpenDefaultMessageQ, ValidateInput,      */
/*           TFListBitSet, R2Err                                          */
/*                                                                         */
/* USED BY : Instrumented user source code                                 */
/*                                                                         */
/* HISTORY :                                                               */
/* VER   DATE         AUTHOR    DESCRIPTION                                */
/* 1.00   6 Feb 93 L. McCallie  Create file.                               */
/* 2.00  23 Mar 97 J. Ward      Modify per Tisk 17 to write file name ILO  */
/*                              file index.                                */
/*-------------------------------------------------------------------------*/
int R2False(char * R2srcfile_ptr, int line)
{

/*-------------------------------------------------------------------------*/
/* Check if the global current trace exists.  If not, create one and       */
/* open the corresponding trace file.                                      */
/*-------------------------------------------------------------------------*/
  if( gCurrentTrace == NULL )
  {
      gCurrentTrace = (R2TRACE *) malloc(sizeof(R2TRACE));
#ifdef MESSAGE_Q
      gCurrentTrace = r2OpenDefaultMessageQ();
#else
      gCurrentTrace = r2OpenDefaultFile();
#endif
  }

/*-------------------------------------------------------------------------*/
/*  If tracing is suspended, return.                                       */
/*-------------------------------------------------------------------------*/
  if(R2SUSPENDED == gCurrentTrace->r2status)
     return 0;

/*-------------------------------------------------------------------------*/
/*  Check the input                                                        */
/*-------------------------------------------------------------------------*/
  ValidateInput(R2srcfile_ptr, line, 1);

/*-------------------------------------------------------------------------*/
/*  Call the lower case function to actually write/save the trace info     */
/*-------------------------------------------------------------------------*/
  return r2false(gCurrentTrace, R2srcfile_ptr, line);
}

int r2false(R2TRACE_PTR theTrace, char *R2srcfile_ptr, int line)
{
char TraceData[MAX_CHARS];
int err, index;

   switch (theTrace->r2status) {
/*-------------------------------------------------------------------------*/
/*  If the trace is open, either set the correspondig bit (MIN_TRACE) or   */
/*  write the line to the trace file.                                      */
/*-------------------------------------------------------------------------*/
      case R2OPEN:
#ifdef MIN_TRACE
            index = R2PathToIndex(R2srcfile_ptr);
            gCurrentTrace->FalseList = 
                        TFListBitSet(theTrace->FalseList, index, line,
                                              &(theTrace->FalseListEntries));
#else
            sprintf(TraceData, "F %d %d %s\n", line, strlen(R2srcfile_ptr),
                                               R2srcfile_ptr);
            err = WriteTrace(TraceData);
            if (err == FILE_ERR)
            R2Err(R2srcfile_ptr, line, "Error writing trace file.");
            if (err == QUEUE_ERR)
            R2Err(R2srcfile_ptr, line, "Error writing to message buffer");
#endif
         break;

/*-------------------------------------------------------------------------*/
/*  If the trace is suspended, return without writing or saving anything   */
/*-------------------------------------------------------------------------*/
      case R2SUSPENDED:
         break;

/*-------------------------------------------------------------------------*/
/*  If the trace is closed, issue an error message.                        */
/*-------------------------------------------------------------------------*/
      case R2CLOSED:
         R2Err(R2srcfile_ptr, line, "Attempt to write to a closed trace");
         break;
   }
return 0;
}

/*=========================================================================*/
/* FUNCTION: R2Switch                                                      */
/*=========================================================================*/
/* PURPOSE : If MIN_TRACE is not defined, writes the 'S' character, line   */
/*           number, switch value, number of characters in the source file */
/*           name, and the source file name to the trace file.  If         */
/*           MIN_TRACE is defined, R2Switch saves the unique combinations  */
/*           of file name, line number, and index for later output.        */
/*                                                                         */
/*           Function is entered when an instrumented switch statement is  */
/*           encountered.  An example statement is as follows:             */
/*                 Before:                                                 */
/*                    switch(expression)                                   */
/*                 After:                                                  */
/*                    switch(R2Switch(expression))                         */
/*                                                                         */
/* SYSTEM  : RECON II                                                      */
/*                                                                         */
/* CALLS   : r2OpenDefaultFile, r2OpenDefaultMessageQ, ValidateInput,      */
/*           R2PathToIndex, NewSwitch, SwitchListAdd, WriteTrace, R2Err    */
/*                                                                         */
/* USED BY : Instrumented user source code                                 */
/*                                                                         */
/* HISTORY :                                                               */
/* VER   DATE         AUTHOR    DESCRIPTION                                */
/* 1.00   6 Feb 93 L. McCallie  Create file.                               */
/* 2.00  23 Mar 97 J. Ward      Modify per Tisk 17 to write file name ILO  */
/*                              file index.                                */
/*-------------------------------------------------------------------------*/
int R2Switch(char * R2srcfile_ptr, int line, int switchValue)
{

/*-------------------------------------------------------------------------*/
/* Check if the global current trace exists.  If not, create one and       */
/* open the corresponding trace file.                                      */
/*-------------------------------------------------------------------------*/
  if( gCurrentTrace == NULL )
  {
      gCurrentTrace = (R2TRACE *) malloc(sizeof(R2TRACE));
#ifdef MESSAGE_Q
      gCurrentTrace = r2OpenDefaultMessageQ();
#else
      gCurrentTrace = r2OpenDefaultFile();
#endif
  }

/*-------------------------------------------------------------------------*/
/*  If tracing is suspended, return.                                       */
/*-------------------------------------------------------------------------*/
  if(R2SUSPENDED == gCurrentTrace->r2status) 
  return r2switch(gCurrentTrace, R2srcfile_ptr, line, switchValue);

/*-------------------------------------------------------------------------*/
/*  Check the input.                                                       */
/*-------------------------------------------------------------------------*/
  ValidateInput(R2srcfile_ptr, line, switchValue);

/*-------------------------------------------------------------------------*/
/*  Call the lower case function to actually write/save the trace info     */
/*-------------------------------------------------------------------------*/
  return r2switch(gCurrentTrace, R2srcfile_ptr, line, switchValue);
}

int r2switch(R2TRACE_PTR theTrace,char *R2srcfile_ptr,int line,int switchValue)
{
char TraceData[MAX_CHARS];
int err, index;
#ifdef MIN_TRACE
   SwitchListADT *SLEntry;
#endif

   switch (theTrace->r2status) {
/*-------------------------------------------------------------------------*/
/*  If the trace is open, either save the unique file name/line number/    */
/*  switch value combinations (MIN_TRACE), or write the line to the        */
/*  trace file.                                                            */
/*-------------------------------------------------------------------------*/
      case R2OPEN:
#ifdef MIN_TRACE
            index = R2PathToIndex(R2srcfile_ptr);

            SLEntry = NewSwitch();

⌨️ 快捷键说明

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