Esempio n. 1
0
void ClientIdentification::dump()
{
	Debug::dump(" client=");
	dumpCode(mClientProcess);
	for (GuestMap::const_iterator it = mGuests.begin(); it != mGuests.end(); ++it) {
		Debug::dump(" guest(0x%x)=", it->first);
		dumpCode(it->second.code);
		if (it->second.gotHash)
			Debug::dump(" [got hash]");
	}
}
Esempio n. 2
0
void DumpJitCodeStr( const char *buffer, unsigned len, void (*output)( char ) )
{
    jit_code_str        *header;

    header = (jit_code_str *)buffer;
    switch( header->arch ) {
    case JIT_ARCH_I86:
    case JIT_ARCH_SPARC:
        myPrintf( output, "arch: %d (%s)\n", header->arch, archTypes[ header->arch ] );
        dumpSection( output, "code", &header->code );
        dumpSection( output, "data", &header->data );
        dumpSection( output, "eh_table", &header->eh_table );
        dumpSection( output, "pdata", &header->pdata );
        dumpSection( output, "relocs", &header->relocs );
        myPrintf( output, "code:\n" );
        dumpCode( output, header );
        myPrintf( output, "data:\n" );
        dumpData( output, header );
        myPrintf( output, "eh_table:\n" );
        dumpEhTable( output, header );
        myPrintf( output, "pdata:\n" );
        dumpPData( output, header );
        myPrintf( output, "relocs:\n" );
        dumpRelocs( output, header );
        break;
    default:
        myPrintf( output, "not a valid code string: arch = %d\n", header->arch );
    }
}
Esempio n. 3
0
/**
 * SNMP Process Handler.
 * UDP Socket and SNMP transaction handling. 
 *
 * @param none
 * @return none
 */
void SnmpXDaemon_process(void)
{
    int32 len = 0;
    
	uint8 svr_addr[6];
	uint16  svr_port;
    
	//UDPOpen(SOCK_SNMP, 161);
    
    //if ( (len = getSn_RX_RSR(SOCK_SNMP)) > 0)
    if((len = GetSocketRxRecvBufferSize(SOCK_SNMP)) > 0)
    {
        request_msg.len= UDPRecv(SOCK_SNMP, (int8 *)&request_msg.buffer[0], len, svr_addr, &svr_port);
    }
    else
    {
        request_msg.len = 0;
        //continue;
    }

    if (request_msg.len > 0)
    {
        dumpCode("\r\n[Request]\r\n", "\r\n", request_msg.buffer, request_msg.len);

        request_msg.index = 0;
        response_msg.index = 0;
        errorStatus = errorIndex = 0;

        if (parseSNMPMessage() != -1)
        {

            UDPSend(SOCK_SNMP, (int8 *)response_msg.buffer, response_msg.index, svr_addr, svr_port);
        
        }
        
        dumpCode("\r\n[Response]\r\n", "\r\n", response_msg.buffer, response_msg.index);      
    }
    
	//UDPClose(SOCK_SNMP);	
}
Esempio n. 4
0
int main()
{
    codePCCache = memalign(4096, 8192);
    codeLRCache = memalign(4096, 8192);

    memcpy(codePCCache + START_PC_PAGE_OFFSET, codePC, 4 * NUM_DUMPED_WORDS);
    memcpy(codeLRCache + START_LR_PAGE_OFFSET, codeLR, 4 * NUM_DUMPED_WORDS);

    dumpCode((int *) (codePCCache + START_PC_PAGE_OFFSET),
             (int *) (codeLRCache + START_LR_PAGE_OFFSET));

    while (!done) {
        sleep(1000);
    }
    return 0;
}
/*
 * Dump a method.
 */
