Exemplo n.º 1
0
//---------------------------------------------------------------------------
Database & Database::drop()
{
    if( !attached() )
        exceptionHandler(newObjectV1C2<EDBNotAttached>((ISC_STATUS *) NULL,__PRETTY_FUNCTION__));
    ISC_STATUS_ARRAY status;
    if( api.isc_drop_database(status,&handle_) != 0 )
        exceptionHandler(newObjectV1C2<EDBDrop>(status, __PRETTY_FUNCTION__));
    detach();
    return *this;
}
Exemplo n.º 2
0
MemoryProxyHandle createMemoryInstance(DomainDesc * domain, jint size, jint bytes)
{
	MemoryProxyHandle m;
	jint rem;
	jint *d;

	if (size < 0 || bytes <= 0) {
		exceptionHandler(THROW_MemoryIndexOutOfBounds);
	}

	d = jxmalloc(size + bytes - 1 MEMTYPE_MEMOBJ);
	domain->memoryObjectBytes += size + bytes - 1;

	if (bytes > 1) {
		rem = ((u4_t) d % bytes);
		if (rem > 0) {
			d = (jint *) (((u4_t) d) + bytes - rem);
		}
	}

	memset(d, 0, size);

	m = allocMemoryProxyInDomain(domain, memoryClass, d, size);

	return m;
}
Exemplo n.º 3
0
static void exceptionHandlerWrapper(uint32_t oldEsp, hostContext_t* context) {
//  printf("Now in handler-wrapper\n");
  hostContext_t tmp;
  getcontext(&tmp.ctx);
  context->fpregs = &context->__fpregs_mem;
  memcpy(context->fpregs,tmp.fpregs,sizeof(struct _libc_fpstate));
  context->esp = oldEsp;
  bool handled = exceptionHandler(context);
  // If handled is false we should generate a new sigsegv for lindy
  setcontext(&context->ctx);
}
Exemplo n.º 4
0
bool _Wolframe::langbind::getDescription( lua_State *ls, int index, std::string& ret)
{
	try
	{
		LuaExceptionHandlerScope exceptionHandler( ls);
		{
			getDescription_( ls, index, ret);
		}
		return true;
	}
	catch (std::bad_alloc) { }
	catch (std::bad_cast) { }
	return false;
}
Exemplo n.º 5
0
/* this function is used to set up exception handlers for tracing and
   breakpoints */
