int main(int argc, char *argv[]) { uint32_t audioServerID; uint32_t commanderID; int32_t ch; char str[128]; uint8_t buf[65536]; MessageInfo msg; FILE *fp; monapi_cmemoryinfo *cmi; connectToKeyboardServer(); // fp = fopen("/APPS/TEST.WAV", "r"); audioServerID = Message::lookupMainThread("AUDIO.EX5"); if( audioServerID == THREAD_UNKNOWN ) exit(printf("Couldn't find an audio server.")); dprintf("AUDIO.EX5 : %x\n", audioServerID); Message::sendReceive(&msg, audioServerID, MSG_AUDIO_SERVER_COMMAND, GetThreadID, COMMAND_THREAD); commanderID = msg.arg2; dprintf("AUDIO.EX5 : %x\n", commanderID); #if 1 Message::sendReceive(&msg, commanderID, MSG_AUDIO_SERVER_COMMAND, GetServerVersion); printf("Server version: %x:%x\n", msg.arg2, msg.arg3); Message::sendReceive(&msg, commanderID, MSG_AUDIO_SERVER_COMMAND, AllocateChannel); ch = msg.arg2; printf("Channel: %d\n", ch); struct audio_server_channel_info ci; ci.channel = ch; ci.samplerate = 44100; ci.bitspersample = 16; ci.channels = 2; memcpy(str, &ci, sizeof(ci)); Message::sendReceive(&msg, commanderID, MSG_AUDIO_SERVER_COMMAND, PrepareChannel, 0, 0, str); printf("Result: %d\n", msg.arg2); /* struct audio_server_buffer_info bi; cmi = monapi_cmemoryinfo_new(); monapi_cmemoryinfo_create(cmi, 0x10000, MONAPI_FALSE); bi.channel = ch; bi.handle = cmi->Handle; bi.size = 0x10000; makeWave(cmi, 200); memcpy(str, &bi, sizeof(bi)); Message::sendReceive(&msg, commanderID, MSG_AUDIO_SERVER_COMMAND, RegisterTID); Message::sendReceive(&msg, commanderID, MSG_AUDIO_SERVER_COMMAND, SetBuffer, 0, 0, str); */ Message::sendReceive(&msg, commanderID, MSG_AUDIO_SERVER_COMMAND, CreateStream, ch); Stream *stream; stream = Stream::FromHandle(msg.arg2); makeWave(buf, 512, 200); /* int readsize; fread(buf, 1, 65536, fp); stream->write(buf, readsize); */ stream->write(buf, 512); printf("Start\n"); Message::sendReceive(&msg, commanderID, MSG_AUDIO_SERVER_COMMAND, StartChannel, ch); while(1) { /* if( Message::receive(&msg) ) continue; if( msg.header == MSG_AUDIO_SERVER_MESSAGE ) { printf("BufferIsEmpty\n"); Message::sendReceive(&msg, commanderID, MSG_AUDIO_SERVER_COMMAND, SetBuffer, 0, 0, str); } */ //int readsize = fread(buf, 1, 65536, fp); stream->waitForWrite(); // stream->write(buf, readsize); stream->write(buf, 512); } END: Message::sendReceive(&msg, commanderID, MSG_AUDIO_SERVER_COMMAND, StopChannel, ch); Message::sendReceive(&msg, commanderID, MSG_AUDIO_SERVER_COMMAND, ReleaseChannel, ch); _printf("Channel was released.\n"); #else Message::sendReceive(&msg, commanderID, MSG_AUDIO_SERVER_COMMAND, CreateChannelObject); ch = msg.arg2; Message::sendReceive(&msg, commanderID, MSG_AUDIO_SERVER_COMMAND, BindChannelObject, ch, 0, "es1370"); #endif return 0; }
inline void pack( Stream& s, const fc::time_point_sec& tp ) { uint32_t usec = tp.sec_since_epoch(); s.write( (const char*)&usec, sizeof(usec) ); }
inline void pack( Stream& s, const fc::time_point& tp ) { uint64_t usec = tp.time_since_epoch().count(); s.write( (const char*)&usec, sizeof(usec) ); }
inline void pack( Stream& s, const fc::microseconds& usec ) { uint64_t usec_as_int64 = usec.count(); s.write( (const char*)&usec_as_int64, sizeof(usec_as_int64) ); }
inline void pack( Stream& s, const fc::int_array<T,N>& v) { s.write( (const char*)&v.data[0], N*sizeof(T) ); }
bool CodeBlock::read(Stream &st) { assert(!m_loaded); U32 globalSize, size, i; version = stream_readi(st); assert(version == 0x21); size = stream_readi(st); #ifdef VERBOSE_CODEBLOCK_READ fprintf(stderr, "Reading %d bytes of globalStrings, currently at position 0x%X\n", size, (unsigned int)st.tellg()); #endif if (size) { globalStrings = new char[size]; globalStringsMaxLen = size; st.read(globalStrings, size); } globalSize = size; size = stream_readi(st); #ifdef VERBOSE_CODEBLOCK_READ fprintf(stderr, "Reading %d bytes of globalFloats, currently at position 0x%X\n", size, (unsigned int)st.tellg()); #endif if (size) { globalFloats = new F64[size]; for (U32 i = 0; i < size; i++) globalFloats[i] = stream_readf(st); } size = stream_readi(st); #ifdef VERBOSE_CODEBLOCK_READ fprintf(stderr, "Reading %d bytes of functionStrings, currently at position 0x%X\n", size, (unsigned int)st.tellg()); #endif if (size) { functionStrings = new char[size]; functionStringsMaxLen = size; st.read(functionStrings, size); } size = stream_readi(st); #ifdef VERBOSE_CODEBLOCK_READ fprintf(stderr, "Reading %d bytes of functionFloats, currently at position 0x%X\n", size, (unsigned int)st.tellg()); #endif if (size) { functionFloats = new F64[size]; for (U32 i = 0; i < size; i++) functionFloats[i] = stream_readf(st); } U32 codeLength; codeLength = stream_readi(st); codeSize = codeLength; lineBreakPairCount = stream_readi(st); #ifdef VERBOSE_CODEBLOCK_READ fprintf(stderr, "Currently at position 0x%X\n", (unsigned int)st.tellg()); #endif U32 totSize = codeLength + lineBreakPairCount * 2; #ifdef VERBOSE_CODEBLOCK_READ fprintf(stderr, "Code length: %d Line Break count: %d totSize: %d\n", codeLength, lineBreakPairCount, totSize); #endif code = new U32[totSize]; for (i = 0; i < codeLength; i++) { U8 b; st.read((char*)&b, 1); if (b == 0xFF) code[i] = stream_readi(st); else code[i] = b; } for (i = codeLength; i < totSize; i++) code[i] = stream_readi(st); lineBreakPairs = code + codeLength; // StringTable-ize our identifiers. U32 identCount; identCount = stream_readi(st); while (identCount--) { U32 offset; offset = stream_readi(st); /*StringTableEntry ste; if (offset < globalSize) ste = StringTable->insert(globalStrings + offset); else ste = StringTable->insert("");*/ char *ste; if (offset < globalSize) ste = globalStrings + offset; else ste = ""; U32 count; count = stream_readi(st); while (count--) { U32 ip; ip = stream_readi(st); code[ip] = (U32)ste; } } #ifdef VERBOSE_CODEBLOCK_READ fprintf(stderr, "Finished reading, currently at position 0x%X\n", (unsigned int)st.tellg()); #endif int c = st.peek(); assert(c == EOF && st.eof()); if (lineBreakPairCount) calcBreakList(); m_loaded = true; return true; }
void recv(Stream & stream, uint16_t len)override { this->len = len; this->WndSupportLevel = stream.in_uint32_le(); this->NumIconCaches = stream.in_uint8(); this->NumIconCacheEntries = stream.in_uint16_le(); }
void cv::gpu::BFMatcher_GPU::radiusMatchCollection(const GpuMat& query, GpuMat& trainIdx, GpuMat& imgIdx, GpuMat& distance, GpuMat& nMatches, float maxDistance, const vector<GpuMat>& masks, Stream& stream) { if (query.empty() || empty()) return; using namespace cv::gpu::device::bf_radius_match; typedef void (*caller_t)(const PtrStepSzb& query, const PtrStepSzb* trains, int n, float maxDistance, const PtrStepSzb* masks, const PtrStepSzi& trainIdx, const PtrStepSzi& imgIdx, const PtrStepSzf& distance, const PtrStepSz<unsigned int>& nMatches, int cc, cudaStream_t stream); static const caller_t callersL1[] = { matchL1_gpu<unsigned char>, 0/*matchL1_gpu<signed char>*/, matchL1_gpu<unsigned short>, matchL1_gpu<short>, matchL1_gpu<int>, matchL1_gpu<float> }; static const caller_t callersL2[] = { 0/*matchL2_gpu<unsigned char>*/, 0/*matchL2_gpu<signed char>*/, 0/*matchL2_gpu<unsigned short>*/, 0/*matchL2_gpu<short>*/, 0/*matchL2_gpu<int>*/, matchL2_gpu<float> }; static const caller_t callersHamming[] = { matchHamming_gpu<unsigned char>, 0/*matchHamming_gpu<signed char>*/, matchHamming_gpu<unsigned short>, 0/*matchHamming_gpu<short>*/, matchHamming_gpu<int>, 0/*matchHamming_gpu<float>*/ }; DeviceInfo info; int cc = info.majorVersion() * 10 + info.minorVersion(); if (!TargetArchs::builtWith(GLOBAL_ATOMICS) || !DeviceInfo().supports(GLOBAL_ATOMICS)) CV_Error(CV_StsNotImplemented, "The device doesn't support global atomics"); const int nQuery = query.rows; CV_Assert(query.channels() == 1 && query.depth() < CV_64F); CV_Assert(trainIdx.empty() || (trainIdx.rows == nQuery && trainIdx.size() == distance.size() && trainIdx.size() == imgIdx.size())); CV_Assert(norm == NORM_L1 || norm == NORM_L2 || norm == NORM_HAMMING); const caller_t* callers = norm == NORM_L1 ? callersL1 : norm == NORM_L2 ? callersL2 : callersHamming; ensureSizeIsEnough(1, nQuery, CV_32SC1, nMatches); if (trainIdx.empty()) { ensureSizeIsEnough(nQuery, std::max((nQuery / 100), 10), CV_32SC1, trainIdx); ensureSizeIsEnough(nQuery, std::max((nQuery / 100), 10), CV_32SC1, imgIdx); ensureSizeIsEnough(nQuery, std::max((nQuery / 100), 10), CV_32FC1, distance); } if (stream) stream.enqueueMemSet(nMatches, Scalar::all(0)); else nMatches.setTo(Scalar::all(0)); caller_t func = callers[query.depth()]; CV_Assert(func != 0); vector<PtrStepSzb> trains_(trainDescCollection.begin(), trainDescCollection.end()); vector<PtrStepSzb> masks_(masks.begin(), masks.end()); func(query, &trains_[0], static_cast<int>(trains_.size()), maxDistance, masks_.size() == 0 ? 0 : &masks_[0], trainIdx, imgIdx, distance, nMatches, cc, StreamAccessor::getStream(stream)); }
parser(const Stream& iss) { parsed = 0; iss_.str(iss.str()); }
static inline void front_out_gcc_conference_user_data_sc_sec1(Stream & stream, int encryptionLevel, uint8_t (&serverRandom)[32], int rc4_key_size, uint8_t (&pub_mod)[512], uint8_t (&pri_exp)[512], Random * gen) { Rsakeys rsa_keys(CFG_PATH "/" RSAKEYS_INI); gen->random(serverRandom, 32); uint8_t pub_sig[512]; memcpy(pub_mod, rsa_keys.pub_mod, 64); memcpy(pub_sig, rsa_keys.pub_sig, 64); memcpy(pri_exp, rsa_keys.pri_exp, 64); stream.out_uint16_le(SC_SECURITY); stream.out_uint16_le(236); // length, including tag and length fields stream.out_uint32_le(rc4_key_size); // key len 1 = 40 bit 2 = 128 bit // crypt level 1 = low 2 = medium, 3 = high stream.out_uint32_le(encryptionLevel); stream.out_uint32_le(32); // random len stream.out_uint32_le(184); // len of rsa info(certificate) stream.out_copy_bytes(serverRandom, 32); /* here to end is certificate */ /* HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\ */ /* TermService\Parameters\Certificate */ stream.out_uint32_le(1); stream.out_uint32_le(1); stream.out_uint32_le(1); // 96 bytes long of sec_tag pubkey stream.out_uint16_le(SEC_TAG_PUBKEY); stream.out_uint16_le(92); // length stream.out_uint32_le(SEC_RSA_MAGIC); stream.out_uint32_le(72); /* 72 bytes modulus len */ stream.out_uint32_be(0x00020000); stream.out_uint32_be(0x3f000000); stream.out_copy_bytes(rsa_keys.pub_exp, 4); /* pub exp */ stream.out_copy_bytes(pub_mod, 64); /* pub mod */ stream.out_clear_bytes(8); /* pad */ // 76 bytes long of sec_tag_pub_sig stream.out_uint16_le(SEC_TAG_KEYSIG); stream.out_uint16_le(72); /* len */ stream.out_copy_bytes(pub_sig, 64); /* pub sig */ stream.out_clear_bytes(8); /* pad */ /* end certificate */ }
void cv::gpu::BFMatcher_GPU::knnMatchSingle(const GpuMat& query, const GpuMat& train, GpuMat& trainIdx, GpuMat& distance, GpuMat& allDist, int k, const GpuMat& mask, Stream& stream) { if (query.empty() || train.empty()) return; using namespace cv::gpu::device::bf_knnmatch; typedef void (*caller_t)(const PtrStepSzb& query, const PtrStepSzb& train, int k, const PtrStepSzb& mask, const PtrStepSzb& trainIdx, const PtrStepSzb& distance, const PtrStepSzf& allDist, int cc, cudaStream_t stream); static const caller_t callersL1[] = { matchL1_gpu<unsigned char>, 0/*matchL1_gpu<signed char>*/, matchL1_gpu<unsigned short>, matchL1_gpu<short>, matchL1_gpu<int>, matchL1_gpu<float> }; static const caller_t callersL2[] = { 0/*matchL2_gpu<unsigned char>*/, 0/*matchL2_gpu<signed char>*/, 0/*matchL2_gpu<unsigned short>*/, 0/*matchL2_gpu<short>*/, 0/*matchL2_gpu<int>*/, matchL2_gpu<float> }; static const caller_t callersHamming[] = { matchHamming_gpu<unsigned char>, 0/*matchHamming_gpu<signed char>*/, matchHamming_gpu<unsigned short>, 0/*matchHamming_gpu<short>*/, matchHamming_gpu<int>, 0/*matchHamming_gpu<float>*/ }; CV_Assert(query.channels() == 1 && query.depth() < CV_64F); CV_Assert(train.type() == query.type() && train.cols == query.cols); CV_Assert(norm == NORM_L1 || norm == NORM_L2 || norm == NORM_HAMMING); const caller_t* callers = norm == NORM_L1 ? callersL1 : norm == NORM_L2 ? callersL2 : callersHamming; const int nQuery = query.rows; const int nTrain = train.rows; if (k == 2) { ensureSizeIsEnough(1, nQuery, CV_32SC2, trainIdx); ensureSizeIsEnough(1, nQuery, CV_32FC2, distance); } else { ensureSizeIsEnough(nQuery, k, CV_32S, trainIdx); ensureSizeIsEnough(nQuery, k, CV_32F, distance); ensureSizeIsEnough(nQuery, nTrain, CV_32FC1, allDist); } if (stream) stream.enqueueMemSet(trainIdx, Scalar::all(-1)); else trainIdx.setTo(Scalar::all(-1)); caller_t func = callers[query.depth()]; CV_Assert(func != 0); DeviceInfo info; int cc = info.majorVersion() * 10 + info.minorVersion(); func(query, train, k, mask, trainIdx, distance, allDist, cc, StreamAccessor::getStream(stream)); }
static inline void parse_mcs_data_sc_security(Stream & cr_stream, CryptContext & encrypt, CryptContext & decrypt, uint32_t & server_public_key_len, uint8_t (& client_crypt_random)[512], int & encryptionLevel, Random * gen) { LOG(LOG_INFO, "SC_SECURITY"); uint32_t encryptionMethod = cr_stream.in_uint32_le(); /* 1 = 40-bit, 2 = 128-bit */ LOG(LOG_INFO, "encryptionMethod = %u", encryptionMethod); encryptionLevel = cr_stream.in_uint32_le(); /* 1 = low, 2 = medium, 3 = high */ LOG(LOG_INFO, "encryptionLevel = %u", encryptionLevel); if (encryptionLevel == 0 && encryptionMethod == 0) { /* no encryption */ LOG(LOG_INFO, "No encryption"); return; } uint8_t modulus[SEC_MAX_MODULUS_SIZE]; uint8_t exponent[SEC_EXPONENT_SIZE]; memset(modulus, 0, sizeof(modulus)); memset(exponent, 0, sizeof(exponent)); ssllib ssl; // serverRandomLen (4 bytes): A 32-bit, unsigned integer. The size in bytes of // the serverRandom field. If the encryptionMethod and encryptionLevel fields // are both set to 0 then the contents of this field MUST be ignored and the // serverRandom field MUST NOT be present. Otherwise, this field MUST be set to // 32 bytes. uint32_t serverRandomLen = cr_stream.in_uint32_le(); LOG(LOG_INFO, "serverRandomLen = %u", serverRandomLen); if (serverRandomLen != SEC_RANDOM_SIZE) { LOG(LOG_ERR, "parse_crypt_info_error: serverRandomLen %d, expected %d", serverRandomLen, SEC_RANDOM_SIZE); throw Error(ERR_SEC_PARSE_CRYPT_INFO_BAD_RANDOM_LEN); } // serverCertLen (4 bytes): A 32-bit, unsigned integer. The size in bytes of the // serverCertificate field. If the encryptionMethod and encryptionLevel fields // are both set to 0 then the contents of this field MUST be ignored and the // serverCertificate field MUST NOT be present. uint32_t serverCertLen = cr_stream.in_uint32_le(); LOG(LOG_INFO, "serverCertLen = %u", serverCertLen); // serverRandom (variable): The variable-length server random value used to // derive session keys (see sections 5.3.4 and 5.3.5). The length in bytes is // given by the serverRandomLen field. If the encryptionMethod and // encryptionLevel fields are both set to 0 then this field MUST NOT be present. uint8_t serverRandom[SEC_RANDOM_SIZE] = {}; cr_stream.in_copy_bytes(serverRandom, serverRandomLen); // serverCertificate (variable): The variable-length certificate containing the // server's public key information. The length in bytes is given by the // serverCertLen field. If the encryptionMethod and encryptionLevel fields are // both set to 0 then this field MUST NOT be present. /* RSA info */ uint8_t * end = cr_stream.p + serverCertLen; if (end > cr_stream.end) { LOG(LOG_ERR, "serverCertLen outside of buffer (%u bytes, remains: %u)", serverCertLen, cr_stream.end - cr_stream.p); throw Error(ERR_SEC_PARSE_CRYPT_INFO_BAD_RSA_LEN); } uint32_t dwVersion = cr_stream.in_uint32_le(); /* 1 = RDP4-style, 0x80000002 = X.509 */ LOG(LOG_INFO, "dwVersion = %x", dwVersion); if (dwVersion & SCSecurityGccUserData::CERT_CHAIN_VERSION_1) { LOG(LOG_DEBUG, "We're going for the RDP4-style encryption"); // dwSigAlgId (4 bytes): A 32-bit, unsigned integer. The signature algorithm // identifier. This field MUST be set to SIGNATURE_ALG_RSA (0x00000001). uint32_t dwSigAlgId = cr_stream.in_uint32_le(); LOG(LOG_DEBUG, "dwSigAlgId = %u", dwSigAlgId); // dwKeyAlgId (4 bytes): A 32-bit, unsigned integer. The key algorithm // identifier. This field MUST be set to KEY_EXCHANGE_ALG_RSA (0x00000001). uint32_t dwKeyAlgId = cr_stream.in_uint32_le(); LOG(LOG_DEBUG, "dwKeyAlgId = %u", dwKeyAlgId); LOG(LOG_DEBUG, "ReceivingPublic key, RDP4-style"); // wPublicKeyBlobType (2 bytes): A 16-bit, unsigned integer. The type of data // in the PublicKeyBlob field. This field MUST be set to BB_RSA_KEY_BLOB // (0x0006). TODO("put assertion to check type and throw and error if not as expected"); uint16_t wPublicKeyBlobType = cr_stream.in_uint16_le(); LOG(LOG_DEBUG, "wPublicKeyBlobType = %u", wPublicKeyBlobType); // wPublicKeyBlobLen (2 bytes): A 16-bit, unsigned integer. The size in bytes // of the PublicKeyBlob field. uint16_t wPublicKeyBlobLen = cr_stream.in_uint16_le(); LOG(LOG_DEBUG, "wPublicKeyBlobLen = %u", wPublicKeyBlobLen); uint8_t * next_tag = cr_stream.p + wPublicKeyBlobLen; // PublicKeyBlob (variable): Variable-length server public key bytes, formatted // using the Rivest-Shamir-Adleman (RSA) Public Key structure (section // 2.2.1.4.3.1.1.1). The length in bytes is given by the wPublicKeyBlobLen // field. uint32_t magic = cr_stream.in_uint32_le(); if (magic != SEC_RSA_MAGIC) { LOG(LOG_WARNING, "RSA magic 0x%x", magic); throw Error(ERR_SEC_PARSE_PUB_KEY_MAGIC_NOT_OK); } server_public_key_len = cr_stream.in_uint32_le() - SEC_PADDING_SIZE; if ((server_public_key_len < SEC_MODULUS_SIZE) || (server_public_key_len > SEC_MAX_MODULUS_SIZE)) { LOG(LOG_WARNING, "Bad server public key size (%u bits)", server_public_key_len * 8); throw Error(ERR_SEC_PARSE_PUB_KEY_MODUL_NOT_OK); } cr_stream.in_skip_bytes(8); /* modulus_bits, unknown */ cr_stream.in_copy_bytes(exponent, SEC_EXPONENT_SIZE); cr_stream.in_copy_bytes(modulus, server_public_key_len); cr_stream.in_skip_bytes(SEC_PADDING_SIZE); LOG(LOG_DEBUG, "Got Public key, RDP4-style"); // This should not be necessary as previous field if fully decoded cr_stream.p = next_tag; LOG(LOG_DEBUG, "Receiving key sig RDP4-style"); // wSignatureBlobType (2 bytes): A 16-bit, unsigned integer. The type of data // in the SignatureKeyBlob field. This field is set to BB_RSA_SIGNATURE_BLOB // (0x0008). TODO("put assertion to check type and throw and error if not as expected"); uint16_t wSignatureBlobType = cr_stream.in_uint16_le(); LOG(LOG_DEBUG, "wSignatureBlobType = %u", wSignatureBlobType); // wSignatureBlobLen (2 bytes): A 16-bit, unsigned integer. The size in bytes // of the SignatureKeyBlob field. uint16_t wSignatureBlobLen = cr_stream.in_uint16_le(); // SignatureBlob (variable): Variable-length signature of the certificate // created with the Terminal Services Signing Key (see sections 5.3.3.1.1 and // 5.3.3.1.2). The length in bytes is given by the wSignatureBlobLen field. cr_stream.in_skip_bytes(wSignatureBlobLen); LOG(LOG_DEBUG, "Got key sig RDP4-style"); } else { LOG(LOG_DEBUG, "We're going for the RDP5-style encryption"); uint32_t certcount = cr_stream.in_uint32_le(); LOG(LOG_DEBUG, "Certcount = %u", certcount); if (certcount < 2){ LOG(LOG_DEBUG, "Server didn't send enough X509 certificates"); throw Error(ERR_SEC_PARSE_CRYPT_INFO_CERT_NOK); } for (; certcount > 2; certcount--){ /* ignore all the certificates between the root and the signing CA */ LOG(LOG_WARNING, " Ignored certs left: %d", certcount); uint32_t ignorelen = cr_stream.in_uint32_le(); LOG(LOG_WARNING, "Ignored Certificate length is %d", ignorelen); SSL_CERT *ignorecert = ssl_cert_read(cr_stream.p, ignorelen); cr_stream.in_skip_bytes(ignorelen); if (ignorecert == NULL){ LOG(LOG_WARNING, "got a bad cert: this will probably screw up" " the rest of the communication"); } LOG(LOG_WARNING, "cert #%d (ignored)", certcount); } /* Do da funky X.509 stuffy "How did I find out about this? I looked up and saw a bright light and when I came to I had a scar on my forehead and knew about X.500" - Peter Gutman in a early version of http://www.cs.auckland.ac.nz/~pgut001/pubs/x509guide.txt */ /* Loading CA_Certificate from server*/ uint32_t cacert_len = cr_stream.in_uint32_le(); LOG(LOG_DEBUG, "CA Certificate length is %d", cacert_len); SSL_CERT *cacert = ssl_cert_read(cr_stream.p, cacert_len); cr_stream.in_skip_bytes(cacert_len); if (NULL == cacert){ LOG(LOG_DEBUG, "Couldn't load CA Certificate from server"); throw Error(ERR_SEC_PARSE_CRYPT_INFO_CACERT_NULL); } /* Loading Certificate from server*/ uint32_t cert_len = cr_stream.in_uint32_le(); LOG(LOG_DEBUG, "Certificate length is %d", cert_len); SSL_CERT *server_cert = ssl_cert_read(cr_stream.p, cert_len); cr_stream.in_skip_bytes(cert_len); if (NULL == server_cert){ ssl_cert_free(cacert); LOG(LOG_DEBUG, "Couldn't load Certificate from server"); throw Error(ERR_SEC_PARSE_CRYPT_INFO_CACERT_NOT_LOADED); } /* Matching certificates */ if (!ssl_certs_ok(server_cert, cacert)){ ssl_cert_free(server_cert); ssl_cert_free(cacert); LOG(LOG_DEBUG, "Security error CA Certificate invalid"); throw Error(ERR_SEC_PARSE_CRYPT_INFO_CACERT_NOT_MATCH); } ssl_cert_free(cacert); cr_stream.in_skip_bytes(16); /* Padding */ SSL_RKEY *server_public_key = ssl_cert_to_rkey(server_cert, server_public_key_len); LOG(LOG_DEBUG, "Server public key length=%u", (unsigned)server_public_key_len); if (NULL == server_public_key){ LOG(LOG_DEBUG, "Didn't parse X509 correctly"); ssl_cert_free(server_cert); throw Error(ERR_SEC_PARSE_CRYPT_INFO_X509_NOT_PARSED); } ssl_cert_free(server_cert); LOG(LOG_INFO, "server_public_key_len=%d, MODULUS_SIZE=%d MAX_MODULUS_SIZE=%d", server_public_key_len, SEC_MODULUS_SIZE, SEC_MAX_MODULUS_SIZE); if ((server_public_key_len < SEC_MODULUS_SIZE) || (server_public_key_len > SEC_MAX_MODULUS_SIZE)){ LOG(LOG_DEBUG, "Bad server public key size (%u bits)", server_public_key_len * 8); ssl.rkey_free(server_public_key); throw Error(ERR_SEC_PARSE_CRYPT_INFO_MOD_SIZE_NOT_OK); } if (ssl_rkey_get_exp_mod(server_public_key, exponent, SEC_EXPONENT_SIZE, modulus, SEC_MAX_MODULUS_SIZE) != 0){ LOG(LOG_DEBUG, "Problem extracting RSA exponent, modulus"); ssl.rkey_free(server_public_key); throw Error(ERR_SEC_PARSE_CRYPT_INFO_RSA_EXP_NOT_OK); } ssl.rkey_free(server_public_key); TODO(" find a way to correctly dispose of garbage at end of buffer") /* There's some garbage here we don't care about */ } uint8_t client_random[SEC_RANDOM_SIZE]; memset(client_random, 0, sizeof(SEC_RANDOM_SIZE)); /* Generate a client random, and determine encryption keys */ gen->random(client_random, SEC_RANDOM_SIZE); ssl.rsa_encrypt(client_crypt_random, client_random, SEC_RANDOM_SIZE, server_public_key_len, modulus, exponent); rdp_sec_generate_keys(encrypt, decrypt, encrypt.sign_key, client_random, serverRandom, encryptionMethod); }
void emit(Stream & stream) { stream.out_uint16_le(this->userDataType); stream.out_uint16_le(this->length); }
//---------------------------------------------------------------------- // DumpCallback // // A callback function for the static DWARFDebugInfo::Parse() function // that gets called each time a compile unit header or debug information // entry is successfully parsed. // // This function dump DWARF information and obey recurse depth and // whether a single DIE is to be dumped (or all of the data). //---------------------------------------------------------------------- static dw_offset_t DumpCallback ( SymbolFileDWARF* dwarf2Data, DWARFCompileUnitSP& cu_sp, DWARFDebugInfoEntry* die, const dw_offset_t next_offset, const uint32_t curr_depth, void* userData ) { DumpInfo* dumpInfo = (DumpInfo*)userData; const DWARFCompileUnit* cu = cu_sp.get(); Stream *s = dumpInfo->strm; bool show_parents = s->GetFlags().Test(DWARFDebugInfo::eDumpFlag_ShowAncestors); if (die) { // Are we dumping everything? if (dumpInfo->die_offset == DW_INVALID_OFFSET) { // Yes we are dumping everything. Obey our recurse level though if (curr_depth < dumpInfo->recurse_depth) die->Dump(dwarf2Data, cu, *s, 0); } else { // We are dumping a specific DIE entry by offset if (dumpInfo->die_offset == die->GetOffset()) { // We found the DIE we were looking for, dump it! if (show_parents) { s->SetIndentLevel(0); const uint32_t num_ancestors = dumpInfo->ancestors.size(); if (num_ancestors > 0) { for (uint32_t i=0; i<num_ancestors-1; ++i) { dumpInfo->ancestors[i].Dump(dwarf2Data, cu, *s, 0); s->IndentMore(); } } } dumpInfo->found_depth = curr_depth; die->Dump(dwarf2Data, cu, *s, 0); // Note that we found the DIE we were looking for dumpInfo->found_die = true; // Since we are dumping a single DIE, if there are no children we are done! if (!die->HasChildren() || dumpInfo->recurse_depth == 0) return DW_INVALID_OFFSET; // Return an invalid address to end parsing } else if (dumpInfo->found_die) { // Are we done with all the children? if (curr_depth <= dumpInfo->found_depth) return DW_INVALID_OFFSET; // We have already found our DIE and are printing it's children. Obey // our recurse depth and return an invalid offset if we get done // dumping all the the children if (dumpInfo->recurse_depth == UINT32_MAX || curr_depth <= dumpInfo->found_depth + dumpInfo->recurse_depth) die->Dump(dwarf2Data, cu, *s, 0); } else if (dumpInfo->die_offset > die->GetOffset()) { if (show_parents) dumpInfo->ancestors.back() = *die; } } // Keep up with our indent level if (die->IsNULL()) { if (show_parents) dumpInfo->ancestors.pop_back(); if (curr_depth <= 1) return cu->GetNextCompileUnitOffset(); else s->IndentLess(); } else if (die->HasChildren()) { if (show_parents) { DWARFDebugInfoEntry null_die; dumpInfo->ancestors.push_back(null_die); } s->IndentMore(); } } else { if (cu == NULL) s->PutCString("NULL - cu"); // We have a compile unit, reset our indent level to zero just in case s->SetIndentLevel(0); // See if we are dumping everything? if (dumpInfo->die_offset == DW_INVALID_OFFSET) { // We are dumping everything cu->Dump(s); return cu->GetFirstDIEOffset(); // Return true to parse all DIEs in this Compile Unit } else { if (show_parents) { dumpInfo->ancestors.clear(); dumpInfo->ancestors.resize(1); } // We are dumping only a single DIE possibly with it's children and // we must find it's compile unit before we can dump it properly if (dumpInfo->die_offset < cu->GetFirstDIEOffset()) { // Not found, maybe the DIE offset provided wasn't correct? // *ostrm_ptr << "DIE at offset " << HEX32 << dumpInfo->die_offset << " was not found." << endl; return DW_INVALID_OFFSET; } else { // See if the DIE is in this compile unit? if (dumpInfo->die_offset < cu->GetNextCompileUnitOffset()) { // This DIE is in this compile unit! if (s->GetVerbose()) cu->Dump(s); // Dump the compile unit for the DIE in verbose mode return next_offset; // // We found our compile unit that contains our DIE, just skip to dumping the requested DIE... // return dumpInfo->die_offset; } else { // Skip to the next compile unit as the DIE isn't in the current one! return cu->GetNextCompileUnitOffset(); } } } } // Just return the current offset to parse the next CU or DIE entry return next_offset; }
void data_recving (MYSQL* conn, char * tablename, int nr_be) { int nr_exited = 0; int tag; int count = 0; // PacketPtr pack; int rank, eid, tid, data, finish, nr_record, mpi_rank, type, src_rank, dst_rank, sendsize, sendtype, recvsize, recvtype; int mpi_comm, mpi_tag; MRN::Network * net = GetNetwork(); unsigned pid; long long unsigned time; unsigned long time_s, time_us; char sql[2048]; char buffer[500]; char instance[40], metric[40]; char *ename = NULL; char *hostname = NULL; char *procdata = NULL; Communicator *comm = net->get_BroadcastCommunicator(); Stream *stream = net->new_Stream( comm, TFILTER_NULL, SFILTER_DONTWAIT ); stream->send( PROT_DATA, "%d", 0 ); printf_d("[MRNFE] recieving data...nr_exited is %d nr_be is %d\n",nr_exited,nr_be); if (mysql_autocommit (conn, 0) != 0) printf_d ("[MRNFE] %s\n", mysql_error(conn)); while( nr_exited != nr_be ) { PacketPtr pack; stream->recv( &tag, pack ); count ++; switch (tag) { case PROT_DATA: pack->unpack("%d %d %d %uld %s %d %s", &tid, &pid, &eid, &time, &hostname, &finish, &ename); char *sql_tmp; sql_tmp = (char *) calloc (sizeof (char *), 200); snprintf_d(sql_tmp, 200, "CALL insertdata ( -1,%d, \"%s\" , %d, \"%s\", 7,\"FFFFFFFF\", '%llu', %d );" , pid, hostname, eid, ename, time, finish); if (mysql_query (conn, sql_tmp)) printf_d ("[MRNFE] %s\n", mysql_error(conn)); free (sql_tmp); free (hostname); free (ename); hostname = NULL; ename = NULL; break; case PROT_MPIDATA: /*MPI wrapper trace 数据*/ pack->unpack("%d %ud %s %d %s %d %d %d %d %d %d %d %d %d %uld %d", &mpi_rank, &pid, &hostname, &eid, &ename, &type, &mpi_comm, &mpi_tag, &src_rank, &dst_rank, &sendsize, &sendtype, &recvsize, &recvtype, &time, &finish); #ifdef debug printf_d ("[DEBUG]:\tRecv_Data: %d %u %s %d %s %d %x %d %d %d %d %d %d %d %llu %d\n", mpi_rank, pid, hostname, eid, ename, type, mpi_comm, mpi_tag, src_rank, dst_rank, sendsize, sendtype, recvsize, recvtype, time, finish); #endif snprintf_d (sql, 2048,"CALL insertdata (%d, %u, \"%s\", %d, \"%s\", %d, \"%x\", %llu, %d);", mpi_rank, pid, hostname, eid, ename, type, mpi_comm, time, finish); #ifdef DEBUG printf_d ("[DEBUG]:\t%s\n", sql); #endif if (mysql_query (conn, sql)) { printf_d ("[MRNFE] %s\n", mysql_error(conn)); } if (type != 0) { snprintf_d (sql, 2048,"CALL insert_comm_data (%d, %u, \"%s\", %d, \"%s\", %d, %d, %d, %d, %d, %d, %d, %llu, %d);", mpi_rank, pid, hostname, eid, ename, mpi_tag, src_rank, dst_rank, sendsize, sendtype, recvsize, recvtype, time, finish); if (mysql_query (conn, sql)) { printf_d ("[MRNFE] %s\n", mysql_error(conn)); } } free (ename); free (hostname); ename = NULL; hostname = NULL; break; case PROT_PROC: /*proc数据*/ if(!use_proc) { printf_d ("[MRNFE] no proc!!! ignored\n"); break; } { pack->unpack("%ud %ud %s %d %s %ud", &time_s, &time_us, &hostname, &nr_record, &procdata, &pid ); //printf_d(" [DEBUG] %ld, %ld, %d %s\n", time_s, time_us, nr_record, procdata ); char *p = procdata; float fdata; for( int i = 0; i < nr_record; i++ ){ sscanf_d( p, "%s", buffer ); p+=strlen(buffer)+1; sscanf_d( buffer, "%[^#]#%[^#]#%f", instance, metric, &fdata ); snprintf_d(sql, 2048, "CALL insertproc( %ld, %ld, \"%s\", %d, \"%s\", \"%s\", '%f')" , time_s, time_us, hostname, pid, metric, instance, fdata); if (mysql_query (conn, sql)) { printf_d ("[MRNFE] %s\n", mysql_error(conn)); } //printf_d ("%s\n", sql); //mysql_query( conn, sql ); } free(procdata); free(hostname); procdata = hostname = NULL; } break; case PROT_PAPI: if (!use_papi) { printf_d ("[MRNFE] no papi!!! ignored\n"); break; } else { long long papi_data; char *papi_event; pack->unpack("%s %ud %d %s %s %ld %uld %d", &ename, &pid, &tid, &hostname, &papi_event, &papi_data, &time, &finish); snprintf_d (sql, 2048, "CALL insert_papi_data(\"%s\", %u, %d, \"%s\", \"%s\", %lld, %llu, %d);", ename, pid, tid, hostname, papi_event, papi_data, time, finish); if (mysql_query (conn, sql)) printf_d ("[MRNFE] %s\n", mysql_error(conn)); free (hostname); free (ename); free (papi_event); hostname = NULL; ename = NULL; papi_event = NULL; } break; case PROT_IO: char *io_data; long long unsigned stime, etime; pack->unpack ("%s %ud %d %s %s %uld %uld", &ename, &pid, &tid, &hostname, &io_data, &stime, &etime); snprintf_d (sql, 2048, "CALL insert_io_data(\"%s\", %u, %d, \"%s\", \"%s\", %llu, %llu);", ename, pid, tid, hostname, io_data, stime, etime); if (mysql_query (conn, sql)) printf_d ("[MRNFE] %s\n", mysql_error(conn)); free (hostname); free (ename); free (io_data); hostname = NULL; ename = NULL; io_data = NULL; break; case PROT_MPIRANK: /*MPI rank数据*/ pack->unpack("%d %d", &rank, &data); snprintf_d( sql, 2048, "update `%s_nodelist` set mpirank=%d where rank=%d", tablename, data, rank ); mysql_query( conn, sql ); break; case PROT_NODEDATA: /*MPI节点数据*/ pack->unpack ("%ud %d", &pid, &mpi_rank); snprintf_d (sql, 2048, "update `%s_nodelist` set mpirank=%d where pid=%u", tablename, mpi_rank, pid); mysql_query( conn, sql ); break; case PROT_HALT: /*发送停止*/ nr_exited ++ ; printf_d( "[DEBUG] %d Back-ends Halted\n", nr_exited ); break; default: break; } if (count % 10000 == 0) mysql_commit(conn); } FE::write_exiting_info(); }
bool Image::read(Stream stream) { BytesArray mem; mem = stream.process(); if (!stream.ok()) return false; FIMEMORY* fimem = FreeImage_OpenMemory(mem.raw(), mem.size()); if (!fimem) return false; FREE_IMAGE_FORMAT fiformat = FreeImage_GetFileTypeFromMemory(fimem); FIBITMAP* fibit = FreeImage_LoadFromMemory(fiformat, fimem); FreeImage_CloseMemory(fimem); if (!fibit) return false; //FIBITMAP* fitmp = fibit; //fibit = FreeImage_ConvertTo32Bits(fitmp); //FreeImage_Unload(fitmp); uint64 red_mask = FreeImage_GetRedMask(fibit); uint64 green_mask = FreeImage_GetGreenMask(fibit); uint64 blue_mask = FreeImage_GetBlueMask(fibit); uint64 alpha_mask = 0; PixelFormat tmpformat; tmpformat.setDepthBits(0); tmpformat.setStencilBits(0); tmpformat.setColorBitsFromMasks(&red_mask, &green_mask, &blue_mask, &alpha_mask); if (FreeImage_GetBPP(fibit) != tmpformat.bitsPerPixel()) { alpha_mask = ~(uint32)(red_mask | green_mask | blue_mask); tmpformat.setColorBitsFromMasks(&red_mask, &green_mask, &blue_mask, &alpha_mask); } format = TransferFormat(tmpformat.getRedBits(), tmpformat.getGreenBits(), tmpformat.getBlueBits(), tmpformat.getAlphaBits()); MIRROR_ASSERT(FreeImage_GetBPP(fibit) == format.bitsPerPixel(), "Conversion from FreeImage bitmap to Mirror bitmap failed!\nBits per pixel conversion from " "FreeImage color masks probably returned bad bits-per-channel values respectivly for red, green and blue channel, as" " stored inside PixelFormat structure - see PixelFormat::setColorBitsFromMasks for calculations!"); my_size = { FreeImage_GetWidth(fibit), FreeImage_GetHeight(fibit) }; uint32 req_bits = my_size.width()*my_size.height()*format.bitsPerPixel(); pixels.resize(PixelFormat::bitsToFullBytes(req_bits)); const uint32 pitch = FreeImage_GetPitch(fibit); const uint32 lineSize = FreeImage_GetLine(fibit); uint32 pixidx = 0; BYTE* line = FreeImage_GetBits(fibit); for (uint32 y = 0; y < my_size.height(); ++y, line += pitch) for (BYTE* pixel = line; pixel < line + lineSize; pixel += format.bytesPerPixel()) { pixels[pixidx++] = pixel[2]; //red pixels[pixidx++] = pixel[1]; //green pixels[pixidx++] = pixel[0]; //blue if (alpha_mask) pixels[pixidx++] = pixel[3]; //alpha } ////transfer pixels from FreeImage to our buffer as raw bits, should be in RGBA order thanks to our new color masks //FreeImage_ConvertToRawBits(pixels.raw(), fibit, format.bitsPerPixel()*my_size.width(), format.bitsPerPixel(), 0, 0, 0, TRUE); FreeImage_Unload(fibit); return true; }
void SimPersistSet::write( Stream& stream, U32 tabStop, U32 flags ) { if( ( flags & SelectedOnly ) && !isSelected() ) return; // If the selection is transient, we cannot really save it. // Just invoke the default SimObject::write and return. if( !getCanSave() ) { Con::errorf( "SimPersistSet::write - transient set being saved: %d:%s (%s)", getId(), getClassName(), getName() ); Parent::write( stream, tabStop, flags ); return; } // If there are unresolved PIDs, give resolving them one last // chance before writing out the set. if( !mUnresolvedPIDs.empty() ) resolvePIDs(); // Write the set out. stream.writeTabs( tabStop ); StringBuilder buffer; buffer.format( "new %s(%s", getClassName(), getName() ? getName() : "" ); // Write the persistent IDs of all child objects into the set's // object constructor so we see them passed back to us through // processArguments when the object gets read in. const U32 numChildren = size(); for( U32 i = 0; i < numChildren; ++ i ) { SimObject* child = at( i ); SimPersistID* pid = child->getPersistentId(); AssertWarn( pid != NULL, "SimPersistSet::write - object without pid in persistent selection!" ); if( !pid ) continue; buffer.append( ',' ); buffer.append( '"' ); buffer.append( pid->getUUID().toString() ); buffer.append( '"' ); } buffer.append( ") {\r\n" ); stream.write( buffer.length(), buffer.data() ); // Write our object fields. writeFields( stream, tabStop + 1 ); // Close our object definition. stream.writeTabs( tabStop ); stream.write( 4, "};\r\n" ); }
void CompilerStringTable::write(Stream &st) { st.write(totalLen); for(Entry *walk = list; walk; walk = walk->next) st.write(walk->len, walk->string); }
ErrorCode InitialObjectDescriptor::Read(Stream& stream) { ULONG nRead; uint32 verflags; nRead = stream.Read(&verflags, 4); verflags = BigEndian32(verflags); uint8 version = (uint8)(verflags>>24); BaseDescriptor descr; descr.Descend(stream); if (descr.m_tag == 0x01) // ObjectDescrTag { VERIFY(0); } else if (descr.m_tag == 0x02) // InitialObjectDescrTag { VERIFY(0); } else if (descr.m_tag == 0x10) // MP4_IOD_Tag { // System::IO::CBitStream bitstream(new System::IO::CByteStream(stream)); // System::IO::CBitStream32* pBitStream = &bitstream; uint16 word = ReadByte(stream)<<8; word |= ReadByte(stream); // stream->Read(&word, 2); // word = BigEndian16(word); m_ObjectDescriptorID = word >> 6;//pBitStream->getnbits(10); int bURLFlag = (word>>5) & 1;//pBitStream->getbit();// URL_Flag; int includeInlineProfileLevelFlag = (word>>4) & 1;//pBitStream->getbit(); int reserved = word & 15;//pBitStream->getnbits(4); // reserved=0b1111; ASSERT(reserved == 0xf); if (bURLFlag) { uint8 URLlength; //= pBitStream->getnbits(8);// URLlength; //bit(8) URLstring[URLlength]; ASSERT(0); } else { uint8 ODProfileLevelIndication = ReadByte(stream); uint8 sceneProfileLevelIndication = ReadByte(stream); uint8 audioProfileLevelIndication = ReadByte(stream); uint8 visualProfileLevelIndication = ReadByte(stream); uint8 graphicsProfileLevelIndication = ReadByte(stream); while (descr.More(stream)) { BaseDescriptor descr2; descr2.Descend(stream); if (descr2.m_tag == 0x0E) // ES_ID_IncTag { uint32 Track_ID; stream.Read(&Track_ID, 4);//= pBitStream->getnbits(32); Track_ID = BigEndian32(Track_ID); m_trackID.Add(Track_ID); } else { MessageBeep(-1); } descr2.Ascend(stream); } /* ES_Descriptor esDescr[1 .. 255]; OCI_Descriptor ociDescr[0 .. 255]; IPMP_DescriptorPointer ipmpDescrPtr[0 .. 255]; */ } //ExtensionDescriptor extDescr[0 .. 255]; }
void CompilerFloatTable::write(Stream &st) { st.write(count); for(Entry *walk = list; walk; walk = walk->next) st.write(walk->val); }
inline void unpack( Stream& s, fc::time_point& tp, uint32_t ) { try { uint64_t usec; s.read( (char*)&usec, sizeof(usec) ); tp = fc::time_point() + fc::microseconds(usec); } FC_RETHROW_EXCEPTIONS( warn, "" ) }
Error ClangExpressionParser::DisassembleFunction (Stream &stream, ExecutionContext &exe_ctx, RecordingMemoryManager *jit_memory_manager) { lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); const char *name = m_expr.FunctionName(); Error ret; ret.Clear(); lldb::addr_t func_local_addr = LLDB_INVALID_ADDRESS; lldb::addr_t func_remote_addr = LLDB_INVALID_ADDRESS; std::vector<JittedFunction>::iterator pos, end = m_jitted_functions.end(); for (pos = m_jitted_functions.begin(); pos < end; pos++) { if (strstr(pos->m_name.c_str(), name)) { func_local_addr = pos->m_local_addr; func_remote_addr = pos->m_remote_addr; } } if (func_local_addr == LLDB_INVALID_ADDRESS) { ret.SetErrorToGenericError(); ret.SetErrorStringWithFormat("Couldn't find function %s for disassembly", name); return ret; } if (log) log->Printf("Found function, has local address 0x%llx and remote address 0x%llx", (uint64_t)func_local_addr, (uint64_t)func_remote_addr); std::pair <lldb::addr_t, lldb::addr_t> func_range; func_range = jit_memory_manager->GetRemoteRangeForLocal(func_local_addr); if (func_range.first == 0 && func_range.second == 0) { ret.SetErrorToGenericError(); ret.SetErrorStringWithFormat("Couldn't find code range for function %s", name); return ret; } if (log) log->Printf("Function's code range is [0x%llx+0x%llx]", func_range.first, func_range.second); Target *target = exe_ctx.GetTargetPtr(); if (!target) { ret.SetErrorToGenericError(); ret.SetErrorString("Couldn't find the target"); } lldb::DataBufferSP buffer_sp(new DataBufferHeap(func_range.second, 0)); Process *process = exe_ctx.GetProcessPtr(); Error err; process->ReadMemory(func_remote_addr, buffer_sp->GetBytes(), buffer_sp->GetByteSize(), err); if (!err.Success()) { ret.SetErrorToGenericError(); ret.SetErrorStringWithFormat("Couldn't read from process: %s", err.AsCString("unknown error")); return ret; } ArchSpec arch(target->GetArchitecture()); Disassembler *disassembler = Disassembler::FindPlugin(arch, NULL); if (disassembler == NULL) { ret.SetErrorToGenericError(); ret.SetErrorStringWithFormat("Unable to find disassembler plug-in for %s architecture.", arch.GetArchitectureName()); return ret; } if (!process) { ret.SetErrorToGenericError(); ret.SetErrorString("Couldn't find the process"); return ret; } DataExtractor extractor(buffer_sp, process->GetByteOrder(), target->GetArchitecture().GetAddressByteSize()); if (log) { log->Printf("Function data has contents:"); extractor.PutToLog (log.get(), 0, extractor.GetByteSize(), func_remote_addr, 16, DataExtractor::TypeUInt8); } disassembler->DecodeInstructions (Address (func_remote_addr), extractor, 0, UINT32_MAX, false); InstructionList &instruction_list = disassembler->GetInstructionList(); const uint32_t max_opcode_byte_size = instruction_list.GetMaxOpcocdeByteSize(); for (uint32_t instruction_index = 0, num_instructions = instruction_list.GetSize(); instruction_index < num_instructions; ++instruction_index) { Instruction *instruction = instruction_list.GetInstructionAtIndex(instruction_index).get(); instruction->Dump (&stream, max_opcode_byte_size, true, true, &exe_ctx); stream.PutChar('\n'); } return ret; }
inline void unpack( Stream& s, fc::microseconds& usec, uint32_t ) { try { uint64_t usec_as_int64; s.read( (char*)&usec_as_int64, sizeof(usec_as_int64) ); usec = fc::microseconds(usec_as_int64); } FC_RETHROW_EXCEPTIONS( warn, "" ) }
void ShaderGenPrinterGLSL::printPixelShaderCloser( Stream& stream ) { const char *closer = " OUT_FragColor0 = col;\r\n}\r\n"; stream.write( dStrlen(closer), closer ); }
inline void unpack( Stream& s, fc::int_array<T,N>& v, uint32_t ) { try { s.read( (char*)&v.data[0], N*sizeof(T) ); } FC_RETHROW_EXCEPTIONS( warn, "fc::int_array<type,length>", ("type",fc::get_typename<T>::name())("length",N) ) }
void ShaderGenPrinterGLSL::printLine(Stream& stream, const String& line) { stream.write(line.length(), line.c_str()); const char* end = "\r\n"; stream.write(dStrlen(end), end); }
inline void unpack( Stream& s, fc::time_point_sec& tp, uint32_t ) { try { uint32_t sec; s.read( (char*)&sec, sizeof(sec) ); tp = fc::time_point() + fc::seconds(sec); } FC_RETHROW_EXCEPTIONS( warn, "" ) }
void ThreadPlanAssemblyTracer::Log () { Stream *stream = GetLogStream (); if (!stream) return; RegisterContext *reg_ctx = m_thread.GetRegisterContext().get(); lldb::addr_t pc = reg_ctx->GetPC(); ProcessSP process_sp (m_thread.GetProcess()); Address pc_addr; bool addr_valid = false; uint8_t buffer[16] = {0}; // Must be big enough for any single instruction addr_valid = process_sp->GetTarget().GetSectionLoadList().ResolveLoadAddress (pc, pc_addr); pc_addr.Dump(stream, &m_thread, Address::DumpStyleResolvedDescription, Address::DumpStyleModuleWithFileAddress); stream->PutCString (" "); Disassembler *disassembler = GetDisassembler(); if (disassembler) { Error err; process_sp->ReadMemory(pc, buffer, sizeof(buffer), err); if (err.Success()) { DataExtractor extractor(buffer, sizeof(buffer), process_sp->GetByteOrder(), process_sp->GetAddressByteSize()); if (addr_valid) disassembler->DecodeInstructions (pc_addr, extractor, 0, 1, false); else disassembler->DecodeInstructions (Address (pc), extractor, 0, 1, false); InstructionList &instruction_list = disassembler->GetInstructionList(); const uint32_t max_opcode_byte_size = instruction_list.GetMaxOpcocdeByteSize(); if (instruction_list.GetSize()) { const bool show_bytes = true; const bool show_address = true; Instruction *instruction = instruction_list.GetInstructionAtIndex(0).get(); instruction->Dump (stream, max_opcode_byte_size, show_address, show_bytes, NULL); } } } const ABI *abi = process_sp->GetABI().get(); TypeFromUser intptr_type = GetIntPointerType(); if (abi && intptr_type.IsValid()) { ValueList value_list; const int num_args = 1; for (int arg_index = 0; arg_index < num_args; ++arg_index) { Value value; value.SetValueType (Value::eValueTypeScalar); value.SetContext (Value::eContextTypeClangType, intptr_type.GetOpaqueQualType()); value_list.PushValue (value); } if (abi->GetArgumentValues (m_thread, value_list)) { for (int arg_index = 0; arg_index < num_args; ++arg_index) { stream->Printf("\n\targ[%d]=%llx", arg_index, value_list.GetValueAtIndex(arg_index)->GetScalar().ULongLong()); if (arg_index + 1 < num_args) stream->PutCString (", "); } } } RegisterValue reg_value; for (uint32_t reg_num = 0, num_registers = reg_ctx->GetRegisterCount(); reg_num < num_registers; ++reg_num) { const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoAtIndex(reg_num); if (reg_ctx->ReadRegister (reg_info, reg_value)) { assert (reg_num < m_register_values.size()); if (m_register_values[reg_num].GetType() == RegisterValue::eTypeInvalid || reg_value != m_register_values[reg_num]) { if (reg_value.GetType() != RegisterValue::eTypeInvalid) { stream->PutCString ("\n\t"); reg_value.Dump(stream, reg_info, true, false, eFormatDefault); } } m_register_values[reg_num] = reg_value; } } stream->EOL(); stream->Flush(); }
void AABB::SerializeTypeId(Stream & stream) const { stream.Save("AABB"); }
void ValueObjectRegister::GetExpressionPath (Stream &s, bool qualify_cxx_base_classes, GetExpressionPathFormat epformat) { s.Printf("$%s", m_reg_info.name); }