void dumpMethod(DexFile* pDexFile, const DexMethod* pDexMethod, int i)
{
    const DexMethodId* pMethodId;
    const char* backDescriptor;
    const char* name;
    char* typeDescriptor;
    char* accessStr;

    pMethodId = dexGetMethodId(pDexFile, pDexMethod->methodIdx);
    name = dexStringById(pDexFile, pMethodId->nameIdx);
    typeDescriptor = dexCopyDescriptorFromMethodId(pDexFile, pMethodId);

    backDescriptor = dexStringByTypeIdx(pDexFile, pMethodId->classIdx);

    accessStr = createAccessFlagStr(pDexMethod->accessFlags,
                    kAccessForMethod);

    printf("    #%d              : (in %s)\n", i, backDescriptor);
    printf("      name          : '%s'\n", name);
    printf("      type          : '%s'\n", typeDescriptor);
    printf("      access        : 0x%04x (%s)\n",
        pDexMethod->accessFlags, accessStr);

    if (pDexMethod->codeOff == 0) {
        printf("      code          : (none)\n");
    } else {
        printf("      code          -\n");
        dumpCode(pDexFile, pDexMethod);
    }

    if (gOptions.disassemble)
        putchar('\n');

    free(typeDescriptor);
    free(accessStr);
}
Esempio n. 6
0
void LinkBuffer::copyCompactAndLinkCode(void* ownerUID, JITCompilationEffort effort)
{
    m_initialSize = m_assembler->m_assembler.codeSize();
    allocate(m_initialSize, ownerUID, effort);
    if (didFailToAllocate())
        return;
    uint8_t* inData = (uint8_t*)m_assembler->unlinkedCode();
    uint8_t* outData = reinterpret_cast<uint8_t*>(m_code);
    int readPtr = 0;
    int writePtr = 0;
    Vector<LinkRecord, 0, UnsafeVectorOverflow>& jumpsToLink = m_assembler->jumpsToLink();
    unsigned jumpCount = jumpsToLink.size();
    for (unsigned i = 0; i < jumpCount; ++i) {
        int offset = readPtr - writePtr;
        ASSERT(!(offset & 1));
            
        // Copy the instructions from the last jump to the current one.
        size_t regionSize = jumpsToLink[i].from() - readPtr;
        InstructionType* copySource = reinterpret_cast_ptr<InstructionType*>(inData + readPtr);
        InstructionType* copyEnd = reinterpret_cast_ptr<InstructionType*>(inData + readPtr + regionSize);
        InstructionType* copyDst = reinterpret_cast_ptr<InstructionType*>(outData + writePtr);
        ASSERT(!(regionSize % 2));
        ASSERT(!(readPtr % 2));
        ASSERT(!(writePtr % 2));
        while (copySource != copyEnd)
            *copyDst++ = *copySource++;
        m_assembler->recordLinkOffsets(readPtr, jumpsToLink[i].from(), offset);
        readPtr += regionSize;
        writePtr += regionSize;
            
        // Calculate absolute address of the jump target, in the case of backwards
        // branches we need to be precise, forward branches we are pessimistic
        const uint8_t* target;
        if (jumpsToLink[i].to() >= jumpsToLink[i].from())
            target = outData + jumpsToLink[i].to() - offset; // Compensate for what we have collapsed so far
        else
            target = outData + jumpsToLink[i].to() - executableOffsetFor(jumpsToLink[i].to());
            
        JumpLinkType jumpLinkType = m_assembler->computeJumpType(jumpsToLink[i], outData + writePtr, target);
        // Compact branch if we can...
        if (m_assembler->canCompact(jumpsToLink[i].type())) {
            // Step back in the write stream
            int32_t delta = m_assembler->jumpSizeDelta(jumpsToLink[i].type(), jumpLinkType);
            if (delta) {
                writePtr -= delta;
                m_assembler->recordLinkOffsets(jumpsToLink[i].from() - delta, readPtr, readPtr - writePtr);
            }
        }
        jumpsToLink[i].setFrom(writePtr);
    }
    // Copy everything after the last jump
    memcpy(outData + writePtr, inData + readPtr, m_initialSize - readPtr);
    m_assembler->recordLinkOffsets(readPtr, m_initialSize, readPtr - writePtr);
        
    for (unsigned i = 0; i < jumpCount; ++i) {
        uint8_t* location = outData + jumpsToLink[i].from();
        uint8_t* target = outData + jumpsToLink[i].to() - executableOffsetFor(jumpsToLink[i].to());
        m_assembler->link(jumpsToLink[i], location, target);
    }

    jumpsToLink.clear();
    shrink(writePtr + m_initialSize - readPtr);

#if DUMP_LINK_STATISTICS
    dumpLinkStatistics(m_code, m_initialSize, m_size);
#endif
#if DUMP_CODE
    dumpCode(m_code, m_size);
#endif
}
Esempio n. 7
0
int main(int argc, const char *argv[]) {
	int retVal = 0;
	struct Buffer data = {0,};
	struct Buffer mask = {0,};
	struct Buffer i2c = {0,};
	BufferStatus bStatus;
	I2CStatus iStatus;
	int dStatus;
	uint8 configByte;
	const char *error = NULL;

	if ( argc != 4 ) {
		usage(argv[0]);
		FAIL(1, cleanup);
	}

	if ( strstr(argv[2], "WithBoot") ) {
		// Boot firmware explicitly connects
		configByte = CONFIG_BYTE_400KHZ | CONFIG_BYTE_DISCON;
	} else {
		// NonBoot firmwares are connected automatically
		configByte = CONFIG_BYTE_400KHZ;
	}

	bStatus = bufInitialise(&data, 0x4000, 0x00, &error);
	CHECK_STATUS(bStatus, 2, cleanup);
	bStatus = bufInitialise(&mask, 0x4000, 0x00, &error);
	CHECK_STATUS(bStatus, 3, cleanup);
	bStatus = bufReadFromIntelHexFile(&data, &mask, argv[1], &error);
	CHECK_STATUS(bStatus, 4, cleanup);

	if ( !strcmp("iic", argv[3]) ) {
		// Get i2c records
		bStatus = bufInitialise(&i2c, 0x4000, 0x00, &error);
		CHECK_STATUS(bStatus, 5, cleanup);
		i2cInitialise(&i2c, 0x0000, 0x0000, 0x0000, configByte);
		iStatus = i2cWritePromRecords(&i2c, &data, &mask, &error);
		CHECK_STATUS(iStatus, 6, cleanup);
		iStatus = i2cFinalise(&i2c, &error);
		CHECK_STATUS(iStatus, 7, cleanup);

		// Dump the code
		dStatus = dumpCode(argv[0], argv[2], &i2c);
		CHECK_STATUS(dStatus, dStatus, cleanup);
	} else if ( !strcmp("bix", argv[3]) ) {
		// Dump the code
		dStatus = dumpCode(argv[0], argv[2], &data);
		CHECK_STATUS(dStatus, dStatus, cleanup);
	} else {
		usage(argv[0]);
		FAIL(8, cleanup);
	}

cleanup:
	if ( error ) {
		fprintf(stderr, "%s: %s\n", argv[0], error);
		errFree(error);
	}
	bufDestroy(&i2c);
	bufDestroy(&mask);
	bufDestroy(&data);
	return retVal;
}
Esempio n. 8
0
int main(int argc, const char *argv[]) {
	int returnCode = 0;
	struct Buffer data1 = {0,};
	struct Buffer mask1 = {0,};
	struct Buffer data2 = {0,};
	struct Buffer mask2 = {0,};
	struct Buffer i2c1 = {0,};
	struct Buffer i2c2 = {0,};
	BufferStatus bStatus;
	I2CStatus iStatus;
	int dStatus;
	uint8 configByte;
	const char *error = NULL;

	if ( argc != 5 ) { //&& argc != 6 ) {
		usage(argv[0]);
		FAIL(1);
	}

	if ( strstr(argv[3], "WithBoot") ) {
		// Boot firmware explicitly connects
		configByte = CONFIG_BYTE_400KHZ | CONFIG_BYTE_DISCON;
	} else {
		// NonBoot firmwares are connected automatically
		configByte = CONFIG_BYTE_400KHZ;
	}

	bStatus = bufInitialise(&data1, 0x4000, 0x00, &error);
	CHECK(bStatus, 2);
	bStatus = bufInitialise(&mask1, 0x4000, 0x00, &error);
	CHECK(bStatus, 3);
	bStatus = bufReadFromIntelHexFile(&data1, &mask1, argv[1], &error);
	CHECK(bStatus, 4);

	bStatus = bufInitialise(&data2, 0x4000, 0x00, &error);
	CHECK(bStatus, 5);
	bStatus = bufInitialise(&mask2, 0x4000, 0x00, &error);
	CHECK(bStatus, 6);
	bStatus = bufReadFromIntelHexFile(&data2, &mask2, argv[2], &error);
	CHECK(bStatus, 7);

	if ( !strcmp("iic", argv[4]) ) {
		// Get i2c records from first build
		bStatus = bufInitialise(&i2c1, 0x4000, 0x00, &error);
		CHECK(bStatus, 8);
		i2cInitialise(&i2c1, 0x0000, 0x0000, 0x0000, configByte);
		iStatus = i2cWritePromRecords(&i2c1, &data1, &mask1, &error);
		CHECK(iStatus, 9);
		iStatus = i2cFinalise(&i2c1, &error);
		CHECK(iStatus, 10);

		// Get i2c records from second build
		bStatus = bufInitialise(&i2c2, 0x4000, 0x00, &error);
		CHECK(bStatus, 11);
		i2cInitialise(&i2c2, 0x0000, 0x0000, 0x0000, configByte);
		iStatus = i2cWritePromRecords(&i2c2, &data2, &mask2, &error);
		CHECK(iStatus, 12);
		iStatus = i2cFinalise(&i2c2, &error);
		CHECK(iStatus, 13);
		
		// Dump the code
		dStatus = dumpCode(argv[0], argv[3], &i2c1, &i2c2);
		CHECK(dStatus, dStatus);
	} else if ( !strcmp("bix", argv[4]) ) {
		// Dump the code
		dStatus = dumpCode(argv[0], argv[3], &data1, &data2);
		CHECK(dStatus, dStatus);
	} else {
		usage(argv[0]);
		FAIL(14);
	}

cleanup:
	if ( error ) {
		fprintf(stderr, "%s: %s\n", argv[0], error);
		errFree(error);
	}
	bufDestroy(&i2c2);
	bufDestroy(&i2c1);
	bufDestroy(&mask2);
	bufDestroy(&data2);
	bufDestroy(&mask1);
	bufDestroy(&data1);
	return returnCode;
}