void set_debug_traps () {
    extern void _debug_level7 ();
    extern void remcomHandler ();
    int exception;

    initializeRemcomErrorFrame ();
    stackPtr = &remcomStack[STACKSIZE / sizeof (int) - 1];

    for (exception = 2; exception <= 23; exception++)
        exceptionHandler (exception, _catchException);

    /* level 7 interrupt              */
    exceptionHandler (31, _debug_level7);

    /* breakpoint exception (trap #1) */
    exceptionHandler (33, _catchException);

    /* This is a trap #8 instruction.  Apparently it is someone's software
       convention for some sort of SIGFPE condition.  Whose?  How many
       people are being screwed by having this code the way it is?
       Is there a clean solution?  */
    exceptionHandler (40, _catchException);

    /* 48 to 54 are floating point coprocessor errors */
    for (exception = 48; exception <= 54; exception++)
        exceptionHandler (exception, _catchException);

    if (oldExceptionHook != remcomHandler)
    {
        oldExceptionHook = exceptionHook;
        exceptionHook = remcomHandler;
    }

    initialized = 1;

}
Exemplo n.º 6
0
static ObjectDesc *bootfs_getReadWriteFile(ObjectDesc * self, ObjectDesc * filename)
{
    FileDesc *fd;
    ObjectDesc *mem;

    if ((fd = memfs_open(curdom(), (char *) memfs_str2chr(filename))) == NULL) {
        exceptionHandler(THROW_NullPointerException);
    }

    mem = (ObjectDesc *) memfs_mmap(fd, curdom(), MEMFS_RW);

    memfs_close(fd);

    return mem;
}
Exemplo n.º 7
0
static void exceptionTrampoline(int signum, siginfo_t *info, void *ptr) {
  hostContext_t* context = ptr;

bool handled = exceptionHandler(context);
if (!handled) {
  abort();
}
return;


if (context->eip & 0x80000000) {
  printf("SIGSEGV - eip was 0x%08X\n",context->eip);
  printf("Crash in host code?\n");
  abort();
  return;
}

//  printf("SIGSEGV - eip was 0x%08X\n",context->eip);

//  printFrame();

  uint8_t* code = (uint8_t*)context->eip;
  uint32_t data = context->eax;

  uint32_t oldEsp = context->esp;
  context->esp -= sizeof(hostContext_t);
  uintptr_t contextPointer = context->esp;
  memcpy((void*)contextPointer,context,sizeof(hostContext_t));
 
  context->esp -= 4;
  *(uint32_t*)context->esp = contextPointer;
  context->esp -= 4;
  *(uint32_t*)context->esp = oldEsp;
  context->esp -= 4;
   // No return address because we will restore the context

  context->eip = (uintptr_t)exceptionHandlerWrapper;

  
  return;


}	 
Exemplo n.º 8
0
MemoryProxyHandle allocMemoryProxyInDomain(DomainDesc * domain, ClassDesc * c, jint start, jint size)
{
	MemoryProxyHandle obj;
	jint objSize = OBJSIZE_MEMORY;

	obj = (MemoryProxyHandle) gc_allocDataInDomain(domain, objSize, OBJFLAGS_MEMORY);
	if (obj == NULL || *obj == NULL) {
		exceptionHandler(THROW_RuntimeException);
	}
	//printf("MEMADDR: %p\n", obj);
	(*obj)->vtable = c->vtable;
	(*obj)->size = size;
	(*obj)->mem = start;

#ifdef PROFILE_AGING
	paMemProxy((jint *) obj, c);
#endif

	return obj;
}
Exemplo n.º 9
0
static jboolean cpuManager_unblock(ObjectDesc * self, CPUStateProxy * cpuStateProxy)
{
    jboolean ret;
    ThreadDesc *cpuState;
    if (cpuStateProxy == NULL)
        exceptionHandler(THROW_RuntimeException);

    cpuState = cpuState2thread((ObjectDesc *) cpuStateProxy);
    if (cpuState == NULL) {
        ret = JNI_FALSE;
        goto finish;
    }
    if (cpuState->state != STATE_BLOCKEDUSER) {
        cpuState->unblockedWithoutBeingBlocked = 1;
        ret = JNI_FALSE;
    } else {
        threadunblock(cpuState);
        ret = JNI_TRUE;
    }
  finish:
    return ret;
}
Exemplo n.º 10
0
jboolean cpuManager_unblock(ObjectDesc * self, CPUStateProxy * cpuStateProxy)
{
	jboolean ret;
	/*ThreadDesc *cpuState = cpuStateProxy->cpuState; */
	ThreadDesc *cpuState;
	if (cpuStateProxy == NULL)
		exceptionHandler(THROW_RuntimeException);

	DISABLE_IRQ;		/* because we access data in another domain (the TCB) */

	cpuState = cpuState2thread(cpuStateProxy);
	if (cpuState == NULL) {
		ret = JNI_FALSE;
		goto finish;
	}
	ASSERTTHREAD(cpuState);
#ifdef VERBOSE_UNBLOCK
	printf("UNBLOCK %d.%d by %d.%d\n", TID(cpuState), TID(curthr()));
	/*printf("CPU%d: unblock %p\n",get_processor_id(), cpuState); */
#endif
	if (cpuState->state != STATE_BLOCKEDUSER) {
#ifdef DEBUG
/*		printf("CPU%d: CPUManager::unblock: Thread %p is in state %d (%s)\n", get_processor_id(), cpuState,
		       cpuState->state, get_state(cpuState));
*/
#endif
		//printStackTrace("STACK: ", curthr(), base);
		cpuState->unblockedWithoutBeingBlocked = 1;
		ret = JNI_FALSE;
	} else {
		threadunblock(cpuState);
		ret = JNI_TRUE;
	}
      finish:
	RESTORE_IRQ;
	return ret;

}
Exemplo n.º 11
0
/*
 * This function does all command procesing for interfacing to gdb.
 */
