예제 #1
0
static int isWatcomHandler      // FIGURE OUT IF WATCOM HANDLER
    ( __EXC_INFO* info )        // - exception info
{
    int retn;
    if( info->in_func
     && 0 != info->dctx.pdata ) {
        unsigned* hand = (unsigned*)info->dctx.pdata->exc;
        if( 0 != hand
         && hand[1] == 0x2B544157           // "WAT+"
         && hand[2] == 0x4D4F432B ) {       // "+COM"
#if 1
            if( procSetsFP( info->dctx.pdata ) ) {
                info->dctx.fp_actual = GetCtxReg( &info->ctx, Fp );
            } else {
                info->dctx.fp_actual = GetCtxReg( &info->ctx, Sp );
            }
#else
            info->dctx.sp_actual = GetCtxReg( &info->ctx, Sp );
            info->dctx.fp_actual = GetCtxReg( &info->ctx, Fp );
#endif
            info->dctx.fp_alternate = info->dctx.fp_actual;
            getProcInfo( info, &info->dctx );
            retn = 1;
        } else {
            retn = 0;
        }
    } else {
        retn = 0;
    }
    return retn;
}
예제 #2
0
static bool isWatcomHandler     // FIGURE OUT IF WATCOM HANDLER
    ( __EXC_INFO* info )        // - exception info
{
    bool retn;

    retn = false;
    if( info->in_func && 0 != info->dctx.pdata ) {
        unsigned* handler = (unsigned*)info->dctx.pdata->ExceptionHandler;
        if( NULL != handler
         && handler[1] == 0x2B544157           // "WAT+"
         && handler[2] == 0x4D4F432B ) {       // "+COM"
#if 1
            if( procSetsFP( info->dctx.pdata ) ) {
                info->dctx.fp_actual = GetCtxReg( &info->ctx, Fp );
            } else {
                info->dctx.fp_actual = GetCtxReg( &info->ctx, Sp );
            }
#else
            info->dctx.sp_actual = GetCtxReg( &info->ctx, Sp );
            info->dctx.fp_actual = GetCtxReg( &info->ctx, Fp );
#endif
            info->dctx.fp_alternate = info->dctx.fp_actual;
            getProcInfo( info, &info->dctx );
            retn = true;
        }
    }
    return( retn );
}
예제 #3
0
void MemoryAuditor::i_printinfo(const std::string& msg, CustomEventTypeRef evt, const std::string& caller)
{
   procInfo info;
   // The fetch method returns true if memory usage has changed...
   if(getProcInfo(info)) {
     MsgStream log(msgSvc(), name());
     log << MSG::INFO << msg << " " << caller << " " << evt <<
       " virtual size = " << info.vsize << " MB"  <<
       " resident set size = " << info.rss << " MB" << endmsg;
   }
}
예제 #4
0
int verifyGroup(GroupInfo *groupInfo)
{
	if(groupInfo == NULL) {
		fprintf(stderr, "empty groupInfo\n");
		return -1;
	}
	int i;
	for(i = 0; i < groupInfo->config.procNum; i++) {
		ProcInfo *procInfo = getProcInfo(groupInfo, i);
		if(procInfo == NULL || verifyProc(procInfo) == -1) {
			fprintf(stderr, "groupInfo verification error\n");
			return -1;
		}
	}
	return 0;
}
예제 #5
0
/*!
 * \brief Collect normal log.
 * \param cause       [in] Invoke function cause.<br>
 *                         E.g. ResourceExhausted, Signal, Interval.
 * \param nowTime     [in] Log collect time.
 * \param archivePath [in] Archive file path.
 * \return Value is zero, if process is succeed.<br />
 *         Value is error number a.k.a. "errno", if process is failure.
 */
