Exemple #1
0
bool Debugger::catchException(Thread* thread, Frame* frame, const Exception& ex)
{
	Frame* myframe = getFrame();
	BEER_STACK_CHECK();

	cout << std::endl << "--------- EXCEPTION ---------" << std::endl;
	printLastOutput();
	printFrame(thread, frame);

	if(ex.getName().compare(BEER_WIDEN("MethodNotFoundException")) == 0) // TODO: better
	{
		cout << std::endl;

		StackRef<Object> receiver(myframe, myframe->stackPush(
			frame->stackTop()
		));

		NULL_ASSERT(*receiver); // TODO

		StackRef<Class> klass(myframe, myframe->stackPush());
		getType(receiver, klass);

		printClassMethods(klass);
		
		myframe->stackMoveTop(-2);  //pop receiver & klass
	}
	
	cout << "\n[" << ex.getName() << "]\n" << ex.getMessage() << " @" << ex.getFilename() << ":" << ex.getFileline() << std::endl;

	return false; // TODO
}
Exemple #2
0
/*	Purpose: copy constructor; designed to copy one exception to another via reference
                 
    Inputs: takes an existing exception by reference, applies the input exception's message to the target exception

    Outputs: no return values
*/
Exception::Exception(const Exception& aException) {
	cout << "Copy Constructor..." << endl;
	setMessage(aException.getMessage());
	//m_msg = new char[MAX_BUF];
	//int b=strlen(aException.getMessage())+1;
	//memcpy(m_msg,aException.getMessage(),b);
}
Exemple #3
0
void FatalException(Exception &e, std::string const &location) {
    DataError *pDataError = dynamic_cast<DataError*> (&e);
    CSPLOG(ERROR, APP) << "CSPSim: caught exception in " << location << ": " << e.getMessage();
    std::cerr << "\n";
    e.details();
    std::cerr << "\n";
    if (pDataError) {
        std::cerr
                << "Please check that the data paths in CSPSim.ini are set to reasonable\n"
                << "values (CSPSim.ini is usually found in CSPSim/Data).  If you appear\n"
                << "to be missing a necessary data file, please check the CSP download\n"
                << "page for the latest data releases or ask for assistance on the CSP\n"
                << "forums:\n"
                << "                http://csp.sourceforge.net/forum\n";
    }
    else {
        std::cerr
                << "CSPSim: caught an exception.  Please report this along with\n"
                << "as much information as possible about what was happening at \n"
                << "the time of the error to the CSP forum at\n"
                << "              http://csp.sourceforge.net/forum\n";
    }
    std::cerr << std::endl;
    ::exit(1);
}
Exemple #4
0
void Logger::Log(LogLevelType level, const char *type, const Exception &e,
                 const char *file /* = NULL */, int line /* = 0 */) {
  if (!IsEnabled()) return;
  auto msg = type + e.getMessage();
  if (file && file[0]) {
    msg += folly::sformat(" in {} on line {}", file, line);
  }
  LogImpl(level, msg, nullptr);
}
 Exception::Exception (const Exception& ex)
 {
     location = ex.getLocation();
     this->message = ex.getMessage();
     if (!ex.getModuleName().empty())
         this->previous = ex.getModuleName();
     else
     if (!ex.module().empty())
         this->previous = ex.module() + "::";
 }