void handle_exception (int exceptionVector)
{
    int sigval, stepping;
    int addr, length;
    char *ptr;
    int newPC;
    Frame *frame;

    if (remote_debug)
        printf ("vector=%d, sr=0x%x, pc=0x%x\n",
                exceptionVector, registers[PS], registers[PC]);

    /* reply to host that an exception has occurred */
    sigval = computeSignal (exceptionVector);
    remcomOutBuffer[0] = 'S';
    remcomOutBuffer[1] = hexchars[sigval >> 4];
    remcomOutBuffer[2] = hexchars[sigval % 16];
    remcomOutBuffer[3] = 0;

    putpacket (remcomOutBuffer);

    stepping = 0;

    while (1 == 1)
    {
        remcomOutBuffer[0] = 0;
        ptr = getpacket ();
        switch (*ptr++)
        {
        case '?':
            remcomOutBuffer[0] = 'S';
            remcomOutBuffer[1] = hexchars[sigval >> 4];
            remcomOutBuffer[2] = hexchars[sigval % 16];
            remcomOutBuffer[3] = 0;
            break;
        case 'd':
            remote_debug = !(remote_debug);	/* toggle debug flag */
            break;
        case 'g':		/* return the value of the CPU registers */
            mem2hex ((char *) registers, remcomOutBuffer, NUMREGBYTES);
            break;
        case 'G':		/* set the value of the CPU registers - return OK */
            hex2mem (ptr, (char *) registers, NUMREGBYTES);
            strcpy (remcomOutBuffer, "OK");
            break;

        /* mAA..AA,LLLL  Read LLLL bytes at address AA..AA */
        case 'm':
            if (setjmp (remcomEnv) == 0)
            {
                exceptionHandler (2, handle_buserror);

                /* TRY TO READ %x,%x.  IF SUCCEED, SET PTR = 0 */
                if (hexToInt (&ptr, &addr))
                    if (*(ptr++) == ',')
                        if (hexToInt (&ptr, &length))
                        {
                            ptr = 0;
                            mem2hex ((char *) addr, remcomOutBuffer, length);
                        }

                if (ptr)
                {
                    strcpy (remcomOutBuffer, "E01");
                }
            }
            else
            {
                exceptionHandler (2, _catchException);
                strcpy (remcomOutBuffer, "E03");
                debug_error ("%s","bus error");
            }

            /* restore handler for bus error */
            exceptionHandler (2, _catchException);
            break;

        /* MAA..AA,LLLL: Write LLLL bytes at address AA.AA return OK */
        case 'M':
            if (setjmp (remcomEnv) == 0)
            {
                exceptionHandler (2, handle_buserror);

                /* TRY TO READ '%x,%x:'.  IF SUCCEED, SET PTR = 0 */
                if (hexToInt (&ptr, &addr))
                    if (*(ptr++) == ',')
                        if (hexToInt (&ptr, &length))
                            if (*(ptr++) == ':')
                            {
                                hex2mem (ptr, (char *) addr, length);
                                ptr = 0;
                                strcpy (remcomOutBuffer, "OK");
                            }
                if (ptr)
                {
                    strcpy (remcomOutBuffer, "E02");
                }
            }
            else
            {
                exceptionHandler (2, _catchException);
                strcpy (remcomOutBuffer, "E03");
                debug_error ("%s","bus error");
            }

            /* restore handler for bus error */
            exceptionHandler (2, _catchException);
            break;

        /* cAA..AA    Continue at address AA..AA(optional) */
        /* sAA..AA   Step one instruction from AA..AA(optional) */
        case 's':
            stepping = 1;
        case 'c':
            /* try to read optional parameter, pc unchanged if no parm */
            if (hexToInt (&ptr, &addr))
                registers[PC] = addr;

            newPC = registers[PC];

            /* clear the trace bit */
            registers[PS] &= 0x7fff;

            /* set the trace bit if we're stepping */
            if (stepping)
                registers[PS] |= 0x8000;

            /*
             * look for newPC in the linked list of exception frames.
             * if it is found, use the old frame it.  otherwise,
             * fake up a dummy frame in returnFromException().
             */
            if (remote_debug)
                printf ("new pc = 0x%x\n", newPC);
            frame = lastFrame;
            while (frame)
            {
                if (remote_debug)
                    printf ("frame at 0x%x has pc=0x%x, except#=%d\n",
                            frame, frame->exceptionPC, frame->exceptionVector);
                if (frame->exceptionPC == newPC)
                    break;		/* bingo! a match */
                /*
                 * for a breakpoint instruction, the saved pc may
                 * be off by two due to re-executing the instruction
                 * replaced by the trap instruction.  Check for this.
                 */
                if ((frame->exceptionVector == 33) &&
                        (frame->exceptionPC == (newPC + 2)))
                    break;
                if (frame == frame->previous)
                {
                    frame = 0;	/* no match found */
                    break;
                }
                frame = frame->previous;
            }

            /*
             * If we found a match for the PC AND we are not returning
             * as a result of a breakpoint (33),
             * trace exception (9), nmi (31), jmp to
             * the old exception handler as if this code never ran.
             */
            if (frame)
            {
                if ((frame->exceptionVector != 9) &&
                        (frame->exceptionVector != 31) &&
                        (frame->exceptionVector != 33))
                {
                    /*
                     * invoke the previous handler.
                     */
                    if (oldExceptionHook)
                        (*oldExceptionHook) (frame->exceptionVector);
                    newPC = registers[PC];	/* pc may have changed  */
                    if (newPC != frame->exceptionPC)
                    {
                        if (remote_debug)
                            printf ("frame at 0x%x has pc=0x%x, except#=%d\n",
                                    frame, frame->exceptionPC,
                                    frame->exceptionVector);
                        /* re-use the last frame, we're skipping it (longjump?) */
                        frame = (Frame *) 0;
                        _returnFromException (frame);	/* this is a jump */
                    }
                }
            }

            /* if we couldn't find a frame, create one */
            if (frame == 0)
            {
                frame = lastFrame - 1;

                /* by using a bunch of print commands with breakpoints,
                   it's possible for the frame stack to creep down.  If it creeps
                   too far, give up and reset it to the top.  Normal use should
                   not see this happen.
                 */
                if ((unsigned int) (frame - 2) < (unsigned int) &gdbFrameStack)
                {
                    initializeRemcomErrorFrame ();
                    frame = lastFrame;
                }
                frame->previous = lastFrame;
                lastFrame = frame;
                frame = 0;	/* null so _return... will properly initialize it */
            }

            _returnFromException (frame);	/* this is a jump */

            break;

        /* kill the program */
        case 'k':		/* do nothing */
            break;
        }			/* switch */

        /* reply to the request */
        putpacket (remcomOutBuffer);
    }
}
Exemplo n.º 12
0
/*********************************************************************

 * @fn      SNP_initGAP
 *
 * @brief   Initial parameter needed for using SPNP GATT functionality
 *
 * @return  None.
 */
