mb_get_runtimeinfo

Previous  Next

 

char* mb_get_runtimeinfo( mb_interpreter_t* s, mb_rtinfo_e rti )

 


 

Returns runtime information such as call and run stacks.

 

typedef enum mb_rtinfo_e

  {

  MB_RTI_NONE          = 0,

  MB_RTI_CALL_STACK    = 1,

  MB_RTI_RUN_STACK     = 2,

  } mb_rtinfo_e;

 

The information is returned as a string with each item separated by a "|" character.  The caller is responsible of freeing the memory allocated to hold the information by calling mb_free.

 

Example

 

/////////////////////////////////////////////////////////////////////////////

//

void CErrorMsgBox::GetStacks()

  {

  if ( m_ExpandDialog.IsExpanded() )

     {

     CString  strLine;

     int      nLine;

 

     // Get the current Call Stack

     char* pCalls = mb_get_runtimeinfo( m_pBasic, MB_RTI_CALL_STACK );

    

     if ( pCalls )

        {

        m_listCallStack.DeleteAllItems();

 

        nLine = 0;

 

        while ( AfxExtractSubString( strLine, pCalls, nLine, '\n' ) && ( strLine.GetLength() > 0 ) )

           {

           CString  strFrom;

           CString  strFunc;

           CString  strReturn;

 

           AfxExtractSubString( strFrom,   strLine, 0, '|' );

           AfxExtractSubString( strFunc,    strLine, 1, '|' );

           AfxExtractSubString( strReturn, strLine, 2, '|' );

 

           m_listCallStack.InsertItem( nLine, strFrom );

           m_listCallStack.SetItemText( nLine, 1, strFunc );

           m_listCallStack.SetItemText( nLine, 2, strReturn );

 

           nLine++;

           }

        endwhile

 

        mb_free( pCalls );

        }

     endif

 

     // Get the current Run Stack

     char* pRuns = mb_get_runtimeinfo( m_pBasic, MB_RTI_RUN_STACK );

    

     if ( pRuns )

        {

        m_listRunStack.DeleteAllItems();

 

        nLine = 0;

 

        while ( AfxExtractSubString( strLine, pRuns, nLine, '\n' ) && ( strLine.GetLength() > 0 ) )

           {

           CString  strModule;

           CString  strCount;

           CString  strFileName;

 

           AfxExtractSubString( strModule,   strLine, 0, '|' );

           AfxExtractSubString( strCount,    strLine, 1, '|' );

           AfxExtractSubString( strFileName, strLine, 2, '|' );

 

           m_listRunStack.InsertItem( nLine, strModule );

           m_listRunStack.SetItemText( nLine, 1, strCount );

           m_listRunStack.SetItemText( nLine, 2, strFileName );

 

           nLine++;

           }

        endwhile

 

        mb_free( pRuns );

        }

     endif

     }

  endif

  }

endfunc