MessageFormatException CMSExceptionSupport::createMessageFormatException( const Exception& cause ) {

    std::string msg = cause.getMessage();

    if( msg.length() == 0 ) {
        msg = typeid( &cause ).name();
    }

    MessageFormatException exception( msg, cause.clone() );

    return exception;
}
Exemple #7
0
void Logger::log(const char *type, const Exception &e,
                 const char *file /* = NULL */, int line /* = 0 */) {
  if (!UseLogAggregator && !UseLogFile) return;

  std::string msg = type;
  msg += e.getMessage();
  if (file && file[0]) {
    ostringstream os;
    os << " in " << file << " on line " << line;
    msg += os.str();
  }
  Log(msg, &e.getStackTrace());
}
Exemple #8
0
void Logger::log(LogLevelType level, const char *type, const Exception &e,
                 const char *file /* = NULL */, int line /* = 0 */) {
  if (!IsEnabled()) return;

  std::string msg = type;
  msg += e.getMessage();
  if (file && file[0]) {
    std::ostringstream os;
    os << " in " << file << " on line " << line;
    msg += os.str();
  }
  Log(level, msg, nullptr);
}
void ExceptionTest::testClone() {

    const char* text = "This is a test";
    Exception ex( __FILE__, __LINE__, text );
    CPPUNIT_ASSERT( strcmp( ex.getMessage().c_str(), text ) == 0 );
    CPPUNIT_ASSERT( ex.getCause() == NULL );

    Exception* cloned = ex.clone();

    CPPUNIT_ASSERT( strcmp( cloned->getMessage().c_str(), text ) == 0 );
    CPPUNIT_ASSERT( cloned->getCause() == NULL );

    delete cloned;
}
bool ExecutionContext::callUserErrorHandler(const Exception &e, int64 errnum,
                                            bool swallowExceptions) {
  int errline = 0;
  String errfile;
  Array backtrace;
  const ExtendedException *ee = dynamic_cast<const ExtendedException*>(&e);
  if (ee) {
    ArrayPtr arr = ee->getBackTrace();
    if (arr) {
      backtrace = *arr;
      Array top = backtrace.rvalAt(0);
      if (!top.isNull()) {
        errfile = top.rvalAt("file");
        errline = top.rvalAt("line").toInt64();
      }
    }
  }
  if (backtrace.isNull()) {
    backtrace = stackTraceToBackTrace(e.getStackTrace());
  }

  bool retval = false;
  RequestData::Data *data = s_request_data->data;
  if (!data->systemExceptionHandlers.empty()) {
    // Avoid calling the user error handler recursively
    if (!data->insideUserHandler) {
      data->insideUserHandler = true;
      try {
        if (!same(f_call_user_func_array
                  (data->systemExceptionHandlers.back(),
                   CREATE_VECTOR6(errnum, String(e.getMessage()), errfile,
                                  errline, "", backtrace)),
                  false)) {
          retval = true;
        }
      } catch (...) {
        data->insideUserHandler = false;
        if (!swallowExceptions) throw;
      }
      data->insideUserHandler = false;
    }
  }

  return retval;
}
bool BaseExecutionContext::callUserErrorHandler(const Exception &e, int errnum,
                                                bool swallowExceptions) {
  switch (getErrorState()) {
  case ExecutingUserHandler:
  case ErrorRaisedByUserHandler:
    return false;
  default:
    break;
  }
  if (!m_userErrorHandlers.empty() &&
      (m_userErrorHandlers.back().second & errnum) != 0) {
    int errline = 0;
    String errfile;
    Array backtrace;
    const ExtendedException *ee = dynamic_cast<const ExtendedException*>(&e);
    if (ee) {
      ArrayPtr arr = ee->getBackTrace();
      if (arr) {
        backtrace = *arr;
        Array top = backtrace.rvalAt(0);
        if (!top.isNull()) {
          errfile = top.rvalAt("file");
          errline = top.rvalAt("line").toInt64();
        }
      }
    }
    if (backtrace.isNull()) {
      backtrace = stackTraceToBackTrace(e.getStackTrace());
    }
    try {
      ErrorStateHelper esh(this, ExecutingUserHandler);
      if (!same(f_call_user_func_array
                (m_userErrorHandlers.back().first,
                 CREATE_VECTOR6(errnum, String(e.getMessage()), errfile,
                                errline, "", backtrace)),
                false)) {
        return true;
      }
    } catch (...) {
      if (!swallowExceptions) throw;
    }
  }
  return false;
}
Exemple #12
0
	extern "C" void segfaulth(int sig,siginfo_t *siginfo, void *secret)
	{

		///c++ abi: nothing to play with
		/*
  ucontext_t *uc=(ucontext_t*)secret;
#ifdef __powerpc__
  signal.setFaultPosition((void *)uc->uc_mcontext.regs->nip);
#else
# ifdef __mips__
  signal.setFaultPosition((void *)( (int) ( uc->uc_mcontext.pc & (0xffffffff) ) ));
# else
  signal.setFaultPosition((void *)uc->uc_mcontext.gregs[REG_EIP]);
# endif
#endif
		 */
		//cerr <<  signal.getStackTrace();
		//cerr << signal.what();

		const char* detail_=fault_detail(sig,siginfo);
		char detail[1024];
		void *faultAddr=NULL;

		SegfaultBuffer emergencyBuffer;
		SegfaultBuffer *oldBuffer=NULL;
		bool stuckCandidate=false;

		if ( siginfo ) faultAddr=siginfo->si_addr;

		snprintf(detail,1024,"Signal (%d) : %s [%p]",sig,detail_,faultAddr);

		fprintf(stderr,"IN RAII SEGFAULT HANDLER, %s\n",detail);fflush(stderr);
               if(1){ //code à activer si demangle et throw merdouillent après segfault
                Exception e;
                std::cerr <<  e.toString() << "\n";
                std::cerr << e.getMessage() << "\n";
                e.poorManPrintStackTrace(false);
                }

		if ( !segfaultBuffer || sig == SIGUSR2 ) {
		        
			fprintf(stderr,
			        sig == SIGUSR2
			        ? "dumping stack\n"
			        : "segfaultBuffer is NULL (not in raii request)!\n");fflush(stderr);
			oldBuffer=segfaultBuffer;
			segfaultBuffer=&emergencyBuffer;
			stuckCandidate=true;
		}
 
		{ // segfaultBuffer is not null, in raii request
			switch (sig)
			{
				case SIGILL:
					segfaultBuffer->exception=new IllegalInstruction(detail);
					break;
				case SIGFPE:
					segfaultBuffer->exception=new FloatingPointException(detail);
					break;
				case SIGSEGV:
					segfaultBuffer->exception=new SegmentationFault(detail);
					break;
				case SIGBUS:
					segfaultBuffer->exception=new BusError(detail);
					break;
				case SIGABRT:
					segfaultBuffer->exception=new Abort(detail);
					break;
				case SIGUSR2:
					segfaultBuffer->exception=new DumpStack(detail);
				default:
					segfaultBuffer->exception=new Signal(detail);
			}
			if ( !segfaultBuffer->exception )
				fprintf(stderr,"UNABLE TO INSTANCIATE EXCEPTION\n");
			else {
				fprintf(stderr,"EXCEPTION INSTANCIATED, STACKTRACE SIZE IS %d\n",segfaultBuffer->exception->depth);
				fflush(stderr);


				segfaultBuffer->exception->depth=backtrace(segfaultBuffer->exception->stackTrace,1024);
				segfaultBuffer->exception->start=2;
				//int i;
/*
				//0 -> segfaulth
				//1 -> __restore_rt
				for ( i=2 ; i < depth ; i++ ) {
					segfaultBuffer->exception->stackTrace_.push_back(p[i]);
				}
				*/

			}
			fflush(stderr);

			segfaultBuffer->signal=sig;
			if ( stuckCandidate ) {
				segfaultBuffer=oldBuffer; //last state
				{
					static Mutex serialize_output;
					Lock l(serialize_output);
					Logger log("raii");
					log ("trying to dump stack");
					if ( emergencyBuffer.exception ) {
        					log.error(emergencyBuffer.exception->toString());
	        				std::cerr << emergencyBuffer.exception->getMessage() << "\n";
	        				if ( sig == SIGUSR2 )
        	        				emergencyBuffer.exception->printStackTrace();
        	        			else
        	        			        emergencyBuffer.exception->poorManPrintStackTrace();
	        		       }
	        		       else {
	        		                log("exception is null");
	        		       }
				}
				delete emergencyBuffer.exception;

				if ( sig == SIGUSR2 ) {
					dumpStackFlag=false;
					return;
				}

				//double fault héhé
				//apache redémarre pour le coup...
				//j'ai pas mieux à proposer. Sinon y'a toujours moyen de
				//passer le thread en stuck avec une contruction du type
				//do { sleep(5); fprintf(stderr,"bip\n"); } while(true);
				//disabling handler for current sig
				signal(sig,SIG_DFL);
				fprintf(stderr,"Commiting suicide with that weapon %s\n",
						fault_detail(sig,siginfo));fflush(stderr);
				raise(sig);
			}
			else {
				fprintf(stderr,"LONGJUMPING\n");fflush(stderr);
				longjmp(segfaultBuffer->env,sig);
			}
		}
	}