void SNP_initGAP(void)
{

  // Setup the GAP
  GAP_SetParamValue(TGAP_CONN_PAUSE_PERIPHERAL, DEFAULT_CONN_PAUSE_PERIPHERAL);

  // Setup the GAP Peripheral Role Profile
  {
    // For all hardware platforms, device starts advertising upon initialization
    uint8_t initialAdvertEnable = FALSE;

    // By setting this to zero, the device will go into the waiting state after
    // being discoverable for 30.72 second, and will not being advertising again
    // until the enabler is set back to TRUE
    uint16_t advertOffTime = 0;

    uint8_t enableUpdateRequest = DEFAULT_ENABLE_UPDATE_REQUEST;
    uint16_t desiredMinInterval = DEFAULT_DESIRED_MIN_CONN_INTERVAL;
    uint16_t desiredMaxInterval = DEFAULT_DESIRED_MAX_CONN_INTERVAL;
    uint16_t desiredSlaveLatency = DEFAULT_DESIRED_SLAVE_LATENCY;
    uint16_t desiredConnTimeout = DEFAULT_DESIRED_CONN_TIMEOUT;

    // Set the GAP Role Parameters
    GAPRole_SetParameter(GAPROLE_ADVERT_ENABLED, sizeof(uint8_t),
                         &initialAdvertEnable);
    GAPRole_SetParameter(GAPROLE_ADVERT_OFF_TIME, sizeof(uint16_t),
                         &advertOffTime);

    GAPRole_SetParameter(GAPROLE_SCAN_RSP_DATA, sizeof(scanRspData),
                         scanRspData);
    
    GAPRole_SetParameter(GAPROLE_ADVERT_DATA, sizeof(advertData),
                         advertData);
    
    GAPRole_SetParameter(GAPROLE_PARAM_UPDATE_ENABLE, sizeof(uint8_t),
                         &enableUpdateRequest);
    GAPRole_SetParameter(GAPROLE_MIN_CONN_INTERVAL, sizeof(uint16_t),
                         &desiredMinInterval);
    GAPRole_SetParameter(GAPROLE_MAX_CONN_INTERVAL, sizeof(uint16_t),
                         &desiredMaxInterval);
    GAPRole_SetParameter(GAPROLE_SLAVE_LATENCY, sizeof(uint16_t),
                         &desiredSlaveLatency);
    GAPRole_SetParameter(GAPROLE_TIMEOUT_MULTIPLIER, sizeof(uint16_t),
                         &desiredConnTimeout);
  }
  // Initialize the Advertising data store table with a valid entry 
  // for the non-connectable mode.
  {
    uint8_t *pDataPtr;
    advPtrTable[SNP_ADV_DATA_NON_CONN_IDX].pData = pDataPtr = ICall_malloc(sizeof(advertData));
    if(pDataPtr)
    {
      advPtrTable[SNP_ADV_DATA_NON_CONN_IDX].length = sizeof(advertData);
      memcpy(pDataPtr, advertData, sizeof(advertData));
    }
    else
    {
      exceptionHandler();
    }
  }

  
  
  // Set advertising interval
  {
    uint16_t advInt = DEFAULT_ADVERTISING_INTERVAL;

    GAP_SetParamValue(TGAP_LIM_DISC_ADV_INT_MIN, advInt);
    GAP_SetParamValue(TGAP_LIM_DISC_ADV_INT_MAX, advInt);
    GAP_SetParamValue(TGAP_GEN_DISC_ADV_INT_MIN, advInt);
    GAP_SetParamValue(TGAP_GEN_DISC_ADV_INT_MAX, advInt);
  }
  
  GAPRole_RegisterAppCBs(&paramUpdateCB);
}
/* this function is used to set up exception handlers for tracing and
   breakpoints */
void
set_debug_traps (void)
{
  stackPtr = &remcomStack[STACKSIZE / sizeof (int) - 1];

  exceptionHandler (0, _catchException0);
  exceptionHandler (1, _catchException1);
  exceptionHandler (3, _catchException3);
  exceptionHandler (4, _catchException4);
  exceptionHandler (5, _catchException5);
  exceptionHandler (6, _catchException6);
  exceptionHandler (7, _catchException7);
  exceptionHandler (8, _catchException8);
  exceptionHandler (9, _catchException9);
  exceptionHandler (10, _catchException10);
  exceptionHandler (11, _catchException11);
  exceptionHandler (12, _catchException12);
  exceptionHandler (13, _catchException13);
  exceptionHandler (14, _catchException14);
  exceptionHandler (16, _catchException16);

  /* In case GDB is started before us, ack any packets (presumably
     "$?#xx") sitting there.  */
  putDebugChar ('+');

  initialized = true;

}
Exemplo n.º 14
0
/*
 *
 * CpuManager Portal
 *
 */
jint cpuManager_receive(ObjectDesc * self, ObjectDesc * obj)
{
    exceptionHandler(THROW_RuntimeException);
    return -1;
}