int TLogManager::collectNormalLog(TInvokeCause cause, TMSecTime nowTime,
                                  char *archivePath) {
  int result = EINVAL;
  TLargeUInt systime = 0;
  TLargeUInt usrtime = 0;
  TLargeUInt vmsize = 0;
  TLargeUInt rssize = 0;
  TMachineTimes cpuTimes = {0};

  /* Get java process information. */
  if (unlikely(!getProcInfo(&systime, &usrtime, &vmsize, &rssize))) {
    logger->printWarnMsg("Failure getting java process information.");
  }

  /* Get machine cpu times. */
  if (unlikely(!getSysTimes(&cpuTimes))) {
    logger->printWarnMsg("Failure getting machine cpu times.");
  }

  /* Make write log line. */
  char logData[4097] = {0};
  snprintf(logData, 4096,
           "%lld,%d"              /* Format : Logging information.      */
           ",%llu,%llu,%llu,%llu" /* Format : Java process information. */
           ",%llu,%llu,%llu"      /* Format : Machine CPU times.        */
           ",%llu,%llu,%llu"
           ",%llu,%llu,%llu"
           ",%lld,%lld,%lld,%lld" /* Format : JVM running information.  */
           ",%s\n",               /* Format : Archive file name.        */
           /* Params : Logging information. */
           nowTime,
           logCauseToInt(cause),
           /* Params : Java process information. */
           usrtime, systime, vmsize, rssize,
           /* Params : Machine CPU times. */
           cpuTimes.usrTime, cpuTimes.lowUsrTime, cpuTimes.sysTime,
           cpuTimes.idleTime, cpuTimes.iowaitTime, cpuTimes.irqTime,
           cpuTimes.sortIrqTime, cpuTimes.stealTime, cpuTimes.guestTime,
           /* Params : JVM running information. */
           (long long int)jvmInfo->getSyncPark(),
           (long long int)jvmInfo->getSafepointTime(),
           (long long int)jvmInfo->getSafepoints(),
           (long long int)jvmInfo->getThreadLive(),
           /* Params : Archive file name. */
           archivePath);

  /* Get mutex. */
  ENTER_PTHREAD_SECTION(&logMutex) {

    /* Open log file. */
    int fd = open(conf->HeapLogFile()->get(), O_CREAT | O_WRONLY | O_APPEND,
                  S_IRUSR | S_IWUSR);

    /* If failure open file. */
    if (unlikely(fd < 0)) {
      result = errno;
      logger->printWarnMsgWithErrno("Could not open log file");
    } else {
      result = 0;

      /* Write line to log file. */
      if (unlikely(write(fd, logData, strlen(logData)) < 0)) {
        result = errno;
        logger->printWarnMsgWithErrno("Could not write to log file");
      }

      /* Cleanup. */
      if (unlikely(close(fd) < 0 && (result == 0))) {
        result = errno;
        logger->printWarnMsgWithErrno("Could not close log file");
      }
    }
  }
  /* Release mutex. */
  EXIT_PTHREAD_SECTION(&logMutex)
  return result;
}
예제 #6
0
_WPRTLINK
unsigned CPPLIB( pd_handler_rtn )  // HANDLER FOR FS REGISTRATIONS
    ( FsExcRec* rec_exc         // - exception record
    , void* sp                  // - frame pointer function entry
    , _CONTEXT*                 // - context record
    , PD_DISP_CTX* dctx         // - dispatch context
    )
{
    unsigned retn;              // - return code
    __EXC_INFO info;            // - procedure exception information

    if( 0 == sp ) {
        // sp == 0 only when called from pd_lookup
        THREAD_CTL* ctl = &_RWD_ThreadData;
        retn = unsigned( ctl );
    } else {
        getProcInfo( &info, dctx );
        if( rec_exc->flags & EXC_TYPE_UNWIND_NORMAL ) {
            if( rec_exc->parm_count != 1
             || rec_exc->object     != sp
             || EXCREC_CODE_SETJMP  != ( EXCREC_CODE_MASK & rec_exc->code )
              ) {
                CPPLIB( destruct_internal )( 0, info.rw );
            }
            retn = EXC_HAND_CONTINUE;
        } else if( rec_exc->flags & EXC_TYPE_UNWIND_EXIT ) {
            if( info.ro->base.reg_type == DTRG_STATIC_INITLS ) {
                // always unwind static initialization
                CPPLIB( destruct_internal )( 0, info.rw );
            }
            retn = EXC_HAND_CONTINUE;
        } else if( EXCREC_CODE_WATCOM
                == ( EXCREC_CODE_MASK & rec_exc->code ) ) {
            // WATCOM C++ Exception raised
#if 0
            DISPATCHABLE type = CPPLIB( dispatchable )( rec_exc->dispatch
                                                      , info.rw );
            DISPATCH_EXC* dispatch = rec_exc->dispatch;
            if( DISPATCHABLE_NONE == type ) {
                if( info.rw == dispatch->fs_last ) {
                    type = DISPATCHABLE_NO_CATCH;
                    dispatch->type = type;
                    retn = EXC_HAND_CATCH;
                } else {
                    retn = EXC_HAND_CONTINUE;
                }
            } else {
                dispatch->pdata = info.pd;
                dispatch->type = type;
                retn = EXC_HAND_CATCH;
            }
#else
            DISPATCHABLE  type;      // - type of dispatchability
            DISPATCH_EXC  *dispatch; // - dispatch control
            _EXC_PR       *srch_ctl;

            dispatch = rec_exc->dispatch;
            if( dispatch->fnexc_skip == info.rw ) {
                dispatch->fnexc_skip = NULL;
            }
            for( srch_ctl = dispatch->srch_ctl
               ; NULL != srch_ctl && srch_ctl->_rw == info.rw
               ; srch_ctl = srch_ctl->_prev ) {
                if( NULL == dispatch->fnexc_skip ) {
                    switch( srch_ctl->_state ) {
                      case EXCSTATE_UNEXPECTED :
                      case EXCSTATE_BAD_EXC :
                        dispatch->fnexc_skip
                            = ((_EXC_PR_FNEXC*)srch_ctl)->_fnexc_skip;
                        continue;
                    }
                    break;
                }
            }
            if( NULL != srch_ctl && srch_ctl->_rw == info.rw ) {
                type = DISPATCHABLE_STOP;
            } else if( NULL == dispatch->fnexc_skip ) {
                type = CPPLIB( dispatchable )( dispatch, info.rw );
            } else {
                type = DISPATCHABLE_NONE;
            }
            if( DISPATCHABLE_NONE == type ) {
                if( info.rw == dispatch->fs_last ) {
                    type = DISPATCHABLE_NO_CATCH;
                    dispatch->type = type;
                    retn = EXC_HAND_CATCH;
                } else {
                    retn = EXC_HAND_CONTINUE;
                }
            } else {
                dispatch->pdata = info.pd;
                dispatch->type = type;
                retn = EXC_HAND_CATCH;
            }
#endif
        } else {
            // not WATCOM throw / re-throw
            retn = EXC_HAND_CONTINUE;
        }
    }
    return retn;
}