void errorExit(Exception& e)
{
    cout << "Error: Failed" << endl << e.getMessage() << endl;
    exit(1);
}
 Str(const Exception& e) : _cstr(e.getMessage().getCString()) { }
void BaseExecutionContext::recordLastError(const Exception &e,
                                           int errnum /* = 0 */) {
  m_lastError = String(e.getMessage());
  m_lastErrorNum = errnum;
}
void Translator::_writeException(const Exception& exception){
	_output << exception.getId() << std::endl;
	_output << exception.getMessage() << std::endl;
}
/**
 * Implements CamInitializerListener callback.
 */
void OpenNiManager::onException(Exception& ex) {
	LOG->error("onException(ex)");
	fprintf(stderr, "Exception: %s\n", ex.getMessage());
	ex.printBacktrace();
}
void ExecutionContext::recordLastError(const Exception &e) {
  RequestData::Data *data = s_request_data->data;
  data->lastError = String(e.getMessage());
}
Exemple #19
0
 virtual void onError(Exception & e, AutoRef<UserData> userData) {
     cout << "Error/e: " << e.getMessage() << endl;
 }
Exemple #20
0
void GarbageCollection::reportError(Exception& ex)
{
  numErrors++;
  cerr << "[E] " << ex.getMessage() << endl;
}